@lacneu/atrium 0.68.1 → 0.68.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccessTab-BFZrGfSt.js → AccessTab-CoRmmFpP.js} +1 -1
- package/dist/assets/{AdvancedFilter-D3IHsSgI.js → AdvancedFilter-DqWG63qF.js} +1 -1
- package/dist/assets/{AgentFilesTab-CHMpYoZN.js → AgentFilesTab-BnwVjBen.js} +1 -1
- package/dist/assets/{AnomaliesTab-Bna7O7DK.js → AnomaliesTab-D0_DaVUT.js} +1 -1
- package/dist/assets/{AuditTab-BQO2KxIW.js → AuditTab-CiMRA2UB.js} +1 -1
- package/dist/assets/{BridgeTab-DCHBE54n.js → BridgeTab-BhAxJtIU.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-B49bnKco.js → ChatDefaultsTab-BRGSYbx2.js} +1 -1
- package/dist/assets/{DataTableShell-BYhMdaSl.js → DataTableShell-D5Nb8D27.js} +1 -1
- package/dist/assets/{DetailChips-BT8QU7Op.js → DetailChips-BpplTXuL.js} +1 -1
- package/dist/assets/{FeedbacksTab-B3aYpOIP.js → FeedbacksTab-6b-IOyv1.js} +1 -1
- package/dist/assets/{FieldLabel-2xG6-0gZ.js → FieldLabel-D_--lTMz.js} +1 -1
- package/dist/assets/{FilesTab-_09UVEP4.js → FilesTab-D5X6EpvN.js} +1 -1
- package/dist/assets/{FilterBar-Bxpfu6Cp.js → FilterBar-3xmqkmtO.js} +1 -1
- package/dist/assets/{GroupsTab-lX4rp_r8.js → GroupsTab-VRfFxe4t.js} +1 -1
- package/dist/assets/{InstancesTab-Bg4DV0Mg.js → InstancesTab-6WQvX86-.js} +1 -1
- package/dist/assets/{IntegrationsTab-eVcH8e5g.js → IntegrationsTab-cja9iSZK.js} +1 -1
- package/dist/assets/{KpiTab-BxeRQXix.js → KpiTab-DyotMcdO.js} +1 -1
- package/dist/assets/{PreferencesTab-DZSU4xP1.js → PreferencesTab-xvCftb-6.js} +1 -1
- package/dist/assets/{ProjectPage-vg8X5OT3.js → ProjectPage-B4CPwcaH.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-88NlW26U.js → PromptInjectionsTab-DEzP8Oti.js} +1 -1
- package/dist/assets/{RolesTab-BZFTJhyf.js → RolesTab-CZfNwFFx.js} +1 -1
- package/dist/assets/{ScheduledTab-DGRbUQ47.js → ScheduledTab-D6x6Mo89.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-pE8F7p-2.js → ServiceAccountsTab-S3OIL2wM.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-BTQehyRQ.js → SubAgentReportsTab-r5dkHWGD.js} +1 -1
- package/dist/assets/{ThemeShowroom-HrqPxKuI.js → ThemeShowroom-ClnOnpAv.js} +1 -1
- package/dist/assets/{TimeRangePicker-DBPA3ISK.js → TimeRangePicker-B3yMy8oz.js} +1 -1
- package/dist/assets/{TimezoneCombobox-Cf0dO1lp.js → TimezoneCombobox-DjUiyEWp.js} +1 -1
- package/dist/assets/{TracesTab-DpeDrf2G.js → TracesTab-CyUsgwvb.js} +1 -1
- package/dist/assets/{UsersTab-txTMEiI9.js → UsersTab-DlotCuaa.js} +1 -1
- package/dist/assets/{VoiceTab-CnjBb1Ea.js → VoiceTab-BaqvZlgH.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-D8RSF8so.js → highlighted-body-OFNGDK62-B8wQuJm_.js} +1 -1
- package/dist/assets/{index-CsdodIca.js → index-DdOFgMFG.js} +76 -76
- package/dist/assets/mermaid-GHXKKRXX-CE8gBGLh.js +1 -0
- package/dist/assets/{pdf-D65rOI23.js → pdf-BNLKKdqq.js} +1 -1
- package/dist/assets/{tabs-lFf0wQh0.js → tabs-D8fO33rb.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/mermaid-GHXKKRXX-CHdRR4I9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$E as r,$s as i,IL as a,QE as o,Qs as s,RL as c,ZE as l,Zs as u,aD as d,ac as f,cD as p,eD as m,ec as h,iD as g,ic as _,lD as v,nD as y,nc as b,oD as x,rD as S,rc as C,sD as w,t as T,tD as E,tc as D,uD as O,zL as k}from"./api-EsnGI4EC.js";import{t as A}from"./button-CZ9WPf0m.js";import{P as j,jt as M,ut as N}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$E as r,$s as i,IL as a,QE as o,Qs as s,RL as c,ZE as l,Zs as u,aD as d,ac as f,cD as p,eD as m,ec as h,iD as g,ic as _,lD as v,nD as y,nc as b,oD as x,rD as S,rc as C,sD as w,t as T,tD as E,tc as D,uD as O,zL as k}from"./api-EsnGI4EC.js";import{t as A}from"./button-CZ9WPf0m.js";import{P as j,jt as M,ut as N}from"./index-DdOFgMFG.js";var P=t(e(),1),F=n();function I(){let e=k(T.integrations.status.status,{}),t=c(T.admin.setIntegrationConfig),[n,i]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&i(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:O()});let a=n,s=(e,t,n)=>i({...a,[e]:{...a[e],[t]:n}}),u=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[v(),` `,(0,F.jsx)(`strong`,{children:p()}),` `,w()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(N,{variant:`secondary`,children:x()}):(0,F.jsx)(N,{variant:`outline`,children:d()}):(0,F.jsx)(N,{variant:`outline`,children:g()}),note:S(),children:[(0,F.jsx)(R,{label:E(),children:(0,F.jsx)(M,{value:a.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>s(`langfuse`,`host`,e.target.value),onBlur:()=>u(`langfuse`,{host:a.langfuse.host??``})})}),(0,F.jsx)(z,{label:l(),checked:a.langfuse.enabled??!0,onChange:e=>{s(`langfuse`,`enabled`,e),u(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(N,{variant:`secondary`,children:x()}):(0,F.jsx)(N,{variant:`outline`,children:d()}):(0,F.jsx)(N,{variant:`outline`,children:g()}),note:y(),children:[(0,F.jsx)(R,{label:m(),children:(0,F.jsx)(M,{value:a.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>s(`opik`,`baseUrl`,e.target.value),onBlur:()=>u(`opik`,{baseUrl:a.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:r(),children:(0,F.jsx)(M,{value:a.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||o(),onChange:e=>s(`opik`,`workspace`,e.target.value),onBlur:()=>u(`opik`,{workspace:a.opik.workspace??``})})}),(0,F.jsx)(z,{label:l(),checked:a.opik.enabled??!0,onChange:e=>{s(`opik`,`enabled`,e),u(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(N,{variant:`secondary`,children:x()}):(0,F.jsx)(N,{variant:`outline`,children:d()}):(0,F.jsx)(N,{variant:`outline`,children:f()}),note:_(),children:[(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(M,{value:a.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>s(`otlp`,`endpoint`,e.target.value),onBlur:()=>u(`otlp`,{endpoint:a.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:l(),checked:a.otlp.enabled??!0,onChange:e=>{s(`otlp`,`enabled`,e),u(`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)(j,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,F.jsx)(`span`,{children:e})]})}function B({headersSet:e}){let t=a(T.integrations.otlpSecret.setOtlpHeaders),n=c(T.integrations.otlpSecret.clearOtlpHeaders),[r,o]=(0,P.useState)(``),[l,d]=(0,P.useState)(null),[f,p]=(0,P.useState)(!1),m=async()=>{p(!0),d(null);try{await t({headersJson:r}),o(``)}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,F.jsxs)(R,{label:b(),children:[(0,F.jsx)(M,{value:r,placeholder:e?D():h(),onChange:e=>o(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||r.trim().length===0,onClick:()=>void m(),children:i()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:s()}):null]}),l?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:l}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:u()})]})}export{I as IntegrationsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{A_ as r,B_ as i,D_ as a,F_ as o,GD as s,ID as c,I_ as l,KD as u,LD as d,L_ as f,M_ as p,N_ as m,O_ as h,P_ as g,R_ as _,WD as v,j_ as y,k_ as b,qD as x,t as S,vO as C,zL as w,z_ as T}from"./api-EsnGI4EC.js";import{Fn as ee,Pn as te,i as ne,o as re,r as E,wt as D}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{A_ as r,B_ as i,D_ as a,F_ as o,GD as s,ID as c,I_ as l,KD as u,LD as d,L_ as f,M_ as p,N_ as m,O_ as h,P_ as g,R_ as _,WD as v,j_ as y,k_ as b,qD as x,t as S,vO as C,zL as w,z_ as T}from"./api-EsnGI4EC.js";import{Fn as ee,Pn as te,i as ne,o as re,r as E,wt as D}from"./index-DdOFgMFG.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-CZABX7Qs.js";import{n as N,t as P}from"./TimeRangePicker-B3yMy8oz.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=w(S.me.getMe,{host:D})?.permissions?.includes(`traces.read`)??!1,t=w(S.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:x()}),(0,I.jsx)(j,{children:s()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:v()}):(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:[c(),` p50 `,R(s.cP50),` `,u()]}),(0,I.jsxs)(`span`,{children:[d(),` p50 `,R(s.aP50),` `,u()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":x(),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:i(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:T(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:_(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:f(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:l(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:o(),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=ee({from:`/settings/kpi`}),t=te({from:`/settings/kpi`}),n=ne(e.from,e.to,E,`now`),r=e=>void t({search:t=>({...t,...re(e)})}),{from:i,to:a}=N(n),{rowLimit:o,buckets:s}=K(i,a),c=w(S.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),l=(0,F.useMemo)(()=>{let e=new Map;for(let t of c??[]){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>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),u=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[g(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:m()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return c===void 0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:p()})]}):c.length===0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:y()})]}):(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(l.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:l.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,i=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&&i>0?` oc-kpi__value--error`:``),children:Q(i)}),(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:r({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:b()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:h({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,o=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":a({max:Q(r),unit:n}),children:e.map((e,a)=>{let s=r>0?e.value/r*(Z-1):0,c=a*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:o,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{$I as r,$w as i,AL as a,AM as o,CM as s,DM as c,EM as l,Et as u,FM as d,IM as f,LM as p,MM as m,Mt as ee,NM as h,OM as te,PM as ne,RL as g,RM as re,SL as ie,SM as ae,TL as oe,TM as se,_L as ce,_M as le,_t as ue,aL as de,aM as fe,bL as pe,bM as me,cL as he,cM as ge,dL as _e,dM as ve,dt as _,eL as v,eM as y,fL as b,fM as x,ft as S,gL as C,gM as w,gt as T,hL as E,hM as D,ht as O,iL as k,iM as A,jM as j,jt as M,kM as N,lL as P,lM as F,mL as ye,mM as be,mt as xe,nL as Se,nM as Ce,oL as we,oM as Te,pL as Ee,pM as I,pt as De,r as L,rL as Oe,rM as ke,sL as Ae,sM as R,t as z,tL as je,tM as Me,uL as Ne,uM as Pe,vL as Fe,vM as Ie,vt as Le,wM as Re,xL as ze,xM as Be,yL as Ve,yM as He,zL as B,zM as Ue}from"./api-EsnGI4EC.js";import{t as V}from"./button-CZ9WPf0m.js";import{At as We,Dt as Ge,Ot as Ke,P as H,_t as qe,bt as Je,jt as U,kt as Ye,q as Xe,t as Ze,ut as W,vt as Qe,wt as G,xt as $e,yt as K}from"./index-CsdodIca.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-Cf0dO1lp.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:L(`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:L(`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:()=>Ue()},{id:`composer`,label:()=>re()},{id:`sidebar`,label:()=>p()},{id:`notifications`,label:()=>me()},{id:`other`,label:()=>f()}],X={showSource:{category:`messages`,label:()=>d(),help:()=>ne()},showReport:{category:`messages`,label:()=>h(),help:()=>m()},copyAssistant:{category:`messages`,label:()=>j()},copyUser:{category:`messages`,label:()=>o()},showDelete:{category:`messages`,label:()=>N()},showTools:{category:`messages`,label:()=>te(),help:()=>c()},voiceInput:{category:`composer`,label:()=>l(),help:()=>se()},showUsage:{category:`composer`,label:()=>Re(),help:()=>s()},autoReadAloud:{category:`composer`,label:()=>ee(),help:()=>M()},showChatAge:{category:`sidebar`,label:()=>ae(),help:()=>Be()},notifSound:{category:`notifications`,label:()=>He(),help:()=>Ie()},notifSystem:{category:`notifications`,label:()=>le(),help:()=>w()},replySound:{category:`notifications`,label:()=>D(),help:()=>be()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>A()};function ut({prefKey:e,ui:t}){let n=g(z.admin.setUiPrefDefault),r=g(z.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ge()}),(0,J.jsxs)(qe,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Je,{size:`sm`,className:`w-36`,children:(0,J.jsx)($e,{})}),(0,J.jsxs)(Qe,{children:[(0,J.jsx)(K,{value:`on`,children:Ce()}),(0,J.jsx)(K,{value:`off`,children:Me()}),(0,J.jsx)(K,{value:`inherit`,children:y()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(H,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":R()}),R()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=g(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[Le(),e?(0,J.jsx)(W,{variant:`secondary`,children:We(e,Ke())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?O():r?T():ue()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:_()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?S():e?De():xe()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=B(z.me.getMe,{host:G}),o=i?.ui,s=$(i?.role)&&n,c=g(z.me.setUiPref).withOptimisticUpdate(Xe),l=(0,q.useMemo)(()=>o?Q(Object.keys(o.effective),e):[],[o,e]);return o?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(H,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":F()}),F()]}):null,s?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:Te()}),(0,J.jsx)(`p`,{children:fe()}),(0,J.jsx)(`p`,{children:ke()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:I(),"aria-label":I(),className:`mb-2`}),l.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:x()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],a=o.effective[e],l=o.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(W,{variant:`outline`,children:ve()}):l?(0,J.jsx)(W,{variant:`secondary`,children:u()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:Pe()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:a()})}var pt={sm:()=>Ne(),md:()=>P(),lg:()=>he(),xl:()=>Ae(),"2xl":()=>we(),"3xl":()=>de()};function mt(){let e=B(z.me.getMe,{host:G}),t=g(z.me.setLocale),n=g(z.me.setTimezone),a=g(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),o=g(z.me.setMyName),s=Ge(),c=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),f=u??l,p=f.trim()!==l.trim();async function m(){try{await o({name:f}),d(null),s.success(Fe())}catch(e){s.error(ce(),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:ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:f,maxLength:120,placeholder:pe(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:i()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ve()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:C()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:E()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:c===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:c==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:oe()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ye()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:k()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Oe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:Se()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:je()})]}),(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:Ee()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:b()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Ze.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void a({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:_e()})]}),(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:v()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:r()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$I as r,$w as i,AL as a,AM as o,CM as s,DM as c,EM as l,Et as u,FM as d,IM as f,LM as p,MM as m,Mt as ee,NM as h,OM as te,PM as ne,RL as g,RM as re,SL as ie,SM as ae,TL as oe,TM as se,_L as ce,_M as le,_t as ue,aL as de,aM as fe,bL as pe,bM as me,cL as he,cM as ge,dL as _e,dM as ve,dt as _,eL as v,eM as y,fL as b,fM as x,ft as S,gL as C,gM as w,gt as T,hL as E,hM as D,ht as O,iL as k,iM as A,jM as j,jt as M,kM as N,lL as P,lM as F,mL as ye,mM as be,mt as xe,nL as Se,nM as Ce,oL as we,oM as Te,pL as Ee,pM as I,pt as De,r as L,rL as Oe,rM as ke,sL as Ae,sM as R,t as z,tL as je,tM as Me,uL as Ne,uM as Pe,vL as Fe,vM as Ie,vt as Le,wM as Re,xL as ze,xM as Be,yL as Ve,yM as He,zL as B,zM as Ue}from"./api-EsnGI4EC.js";import{t as V}from"./button-CZ9WPf0m.js";import{At as We,Dt as Ge,Ot as Ke,P as H,_t as qe,bt as Je,jt as U,kt as Ye,q as Xe,t as Ze,ut as W,vt as Qe,wt as G,xt as $e,yt as K}from"./index-DdOFgMFG.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-DjUiyEWp.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:L(`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:L(`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:()=>Ue()},{id:`composer`,label:()=>re()},{id:`sidebar`,label:()=>p()},{id:`notifications`,label:()=>me()},{id:`other`,label:()=>f()}],X={showSource:{category:`messages`,label:()=>d(),help:()=>ne()},showReport:{category:`messages`,label:()=>h(),help:()=>m()},copyAssistant:{category:`messages`,label:()=>j()},copyUser:{category:`messages`,label:()=>o()},showDelete:{category:`messages`,label:()=>N()},showTools:{category:`messages`,label:()=>te(),help:()=>c()},voiceInput:{category:`composer`,label:()=>l(),help:()=>se()},showUsage:{category:`composer`,label:()=>Re(),help:()=>s()},autoReadAloud:{category:`composer`,label:()=>ee(),help:()=>M()},showChatAge:{category:`sidebar`,label:()=>ae(),help:()=>Be()},notifSound:{category:`notifications`,label:()=>He(),help:()=>Ie()},notifSystem:{category:`notifications`,label:()=>le(),help:()=>w()},replySound:{category:`notifications`,label:()=>D(),help:()=>be()}};function Z(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function Q(e,t){let n=Z(t.trim()),r=new Map(Y.map(e=>[e.id,e.label()])),i=new Map(Y.map(e=>[e.id,[]]));for(let t of e){let e=X[t],a=e?.category??`other`;n&&!Z(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return Y.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var rt=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showUsage`,`autoReadAloud`,`notifSound`,`notifSystem`,`replySound`],it={voiceInput:`voiceInput`};function at(e){return rt.includes(e)}function $(e){return e===`admin`}function ot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function st(e){return e===`on`?!0:e===`off`?!1:null}function ct(e){return at(e)?it[e]:void 0}var lt={voiceInput:()=>A()};function ut({prefKey:e,ui:t}){let n=g(z.admin.setUiPrefDefault),r=g(z.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:ge()}),(0,J.jsxs)(qe,{value:ot(t.defaults[e]),onValueChange:t=>void n({key:e,value:st(t)}),children:[(0,J.jsx)(Je,{size:`sm`,className:`w-36`,children:(0,J.jsx)($e,{})}),(0,J.jsxs)(Qe,{children:[(0,J.jsx)(K,{value:`on`,children:Ce()}),(0,J.jsx)(K,{value:`off`,children:Me()}),(0,J.jsx)(K,{value:`inherit`,children:y()})]})]}),i?(0,J.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,J.jsx)(H,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":R()}),R()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=g(z.me.setDictationShortcut),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!r)return;let e=e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=Ye(e);if(t===null){[`Shift`,`Control`,`Meta`,`Alt`].includes(e.key)||(o(!0),window.setTimeout(()=>o(!1),1800));return}i(!1),n({shortcut:t})};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r,n]),(0,J.jsxs)(`div`,{className:`oc-prefs__row${t?``:` is-locked`}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[Le(),e?(0,J.jsx)(W,{variant:`secondary`,children:We(e,Ke())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?O():r?T():ue()})]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[e&&!r?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void n({shortcut:null}),children:_()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?S():e?De():xe()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=B(z.me.getMe,{host:G}),o=i?.ui,s=$(i?.role)&&n,c=g(z.me.setUiPref).withOptimisticUpdate(Xe),l=(0,q.useMemo)(()=>o?Q(Object.keys(o.effective),e):[],[o,e]);return o?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(H,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":F()}),F()]}):null,s?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:Te()}),(0,J.jsx)(`p`,{children:fe()}),(0,J.jsx)(`p`,{children:ke()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:I(),"aria-label":I(),className:`mb-2`}),l.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:x()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:l.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=o.locked[e],a=o.effective[e],l=o.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(W,{variant:`outline`,children:ve()}):l?(0,J.jsx)(W,{variant:`secondary`,children:u()}):null]}),r?(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,J.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void c({key:e,value:null}),children:Pe()}):null,(0,J.jsx)(nt,{checked:a,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),c({key:e,value:t})},"aria-label":n})]}),s?(0,J.jsx)(ut,{prefKey:e,ui:o}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:o.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:a()})}var pt={sm:()=>Ne(),md:()=>P(),lg:()=>he(),xl:()=>Ae(),"2xl":()=>we(),"3xl":()=>de()};function mt(){let e=B(z.me.getMe,{host:G}),t=g(z.me.setLocale),n=g(z.me.setTimezone),a=g(z.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(z.me.getMe,{host:G});n&&e.setQuery(z.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),o=g(z.me.setMyName),s=Ge(),c=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),f=u??l,p=f.trim()!==l.trim();async function m(){try{await o({name:f}),d(null),s.success(Fe())}catch(e){s.error(ce(),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:ie()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ze()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:f,maxLength:120,placeholder:pe(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p&&(e.preventDefault(),m())}}),(0,J.jsx)(V,{size:`sm`,disabled:!p,onClick:()=>void m(),children:i()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ve()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:C()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:E()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:c===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:c==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:oe()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ye()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:k()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Oe()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(tt,{value:e?.timezone??``,onChange:e=>void n({timezone:e})}),(0,J.jsx)(V,{variant:e?.timezone===null||e?.timezone===void 0?`default`:`outline`,size:`sm`,onClick:()=>void n({timezone:null}),children:Se()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:je()})]}),(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:Ee()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:b()})]}),(0,J.jsx)(`div`,{className:`oc-show__row`,children:Ze.map(t=>(0,J.jsx)(V,{variant:(e?.fontScale??`md`)===t?`default`:`outline`,size:`sm`,onClick:()=>void a({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:_e()})]}),(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:v()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:r()})]}),(0,J.jsx)(ft,{})]})]})}export{mt as PreferencesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AL as r,Ag as i,Bg as a,Cg as o,D as s,Dg as c,Eg as l,Fg as u,Gg as d,Hg as f,Ig as p,Jg as m,Kg as h,Lg as g,Mg as ee,Ng as _,Og as v,Pg as y,Pm as te,RL as b,Sg as ne,Tg as re,Ug as ie,Vg as x,Yg as ae,Zg as S,_g as C,ag as oe,c_ as se,cg as w,dg as ce,e_ as le,eg as T,fg as ue,gg as de,i_ as E,ig as fe,jg as pe,kg as D,l_ as me,ng as O,og as he,qg as ge,r_ as _e,rg as ve,sg as k,t as A,t_ as ye,u_ as be,ug as j,vg as xe,wg as M,xg as Se,yg as Ce,zL as N,zg as we}from"./api-EsnGI4EC.js";import{r as Te}from"./dist-BM94bqpE.js";import{t as Ee}from"./list-DaUUbsAN.js";import{t as P}from"./button-CZ9WPf0m.js";import{A as De,C as Oe,Cn as ke,D as Ae,Dt as je,E as Me,En as Ne,Et as Pe,F as Fe,Fn as Ie,Ft as Le,In as Re,It as ze,Lt as Be,Mt as Ve,Nt as He,O as F,Pn as I,Pt as L,Q as Ue,S as We,Sn as R,T as Ge,Tt as Ke,Z as qe,_ as Je,_n as Ye,b as z,d as Xe,dn as Ze,f as Qe,fn as B,g as V,h as H,hn as U,in as $e,j as W,jn as et,jt as G,k as tt,m as nt,p as rt,pn as it,v as K,vn as at,w as ot,wn as q,x as J,y as st}from"./index-CsdodIca.js";var ct=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),lt=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),ut=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),dt=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Y=t(e(),1),X=n();function Z({className:e}){return(0,X.jsx)(Be,{asChild:!0,children:(0,X.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":w(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,X.jsx)(Ne,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let o=b(A.projects.renameProject),s=b(A.projects.setProjectColor),c=b(A.projects.moveProject),l=b(A.projects.deleteProject),u=b(A.projects.createProject),f=qe(),g=Ue(),[ee,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(t),[te,ne]=(0,Y.useState)(!1),[re,ie]=(0,Y.useState)(!1),x=N(A.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ve,{onOpenChange:e=>e&&ie(!0),children:[(0,X.jsx)(Z,{className:i}),(0,X.jsxs)(He,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(L,{onSelect:()=>a(),children:[(0,X.jsx)(q,{}),` `,d()]}),(0,X.jsxs)(L,{onSelect:()=>{y(t),_(!0)},children:[(0,X.jsx)(it,{}),` `,k()]}),(0,X.jsxs)(L,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await g({title:p(),label:be(),placeholder:me(),confirmLabel:se()});t&&await u({name:t,parentId:e})})},children:[(0,X.jsx)(ke,{}),` `,p()]}),(0,X.jsxs)(L,{onSelect:()=>ne(!0),children:[(0,X.jsx)(lt,{}),` `,xe()]}),(0,X.jsx)(Le,{children:fe()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":ve(),children:`✕`}),nt.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e,color:t.value})},t.value))]}),(0,X.jsx)(ze,{}),(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=x?.folders??0,r=x?.chats??0;await f({title:m({name:t}),description:n>0?h({folders:n,chats:r}):r>0?ge({count:r}):ce(),confirmWord:j(),confirmLabel:ae(),destructive:!0})&&await l({projectId:e})})},children:[(0,X.jsx)($e,{}),` `,j()]})]})]}),(0,X.jsx)(Je,{open:ee,onOpenChange:_,title:le(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),_(!1)},submitLabel:k(),children:(0,X.jsx)(G,{value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),te?(0,X.jsx)(rt,{open:te,onOpenChange:ne,title:de(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=b(A.chats.pinChat),i=b(A.chats.deleteChat),a=b(A.chats.renameChat),o=b(A.chats.setChatSidebar),s=b(A.chats.moveChatToProject),c=qe(),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)(e.title??``),[m,h]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Z,{className:n}),(0,X.jsxs)(He,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(L,{onSelect:()=>{p(e.title??``),u(!0)},children:[(0,X.jsx)(it,{}),` `,k()]}),(0,X.jsxs)(L,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,X.jsx)(Ze,{}):(0,X.jsx)(B,{}),e.pinned?he():oe()]}),(0,X.jsxs)(L,{onSelect:()=>h(!0),children:[(0,X.jsx)(lt,{}),` `,Ce()]}),e.pinned&&e.inSidebar?null:(0,X.jsxs)(L,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,X.jsx)(U,{}):(0,X.jsx)(dt,{}),e.inSidebar?f():ie()]}),(0,X.jsx)(ze,{}),(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:O(),description:ce(),confirmLabel:j(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,X.jsx)($e,{}),` `,j()]})]})]}),(0,X.jsx)(Je,{open:l,onOpenChange:u,title:T(),canSubmit:d.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:d.trim()}),u(!1)},submitLabel:k(),children:(0,X.jsx)(G,{value:d,onChange:e=>p(e.target.value),autoFocus:!0})}),m?(0,X.jsx)(rt,{open:m,onOpenChange:h,title:C(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function mt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function xt(){let{projectId:e}=Re({from:`/project/$projectId`}),t=I(),n=N(A.projects.projectPage,{projectId:e});return(0,X.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):n===null?(0,X.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,X.jsx)(`h2`,{children:M()}),(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:o()}),(0,X.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ne()})]}):(0,X.jsx)(St,{page:n})})}function St({page:e}){let t=I(),n=qe(),r=Ue(),i=je(),o=b(A.projects.renameProject),s=b(A.projects.setProjectColor),u=b(A.projects.deleteProject),d=b(A.projects.createProject),f=b(A.projects.moveProject),y=b(A.chats.moveChatToProject),ne=b(A.chats.reorderChat),ie=b(A.projects.reorderProject),S=N(A.projects.projectTreeCount,{projectId:e.project._id}),[C,oe]=(0,Y.useState)(gt),w=e=>{localStorage.setItem(ht,e),oe(e)},T=N(A.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=N(A.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:O}=Ie({from:`/project/$projectId`}),he=N(A.projects.listProjects,{}),_e=N(A.chatReads.myBusyChats,{}),M=(0,Y.useMemo)(()=>new Set(_e??[]),[_e]),Ce=N(A.chatReads.myChatReads,{}),Te=(0,Y.useMemo)(()=>mt(e.chats,Ce??[]),[e.chats,Ce]),{startNewChat:Re,picker:F}=Xe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[z,Ze]=(0,Y.useState)(``),[Qe,B]=(0,Y.useState)(!1),[H,U]=(0,Y.useState)(e.project.name),[W,et]=(0,Y.useState)(!1),[q,dt]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=setTimeout(()=>dt(z.trim()),180);return()=>clearTimeout(e)},[z]);let Z=N(A.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),Q=De(tt(ot,{activationConstraint:{distance:4}}),tt(Ge,{activationConstraint:{delay:250,tolerance:8}})),$=(0,Y.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,Y.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||E()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(he??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,Y.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=Ae(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=Ae(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=Ae(n(`crumb:`));if(a.length>0)return a;let o=Ae(n(`col:`));return o.length>0?o:Me(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(C===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(C===`list`){let e=D?.chats.find(e=>e._id===t);return e?{list:D.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},kt=t=>{if(C===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(C===`list`){let e=D?.folders.find(e=>e._id===t);if(!e||!D)return null;let n=e.parentId??D.rootId;return{list:Pe(D.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),a=String(t.id),o=a.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(o)await y({chatId:a.slice(5),projectId:e});else{let t=a.slice(7);if(t===e)return;if(!Ke(he??[],t,e)){i.error(g());return}await f({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=a.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await y({chatId:e,projectId:n.folderId});let i=pt(n.list,e=>e._id,e=>e.sortKey,e,t);i&&await ne({chatId:e,...i});return}if(!o&&r.startsWith(`folder:`)){let e=a.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ke(he??[],e,n.parentId)){i.error(g());return}await f({projectId:e,parentId:n.parentId})}let o=pt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await ie({projectId:e,...o});return}}catch{i.error(g())}},[,Mt]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=V(e.project),Ft=ft(e.chats,z),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,X.jsxs)(We,{sensors:Q,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,X.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":Se(),children:[It.map(e=>(0,X.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,X.jsx)(Ct,{folderId:e._id,children:(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,X.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,X.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,X.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,X.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,X.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":x(),children:[(0,X.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":x(),title:x(),"aria-pressed":C===`cards`,onClick:()=>w(`cards`),children:(0,X.jsx)(ut,{})}),(0,X.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":a(),title:a(),"aria-pressed":C===`columns`,onClick:()=>w(`columns`),children:(0,X.jsx)(ct,{})}),(0,X.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":we(),title:we(),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:(0,X.jsx)(Ee,{})})]}),(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Re({projectId:e.project._id}),children:[(0,X.jsx)(at,{}),pe()]}),(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:p(),label:be(),placeholder:me(),confirmLabel:se()});t&&await d({name:t,parentId:e.project._id})},children:[(0,X.jsx)(ke,{}),p()]}),(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Be,{asChild:!0,children:(0,X.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ye(),children:(0,X.jsx)(Ne,{})})}),(0,X.jsxs)(He,{align:`end`,className:`w-48`,children:[(0,X.jsxs)(L,{onSelect:()=>{U(e.project.name),B(!0)},children:[(0,X.jsx)(it,{}),` `,k()]}),(0,X.jsxs)(L,{onSelect:()=>et(!0),children:[(0,X.jsx)(lt,{}),` `,xe()]}),(0,X.jsx)(Le,{children:fe()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e.project._id,color:null}),"aria-label":ve(),children:`✕`}),nt.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e.project._id,color:t.value})},t.value))]}),(0,X.jsx)(ze,{}),(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=S?.folders??0,a=S?.chats??0;await n({title:m({name:e.project.name}),description:i>0?h({folders:i,chats:a}):a>0?ge({count:a}):ce(),confirmWord:j(),confirmLabel:ae(),destructive:!0})&&(await u({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,X.jsx)($e,{}),` `,j()]})]})]})]})]}),C===`columns`?(0,X.jsx)(jt,{data:T,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:O??null}):C===`list`?(0,X.jsx)(Ot,{data:D,busyIds:M,suppressClick:$,locateChatId:O??null}):(0,X.jsxs)(X.Fragment,{children:[e.children.length>0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:_()}),(0,X.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,X.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:st,children:e.children.map(t=>(0,X.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ee()}),e.chats.length>0?(0,X.jsx)(G,{value:z,onChange:e=>Ze(e.target.value),placeholder:v(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?l():re()}):Ft.length===0&&(Z??[]).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:z.trim()})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,X.jsx)(K,{items:Ft.map(e=>`chat:${e._id}`),strategy:J,children:Ft.map(t=>(0,X.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:Te.has(t._id),locate:t._id===O,suppressClick:$},t._id))})})]}),q.length>=2&&Z!==void 0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),Z.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:q})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:Z.map(e=>(0,X.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&Fe(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,X.jsx)(Ye,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,X.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||te()}),e.projectPath&&e.projectPath.length>1?(0,X.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,X.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,X.jsx)(Je,{open:Qe,onOpenChange:B,title:le(),canSubmit:H.trim().length>0,onSubmit:async()=>{await o({projectId:e.project._id,name:H.trim()}),B(!1)},submitLabel:k(),children:(0,X.jsx)(G,{value:H,onChange:e=>U(e.target.value),autoFocus:!0})}),W?(0,X.jsx)(rt,{open:W,onOpenChange:et,title:de(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void f({projectId:e.project._id,parentId:t})}):null,F]}),(0,X.jsx)(Oe,{children:vt?(0,X.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,X.jsx)(R,{size:13,"aria-hidden":!0}):(0,X.jsx)(Ye,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=F({id:yt(e)});return(0,X.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let a=I(),o=z({id:`folder:${e._id}`}),s=F({id:_t(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.setNodeRef(e)},className:`oc-projpage__card`+(s.isOver?` is-over`:``)+(o.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:W.Transform.toString(o.transform),transition:o.transition},onClick:()=>{r.current||a({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&a({to:`/project/$projectId`,params:{projectId:e._id}})},...o.listeners,...o.attributes,role:`link`,tabIndex:0,children:[(0,X.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,X.jsx)(R,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,X.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void a({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,X.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?i({count:e.folderCount})+` · `:``,D({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,X.jsx)(`span`,{className:`oc-projpage__cardage`,children:Qe(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=b(A.chats.setChatSidebar),n=e.inSidebar?f():ie();return(0,X.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,X.jsx)(U,{}):(0,X.jsx)(dt,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=I(),c=H(e.color),l=z({id:`chat:${e._id}`}),u=Dt(a);return(0,X.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:W.Transform.toString(l.transform),transition:l.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||s({to:`/chat/$chatId`,params:{chatId:e._id}})},...l.listeners,...l.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||E()}),e.pinned?(0,X.jsx)(B,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,X.jsx)(`span`,{className:`oc-projpage__chatage`,children:Qe(e.updatedAt,n)}),r?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,title:_e(),"aria-label":_e()}):null,i&&!r?(0,X.jsx)(`span`,{className:`oc-chatitem__unread`,title:S(),"aria-label":S()}):null]}),(0,X.jsx)(Tt,{chat:e}),(0,X.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:i}){let[a,o]=(0,Y.useState)(new Set),s=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:r()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),u=(r,o)=>{let l=s.get(r??e.rootId)??[],d=Pe(e.folders,r);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{items:l.map(e=>`chat:${e._id}`),strategy:J,children:l.map(e=>(0,X.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===i,suppressClick:n},e._id))}),(0,X.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:J,children:d.map(t=>(0,X.jsx)(kt,{folder:t,parentId:r??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.has(t._id)?null:u(t._id,o+1)},t._id))})]})};return(0,X.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Pe(e.folders,null).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):u(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=I(),c=z({id:`folder:${e._id}`}),l=F({id:_t(e._id)});return(0,X.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,X.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":V(e),transform:W.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?u():y(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,X.jsx)(et,{size:13}):(0,X.jsx)(Te,{size:13})}),(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=I(),o=z({id:`chat:${e._id}`}),s=Dt(r),c=H(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:W.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||E()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,X.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:i,locateChatId:a}){let o=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=o.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):(0,X.jsx)(`div`,{className:`oc-projpage__cols`,ref:o,children:e.columns.map((r,o)=>(0,X.jsx)(Mt,{col:r,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:i,locateChatId:a},r.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=I(),s=F({id:vt(e.folderId)});return(0,X.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,X.jsx)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:J,children:e.folders.map(t=>(0,X.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,X.jsx)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:J,children:e.chats.map(t=>(0,X.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__colempty`,children:re()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=z({id:`folder:${e._id}`}),o=F({id:_t(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:W.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=z({id:`chat:${e._id}`}),s=Dt(r),c=H(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:W.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||E()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,X.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AL as r,Ag as i,Bg as a,Cg as o,D as s,Dg as c,Eg as l,Fg as u,Gg as d,Hg as f,Ig as p,Jg as m,Kg as h,Lg as g,Mg as ee,Ng as _,Og as v,Pg as y,Pm as te,RL as b,Sg as ne,Tg as re,Ug as ie,Vg as x,Yg as ae,Zg as S,_g as C,ag as oe,c_ as se,cg as w,dg as ce,e_ as le,eg as T,fg as ue,gg as de,i_ as E,ig as fe,jg as pe,kg as D,l_ as me,ng as O,og as he,qg as ge,r_ as _e,rg as ve,sg as k,t as A,t_ as ye,u_ as be,ug as j,vg as xe,wg as M,xg as Se,yg as Ce,zL as N,zg as we}from"./api-EsnGI4EC.js";import{r as Te}from"./dist-BM94bqpE.js";import{t as Ee}from"./list-DaUUbsAN.js";import{t as P}from"./button-CZ9WPf0m.js";import{A as De,C as Oe,Cn as ke,D as Ae,Dt as je,E as Me,En as Ne,Et as Pe,F as Fe,Fn as Ie,Ft as Le,In as Re,It as ze,Lt as Be,Mt as Ve,Nt as He,O as F,Pn as I,Pt as L,Q as Ue,S as We,Sn as R,T as Ge,Tt as Ke,Z as qe,_ as Je,_n as Ye,b as z,d as Xe,dn as Ze,f as Qe,fn as B,g as V,h as H,hn as U,in as $e,j as W,jn as et,jt as G,k as tt,m as nt,p as rt,pn as it,v as K,vn as at,w as ot,wn as q,x as J,y as st}from"./index-DdOFgMFG.js";var ct=s(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),lt=s(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),ut=s(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),dt=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),Y=t(e(),1),X=n();function Z({className:e}){return(0,X.jsx)(Be,{asChild:!0,children:(0,X.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":w(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,X.jsx)(Ne,{})})})}function Q({folderId:e,name:t,color:n,currentParentId:r,className:i,onOpen:a}){let o=b(A.projects.renameProject),s=b(A.projects.setProjectColor),c=b(A.projects.moveProject),l=b(A.projects.deleteProject),u=b(A.projects.createProject),f=qe(),g=Ue(),[ee,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(t),[te,ne]=(0,Y.useState)(!1),[re,ie]=(0,Y.useState)(!1),x=N(A.projects.projectTreeCount,re?{projectId:e}:`skip`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ve,{onOpenChange:e=>e&&ie(!0),children:[(0,X.jsx)(Z,{className:i}),(0,X.jsxs)(He,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(L,{onSelect:()=>a(),children:[(0,X.jsx)(q,{}),` `,d()]}),(0,X.jsxs)(L,{onSelect:()=>{y(t),_(!0)},children:[(0,X.jsx)(it,{}),` `,k()]}),(0,X.jsxs)(L,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await g({title:p(),label:be(),placeholder:me(),confirmLabel:se()});t&&await u({name:t,parentId:e})})},children:[(0,X.jsx)(ke,{}),` `,p()]}),(0,X.jsxs)(L,{onSelect:()=>ne(!0),children:[(0,X.jsx)(lt,{}),` `,xe()]}),(0,X.jsx)(Le,{children:fe()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e,color:null}),"aria-label":ve(),children:`✕`}),nt.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e,color:t.value})},t.value))]}),(0,X.jsx)(ze,{}),(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=x?.folders??0,r=x?.chats??0;await f({title:m({name:t}),description:n>0?h({folders:n,chats:r}):r>0?ge({count:r}):ce(),confirmWord:j(),confirmLabel:ae(),destructive:!0})&&await l({projectId:e})})},children:[(0,X.jsx)($e,{}),` `,j()]})]})]}),(0,X.jsx)(Je,{open:ee,onOpenChange:_,title:le(),canSubmit:v.trim().length>0,onSubmit:async()=>{await o({projectId:e,name:v.trim()}),_(!1)},submitLabel:k(),children:(0,X.jsx)(G,{value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),te?(0,X.jsx)(rt,{open:te,onOpenChange:ne,title:de(),movingFolderId:e,currentId:r,onPick:t=>void c({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=b(A.chats.pinChat),i=b(A.chats.deleteChat),a=b(A.chats.renameChat),o=b(A.chats.setChatSidebar),s=b(A.chats.moveChatToProject),c=qe(),[l,u]=(0,Y.useState)(!1),[d,p]=(0,Y.useState)(e.title??``),[m,h]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Z,{className:n}),(0,X.jsxs)(He,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(L,{onSelect:()=>{p(e.title??``),u(!0)},children:[(0,X.jsx)(it,{}),` `,k()]}),(0,X.jsxs)(L,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,X.jsx)(Ze,{}):(0,X.jsx)(B,{}),e.pinned?he():oe()]}),(0,X.jsxs)(L,{onSelect:()=>h(!0),children:[(0,X.jsx)(lt,{}),` `,Ce()]}),e.pinned&&e.inSidebar?null:(0,X.jsxs)(L,{onSelect:()=>void o({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,X.jsx)(U,{}):(0,X.jsx)(dt,{}),e.inSidebar?f():ie()]}),(0,X.jsx)(ze,{}),(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await c({title:O(),description:ce(),confirmLabel:j(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,X.jsx)($e,{}),` `,j()]})]})]}),(0,X.jsx)(Je,{open:l,onOpenChange:u,title:T(),canSubmit:d.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:d.trim()}),u(!1)},submitLabel:k(),children:(0,X.jsx)(G,{value:d,onChange:e=>p(e.target.value),autoFocus:!0})}),m?(0,X.jsx)(rt,{open:m,onOpenChange:h,title:C(),currentId:t,onPick:t=>void s({chatId:e._id,projectId:t})}):null]})}function ft(e,t){let n=t.trim().toLowerCase();return n===``?e:e.filter(e=>(e.title??``).toLowerCase().includes(n))}function pt(e,t,n,r,i){let a=e.map(t),o=a.indexOf(i);if(o<0)return null;let s=a.indexOf(r);if(s>=0){let t=[...e],[r]=t.splice(s,1);t.splice(o,0,r);let i=t[o-1],a=t[o+1];return{prevKey:i===void 0?null:n(i),nextKey:a===void 0?null:n(a)}}let c=e[o-1];return{prevKey:c===void 0?null:n(c),nextKey:n(e[o])}}function mt(e,t){let n=new Map(t.map(e=>[e.chatId,e.lastSeenAt])),r=new Set;for(let t of e){let e=n.get(t._id);e!==void 0&&t.lastAssistantAt!==null&&t.lastAssistantAt>e&&r.add(t._id)}return r}var ht=`oc.projpage.view`;function gt(){let e=localStorage.getItem(ht);return e===`cards`||e===`list`?e:`columns`}var _t=e=>`into:${e}`,vt=e=>`col:${e??`null`}`,yt=e=>`crumb:${e}`;function bt(e){if(e.startsWith(`into:`))return e.slice(5);if(e.startsWith(`crumb:`))return e.slice(6);if(e.startsWith(`col:`)){let t=e.slice(4);return t===`null`?null:t}}function xt(){let{projectId:e}=Re({from:`/project/$projectId`}),t=I(),n=N(A.projects.projectPage,{projectId:e});return(0,X.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):n===null?(0,X.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,X.jsx)(`h2`,{children:M()}),(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:o()}),(0,X.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:ne()})]}):(0,X.jsx)(St,{page:n})})}function St({page:e}){let t=I(),n=qe(),r=Ue(),i=je(),o=b(A.projects.renameProject),s=b(A.projects.setProjectColor),u=b(A.projects.deleteProject),d=b(A.projects.createProject),f=b(A.projects.moveProject),y=b(A.chats.moveChatToProject),ne=b(A.chats.reorderChat),ie=b(A.projects.reorderProject),S=N(A.projects.projectTreeCount,{projectId:e.project._id}),[C,oe]=(0,Y.useState)(gt),w=e=>{localStorage.setItem(ht,e),oe(e)},T=N(A.projects.folderColumns,C===`columns`?{projectId:e.project._id}:`skip`),D=N(A.projects.projectTreeList,C===`list`?{projectId:e.project._id}:`skip`),{c:O}=Ie({from:`/project/$projectId`}),he=N(A.projects.listProjects,{}),_e=N(A.chatReads.myBusyChats,{}),M=(0,Y.useMemo)(()=>new Set(_e??[]),[_e]),Ce=N(A.chatReads.myChatReads,{}),Te=(0,Y.useMemo)(()=>mt(e.chats,Ce??[]),[e.chats,Ce]),{startNewChat:Re,picker:F}=Xe(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[z,Ze]=(0,Y.useState)(``),[Qe,B]=(0,Y.useState)(!1),[H,U]=(0,Y.useState)(e.project.name),[W,et]=(0,Y.useState)(!1),[q,dt]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{let e=setTimeout(()=>dt(z.trim()),180);return()=>clearTimeout(e)},[z]);let Z=N(A.search.searchConversations,q.length>=2?{query:q,projectId:e.project._id}:`skip`),Q=De(tt(ot,{activationConstraint:{distance:4}}),tt(Ge,{activationConstraint:{delay:250,tolerance:8}})),$=(0,Y.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,Y.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=T?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||E()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(he??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,Y.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=Ae(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=Ae(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=Ae(n(`crumb:`));if(a.length>0)return a;let o=Ae(n(`col:`));return o.length>0?o:Me(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(C===`columns`){for(let e of T?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(C===`list`){let e=D?.chats.find(e=>e._id===t);return e?{list:D.chats.filter(t=>t.folderId===e.folderId),folderId:e.folderId}:null}return e.chats.some(e=>e._id===t)?{list:e.chats,folderId:e.project._id}:null},kt=t=>{if(C===`columns`){for(let e of T?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(C===`list`){let e=D?.folders.find(e=>e._id===t);if(!e||!D)return null;let n=e.parentId??D.rootId;return{list:Pe(D.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),a=String(t.id),o=a.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(o)await y({chatId:a.slice(5),projectId:e});else{let t=a.slice(7);if(t===e)return;if(!Ke(he??[],t,e)){i.error(g());return}await f({projectId:t,parentId:e})}return}if(o&&r.startsWith(`chat:`)){let e=a.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await y({chatId:e,projectId:n.folderId});let i=pt(n.list,e=>e._id,e=>e.sortKey,e,t);i&&await ne({chatId:e,...i});return}if(!o&&r.startsWith(`folder:`)){let e=a.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ke(he??[],e,n.parentId)){i.error(g());return}await f({projectId:e,parentId:n.parentId})}let o=pt(n.list,e=>e._id,e=>e.sortKey,e,t);o&&await ie({projectId:e,...o});return}}catch{i.error(g())}},[,Mt]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=V(e.project),Ft=ft(e.chats,z),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,X.jsxs)(We,{sensors:Q,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,X.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":Se(),children:[It.map(e=>(0,X.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,X.jsx)(Ct,{folderId:e._id,children:(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,X.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,X.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,X.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,X.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,X.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":x(),children:[(0,X.jsx)(P,{variant:C===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":x(),title:x(),"aria-pressed":C===`cards`,onClick:()=>w(`cards`),children:(0,X.jsx)(ut,{})}),(0,X.jsx)(P,{variant:C===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":a(),title:a(),"aria-pressed":C===`columns`,onClick:()=>w(`columns`),children:(0,X.jsx)(ct,{})}),(0,X.jsx)(P,{variant:C===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":we(),title:we(),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:(0,X.jsx)(Ee,{})})]}),(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Re({projectId:e.project._id}),children:[(0,X.jsx)(at,{}),pe()]}),(0,X.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await r({title:p(),label:be(),placeholder:me(),confirmLabel:se()});t&&await d({name:t,parentId:e.project._id})},children:[(0,X.jsx)(ke,{}),p()]}),(0,X.jsxs)(Ve,{children:[(0,X.jsx)(Be,{asChild:!0,children:(0,X.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ye(),children:(0,X.jsx)(Ne,{})})}),(0,X.jsxs)(He,{align:`end`,className:`w-48`,children:[(0,X.jsxs)(L,{onSelect:()=>{U(e.project.name),B(!0)},children:[(0,X.jsx)(it,{}),` `,k()]}),(0,X.jsxs)(L,{onSelect:()=>et(!0),children:[(0,X.jsx)(lt,{}),` `,xe()]}),(0,X.jsx)(Le,{children:fe()}),(0,X.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,X.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void s({projectId:e.project._id,color:null}),"aria-label":ve(),children:`✕`}),nt.map(t=>(0,X.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void s({projectId:e.project._id,color:t.value})},t.value))]}),(0,X.jsx)(ze,{}),(0,X.jsxs)(L,{variant:`destructive`,onSelect:()=>{let r=e.project.parentId;requestAnimationFrame(async()=>{let i=S?.folders??0,a=S?.chats??0;await n({title:m({name:e.project.name}),description:i>0?h({folders:i,chats:a}):a>0?ge({count:a}):ce(),confirmWord:j(),confirmLabel:ae(),destructive:!0})&&(await u({projectId:e.project._id}),t(r===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:r}}))})},children:[(0,X.jsx)($e,{}),` `,j()]})]})]})]})]}),C===`columns`?(0,X.jsx)(jt,{data:T,currentId:e.project._id,busyIds:M,suppressClick:$,locateChatId:O??null}):C===`list`?(0,X.jsx)(Ot,{data:D,busyIds:M,suppressClick:$,locateChatId:O??null}):(0,X.jsxs)(X.Fragment,{children:[e.children.length>0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:_()}),(0,X.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,X.jsx)(K,{items:e.children.map(e=>`folder:${e._id}`),strategy:st,children:e.children.map(t=>(0,X.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ee()}),e.chats.length>0?(0,X.jsx)(G,{value:z,onChange:e=>Ze(e.target.value),placeholder:v(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?l():re()}):Ft.length===0&&(Z??[]).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:z.trim()})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,X.jsx)(K,{items:Ft.map(e=>`chat:${e._id}`),strategy:J,children:Ft.map(t=>(0,X.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:M.has(t._id),unread:Te.has(t._id),locate:t._id===O,suppressClick:$},t._id))})})]}),q.length>=2&&Z!==void 0?(0,X.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,X.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:ue()}),Z.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:c({term:q})}):(0,X.jsx)(`ul`,{className:`oc-projpage__chats`,children:Z.map(e=>(0,X.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&q&&Fe(e.messageId,q),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,X.jsx)(Ye,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,X.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||te()}),e.projectPath&&e.projectPath.length>1?(0,X.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,X.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,X.jsx)(Je,{open:Qe,onOpenChange:B,title:le(),canSubmit:H.trim().length>0,onSubmit:async()=>{await o({projectId:e.project._id,name:H.trim()}),B(!1)},submitLabel:k(),children:(0,X.jsx)(G,{value:H,onChange:e=>U(e.target.value),autoFocus:!0})}),W?(0,X.jsx)(rt,{open:W,onOpenChange:et,title:de(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void f({projectId:e.project._id,parentId:t})}):null,F]}),(0,X.jsx)(Oe,{children:vt?(0,X.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,X.jsx)(R,{size:13,"aria-hidden":!0}):(0,X.jsx)(Ye,{size:13,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=F({id:yt(e)});return(0,X.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let a=I(),o=z({id:`folder:${e._id}`}),s=F({id:_t(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.setNodeRef(e)},className:`oc-projpage__card`+(s.isOver?` is-over`:``)+(o.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:W.Transform.toString(o.transform),transition:o.transition},onClick:()=>{r.current||a({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&a({to:`/project/$projectId`,params:{projectId:e._id}})},...o.listeners,...o.attributes,role:`link`,tabIndex:0,children:[(0,X.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,X.jsx)(R,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,X.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void a({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,X.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?i({count:e.folderCount})+` · `:``,D({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,X.jsx)(`span`,{className:`oc-projpage__cardage`,children:Qe(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=b(A.chats.setChatSidebar),n=e.inSidebar?f():ie();return(0,X.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,X.jsx)(U,{}):(0,X.jsx)(dt,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=I(),c=H(e.color),l=z({id:`chat:${e._id}`}),u=Dt(a);return(0,X.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:W.Transform.toString(l.transform),transition:l.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{o.current||s({to:`/chat/$chatId`,params:{chatId:e._id}})},...l.listeners,...l.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||E()}),e.pinned?(0,X.jsx)(B,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,X.jsx)(`span`,{className:`oc-projpage__chatage`,children:Qe(e.updatedAt,n)}),r?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,title:_e(),"aria-label":_e()}):null,i&&!r?(0,X.jsx)(`span`,{className:`oc-chatitem__unread`,title:S(),"aria-label":S()}):null]}),(0,X.jsx)(Tt,{chat:e}),(0,X.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:i}){let[a,o]=(0,Y.useState)(new Set),s=(0,Y.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:r()});if(e===null)return null;let c=e=>o(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),u=(r,o)=>{let l=s.get(r??e.rootId)??[],d=Pe(e.folders,r);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{items:l.map(e=>`chat:${e._id}`),strategy:J,children:l.map(e=>(0,X.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===i,suppressClick:n},e._id))}),(0,X.jsx)(K,{items:d.map(e=>`folder:${e._id}`),strategy:J,children:d.map(t=>(0,X.jsx)(kt,{folder:t,parentId:r??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.has(t._id)?null:u(t._id,o+1)},t._id))})]})};return(0,X.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Pe(e.folders,null).length===0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:l()}):u(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=I(),c=z({id:`folder:${e._id}`}),l=F({id:_t(e._id)});return(0,X.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,X.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":V(e),transform:W.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,X.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?u():y(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,X.jsx)(et,{size:13}):(0,X.jsx)(Te,{size:13})}),(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=I(),o=z({id:`chat:${e._id}`}),s=Dt(r),c=H(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:W.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||E()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,X.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:i,locateChatId:a}){let o=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let e=o.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,X.jsx)(`p`,{className:`oc-projpage__hint`,children:r()}):(0,X.jsx)(`div`,{className:`oc-projpage__cols`,ref:o,children:e.columns.map((r,o)=>(0,X.jsx)(Mt,{col:r,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:i,locateChatId:a},r.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=I(),s=F({id:vt(e.folderId)});return(0,X.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,X.jsx)(K,{items:e.folders.map(e=>`folder:${e._id}`),strategy:J,children:e.folders.map(t=>(0,X.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,X.jsx)(K,{items:e.chats.map(e=>`chat:${e._id}`),strategy:J,children:e.chats.map(t=>(0,X.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,X.jsx)(`p`,{className:`oc-projpage__colempty`,children:re()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=z({id:`folder:${e._id}`}),o=F({id:_t(e._id)});return(0,X.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":V(e),transform:W.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,X.jsx)(R,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,X.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,X.jsx)(Q,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=z({id:`chat:${e._id}`}),s=Dt(r),c=H(e.color);return(0,X.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:W.Transform.toString(o.transform),transition:o.transition},children:[(0,X.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,X.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,X.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,X.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||E()}),n?(0,X.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,X.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,X.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Bo as i,Ey as a,Gi as o,Ho as s,Ji as c,Ki as l,RL as u,Ty as d,Uo as f,Vo as p,Yi as m,_r as h,_y as g,aa as _,ay as v,cy as y,dy as b,ey as x,fy as S,gr as C,gy as w,hr as ee,hy as te,ia as ne,iy as re,ly as ie,my as ae,na as oe,ny as se,oy as ce,py as T,qi as E,ra as D,ry as O,sy as k,t as A,ty as j,uy as M,vy as N,zL as P,zo as F}from"./api-EsnGI4EC.js";import{d as I,f as L,i as R,l as z,n as B,r as le,t as V,u as H}from"./FieldLabel-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$v as r,Bo as i,Ey as a,Gi as o,Ho as s,Ji as c,Ki as l,RL as u,Ty as d,Uo as f,Vo as p,Yi as m,_r as h,_y as g,aa as _,ay as v,cy as y,dy as b,ey as x,fy as S,gr as C,gy as w,hr as ee,hy as te,ia as ne,iy as re,ly as ie,my as ae,na as oe,ny as se,oy as ce,py as T,qi as E,ra as D,ry as O,sy as k,t as A,ty as j,uy as M,vy as N,zL as P,zo as F}from"./api-EsnGI4EC.js";import{d as I,f as L,i as R,l as z,n as B,r as le,t as V,u as H}from"./FieldLabel-D_--lTMz.js";import{t as U}from"./button-CZ9WPf0m.js";import{Dt as W,P as ue,_t as G,bt as K,vt as q,wt as de,xt as J,yt as Y}from"./index-DdOFgMFG.js";import{r as X,t as fe}from"./locales-CPjguROj.js";import{t as pe}from"./localePickerView-C2RmOS86.js";/* empty css */var Z=t(e(),1),Q=n(),$={media_delivery:{label:T,help:S},documentary_fetch:{label:b,help:M},inbound_files:{label:ie,help:y},history_summary:{label:f,help:s},file_curation:{label:_,help:m},quote_reply:{label:ne,help:D}},me={outboundDir:`/home/node/.openclaw/media/outbound`,references:`- gdrive/1a2b3c4d5e6f7890abcd
|
|
2
2
|
- gdrive/0f9e8d7c6b5a4321dcba`,files:`- /home/node/.openclaw/media/inbound/rapport.pdf (124800 o, application/pdf)`,previous_summary:`Projet Alpha : budget 40 000 EUR ; choix du serveur en cours.`,new_messages:`Utilisateur : Compare OVH et Scaleway.
|
|
3
3
|
Assistant : Comparaison en cours.`,max_chars:`6000`,file_name:`MEMORY.md`,budget_chars:`20000`,feedback:`Trop de suppressions dans la section des liens, garde-les.`,content:`# Memory index
|
|
4
4
|
- [Fait 1](fait-1.md) - note du projet`,excerpt:`Le classement propose trois dossiers : Clients, Fournisseurs, Interne.`},he={outboundDir:j,references:x,files:r,previous_summary:p,new_messages:i,max_chars:F,file_name:c,budget_chars:E,feedback:l,content:o,excerpt:oe};function ge(){let e=P(A.admin.listInstances,{}),[t,n]=(0,Z.useState)(null);if(e===void 0)return(0,Q.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`});if(e.length===0)return(0,Q.jsx)(`div`,{className:`oc-injtab`,children:(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:ce()})});let r=e.find(e=>e._id===t)??e[0];return(0,Q.jsxs)(`div`,{className:`oc-injtab`,children:[(0,Q.jsxs)(`div`,{className:`oc-injtab__head`,children:[(0,Q.jsx)(B,{label:N(),help:g()}),(0,Q.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,Q.jsx)(`span`,{children:k()}),(0,Q.jsxs)(G,{value:r._id,onValueChange:e=>n(e),children:[(0,Q.jsx)(K,{size:`sm`,className:`min-w-44`,children:(0,Q.jsx)(J,{})}),(0,Q.jsx)(q,{children:e.map(e=>(0,Q.jsx)(Y,{value:e._id,children:e.displayName??e.name},e._id))})]})]})]}),(0,Q.jsx)(_e,{instance:r},r._id)]})}function _e({instance:e}){let t=u(A.admin.upsertInstanceConfig),n=W(),r=P(A.me.getMe,{host:de}),i=e.config??{},o=X(e.config?.contentLocale,r?.defaultLocale??void 0),[s,c]=(0,Z.useState)(()=>R(i,o));(0,Z.useEffect)(()=>{c(R(i,o))},[o,e._id]);let[l,f]=(0,Z.useState)(!1),p=s.promptInjections,m=(e,t)=>c({...s,promptInjections:{...p,[e]:{...p[e],...t}}});async function g(){f(!0);try{await t({instanceId:e._id,config:le(s,i,o)})}catch(e){n.error(d(),e)}finally{f(!1)}}async function _(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(d(),e)}}let v=e.config?.contentLocale??`default`,y=fe[X(void 0,r?.defaultLocale??void 0)];return(0,Q.jsxs)(`div`,{className:`oc-injtab__body`,children:[(0,Q.jsxs)(`div`,{className:`oc-injtab__content-locale`,children:[(0,Q.jsx)(`span`,{children:h()}),(0,Q.jsxs)(G,{value:v,onValueChange:e=>void _(e),children:[(0,Q.jsx)(K,{size:`sm`,className:`min-w-44`,children:(0,Q.jsx)(J,{})}),(0,Q.jsxs)(q,{children:[(0,Q.jsx)(Y,{value:`default`,children:ee({locale:y})}),pe().map(e=>(0,Q.jsx)(Y,{value:e.value,children:e.label},e.value))]})]}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:C()})]}),H.map(e=>(0,Q.jsx)(ve,{injKey:e,def:z[e],i18n:$[e],row:p[e]??{enabled:!0,template:z[e].defaultTemplate[o]},contentLocale:o,onChange:t=>m(e,t)},e)),(0,Q.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,Q.jsx)(U,{size:`sm`,onClick:()=>void g(),disabled:l,children:a()})})]})}function ve({injKey:e,def:t,i18n:n,row:r,contentLocale:i,onChange:a}){let[o,s]=(0,Z.useState)(!1),c=r.template.trim()!==t.defaultTemplate[i],l=t.togglable&&!r.enabled,u=Object.fromEntries(t.placeholders.map(e=>[e,me[e]??`{${e}}`])),d=I(e,r,i),f=d?L(d,u):``;return(0,Q.jsxs)(`section`,{className:`oc-injcard`,children:[(0,Q.jsxs)(`div`,{className:`oc-injcard__head`,children:[t.togglable?(0,Q.jsxs)(`label`,{className:`oc-field--row`,children:[(0,Q.jsx)(ue,{checked:r.enabled,onCheckedChange:e=>a({enabled:e===!0})}),(0,Q.jsx)(B,{label:n.label(),help:n.help()})]}):(0,Q.jsx)(B,{label:n.label(),help:n.help()}),c&&(0,Q.jsx)(`span`,{className:`oc-injection__badge`,children:te()})]}),(0,Q.jsx)(`textarea`,{className:`oc-injcard__text`,value:r.template,disabled:l,rows:8,spellCheck:!1,onChange:e=>a({template:e.target.value})}),(0,Q.jsxs)(`div`,{className:`oc-injection__foot`,children:[(0,Q.jsxs)(`div`,{className:`oc-injcard__phs`,children:[(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:ae()}),t.placeholders.map(e=>(0,Q.jsxs)(`span`,{className:`oc-injcard__ph-chip`,children:[(0,Q.jsx)(`code`,{children:`{${e}}`}),(0,Q.jsx)(V,{text:(he[e]??(()=>e))()})]},e))]}),(0,Q.jsxs)(`div`,{className:`oc-injcard__btns`,children:[(0,Q.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>s(e=>!e),children:o?re():v()}),c&&(0,Q.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:w()})]})]}),o&&(0,Q.jsx)(`div`,{className:`oc-injcard__preview`,children:f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`pre`,{className:`oc-injcard__previewtext`,children:f}),(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:O()})]}):(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:se()})})]})}export{ge as PromptInjectionsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$S as r,AS as ee,BS as i,DS as a,ES as te,GS as o,HS as s,JS as c,KS as l,MS as u,NS as d,OS as f,QS as p,RL as m,TS as ne,US as re,VS as ie,WS as h,XS as g,YS as _,ZS as v,aC as y,cC as b,dC as x,eC as S,fC as C,iC as w,jS as T,kS as E,ka as D,lC as O,mC as k,nC as A,oC as j,pC as M,qS as N,rC as P,sC as F,t as I,tC as L,uC as R,zL as z,zS as ae}from"./api-EsnGI4EC.js";import{t as B}from"./button-CZ9WPf0m.js";import{Dt as V,P as H,Z as U,_ as W,jt as G,ut as K,yn as q}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$S as r,AS as ee,BS as i,DS as a,ES as te,GS as o,HS as s,JS as c,KS as l,MS as u,NS as d,OS as f,QS as p,RL as m,TS as ne,US as re,VS as ie,WS as h,XS as g,YS as _,ZS as v,aC as y,cC as b,dC as x,eC as S,fC as C,iC as w,jS as T,kS as E,ka as D,lC as O,mC as k,nC as A,oC as j,pC as M,qS as N,rC as P,sC as F,t as I,tC as L,uC as R,zL as z,zS as ae}from"./api-EsnGI4EC.js";import{t as B}from"./button-CZ9WPf0m.js";import{Dt as V,P as H,Z as U,_ as W,jt as G,ut as K,yn as q}from"./index-DdOFgMFG.js";import{t as J}from"./roleDescriptions-DEIReM8x.js";var Y=t(e(),1),X=n(),Z=[{group:()=>k(),keys:[{key:`traces.read`,label:()=>O()},{key:`traces.read.content`,label:()=>b(),phi:!0},{key:`traces.write`,label:()=>F()}]},{group:()=>M(),keys:[{key:`kpi.read`,label:()=>O()},{key:`kpi.write`,label:()=>F()}]},{group:()=>C(),keys:[{key:`openclaw.query`,label:()=>j()},{key:`anomalies.read`,label:()=>y()},{key:`anomalies.report`,label:()=>w()}]},{group:()=>x(),keys:[{key:`chats.read`,label:()=>O()},{key:`selfheal`,label:()=>A()},{key:`feedback.respond`,label:()=>D()}]},{group:()=>R(),keys:[{key:`admin.manage`,label:()=>P()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=z(I.apiKeys.listRoles,{}),t=m(I.apiKeys.createRole),n=m(I.apiKeys.ensureRolesSeeded),y=m(I.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(I.apiKeys.listRoles,{});r&&e.setQuery(I.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),b=U(),x=V(),[C,w]=(0,Y.useState)(!1),[D,O]=(0,Y.useState)($),[k,A]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{x.error(S(),e)})},[n,x]);let j=e??[];async function M(e,t){if(Q(e.permissions))return;if(e.builtin){await b({title:r({name:e.name}),description:p(),confirmLabel:v()});return}if(k.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];A(t=>new Set(t).add(e._id));try{await y({roleId:e._id,permissions:n})}catch(e){x.error(g(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function P(){try{await t({key:D.key,name:D.name,description:D.description||void 0,permissions:[]}),O($),w(!1)}catch(e){x.error(_(),e)}}let F=e===void 0,R=!F&&j.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[c(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,N(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,l()]}),(0,X.jsxs)(`div`,{className:`oc-dt`,children:[(0,X.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,X.jsx)(`h2`,{className:`oc-dt__title`,children:o()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{O($),w(!0)},children:h()})})]}),F?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:re()}):R?(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:ie()}),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?L({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:j.map(e=>{let t=Q(e.permissions),n=k.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)(K,{variant:`outline`,className:`gap-1`,children:[(0,X.jsx)(q,{}),` `,i()]}):(0,X.jsx)(K,{variant:`secondary`,children:ae()})]}),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)(H,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?d():n?u():r,onCheckedChange:()=>void M(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:C,onOpenChange:w,title:T(),description:ee(),canSubmit:!!(D.key&&D.name),onSubmit:P,submitLabel:E(),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:f()}),(0,X.jsx)(G,{value:D.key,placeholder:a(),onChange:e=>O({...D,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:te()}),(0,X.jsx)(G,{value:D.name,onChange:e=>O({...D,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:ne()}),(0,X.jsx)(G,{value:D.description,onChange:e=>O({...D,description:e.target.value})})]})]})})]})}export{se as RolesTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,AF as i,AL as a,AP as o,CF as s,CP as c,D as l,DF as u,DP as ee,EF as d,EP as f,FF as p,FP as te,GP as ne,IF as re,IL as m,JP as ie,KP as ae,LF as oe,ML as h,MP as se,NF as ce,NP as le,OF as ue,OP as de,PF as fe,PP as pe,QP as me,SP as he,TF as ge,TP as _e,XP as g,YP as ve,ZP as _,_F as ye,aF as be,aI as xe,bP as Se,cI as Ce,dF as we,dI as Te,eF as Ee,eI as De,fF as Oe,fI as ke,fP as Ae,gF as je,hF as Me,iF as Ne,iI as Pe,jF as v,jP as Fe,kF as Ie,kP as Le,lI as Re,mF as ze,mI as Be,nF as Ve,nI as He,oF as y,oI as Ue,pF as We,pI as Ge,qP as Ke,rF as b,rI as qe,sI as Je,t as x,tF as Ye,tI as Xe,uI as Ze,vF as Qe,vP as $e,wF as et,wP as tt,xP as nt,yF as rt,yP as it,zL as at}from"./api-EsnGI4EC.js";import{t as ot}from"./list-DaUUbsAN.js";import{t as S}from"./button-CZ9WPf0m.js";import{$ as st,Bt as C,Dt as ct,Mn as w,Rt as T,X as lt,Y as ut,_t as E,at as dt,bn as ft,bt as D,cn as pt,dt as mt,et as ht,ft as gt,gt as _t,ht as vt,in as yt,it as bt,jn as O,jt as xt,mn as St,mt as Ct,nt as wt,ot as Tt,pn as Et,pt as Dt,rt as Ot,tn as kt,tt as At,un as jt,ut as k,vt as A,wt as Mt,xt as j,yt as M,zt as N}from"./index-CsdodIca.js";import{a as Nt,i as P,n as Pt,o as Ft,r as F,t as It}from"./table-B--HXOj1.js";import{t as Lt}from"./FilterBar-Bxpfu6Cp.js";/* empty css */import{a as I,c as Rt,i as zt,l as Bt,n as Vt,o as Ht,r as Ut,s as L,t as Wt}from"./TimezoneCombobox-Cf0dO1lp.js";var Gt=l(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Kt=l(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=t(e(),1),z=n();function B(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function qt({value:e,onChange:t}){let n=Rt(e),r=(0,R.useMemo)(()=>new Date,[]),[i,a]=(0,R.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>B(h()),[]),l=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{month:`long`,year:`numeric`}),[]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=L(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(Bt(e,n,r,i,a)),te=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},ne=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},re=n===null?be():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,z.jsxs)(T,{modal:!0,open:o,onOpenChange:s,children:[(0,z.jsx)(C,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":y(),children:[(0,z.jsx)(Gt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,z.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:re})]})}),(0,z.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,z.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":Ne(),onClick:()=>ne(-1),children:(0,z.jsx)(w,{size:15,"aria-hidden":!0})}),(0,z.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":b(),onClick:()=>ne(1),children:(0,z.jsx)(O,{size:15,"aria-hidden":!0})})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>te(e.year,e.month,e.day),children:e.day},t)})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,z.jsxs)(E,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,z.jsx)(D,{size:`sm`,"aria-label":Ve(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,z.jsx)(M,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,z.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,z.jsxs)(E,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,z.jsx)(D,{size:`sm`,"aria-label":Ye(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,z.jsx)(M,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function V(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Jt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Yt(e){let t=new Map;for(let n of e){let e=V(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function H(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Jt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function Xt(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Zt(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+42);return{startMs:r.getTime(),endMs:i.getTime()}}function Qt(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var U=3;function $t({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=h(),c=(0,R.useMemo)(()=>Yt(e),[e]),l=(0,R.useMemo)(()=>Xt(s),[s]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),ee=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),d=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),f=new Date,p=e=>{if(t===`year`){i({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);i({year:r.getFullYear(),month:r.getMonth()})},te=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,z.jsxs)(`div`,{className:`oc-cal`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":ie(),onClick:()=>p(-1),children:(0,z.jsx)(w,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":Ke(),onClick:()=>p(1),children:(0,z.jsx)(O,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>i({year:f.getFullYear(),month:f.getMonth()}),children:ve()})]}),(0,z.jsx)(`span`,{className:`oc-cal__title`,children:te}),(0,z.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,z.jsx)(S,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:_()}),(0,z.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:g()})]})]}),t===`month`?(0,z.jsx)(en,{cursor:n,byDay:c,weekdays:l,timeFmt:d,now:f,onEventClick:a}):(0,z.jsx)(tn,{year:n.year,byDay:c,monthShortFmt:ee,now:f,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,z.jsx)(`p`,{className:`oc-cal__footnote`,children:o}):null]})}function en({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=L(e.year,e.month);return(0,z.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Jt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,z.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,z.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,U).map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,z.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,z.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>U?(0,z.jsx)(`span`,{className:`oc-cal__more`,children:ae({count:o.length-U})}):null]},n)})]})}function tn({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,z.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=H(t,e,o),c=L(e,o);return(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,z.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,z.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var W={h:36e5,min:6e4,s:1e3,ms:1};function nn(e){if(e===null)return null;let t=e.trim(),n=/^every\s+(\d+(?:\.\d+)?)(h|min|s|ms)$/.exec(t);if(n!==null){let e=Number(n[1])*W[n[2]];return Number.isFinite(e)&&e>0?{kind:`every`,everyMs:e}:null}let r=/^(?:cron\s+)?([\d*,/-]+(?:\s+[\d*,/-]+){4})(?:\s*\(([^)]+)\))?$/.exec(t);if(r!==null)return{kind:`cron`,expr:r[1],tz:r[2]??null};let i=Date.parse(t);return Number.isFinite(i)?{kind:`at`,atMs:i}:null}function G(e,t,n){let r=new Set;for(let i of e.split(`,`)){let e=i,a=1,o=/^(.+)\/(\d{1,3})$/.exec(i);if(o!==null&&(e=o[1],a=Number(o[2]),a<1))return null;let s,c;if(e===`*`)s=t,c=n;else{let r=/^(\d{1,3})(?:-(\d{1,3}))?$/.exec(e);if(r===null||(s=Number(r[1]),c=r[2]===void 0?s:Number(r[2]),r[2]===void 0&&o!==null&&(c=n),s<t||c>n||s>c))return null}for(let e=s;e<=c;e+=a)r.add(e)}return r.size>0?[...r].sort((e,t)=>e-t):null}function K(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=G(t[0],0,59),r=G(t[1],0,23),i=G(t[2],1,31),a=G(t[3],1,12),o=G(t[4],0,7);if(!n||!r||!i||!a||!o)return null;let s=new Set(o.map(e=>e%7));return{minutes:n,hours:r,dom:new Set(i),months:new Set(a),dow:s,domRestricted:t[2]!==`*`,dowRestricted:t[4]!==`*`}}var q=new Map;function J(e){let t=q.get(e);if(t!==void 0)return t;let n=null;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{n=null}return q.set(e,n),n}function Y(e,t){if(t!==null){let n=J(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function X(e,t,n,r,i,a){if(a===null||J(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=Y(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function Z(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=K(e.expr);if(t!==null&&t.hours.length*t.minutes.length<=400){let i=0,o=n-864e5;for(;o<r+864e5&&i<400;){let s=Y(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Q=`crons`;function rn(e,t){return`${e}${t}`}function an(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=rn(a.instanceName,e.id);i.set(o,a);let s=Z(e.enabled===!1?null:nn(e.schedule),e.nextRunAtMs,t,n);for(let t of s)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:e.enabled===!1,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function on(e){return e?.data?.code??`unknown`}function sn({status:e}){switch(I(e)){case`ok`:return(0,z.jsx)(k,{variant:`secondary`,children:Qe()});case`error`:return(0,z.jsx)(k,{variant:`destructive`,children:ye()});case`running`:return(0,z.jsx)(k,{variant:`outline`,children:je()});case`other`:return(0,z.jsx)(k,{variant:`outline`,children:e});case`none`:return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function cn(){let e=m(x.scheduled.listMyCrons),t=m(x.scheduled.getCronDetail),n=m(x.scheduled.listCronRuns),l=m(x.scheduled.updateCron),ie=m(x.scheduled.removeCron),ae=m(x.scheduled.runCronNow),g=ct(),ve=at(x.me.getMe,{host:Mt})?.timezone,[_,be]=(0,R.useState)(null),[Ne,Ve]=(0,R.useState)(!1),[y,Ke]=(0,R.useState)(!1),[b,Ye]=(0,R.useState)(null),[C,w]=(0,R.useState)(null),[T,O]=(0,R.useState)(null),[N,I]=(0,R.useState)(null),[Rt,Bt]=(0,R.useState)(!1),[L,B]=(0,R.useState)(Vt),[V,Jt]=(0,R.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Yt=e=>{localStorage.setItem(`oc.sched.view`,e),Jt(e)},[H,Xt]=(0,R.useState)(`month`),[U,en]=(0,R.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),tn=(0,R.useMemo)(()=>{let e=[];for(let t of _??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)zt(r,L)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[_,L]),W=(0,R.useMemo)(()=>H===`year`?Qt(U.year):Zt(U.year,U.month),[H,U]),nn=(0,R.useMemo)(()=>an(tn,W.startMs,W.endMs),[tn,W]),G=e=>{let t=nn.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||cn(t.instanceName,t.job)},K=(0,R.useCallback)(async()=>{Ve(!0),Ke(!1);try{be(await e({}))}catch{Ke(!0)}finally{Ve(!1)}},[e]);(0,R.useEffect)(()=>{K()},[K]);let q=(0,R.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,R.useRef)(null);(0,R.useEffect)(()=>{_!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[_]);let Y=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{Ye(e);try{await t(),g.success(n),await K()}catch(e){g.toast({variant:`error`,title:v({code:on(e)})})}finally{Ye(null)}},Z=(0,R.useRef)(0),Q=(0,R.useRef)(0),rn=async(e,t)=>{if(t.id===null)return;let r=++Z.current;O({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;O({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;O(null),g.toast({variant:`error`,title:v({code:on(e)})})}},cn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;I({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.current)return;I(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Q.current)return;I(null),g.toast({variant:`error`,title:v({code:on(e)})})}},ln=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){g.toast({variant:`error`,title:$e()});return}if(N.nameDirty&&N.name.trim()!==``&&(e.name=N.name.trim()),N.scheduleDirty){if(N.scheduleKind===`cron`&&N.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:N.cronExpr.trim(),...N.tz.trim()===``?{}:{tz:N.tz.trim()}};else if(N.scheduleKind===`every`){let t=Number(N.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[N.everyUnit])})}else if(N.scheduleKind===`at`&&N.at!==``){let t=Date.parse(N.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(N.scheduleDirty&&e.schedule===void 0){g.toast({variant:`error`,title:it()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Q.current;Bt(!0);try{await l({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(se()),t===Q.current&&I(null),await K()}catch(e){g.toast({variant:`error`,title:v({code:on(e)})})}finally{Bt(!1)}},un=_?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:Be()}),(0,z.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Ee(),children:[(0,z.jsx)(S,{variant:V===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":r(),title:r(),"aria-pressed":V===`list`,onClick:()=>Yt(`list`),children:(0,z.jsx)(ot,{})}),(0,z.jsx)(S,{variant:V===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":me(),title:me(),"aria-pressed":V===`calendar`,onClick:()=>Yt(`calendar`),children:(0,z.jsx)(Gt,{})})]}),(0,z.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:Ne,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,z.jsx)(pt,{size:14,"aria-hidden":!0}),Ge()]})]}),_!==null&&un>0?(0,z.jsxs)(Lt,{q:L.q,onQChange:e=>B(t=>({...t,q:e})),searchPlaceholder:ze(),onReset:()=>B(Vt),canReset:Ut(L),children:[(0,z.jsxs)(E,{value:L.state,onValueChange:e=>B(t=>({...t,state:e})),children:[(0,z.jsx)(D,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`all`,children:We()}),(0,z.jsx)(M,{value:`active`,children:De()}),(0,z.jsx)(M,{value:`paused`,children:Xe()})]})]}),(0,z.jsxs)(E,{value:L.result,onValueChange:e=>B(t=>({...t,result:e})),children:[(0,z.jsx)(D,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`all`,children:Oe()}),(0,z.jsx)(M,{value:`ok`,children:Qe()}),(0,z.jsx)(M,{value:`error`,children:ye()}),(0,z.jsx)(M,{value:`running`,children:je()}),(0,z.jsx)(M,{value:`none`,children:Me()})]})]})]}):null,_===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Ne,children:y?ke():a()}):V===`calendar`?(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ke()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Te()}):(0,z.jsx)($t,{events:nn.events,mode:H,cursor:U,onModeChange:Xt,onCursorChange:en,onEventClick:G,footnote:ne()})]}):(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ke()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Te()}):null,_.map(e=>{let t=e.jobs.filter(e=>zt(e,L)),n=Ut(L)&&e.jobs.length>0&&t.length===0;return(0,z.jsxs)(`section`,{style:{marginBottom:20},children:[_.length>1||e.error||!e.supported?(0,z.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,z.jsx)(k,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Re({code:e.error})}):e.jobs.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):n?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):(0,z.jsxs)(It,{children:[(0,z.jsx)(Nt,{children:(0,z.jsxs)(Ft,{children:[(0,z.jsx)(P,{children:Je()}),(0,z.jsx)(P,{children:Ue()}),(0,z.jsx)(P,{children:xe()}),(0,z.jsx)(P,{children:Pe()}),(0,z.jsx)(P,{children:qe()}),(0,z.jsx)(P,{children:rt()}),(0,z.jsx)(P,{children:te()})]})}),(0,z.jsx)(Pt,{children:t.map((t,n)=>{let r=`${e.instanceName}:${t.id??n}`,a=b===r,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,z.jsxs)(Ft,{ref:t.id!==null&&t.id===q?J:void 0,"data-state":t.id!==null&&t.id===q?`selected`:void 0,children:[(0,z.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??He()}),(0,z.jsx)(F,{children:(0,z.jsx)(k,{variant:`secondary`,children:t.agentId})}),(0,z.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=ut(t.schedule),n=e===null?null:lt(e);return n===null?null:(0,z.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,z.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,z.jsx)(F,{children:Ht(t.enabled)===`active`?(0,z.jsx)(k,{variant:`secondary`,children:De()}):Ht(t.enabled)===`paused`?(0,z.jsx)(k,{variant:`outline`,children:Xe()}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,z.jsx)(F,{children:(0,z.jsx)(sn,{status:t.lastRunStatus})}),(0,z.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,z.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,z.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:re(),"aria-label":re(),disabled:b!==null,onClick:()=>void X(r,async()=>{let n=await ae({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},i()),children:(0,z.jsx)(kt,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:t.enabled?p():fe(),"aria-label":t.enabled?p():fe(),disabled:b!==null,onClick:()=>void X(r,()=>l({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?Ie():ue()),children:t.enabled?(0,z.jsx)(St,{size:14,"aria-hidden":!0}):(0,z.jsx)(jt,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:pe(),"aria-label":pe(),disabled:b!==null,onClick:()=>void cn(e.instanceName,t),children:(0,z.jsx)(Et,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:le(),"aria-label":le(),disabled:b!==null,onClick:()=>void rn(e.instanceName,t),children:(0,z.jsx)(Kt,{size:14,"aria-hidden":!0})}):null,o?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:ce(),"aria-label":ce(),disabled:b!==null,onClick:()=>w({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,z.jsx)(yt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ze()})]},e.instanceName)}),un>0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ae()}):null]}),(0,z.jsx)(st,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,z.jsxs)(wt,{children:[(0,z.jsxs)(dt,{children:[(0,z.jsx)(Tt,{children:d()}),(0,z.jsx)(Ot,{children:ge({name:C?.name??``})})]}),(0,z.jsxs)(bt,{children:[(0,z.jsx)(At,{children:et()}),(0,z.jsx)(ht,{onClick:()=>{let e=C;w(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>ie({instanceName:e.instanceName,jobId:e.jobId}),u())},children:s()})]})]})}),(0,z.jsx)(mt,{open:T!==null,onOpenChange:e=>{e||(Z.current++,O(null))},children:(0,z.jsxs)(gt,{style:{maxWidth:640},children:[(0,z.jsx)(vt,{children:(0,z.jsx)(_t,{children:Fe({name:T?.name??``})})}),T?.entries===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):T!==null&&T.entries.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):T===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:T.entries.map((e,t)=>(0,z.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,z.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,z.jsx)(sn,{status:e.status}),(0,z.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,z.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error})]},t))})]})}),(0,z.jsx)(mt,{open:N!==null,onOpenChange:e=>{e||(Q.current++,I(null))},children:(0,z.jsxs)(gt,{className:`oc-cronedit`,children:[(0,z.jsxs)(vt,{children:[(0,z.jsx)(_t,{children:Le()}),(0,z.jsx)(Dt,{children:de()})]}),N===null?null:N.loading?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Je()}),(0,z.jsx)(xt,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ee()}),(0,z.jsxs)(E,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,z.jsx)(D,{children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`cron`,children:f()}),(0,z.jsx)(M,{value:`every`,children:_e()}),(0,z.jsx)(M,{value:`at`,children:tt()})]})]}),N.scheduleKind===`cron`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(xt,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,z.jsx)(Wt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:ve??void 0})]}):N.scheduleKind===`every`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(xt,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,z.jsxs)(E,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,z.jsx)(D,{style:{maxWidth:160},children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`minutes`,children:c()}),(0,z.jsx)(M,{value:`hours`,children:he()}),(0,z.jsx)(M,{value:`days`,children:nt()})]})]})]}):(0,z.jsx)(qt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:oe()}),(0,z.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,z.jsxs)(Ct,{children:[(0,z.jsx)(S,{variant:`ghost`,onClick:()=>I(null),children:et()}),(0,z.jsxs)(S,{onClick:()=>void ln(),disabled:N===null||N.loading||Rt,children:[Rt?(0,z.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,Se()]})]})]})})]})}export{cn as ScheduledTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$P as r,AF as i,AL as a,AP as o,CF as s,CP as c,D as l,DF as u,DP as ee,EF as d,EP as f,FF as p,FP as te,GP as ne,IF as re,IL as m,JP as ie,KP as ae,LF as oe,ML as h,MP as se,NF as ce,NP as le,OF as ue,OP as de,PF as fe,PP as pe,QP as me,SP as he,TF as ge,TP as _e,XP as g,YP as ve,ZP as _,_F as ye,aF as be,aI as xe,bP as Se,cI as Ce,dF as we,dI as Te,eF as Ee,eI as De,fF as Oe,fI as ke,fP as Ae,gF as je,hF as Me,iF as Ne,iI as Pe,jF as v,jP as Fe,kF as Ie,kP as Le,lI as Re,mF as ze,mI as Be,nF as Ve,nI as He,oF as y,oI as Ue,pF as We,pI as Ge,qP as Ke,rF as b,rI as qe,sI as Je,t as x,tF as Ye,tI as Xe,uI as Ze,vF as Qe,vP as $e,wF as et,wP as tt,xP as nt,yF as rt,yP as it,zL as at}from"./api-EsnGI4EC.js";import{t as ot}from"./list-DaUUbsAN.js";import{t as S}from"./button-CZ9WPf0m.js";import{$ as st,Bt as C,Dt as ct,Mn as w,Rt as T,X as lt,Y as ut,_t as E,at as dt,bn as ft,bt as D,cn as pt,dt as mt,et as ht,ft as gt,gt as _t,ht as vt,in as yt,it as bt,jn as O,jt as xt,mn as St,mt as Ct,nt as wt,ot as Tt,pn as Et,pt as Dt,rt as Ot,tn as kt,tt as At,un as jt,ut as k,vt as A,wt as Mt,xt as j,yt as M,zt as N}from"./index-DdOFgMFG.js";import{a as Nt,i as P,n as Pt,o as Ft,r as F,t as It}from"./table-B--HXOj1.js";import{t as Lt}from"./FilterBar-3xmqkmtO.js";/* empty css */import{a as I,c as Rt,i as zt,l as Bt,n as Vt,o as Ht,r as Ut,s as L,t as Wt}from"./TimezoneCombobox-DjUiyEWp.js";var Gt=l(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),Kt=l(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),R=t(e(),1),z=n();function B(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function qt({value:e,onChange:t}){let n=Rt(e),r=(0,R.useMemo)(()=>new Date,[]),[i,a]=(0,R.useState)(()=>({year:n?.year??r.getFullYear(),month:n?.month??r.getMonth()})),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>B(h()),[]),l=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{month:`long`,year:`numeric`}),[]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{dateStyle:`medium`,timeStyle:`short`}),[]),ee=L(i.year,i.month),d=n?.hour??9,f=n?.minute??0,p=(e,n,r,i,a)=>t(Bt(e,n,r,i,a)),te=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},ne=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},re=n===null?be():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,z.jsxs)(T,{modal:!0,open:o,onOpenChange:s,children:[(0,z.jsx)(C,{asChild:!0,children:(0,z.jsxs)(`button`,{type:`button`,className:`oc-dtp__trigger`,"aria-label":y(),children:[(0,z.jsx)(Gt,{size:14,"aria-hidden":!0,className:`oc-dtp__icon`}),(0,z.jsx)(`span`,{className:n===null?`oc-dtp__placeholder`:void 0,children:re})]})}),(0,z.jsxs)(N,{align:`start`,className:`oc-dtp__pop`,children:[(0,z.jsxs)(`div`,{className:`oc-dtp__head`,children:[(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":Ne(),onClick:()=>ne(-1),children:(0,z.jsx)(w,{size:15,"aria-hidden":!0})}),(0,z.jsx)(`span`,{className:`oc-dtp__month`,children:l.format(new Date(i.year,i.month,1))}),(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__nav`,"aria-label":b(),onClick:()=>ne(1),children:(0,z.jsx)(O,{size:15,"aria-hidden":!0})})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__grid`,children:[c.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-dtp__wd`,children:e},t)),ee.map((e,t)=>{let i=n!==null&&n.year===e.year&&n.month===e.month&&n.day===e.day,a=r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`button`,{type:`button`,className:`oc-dtp__day`+(e.inMonth?``:` oc-dtp__day--out`)+(i?` oc-dtp__day--sel`:``)+(a&&!i?` oc-dtp__day--today`:``),onClick:()=>te(e.year,e.month,e.day),children:e.day},t)})]}),(0,z.jsxs)(`div`,{className:`oc-dtp__time`,children:[(0,z.jsxs)(E,{value:String(d),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),Number(e),f),children:[(0,z.jsx)(D,{size:`sm`,"aria-label":Ve(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:24},(e,t)=>(0,z.jsx)(M,{value:String(t),children:String(t).padStart(2,`0`)},t))})]}),(0,z.jsx)(`span`,{className:`oc-dtp__colon`,children:`:`}),(0,z.jsxs)(E,{value:String(f),onValueChange:e=>p(i.year,i.month,n?.day??r.getDate(),d,Number(e)),children:[(0,z.jsx)(D,{size:`sm`,"aria-label":Ye(),children:(0,z.jsx)(j,{})}),(0,z.jsx)(A,{className:`oc-dtp__timeopts`,children:Array.from({length:60},(e,t)=>(0,z.jsx)(M,{value:String(t),children:String(t).padStart(2,`0`)},t))})]})]})]})]})}function V(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Jt(e,t,n){let r=e=>String(e).padStart(2,`0`);return`${e}-${r(t+1)}-${r(n)}`}function Yt(e){let t=new Map;for(let n of e){let e=V(n.atMs),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}for(let e of t.values())e.sort((e,t)=>e.atMs-t.atMs);return t}function H(e,t,n){let r=new Map,i=new Date(t,n+1,0).getDate();for(let a=1;a<=i;a++){let i=e.get(Jt(t,n,a));i!==void 0&&i.length>0&&r.set(a,i.length)}return r}function Xt(e){try{let t=new Intl.DateTimeFormat(e,{weekday:`narrow`});return Array.from({length:7},(e,n)=>t.format(new Date(2024,0,1+n)))}catch{return[`M`,`T`,`W`,`T`,`F`,`S`,`S`]}}function Zt(e,t){let n=(new Date(e,t,1).getDay()+6)%7,r=new Date(e,t,1-n),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()+42);return{startMs:r.getTime(),endMs:i.getTime()}}function Qt(e){return{startMs:new Date(e,0,1).getTime(),endMs:new Date(e+1,0,1).getTime()}}var U=3;function $t({events:e,mode:t,cursor:n,onModeChange:r,onCursorChange:i,onEventClick:a,footnote:o}){let s=h(),c=(0,R.useMemo)(()=>Yt(e),[e]),l=(0,R.useMemo)(()=>Xt(s),[s]),u=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`,year:`numeric`}),[s]),ee=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{month:`long`}),[s]),d=(0,R.useMemo)(()=>new Intl.DateTimeFormat(s,{hour:`2-digit`,minute:`2-digit`}),[s]),f=new Date,p=e=>{if(t===`year`){i({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);i({year:r.getFullYear(),month:r.getMonth()})},te=t===`year`?String(n.year):u.format(new Date(n.year,n.month,1));return(0,z.jsxs)(`div`,{className:`oc-cal`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__head`,children:[(0,z.jsxs)(`div`,{className:`oc-cal__nav`,children:[(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":ie(),onClick:()=>p(-1),children:(0,z.jsx)(w,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":Ke(),onClick:()=>p(1),children:(0,z.jsx)(O,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>i({year:f.getFullYear(),month:f.getMonth()}),children:ve()})]}),(0,z.jsx)(`span`,{className:`oc-cal__title`,children:te}),(0,z.jsxs)(`div`,{className:`oc-cal__modes`,role:`group`,children:[(0,z.jsx)(S,{variant:t===`month`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`month`,onClick:()=>r(`month`),children:_()}),(0,z.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>r(`year`),children:g()})]})]}),t===`month`?(0,z.jsx)(en,{cursor:n,byDay:c,weekdays:l,timeFmt:d,now:f,onEventClick:a}):(0,z.jsx)(tn,{year:n.year,byDay:c,monthShortFmt:ee,now:f,onOpenMonth:e=>{i({year:n.year,month:e}),r(`month`)}}),o?(0,z.jsx)(`p`,{className:`oc-cal__footnote`,children:o}):null]})}function en({cursor:e,byDay:t,weekdays:n,timeFmt:r,now:i,onEventClick:a}){let o=L(e.year,e.month);return(0,z.jsxs)(`div`,{className:`oc-cal__month`,children:[n.map((e,t)=>(0,z.jsx)(`span`,{className:`oc-cal__wd`,children:e},t)),o.map((e,n)=>{let o=t.get(Jt(e.year,e.month,e.day))??[],s=i.getFullYear()===e.year&&i.getMonth()===e.month&&i.getDate()===e.day;return(0,z.jsxs)(`div`,{className:`oc-cal__day`+(e.inMonth?``:` oc-cal__day--out`)+(s?` oc-cal__day--today`:``),children:[(0,z.jsx)(`span`,{className:`oc-cal__daynum`,children:e.day}),o.slice(0,U).map(e=>(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__event`+(e.muted?` oc-cal__event--muted`:``)+(e.exact?` oc-cal__event--exact`:``),style:e.color?{"--cal-ev":e.color}:void 0,title:`${r.format(e.atMs)} ${e.title}`,onClick:a?()=>a(e):void 0,children:[(0,z.jsx)(`span`,{className:`oc-cal__evdot`,"aria-hidden":!0}),(0,z.jsx)(`span`,{className:`oc-cal__evtime`,children:r.format(e.atMs)}),(0,z.jsx)(`span`,{className:`oc-cal__evtitle`,children:e.title})]},e.id)),o.length>U?(0,z.jsx)(`span`,{className:`oc-cal__more`,children:ae({count:o.length-U})}):null]},n)})]})}function tn({year:e,byDay:t,monthShortFmt:n,now:r,onOpenMonth:i}){return(0,z.jsx)(`div`,{className:`oc-cal__year`,children:Array.from({length:12},(a,o)=>{let s=H(t,e,o),c=L(e,o);return(0,z.jsxs)(`button`,{type:`button`,className:`oc-cal__mini`,onClick:()=>i(o),children:[(0,z.jsx)(`span`,{className:`oc-cal__mininame`,children:n.format(new Date(e,o,1))}),(0,z.jsx)(`span`,{className:`oc-cal__minigrid`,"aria-hidden":!0,children:c.map((e,t)=>{let n=e.inMonth?s.get(e.day)??0:0,i=e.inMonth&&r.getFullYear()===e.year&&r.getMonth()===e.month&&r.getDate()===e.day;return(0,z.jsx)(`span`,{className:`oc-cal__minidot`+(e.inMonth?``:` is-out`)+(n===1?` has-one`:``)+(n>1?` has-many`:``)+(i?` is-today`:``)},t)})})]},o)})})}var W={h:36e5,min:6e4,s:1e3,ms:1};function nn(e){if(e===null)return null;let t=e.trim(),n=/^every\s+(\d+(?:\.\d+)?)(h|min|s|ms)$/.exec(t);if(n!==null){let e=Number(n[1])*W[n[2]];return Number.isFinite(e)&&e>0?{kind:`every`,everyMs:e}:null}let r=/^(?:cron\s+)?([\d*,/-]+(?:\s+[\d*,/-]+){4})(?:\s*\(([^)]+)\))?$/.exec(t);if(r!==null)return{kind:`cron`,expr:r[1],tz:r[2]??null};let i=Date.parse(t);return Number.isFinite(i)?{kind:`at`,atMs:i}:null}function G(e,t,n){let r=new Set;for(let i of e.split(`,`)){let e=i,a=1,o=/^(.+)\/(\d{1,3})$/.exec(i);if(o!==null&&(e=o[1],a=Number(o[2]),a<1))return null;let s,c;if(e===`*`)s=t,c=n;else{let r=/^(\d{1,3})(?:-(\d{1,3}))?$/.exec(e);if(r===null||(s=Number(r[1]),c=r[2]===void 0?s:Number(r[2]),r[2]===void 0&&o!==null&&(c=n),s<t||c>n||s>c))return null}for(let e=s;e<=c;e+=a)r.add(e)}return r.size>0?[...r].sort((e,t)=>e-t):null}function K(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=G(t[0],0,59),r=G(t[1],0,23),i=G(t[2],1,31),a=G(t[3],1,12),o=G(t[4],0,7);if(!n||!r||!i||!a||!o)return null;let s=new Set(o.map(e=>e%7));return{minutes:n,hours:r,dom:new Set(i),months:new Set(a),dow:s,domRestricted:t[2]!==`*`,dowRestricted:t[4]!==`*`}}var q=new Map;function J(e){let t=q.get(e);if(t!==void 0)return t;let n=null;try{n=new Intl.DateTimeFormat(`en-US`,{timeZone:e,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}catch{n=null}return q.set(e,n),n}function Y(e,t){if(t!==null){let n=J(t);if(n!==null){let t={};for(let r of n.formatToParts(e))r.type!==`literal`&&(t[r.type]=Number(r.value));return{y:t.year,mo:t.month-1,d:t.day,h:t.hour===24?0:t.hour,mi:t.minute}}}let n=new Date(e);return{y:n.getFullYear(),mo:n.getMonth(),d:n.getDate(),h:n.getHours(),mi:n.getMinutes()}}function X(e,t,n,r,i,a){if(a===null||J(a)===null)return new Date(e,t,n,r,i).getTime();let o=Date.UTC(e,t,n,r,i),s=e=>{let t=Y(e,a);return Date.UTC(t.y,t.mo,t.d,t.h,t.mi)-e},c=s(o),l=o-c,u=s(l);return u!==c&&(l=o-u),l}function Z(e,t,n,r){let i=new Map,a=(e,t)=>{e<n||e>=r||i.set(e,t||(i.get(e)??!1))};if(e?.kind===`at`)a(e.atMs,!0);else if(e?.kind===`every`){if(t!==null){let i=e.everyMs,o=Math.ceil((n-t)/i);for(let e=t+o*i,n=0;e<r&&n<400;e+=i,n++)a(e,e===t)}}else if(e?.kind===`cron`){let t=K(e.expr);if(t!==null&&t.hours.length*t.minutes.length<=400){let i=0,o=n-864e5;for(;o<r+864e5&&i<400;){let s=Y(o,e.tz);if(t.months.has(s.mo+1)){let o=new Date(Date.UTC(s.y,s.mo,s.d)).getUTCDay(),c=t.dom.has(s.d),l=t.dow.has(o);if(t.domRestricted&&t.dowRestricted?c||l:c&&l)for(let o of t.hours)for(let c of t.minutes){if(i>=400)break;let t=X(s.y,s.mo,s.d,o,c,e.tz);t>=n&&t<r&&(a(t,!1),i++)}}o=X(s.y,s.mo,s.d,12,0,e.tz)+864e5}}}return t!==null&&a(t,!0),[...i.entries()].map(([e,t])=>({atMs:e,exact:t})).sort((e,t)=>e.atMs-t.atMs).slice(0,400)}var Q=`crons`;function rn(e,t){return`${e}${t}`}function an(e,t,n){let r=[],i=new Map;for(let a of e){let{job:e}=a;if(e.id===null)continue;let o=rn(a.instanceName,e.id);i.set(o,a);let s=Z(e.enabled===!1?null:nn(e.schedule),e.nextRunAtMs,t,n);for(let t of s)r.push({id:`${o}:${t.atMs}`,sourceId:Q,itemId:o,atMs:t.atMs,title:e.name??e.id,muted:e.enabled===!1,exact:t.exact})}return{events:r,byItemId:i}}var $={minutes:6e4,hours:36e5,days:864e5};function on(e){return e?.data?.code??`unknown`}function sn({status:e}){switch(I(e)){case`ok`:return(0,z.jsx)(k,{variant:`secondary`,children:Qe()});case`error`:return(0,z.jsx)(k,{variant:`destructive`,children:ye()});case`running`:return(0,z.jsx)(k,{variant:`outline`,children:je()});case`other`:return(0,z.jsx)(k,{variant:`outline`,children:e});case`none`:return(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}}function cn(){let e=m(x.scheduled.listMyCrons),t=m(x.scheduled.getCronDetail),n=m(x.scheduled.listCronRuns),l=m(x.scheduled.updateCron),ie=m(x.scheduled.removeCron),ae=m(x.scheduled.runCronNow),g=ct(),ve=at(x.me.getMe,{host:Mt})?.timezone,[_,be]=(0,R.useState)(null),[Ne,Ve]=(0,R.useState)(!1),[y,Ke]=(0,R.useState)(!1),[b,Ye]=(0,R.useState)(null),[C,w]=(0,R.useState)(null),[T,O]=(0,R.useState)(null),[N,I]=(0,R.useState)(null),[Rt,Bt]=(0,R.useState)(!1),[L,B]=(0,R.useState)(Vt),[V,Jt]=(0,R.useState)(()=>new URLSearchParams(window.location.search).get(`job`)===null&&localStorage.getItem(`oc.sched.view`)===`calendar`?`calendar`:`list`),Yt=e=>{localStorage.setItem(`oc.sched.view`,e),Jt(e)},[H,Xt]=(0,R.useState)(`month`),[U,en]=(0,R.useState)(()=>{let e=new Date;return{year:e.getFullYear(),month:e.getMonth()}}),tn=(0,R.useMemo)(()=>{let e=[];for(let t of _??[]){if(!t.supported||t.error!==null)continue;let n=t.kind===`openclaw`&&t.manageSupported;for(let r of t.jobs)zt(r,L)&&e.push({instanceName:t.instanceName,canEdit:n,job:r})}return e},[_,L]),W=(0,R.useMemo)(()=>H===`year`?Qt(U.year):Zt(U.year,U.month),[H,U]),nn=(0,R.useMemo)(()=>an(tn,W.startMs,W.endMs),[tn,W]),G=e=>{let t=nn.byItemId.get(e.itemId);t===void 0||!t.canEdit||t.job.id===null||cn(t.instanceName,t.job)},K=(0,R.useCallback)(async()=>{Ve(!0),Ke(!1);try{be(await e({}))}catch{Ke(!0)}finally{Ve(!1)}},[e]);(0,R.useEffect)(()=>{K()},[K]);let q=(0,R.useMemo)(()=>new URLSearchParams(window.location.search).get(`job`),[]),J=(0,R.useRef)(null);(0,R.useEffect)(()=>{_!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[_]);let Y=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{Ye(e);try{await t(),g.success(n),await K()}catch(e){g.toast({variant:`error`,title:v({code:on(e)})})}finally{Ye(null)}},Z=(0,R.useRef)(0),Q=(0,R.useRef)(0),rn=async(e,t)=>{if(t.id===null)return;let r=++Z.current;O({name:t.name??t.id,entries:null});try{let i=await n({instanceName:e,jobId:t.id,limit:20});if(r!==Z.current)return;O({name:t.name??t.id,entries:i})}catch(e){if(r!==Z.current)return;O(null),g.toast({variant:`error`,title:v({code:on(e)})})}},cn=async(e,n)=>{if(n.id===null)return;let r=++Q.current;I({instanceName:e,jobId:n.id,loading:!0,name:n.name??``,scheduleKind:`cron`,cronExpr:``,tz:``,everyValue:`1`,everyUnit:`hours`,at:``,message:``,hasMessage:!1,scheduleDirty:!1,messageDirty:!1,nameDirty:!1});try{let i=(await t({instanceName:e,jobId:n.id})).job,a=i.scheduleKind===`every`||i.scheduleKind===`at`?i.scheduleKind:`cron`,o=``;if(a===`at`&&i.scheduleExpr!==null){let e=Date.parse(i.scheduleExpr);Number.isFinite(e)&&(o=new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16))}let s=`1`,c=`hours`;if(a===`every`&&i.scheduleExpr!==null){let e=Number(i.scheduleExpr);Number.isFinite(e)&&e>0&&(e%$.days===0?(s=String(e/$.days),c=`days`):e%$.hours===0?(s=String(e/$.hours),c=`hours`):(s=String(Math.max(1,Math.round(e/$.minutes))),c=`minutes`))}if(r!==Q.current)return;I(e=>e===null||e.jobId!==n.id?e:{...e,loading:!1,name:i.name??e.name,scheduleKind:a,cronExpr:a===`cron`?i.scheduleExpr??``:``,tz:i.tz??``,everyValue:s,everyUnit:c,at:o,message:i.message??``,hasMessage:i.message!==null&&!i.messageTruncated})}catch(e){if(r!==Q.current)return;I(null),g.toast({variant:`error`,title:v({code:on(e)})})}},ln=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){g.toast({variant:`error`,title:$e()});return}if(N.nameDirty&&N.name.trim()!==``&&(e.name=N.name.trim()),N.scheduleDirty){if(N.scheduleKind===`cron`&&N.cronExpr.trim()!==``)e.schedule={kind:`cron`,expr:N.cronExpr.trim(),...N.tz.trim()===``?{}:{tz:N.tz.trim()}};else if(N.scheduleKind===`every`){let t=Number(N.everyValue);Number.isFinite(t)&&t>=1&&(e.schedule={kind:`every`,everyMs:Math.round(t*$[N.everyUnit])})}else if(N.scheduleKind===`at`&&N.at!==``){let t=Date.parse(N.at);Number.isFinite(t)&&(e.schedule={kind:`at`,at:new Date(t).toISOString()})}}if(N.scheduleDirty&&e.schedule===void 0){g.toast({variant:`error`,title:it()});return}if(N.messageDirty&&N.hasMessage&&N.message.trim()!==``&&(e.message=N.message.trim()),Object.keys(e).length===0){I(null);return}let t=Q.current;Bt(!0);try{await l({instanceName:N.instanceName,jobId:N.jobId,patch:e}),g.success(se()),t===Q.current&&I(null),await K()}catch(e){g.toast({variant:`error`,title:v({code:on(e)})})}finally{Bt(!1)}},un=_?.reduce((e,t)=>e+t.jobs.length,0)??0;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:8,marginBottom:12},children:[(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{flex:1,margin:0},children:Be()}),(0,z.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Ee(),children:[(0,z.jsx)(S,{variant:V===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":r(),title:r(),"aria-pressed":V===`list`,onClick:()=>Yt(`list`),children:(0,z.jsx)(ot,{})}),(0,z.jsx)(S,{variant:V===`calendar`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":me(),title:me(),"aria-pressed":V===`calendar`,onClick:()=>Yt(`calendar`),children:(0,z.jsx)(Gt,{})})]}),(0,z.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:Ne,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,z.jsx)(pt,{size:14,"aria-hidden":!0}),Ge()]})]}),_!==null&&un>0?(0,z.jsxs)(Lt,{q:L.q,onQChange:e=>B(t=>({...t,q:e})),searchPlaceholder:ze(),onReset:()=>B(Vt),canReset:Ut(L),children:[(0,z.jsxs)(E,{value:L.state,onValueChange:e=>B(t=>({...t,state:e})),children:[(0,z.jsx)(D,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`all`,children:We()}),(0,z.jsx)(M,{value:`active`,children:De()}),(0,z.jsx)(M,{value:`paused`,children:Xe()})]})]}),(0,z.jsxs)(E,{value:L.result,onValueChange:e=>B(t=>({...t,result:e})),children:[(0,z.jsx)(D,{size:`sm`,className:`w-40`,children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`all`,children:Oe()}),(0,z.jsx)(M,{value:`ok`,children:Qe()}),(0,z.jsx)(M,{value:`error`,children:ye()}),(0,z.jsx)(M,{value:`running`,children:je()}),(0,z.jsx)(M,{value:`none`,children:Me()})]})]})]}):null,_===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":Ne,children:y?ke():a()}):V===`calendar`?(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ke()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Te()}):(0,z.jsx)($t,{events:nn.events,mode:H,cursor:U,onModeChange:Xt,onCursorChange:en,onEventClick:G,footnote:ne()})]}):(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ke()}):null,_.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Te()}):null,_.map(e=>{let t=e.jobs.filter(e=>zt(e,L)),n=Ut(L)&&e.jobs.length>0&&t.length===0;return(0,z.jsxs)(`section`,{style:{marginBottom:20},children:[_.length>1||e.error||!e.supported?(0,z.jsxs)(`h3`,{style:{display:`flex`,alignItems:`center`,gap:8,fontSize:`0.85rem`,fontWeight:600,margin:`0 0 6px`},children:[e.instanceName,(0,z.jsx)(k,{variant:`outline`,children:e.kind})]}):null,e.supported?e.error?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Re({code:e.error})}):e.jobs.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ce()}):n?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:we()}):(0,z.jsxs)(It,{children:[(0,z.jsx)(Nt,{children:(0,z.jsxs)(Ft,{children:[(0,z.jsx)(P,{children:Je()}),(0,z.jsx)(P,{children:Ue()}),(0,z.jsx)(P,{children:xe()}),(0,z.jsx)(P,{children:Pe()}),(0,z.jsx)(P,{children:qe()}),(0,z.jsx)(P,{children:rt()}),(0,z.jsx)(P,{children:te()})]})}),(0,z.jsx)(Pt,{children:t.map((t,n)=>{let r=`${e.instanceName}:${t.id??n}`,a=b===r,o=e.manageSupported,s=e.kind===`openclaw`&&o;return(0,z.jsxs)(Ft,{ref:t.id!==null&&t.id===q?J:void 0,"data-state":t.id!==null&&t.id===q?`selected`:void 0,children:[(0,z.jsx)(F,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:t.name??void 0,children:t.name??He()}),(0,z.jsx)(F,{children:(0,z.jsx)(k,{variant:`secondary`,children:t.agentId})}),(0,z.jsxs)(F,{className:`whitespace-nowrap`,children:[(0,z.jsx)(`span`,{style:{fontFamily:`var(--font-mono, monospace)`},children:t.schedule??`—`}),(()=>{let e=ut(t.schedule),n=e===null?null:lt(e);return n===null?null:(0,z.jsx)(`span`,{className:`text-muted-foreground`,style:{display:`block`,fontSize:`0.78rem`},children:n})})()]}),(0,z.jsx)(F,{className:`whitespace-nowrap text-muted-foreground`,children:t.nextRunAtMs===null?`—`:Y.format(t.nextRunAtMs)}),(0,z.jsx)(F,{children:Ht(t.enabled)===`active`?(0,z.jsx)(k,{variant:`secondary`,children:De()}):Ht(t.enabled)===`paused`?(0,z.jsx)(k,{variant:`outline`,children:Xe()}):(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,z.jsx)(F,{children:(0,z.jsx)(sn,{status:t.lastRunStatus})}),(0,z.jsx)(F,{className:`whitespace-nowrap`,children:t.id===null?(0,z.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a?(0,z.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,z.jsxs)(`span`,{className:`oc-cronactions`,children:[s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:re(),"aria-label":re(),disabled:b!==null,onClick:()=>void X(r,async()=>{let n=await ae({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},i()),children:(0,z.jsx)(kt,{size:14,"aria-hidden":!0})}):null,s&&t.enabled!==null?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:t.enabled?p():fe(),"aria-label":t.enabled?p():fe(),disabled:b!==null,onClick:()=>void X(r,()=>l({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?Ie():ue()),children:t.enabled?(0,z.jsx)(St,{size:14,"aria-hidden":!0}):(0,z.jsx)(jt,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:pe(),"aria-label":pe(),disabled:b!==null,onClick:()=>void cn(e.instanceName,t),children:(0,z.jsx)(Et,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:le(),"aria-label":le(),disabled:b!==null,onClick:()=>void rn(e.instanceName,t),children:(0,z.jsx)(Kt,{size:14,"aria-hidden":!0})}):null,o?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:ce(),"aria-label":ce(),disabled:b!==null,onClick:()=>w({instanceName:e.instanceName,jobId:t.id,name:t.name??t.id}),children:(0,z.jsx)(yt,{size:14,"aria-hidden":!0})}):null]})})]},t.id??`${e.instanceName}-${n}`)})})]}):(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ze()})]},e.instanceName)}),un>0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ae()}):null]}),(0,z.jsx)(st,{open:C!==null,onOpenChange:e=>{e||w(null)},children:(0,z.jsxs)(wt,{children:[(0,z.jsxs)(dt,{children:[(0,z.jsx)(Tt,{children:d()}),(0,z.jsx)(Ot,{children:ge({name:C?.name??``})})]}),(0,z.jsxs)(bt,{children:[(0,z.jsx)(At,{children:et()}),(0,z.jsx)(ht,{onClick:()=>{let e=C;w(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>ie({instanceName:e.instanceName,jobId:e.jobId}),u())},children:s()})]})]})}),(0,z.jsx)(mt,{open:T!==null,onOpenChange:e=>{e||(Z.current++,O(null))},children:(0,z.jsxs)(gt,{style:{maxWidth:640},children:[(0,z.jsx)(vt,{children:(0,z.jsx)(_t,{children:Fe({name:T?.name??``})})}),T?.entries===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):T!==null&&T.entries.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:o()}):T===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__runs`,style:{maxHeight:420,overflowY:`auto`},children:T.entries.map((e,t)=>(0,z.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,z.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[(0,z.jsx)(sn,{status:e.status}),(0,z.jsx)(`span`,{children:typeof(e.runAtMs??e.ts)==`number`?Y.format(e.runAtMs??e.ts):`—`}),typeof e.durationMs==`number`?(0,z.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,z.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error})]},t))})]})}),(0,z.jsx)(mt,{open:N!==null,onOpenChange:e=>{e||(Q.current++,I(null))},children:(0,z.jsxs)(gt,{className:`oc-cronedit`,children:[(0,z.jsxs)(vt,{children:[(0,z.jsx)(_t,{children:Le()}),(0,z.jsx)(Dt,{children:de()})]}),N===null?null:N.loading?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:a()}):(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:12},children:[(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:Je()}),(0,z.jsx)(xt,{value:N.name,maxLength:200,onChange:e=>I({...N,name:e.target.value,nameDirty:!0})})]}),(0,z.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:ee()}),(0,z.jsxs)(E,{value:N.scheduleKind,onValueChange:e=>I({...N,scheduleKind:e,scheduleDirty:!0}),children:[(0,z.jsx)(D,{children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`cron`,children:f()}),(0,z.jsx)(M,{value:`every`,children:_e()}),(0,z.jsx)(M,{value:`at`,children:tt()})]})]}),N.scheduleKind===`cron`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(xt,{value:N.cronExpr,onChange:e=>I({...N,cronExpr:e.target.value,scheduleDirty:!0}),placeholder:`30 9 * * *`,style:{fontFamily:`var(--font-mono, monospace)`}}),(0,z.jsx)(Wt,{value:N.tz,onChange:e=>I({...N,tz:e,scheduleDirty:!0}),fallbackTz:ve??void 0})]}):N.scheduleKind===`every`?(0,z.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,z.jsx)(xt,{type:`number`,min:1,value:N.everyValue,onChange:e=>I({...N,everyValue:e.target.value,scheduleDirty:!0}),style:{maxWidth:120}}),(0,z.jsxs)(E,{value:N.everyUnit,onValueChange:e=>I({...N,everyUnit:e,scheduleDirty:!0}),children:[(0,z.jsx)(D,{style:{maxWidth:160},children:(0,z.jsx)(j,{})}),(0,z.jsxs)(A,{children:[(0,z.jsx)(M,{value:`minutes`,children:c()}),(0,z.jsx)(M,{value:`hours`,children:he()}),(0,z.jsx)(M,{value:`days`,children:nt()})]})]})]}):(0,z.jsx)(qt,{value:N.at,onChange:e=>I({...N,at:e,scheduleDirty:!0})})]}),N.hasMessage?(0,z.jsxs)(`label`,{style:{display:`flex`,flexDirection:`column`,gap:4},children:[(0,z.jsx)(`span`,{className:`oc-admin__hint`,style:{margin:0},children:oe()}),(0,z.jsx)(`textarea`,{className:`oc-cronedit__textarea`,rows:4,value:N.message,onChange:e=>I({...N,message:e.target.value,messageDirty:!0})})]}):null]}),(0,z.jsxs)(Ct,{children:[(0,z.jsx)(S,{variant:`ghost`,onClick:()=>I(null),children:et()}),(0,z.jsxs)(S,{onClick:()=>void ln(),disabled:N===null||N.loading||Rt,children:[Rt?(0,z.jsx)(ft,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):null,Se()]})]})]})})]})}export{cn as ScheduledTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$A as r,$j as i,Aj as ee,BA as a,Bj as te,Cj as ne,Dj as re,Ej as ie,FA as o,Fj as ae,GA as s,Gj as oe,HA as c,Hj as se,IA as l,IL as ce,Ij as le,JA as u,Jj as d,KA as f,Kj as ue,LA as p,Lj as de,Mj as fe,NA as m,Nj as pe,Oj as me,PA as he,Pj as ge,QA as _e,Qj as ve,RA as ye,RL as h,Rj as be,Sj as xe,Tj as Se,UA as g,Uj as Ce,VA as _,Vj as we,WA as v,Wj as Te,XA as y,Xj as Ee,YA as b,Yj as De,ZA as x,Zj as Oe,_j as ke,aj as Ae,bj as je,cj as Me,dj as Ne,ej as S,fj as Pe,gj as Fe,hj as Ie,ij as Le,jj as Re,kj as ze,lj as Be,mj as Ve,nj as C,oj as He,pj as Ue,qA as w,qj as T,rj as We,sj as Ge,t as E,tj as D,uj as Ke,vj as qe,wj as Je,xj as Ye,yj as Xe,zA as O,zL as k,zj as Ze}from"./api-EsnGI4EC.js";import{t as A}from"./check-LaI7fqW2.js";import{r as Qe}from"./dist-BM94bqpE.js";import{t as j}from"./button-CZ9WPf0m.js";import{Dt as $e,Fn as et,On as M,Pn as tt,Z as nt,_ as rt,_t as N,bt as P,ct as F,dt as I,ft as L,gt as R,ht as z,jn as it,jt as B,mt as at,pt as ot,st as V,ut as H,vt as U,xt as W,yt as G}from"./index-CsdodIca.js";import{t as st}from"./FilterBar-Bxpfu6Cp.js";import{t as ct}from"./DataTableShell-BYhMdaSl.js";import{t as lt}from"./roleDescriptions-DEIReM8x.js";var K=t(e(),1),q=n(),J=[{value:`never`,label:()=>O(),days:null},{value:`30`,label:()=>ye(),days:30},{value:`90`,label:()=>p(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=et({from:`/settings/serviceAccounts`}),t=tt({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??X,[a,o]=(0,K.useState)(X),s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),c=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),l=k(E.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:r===X?void 0:r===`disabled`}}),u=k(E.apiKeys.listKeys,{}),f=k(E.apiKeys.listRoles,{}),p=h(E.apiKeys.createServiceAccount),m=h(E.apiKeys.updateServiceAccount),he=h(E.apiKeys.deleteServiceAccount),_e=ce(E.apiKeys.mintApiKey),ye=h(E.apiKeys.revokeApiKey),g=nt(),_=$e(),v=n!==``||a!==X||r!==X;function y(){o(X),t({search:{},replace:!0})}let[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(Z),[w,D]=(0,K.useState)(null),[O,A]=(0,K.useState)(new Set),[M,F]=(0,K.useState)(null),I=(0,K.useRef)(!1),[L,R]=(0,K.useState)(new Set),[z,at]=(0,K.useState)({}),[ot,V]=(0,K.useState)(null),Y=(0,K.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[u]);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{w?(await m({serviceAccountId:w,name:S.name,roleKey:S.roleKey,description:S.description}),_.success(ke())):await p({name:S.name,roleKey:S.roleKey,description:S.description||void 0}),C(Z),D(null),x(!1)}catch(e){_.error(w?qe():Xe(),e)}}function pt(e){C({name:e.name,roleKey:e.roleKey,description:e.description??``}),D(e._id),x(!0)}async function mt(e){if(I.current)return;I.current=!0;let t=z[e._id]??`never`,n=J.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;F(e._id);try{let t=await _e({serviceAccountId:e._id,expiresAt:r});V({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(Fe(),e)}finally{I.current=!1,F(null)}}async function $(e){if(await g({title:Ie(),description:(0,q.jsxs)(q.Fragment,{children:[Ve(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Ue(),` `,(0,q.jsx)(`strong`,{children:Pe()}),` `,Ne()]}),confirmWord:e.name,confirmLabel:Ke(),destructive:!0}))try{await he({serviceAccountId:e._id}),_.success(Be(),e.name)}catch(e){_.error(Me(),e)}}async function ht(e){if(await g({title:Ge(),description:(0,q.jsxs)(q.Fragment,{children:[He(),` `,(0,q.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ae()]}),confirmLabel:Le(),destructive:!0})&&!L.has(e._id)){R(t=>new Set(t).add(e._id));try{await ye({keyId:e._id})}catch(e){_.error(We(),e)}finally{R(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}),(0,q.jsxs)(st,{q:n,onQChange:s,searchPlaceholder:ve(),onReset:y,canReset:v,children:[(0,q.jsxs)(N,{value:a,onValueChange:o,children:[(0,q.jsx)(P,{size:`sm`,className:`w-40`,children:(0,q.jsx)(W,{placeholder:Oe()})}),(0,q.jsxs)(U,{children:[(0,q.jsx)(G,{value:X,children:Ee()}),(f??[]).map(e=>(0,q.jsx)(G,{value:e.key,children:e.key},e._id))]})]}),(0,q.jsxs)(N,{value:r,onValueChange:c,children:[(0,q.jsx)(P,{size:`sm`,className:`w-36`,children:(0,q.jsx)(W,{})}),(0,q.jsxs)(U,{children:[(0,q.jsx)(G,{value:X,children:De()}),(0,q.jsx)(G,{value:`active`,children:d()}),(0,q.jsx)(G,{value:`disabled`,children:T()})]})]})]}),(0,q.jsx)(ct,{title:ue(),rows:l,addLabel:oe(),onAdd:()=>{C(Z),D(null),x(!0)},emptyHint:Te(),isExpanded:e=>O.has(e._id),renderExpanded:e=>(0,q.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:L}),rowActions:e=>[{label:te(),onSelect:()=>pt(e)},{label:Ce(),onSelect:()=>void mt(e)},{label:O.has(e._id)?se():we(),onSelect:()=>Q(e._id)},{label:Ze(),variant:`destructive`,onSelect:()=>void $(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,q.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":O.has(e._id)?be():de(),onClick:()=>Q(e._id),children:O.has(e._id)?(0,q.jsx)(Qe,{}):(0,q.jsx)(it,{})})},{header:le(),sort:e=>e.name,cell:e=>(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`span`,{children:e.name}),e.description?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:ae(),sort:e=>e.roleKey,cell:e=>(0,q.jsx)(H,{variant:`secondary`,children:e.roleKey})},{header:ge(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,q.jsx)(H,{variant:`destructive`,children:T()}):(0,q.jsx)(H,{variant:`outline`,children:d()})},{header:pe(),cell:e=>(0,q.jsxs)(N,{value:z[e._id]??`never`,onValueChange:t=>at(n=>({...n,[e._id]:t})),children:[(0,q.jsx)(P,{size:`sm`,className:`w-32`,children:(0,q.jsx)(W,{})}),(0,q.jsx)(U,{children:J.map(e=>(0,q.jsx)(G,{value:e.value,children:e.label()},e.value))})]})},{header:fe(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,q.jsx)(`span`,{className:`oc-sa__keycount`,children:M===e._id?Re():ee({count:t})})}}]}),(0,q.jsx)(rt,{open:b,onOpenChange:e=>{x(e),e||D(null)},title:w?ze():ie(),description:w?me():Se(),canSubmit:!!(S.name&&S.roleKey),onSubmit:ft,submitLabel:w?re():Je(),children:(0,q.jsxs)(`div`,{className:`oc-form`,children:[(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:ne()}),(0,q.jsx)(B,{value:S.name,onChange:e=>C({...S,name:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:xe()}),(0,q.jsxs)(N,{value:S.roleKey||void 0,onValueChange:e=>C({...S,roleKey:e}),children:[(0,q.jsx)(P,{className:`w-full`,children:(0,q.jsx)(W,{placeholder:Ye()})}),(0,q.jsx)(U,{children:(f??[]).map(e=>(0,q.jsxs)(G,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(f??[]).find(e=>e.key===S.roleKey),t=e?lt(e):null;return t?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:je()}),(0,q.jsx)(B,{value:S.description,onChange:e=>C({...S,description:e.target.value})})]})]})}),(0,q.jsx)(dt,{minted:ot,onClose:()=>V(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:i}){return(0,q.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,q.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[C(),` `,(0,q.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:D()}):(0,q.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:S()}),(0,q.jsx)(`th`,{children:r()}),(0,q.jsx)(`th`,{children:_e()}),(0,q.jsx)(`th`,{children:x()}),(0,q.jsx)(`th`,{children:y()}),(0,q.jsx)(`th`,{children:b()}),(0,q.jsx)(`th`,{})]})}),(0,q.jsx)(`tbody`,{children:t.map(t=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,q.jsx)(`td`,{children:(0,q.jsx)(H,{variant:`secondary`,children:e.roleKey})}),(0,q.jsx)(`td`,{children:F(t.createdAt)}),(0,q.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,q.jsx)(`td`,{children:mt(t.expiresAt)}),(0,q.jsx)(`td`,{children:$(t)}),(0,q.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,q.jsx)(j,{variant:`destructive`,size:`sm`,disabled:i.has(t._id),onClick:()=>n(t),children:i.has(t._id)?u():w()})})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,K.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,q.jsx)(I,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,q.jsxs)(L,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:f()}),(0,q.jsx)(ot,{children:s({name:e.accountName})})]}),(0,q.jsx)(`div`,{className:`oc-sa__minted-warning`,children:v()}),(0,q.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,q.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,q.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":g(),children:[n?(0,q.jsx)(A,{}):(0,q.jsx)(M,{}),n?c():_()]})]}),(0,q.jsx)(at,{children:(0,q.jsx)(j,{onClick:()=>{r(!1),t()},children:a()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?l():F(e)}function mt(e){return e===null?`—`:V(e)}function $(e){return e.disabled?(0,q.jsx)(H,{variant:`destructive`,children:o()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,q.jsx)(H,{variant:`outline`,children:he()}):(0,q.jsx)(H,{variant:`outline`,children:m()})}export{Q as ServiceAccountsTab};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$A as r,$j as i,Aj as ee,BA as a,Bj as te,Cj as ne,Dj as re,Ej as ie,FA as o,Fj as ae,GA as s,Gj as oe,HA as c,Hj as se,IA as l,IL as ce,Ij as le,JA as u,Jj as d,KA as f,Kj as ue,LA as p,Lj as de,Mj as fe,NA as m,Nj as pe,Oj as me,PA as he,Pj as ge,QA as _e,Qj as ve,RA as ye,RL as h,Rj as be,Sj as xe,Tj as Se,UA as g,Uj as Ce,VA as _,Vj as we,WA as v,Wj as Te,XA as y,Xj as Ee,YA as b,Yj as De,ZA as x,Zj as Oe,_j as ke,aj as Ae,bj as je,cj as Me,dj as Ne,ej as S,fj as Pe,gj as Fe,hj as Ie,ij as Le,jj as Re,kj as ze,lj as Be,mj as Ve,nj as C,oj as He,pj as Ue,qA as w,qj as T,rj as We,sj as Ge,t as E,tj as D,uj as Ke,vj as qe,wj as Je,xj as Ye,yj as Xe,zA as O,zL as k,zj as Ze}from"./api-EsnGI4EC.js";import{t as A}from"./check-LaI7fqW2.js";import{r as Qe}from"./dist-BM94bqpE.js";import{t as j}from"./button-CZ9WPf0m.js";import{Dt as $e,Fn as et,On as M,Pn as tt,Z as nt,_ as rt,_t as N,bt as P,ct as F,dt as I,ft as L,gt as R,ht as z,jn as it,jt as B,mt as at,pt as ot,st as V,ut as H,vt as U,xt as W,yt as G}from"./index-DdOFgMFG.js";import{t as st}from"./FilterBar-3xmqkmtO.js";import{t as ct}from"./DataTableShell-D5Nb8D27.js";import{t as lt}from"./roleDescriptions-DEIReM8x.js";var K=t(e(),1),q=n(),J=[{value:`never`,label:()=>O(),days:null},{value:`30`,label:()=>ye(),days:30},{value:`90`,label:()=>p(),days:90}],Y=720*60*60*1e3,X=`__all__`,Z={name:``,roleKey:``,description:``};function Q(){let e=et({from:`/settings/serviceAccounts`}),t=tt({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??X,[a,o]=(0,K.useState)(X),s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),c=e=>void t({search:t=>({...t,status:e===X?void 0:e})}),l=k(E.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===X?void 0:a,disabled:r===X?void 0:r===`disabled`}}),u=k(E.apiKeys.listKeys,{}),f=k(E.apiKeys.listRoles,{}),p=h(E.apiKeys.createServiceAccount),m=h(E.apiKeys.updateServiceAccount),he=h(E.apiKeys.deleteServiceAccount),_e=ce(E.apiKeys.mintApiKey),ye=h(E.apiKeys.revokeApiKey),g=nt(),_=$e(),v=n!==``||a!==X||r!==X;function y(){o(X),t({search:{},replace:!0})}let[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(Z),[w,D]=(0,K.useState)(null),[O,A]=(0,K.useState)(new Set),[M,F]=(0,K.useState)(null),I=(0,K.useRef)(!1),[L,R]=(0,K.useState)(new Set),[z,at]=(0,K.useState)({}),[ot,V]=(0,K.useState)(null),Y=(0,K.useMemo)(()=>{let e=new Map;for(let t of u??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[u]);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{w?(await m({serviceAccountId:w,name:S.name,roleKey:S.roleKey,description:S.description}),_.success(ke())):await p({name:S.name,roleKey:S.roleKey,description:S.description||void 0}),C(Z),D(null),x(!1)}catch(e){_.error(w?qe():Xe(),e)}}function pt(e){C({name:e.name,roleKey:e.roleKey,description:e.description??``}),D(e._id),x(!0)}async function mt(e){if(I.current)return;I.current=!0;let t=z[e._id]??`never`,n=J.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;F(e._id);try{let t=await _e({serviceAccountId:e._id,expiresAt:r});V({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(Fe(),e)}finally{I.current=!1,F(null)}}async function $(e){if(await g({title:Ie(),description:(0,q.jsxs)(q.Fragment,{children:[Ve(),` `,(0,q.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Ue(),` `,(0,q.jsx)(`strong`,{children:Pe()}),` `,Ne()]}),confirmWord:e.name,confirmLabel:Ke(),destructive:!0}))try{await he({serviceAccountId:e._id}),_.success(Be(),e.name)}catch(e){_.error(Me(),e)}}async function ht(e){if(await g({title:Ge(),description:(0,q.jsxs)(q.Fragment,{children:[He(),` `,(0,q.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Ae()]}),confirmLabel:Le(),destructive:!0})&&!L.has(e._id)){R(t=>new Set(t).add(e._id));try{await ye({keyId:e._id})}catch(e){_.error(We(),e)}finally{R(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:i()}),(0,q.jsxs)(st,{q:n,onQChange:s,searchPlaceholder:ve(),onReset:y,canReset:v,children:[(0,q.jsxs)(N,{value:a,onValueChange:o,children:[(0,q.jsx)(P,{size:`sm`,className:`w-40`,children:(0,q.jsx)(W,{placeholder:Oe()})}),(0,q.jsxs)(U,{children:[(0,q.jsx)(G,{value:X,children:Ee()}),(f??[]).map(e=>(0,q.jsx)(G,{value:e.key,children:e.key},e._id))]})]}),(0,q.jsxs)(N,{value:r,onValueChange:c,children:[(0,q.jsx)(P,{size:`sm`,className:`w-36`,children:(0,q.jsx)(W,{})}),(0,q.jsxs)(U,{children:[(0,q.jsx)(G,{value:X,children:De()}),(0,q.jsx)(G,{value:`active`,children:d()}),(0,q.jsx)(G,{value:`disabled`,children:T()})]})]})]}),(0,q.jsx)(ct,{title:ue(),rows:l,addLabel:oe(),onAdd:()=>{C(Z),D(null),x(!0)},emptyHint:Te(),isExpanded:e=>O.has(e._id),renderExpanded:e=>(0,q.jsx)(ut,{account:e,keys:Y.get(e._id)??[],onRevoke:ht,revoking:L}),rowActions:e=>[{label:te(),onSelect:()=>pt(e)},{label:Ce(),onSelect:()=>void mt(e)},{label:O.has(e._id)?se():we(),onSelect:()=>Q(e._id)},{label:Ze(),variant:`destructive`,onSelect:()=>void $(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,q.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":O.has(e._id)?be():de(),onClick:()=>Q(e._id),children:O.has(e._id)?(0,q.jsx)(Qe,{}):(0,q.jsx)(it,{})})},{header:le(),sort:e=>e.name,cell:e=>(0,q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,q.jsx)(`span`,{children:e.name}),e.description?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:ae(),sort:e=>e.roleKey,cell:e=>(0,q.jsx)(H,{variant:`secondary`,children:e.roleKey})},{header:ge(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,q.jsx)(H,{variant:`destructive`,children:T()}):(0,q.jsx)(H,{variant:`outline`,children:d()})},{header:pe(),cell:e=>(0,q.jsxs)(N,{value:z[e._id]??`never`,onValueChange:t=>at(n=>({...n,[e._id]:t})),children:[(0,q.jsx)(P,{size:`sm`,className:`w-32`,children:(0,q.jsx)(W,{})}),(0,q.jsx)(U,{children:J.map(e=>(0,q.jsx)(G,{value:e.value,children:e.label()},e.value))})]})},{header:fe(),sort:e=>(Y.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(Y.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,q.jsx)(`span`,{className:`oc-sa__keycount`,children:M===e._id?Re():ee({count:t})})}}]}),(0,q.jsx)(rt,{open:b,onOpenChange:e=>{x(e),e||D(null)},title:w?ze():ie(),description:w?me():Se(),canSubmit:!!(S.name&&S.roleKey),onSubmit:ft,submitLabel:w?re():Je(),children:(0,q.jsxs)(`div`,{className:`oc-form`,children:[(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:ne()}),(0,q.jsx)(B,{value:S.name,onChange:e=>C({...S,name:e.target.value})})]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:xe()}),(0,q.jsxs)(N,{value:S.roleKey||void 0,onValueChange:e=>C({...S,roleKey:e}),children:[(0,q.jsx)(P,{className:`w-full`,children:(0,q.jsx)(W,{placeholder:Ye()})}),(0,q.jsx)(U,{children:(f??[]).map(e=>(0,q.jsxs)(G,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(f??[]).find(e=>e.key===S.roleKey),t=e?lt(e):null;return t?(0,q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,q.jsxs)(`label`,{className:`oc-field`,children:[(0,q.jsx)(`span`,{className:`oc-field__label`,children:je()}),(0,q.jsx)(B,{value:S.description,onChange:e=>C({...S,description:e.target.value})})]})]})}),(0,q.jsx)(dt,{minted:ot,onClose:()=>V(null)})]})}function ut({account:e,keys:t,onRevoke:n,revoking:i}){return(0,q.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,q.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[C(),` `,(0,q.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,q.jsx)(`p`,{className:`oc-admin__hint`,children:D()}):(0,q.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`th`,{children:S()}),(0,q.jsx)(`th`,{children:r()}),(0,q.jsx)(`th`,{children:_e()}),(0,q.jsx)(`th`,{children:x()}),(0,q.jsx)(`th`,{children:y()}),(0,q.jsx)(`th`,{children:b()}),(0,q.jsx)(`th`,{})]})}),(0,q.jsx)(`tbody`,{children:t.map(t=>(0,q.jsxs)(`tr`,{children:[(0,q.jsx)(`td`,{children:(0,q.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,q.jsx)(`td`,{children:(0,q.jsx)(H,{variant:`secondary`,children:e.roleKey})}),(0,q.jsx)(`td`,{children:F(t.createdAt)}),(0,q.jsx)(`td`,{className:ft(t.lastUsedAt)?`oc-sa__stale`:``,children:pt(t.lastUsedAt)}),(0,q.jsx)(`td`,{children:mt(t.expiresAt)}),(0,q.jsx)(`td`,{children:$(t)}),(0,q.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,q.jsx)(j,{variant:`destructive`,size:`sm`,disabled:i.has(t._id),onClick:()=>n(t),children:i.has(t._id)?u():w()})})]},t._id))})]})]})}function dt({minted:e,onClose:t}){let[n,r]=(0,K.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,q.jsx)(I,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,q.jsxs)(L,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,q.jsxs)(z,{children:[(0,q.jsx)(R,{children:f()}),(0,q.jsx)(ot,{children:s({name:e.accountName})})]}),(0,q.jsx)(`div`,{className:`oc-sa__minted-warning`,children:v()}),(0,q.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,q.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,q.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":g(),children:[n?(0,q.jsx)(A,{}):(0,q.jsx)(M,{}),n?c():_()]})]}),(0,q.jsx)(at,{children:(0,q.jsx)(j,{onClick:()=>{r(!1),t()},children:a()})})]}):null})}function ft(e){return e===null?!1:Date.now()-e>Y}function pt(e){return e===null?l():F(e)}function mt(e){return e===null?`—`:V(e)}function $(e){return e.disabled?(0,q.jsx)(H,{variant:`destructive`,children:o()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,q.jsx)(H,{variant:`outline`,children:he()}):(0,q.jsx)(H,{variant:`outline`,children:m()})}export{Q as ServiceAccountsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$o as r,As as i,Cs as a,Ds as o,Es as s,Jo as c,Ms as l,Os as u,Qo as d,RL as f,Ss as p,Ts as m,Xo as h,Yo as g,Zo as _,_s as v,as as y,bs as b,cs as x,ds as S,es as C,fs as w,gs as T,hs as E,is as D,js as O,ks as k,ls as A,ms as j,ns as M,os as N,ps as P,rs as F,ss as I,t as L,ts as R,us as ee,vs as z,ws as B,xs as V,ys as H,zL as U}from"./api-EsnGI4EC.js";import{t as W}from"./button-CZ9WPf0m.js";import{Z as G,ct as K}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$o as r,As as i,Cs as a,Ds as o,Es as s,Jo as c,Ms as l,Os as u,Qo as d,RL as f,Ss as p,Ts as m,Xo as h,Yo as g,Zo as _,_s as v,as as y,bs as b,cs as x,ds as S,es as C,fs as w,gs as T,hs as E,is as D,js as O,ks as k,ls as A,ms as j,ns as M,os as N,ps as P,rs as F,ss as I,t as L,ts as R,us as ee,vs as z,ws as B,xs as V,ys as H,zL as U}from"./api-EsnGI4EC.js";import{t as W}from"./button-CZ9WPf0m.js";import{Z as G,ct as K}from"./index-DdOFgMFG.js";import{t as q}from"./DataTableShell-D5Nb8D27.js";var J=t(e(),1),Y=n(),X={hung:()=>E(),wrong_result:()=>j(),error:()=>P(),other:()=>w()},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=f(L.subAgentReports.respondToReport),[i,a]=(0,J.useState)(e.thread),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1);async function u(){let t=o.trim();if(!(!t||c)){l(!0);try{await n({reportId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),s(``)}finally{l(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,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:ee()}),(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:A()}),i.length>0?(0,Y.jsx)(`div`,{className:`oc-fbadmin__thread`,children:i.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`?x():I()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:N()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:y(),value:o,maxLength:2e3,rows:3,onChange:e=>s(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void u(),disabled:!o.trim()||c,children:c?F():D()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[M({count:t.children.length}),t.childrenTruncated?` ${R()}`:``,t.textTruncated?` ${C()}`:``]}),(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?` · ${r()}`:``]}),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:d()}),(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:_()}),(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=U(L.subAgentReports.listForAdmin,{}),t=f(L.subAgentReports.readReport),n=f(L.subAgentReports.deleteReport),r=G(),[d,_]=(0,J.useState)(null),[y,x]=(0,J.useState)({});async function S(e){if(d===e._id){_(null);return}if(!y[e._id]){let n=await t({reportId:e._id});x(t=>({...t,[e._id]:n}))}_(e._id)}async function C(e){await r({title:h(),description:g(),confirmLabel:c(),destructive:!0})&&(await n({reportId:e._id}),d===e._id&&_(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[i(),` `,(0,Y.jsx)(`strong`,{children:k()}),` `,u()]}),(0,Y.jsx)(q,{title:l(),rows:e,emptyHint:O(),isExpanded:e=>d===e._id&&!!y[e._id],renderExpanded:e=>y[e._id]?(0,Y.jsx)($,{data:y[e._id]}):null,columns:[{header:o(),cell:e=>K(e.at),sort:e=>e.at},{header:s(),cell:e=>Z(e.category),sort:e=>Z(e.category)},{header:m(),cell:e=>`${e.failedCount}/${e.totalCount}`,sort:e=>e.failedCount},{header:B(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${V({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:a(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:p(),cell:e=>e.answered?(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:b()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:H()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:d===e._id?v():z(),onSelect:()=>void S(e)},{label:T(),onSelect:()=>void C(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
|