@lacneu/atrium 0.55.3 → 0.55.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/assets/{AccessTab-C31jlbg9.js → AccessTab-BlAZu92G.js} +1 -1
  2. package/dist/assets/{AdvancedFilter-Cqqt3aQy.js → AdvancedFilter-gE4hTfw8.js} +1 -1
  3. package/dist/assets/{AgentFilesTab-hoV2OJkH.js → AgentFilesTab-DXmwR5XT.js} +1 -1
  4. package/dist/assets/{AnomaliesTab-HNlBWX4H.js → AnomaliesTab-BcuZ6-OT.js} +1 -1
  5. package/dist/assets/{AuditTab-BDkuGhWd.js → AuditTab-C-XOYh_i.js} +1 -1
  6. package/dist/assets/{BridgeTab-7Gp-lSm8.js → BridgeTab-DJMBid3T.js} +1 -1
  7. package/dist/assets/{ChatDefaultsTab-CuRfo1OD.js → ChatDefaultsTab-BVfKA1sx.js} +1 -1
  8. package/dist/assets/{DataTableShell-O-bA35dG.js → DataTableShell-CcVtwrRQ.js} +1 -1
  9. package/dist/assets/{DetailChips-F3RMiEWW.js → DetailChips-CN8LrgGO.js} +1 -1
  10. package/dist/assets/{FeedbacksTab-n6fND_d8.js → FeedbacksTab-1CFUrJgw.js} +1 -1
  11. package/dist/assets/{FieldLabel-C2HKtml6.js → FieldLabel-elWVqmbc.js} +1 -1
  12. package/dist/assets/{FilesTab-ClwXf69-.js → FilesTab-DMG5NM2r.js} +1 -1
  13. package/dist/assets/{FilterBar-CQBSm0gy.js → FilterBar-CGBz7_qR.js} +1 -1
  14. package/dist/assets/{GroupsTab-By9wK7Xb.js → GroupsTab-4IxYHQdJ.js} +1 -1
  15. package/dist/assets/{InstancesTab-F8EFka-Z.js → InstancesTab-CBZ2j5zg.js} +1 -1
  16. package/dist/assets/{IntegrationsTab-DyjOkGyX.js → IntegrationsTab-D6160dRg.js} +1 -1
  17. package/dist/assets/{KpiTab-D8YvkmYo.js → KpiTab-ChT2wJK3.js} +1 -1
  18. package/dist/assets/{PreferencesTab-CVf28USb.js → PreferencesTab-G29WsO8x.js} +1 -1
  19. package/dist/assets/{PromptInjectionsTab-BnOXHYex.js → PromptInjectionsTab-B3zdXItl.js} +1 -1
  20. package/dist/assets/{RolesTab-HPXx0Dh3.js → RolesTab-DfTKsa9B.js} +1 -1
  21. package/dist/assets/{ScheduledTab-CMFb6jsp.js → ScheduledTab-CwWrkY40.js} +1 -1
  22. package/dist/assets/{ServiceAccountsTab-CkbSZ_vx.js → ServiceAccountsTab-DgxZwEZb.js} +1 -1
  23. package/dist/assets/{SubAgentReportsTab-BhJ2Xi_p.js → SubAgentReportsTab-BdMPMN8f.js} +1 -1
  24. package/dist/assets/{ThemeShowroom-BHaHjfmV.js → ThemeShowroom-CqkJyig0.js} +1 -1
  25. package/dist/assets/{TimeRangePicker-CV_IaaKP.js → TimeRangePicker-CxfILbJE.js} +1 -1
  26. package/dist/assets/{TracesTab-ChOCnxTO.js → TracesTab-ru8pnxnK.js} +1 -1
  27. package/dist/assets/{UsersTab-CKat_1Zz.js → UsersTab-DrEOcHMC.js} +1 -1
  28. package/dist/assets/{VoiceTab-Kw-KPRnH.js → VoiceTab-Bfv15iGQ.js} +1 -1
  29. package/dist/assets/{highlighted-body-OFNGDK62-dkUlu-Yf.js → highlighted-body-OFNGDK62-DNCL1qt_.js} +1 -1
  30. package/dist/assets/{index-DZcxHX-q.js → index-CnNzzVmB.js} +9 -9
  31. package/dist/assets/mermaid-GHXKKRXX-C_oANOwV.js +1 -0
  32. package/dist/assets/{pdf-XVS5_Y6b.js → pdf-BlJTUgBI.js} +1 -1
  33. package/dist/assets/{tabs-CXQdq7rn.js → tabs-BHnM2BeW.js} +1 -1
  34. package/dist/index.html +1 -1
  35. package/package.json +1 -1
  36. package/dist/assets/mermaid-GHXKKRXX-DWJbe-FR.js +0 -1
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ao as r,Cw as i,Do as a,E as o,Eo as s,Mo as c,Oo as l,Sw as u,To as d,Tw as f,_P as p,_w as m,bw as h,fw as g,gw as _,hP as v,hw as y,jo as b,ko as x,mw as S,pw as C,vP as w,vw as T,wo as E,ww as D,xw as O,yw as k}from"./dist-BKXYNjW7.js";import{t as A}from"./button-CdHluvSK.js";import{dt as j,ft as M,m as N}from"./index-DZcxHX-q.js";var P=t(e(),1),F=n();function I(){let e=w(o.integrations.status.status,{}),t=p(o.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:f()});let s=n,l=(e,t,n)=>a({...s,[e]:{...s[e],[t]:n}}),d=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[D(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,u()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:k()}),note:T(),children:[(0,F.jsx)(R,{label:_(),children:(0,F.jsx)(M,{value:s.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>l(`langfuse`,`host`,e.target.value),onBlur:()=>d(`langfuse`,{host:s.langfuse.host??``})})}),(0,F.jsx)(z,{label:g(),checked:s.langfuse.enabled??!0,onChange:e=>{l(`langfuse`,`enabled`,e),d(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:k()}),note:m(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:s.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>l(`opik`,`baseUrl`,e.target.value),onBlur:()=>d(`opik`,{baseUrl:s.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:S(),children:(0,F.jsx)(M,{value:s.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||C(),onChange:e=>l(`opik`,`workspace`,e.target.value),onBlur:()=>d(`opik`,{workspace:s.opik.workspace??``})})}),(0,F.jsx)(z,{label:g(),checked:s.opik.enabled??!0,onChange:e=>{l(`opik`,`enabled`,e),d(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:c()}),note:b(),children:[(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:s.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>l(`otlp`,`endpoint`,e.target.value),onBlur:()=>d(`otlp`,{endpoint:s.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:g(),checked:s.otlp.enabled??!0,onChange:e=>{l(`otlp`,`enabled`,e),d(`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=v(o.integrations.otlpSecret.setOtlpHeaders),n=p(o.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[c,u]=(0,P.useState)(null),[f,m]=(0,P.useState)(!1),h=async()=>{m(!0),u(null);try{await t({headersJson:r}),i(``)}catch(e){u(e instanceof Error?e.message:String(e))}finally{m(!1)}};return(0,F.jsxs)(R,{label:x(),children:[(0,F.jsx)(M,{value:r,placeholder:e?l():a(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void h(),children:s()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:d()}):null]}),c?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:c}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:E()})]})}export{I as IntegrationsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ao as r,Cw as i,Do as a,E as o,Eo as s,Mo as c,Oo as l,Sw as u,To as d,Tw as f,_P as p,_w as m,bw as h,fw as g,gw as _,hP as v,hw as y,jo as b,ko as x,mw as S,pw as C,vP as w,vw as T,wo as E,ww as D,xw as O,yw as k}from"./dist-BKXYNjW7.js";import{t as A}from"./button-CdHluvSK.js";import{dt as j,ft as M,m as N}from"./index-CnNzzVmB.js";var P=t(e(),1),F=n();function I(){let e=w(o.integrations.status.status,{}),t=p(o.admin.setIntegrationConfig),[n,a]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&a(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:f()});let s=n,l=(e,t,n)=>a({...s,[e]:{...s[e],[t]:n}}),d=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[D(),` `,(0,F.jsx)(`strong`,{children:i()}),` `,u()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:k()}),note:T(),children:[(0,F.jsx)(R,{label:_(),children:(0,F.jsx)(M,{value:s.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>l(`langfuse`,`host`,e.target.value),onBlur:()=>d(`langfuse`,{host:s.langfuse.host??``})})}),(0,F.jsx)(z,{label:g(),checked:s.langfuse.enabled??!0,onChange:e=>{l(`langfuse`,`enabled`,e),d(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:k()}),note:m(),children:[(0,F.jsx)(R,{label:y(),children:(0,F.jsx)(M,{value:s.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>l(`opik`,`baseUrl`,e.target.value),onBlur:()=>d(`opik`,{baseUrl:s.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:S(),children:(0,F.jsx)(M,{value:s.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||C(),onChange:e=>l(`opik`,`workspace`,e.target.value),onBlur:()=>d(`opik`,{workspace:s.opik.workspace??``})})}),(0,F.jsx)(z,{label:g(),checked:s.opik.enabled??!0,onChange:e=>{l(`opik`,`enabled`,e),d(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(j,{variant:`secondary`,children:O()}):(0,F.jsx)(j,{variant:`outline`,children:h()}):(0,F.jsx)(j,{variant:`outline`,children:c()}),note:b(),children:[(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:s.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>l(`otlp`,`endpoint`,e.target.value),onBlur:()=>d(`otlp`,{endpoint:s.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:g(),checked:s.otlp.enabled??!0,onChange:e=>{l(`otlp`,`enabled`,e),d(`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=v(o.integrations.otlpSecret.setOtlpHeaders),n=p(o.integrations.otlpSecret.clearOtlpHeaders),[r,i]=(0,P.useState)(``),[c,u]=(0,P.useState)(null),[f,m]=(0,P.useState)(!1),h=async()=>{m(!0),u(null);try{await t({headersJson:r}),i(``)}catch(e){u(e instanceof Error?e.message:String(e))}finally{m(!1)}};return(0,F.jsxs)(R,{label:x(),children:[(0,F.jsx)(M,{value:r,placeholder:e?l():a(),onChange:e=>i(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void h(),children:s()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:d()}):null]}),c?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:c}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:E()})]})}export{I as IntegrationsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,E as i,Gm as a,Jm as o,Km as s,NT as c,Qm as l,Qw as u,Um as d,Wm as f,Xm as p,Ym as m,Zm as h,Zw as g,aT as _,cT as v,eh as y,nh as b,oT as x,qm as S,sT as C,th as w,vP as T}from"./dist-BKXYNjW7.js";import{i as E,nn as D,o as ee,r as te,rn as ne,wt as re}from"./index-DZcxHX-q.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-AXe34vGw.js";import{n as N,t as P}from"./TimeRangePicker-CV_IaaKP.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=T(i.me.getMe,{host:re})?.permissions?.includes(`traces.read`)??!1,t=T(i.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,L).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:c()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:v()}),(0,I.jsx)(j,{children:x()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,I.jsx)(B,{series:n})})]})]})}function B({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{style:{color:`var(--primary)`},children:[g(),` p50 `,R(s.cP50),` `,C()]}),(0,I.jsxs)(`span`,{children:[u(),` p50 `,R(s.aP50),` `,C()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":v(),children:[(0,I.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:b(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:w(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:y(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:r(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],H=V.length,U=[`API`,`OpenClaw`,`Chat`,`Assistant`],W=1e3,G=36e5;function K(e,t){let n=Math.max(1,Math.ceil((t-e)/G)),r=Math.min(n*H,W);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/H))}}function q(){let e=ne({from:`/settings/kpi`}),t=D({from:`/settings/kpi`}),n=E(e.from,e.to,te,`now`),r=e=>void t({search:t=>({...t,...ee(e)})}),{from:a,to:s}=N(n),{rowLimit:c,buckets:l}=K(a,s),u=T(i.kpi.listKpis,{limit:c,filter:{from:a,to:s}}),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]),f=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[p(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return u===void 0?(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}):u.length===0?(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:S()})]}):(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,I.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,I.jsx)(Y,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function J({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(P,{value:e,onChange:t})})}function Y({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(ae,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:s({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:f({count:t.length})})]})]})]})}var X=240,Z=48,ie=1;function ae({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.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-ie,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":d({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,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.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{q as KpiTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$m as r,E as i,Gm as a,Jm as o,Km as s,NT as c,Qm as l,Qw as u,Um as d,Wm as f,Xm as p,Ym as m,Zm as h,Zw as g,aT as _,cT as v,eh as y,nh as b,oT as x,qm as S,sT as C,th as w,vP as T}from"./dist-BKXYNjW7.js";import{i as E,nn as D,o as ee,r as te,rn as ne,wt as re}from"./index-CnNzzVmB.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-AXe34vGw.js";import{n as N,t as P}from"./TimeRangePicker-CxfILbJE.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=T(i.me.getMe,{host:re})?.permissions?.includes(`traces.read`)??!1,t=T(i.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,L).reverse().map(e=>({startedAt:e.startedAt,cP50:e.rollup?.cP50,aP50:e.rollup?.aP50})):[],[t]);return t===void 0?null:(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:c()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:v()}),(0,I.jsx)(j,{children:x()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):(0,I.jsx)(B,{series:n})})]})]})}function B({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),r=Math.max(1,...t,...n),i=t=>6+t*468/(e.length-1),a=e=>74-e*68/r,o=e=>e.map((e,t)=>`${t===0?`M`:`L`}${i(t).toFixed(1)},${a(e).toFixed(1)}`).join(` `),s=e[e.length-1];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsxs)(`div`,{className:`flex gap-3 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{style:{color:`var(--primary)`},children:[g(),` p50 `,R(s.cP50),` `,C()]}),(0,I.jsxs)(`span`,{children:[u(),` p50 `,R(s.aP50),` `,C()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":v(),children:[(0,I.jsx)(`path`,{d:o(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:o(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:b(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:w(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:y(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:r(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:h(),unit:`/h`,group:`Assistant`,isError:!0}],H=V.length,U=[`API`,`OpenClaw`,`Chat`,`Assistant`],W=1e3,G=36e5;function K(e,t){let n=Math.max(1,Math.ceil((t-e)/G)),r=Math.min(n*H,W);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/H))}}function q(){let e=ne({from:`/settings/kpi`}),t=D({from:`/settings/kpi`}),n=E(e.from,e.to,te,`now`),r=e=>void t({search:t=>({...t,...ee(e)})}),{from:a,to:s}=N(n),{rowLimit:c,buckets:l}=K(a,s),u=T(i.kpi.listKpis,{limit:c,filter:{from:a,to:s}}),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]),f=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[p(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return u===void 0?(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:o()})]}):u.length===0?(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:S()})]}):(0,I.jsxs)(I.Fragment,{children:[f,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(d.get(e.metric)??[]).length>0)?(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,I.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,I.jsx)(Y,{config:e,series:d.get(e.metric)??[]},e.metric))})]},e):null})]})}function J({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(P,{value:e,onChange:t})})}function Y({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(ae,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:s({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:a()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:f({count:t.length})})]})]})]})}var X=240,Z=48,ie=1;function ae({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.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-ie,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":d({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,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.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{q as KpiTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$k as i,A as a,Ak as o,BN as s,Bk as c,Ck as l,Dk as u,E as d,Ek as f,F as p,Fk as ee,G as m,GN as te,Gk as ne,HN as re,Hk as ie,I as ae,Ik as oe,JN as se,Jk as ce,KN as le,Kk as ue,L as de,Lk as fe,M as pe,Mk as me,N as he,Nk as ge,Ok as h,P as _e,Pk as g,QN as _,Qk as v,RN as y,Rk as b,Sk as x,Tk as S,UN as C,Uk as w,VN as T,Vk as E,WN as D,Wk as O,X as k,XN as A,Xk as j,YN as M,Yk as N,Z as P,ZN as F,Zk as I,_P as L,_k as ve,bk as ye,eA as be,eP as xe,gk as Se,hS as Ce,hk as we,iP as Te,j as Ee,jk as De,kk as Oe,lP as ke,n as R,qN as Ae,qk as je,tP as Me,vP as z,vk as Ne,wk as B,xk as Pe,yk as Fe,zN as Ie,zk as Le}from"./dist-BKXYNjW7.js";import{t as V}from"./button-CdHluvSK.js";import{C as H,Ct as Re,H as ze,S as Be,St as Ve,T as He,dt as U,ft as W,j as Ue,m as G,t as We,w as Ge,wt as K,x as Ke,xt as qe}from"./index-DZcxHX-q.js";import{t as Je}from"./localePickerView-C2RmOS86.js";var q=t(e(),1),J=n();function Ye({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:()=>be()},{id:`composer`,label:()=>i()},{id:`sidebar`,label:()=>v()},{id:`notifications`,label:()=>ee()},{id:`other`,label:()=>I()}],X={showSource:{category:`messages`,label:()=>j(),help:()=>N()},showReport:{category:`messages`,label:()=>ce(),help:()=>je()},copyAssistant:{category:`messages`,label:()=>ue()},copyUser:{category:`messages`,label:()=>ne()},showDelete:{category:`messages`,label:()=>O()},showTools:{category:`messages`,label:()=>w(),help:()=>ie()},voiceInput:{category:`composer`,label:()=>E(),help:()=>c()},showUsage:{category:`composer`,label:()=>Le(),help:()=>b()},autoReadAloud:{category:`composer`,label:()=>P(),help:()=>k()},showChatAge:{category:`sidebar`,label:()=>fe(),help:()=>oe()},notifSound:{category:`notifications`,label:()=>g(),help:()=>ge()},notifSystem:{category:`notifications`,label:()=>me(),help:()=>De()},replySound:{category:`notifications`,label:()=>o(),help:()=>Oe()}};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 Xe=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],Ze={voiceInput:`voiceInput`};function Qe(e){return Xe.includes(e)}function $(e){return e===`admin`}function $e(e){return e===!0?`on`:e===!1?`off`:`inherit`}function et(e){return e===`on`?!0:e===`off`?!1:null}function tt(e){return Qe(e)?Ze[e]:void 0}var nt={voiceInput:()=>Fe()};function rt({prefKey:e,ui:t}){let n=L(d.admin.setUiPrefDefault),r=L(d.admin.setFeatureEnabled),i=tt(e),a=i?nt[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:l()}),(0,J.jsxs)(Ke,{value:$e(t.defaults[e]),onValueChange:t=>void n({key:e,value:et(t)}),children:[(0,J.jsx)(Ge,{size:`sm`,className:`w-36`,children:(0,J.jsx)(He,{})}),(0,J.jsxs)(Be,{children:[(0,J.jsx)(H,{value:`on`,children:ve()}),(0,J.jsx)(H,{value:`off`,children:Se()}),(0,J.jsx)(H,{value:`inherit`,children:we()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(G,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":x()}),x()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function it({current:e,enabled:t}){let n=L(d.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(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=Ve(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!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:[de(),e?(0,J.jsx)(U,{variant:`secondary`,children:Re(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?_e():r?p():ae()})]}),(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:a()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?Ee():e?pe():he()})]})]})}function at(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=z(d.me.getMe,{host:K}),a=i?.ui,o=$(i?.role)&&n,s=L(d.me.setUiPref).withOptimisticUpdate(Ue),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)(G,{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:Pe()}),(0,J.jsx)(`p`,{children:ye()}),(0,J.jsx)(`p`,{children:Ne()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:h(),"aria-label":h(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:u()}):(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)(U,{variant:`outline`,children:f()}):l?(0,J.jsx)(U,{variant:`secondary`,children:m()}):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:S()}):null,(0,J.jsx)(Ye,{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)(rt,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(it,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:ke()})}var ot={sm:()=>C(),md:()=>re(),lg:()=>T(),xl:()=>s()};function st(){let e=z(d.me.getMe,{host:K}),t=L(d.me.setLocale),n=L(d.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(d.me.getMe,{host:K});n&&e.setQuery(d.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=L(d.me.setMyName),a=ze(),o=e?.locale??`default`,s=e?.name??``,[c,l]=(0,q.useState)(null),u=c??s,f=u.trim()!==s.trim();async function p(){try{await i({name:u}),l(null),a.success(F())}catch(e){a.error(A(),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:Me()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:xe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:u,maxLength:120,placeholder:r(),onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),p())}}),(0,J.jsx)(V,{size:`sm`,disabled:!f,onClick:()=>void p(),children:Ce()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,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:M()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:se()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[Je().map(e=>(0,J.jsx)(V,{variant:o===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:o==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:Te()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(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:te()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:We.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void n({scale:t}),children:ot[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(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:Ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:y()})]}),(0,J.jsx)(at,{})]})]})}export{st as PreferencesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$N as r,$k as i,A as a,Ak as o,BN as s,Bk as c,Ck as l,Dk as u,E as d,Ek as f,F as p,Fk as ee,G as m,GN as te,Gk as ne,HN as re,Hk as ie,I as ae,Ik as oe,JN as se,Jk as ce,KN as le,Kk as ue,L as de,Lk as fe,M as pe,Mk as me,N as he,Nk as ge,Ok as h,P as _e,Pk as g,QN as _,Qk as v,RN as y,Rk as b,Sk as x,Tk as S,UN as C,Uk as w,VN as T,Vk as E,WN as D,Wk as O,X as k,XN as A,Xk as j,YN as M,Yk as N,Z as P,ZN as F,Zk as I,_P as L,_k as ve,bk as ye,eA as be,eP as xe,gk as Se,hS as Ce,hk as we,iP as Te,j as Ee,jk as De,kk as Oe,lP as ke,n as R,qN as Ae,qk as je,tP as Me,vP as z,vk as Ne,wk as B,xk as Pe,yk as Fe,zN as Ie,zk as Le}from"./dist-BKXYNjW7.js";import{t as V}from"./button-CdHluvSK.js";import{C as H,Ct as Re,H as ze,S as Be,St as Ve,T as He,dt as U,ft as W,j as Ue,m as G,t as We,w as Ge,wt as K,x as Ke,xt as qe}from"./index-CnNzzVmB.js";import{t as Je}from"./localePickerView-C2RmOS86.js";var q=t(e(),1),J=n();function Ye({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:()=>be()},{id:`composer`,label:()=>i()},{id:`sidebar`,label:()=>v()},{id:`notifications`,label:()=>ee()},{id:`other`,label:()=>I()}],X={showSource:{category:`messages`,label:()=>j(),help:()=>N()},showReport:{category:`messages`,label:()=>ce(),help:()=>je()},copyAssistant:{category:`messages`,label:()=>ue()},copyUser:{category:`messages`,label:()=>ne()},showDelete:{category:`messages`,label:()=>O()},showTools:{category:`messages`,label:()=>w(),help:()=>ie()},voiceInput:{category:`composer`,label:()=>E(),help:()=>c()},showUsage:{category:`composer`,label:()=>Le(),help:()=>b()},autoReadAloud:{category:`composer`,label:()=>P(),help:()=>k()},showChatAge:{category:`sidebar`,label:()=>fe(),help:()=>oe()},notifSound:{category:`notifications`,label:()=>g(),help:()=>ge()},notifSystem:{category:`notifications`,label:()=>me(),help:()=>De()},replySound:{category:`notifications`,label:()=>o(),help:()=>Oe()}};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 Xe=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],Ze={voiceInput:`voiceInput`};function Qe(e){return Xe.includes(e)}function $(e){return e===`admin`}function $e(e){return e===!0?`on`:e===!1?`off`:`inherit`}function et(e){return e===`on`?!0:e===`off`?!1:null}function tt(e){return Qe(e)?Ze[e]:void 0}var nt={voiceInput:()=>Fe()};function rt({prefKey:e,ui:t}){let n=L(d.admin.setUiPrefDefault),r=L(d.admin.setFeatureEnabled),i=tt(e),a=i?nt[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:l()}),(0,J.jsxs)(Ke,{value:$e(t.defaults[e]),onValueChange:t=>void n({key:e,value:et(t)}),children:[(0,J.jsx)(Ge,{size:`sm`,className:`w-36`,children:(0,J.jsx)(He,{})}),(0,J.jsxs)(Be,{children:[(0,J.jsx)(H,{value:`on`,children:ve()}),(0,J.jsx)(H,{value:`off`,children:Se()}),(0,J.jsx)(H,{value:`inherit`,children:we()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(G,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":x()}),x()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function it({current:e,enabled:t}){let n=L(d.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[o,s]=(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=Ve(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(s(!0),window.setTimeout(()=>s(!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:[de(),e?(0,J.jsx)(U,{variant:`secondary`,children:Re(e,qe())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:o?_e():r?p():ae()})]}),(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:a()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?Ee():e?pe():he()})]})]})}function at(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=z(d.me.getMe,{host:K}),a=i?.ui,o=$(i?.role)&&n,s=L(d.me.setUiPref).withOptimisticUpdate(Ue),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)(G,{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:Pe()}),(0,J.jsx)(`p`,{children:ye()}),(0,J.jsx)(`p`,{children:Ne()})]}):null,(0,J.jsx)(W,{value:e,onChange:e=>t(e.target.value),placeholder:h(),"aria-label":h(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:u()}):(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)(U,{variant:`outline`,children:f()}):l?(0,J.jsx)(U,{variant:`secondary`,children:m()}):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:S()}):null,(0,J.jsx)(Ye,{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)(rt,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(it,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:ke()})}var ot={sm:()=>C(),md:()=>re(),lg:()=>T(),xl:()=>s()};function st(){let e=z(d.me.getMe,{host:K}),t=L(d.me.setLocale),n=L(d.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(d.me.getMe,{host:K});n&&e.setQuery(d.me.getMe,{host:K},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=L(d.me.setMyName),a=ze(),o=e?.locale??`default`,s=e?.name??``,[c,l]=(0,q.useState)(null),u=c??s,f=u.trim()!==s.trim();async function p(){try{await i({name:u}),l(null),a.success(F())}catch(e){a.error(A(),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:Me()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:xe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(W,{className:`max-w-xs`,value:u,maxLength:120,placeholder:r(),onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&f&&(e.preventDefault(),p())}}),(0,J.jsx)(V,{size:`sm`,disabled:!f,onClick:()=>void p(),children:Ce()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,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:M()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:se()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[Je().map(e=>(0,J.jsx)(V,{variant:o===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:o==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:Te()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(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:te()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:We.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void n({scale:t}),children:ot[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:D()})]}),(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:Ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:y()})]}),(0,J.jsx)(at,{})]})]})}export{st as PreferencesTab};
@@ -1,4 +1,4 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$t as r,Ag as i,Ar as a,Cg as o,Dg as s,Dr as c,E as l,Eg as u,Hg as d,Mg as f,Mr as p,Ng as m,Og as h,Or as g,Pg as _,Qt as v,Sg as y,Tg as ee,Vg as b,Zt as x,_P as S,_g as C,bg as w,fa as te,ga as T,gg as E,ha as D,hg as ne,jg as re,jr as ie,kg as ae,kr as O,ma as k,pa as A,vP as j,vg as M,wg as N,xg as P,yg as F}from"./dist-BKXYNjW7.js";import{d as I,f as L,i as R,l as z,n as B,r as V,t as H,u as U}from"./FieldLabel-C2HKtml6.js";import{t as W}from"./button-CdHluvSK.js";import{C as G,H as K,S as q,T as J,m as oe,w as Y,wt as se,x as X}from"./index-DZcxHX-q.js";import{r as Z,t as ce}from"./locales-CPjguROj.js";import{t as le}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),ue={media_delivery:{label:ae,help:h},documentary_fetch:{label:s,help:u},inbound_files:{label:ee,help:N},history_summary:{label:T,help:D},file_curation:{label:p,help:ie}},de={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{$t as r,Ag as i,Ar as a,Cg as o,Dg as s,Dr as c,E as l,Eg as u,Hg as d,Mg as f,Mr as p,Ng as m,Og as h,Or as g,Pg as _,Qt as v,Sg as y,Tg as ee,Vg as b,Zt as x,_P as S,_g as C,bg as w,fa as te,ga as T,gg as E,ha as D,hg as ne,jg as re,jr as ie,kg as ae,kr as O,ma as k,pa as A,vP as j,vg as M,wg as N,xg as P,yg as F}from"./dist-BKXYNjW7.js";import{d as I,f as L,i as R,l as z,n as B,r as V,t as H,u as U}from"./FieldLabel-elWVqmbc.js";import{t as W}from"./button-CdHluvSK.js";import{C as G,H as K,S as q,T as J,m as oe,w as Y,wt as se,x as X}from"./index-CnNzzVmB.js";import{r as Z,t as ce}from"./locales-CPjguROj.js";import{t as le}from"./localePickerView-C2RmOS86.js";/* empty css */var Q=t(e(),1),$=n(),ue={media_delivery:{label:ae,help:h},documentary_fetch:{label:s,help:u},inbound_files:{label:ee,help:N},history_summary:{label:T,help:D},file_curation:{label:p,help:ie}},de={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`},fe={outboundDir:C,references:E,files:ne,previous_summary:k,new_messages:A,max_chars:te,file_name:a,budget_chars:O,feedback:g,content:c};function pe(){let e=j(l.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:y()})});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)(B,{label:_(),help:m()}),(0,$.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,$.jsx)(`span`,{children:o()}),(0,$.jsxs)(X,{value:r._id,onValueChange:e=>n(e),children:[(0,$.jsx)(Y,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(J,{})}),(0,$.jsx)(q,{children:e.map(e=>(0,$.jsx)(G,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,$.jsx)(me,{instance:r},r._id)]})}function me({instance:e}){let t=S(l.admin.upsertInstanceConfig),n=K(),i=j(l.me.getMe,{host:se}),a=e.config??{},o=Z(e.config?.contentLocale,i?.defaultLocale??void 0),[s,c]=(0,Q.useState)(()=>R(a,o));(0,Q.useEffect)(()=>{c(R(a,o))},[o,e._id]);let[u,f]=(0,Q.useState)(!1),p=s.promptInjections,m=(e,t)=>c({...s,promptInjections:{...p,[e]:{...p[e],...t}}});async function h(){f(!0);try{await t({instanceId:e._id,config:V(s,a,o)})}catch(e){n.error(b(),e)}finally{f(!1)}}async function g(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(b(),e)}}let _=e.config?.contentLocale??`default`,y=ce[Z(void 0,i?.defaultLocale??void 0)];return(0,$.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,$.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,$.jsx)(`span`,{children:r()}),(0,$.jsxs)(X,{value:_,onValueChange:e=>void g(e),children:[(0,$.jsx)(Y,{size:`sm`,className:`min-w-44`,children:(0,$.jsx)(J,{})}),(0,$.jsxs)(q,{children:[(0,$.jsx)(G,{value:`default`,children:x({locale:y})}),le().map(e=>(0,$.jsx)(G,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsx)(`p`,{className:`oc-admin__hint`,children:v()})]}),U.map(e=>(0,$.jsx)(he,{injKey:e,def:z[e],i18n:ue[e],row:p[e]??{enabled:!0,template:z[e].defaultTemplate[o]},contentLocale:o,onChange:t=>m(e,t)},e)),(0,$.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,$.jsx)(W,{size:`sm`,onClick:()=>void h(),disabled:u,children:d()})})]})}function he({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,d=Object.fromEntries(t.placeholders.map(e=>[e,de[e]??`{${e}}`])),p=I(e,r,a),m=p?L(p,d):``;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)(oe,{checked:r.enabled,onCheckedChange:e=>o({enabled:e===!0})}),(0,$.jsx)(B,{label:n.label(),help:n.help()})]}):(0,$.jsx)(B,{label:n.label(),help:n.help()}),l&&(0,$.jsx)(`span`,{className:`oc-injection__badge`,children:re()})]}),(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:i()}),t.placeholders.map(e=>(0,$.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,$.jsx)(`code`,{children:`{${e}}`}),(0,$.jsx)(H,{text:(fe[e]??(()=>e))()})]},e))]}),(0,$.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,$.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>c(e=>!e),children:s?w():P()}),l&&(0,$.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>o({template:t.defaultTemplate[a]}),children:f()})]})]}),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:F()})]}):(0,$.jsx)(`span`,{className:`oc-injection__ph`,children:M()})})]})}export{pe as PromptInjectionsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ab as r,Cb as i,Db as a,E as o,Eb as s,Gy as c,Hy as l,Jy as u,Ky as d,Ob as f,Sb as p,Tb as m,Uy as h,Vy as g,Wy as ee,Yy as _,_P as v,_b as y,ab as b,bb as x,cb as te,db as ne,fb as re,gb as ie,hb as ae,ib as S,kb as C,lb as w,mb as T,nb as E,ni as D,ob as O,pb as k,qy as A,rb as j,sb as M,tb as N,ub as P,vP as F,vb as I,wb as L,xb as R,yb as z}from"./dist-BKXYNjW7.js";import{t as B}from"./button-CdHluvSK.js";import{Gt as V,H,U,d as W,dt as G,ft as K,m as q}from"./index-DZcxHX-q.js";import{t as J}from"./roleDescriptions-ReA48WUh.js";var Y=t(e(),1),X=n(),Z=[{group:()=>r(),keys:[{key:`traces.read`,label:()=>m()},{key:`traces.read.content`,label:()=>L(),phi:!0},{key:`traces.write`,label:()=>i()}]},{group:()=>C(),keys:[{key:`kpi.read`,label:()=>m()},{key:`kpi.write`,label:()=>i()}]},{group:()=>f(),keys:[{key:`openclaw.query`,label:()=>p()},{key:`anomalies.read`,label:()=>R()},{key:`anomalies.report`,label:()=>x()}]},{group:()=>a(),keys:[{key:`chats.read`,label:()=>m()},{key:`selfheal`,label:()=>I()},{key:`feedback.respond`,label:()=>D()}]},{group:()=>s(),keys:[{key:`admin.manage`,label:()=>z()}]}],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(o.apiKeys.listRoles,{}),t=v(o.apiKeys.createRole),n=v(o.apiKeys.ensureRolesSeeded),r=v(o.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(o.apiKeys.listRoles,{});r&&e.setQuery(o.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),i=U(),a=H(),[s,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)($),[x,C]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{a.error(ie(),e)})},[n,a]);let D=e??[];async function I(e,t){if(Q(e.permissions))return;if(e.builtin){await i({title:ae({name:e.name}),description:T(),confirmLabel:k()});return}if(x.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];C(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){a.error(re(),e)}finally{C(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function L(){try{await t({key:p.key,name:p.name,description:p.description||void 0,permissions:[]}),m($),f(!1)}catch(e){a.error(ne(),e)}}let R=e===void 0,z=!R&&D.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[P(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,w(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,te()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:M()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{m($),f(!0)},children:O()})})]}),R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):(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:j()}),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?y({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:D.map(e=>{let t=Q(e.permissions),n=x.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(G,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(V,{}),` `,E()]}):(0,X.jsx)(G,{variant:`secondary`,children:N()})]}),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?_():n?u():r,onCheckedChange:()=>void I(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:s,onOpenChange:f,title:A(),description:d(),canSubmit:!!(p.key&&p.name),onSubmit:L,submitLabel:c(),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:ee()}),(0,X.jsx)(K,{value:p.key,placeholder:h(),onChange:e=>m({...p,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:l()}),(0,X.jsx)(K,{value:p.name,onChange:e=>m({...p,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:g()}),(0,X.jsx)(K,{value:p.description,onChange:e=>m({...p,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{Ab as r,Cb as i,Db as a,E as o,Eb as s,Gy as c,Hy as l,Jy as u,Ky as d,Ob as f,Sb as p,Tb as m,Uy as h,Vy as g,Wy as ee,Yy as _,_P as v,_b as y,ab as b,bb as x,cb as te,db as ne,fb as re,gb as ie,hb as ae,ib as S,kb as C,lb as w,mb as T,nb as E,ni as D,ob as O,pb as k,qy as A,rb as j,sb as M,tb as N,ub as P,vP as F,vb as I,wb as L,xb as R,yb as z}from"./dist-BKXYNjW7.js";import{t as B}from"./button-CdHluvSK.js";import{Gt as V,H,U,d as W,dt as G,ft as K,m as q}from"./index-CnNzzVmB.js";import{t as J}from"./roleDescriptions-ReA48WUh.js";var Y=t(e(),1),X=n(),Z=[{group:()=>r(),keys:[{key:`traces.read`,label:()=>m()},{key:`traces.read.content`,label:()=>L(),phi:!0},{key:`traces.write`,label:()=>i()}]},{group:()=>C(),keys:[{key:`kpi.read`,label:()=>m()},{key:`kpi.write`,label:()=>i()}]},{group:()=>f(),keys:[{key:`openclaw.query`,label:()=>p()},{key:`anomalies.read`,label:()=>R()},{key:`anomalies.report`,label:()=>x()}]},{group:()=>a(),keys:[{key:`chats.read`,label:()=>m()},{key:`selfheal`,label:()=>I()},{key:`feedback.respond`,label:()=>D()}]},{group:()=>s(),keys:[{key:`admin.manage`,label:()=>z()}]}],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(o.apiKeys.listRoles,{}),t=v(o.apiKeys.createRole),n=v(o.apiKeys.ensureRolesSeeded),r=v(o.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(o.apiKeys.listRoles,{});r&&e.setQuery(o.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),i=U(),a=H(),[s,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)($),[x,C]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{a.error(ie(),e)})},[n,a]);let D=e??[];async function I(e,t){if(Q(e.permissions))return;if(e.builtin){await i({title:ae({name:e.name}),description:T(),confirmLabel:k()});return}if(x.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];C(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){a.error(re(),e)}finally{C(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function L(){try{await t({key:p.key,name:p.name,description:p.description||void 0,permissions:[]}),m($),f(!1)}catch(e){a.error(ne(),e)}}let R=e===void 0,z=!R&&D.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[P(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,w(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,te()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:M()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{m($),f(!0)},children:O()})})]}),R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:S()}):(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:j()}),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?y({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:D.map(e=>{let t=Q(e.permissions),n=x.has(e._id);return(0,X.jsxs)(`tr`,{children:[(0,X.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,X.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,X.jsx)(`span`,{children:e.name}),(0,X.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,X.jsxs)(G,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(V,{}),` `,E()]}):(0,X.jsx)(G,{variant:`secondary`,children:N()})]}),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?_():n?u():r,onCheckedChange:()=>void I(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:s,onOpenChange:f,title:A(),description:d(),canSubmit:!!(p.key&&p.name),onSubmit:L,submitLabel:c(),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:ee()}),(0,X.jsx)(K,{value:p.key,placeholder:h(),onChange:e=>m({...p,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:l()}),(0,X.jsx)(K,{value:p.name,onChange:e=>m({...p,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:g()}),(0,X.jsx)(K,{value:p.description,onChange:e=>m({...p,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{$M as r,BM as i,Bj as a,D as o,Dj as s,E as c,Fj as ee,GM as te,Gj as ne,HM as re,Hj as ie,Ij as ae,JM as oe,Jj as l,KM as u,Kj as se,Lj as ce,Mj as le,Nj as ue,Pj as de,QM as fe,Rj as pe,SM as me,UM as he,Uj as ge,VM as _e,Vj as ve,WM as ye,Wj as be,XM as xe,YM as Se,Yj as Ce,ZM as d,aM as we,bM as f,cM as Te,dM as Ee,dP as De,fM as Oe,gM as p,hM as ke,hP as m,lM as h,lP as g,mM as Ae,oM as je,pM as Me,qM as Ne,qj as Pe,uM as Fe,vM as Ie,xM as Le,yM as Re,zM as ze,zj as Be}from"./dist-BKXYNjW7.js";import{t as _}from"./button-CdHluvSK.js";import{B as Ve,C as v,Ft as He,G as Ue,H as We,Ht as Ge,J as Ke,K as qe,Kt as Je,Mt as Ye,Q as Xe,S as Ze,T as y,Ut as Qe,V as $e,Vt as et,X as tt,Y as nt,Z as rt,_t as b,dt as x,ft as S,gt as it,ht as at,mt as C,pt as w,q as ot,vt as T,w as E,x as D,zt as st}from"./index-DZcxHX-q.js";import{a as ct,i as O,n as lt,o as k,r as A,t as ut}from"./table-BlgvNhKf.js";var dt=o(`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`}]]),j=t(e(),1),M=n(),N={minutes:6e4,hours:36e5,days:864e5};function P(e){return e?.data?.code??`unknown`}function F(){let e=m(c.scheduled.listMyCrons),t=m(c.scheduled.getCronDetail),n=m(c.scheduled.listCronRuns),o=m(c.scheduled.updateCron),F=m(c.scheduled.removeCron),ft=m(c.scheduled.runCronNow),I=We(),[L,pt]=(0,j.useState)(null),[R,z]=(0,j.useState)(!1),[B,mt]=(0,j.useState)(!1),[V,ht]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(null),[K,q]=(0,j.useState)(null),[gt,J]=(0,j.useState)(!1),Y=(0,j.useCallback)(async()=>{z(!0),mt(!1);try{pt(await e({}))}catch{mt(!0)}finally{z(!1)}},[e]);(0,j.useEffect)(()=>{Y()},[Y]);let _t=(0,j.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),X=(0,j.useRef)(null);(0,j.useEffect)(()=>{L!==null&&X.current!==null&&X.current.scrollIntoView({block:`center`})},[L]);let vt=(0,j.useMemo)(()=>new Intl.DateTimeFormat(De(),{dateStyle:`medium`,timeStyle:`short`}),[]),Z=async(e,t,n)=>{ht(e);try{await t(),I.success(n),await Y()}catch(e){I.toast({variant:`error`,title:p({code:P(e)})})}finally{ht(null)}},Q=(0,j.useRef)(0),$=(0,j.useRef)(0),yt=async(e,t)=>{if(t.id===null)return;let r=++Q.current;G({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Q.current)return;G({name:t.name??t.id,entries:i})}catch(e){if(r!==Q.current)return;G(null),I.toast({variant:`error`,title:p({code:P(e)})})}},bt=async(e,n)=>{if(n.id===null)return;let r=++$.current;q({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%N.days===0?(s=String(e/N.days),c=`days`):e%N.hours===0?(s=String(e/N.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/N.minutes))),c=`minutes`))}if(r!==$.current)return;q(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!==$.current)return;q(null),I.toast({variant:`error`,title:p({code:P(e)})})}},xt=async()=>{if(K===null)return;let e={};if(K.nameDirty&&K.name.trim()===``||K.messageDirty&&K.hasMessage&&K.message.trim()===``){I.toast({variant:`error`,title:le()});return}if(K.nameDirty&&K.name.trim()!==``&&(e.name=K.name.trim()),K.scheduleDirty){if(K.scheduleKind===`cron`&&K.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:K.cronExpr.trim(),...K.tz.trim()===``?{}:{tz:K.tz.trim()}};else if(K.scheduleKind===`every`){let t=Number(K.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*N[K.everyUnit])})}else if(K.scheduleKind===`at`&&K.at!==``){let t=Date.parse(K.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(K.scheduleDirty&&e.schedule===void 0){I.toast({variant:`error`,title:ue()});return}if(K.messageDirty&&K.hasMessage&&K.message.trim()!==``&&(e.message=K.message.trim()),Object.keys(e).length===0){q(null);return}let t=$.current;J(!0);try{await o({instanceName:K.instanceName,jobId:K.jobId,patch:e}),I.success(se()),t===$.current&&q(null),await Y()}catch(e){I.toast({variant:`error`,title:p({code:P(e)})})}finally{J(!1)}},St=L?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,M.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:r()}),(0,M.jsxs)(_,{variant:`ghost`,size:`sm`,onClick:()=>void Y(),disabled:R,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,M.jsx)(st,{size:14,"aria-hidden":!0}),fe()]})]}),L===null?(0,M.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":R,children:B?d():g()}):(0,M.jsxs)(M.Fragment,{children:[B?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):null,L.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}):null,L.map(e=>(0,M.jsxs)(`section`,{style:{marginBottom:20},children:[L.length>1||e.error||!e.supported?(0,M.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,M.jsx)(x,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:oe({code:e.error})}):e.jobs.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:Ne()}):(0,M.jsxs)(ut,{children:[(0,M.jsx)(ct,{children:(0,M.jsxs)(k,{children:[(0,M.jsx)(O,{children:u()}),(0,M.jsx)(O,{children:te()}),(0,M.jsx)(O,{children:ye()}),(0,M.jsx)(O,{children:he()}),(0,M.jsx)(O,{children:re()}),(0,M.jsx)(O,{children:Ce()})]})}),(0,M.jsx)(lt,{children:e.jobs.map((t,n)=>{let r=`${e.instanceName}:${t.id??n}`,a=V===r,s=e.manageSupported,c=e.kind===`openclaw`&&s;return(0,M.jsxs)(k,{ref:t.id!==null&&t.id===_t?X:void 0,"data-state":t.id!==null&&t.id===_t?`selected`:void 0,children:[(0,M.jsx)(A,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??_e()}),(0,M.jsx)(A,{children:(0,M.jsx)(x,{variant:`secondary`,children:t.agentId})}),(0,M.jsxs)(A,{className:`whitespace-nowrap`,children:[(0,M.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=Ve(t.schedule),n=e===null?null:$e(e);return n===null?null:(0,M.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,M.jsx)(A,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:vt.format(t.nextRunAtMs)}),(0,M.jsxs)(A,{children:[t.enabled===!0?(0,M.jsx)(x,{variant:`secondary`,children:ze()}):t.enabled===!1?(0,M.jsx)(x,{variant:`outline`,children:i()}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),t.lastRunStatus?(0,M.jsx)(`span`,{className:`text-muted-foreground`,style:{marginLeft:8,fontSize:`0.8rem`},children:t.lastRunStatus}):null]}),(0,M.jsx)(A,{className:`whitespace-nowrap`,children:t.id===null?(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,M.jsx)(Je,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,M.jsxs)(`span`,{style:{display:`inline-flex`,gap:2},children:[c?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:Le(),"aria-label":Le(),disabled:V!==null,onClick:()=>void Z(r,async()=>{let n=await ft({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},ke()),children:(0,M.jsx)(Ye,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:t.enabled?f():Re(),"aria-label":t.enabled?f():Re(),disabled:V!==null,onClick:()=>void Z(r,()=>o({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?Ae():Me()),children:t.enabled?(0,M.jsx)(Qe,{size:14,"aria-hidden":!0}):(0,M.jsx)(et,{size:14,"aria-hidden":!0})}):null,c?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:l(),"aria-label":l(),disabled:V!==null,onClick:()=>void bt(e.instanceName,t),children:(0,M.jsx)(Ge,{size:14,"aria-hidden":!0})}):null,c?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:Pe(),"aria-label":Pe(),disabled:V!==null,onClick:()=>void yt(e.instanceName,t),children:(0,M.jsx)(dt,{size:14,"aria-hidden":!0})}):null,s?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:Ie(),"aria-label":Ie(),disabled:V!==null,onClick:()=>U({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,M.jsx)(He,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:Se()})]},e.instanceName)),St>0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:s()}):null]}),(0,M.jsx)(Ue,{open:H!==null,onOpenChange:e=>{e||U(null)},children:(0,M.jsxs)(Ke,{children:[(0,M.jsxs)(rt,{children:[(0,M.jsx)(Xe,{children:Ee()}),(0,M.jsx)(nt,{children:Fe({name:H?.name??``})})]}),(0,M.jsxs)(tt,{children:[(0,M.jsx)(ot,{children:h()}),(0,M.jsx)(qe,{onClick:()=>{let e=H;U(null),e!==null&&Z(`${e.instanceName}:${e.jobId}`,()=>F({instanceName:e.instanceName,jobId:e.jobId}),Oe())},children:Te()})]})]})}),(0,M.jsx)(w,{open:W!==null,onOpenChange:e=>{e||(Q.current++,G(null))},children:(0,M.jsxs)(C,{style:{maxWidth:640},children:[(0,M.jsx)(b,{children:(0,M.jsx)(T,{children:ne({name:W?.name??``})})}),W?.entries===null?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):W!==null&&W.entries.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):W===null?null:(0,M.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:W.entries.map((e,t)=>(0,M.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,M.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[e.status===`ok`?(0,M.jsx)(x,{variant:`secondary`,children:je()}):e.status===`error`?(0,M.jsx)(x,{variant:`destructive`,children:we()}):(0,M.jsx)(x,{variant:`outline`,children:e.status??`—`}),(0,M.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?vt.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,M.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,M.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,M.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error})]},t))})]})}),(0,M.jsx)(w,{open:K!==null,onOpenChange:e=>{e||($.current++,q(null))},children:(0,M.jsxs)(C,{children:[(0,M.jsxs)(b,{children:[(0,M.jsx)(T,{children:ge()}),(0,M.jsx)(at,{children:ie()})]}),K===null?null:K.loading?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,M.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,M.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:u()}),(0,M.jsx)(S,{value:K.name,maxLength:200,onChange:e=>q({...K,name:e.target.value,nameDirty:!0})})]}),(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,M.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ve()}),(0,M.jsxs)(D,{value:K.scheduleKind,onValueChange:e=>q({...K,scheduleKind:e,scheduleDirty:!0}),children:[(0,M.jsx)(E,{children:(0,M.jsx)(y,{})}),(0,M.jsxs)(Ze,{children:[(0,M.jsx)(v,{value:`cron`,children:a()}),(0,M.jsx)(v,{value:`every`,children:Be()}),(0,M.jsx)(v,{value:`at`,children:pe()})]})]}),K.scheduleKind===`cron`?(0,M.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,M.jsx)(S,{value:K.cronExpr,onChange:e=>q({...K,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,M.jsx)(S,{value:K.tz,onChange:e=>q({...K,tz:e.target.value,scheduleDirty:!0}),placeholder:`America/Toronto`,style:{maxWidth:180}})]}):K.scheduleKind===`every`?(0,M.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,M.jsx)(S,{type:`number`,min:1,value:K.everyValue,onChange:e=>q({...K,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,M.jsxs)(D,{value:K.everyUnit,onValueChange:e=>q({...K,everyUnit:e,scheduleDirty:!0}),children:[(0,M.jsx)(E,{style:{maxWidth:160},children:(0,M.jsx)(y,{})}),(0,M.jsxs)(Ze,{children:[(0,M.jsx)(v,{value:`minutes`,children:ce()}),(0,M.jsx)(v,{value:`hours`,children:ae()}),(0,M.jsx)(v,{value:`days`,children:ee()})]})]})]}):(0,M.jsx)(S,{type:`datetime-local`,value:K.at,onChange:e=>q({...K,at:e.target.value,scheduleDirty:!0})})]}),K.hasMessage?(0,M.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,M.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:me()}),(0,M.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:K.message,onChange:e=>q({...K,message:e.target.value,messageDirty:!0})})]}):null]}),(0,M.jsxs)(it,{children:[(0,M.jsx)(_,{variant:`ghost`,onClick:()=>q(null),children:h()}),(0,M.jsxs)(_,{onClick:()=>void xt(),disabled:K===null||K.loading||gt,children:[gt?(0,M.jsx)(Je,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,de()]})]})]})})]})}export{F as ScheduledTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$M as r,BM as i,Bj as a,D as o,Dj as s,E as c,Fj as ee,GM as te,Gj as ne,HM as re,Hj as ie,Ij as ae,JM as oe,Jj as l,KM as u,Kj as se,Lj as ce,Mj as le,Nj as ue,Pj as de,QM as fe,Rj as pe,SM as me,UM as he,Uj as ge,VM as _e,Vj as ve,WM as ye,Wj as be,XM as xe,YM as Se,Yj as Ce,ZM as d,aM as we,bM as f,cM as Te,dM as Ee,dP as De,fM as Oe,gM as p,hM as ke,hP as m,lM as h,lP as g,mM as Ae,oM as je,pM as Me,qM as Ne,qj as Pe,uM as Fe,vM as Ie,xM as Le,yM as Re,zM as ze,zj as Be}from"./dist-BKXYNjW7.js";import{t as _}from"./button-CdHluvSK.js";import{B as Ve,C as v,Ft as He,G as Ue,H as We,Ht as Ge,J as Ke,K as qe,Kt as Je,Mt as Ye,Q as Xe,S as Ze,T as y,Ut as Qe,V as $e,Vt as et,X as tt,Y as nt,Z as rt,_t as b,dt as x,ft as S,gt as it,ht as at,mt as C,pt as w,q as ot,vt as T,w as E,x as D,zt as st}from"./index-CnNzzVmB.js";import{a as ct,i as O,n as lt,o as k,r as A,t as ut}from"./table-BlgvNhKf.js";var dt=o(`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`}]]),j=t(e(),1),M=n(),N={minutes:6e4,hours:36e5,days:864e5};function P(e){return e?.data?.code??`unknown`}function F(){let e=m(c.scheduled.listMyCrons),t=m(c.scheduled.getCronDetail),n=m(c.scheduled.listCronRuns),o=m(c.scheduled.updateCron),F=m(c.scheduled.removeCron),ft=m(c.scheduled.runCronNow),I=We(),[L,pt]=(0,j.useState)(null),[R,z]=(0,j.useState)(!1),[B,mt]=(0,j.useState)(!1),[V,ht]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(null),[K,q]=(0,j.useState)(null),[gt,J]=(0,j.useState)(!1),Y=(0,j.useCallback)(async()=>{z(!0),mt(!1);try{pt(await e({}))}catch{mt(!0)}finally{z(!1)}},[e]);(0,j.useEffect)(()=>{Y()},[Y]);let _t=(0,j.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),X=(0,j.useRef)(null);(0,j.useEffect)(()=>{L!==null&&X.current!==null&&X.current.scrollIntoView({block:`center`})},[L]);let vt=(0,j.useMemo)(()=>new Intl.DateTimeFormat(De(),{dateStyle:`medium`,timeStyle:`short`}),[]),Z=async(e,t,n)=>{ht(e);try{await t(),I.success(n),await Y()}catch(e){I.toast({variant:`error`,title:p({code:P(e)})})}finally{ht(null)}},Q=(0,j.useRef)(0),$=(0,j.useRef)(0),yt=async(e,t)=>{if(t.id===null)return;let r=++Q.current;G({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Q.current)return;G({name:t.name??t.id,entries:i})}catch(e){if(r!==Q.current)return;G(null),I.toast({variant:`error`,title:p({code:P(e)})})}},bt=async(e,n)=>{if(n.id===null)return;let r=++$.current;q({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%N.days===0?(s=String(e/N.days),c=`days`):e%N.hours===0?(s=String(e/N.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/N.minutes))),c=`minutes`))}if(r!==$.current)return;q(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!==$.current)return;q(null),I.toast({variant:`error`,title:p({code:P(e)})})}},xt=async()=>{if(K===null)return;let e={};if(K.nameDirty&&K.name.trim()===``||K.messageDirty&&K.hasMessage&&K.message.trim()===``){I.toast({variant:`error`,title:le()});return}if(K.nameDirty&&K.name.trim()!==``&&(e.name=K.name.trim()),K.scheduleDirty){if(K.scheduleKind===`cron`&&K.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:K.cronExpr.trim(),...K.tz.trim()===``?{}:{tz:K.tz.trim()}};else if(K.scheduleKind===`every`){let t=Number(K.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*N[K.everyUnit])})}else if(K.scheduleKind===`at`&&K.at!==``){let t=Date.parse(K.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(K.scheduleDirty&&e.schedule===void 0){I.toast({variant:`error`,title:ue()});return}if(K.messageDirty&&K.hasMessage&&K.message.trim()!==``&&(e.message=K.message.trim()),Object.keys(e).length===0){q(null);return}let t=$.current;J(!0);try{await o({instanceName:K.instanceName,jobId:K.jobId,patch:e}),I.success(se()),t===$.current&&q(null),await Y()}catch(e){I.toast({variant:`error`,title:p({code:P(e)})})}finally{J(!1)}},St=L?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,M.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:r()}),(0,M.jsxs)(_,{variant:`ghost`,size:`sm`,onClick:()=>void Y(),disabled:R,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,M.jsx)(st,{size:14,"aria-hidden":!0}),fe()]})]}),L===null?(0,M.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":R,children:B?d():g()}):(0,M.jsxs)(M.Fragment,{children:[B?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:d()}):null,L.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:xe()}):null,L.map(e=>(0,M.jsxs)(`section`,{style:{marginBottom:20},children:[L.length>1||e.error||!e.supported?(0,M.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,M.jsx)(x,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:oe({code:e.error})}):e.jobs.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:Ne()}):(0,M.jsxs)(ut,{children:[(0,M.jsx)(ct,{children:(0,M.jsxs)(k,{children:[(0,M.jsx)(O,{children:u()}),(0,M.jsx)(O,{children:te()}),(0,M.jsx)(O,{children:ye()}),(0,M.jsx)(O,{children:he()}),(0,M.jsx)(O,{children:re()}),(0,M.jsx)(O,{children:Ce()})]})}),(0,M.jsx)(lt,{children:e.jobs.map((t,n)=>{let r=`${e.instanceName}:${t.id??n}`,a=V===r,s=e.manageSupported,c=e.kind===`openclaw`&&s;return(0,M.jsxs)(k,{ref:t.id!==null&&t.id===_t?X:void 0,"data-state":t.id!==null&&t.id===_t?`selected`:void 0,children:[(0,M.jsx)(A,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??_e()}),(0,M.jsx)(A,{children:(0,M.jsx)(x,{variant:`secondary`,children:t.agentId})}),(0,M.jsxs)(A,{className:`whitespace-nowrap`,children:[(0,M.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=Ve(t.schedule),n=e===null?null:$e(e);return n===null?null:(0,M.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,M.jsx)(A,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:vt.format(t.nextRunAtMs)}),(0,M.jsxs)(A,{children:[t.enabled===!0?(0,M.jsx)(x,{variant:`secondary`,children:ze()}):t.enabled===!1?(0,M.jsx)(x,{variant:`outline`,children:i()}):(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}),t.lastRunStatus?(0,M.jsx)(`span`,{className:`text-muted-foreground`,style:{marginLeft:8,fontSize:`0.8rem`},children:t.lastRunStatus}):null]}),(0,M.jsx)(A,{className:`whitespace-nowrap`,children:t.id===null?(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,M.jsx)(Je,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,M.jsxs)(`span`,{style:{display:`inline-flex`,gap:2},children:[c?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:Le(),"aria-label":Le(),disabled:V!==null,onClick:()=>void Z(r,async()=>{let n=await ft({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},ke()),children:(0,M.jsx)(Ye,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:t.enabled?f():Re(),"aria-label":t.enabled?f():Re(),disabled:V!==null,onClick:()=>void Z(r,()=>o({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?Ae():Me()),children:t.enabled?(0,M.jsx)(Qe,{size:14,"aria-hidden":!0}):(0,M.jsx)(et,{size:14,"aria-hidden":!0})}):null,c?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:l(),"aria-label":l(),disabled:V!==null,onClick:()=>void bt(e.instanceName,t),children:(0,M.jsx)(Ge,{size:14,"aria-hidden":!0})}):null,c?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:Pe(),"aria-label":Pe(),disabled:V!==null,onClick:()=>void yt(e.instanceName,t),children:(0,M.jsx)(dt,{size:14,"aria-hidden":!0})}):null,s?(0,M.jsx)(_,{variant:`ghost`,size:`icon-sm`,title:Ie(),"aria-label":Ie(),disabled:V!==null,onClick:()=>U({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,M.jsx)(He,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:Se()})]},e.instanceName)),St>0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:s()}):null]}),(0,M.jsx)(Ue,{open:H!==null,onOpenChange:e=>{e||U(null)},children:(0,M.jsxs)(Ke,{children:[(0,M.jsxs)(rt,{children:[(0,M.jsx)(Xe,{children:Ee()}),(0,M.jsx)(nt,{children:Fe({name:H?.name??``})})]}),(0,M.jsxs)(tt,{children:[(0,M.jsx)(ot,{children:h()}),(0,M.jsx)(qe,{onClick:()=>{let e=H;U(null),e!==null&&Z(`${e.instanceName}:${e.jobId}`,()=>F({instanceName:e.instanceName,jobId:e.jobId}),Oe())},children:Te()})]})]})}),(0,M.jsx)(w,{open:W!==null,onOpenChange:e=>{e||(Q.current++,G(null))},children:(0,M.jsxs)(C,{style:{maxWidth:640},children:[(0,M.jsx)(b,{children:(0,M.jsx)(T,{children:ne({name:W?.name??``})})}),W?.entries===null?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):W!==null&&W.entries.length===0?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:be()}):W===null?null:(0,M.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:W.entries.map((e,t)=>(0,M.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,M.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[e.status===`ok`?(0,M.jsx)(x,{variant:`secondary`,children:je()}):e.status===`error`?(0,M.jsx)(x,{variant:`destructive`,children:we()}):(0,M.jsx)(x,{variant:`outline`,children:e.status??`—`}),(0,M.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?vt.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,M.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,M.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,M.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error})]},t))})]})}),(0,M.jsx)(w,{open:K!==null,onOpenChange:e=>{e||($.current++,q(null))},children:(0,M.jsxs)(C,{children:[(0,M.jsxs)(b,{children:[(0,M.jsx)(T,{children:ge()}),(0,M.jsx)(at,{children:ie()})]}),K===null?null:K.loading?(0,M.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,M.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,M.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:u()}),(0,M.jsx)(S,{value:K.name,maxLength:200,onChange:e=>q({...K,name:e.target.value,nameDirty:!0})})]}),(0,M.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,M.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ve()}),(0,M.jsxs)(D,{value:K.scheduleKind,onValueChange:e=>q({...K,scheduleKind:e,scheduleDirty:!0}),children:[(0,M.jsx)(E,{children:(0,M.jsx)(y,{})}),(0,M.jsxs)(Ze,{children:[(0,M.jsx)(v,{value:`cron`,children:a()}),(0,M.jsx)(v,{value:`every`,children:Be()}),(0,M.jsx)(v,{value:`at`,children:pe()})]})]}),K.scheduleKind===`cron`?(0,M.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,M.jsx)(S,{value:K.cronExpr,onChange:e=>q({...K,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,M.jsx)(S,{value:K.tz,onChange:e=>q({...K,tz:e.target.value,scheduleDirty:!0}),placeholder:`America/Toronto`,style:{maxWidth:180}})]}):K.scheduleKind===`every`?(0,M.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,M.jsx)(S,{type:`number`,min:1,value:K.everyValue,onChange:e=>q({...K,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,M.jsxs)(D,{value:K.everyUnit,onValueChange:e=>q({...K,everyUnit:e,scheduleDirty:!0}),children:[(0,M.jsx)(E,{style:{maxWidth:160},children:(0,M.jsx)(y,{})}),(0,M.jsxs)(Ze,{children:[(0,M.jsx)(v,{value:`minutes`,children:ce()}),(0,M.jsx)(v,{value:`hours`,children:ae()}),(0,M.jsx)(v,{value:`days`,children:ee()})]})]})]}):(0,M.jsx)(S,{type:`datetime-local`,value:K.at,onChange:e=>q({...K,at:e.target.value,scheduleDirty:!0})})]}),K.hasMessage?(0,M.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,M.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:me()}),(0,M.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:K.message,onChange:e=>q({...K,message:e.target.value,messageDirty:!0})})]}):null]}),(0,M.jsxs)(it,{children:[(0,M.jsx)(_,{variant:`ghost`,onClick:()=>q(null),children:h()}),(0,M.jsxs)(_,{onClick:()=>void xt(),disabled:K===null||K.loading||gt,children:[gt?(0,M.jsx)(Je,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,de()]})]})]})})]})}export{F as ScheduledTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,$O as i,AO as ee,BO as te,CO as ne,DO as re,E as a,EO as ie,FO as ae,GO as oe,HO as se,IO as ce,JD as o,JO as le,KO as ue,LO as de,MO as fe,NO as pe,OO as me,PO as he,QD as s,QO as ge,RO as _e,SO as ve,TO as ye,UO as be,VO as xe,WO as Se,XD as Ce,XO as we,YD as Te,YO as Ee,ZD as De,ZO as Oe,_O as c,_P as l,aO as u,ak as ke,bO as Ae,cO as d,ck as f,dO as p,dk as je,eO as m,ek as Me,fO as h,fk as Ne,gO as g,hO as _,hP as Pe,iO as v,ik as Fe,jO as Ie,kO as Le,lO as y,lk as b,mO as x,mk as Re,nO as S,nk as ze,oO as C,ok as Be,pO as w,pk as Ve,qO as He,rO as T,rk as Ue,sO as E,sk as We,tO as D,tk as Ge,uO as O,uk as Ke,vO as qe,vP as k,wO as Je,xO as Ye,yO as Xe,zO as Ze}from"./dist-BKXYNjW7.js";import{n as A}from"./dist-x2y4VoOj.js";import{i as Qe}from"./dist-D06QCQPB.js";import{t as j}from"./button-CdHluvSK.js";import{C as M,H as $e,S as N,T as P,U as et,Zt as F,_t as I,d as tt,dt as L,en as nt,ft as R,gt as z,ht as B,mt as V,nn as rt,nt as H,pt as it,rn as at,rt as U,vt as W,w as G,x as K}from"./index-DZcxHX-q.js";import{t as ot}from"./FilterBar-CQBSm0gy.js";import{t as st}from"./DataTableShell-O-bA35dG.js";import{t as ct}from"./roleDescriptions-ReA48WUh.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>m(),days:null},{value:`30`,label:()=>r(),days:30},{value:`90`,label:()=>s(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=at({from:`/settings/serviceAccounts`}),t=rt({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??X,[o,s]=(0,q.useState)(X),Ce=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),Te=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),De=k(a.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:o===X?void 0:o,disabled:r===X?void 0:r===`disabled`}}),c=k(a.apiKeys.listKeys,{}),u=k(a.apiKeys.listRoles,{}),d=l(a.apiKeys.createServiceAccount),p=l(a.apiKeys.updateServiceAccount),m=l(a.apiKeys.deleteServiceAccount),h=Pe(a.apiKeys.mintApiKey),g=l(a.apiKeys.revokeApiKey),_=et(),v=$e(),y=n!==``||o!==X||r!==X;function x(){s(X),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Z),[E,D]=(0,q.useState)(null),[O,A]=(0,q.useState)(new Set),[F,I]=(0,q.useState)(null),z=(0,q.useRef)(!1),[B,V]=(0,q.useState)(new Set),[H,it]=(0,q.useState)({}),[U,W]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[c]);function Q(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{E?(await p({serviceAccountId:E,name:w.name,roleKey:w.roleKey,description:w.description}),v.success(fe())):await d({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Z),D(null),C(!1)}catch(e){v.error(E?pe():he(),e)}}function pt(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),D(e._id),C(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=H[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;I(e._id);try{let t=await h({serviceAccountId:e._id,expiresAt:r});W({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){v.error(Ie(),e)}finally{z.current=!1,I(null)}}async function $(e){if(await _({title:ee(),description:(0,J.jsxs)(J.Fragment,{children:[Le(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,me(),` `,(0,J.jsx)(`strong`,{children:re()}),` `,ie()]}),confirmWord:e.name,confirmLabel:ye(),destructive:!0}))try{await m({serviceAccountId:e._id}),v.success(Je(),e.name)}catch(e){v.error(ne(),e)}}async function ht(e){if(await _({title:ve(),description:(0,J.jsxs)(J.Fragment,{children:[Ye(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ae()]}),confirmLabel:Xe(),destructive:!0})&&!B.has(e._id)){V(t=>new Set(t).add(e._id));try{await g({keyId:e._id})}catch(e){v.error(qe(),e)}finally{V(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}),(0,J.jsxs)(ot,{q:n,onQChange:Ce,searchPlaceholder:Ve(),onReset:x,canReset:y,children:[(0,J.jsxs)(K,{value:o,onValueChange:s,children:[(0,J.jsx)(G,{size:`sm`,className:`w-40`,children:(0,J.jsx)(P,{placeholder:Ne()})}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{value:X,children:je()}),(u??[]).map(e=>(0,J.jsx)(M,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(K,{value:r,onValueChange:Te,children:[(0,J.jsx)(G,{size:`sm`,className:`w-36`,children:(0,J.jsx)(P,{})}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{value:X,children:Ke()}),(0,J.jsx)(M,{value:`active`,children:b()}),(0,J.jsx)(M,{value:`disabled`,children:f()})]})]})]}),(0,J.jsx)(st,{title:We(),rows:De,addLabel:Be(),onAdd:()=>{T(Z),D(null),C(!0)},emptyHint:ke(),isExpanded:e=>O.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:B}),rowActions:e=>[{label:Ge(),onSelect:()=>pt(e)},{label:Fe(),onSelect:()=>void mt(e)},{label:O.has(e._id)?Ue():ze(),onSelect:()=>Q(e._id)},{label:Me(),variant:`destructive`,onSelect:()=>void $(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":O.has(e._id)?i():ge(),onClick:()=>Q(e._id),children:O.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(nt,{})})},{header:Oe(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:we(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(L,{variant:`secondary`,children:e.roleKey})},{header:Ee(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(L,{variant:`destructive`,children:f()}):(0,J.jsx)(L,{variant:`outline`,children:b()})},{header:le(),cell:e=>(0,J.jsxs)(K,{value:H[e._id]??`never`,onValueChange:t=>it(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(G,{size:`sm`,className:`w-32`,children:(0,J.jsx)(P,{})}),(0,J.jsx)(N,{children:lt.map(e=>(0,J.jsx)(M,{value:e.value,children:e.label()},e.value))})]})},{header:He(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:F===e._id?ue():oe({count:t})})}}]}),(0,J.jsx)(tt,{open:S,onOpenChange:e=>{C(e),e||D(null)},title:E?Se():xe(),description:E?be():te(),canSubmit:!!(w.name&&w.roleKey),onSubmit:ft,submitLabel:E?se():Ze(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:_e()}),(0,J.jsx)(R,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:de()}),(0,J.jsxs)(K,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(G,{className:`w-full`,children:(0,J.jsx)(P,{placeholder:ce()})}),(0,J.jsx)(N,{children:(u??[]).map(e=>(0,J.jsxs)(M,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(u??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ae()}),(0,J.jsx)(R,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:U,onClose:()=>W(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[c(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:_()}),(0,J.jsx)(`th`,{children:x()}),(0,J.jsx)(`th`,{children:w()}),(0,J.jsx)(`th`,{children:h()}),(0,J.jsx)(`th`,{children:p()}),(0,J.jsx)(`th`,{children:O()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(L,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:U(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?y():d()})})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(it,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(V,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(I,{children:[(0,J.jsx)(W,{children:E()}),(0,J.jsx)(B,{children:C({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:u()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":v(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(F,{}),n?T():S()]})]}),(0,J.jsx)(z,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:D()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?De():U(e)}function mt(e){return e===null?`—`:H(e)}function $(e){return e.disabled?(0,J.jsx)(L,{variant:`destructive`,children:Ce()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(L,{variant:`outline`,children:Te()}):(0,J.jsx)(L,{variant:`outline`,children:o()})}export{Q as ServiceAccountsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$D as r,$O as i,AO as ee,BO as te,CO as ne,DO as re,E as a,EO as ie,FO as ae,GO as oe,HO as se,IO as ce,JD as o,JO as le,KO as ue,LO as de,MO as fe,NO as pe,OO as me,PO as he,QD as s,QO as ge,RO as _e,SO as ve,TO as ye,UO as be,VO as xe,WO as Se,XD as Ce,XO as we,YD as Te,YO as Ee,ZD as De,ZO as Oe,_O as c,_P as l,aO as u,ak as ke,bO as Ae,cO as d,ck as f,dO as p,dk as je,eO as m,ek as Me,fO as h,fk as Ne,gO as g,hO as _,hP as Pe,iO as v,ik as Fe,jO as Ie,kO as Le,lO as y,lk as b,mO as x,mk as Re,nO as S,nk as ze,oO as C,ok as Be,pO as w,pk as Ve,qO as He,rO as T,rk as Ue,sO as E,sk as We,tO as D,tk as Ge,uO as O,uk as Ke,vO as qe,vP as k,wO as Je,xO as Ye,yO as Xe,zO as Ze}from"./dist-BKXYNjW7.js";import{n as A}from"./dist-x2y4VoOj.js";import{i as Qe}from"./dist-D06QCQPB.js";import{t as j}from"./button-CdHluvSK.js";import{C as M,H as $e,S as N,T as P,U as et,Zt as F,_t as I,d as tt,dt as L,en as nt,ft as R,gt as z,ht as B,mt as V,nn as rt,nt as H,pt as it,rn as at,rt as U,vt as W,w as G,x as K}from"./index-CnNzzVmB.js";import{t as ot}from"./FilterBar-CGBz7_qR.js";import{t as st}from"./DataTableShell-CcVtwrRQ.js";import{t as ct}from"./roleDescriptions-ReA48WUh.js";var q=t(e(),1),J=n(),lt=[{value:`never`,label:()=>m(),days:null},{value:`30`,label:()=>r(),days:30},{value:`90`,label:()=>s(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=at({from:`/settings/serviceAccounts`}),t=rt({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??X,[o,s]=(0,q.useState)(X),Ce=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),Te=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),De=k(a.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:o===X?void 0:o,disabled:r===X?void 0:r===`disabled`}}),c=k(a.apiKeys.listKeys,{}),u=k(a.apiKeys.listRoles,{}),d=l(a.apiKeys.createServiceAccount),p=l(a.apiKeys.updateServiceAccount),m=l(a.apiKeys.deleteServiceAccount),h=Pe(a.apiKeys.mintApiKey),g=l(a.apiKeys.revokeApiKey),_=et(),v=$e(),y=n!==``||o!==X||r!==X;function x(){s(X),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Z),[E,D]=(0,q.useState)(null),[O,A]=(0,q.useState)(new Set),[F,I]=(0,q.useState)(null),z=(0,q.useRef)(!1),[B,V]=(0,q.useState)(new Set),[H,it]=(0,q.useState)({}),[U,W]=(0,q.useState)(null),Y=(0,q.useMemo)(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[c]);function Q(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function ft(){try{E?(await p({serviceAccountId:E,name:w.name,roleKey:w.roleKey,description:w.description}),v.success(fe())):await d({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Z),D(null),C(!1)}catch(e){v.error(E?pe():he(),e)}}function pt(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),D(e._id),C(!0)}async function mt(e){if(z.current)return;z.current=!0;let t=H[e._id]??`never`,n=lt.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;I(e._id);try{let t=await h({serviceAccountId:e._id,expiresAt:r});W({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){v.error(Ie(),e)}finally{z.current=!1,I(null)}}async function $(e){if(await _({title:ee(),description:(0,J.jsxs)(J.Fragment,{children:[Le(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,me(),` `,(0,J.jsx)(`strong`,{children:re()}),` `,ie()]}),confirmWord:e.name,confirmLabel:ye(),destructive:!0}))try{await m({serviceAccountId:e._id}),v.success(Je(),e.name)}catch(e){v.error(ne(),e)}}async function ht(e){if(await _({title:ve(),description:(0,J.jsxs)(J.Fragment,{children:[Ye(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ae()]}),confirmLabel:Xe(),destructive:!0})&&!B.has(e._id)){V(t=>new Set(t).add(e._id));try{await g({keyId:e._id})}catch(e){v.error(qe(),e)}finally{V(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Re()}),(0,J.jsxs)(ot,{q:n,onQChange:Ce,searchPlaceholder:Ve(),onReset:x,canReset:y,children:[(0,J.jsxs)(K,{value:o,onValueChange:s,children:[(0,J.jsx)(G,{size:`sm`,className:`w-40`,children:(0,J.jsx)(P,{placeholder:Ne()})}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{value:X,children:je()}),(u??[]).map(e=>(0,J.jsx)(M,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(K,{value:r,onValueChange:Te,children:[(0,J.jsx)(G,{size:`sm`,className:`w-36`,children:(0,J.jsx)(P,{})}),(0,J.jsxs)(N,{children:[(0,J.jsx)(M,{value:X,children:Ke()}),(0,J.jsx)(M,{value:`active`,children:b()}),(0,J.jsx)(M,{value:`disabled`,children:f()})]})]})]}),(0,J.jsx)(st,{title:We(),rows:De,addLabel:Be(),onAdd:()=>{T(Z),D(null),C(!0)},emptyHint:ke(),isExpanded:e=>O.has(e._id),renderExpanded:e=>(0,J.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:B}),rowActions:e=>[{label:Ge(),onSelect:()=>pt(e)},{label:Fe(),onSelect:()=>void mt(e)},{label:O.has(e._id)?Ue():ze(),onSelect:()=>Q(e._id)},{label:Me(),variant:`destructive`,onSelect:()=>void $(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":O.has(e._id)?i():ge(),onClick:()=>Q(e._id),children:O.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(nt,{})})},{header:Oe(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:we(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(L,{variant:`secondary`,children:e.roleKey})},{header:Ee(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(L,{variant:`destructive`,children:f()}):(0,J.jsx)(L,{variant:`outline`,children:b()})},{header:le(),cell:e=>(0,J.jsxs)(K,{value:H[e._id]??`never`,onValueChange:t=>it(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(G,{size:`sm`,className:`w-32`,children:(0,J.jsx)(P,{})}),(0,J.jsx)(N,{children:lt.map(e=>(0,J.jsx)(M,{value:e.value,children:e.label()},e.value))})]})},{header:He(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:F===e._id?ue():oe({count:t})})}}]}),(0,J.jsx)(tt,{open:S,onOpenChange:e=>{C(e),e||D(null)},title:E?Se():xe(),description:E?be():te(),canSubmit:!!(w.name&&w.roleKey),onSubmit:ft,submitLabel:E?se():Ze(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:_e()}),(0,J.jsx)(R,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:de()}),(0,J.jsxs)(K,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(G,{className:`w-full`,children:(0,J.jsx)(P,{placeholder:ce()})}),(0,J.jsx)(N,{children:(u??[]).map(e=>(0,J.jsxs)(M,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(u??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ae()}),(0,J.jsx)(R,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(dt,{minted:U,onClose:()=>W(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:r}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[c(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:g()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:_()}),(0,J.jsx)(`th`,{children:x()}),(0,J.jsx)(`th`,{children:w()}),(0,J.jsx)(`th`,{children:h()}),(0,J.jsx)(`th`,{children:p()}),(0,J.jsx)(`th`,{children:O()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(L,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:U(t.createdAt)}),(0,J.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:mt(t.expiresAt)}),(0,J.jsx)(`td`,{children:$(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?y():d()})})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(it,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(V,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(I,{children:[(0,J.jsx)(W,{children:E()}),(0,J.jsx)(B,{children:C({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:u()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":v(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(F,{}),n?T():S()]})]}),(0,J.jsx)(z,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:D()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?De():U(e)}function mt(e){return e===null?`—`:H(e)}function $(e){return e.disabled?(0,J.jsx)(L,{variant:`destructive`,children:Ce()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(L,{variant:`outline`,children:Te()}):(0,J.jsx)(L,{variant:`outline`,children:o()})}export{Q as ServiceAccountsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$a as r,Aa as i,Ba as a,Ca as o,Da as s,E as c,Ea as l,Fa as u,Ga as d,Ha as f,Ia as p,Ja as m,Ka as h,La as g,Ma as _,Na as v,Oa as y,Pa as b,Qa as x,Ra as S,Sa as C,Ta as w,Ua as T,Va as E,Wa as D,Xa as O,Ya as k,Za as A,_P as j,ao as M,eo as N,io as P,ja as F,ka as I,no as ee,qa as L,ro as R,to as z,vP as B,wa as V,xa as H,za as U}from"./dist-BKXYNjW7.js";import{t as W}from"./button-CdHluvSK.js";import{U as G,rt as K}from"./index-DZcxHX-q.js";import{t as q}from"./DataTableShell-O-bA35dG.js";var J=t(e(),1),Y=n(),X={hung:()=>f(),wrong_result:()=>E(),error:()=>a(),other:()=>U()},Z=e=>(e&&X[e]?.())??e??`—`;function Q(e){let t=e.slice(e.lastIndexOf(`:`)+1)||e;return t.length>12?`${t.slice(0,12)}…`:t}function $({data:e}){let t=e.snapshot,n=j(c.subAgentReports.respondToReport),[r,a]=(0,J.useState)(e.thread),[o,d]=(0,J.useState)(``),[f,m]=(0,J.useState)(!1);async function h(){let t=o.trim();if(!(!t||f)){m(!0);try{await n({reportId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),d(``)}finally{m(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,S({failed:t.failedCount,total:t.totalCount}),t.openclawModel?` · ${t.openclawModel}`:``,t.openclawRuntime?` (${t.openclawRuntime})`:``]})}),e.comment?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:p()}),r.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:r.map((e,t)=>(0,Y.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Y.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?u():b()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:v()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:_(),value:o,maxLength:2e3,rows:3,onChange:e=>d(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void h(),disabled:!o.trim()||f,children:f?i():F()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[I({count:t.children.length}),t.childrenTruncated?` ${y()}`:``,t.textTruncated?` ${s()}`:``]}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:t.children.map((e,n)=>(0,Y.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Y.jsxs)(`span`,{className:`oc-fbadmin__ctx-role`,children:[(e.taskName?.trim()||Q(e.childSessionKey))+` · ${e.status}`,e.phase?` · ${e.phase}`:``,e.childSessionKey===t.flaggedChildSessionKey?` · ${l()}`:``]}),e.errorMessage?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.errorMessage}):null,e.resultText?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.resultText}):null]},n))})]}),t.parentText?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=B(c.subAgentReports.listForAdmin,{}),t=j(c.subAgentReports.readReport),n=j(c.subAgentReports.deleteReport),i=G(),[a,s]=(0,J.useState)(null),[l,u]=(0,J.useState)({});async function f(e){if(a===e._id){s(null);return}if(!l[e._id]){let n=await t({reportId:e._id});u(t=>({...t,[e._id]:n}))}s(e._id)}async function p(e){await i({title:o(),description:C(),confirmLabel:H(),destructive:!0})&&(await n({reportId:e._id}),a===e._id&&s(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[R(),` `,(0,Y.jsx)(`strong`,{children:ee()}),` `,z()]}),(0,Y.jsx)(q,{title:M(),rows:e,emptyHint:P(),isExpanded:e=>a===e._id&&!!l[e._id],renderExpanded:e=>l[e._id]?(0,Y.jsx)($,{data:l[e._id]}):null,columns:[{header:N(),cell:e=>K(e.at),sort:e=>e.at},{header:r(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:x(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:A(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${m({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:O(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:k(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:L()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:h()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:a===e._id?D():d(),onSelect:()=>void f(e)},{label:T(),onSelect:()=>void p(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$a as r,Aa as i,Ba as a,Ca as o,Da as s,E as c,Ea as l,Fa as u,Ga as d,Ha as f,Ia as p,Ja as m,Ka as h,La as g,Ma as _,Na as v,Oa as y,Pa as b,Qa as x,Ra as S,Sa as C,Ta as w,Ua as T,Va as E,Wa as D,Xa as O,Ya as k,Za as A,_P as j,ao as M,eo as N,io as P,ja as F,ka as I,no as ee,qa as L,ro as R,to as z,vP as B,wa as V,xa as H,za as U}from"./dist-BKXYNjW7.js";import{t as W}from"./button-CdHluvSK.js";import{U as G,rt as K}from"./index-CnNzzVmB.js";import{t as q}from"./DataTableShell-CcVtwrRQ.js";var J=t(e(),1),Y=n(),X={hung:()=>f(),wrong_result:()=>E(),error:()=>a(),other:()=>U()},Z=e=>(e&&X[e]?.())??e??`—`;function Q(e){let t=e.slice(e.lastIndexOf(`:`)+1)||e;return t.length>12?`${t.slice(0,12)}…`:t}function $({data:e}){let t=e.snapshot,n=j(c.subAgentReports.respondToReport),[r,a]=(0,J.useState)(e.thread),[o,d]=(0,J.useState)(``),[f,m]=(0,J.useState)(!1);async function h(){let t=o.trim();if(!(!t||f)){m(!0);try{await n({reportId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),d(``)}finally{m(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,S({failed:t.failedCount,total:t.totalCount}),t.openclawModel?` · ${t.openclawModel}`:``,t.openclawRuntime?` (${t.openclawRuntime})`:``]})}),e.comment?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:g()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:p()}),r.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:r.map((e,t)=>(0,Y.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,Y.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?u():b()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:v()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:_(),value:o,maxLength:2e3,rows:3,onChange:e=>d(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void h(),disabled:!o.trim()||f,children:f?i():F()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[I({count:t.children.length}),t.childrenTruncated?` ${y()}`:``,t.textTruncated?` ${s()}`:``]}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:t.children.map((e,n)=>(0,Y.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,Y.jsxs)(`span`,{className:`oc-fbadmin__ctx-role`,children:[(e.taskName?.trim()||Q(e.childSessionKey))+` · ${e.status}`,e.phase?` · ${e.phase}`:``,e.childSessionKey===t.flaggedChildSessionKey?` · ${l()}`:``]}),e.errorMessage?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.errorMessage}):null,e.resultText?(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:e.resultText}):null]},n))})]}),t.parentText?(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:w()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:V()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=B(c.subAgentReports.listForAdmin,{}),t=j(c.subAgentReports.readReport),n=j(c.subAgentReports.deleteReport),i=G(),[a,s]=(0,J.useState)(null),[l,u]=(0,J.useState)({});async function f(e){if(a===e._id){s(null);return}if(!l[e._id]){let n=await t({reportId:e._id});u(t=>({...t,[e._id]:n}))}s(e._id)}async function p(e){await i({title:o(),description:C(),confirmLabel:H(),destructive:!0})&&(await n({reportId:e._id}),a===e._id&&s(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[R(),` `,(0,Y.jsx)(`strong`,{children:ee()}),` `,z()]}),(0,Y.jsx)(q,{title:M(),rows:e,emptyHint:P(),isExpanded:e=>a===e._id&&!!l[e._id],renderExpanded:e=>l[e._id]?(0,Y.jsx)($,{data:l[e._id]}):null,columns:[{header:N(),cell:e=>K(e.at),sort:e=>e.at},{header:r(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:x(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:A(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${m({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:O(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:k(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:L()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:h()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:a===e._id?D():d(),onSelect:()=>void f(e)},{label:T(),onSelect:()=>void p(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$A as r,AA as i,BA as a,CA as o,Cj as s,D as c,DA as l,E as u,EA as d,FA as f,GA as p,HA as m,IA as h,JA as g,KA as _,LA as v,MA as y,NA as ee,OA as te,PA as ne,QA as re,RA as ie,SA as ae,Sj as oe,TA as se,UA as ce,VA as le,WA as ue,XA as de,YA as fe,ZA as pe,_A as me,_P as b,_a as he,_j as ge,aA as x,aP as _e,aj as ve,bA as ye,ba as S,bj as be,cA as xe,cj as Se,dA as Ce,dj as we,ej as Te,fA as Ee,fj as De,gA as Oe,gj as ke,hA as Ae,hP as je,hj as Me,iA as Ne,ij as Pe,jA as Fe,kA as Ie,lA as C,lj as Le,mA as Re,mj as ze,n as Be,nA as Ve,nj as He,oA as Ue,oP as We,oj as Ge,pA as Ke,pj as w,qA as qe,rA as Je,rj as Ye,sA as Xe,sP as Ze,sj as Qe,tA as $e,tj as et,uA as tt,uj as nt,vA as rt,vP as T,va as it,vj as at,wA as ot,xA as E,xj as st,yA as ct,ya as lt,yj as ut,zA as dt}from"./dist-BKXYNjW7.js";import{n as D}from"./dist-x2y4VoOj.js";import{t as O}from"./x-B77pQElB.js";import{t as k}from"./button-CdHluvSK.js";import{C as A,S as j,T as M,Xt as ft,Yt as N,at as pt,bt as mt,ct as ht,dt as P,ft as F,lt as I,m as L,ot as gt,st as R,ut as _t,w as z,wt as B,x as V,yt as vt}from"./index-DZcxHX-q.js";import{t as yt}from"./localePickerView-C2RmOS86.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,t as Tt}from"./card-AXe34vGw.js";import{a as Et,i as H,n as Dt,o as U,r as W,t as Ot}from"./table-BlgvNhKf.js";import{t as kt}from"./TimeRangePicker-CV_IaaKP.js";import{t as At}from"./FilterBar-CQBSm0gy.js";import{t as jt}from"./AdvancedFilter-Cqqt3aQy.js";var G=c(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),K=t(e(),1),Mt=.1,Nt=[248,248,248],Pt=[24,24,24];function Ft(e,t,n){let r=t,i=n,a=-1,o=-1;for(let s=0;s<n;s++)for(let n=0;n<t;n++)e[(s*t+n)*4+3]>8&&(n<r&&(r=n),n>a&&(a=n),s<i&&(i=s),s>o&&(o=s));return a<0?null:{x:r,y:i,width:a-r+1,height:o-i+1}}function It(e,t,n){let r=t*n;if(r===0)return 0;let i=0;for(let t=3;t<e.length;t+=4)e[t]<=8&&i++;return i/r}function q(e,t,n){return It(e,t,n)>=Mt}function Lt(e,t){for(let n=0;n<e.length;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2]}function Rt(e){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}var zt=12*1024*1024,Bt=480,Vt=160,Ht=.92;async function Ut(e,t={}){if(!e.type.startsWith(`image/`))throw Error(ot());if(e.size>zt)throw Error(o());let{source:n,width:r,height:i,cleanup:a}=await Wt(e);try{let a=e.type===`image/svg+xml`,o=Math.min(Bt/r,Vt/i,a?1/0:1),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o)),l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u)throw Error(E());u.imageSmoothingEnabled=!0,u.imageSmoothingQuality=`high`,u.drawImage(n,0,0,s,c);let d=Ft(u.getImageData(0,0,s,c).data,s,c)??{x:0,y:0,width:s,height:c},f=document.createElement(`canvas`);f.width=d.width,f.height=d.height;let p=f.getContext(`2d`);if(!p)throw Error(E());if(p.drawImage(l,d.x,d.y,d.width,d.height,0,0,d.width,d.height),t.variantFor){let e=p.getImageData(0,0,d.width,d.height);q(e.data,d.width,d.height)?Lt(e.data,t.variantFor===`dark`?Nt:Pt):Rt(e.data),p.putImageData(e,0,0)}let m=q(p.getImageData(0,0,d.width,d.height).data,d.width,d.height),h=await Y(f,`image/webp`,Ht)??await Y(f,`image/png`);if(!h)throw Error(ye());return{blob:h,hasAlpha:m}}finally{a()}}async function Wt(e){if(e.type===`image/svg+xml`)return J(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return J(e)}async function J(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(ae())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function Y(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var X=n();function Gt(e,t){let n=e.trim().replace(/[^A-Za-z0-9_.-]+/g,`-`).replace(/^-+|-+$/g,``)||`chart`,r=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${n}.chart.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var Z=`__all__`,Q={kind:`relative`,from:`now-24h`,to:`now`},Kt=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function $({title:e,description:t,children:n}){return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,X.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function qt(e){return e===`light`?Ze():e===`dark`?We():_e()}var Jt=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function Yt({tokens:e,mode:t}){let n=e.colors[t];return(0,X.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:Jt.map(e=>{let t=n[e];return(0,X.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function Xt({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a,onExport:o}){return(0,X.jsxs)(`div`,{className:`oc-chart-card-wrap`,children:[(0,X.jsxs)(`button`,{type:`button`,className:Be(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,X.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,X.jsx)(D,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,X.jsx)(Yt,{tokens:r,mode:i}):(0,X.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,X.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]}),o?(0,X.jsx)(k,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-chart-card__export`,onClick:o,"aria-label":S(),title:S(),children:(0,X.jsx)(ft,{className:`size-4`})}):null]})}function Zt({selectedKey:e,resolvedMode:t}){let n=T(u.charts.listMyCharts),r=b(u.charts.setMyChart);async function i(e){try{await r({name:e})}catch{}}return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:Me()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,X.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,X.jsx)(Xt,{selected:e===null,title:w(),subtitle:De(),tokens:null,mode:t,onSelect:()=>void i(null)}),(n??[]).map(n=>{let r=n.via===`common`?we():n.via===`owner`?nt():Le({group:n.via.group});return(0,X.jsx)(Xt,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void i(n.key),onExport:()=>Gt(n.name,n.tokens)},n.key)})]}),n!==void 0&&n.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Se()}):null]})}function Qt(){let e=b(u.charts.importChart),[t,n]=(0,K.useState)(``),[r,i]=(0,K.useState)(``),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[d,f]=(0,K.useState)(!1);async function h(e){let t=e.target.files?.[0];if(e.target.value=``,t){s(null),l(!1);try{i(await t.text())}catch{s(a())}}}async function v(){if(s(null),l(!1),t.trim()===``){s(ie());return}let o;try{o=JSON.parse(r)}catch{s(a());return}f(!0);try{await e({name:t.trim(),tokens:o}),l(!0),n(``),i(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{f(!1)}}return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:g()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:qe()})]}),(0,X.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:_()}),(0,X.jsx)(F,{value:t,onChange:e=>n(e.target.value),placeholder:p(),maxLength:60})]}),(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:ue()}),(0,X.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:r,onChange:e=>i(e.target.value),placeholder:ce(),rows:8,spellCheck:!1})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,X.jsx)(G,{className:`size-4`}),m(),(0,X.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void h(e)})]})}),(0,X.jsx)(k,{size:`sm`,disabled:d,onClick:()=>void v(),children:le()})]}),o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null,c?(0,X.jsx)(`p`,{className:`oc-chart-import__ok`,children:dt()}):null]})]})}function $t({chart:e}){let t=je(u.charts.setChartLogo),n=b(u.charts.removeChartLogo),[r,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function f(n,r,i){if(e.chartId!==void 0){s(null),a(!0);try{let{blob:a,hasAlpha:o}=await Ut(r,i?{variantFor:i}:{}),s=await a.arrayBuffer();await t({chartId:e.chartId,bytes:s,mode:n,hasAlpha:o})}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}}async function p(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await f(e,n)}async function m(t){if(e.chartId!==void 0){s(null),a(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}}async function h(e){let t=c(e===`light`?`dark`:`light`);if(t){s(null),a(!0);try{await f(e,await(await fetch(t)).blob(),e)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}}function g({mode:e}){let t=c(e),n=c(e===`light`?`dark`:`light`);return(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?Fe():i()}),(0,X.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,X.jsx)(`img`,{src:t,alt:``}):null}),(0,X.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,X.jsx)(G,{className:`size-4`}),t?te():Ie(),(0,X.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void p(e,t)})]})}),!t&&n?(0,X.jsx)(k,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void h(e),children:d()}):null,t?(0,X.jsx)(k,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void m(e),children:l()}):null]})}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:y()}),(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,X.jsx)(g,{mode:`light`}),(0,X.jsx)(g,{mode:`dark`})]}),r?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:se()}):null,o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})}function en({chart:e}){let t=T(u.me.getMe,{host:B}),n=b(u.charts.addChartDomain),r=b(u.charts.removeChartDomain),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1);if(t?.role!==`admin`)return null;let d=e.domains??[];async function f(){let t=i.trim();if(t!==``){s(null),l(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}async function p(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:ct()}),(0,X.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,X.jsx)(`div`,{className:`oc-chart-avail__groups`,children:d.length===0?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Ae()}):d.map(e=>(0,X.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":Re({domain:e}),onClick:()=>void p(e),children:(0,X.jsx)(O,{className:`size-3`})})]},e))}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(F,{value:i,onChange:e=>a(e.target.value),placeholder:me(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&f()}}),(0,X.jsx)(k,{variant:`outline`,size:`sm`,disabled:c,onClick:()=>void f(),children:Oe()})]}),(0,X.jsx)(`span`,{className:`oc-show__desc`,children:rt()}),o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function tn(e){let t={...e};return delete t.bpm,JSON.stringify(t,null,2)}function nn({chart:e}){let t=b(u.charts.updateChart),n=b(u.charts.deleteChart),[r,i]=(0,K.useState)(!1),[o,s]=(0,K.useState)(e.name),[c,l]=(0,K.useState)(()=>tn(e.tokens)),[d,f]=(0,K.useState)(e.tokens.bpm??0),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1);function _(){s(e.name),l(tn(e.tokens)),f(e.tokens.bpm??0),m(null),i(!0)}async function v(){if(e.chartId===void 0)return;m(null);let n;try{n=JSON.parse(c)}catch{m(a());return}if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n;d>0?e.bpm=d:delete e.bpm}g(!0);try{await t({chartId:e.chartId,name:o.trim(),tokens:n}),i(!1)}catch(e){m(e instanceof Error?e.message:String(e))}finally{g(!1)}}async function y(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:r?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{variant:`outline`,size:`sm`,onClick:_,children:ne()}),(0,X.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>void y(),children:ee()})]})})]}),r?(0,X.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:Ce()}),(0,X.jsx)(F,{value:o,onChange:e=>s(e.target.value),maxLength:60})]}),(0,X.jsxs)(`div`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:lt()}),(0,X.jsxs)(`div`,{className:`oc-chart-bpm`,children:[(0,X.jsx)(`input`,{type:`range`,className:`oc-chart-bpm__slider`,min:0,max:90,step:5,value:d,onChange:e=>f(Number(e.target.value)),"aria-label":lt()}),(0,X.jsx)(`span`,{className:`oc-chart-bpm__value`,children:d===0?it():`${d} BPM`})]}),(0,X.jsx)(`span`,{className:`oc-show__desc`,children:he()})]}),(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:tt()}),(0,X.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:c,onChange:e=>l(e.target.value),rows:10,spellCheck:!1})]}),p?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:p}):null,(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{size:`sm`,disabled:h,onClick:()=>void v(),children:Ke()}),(0,X.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>i(!1),children:Ee()})]})]}):null,(0,X.jsx)($t,{chart:e}),(0,X.jsx)(en,{chart:e})]})}function rn(){let e=T(u.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:v()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:h()})]}),e!==void 0&&t.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:f()}):(0,X.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,X.jsx)(nn,{chart:e},e.key))})]})}function an({chart:e,groups:t}){let n=b(u.charts.addChartToGroupPool),i=b(u.charts.removeChartFromGroupPool),a=e.restrictedToGroups,o=e.poolGroups,s=new Set((o??[]).map(e=>e.groupId)),c=t.filter(e=>!s.has(e._id));async function l(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function d(t){try{await i({groupId:t,chartKey:e.key})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,X.jsx)(P,{variant:a?`secondary`:`outline`,className:`oc-chart-avail__state`,children:a?Te():e.kind===`custom`&&e.scope===`personal`?x():et()}),e.isGlobalDefault?(0,X.jsx)(P,{variant:`default`,children:r()}):null]}),(0,X.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:pe()}),(o??[]).map(e=>(0,X.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,X.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":fe({group:e.name}),onClick:()=>void d(e.groupId),children:(0,X.jsx)(O,{className:`size-3`})})]},e.groupId)),c.length>0?(0,X.jsxs)(V,{value:``,onValueChange:e=>void l(e),children:[(0,X.jsx)(z,{size:`sm`,className:`w-56`,children:(0,X.jsx)(M,{placeholder:de()})}),(0,X.jsx)(j,{children:c.map(e=>(0,X.jsx)(A,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:re()}):null]})]})}function on({chart:e}){let t=b(u.charts.promoteChartToCommon),n=b(u.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,X.jsx)(P,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?Ne():x()}),e.ownerLabel?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Ue({owner:e.ownerLabel})}):null]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,X.jsx)(k,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:Je()}):null,(0,X.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:Ve()})]})]})}function sn({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=b(u.admin.setDefaultThemeMode),i=b(u.admin.setDefaultLocale),a=b(u.charts.setDefaultChart),o=T(u.charts.listChartsAdmin),c=T(u.groups.listGroups,{}),l=e??`system`,d=t??`fr`;return(0,X.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:ge()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ke()})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Qe()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Ge()})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void a({name:null}),children:w()}),mt.map(e=>(0,X.jsx)(k,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key)),(o??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,X.jsx)(k,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key))]})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:ve()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Pe()})]}),(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,X.jsx)(an,{chart:e,groups:c??[]},e.key))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Ye()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:He()})]}),(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,X.jsx)(en,{chart:e})]},e.key))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:xe()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Xe()})]}),(()=>{let e=(o??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:$e()}):(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,X.jsx)(on,{chart:e},e.key))})})()]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:s()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:oe()})]}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,X.jsx)(k,{variant:l===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:qt(e)},e))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:st()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:be()})]}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:yt().map(e=>(0,X.jsx)(k,{variant:d===e.value?`default`:`outline`,size:`sm`,onClick:()=>void i({locale:e.value}),children:e.label},e.value))}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ut()})]})]})}function cn(){let e=T(u.me.getMe,{host:B}),t=vt(e?.resolvedThemeMode);return(0,X.jsxs)(`div`,{className:`oc-appearance`,children:[(0,X.jsx)(Zt,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,X.jsx)(Qt,{}),(0,X.jsx)(rn,{}),e?.role===`admin`?(0,X.jsx)(sn,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function ln(){let[e,t]=(0,K.useState)(!0),[n,r]=(0,K.useState)(`per-user`),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(Z),[c,l]=(0,K.useState)(Z),[u,d]=(0,K.useState)(Q),f=i!==``||o!==Z||c!==Z;function p(){a(``),s(Z),l(Z),d(Q)}return(0,X.jsxs)(`div`,{className:`oc-show`,children:[(0,X.jsx)(cn,{}),(0,X.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,X.jsx)(`summary`,{className:`oc-show__title`,children:at()}),(0,X.jsxs)($,{title:`Buttons`,description:`Variants`,children:[(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{children:`Default`}),(0,X.jsx)(k,{variant:`secondary`,children:`Secondary`}),(0,X.jsx)(k,{variant:`outline`,children:`Outline`}),(0,X.jsx)(k,{variant:`ghost`,children:`Ghost`}),(0,X.jsx)(k,{variant:`destructive`,children:`Destructive`}),(0,X.jsx)(k,{variant:`link`,children:`Link`})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{size:`sm`,children:`Small`}),(0,X.jsx)(k,{children:`Default`}),(0,X.jsx)(k,{size:`lg`,children:`Large`}),(0,X.jsx)(k,{size:`icon`,"aria-label":`more`,children:(0,X.jsx)(N,{})}),(0,X.jsx)(k,{disabled:!0,children:`Disabled`})]})]}),(0,X.jsx)($,{title:`Badges`,children:(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(P,{children:`Default`}),(0,X.jsx)(P,{variant:`secondary`,children:`Secondary`}),(0,X.jsx)(P,{variant:`outline`,children:`Outline`}),(0,X.jsx)(P,{variant:`destructive`,children:`Destructive`})]})}),(0,X.jsx)($,{title:`Inputs & selection`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsx)(F,{placeholder:`Text input…`}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsxs)(V,{value:n,onValueChange:r,children:[(0,X.jsx)(z,{className:`w-56`,children:(0,X.jsx)(M,{placeholder:`Select…`})}),(0,X.jsxs)(j,{children:[(0,X.jsx)(A,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,X.jsx)(A,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,X.jsxs)(`label`,{className:`oc-show__check`,children:[(0,X.jsx)(L,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,X.jsx)($,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsxs)(At,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:u,onTimeRangeChange:d,onReset:p,canReset:f,children:[(0,X.jsxs)(V,{value:o,onValueChange:s,children:[(0,X.jsx)(z,{size:`sm`,children:(0,X.jsx)(M,{})}),(0,X.jsxs)(j,{children:[(0,X.jsx)(A,{value:Z,children:`Toutes directions`}),(0,X.jsx)(A,{value:`inbound`,children:`inbound`}),(0,X.jsx)(A,{value:`outbound`,children:`outbound`}),(0,X.jsx)(A,{value:`internal`,children:`internal`})]})]}),(0,X.jsxs)(V,{value:c,onValueChange:l,children:[(0,X.jsx)(z,{size:`sm`,children:(0,X.jsx)(M,{})}),(0,X.jsxs)(j,{children:[(0,X.jsx)(A,{value:Z,children:`Toutes sévérités`}),(0,X.jsx)(A,{value:`info`,children:`info`}),(0,X.jsx)(A,{value:`warn`,children:`warn`}),(0,X.jsx)(A,{value:`critical`,children:`critical`})]})]})]}),(0,X.jsx)(jt,{fields:Kt,onChange:()=>{}}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,X.jsx)(kt,{value:u,onChange:d})]})]})}),(0,X.jsx)($,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,X.jsxs)(pt,{children:[(0,X.jsx)(_t,{asChild:!0,children:(0,X.jsx)(k,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,X.jsx)(N,{})})}),(0,X.jsxs)(gt,{align:`start`,children:[(0,X.jsx)(ht,{children:`Actions`}),(0,X.jsx)(I,{}),(0,X.jsx)(R,{children:`Edit`}),(0,X.jsx)(R,{children:`Duplicate`}),(0,X.jsx)(I,{}),(0,X.jsx)(R,{variant:`destructive`,children:`Delete`})]})]})}),(0,X.jsx)($,{title:`Card`,children:(0,X.jsxs)(Tt,{className:`w-80`,children:[(0,X.jsxs)(bt,{children:[(0,X.jsx)(Ct,{children:`Instance`}),(0,X.jsx)(wt,{children:`Non-secret metadata only.`})]}),(0,X.jsx)(St,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,X.jsxs)(xt,{className:`gap-2`,children:[(0,X.jsx)(k,{size:`sm`,children:`Save`}),(0,X.jsx)(k,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,X.jsx)($,{title:`Table`,children:(0,X.jsxs)(Ot,{children:[(0,X.jsx)(Et,{children:(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{className:`w-8`,children:(0,X.jsx)(L,{"aria-label":`select all`})}),(0,X.jsx)(H,{children:`Name`}),(0,X.jsx)(H,{children:`Mode`}),(0,X.jsx)(H,{className:`text-right`,children:`Status`}),(0,X.jsx)(H,{className:`w-8`})]})}),(0,X.jsx)(Dt,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,X.jsxs)(U,{children:[(0,X.jsx)(W,{children:(0,X.jsx)(L,{"aria-label":`select ${e.n}`})}),(0,X.jsx)(W,{className:`font-medium`,children:e.n}),(0,X.jsx)(W,{children:(0,X.jsx)(P,{variant:`secondary`,children:e.m})}),(0,X.jsx)(W,{className:`text-right`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(D,{className:`size-3.5`}),` `,e.s]})}),(0,X.jsx)(W,{children:(0,X.jsx)(k,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,X.jsx)(N,{})})})]},e.n))})]})}),(0,X.jsx)($,{title:`App fragments`,description:`Chat-specific components`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,X.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,X.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,X.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,X.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,X.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,X.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,X.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,X.jsx)(`span`,{className:`oc-run-status__dot`}),(0,X.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}export{ln as ThemeShowroom};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$A as r,AA as i,BA as a,CA as o,Cj as s,D as c,DA as l,E as u,EA as d,FA as f,GA as p,HA as m,IA as h,JA as g,KA as _,LA as v,MA as y,NA as ee,OA as te,PA as ne,QA as re,RA as ie,SA as ae,Sj as oe,TA as se,UA as ce,VA as le,WA as ue,XA as de,YA as fe,ZA as pe,_A as me,_P as b,_a as he,_j as ge,aA as x,aP as _e,aj as ve,bA as ye,ba as S,bj as be,cA as xe,cj as Se,dA as Ce,dj as we,ej as Te,fA as Ee,fj as De,gA as Oe,gj as ke,hA as Ae,hP as je,hj as Me,iA as Ne,ij as Pe,jA as Fe,kA as Ie,lA as C,lj as Le,mA as Re,mj as ze,n as Be,nA as Ve,nj as He,oA as Ue,oP as We,oj as Ge,pA as Ke,pj as w,qA as qe,rA as Je,rj as Ye,sA as Xe,sP as Ze,sj as Qe,tA as $e,tj as et,uA as tt,uj as nt,vA as rt,vP as T,va as it,vj as at,wA as ot,xA as E,xj as st,yA as ct,ya as lt,yj as ut,zA as dt}from"./dist-BKXYNjW7.js";import{n as D}from"./dist-x2y4VoOj.js";import{t as O}from"./x-B77pQElB.js";import{t as k}from"./button-CdHluvSK.js";import{C as A,S as j,T as M,Xt as ft,Yt as N,at as pt,bt as mt,ct as ht,dt as P,ft as F,lt as I,m as L,ot as gt,st as R,ut as _t,w as z,wt as B,x as V,yt as vt}from"./index-CnNzzVmB.js";import{t as yt}from"./localePickerView-C2RmOS86.js";import{a as bt,i as xt,n as St,o as Ct,r as wt,t as Tt}from"./card-AXe34vGw.js";import{a as Et,i as H,n as Dt,o as U,r as W,t as Ot}from"./table-BlgvNhKf.js";import{t as kt}from"./TimeRangePicker-CxfILbJE.js";import{t as At}from"./FilterBar-CGBz7_qR.js";import{t as jt}from"./AdvancedFilter-gE4hTfw8.js";var G=c(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),K=t(e(),1),Mt=.1,Nt=[248,248,248],Pt=[24,24,24];function Ft(e,t,n){let r=t,i=n,a=-1,o=-1;for(let s=0;s<n;s++)for(let n=0;n<t;n++)e[(s*t+n)*4+3]>8&&(n<r&&(r=n),n>a&&(a=n),s<i&&(i=s),s>o&&(o=s));return a<0?null:{x:r,y:i,width:a-r+1,height:o-i+1}}function It(e,t,n){let r=t*n;if(r===0)return 0;let i=0;for(let t=3;t<e.length;t+=4)e[t]<=8&&i++;return i/r}function q(e,t,n){return It(e,t,n)>=Mt}function Lt(e,t){for(let n=0;n<e.length;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2]}function Rt(e){for(let t=0;t<e.length;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]}var zt=12*1024*1024,Bt=480,Vt=160,Ht=.92;async function Ut(e,t={}){if(!e.type.startsWith(`image/`))throw Error(ot());if(e.size>zt)throw Error(o());let{source:n,width:r,height:i,cleanup:a}=await Wt(e);try{let a=e.type===`image/svg+xml`,o=Math.min(Bt/r,Vt/i,a?1/0:1),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o)),l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u)throw Error(E());u.imageSmoothingEnabled=!0,u.imageSmoothingQuality=`high`,u.drawImage(n,0,0,s,c);let d=Ft(u.getImageData(0,0,s,c).data,s,c)??{x:0,y:0,width:s,height:c},f=document.createElement(`canvas`);f.width=d.width,f.height=d.height;let p=f.getContext(`2d`);if(!p)throw Error(E());if(p.drawImage(l,d.x,d.y,d.width,d.height,0,0,d.width,d.height),t.variantFor){let e=p.getImageData(0,0,d.width,d.height);q(e.data,d.width,d.height)?Lt(e.data,t.variantFor===`dark`?Nt:Pt):Rt(e.data),p.putImageData(e,0,0)}let m=q(p.getImageData(0,0,d.width,d.height).data,d.width,d.height),h=await Y(f,`image/webp`,Ht)??await Y(f,`image/png`);if(!h)throw Error(ye());return{blob:h,hasAlpha:m}}finally{a()}}async function Wt(e){if(e.type===`image/svg+xml`)return J(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return J(e)}async function J(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(ae())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function Y(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var X=n();function Gt(e,t){let n=e.trim().replace(/[^A-Za-z0-9_.-]+/g,`-`).replace(/^-+|-+$/g,``)||`chart`,r=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`${n}.chart.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var Z=`__all__`,Q={kind:`relative`,from:`now-24h`,to:`now`},Kt=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function $({title:e,description:t,children:n}){return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,X.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function qt(e){return e===`light`?Ze():e===`dark`?We():_e()}var Jt=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function Yt({tokens:e,mode:t}){let n=e.colors[t];return(0,X.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:Jt.map(e=>{let t=n[e];return(0,X.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function Xt({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a,onExport:o}){return(0,X.jsxs)(`div`,{className:`oc-chart-card-wrap`,children:[(0,X.jsxs)(`button`,{type:`button`,className:Be(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,X.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,X.jsx)(D,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,X.jsx)(Yt,{tokens:r,mode:i}):(0,X.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,X.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]}),o?(0,X.jsx)(k,{type:`button`,variant:`ghost`,size:`icon`,className:`oc-chart-card__export`,onClick:o,"aria-label":S(),title:S(),children:(0,X.jsx)(ft,{className:`size-4`})}):null]})}function Zt({selectedKey:e,resolvedMode:t}){let n=T(u.charts.listMyCharts),r=b(u.charts.setMyChart);async function i(e){try{await r({name:e})}catch{}}return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:Me()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,X.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,X.jsx)(Xt,{selected:e===null,title:w(),subtitle:De(),tokens:null,mode:t,onSelect:()=>void i(null)}),(n??[]).map(n=>{let r=n.via===`common`?we():n.via===`owner`?nt():Le({group:n.via.group});return(0,X.jsx)(Xt,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void i(n.key),onExport:()=>Gt(n.name,n.tokens)},n.key)})]}),n!==void 0&&n.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Se()}):null]})}function Qt(){let e=b(u.charts.importChart),[t,n]=(0,K.useState)(``),[r,i]=(0,K.useState)(``),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[d,f]=(0,K.useState)(!1);async function h(e){let t=e.target.files?.[0];if(e.target.value=``,t){s(null),l(!1);try{i(await t.text())}catch{s(a())}}}async function v(){if(s(null),l(!1),t.trim()===``){s(ie());return}let o;try{o=JSON.parse(r)}catch{s(a());return}f(!0);try{await e({name:t.trim(),tokens:o}),l(!0),n(``),i(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{f(!1)}}return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:g()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:qe()})]}),(0,X.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:_()}),(0,X.jsx)(F,{value:t,onChange:e=>n(e.target.value),placeholder:p(),maxLength:60})]}),(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:ue()}),(0,X.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:r,onChange:e=>i(e.target.value),placeholder:ce(),rows:8,spellCheck:!1})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,X.jsx)(G,{className:`size-4`}),m(),(0,X.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void h(e)})]})}),(0,X.jsx)(k,{size:`sm`,disabled:d,onClick:()=>void v(),children:le()})]}),o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null,c?(0,X.jsx)(`p`,{className:`oc-chart-import__ok`,children:dt()}):null]})]})}function $t({chart:e}){let t=je(u.charts.setChartLogo),n=b(u.charts.removeChartLogo),[r,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(null),c=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function f(n,r,i){if(e.chartId!==void 0){s(null),a(!0);try{let{blob:a,hasAlpha:o}=await Ut(r,i?{variantFor:i}:{}),s=await a.arrayBuffer();await t({chartId:e.chartId,bytes:s,mode:n,hasAlpha:o})}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}}async function p(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await f(e,n)}async function m(t){if(e.chartId!==void 0){s(null),a(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}}async function h(e){let t=c(e===`light`?`dark`:`light`);if(t){s(null),a(!0);try{await f(e,await(await fetch(t)).blob(),e)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}}function g({mode:e}){let t=c(e),n=c(e===`light`?`dark`:`light`);return(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?Fe():i()}),(0,X.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,X.jsx)(`img`,{src:t,alt:``}):null}),(0,X.jsx)(k,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,X.jsx)(G,{className:`size-4`}),t?te():Ie(),(0,X.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void p(e,t)})]})}),!t&&n?(0,X.jsx)(k,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void h(e),children:d()}):null,t?(0,X.jsx)(k,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void m(e),children:l()}):null]})}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:y()}),(0,X.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,X.jsx)(g,{mode:`light`}),(0,X.jsx)(g,{mode:`dark`})]}),r?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:se()}):null,o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})}function en({chart:e}){let t=T(u.me.getMe,{host:B}),n=b(u.charts.addChartDomain),r=b(u.charts.removeChartDomain),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1);if(t?.role!==`admin`)return null;let d=e.domains??[];async function f(){let t=i.trim();if(t!==``){s(null),l(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}async function p(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:ct()}),(0,X.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,X.jsx)(`div`,{className:`oc-chart-avail__groups`,children:d.length===0?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Ae()}):d.map(e=>(0,X.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,X.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":Re({domain:e}),onClick:()=>void p(e),children:(0,X.jsx)(O,{className:`size-3`})})]},e))}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(F,{value:i,onChange:e=>a(e.target.value),placeholder:me(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&f()}}),(0,X.jsx)(k,{variant:`outline`,size:`sm`,disabled:c,onClick:()=>void f(),children:Oe()})]}),(0,X.jsx)(`span`,{className:`oc-show__desc`,children:rt()}),o?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function tn(e){let t={...e};return delete t.bpm,JSON.stringify(t,null,2)}function nn({chart:e}){let t=b(u.charts.updateChart),n=b(u.charts.deleteChart),[r,i]=(0,K.useState)(!1),[o,s]=(0,K.useState)(e.name),[c,l]=(0,K.useState)(()=>tn(e.tokens)),[d,f]=(0,K.useState)(e.tokens.bpm??0),[p,m]=(0,K.useState)(null),[h,g]=(0,K.useState)(!1);function _(){s(e.name),l(tn(e.tokens)),f(e.tokens.bpm??0),m(null),i(!0)}async function v(){if(e.chartId===void 0)return;m(null);let n;try{n=JSON.parse(c)}catch{m(a());return}if(n&&typeof n==`object`&&!Array.isArray(n)){let e=n;d>0?e.bpm=d:delete e.bpm}g(!0);try{await t({chartId:e.chartId,name:o.trim(),tokens:n}),i(!1)}catch(e){m(e instanceof Error?e.message:String(e))}finally{g(!1)}}async function y(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:r?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{variant:`outline`,size:`sm`,onClick:_,children:ne()}),(0,X.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>void y(),children:ee()})]})})]}),r?(0,X.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:Ce()}),(0,X.jsx)(F,{value:o,onChange:e=>s(e.target.value),maxLength:60})]}),(0,X.jsxs)(`div`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:lt()}),(0,X.jsxs)(`div`,{className:`oc-chart-bpm`,children:[(0,X.jsx)(`input`,{type:`range`,className:`oc-chart-bpm__slider`,min:0,max:90,step:5,value:d,onChange:e=>f(Number(e.target.value)),"aria-label":lt()}),(0,X.jsx)(`span`,{className:`oc-chart-bpm__value`,children:d===0?it():`${d} BPM`})]}),(0,X.jsx)(`span`,{className:`oc-show__desc`,children:he()})]}),(0,X.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,X.jsx)(`span`,{className:`oc-chart-import__label`,children:tt()}),(0,X.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:c,onChange:e=>l(e.target.value),rows:10,spellCheck:!1})]}),p?(0,X.jsx)(`p`,{className:`oc-chart-import__error`,children:p}):null,(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{size:`sm`,disabled:h,onClick:()=>void v(),children:Ke()}),(0,X.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>i(!1),children:Ee()})]})]}):null,(0,X.jsx)($t,{chart:e}),(0,X.jsx)(en,{chart:e})]})}function rn(){let e=T(u.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:v()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:h()})]}),e!==void 0&&t.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:f()}):(0,X.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,X.jsx)(nn,{chart:e},e.key))})]})}function an({chart:e,groups:t}){let n=b(u.charts.addChartToGroupPool),i=b(u.charts.removeChartFromGroupPool),a=e.restrictedToGroups,o=e.poolGroups,s=new Set((o??[]).map(e=>e.groupId)),c=t.filter(e=>!s.has(e._id));async function l(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function d(t){try{await i({groupId:t,chartKey:e.key})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,X.jsx)(P,{variant:a?`secondary`:`outline`,className:`oc-chart-avail__state`,children:a?Te():e.kind===`custom`&&e.scope===`personal`?x():et()}),e.isGlobalDefault?(0,X.jsx)(P,{variant:`default`,children:r()}):null]}),(0,X.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,X.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:pe()}),(o??[]).map(e=>(0,X.jsxs)(P,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,X.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":fe({group:e.name}),onClick:()=>void d(e.groupId),children:(0,X.jsx)(O,{className:`size-3`})})]},e.groupId)),c.length>0?(0,X.jsxs)(V,{value:``,onValueChange:e=>void l(e),children:[(0,X.jsx)(z,{size:`sm`,className:`w-56`,children:(0,X.jsx)(M,{placeholder:de()})}),(0,X.jsx)(j,{children:c.map(e=>(0,X.jsx)(A,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:re()}):null]})]})}function on({chart:e}){let t=b(u.charts.promoteChartToCommon),n=b(u.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(C()))try{await n({chartId:e.chartId})}catch{}}return(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,X.jsx)(P,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?Ne():x()}),e.ownerLabel?(0,X.jsx)(`span`,{className:`oc-show__desc`,children:Ue({owner:e.ownerLabel})}):null]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,X.jsx)(k,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:Je()}):null,(0,X.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:Ve()})]})]})}function sn({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=b(u.admin.setDefaultThemeMode),i=b(u.admin.setDefaultLocale),a=b(u.charts.setDefaultChart),o=T(u.charts.listChartsAdmin),c=T(u.groups.listGroups,{}),l=e??`system`,d=t??`fr`;return(0,X.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h2`,{className:`oc-show__title`,children:ge()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ke()})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Qe()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Ge()})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void a({name:null}),children:w()}),mt.map(e=>(0,X.jsx)(k,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key)),(o??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,X.jsx)(k,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key))]})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:ve()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Pe()})]}),(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,X.jsx)(an,{chart:e,groups:c??[]},e.key))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:Ye()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:He()})]}),(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,X.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,X.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,X.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,X.jsx)(en,{chart:e})]},e.key))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:xe()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:Xe()})]}),(()=>{let e=(o??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,X.jsx)(`p`,{className:`oc-show__desc`,children:$e()}):(0,X.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,X.jsx)(on,{chart:e},e.key))})})()]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:s()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:oe()})]}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,X.jsx)(k,{variant:l===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:qt(e)},e))})]}),(0,X.jsxs)(`section`,{className:`oc-show__section`,children:[(0,X.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,X.jsx)(`h3`,{className:`oc-show__title`,children:st()}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:be()})]}),(0,X.jsx)(`div`,{className:`oc-show__row`,children:yt().map(e=>(0,X.jsx)(k,{variant:d===e.value?`default`:`outline`,size:`sm`,onClick:()=>void i({locale:e.value}),children:e.label},e.value))}),(0,X.jsx)(`p`,{className:`oc-show__desc`,children:ut()})]})]})}function cn(){let e=T(u.me.getMe,{host:B}),t=vt(e?.resolvedThemeMode);return(0,X.jsxs)(`div`,{className:`oc-appearance`,children:[(0,X.jsx)(Zt,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,X.jsx)(Qt,{}),(0,X.jsx)(rn,{}),e?.role===`admin`?(0,X.jsx)(sn,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function ln(){let[e,t]=(0,K.useState)(!0),[n,r]=(0,K.useState)(`per-user`),[i,a]=(0,K.useState)(``),[o,s]=(0,K.useState)(Z),[c,l]=(0,K.useState)(Z),[u,d]=(0,K.useState)(Q),f=i!==``||o!==Z||c!==Z;function p(){a(``),s(Z),l(Z),d(Q)}return(0,X.jsxs)(`div`,{className:`oc-show`,children:[(0,X.jsx)(cn,{}),(0,X.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,X.jsx)(`summary`,{className:`oc-show__title`,children:at()}),(0,X.jsxs)($,{title:`Buttons`,description:`Variants`,children:[(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{children:`Default`}),(0,X.jsx)(k,{variant:`secondary`,children:`Secondary`}),(0,X.jsx)(k,{variant:`outline`,children:`Outline`}),(0,X.jsx)(k,{variant:`ghost`,children:`Ghost`}),(0,X.jsx)(k,{variant:`destructive`,children:`Destructive`}),(0,X.jsx)(k,{variant:`link`,children:`Link`})]}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(k,{size:`sm`,children:`Small`}),(0,X.jsx)(k,{children:`Default`}),(0,X.jsx)(k,{size:`lg`,children:`Large`}),(0,X.jsx)(k,{size:`icon`,"aria-label":`more`,children:(0,X.jsx)(N,{})}),(0,X.jsx)(k,{disabled:!0,children:`Disabled`})]})]}),(0,X.jsx)($,{title:`Badges`,children:(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(P,{children:`Default`}),(0,X.jsx)(P,{variant:`secondary`,children:`Secondary`}),(0,X.jsx)(P,{variant:`outline`,children:`Outline`}),(0,X.jsx)(P,{variant:`destructive`,children:`Destructive`})]})}),(0,X.jsx)($,{title:`Inputs & selection`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsx)(F,{placeholder:`Text input…`}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsxs)(V,{value:n,onValueChange:r,children:[(0,X.jsx)(z,{className:`w-56`,children:(0,X.jsx)(M,{placeholder:`Select…`})}),(0,X.jsxs)(j,{children:[(0,X.jsx)(A,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,X.jsx)(A,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,X.jsxs)(`label`,{className:`oc-show__check`,children:[(0,X.jsx)(L,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,X.jsx)($,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsxs)(At,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:u,onTimeRangeChange:d,onReset:p,canReset:f,children:[(0,X.jsxs)(V,{value:o,onValueChange:s,children:[(0,X.jsx)(z,{size:`sm`,children:(0,X.jsx)(M,{})}),(0,X.jsxs)(j,{children:[(0,X.jsx)(A,{value:Z,children:`Toutes directions`}),(0,X.jsx)(A,{value:`inbound`,children:`inbound`}),(0,X.jsx)(A,{value:`outbound`,children:`outbound`}),(0,X.jsx)(A,{value:`internal`,children:`internal`})]})]}),(0,X.jsxs)(V,{value:c,onValueChange:l,children:[(0,X.jsx)(z,{size:`sm`,children:(0,X.jsx)(M,{})}),(0,X.jsxs)(j,{children:[(0,X.jsx)(A,{value:Z,children:`Toutes sévérités`}),(0,X.jsx)(A,{value:`info`,children:`info`}),(0,X.jsx)(A,{value:`warn`,children:`warn`}),(0,X.jsx)(A,{value:`critical`,children:`critical`})]})]})]}),(0,X.jsx)(jt,{fields:Kt,onChange:()=>{}}),(0,X.jsxs)(`div`,{className:`oc-show__row`,children:[(0,X.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,X.jsx)(kt,{value:u,onChange:d})]})]})}),(0,X.jsx)($,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,X.jsxs)(pt,{children:[(0,X.jsx)(_t,{asChild:!0,children:(0,X.jsx)(k,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,X.jsx)(N,{})})}),(0,X.jsxs)(gt,{align:`start`,children:[(0,X.jsx)(ht,{children:`Actions`}),(0,X.jsx)(I,{}),(0,X.jsx)(R,{children:`Edit`}),(0,X.jsx)(R,{children:`Duplicate`}),(0,X.jsx)(I,{}),(0,X.jsx)(R,{variant:`destructive`,children:`Delete`})]})]})}),(0,X.jsx)($,{title:`Card`,children:(0,X.jsxs)(Tt,{className:`w-80`,children:[(0,X.jsxs)(bt,{children:[(0,X.jsx)(Ct,{children:`Instance`}),(0,X.jsx)(wt,{children:`Non-secret metadata only.`})]}),(0,X.jsx)(St,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,X.jsxs)(xt,{className:`gap-2`,children:[(0,X.jsx)(k,{size:`sm`,children:`Save`}),(0,X.jsx)(k,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,X.jsx)($,{title:`Table`,children:(0,X.jsxs)(Ot,{children:[(0,X.jsx)(Et,{children:(0,X.jsxs)(U,{children:[(0,X.jsx)(H,{className:`w-8`,children:(0,X.jsx)(L,{"aria-label":`select all`})}),(0,X.jsx)(H,{children:`Name`}),(0,X.jsx)(H,{children:`Mode`}),(0,X.jsx)(H,{className:`text-right`,children:`Status`}),(0,X.jsx)(H,{className:`w-8`})]})}),(0,X.jsx)(Dt,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,X.jsxs)(U,{children:[(0,X.jsx)(W,{children:(0,X.jsx)(L,{"aria-label":`select ${e.n}`})}),(0,X.jsx)(W,{className:`font-medium`,children:e.n}),(0,X.jsx)(W,{children:(0,X.jsx)(P,{variant:`secondary`,children:e.m})}),(0,X.jsx)(W,{className:`text-right`,children:(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,X.jsx)(D,{className:`size-3.5`}),` `,e.s]})}),(0,X.jsx)(W,{children:(0,X.jsx)(k,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,X.jsx)(N,{})})})]},e.n))})]})}),(0,X.jsx)($,{title:`App fragments`,description:`Chat-specific components`,children:(0,X.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,X.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,X.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,X.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,X.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,X.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,X.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,X.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,X.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,X.jsx)(`span`,{className:`oc-run-status__dot`}),(0,X.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}export{ln as ThemeShowroom};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{_r as r,ah as i,ch as a,dh as o,fh as s,gr as c,hh as l,hr as u,ih as d,lh as f,mh as p,mr as m,oh as h,ph as g,pr as _,rh as v,sh as y,uh as b,vr as x,yr as S}from"./dist-BKXYNjW7.js";import{t as C}from"./button-CdHluvSK.js";import{Dt as w,Et as T,Ot as E,Qt as D,Rt as O,Tt as k,ft as A,rt as j}from"./index-DZcxHX-q.js";var M=t(e(),1),N={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function P(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=N[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function F(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:P(e.from,t)??t-N.h,to:P(e.to,t)??t}}var I=[{label:l(),from:`now-5m`},{label:p(),from:`now-15m`},{label:g(),from:`now-30m`},{label:s(),from:`now-1h`},{label:o(),from:`now-3h`},{label:b(),from:`now-6h`},{label:f(),from:`now-12h`},{label:a(),from:`now-24h`},{label:y(),from:`now-2d`},{label:h(),from:`now-7d`},{label:i(),from:`now-30d`},{label:d(),from:`now-90d`},{label:v(),from:`now-520w`}];function L(e){return j(e,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function R(e){if(e.kind===`relative`){let t=I.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${L(e.from)} → ${L(e.to)}`}function z(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function B(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function V(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}var H=n();function U(e){let[t,n]=(0,M.useState)(0);return(0,M.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,M.useMemo)(()=>{let{from:t,to:n}=F(e);return e.kind===`absolute`?{from:t,to:n}:{from:W(t),to:W(n)}},[e,t])}function W(e){return Math.floor(e/6e4)*6e4}function G({value:e,onChange:t}){let[n,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)(``),s=F(e),[l,d]=(0,M.useState)(()=>z(s.from)),[f,p]=(0,M.useState)(()=>z(s.to));function h(t){if(t){let t=F(e);d(z(t.from)),p(z(t.to)),o(``)}i(t)}function g(e){t({kind:`relative`,from:e,to:`now`}),i(!1)}function v(){let e=B(l),n=B(f);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),i(!1))}let y=(0,M.useMemo)(()=>{let e=a.trim().toLowerCase();return e===``?I:I.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[a]),b=B(l)!==null&&B(f)!==null;return(0,H.jsxs)(w,{open:n,onOpenChange:h,children:[(0,H.jsx)(E,{asChild:!0,children:(0,H.jsxs)(C,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,H.jsx)(D,{}),R(e)]})}),(0,H.jsx)(T,{children:(0,H.jsx)(k,{align:`end`,sideOffset:6,className:`oc-timerange__panel z-50 rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,H.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,H.jsx)(`div`,{className:`oc-timerange__section-title`,children:S()}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:x()}),(0,H.jsx)(A,{type:`datetime-local`,value:l,onChange:e=>d(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:r()}),(0,H.jsx)(A,{type:`datetime-local`,value:f,onChange:e=>p(e.target.value)})]}),(0,H.jsx)(C,{size:`sm`,className:`oc-timerange__apply`,disabled:!b,onClick:v,children:c()})]}),(0,H.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,H.jsx)(O,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,H.jsx)(A,{value:a,onChange:e=>o(e.target.value),placeholder:u(),"aria-label":m()})]}),(0,H.jsx)(`ul`,{className:`oc-timerange__list`,children:y.length===0?(0,H.jsx)(`li`,{className:`oc-timerange__empty`,children:_()}):y.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>g(t.from),children:t.label})},t.from))})]})]})})})]})}export{U as n,V as r,G as t};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{_r as r,ah as i,ch as a,dh as o,fh as s,gr as c,hh as l,hr as u,ih as d,lh as f,mh as p,mr as m,oh as h,ph as g,pr as _,rh as v,sh as y,uh as b,vr as x,yr as S}from"./dist-BKXYNjW7.js";import{t as C}from"./button-CdHluvSK.js";import{Dt as w,Et as T,Ot as E,Qt as D,Rt as O,Tt as k,ft as A,rt as j}from"./index-CnNzzVmB.js";var M=t(e(),1),N={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function P(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=N[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function F(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:P(e.from,t)??t-N.h,to:P(e.to,t)??t}}var I=[{label:l(),from:`now-5m`},{label:p(),from:`now-15m`},{label:g(),from:`now-30m`},{label:s(),from:`now-1h`},{label:o(),from:`now-3h`},{label:b(),from:`now-6h`},{label:f(),from:`now-12h`},{label:a(),from:`now-24h`},{label:y(),from:`now-2d`},{label:h(),from:`now-7d`},{label:i(),from:`now-30d`},{label:d(),from:`now-90d`},{label:v(),from:`now-520w`}];function L(e){return j(e,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function R(e){if(e.kind===`relative`){let t=I.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${L(e.from)} → ${L(e.to)}`}function z(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function B(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function V(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}var H=n();function U(e){let[t,n]=(0,M.useState)(0);return(0,M.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,M.useMemo)(()=>{let{from:t,to:n}=F(e);return e.kind===`absolute`?{from:t,to:n}:{from:W(t),to:W(n)}},[e,t])}function W(e){return Math.floor(e/6e4)*6e4}function G({value:e,onChange:t}){let[n,i]=(0,M.useState)(!1),[a,o]=(0,M.useState)(``),s=F(e),[l,d]=(0,M.useState)(()=>z(s.from)),[f,p]=(0,M.useState)(()=>z(s.to));function h(t){if(t){let t=F(e);d(z(t.from)),p(z(t.to)),o(``)}i(t)}function g(e){t({kind:`relative`,from:e,to:`now`}),i(!1)}function v(){let e=B(l),n=B(f);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),i(!1))}let y=(0,M.useMemo)(()=>{let e=a.trim().toLowerCase();return e===``?I:I.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[a]),b=B(l)!==null&&B(f)!==null;return(0,H.jsxs)(w,{open:n,onOpenChange:h,children:[(0,H.jsx)(E,{asChild:!0,children:(0,H.jsxs)(C,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,H.jsx)(D,{}),R(e)]})}),(0,H.jsx)(T,{children:(0,H.jsx)(k,{align:`end`,sideOffset:6,className:`oc-timerange__panel z-50 rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,H.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,H.jsx)(`div`,{className:`oc-timerange__section-title`,children:S()}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:x()}),(0,H.jsx)(A,{type:`datetime-local`,value:l,onChange:e=>d(e.target.value)})]}),(0,H.jsxs)(`label`,{className:`oc-field`,children:[(0,H.jsx)(`span`,{className:`oc-field__label`,children:r()}),(0,H.jsx)(A,{type:`datetime-local`,value:f,onChange:e=>p(e.target.value)})]}),(0,H.jsx)(C,{size:`sm`,className:`oc-timerange__apply`,disabled:!b,onClick:v,children:c()})]}),(0,H.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,H.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,H.jsx)(O,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,H.jsx)(A,{value:a,onChange:e=>o(e.target.value),placeholder:u(),"aria-label":m()})]}),(0,H.jsx)(`ul`,{className:`oc-timerange__list`,children:y.length===0?(0,H.jsx)(`li`,{className:`oc-timerange__empty`,children:_()}):y.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>g(t.from),children:t.label})},t.from))})]})]})})})]})}export{U as n,V as r,G as t};
@@ -1 +1 @@
1
- import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$_ as r,$w as i,AT as a,B_ as o,CT as s,D as c,DT as l,E as u,ET as d,G_ as f,Gw as p,H_ as m,I_ as h,J_ as g,Jw as _,K_ as v,Kw as y,L_ as b,MT as x,NT as S,OT as C,Q_ as ee,Qw as te,R_ as ne,ST as re,TT as ie,U_ as ae,V_ as oe,W_ as se,Ww as w,X_ as ce,Xw as T,Y_ as le,Yw as E,Z_ as ue,Zw as D,_P as O,_T as k,_v as de,av as fe,bT as A,bv as pe,cv as me,dT as j,dv as he,eT as M,ev as ge,fT as N,fv as _e,gT as P,gn as F,gv as ve,hT as ye,hn as be,hv as xe,iT as Se,iv as Ce,jT as we,kT as Te,lT as Ee,lv as De,mT as Oe,mn as ke,mv as Ae,nT as je,nv as Me,ov as Ne,pT as Pe,pv as Fe,q_ as Ie,qw as Le,rT as Re,rv as ze,sv as Be,tT as Ve,tv as He,uT as Ue,uv as We,vP as I,vT as Ge,vv as Ke,wT as qe,xT as L,yT as Je,yv as Ye,z_ as Xe}from"./dist-BKXYNjW7.js";import{n as Ze}from"./dist-x2y4VoOj.js";import{t as Qe}from"./x-B77pQElB.js";import{i as R,n as z,r as $e,t as et}from"./tabs-CXQdq7rn.js";import{t as B}from"./button-CdHluvSK.js";import{C as V,Jt as tt,M as nt,S as H,T as U,Zt as rt,_t as it,a as at,dt as W,ht as ot,i as st,it as ct,mt as lt,nn as ut,o as dt,pt as ft,qt as pt,rn as mt,rt as G,s as ht,vt as gt,w as K,wt as _t,x as q}from"./index-DZcxHX-q.js";import{n as vt}from"./TimeRangePicker-CV_IaaKP.js";import{t as yt}from"./FilterBar-CQBSm0gy.js";import{t as bt}from"./AdvancedFilter-Cqqt3aQy.js";import{t as xt}from"./DataTableShell-O-bA35dG.js";var St=c(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ct=c(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),J=t(e(),1),Y=n(),X={kind:`relative`,from:`now-520w`,to:`now`},Z=e=>e===null?`-`:String(Math.round(e));function wt(e){let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1);return n===`admin`?Oe():n===`agent`?`${Pe()} - ${r}`:e}function Tt(){let e=I(u.me.getMe,{host:_t})?.role===`admin`,t=I(u.deliveryTiming.getDeliveryStatus,{}),n=O(u.deliveryTiming.startDeliveryRecord),r=O(u.deliveryTiming.stopDeliveryRecord),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=t?.recording??!1,f=async()=>{c(!0);try{l?await r({}):await n({})}finally{c(!1)}};return(0,Y.jsxs)(`section`,{className:`mb-4 flex flex-col gap-3 rounded-lg border border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:S()}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:x()})]}),e?(0,Y.jsx)(B,{variant:l?`destructive`:`default`,size:`sm`,disabled:s||t===void 0,onClick:()=>void f(),children:l?a():we()}):null]}),l?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(W,{variant:`secondary`,children:Te()}),t?.startedAt?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:C({time:ct(t.startedAt)})}):null]}):null,(0,Y.jsx)(`div`,{children:(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>o(e=>!e),children:i?ie():d()})}),i?(0,Y.jsx)(Et,{isAdmin:e}):null]})}function Et({isAdmin:e}){let t=I(u.deliveryTiming.listDeliverySessions,{}),n=O(u.deliveryTiming.deleteDeliverySessions),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(`all`),[c,l]=(0,J.useState)(X),[d,f]=(0,J.useState)(null),{from:m,to:h}=vt(c),g=c.to===`now`?1/0:h,_=r.trim()!==``||a!==`all`||c!==X,v=()=>{i(``),o(`all`),l(X)},y=(0,J.useMemo)(()=>{if(t===void 0)return;let e=r.trim().toLowerCase();return t.filter(t=>(e===``||t.startedBy.toLowerCase().includes(e))&&(a===`all`||(a===`active`?t.active:!t.active))&&t.startedAt>=m&&t.startedAt<=g).map(e=>({...e,_id:e.sessionId}))},[t,r,a,m,g]),b=e=>{let t=new Set((y??[]).map(e=>e.sessionId)),r=e.filter(e=>t.has(e));r.length!==0&&(n({sessionIds:r}),d!==null&&r.includes(d)&&f(null))};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(yt,{q:r,onQChange:i,searchPlaceholder:s(),timeRange:c,onTimeRangeChange:l,onReset:v,canReset:_,children:(0,Y.jsxs)(q,{value:a,onValueChange:e=>o(e),children:[(0,Y.jsx)(K,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(U,{})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:`all`,children:re()}),(0,Y.jsx)(V,{value:`active`,children:L()}),(0,Y.jsx)(V,{value:`stopped`,children:A()})]})]})}),(0,Y.jsx)(xt,{title:qe(),rows:y,emptyHint:p(),columns:[{header:``,className:`w-8`,cell:e=>(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,"aria-label":d===e.sessionId?j():N(),onClick:()=>f(t=>t===e.sessionId?null:e.sessionId),children:d===e.sessionId?(0,Y.jsx)(St,{size:15,"aria-hidden":!0}):(0,Y.jsx)(tt,{size:15,"aria-hidden":!0})})},{header:Je(),sort:e=>e.startedAt,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:G(e.startedAt)})},{header:Ge(),sort:e=>e.stoppedAt,cell:e=>e.stoppedAt===null?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`-`}):(0,Y.jsx)(`span`,{className:`tabular-nums`,children:G(e.stoppedAt)})},{header:k(),sort:e=>e.count,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Z(e.count)})},{header:P(),sort:e=>e.startedBy,cell:e=>wt(e.startedBy)},{header:ye(),sort:e=>e.active,cell:e=>e.active?(0,Y.jsx)(W,{variant:`secondary`,children:L()}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:A()})}],rowActions:e?e=>[{label:Ue(),variant:`destructive`,onSelect:()=>b([e.sessionId])}]:void 0,bulkActions:e?[{label:Ue(),variant:`destructive`,onSelect:e=>b(e)}]:void 0,isExpanded:e=>e.sessionId===d,renderExpanded:e=>(0,Y.jsx)(Dt,{sessionId:e.sessionId})})]})}function Dt({sessionId:e}){let t=I(u.deliveryTiming.getDeliveryReport,{sessionId:e}),[n,r]=(0,J.useState)(!1);return(0,Y.jsx)(Ot,{report:t,copied:n,onCopy:()=>{t&&navigator.clipboard?.writeText(nt(t)).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)}).catch(()=>{})}})}function Ot({report:e,copied:t,onCopy:n}){if(!e)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:Ee()});if(e.count===0||e.segments===null)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:l()});let r=e.segments,a=(e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,Y.jsx)(`td`,{className:`py-1`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.count}),(0,Y.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[Z(t.p50),` / `,Z(t.p95),` / `,Z(t.max)]})]});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,w()]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:n,children:[t?(0,Y.jsx)(Ze,{size:13,"aria-hidden":!0}):(0,Y.jsx)(rt,{size:13,"aria-hidden":!0}),t?y():Le()]})]}),(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1 font-medium`,children:je()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:Ve()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:M()})]})}),(0,Y.jsxs)(`tbody`,{children:[a(i(),r.bridge),a(te(),r.A),a(D(),r.C)]})]}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:T()}),e.truncated?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):null,(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:E()})]})}var kt=[50,100,200,500],At=`all`,Q=`__all__`,jt=[`2xx`,`4xx`,`5xx`],Mt=[`user`,`service`,`system`],Nt=[`inbound`,`outbound`,`internal`],Pt={kind:`relative`,from:`now-30d`,to:`now`},Ft=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:F()},{value:`principalType`,label:be()},{value:`direction`,label:`direction`},{value:`roleKey`,label:ke()},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function It(){let e=mt({from:`/settings/traces`}),t=ut({from:`/settings/traces`}),n=e.limit,i=e.kind,a=e.statusClass??Q,s=e.principalType??Q,c=e.direction??Q,l=e.roleKey??Q,d=e.q??``,p=st(e.from,e.to),h=(0,J.useMemo)(()=>ht(e.adv),[e.adv]),{from:_,to:y}=vt(p),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),te=e=>void t({search:t=>({...t,limit:e})}),ne=e=>void t({search:t=>({...t,kind:e})}),re=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),ie=e=>void t({search:t=>({...t,statusClass:e===Q?void 0:e})}),w=e=>void t({search:t=>({...t,principalType:e===Q?void 0:e})}),T=e=>void t({search:t=>({...t,direction:e===Q?void 0:e})}),E=e=>void t({search:t=>({...t,roleKey:e===Q?void 0:e})}),D=e=>void t({search:t=>({...t,...dt(e)})}),O=e=>void t({search:t=>({...t,adv:at(e)}),replace:!0}),k=I(u.observability.listEvents,{limit:n}),A=I(u.observability.listEvents,{limit:n,kind:i===At?void 0:i,filter:{q:d||void 0,from:_,to:y,statusClass:a===Q?void 0:a,principalType:s===Q?void 0:s,direction:c===Q?void 0:c,roleKey:l===Q?void 0:l,advanced:h.length>0?h:void 0}}),j=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])e.add(t.kind);return[...e].sort()},[k]),M=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[k]),N=d!==``||a!==Q||s!==Q||c!==Q||l!==Q||h.length>0||p.kind!==`relative`||p.from!==Pt.from;function P(){t({search:{limit:100,kind:`all`},replace:!0})}let F=b?k?.filter(e=>e.correlationId===b):A,ye=e.section,be=e=>void t({search:t=>({...t,section:e}),replace:!0});return(0,Y.jsxs)(et,{value:ye,onValueChange:e=>be(e),children:[(0,Y.jsxs)($e,{className:`w-full`,children:[(0,Y.jsxs)(R,{value:`latency`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(pt,{size:13,"aria-hidden":!0}),Se()]}),(0,Y.jsxs)(R,{value:`events`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(Ct,{size:13,"aria-hidden":!0}),Re()]})]}),(0,Y.jsx)(z,{value:`latency`,children:(0,Y.jsx)(Tt,{})}),(0,Y.jsxs)(z,{value:`events`,className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[pe(),(0,Y.jsx)(`strong`,{children:Ye()}),Ke(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:de()})]}),(0,Y.jsxs)(yt,{q:d,onQChange:re,searchPlaceholder:ve(),timeRange:p,onTimeRangeChange:D,onReset:P,canReset:N,children:[(0,Y.jsxs)(q,{value:a,onValueChange:ie,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(U,{placeholder:xe()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:Ae()}),jt.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:s,onValueChange:w,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(U,{placeholder:Fe()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:_e()}),Mt.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:c,onValueChange:T,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(U,{placeholder:he()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:We()}),Nt.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:l,onValueChange:E,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(U,{placeholder:De()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:me()}),M.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:i,onValueChange:ne,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-44`,children:(0,Y.jsx)(U,{placeholder:Be()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:At,children:Ne()}),j.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:String(n),onValueChange:e=>te(Number(e)),children:[(0,Y.jsx)(K,{size:`sm`,className:`w-28`,children:(0,Y.jsx)(U,{})}),(0,Y.jsx)(H,{children:kt.map(e=>(0,Y.jsx)(V,{value:String(e),children:fe({count:e})},e))})]})]}),(0,Y.jsx)(bt,{fields:Ft,seed:h,onChange:O}),b?(0,Y.jsx)(`div`,{className:`oc-traces__followline`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>x(null),title:Ce(),children:[(0,Y.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[ze(),(0,Y.jsx)(`code`,{children:$(b)})]}),(0,Y.jsx)(Qe,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:Me()})]})}):null,(0,Y.jsx)(xt,{title:He(),rows:F,emptyHint:b?ge():r(),columns:[{header:ee(),sort:e=>e.at,cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:G(e.at)})},{header:ue(),sort:e=>e.kind,cell:e=>(0,Y.jsx)(W,{variant:`secondary`,children:e.kind})},{header:ce(),sort:e=>Rt(e)??null,cell:e=>{let t=Rt(e);return t?(0,Y.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,Y.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":le(),children:`✓`})}},{header:g(),sort:e=>e.direction,cell:e=>e.direction?(0,Y.jsx)(W,{variant:`outline`,children:e.direction}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Ie(),sort:e=>e.principalType,cell:e=>(0,Y.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,Y.jsx)(W,{variant:`outline`,children:e.principalType}),e.principalId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:$(e.principalId)}):null]})},{header:v(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,Y.jsx)(W,{variant:`secondary`,children:e.roleKey}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:f(),sort:e=>e.route,cell:e=>e.route?(0,Y.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,Y.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:se(),sort:e=>e.status,cell:e=>e.status===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsx)(`span`,{className:`oc-traces__status ${Lt(e.status)}`,children:e.status})},{header:ae(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:m(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,Y.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:oe(),onClick:()=>x(e.correlationId),children:$(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:o(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>C(e),children:Xe()}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,Y.jsx)(zt,{row:S,onClose:()=>C(null)})]})]})}function Lt(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function $(e){return e.length>8?e.slice(0,8):e}function Rt(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function zt({row:e,onClose:t}){let n=(0,J.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,Y.jsx)(ft,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,Y.jsxs)(lt,{className:`max-w-lg`,children:[(0,Y.jsxs)(it,{children:[(0,Y.jsxs)(gt,{className:`oc-traces__meta-title`,children:[ne(),` `,(0,Y.jsx)(`code`,{children:e.kind}),(0,Y.jsx)(W,{variant:`outline`,children:b()})]}),(0,Y.jsx)(ot,{children:h()})]}),(0,Y.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}export{It as TracesTab};
1
+ import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$_ as r,$w as i,AT as a,B_ as o,CT as s,D as c,DT as l,E as u,ET as d,G_ as f,Gw as p,H_ as m,I_ as h,J_ as g,Jw as _,K_ as v,Kw as y,L_ as b,MT as x,NT as S,OT as C,Q_ as ee,Qw as te,R_ as ne,ST as re,TT as ie,U_ as ae,V_ as oe,W_ as se,Ww as w,X_ as ce,Xw as T,Y_ as le,Yw as E,Z_ as ue,Zw as D,_P as O,_T as k,_v as de,av as fe,bT as A,bv as pe,cv as me,dT as j,dv as he,eT as M,ev as ge,fT as N,fv as _e,gT as P,gn as F,gv as ve,hT as ye,hn as be,hv as xe,iT as Se,iv as Ce,jT as we,kT as Te,lT as Ee,lv as De,mT as Oe,mn as ke,mv as Ae,nT as je,nv as Me,ov as Ne,pT as Pe,pv as Fe,q_ as Ie,qw as Le,rT as Re,rv as ze,sv as Be,tT as Ve,tv as He,uT as Ue,uv as We,vP as I,vT as Ge,vv as Ke,wT as qe,xT as L,yT as Je,yv as Ye,z_ as Xe}from"./dist-BKXYNjW7.js";import{n as Ze}from"./dist-x2y4VoOj.js";import{t as Qe}from"./x-B77pQElB.js";import{i as R,n as z,r as $e,t as et}from"./tabs-BHnM2BeW.js";import{t as B}from"./button-CdHluvSK.js";import{C as V,Jt as tt,M as nt,S as H,T as U,Zt as rt,_t as it,a as at,dt as W,ht as ot,i as st,it as ct,mt as lt,nn as ut,o as dt,pt as ft,qt as pt,rn as mt,rt as G,s as ht,vt as gt,w as K,wt as _t,x as q}from"./index-CnNzzVmB.js";import{n as vt}from"./TimeRangePicker-CxfILbJE.js";import{t as yt}from"./FilterBar-CGBz7_qR.js";import{t as bt}from"./AdvancedFilter-gE4hTfw8.js";import{t as xt}from"./DataTableShell-CcVtwrRQ.js";var St=c(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ct=c(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),J=t(e(),1),Y=n(),X={kind:`relative`,from:`now-520w`,to:`now`},Z=e=>e===null?`-`:String(Math.round(e));function wt(e){let t=e.indexOf(`:`);if(t<0)return e;let n=e.slice(0,t),r=e.slice(t+1);return n===`admin`?Oe():n===`agent`?`${Pe()} - ${r}`:e}function Tt(){let e=I(u.me.getMe,{host:_t})?.role===`admin`,t=I(u.deliveryTiming.getDeliveryStatus,{}),n=O(u.deliveryTiming.startDeliveryRecord),r=O(u.deliveryTiming.stopDeliveryRecord),[i,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=t?.recording??!1,f=async()=>{c(!0);try{l?await r({}):await n({})}finally{c(!1)}};return(0,Y.jsxs)(`section`,{className:`mb-4 flex flex-col gap-3 rounded-lg border border-border p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-sm font-semibold`,children:S()}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:x()})]}),e?(0,Y.jsx)(B,{variant:l?`destructive`:`default`,size:`sm`,disabled:s||t===void 0,onClick:()=>void f(),children:l?a():we()}):null]}),l?(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm`,children:[(0,Y.jsx)(W,{variant:`secondary`,children:Te()}),t?.startedAt?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:C({time:ct(t.startedAt)})}):null]}):null,(0,Y.jsx)(`div`,{children:(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>o(e=>!e),children:i?ie():d()})}),i?(0,Y.jsx)(Et,{isAdmin:e}):null]})}function Et({isAdmin:e}){let t=I(u.deliveryTiming.listDeliverySessions,{}),n=O(u.deliveryTiming.deleteDeliverySessions),[r,i]=(0,J.useState)(``),[a,o]=(0,J.useState)(`all`),[c,l]=(0,J.useState)(X),[d,f]=(0,J.useState)(null),{from:m,to:h}=vt(c),g=c.to===`now`?1/0:h,_=r.trim()!==``||a!==`all`||c!==X,v=()=>{i(``),o(`all`),l(X)},y=(0,J.useMemo)(()=>{if(t===void 0)return;let e=r.trim().toLowerCase();return t.filter(t=>(e===``||t.startedBy.toLowerCase().includes(e))&&(a===`all`||(a===`active`?t.active:!t.active))&&t.startedAt>=m&&t.startedAt<=g).map(e=>({...e,_id:e.sessionId}))},[t,r,a,m,g]),b=e=>{let t=new Set((y??[]).map(e=>e.sessionId)),r=e.filter(e=>t.has(e));r.length!==0&&(n({sessionIds:r}),d!==null&&r.includes(d)&&f(null))};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(yt,{q:r,onQChange:i,searchPlaceholder:s(),timeRange:c,onTimeRangeChange:l,onReset:v,canReset:_,children:(0,Y.jsxs)(q,{value:a,onValueChange:e=>o(e),children:[(0,Y.jsx)(K,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(U,{})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:`all`,children:re()}),(0,Y.jsx)(V,{value:`active`,children:L()}),(0,Y.jsx)(V,{value:`stopped`,children:A()})]})]})}),(0,Y.jsx)(xt,{title:qe(),rows:y,emptyHint:p(),columns:[{header:``,className:`w-8`,cell:e=>(0,Y.jsx)(B,{variant:`ghost`,size:`icon`,"aria-label":d===e.sessionId?j():N(),onClick:()=>f(t=>t===e.sessionId?null:e.sessionId),children:d===e.sessionId?(0,Y.jsx)(St,{size:15,"aria-hidden":!0}):(0,Y.jsx)(tt,{size:15,"aria-hidden":!0})})},{header:Je(),sort:e=>e.startedAt,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:G(e.startedAt)})},{header:Ge(),sort:e=>e.stoppedAt,cell:e=>e.stoppedAt===null?(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`-`}):(0,Y.jsx)(`span`,{className:`tabular-nums`,children:G(e.stoppedAt)})},{header:k(),sort:e=>e.count,cell:e=>(0,Y.jsx)(`span`,{className:`tabular-nums`,children:Z(e.count)})},{header:P(),sort:e=>e.startedBy,cell:e=>wt(e.startedBy)},{header:ye(),sort:e=>e.active,cell:e=>e.active?(0,Y.jsx)(W,{variant:`secondary`,children:L()}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:A()})}],rowActions:e?e=>[{label:Ue(),variant:`destructive`,onSelect:()=>b([e.sessionId])}]:void 0,bulkActions:e?[{label:Ue(),variant:`destructive`,onSelect:e=>b(e)}]:void 0,isExpanded:e=>e.sessionId===d,renderExpanded:e=>(0,Y.jsx)(Dt,{sessionId:e.sessionId})})]})}function Dt({sessionId:e}){let t=I(u.deliveryTiming.getDeliveryReport,{sessionId:e}),[n,r]=(0,J.useState)(!1);return(0,Y.jsx)(Ot,{report:t,copied:n,onCopy:()=>{t&&navigator.clipboard?.writeText(nt(t)).then(()=>{r(!0),window.setTimeout(()=>r(!1),1200)}).catch(()=>{})}})}function Ot({report:e,copied:t,onCopy:n}){if(!e)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:Ee()});if(e.count===0||e.segments===null)return(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:l()});let r=e.segments,a=(e,t)=>(0,Y.jsxs)(`tr`,{className:`border-t border-border`,children:[(0,Y.jsx)(`td`,{className:`py-1`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.count}),(0,Y.jsxs)(`td`,{className:`py-1 text-right tabular-nums`,children:[Z(t.p50),` / `,Z(t.p95),` / `,Z(t.max)]})]});return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,w()]}),(0,Y.jsxs)(B,{variant:`outline`,size:`sm`,onClick:n,children:[t?(0,Y.jsx)(Ze,{size:13,"aria-hidden":!0}):(0,Y.jsx)(rt,{size:13,"aria-hidden":!0}),t?y():Le()]})]}),(0,Y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left text-muted-foreground`,children:[(0,Y.jsx)(`th`,{className:`py-1 font-medium`,children:je()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:Ve()}),(0,Y.jsx)(`th`,{className:`py-1 text-right font-medium`,children:M()})]})}),(0,Y.jsxs)(`tbody`,{children:[a(i(),r.bridge),a(te(),r.A),a(D(),r.C)]})]}),(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:T()}),e.truncated?(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:_()}):null,(0,Y.jsx)(`p`,{className:`oc-admin__hint`,children:E()})]})}var kt=[50,100,200,500],At=`all`,Q=`__all__`,jt=[`2xx`,`4xx`,`5xx`],Mt=[`user`,`service`,`system`],Nt=[`inbound`,`outbound`,`internal`],Pt={kind:`relative`,from:`now-30d`,to:`now`},Ft=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:F()},{value:`principalType`,label:be()},{value:`direction`,label:`direction`},{value:`roleKey`,label:ke()},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function It(){let e=mt({from:`/settings/traces`}),t=ut({from:`/settings/traces`}),n=e.limit,i=e.kind,a=e.statusClass??Q,s=e.principalType??Q,c=e.direction??Q,l=e.roleKey??Q,d=e.q??``,p=st(e.from,e.to),h=(0,J.useMemo)(()=>ht(e.adv),[e.adv]),{from:_,to:y}=vt(p),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(null),te=e=>void t({search:t=>({...t,limit:e})}),ne=e=>void t({search:t=>({...t,kind:e})}),re=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),ie=e=>void t({search:t=>({...t,statusClass:e===Q?void 0:e})}),w=e=>void t({search:t=>({...t,principalType:e===Q?void 0:e})}),T=e=>void t({search:t=>({...t,direction:e===Q?void 0:e})}),E=e=>void t({search:t=>({...t,roleKey:e===Q?void 0:e})}),D=e=>void t({search:t=>({...t,...dt(e)})}),O=e=>void t({search:t=>({...t,adv:at(e)}),replace:!0}),k=I(u.observability.listEvents,{limit:n}),A=I(u.observability.listEvents,{limit:n,kind:i===At?void 0:i,filter:{q:d||void 0,from:_,to:y,statusClass:a===Q?void 0:a,principalType:s===Q?void 0:s,direction:c===Q?void 0:c,roleKey:l===Q?void 0:l,advanced:h.length>0?h:void 0}}),j=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])e.add(t.kind);return[...e].sort()},[k]),M=(0,J.useMemo)(()=>{let e=new Set;for(let t of k??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[k]),N=d!==``||a!==Q||s!==Q||c!==Q||l!==Q||h.length>0||p.kind!==`relative`||p.from!==Pt.from;function P(){t({search:{limit:100,kind:`all`},replace:!0})}let F=b?k?.filter(e=>e.correlationId===b):A,ye=e.section,be=e=>void t({search:t=>({...t,section:e}),replace:!0});return(0,Y.jsxs)(et,{value:ye,onValueChange:e=>be(e),children:[(0,Y.jsxs)($e,{className:`w-full`,children:[(0,Y.jsxs)(R,{value:`latency`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(pt,{size:13,"aria-hidden":!0}),Se()]}),(0,Y.jsxs)(R,{value:`events`,className:`flex-1 gap-1.5`,children:[(0,Y.jsx)(Ct,{size:13,"aria-hidden":!0}),Re()]})]}),(0,Y.jsx)(z,{value:`latency`,children:(0,Y.jsx)(Tt,{})}),(0,Y.jsxs)(z,{value:`events`,className:`flex flex-col gap-3`,children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[pe(),(0,Y.jsx)(`strong`,{children:Ye()}),Ke(),` `,(0,Y.jsx)(`span`,{className:`oc-filter__window`,children:de()})]}),(0,Y.jsxs)(yt,{q:d,onQChange:re,searchPlaceholder:ve(),timeRange:p,onTimeRangeChange:D,onReset:P,canReset:N,children:[(0,Y.jsxs)(q,{value:a,onValueChange:ie,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(U,{placeholder:xe()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:Ae()}),jt.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:s,onValueChange:w,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(U,{placeholder:Fe()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:_e()}),Mt.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:c,onValueChange:T,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-32`,children:(0,Y.jsx)(U,{placeholder:he()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:We()}),Nt.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:l,onValueChange:E,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-36`,children:(0,Y.jsx)(U,{placeholder:De()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:Q,children:me()}),M.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:i,onValueChange:ne,children:[(0,Y.jsx)(K,{size:`sm`,className:`w-44`,children:(0,Y.jsx)(U,{placeholder:Be()})}),(0,Y.jsxs)(H,{children:[(0,Y.jsx)(V,{value:At,children:Ne()}),j.map(e=>(0,Y.jsx)(V,{value:e,children:e},e))]})]}),(0,Y.jsxs)(q,{value:String(n),onValueChange:e=>te(Number(e)),children:[(0,Y.jsx)(K,{size:`sm`,className:`w-28`,children:(0,Y.jsx)(U,{})}),(0,Y.jsx)(H,{children:kt.map(e=>(0,Y.jsx)(V,{value:String(e),children:fe({count:e})},e))})]})]}),(0,Y.jsx)(bt,{fields:Ft,seed:h,onChange:O}),b?(0,Y.jsx)(`div`,{className:`oc-traces__followline`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>x(null),title:Ce(),children:[(0,Y.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[ze(),(0,Y.jsx)(`code`,{children:$(b)})]}),(0,Y.jsx)(Qe,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`sr-only`,children:Me()})]})}):null,(0,Y.jsx)(xt,{title:He(),rows:F,emptyHint:b?ge():r(),columns:[{header:ee(),sort:e=>e.at,cell:e=>(0,Y.jsx)(`span`,{className:`oc-traces__time`,children:G(e.at)})},{header:ue(),sort:e=>e.kind,cell:e=>(0,Y.jsx)(W,{variant:`secondary`,children:e.kind})},{header:ce(),sort:e=>Rt(e)??null,cell:e=>{let t=Rt(e);return t?(0,Y.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,Y.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":le(),children:`✓`})}},{header:g(),sort:e=>e.direction,cell:e=>e.direction?(0,Y.jsx)(W,{variant:`outline`,children:e.direction}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Ie(),sort:e=>e.principalType,cell:e=>(0,Y.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,Y.jsx)(W,{variant:`outline`,children:e.principalType}),e.principalId?(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:$(e.principalId)}):null]})},{header:v(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,Y.jsx)(W,{variant:`secondary`,children:e.roleKey}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:f(),sort:e=>e.route,cell:e=>e.route?(0,Y.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,Y.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,Y.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:se(),sort:e=>e.status,cell:e=>e.status===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsx)(`span`,{className:`oc-traces__status ${Lt(e.status)}`,children:e.status})},{header:ae(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,Y.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:m(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,Y.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:oe(),onClick:()=>x(e.correlationId),children:$(e.correlationId)}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:o(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,Y.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>C(e),children:Xe()}):(0,Y.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,Y.jsx)(zt,{row:S,onClose:()=>C(null)})]})]})}function Lt(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function $(e){return e.length>8?e.slice(0,8):e}function Rt(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function zt({row:e,onClose:t}){let n=(0,J.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,Y.jsx)(ft,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,Y.jsxs)(lt,{className:`max-w-lg`,children:[(0,Y.jsxs)(it,{children:[(0,Y.jsxs)(gt,{className:`oc-traces__meta-title`,children:[ne(),` `,(0,Y.jsx)(`code`,{children:e.kind}),(0,Y.jsx)(W,{variant:`outline`,children:b()})]}),(0,Y.jsx)(ot,{children:h()})]}),(0,Y.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}export{It as TracesTab};