@lacneu/atrium 0.68.7 → 0.68.10
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-B7G7Im-a.js → AccessTab-gw37MX4z.js} +1 -1
- package/dist/assets/{AdvancedFilter-CjEUAVch.js → AdvancedFilter-BDno6bpi.js} +1 -1
- package/dist/assets/{AgentFilesTab-DKEO7ihf.js → AgentFilesTab-W9i4xzRo.js} +1 -1
- package/dist/assets/{AnomaliesTab-Bvq6x8ww.js → AnomaliesTab-Cl6fhnzj.js} +1 -1
- package/dist/assets/{AuditTab-DIByJCQ9.js → AuditTab-D97UVjIT.js} +1 -1
- package/dist/assets/{BridgeTab-LvVXzAlN.js → BridgeTab-BDw6d-rB.js} +1 -1
- package/dist/assets/{ChatDefaultsTab-D_jEnjO5.js → ChatDefaultsTab-DyNXBEEJ.js} +1 -1
- package/dist/assets/{DataTableShell-BmkE6ZKo.js → DataTableShell-BDPxsytR.js} +1 -1
- package/dist/assets/{DetailChips-Di7RSv7f.js → DetailChips-Dz1CvCUA.js} +1 -1
- package/dist/assets/{FeedbacksTab-BmhnkPhR.js → FeedbacksTab-CDK3yYEV.js} +1 -1
- package/dist/assets/{FieldLabel-DnOYy3n5.js → FieldLabel-TkK78Rxe.js} +1 -1
- package/dist/assets/{FilesTab-1YAzvBPF.js → FilesTab-DLluQLgq.js} +1 -1
- package/dist/assets/{FilterBar-DlTMnvB-.js → FilterBar-BBUyj-UI.js} +1 -1
- package/dist/assets/{GroupsTab-ClVeesJC.js → GroupsTab-Co_3EhXl.js} +1 -1
- package/dist/assets/{InstancesTab-DYkjYsMn.js → InstancesTab-CsLF4tq3.js} +1 -1
- package/dist/assets/{IntegrationsTab-zS2Esk5O.js → IntegrationsTab-Bjt9q4ZK.js} +1 -1
- package/dist/assets/{KpiTab-CNmL3EST.js → KpiTab-CRc4Euhi.js} +1 -1
- package/dist/assets/{PreferencesTab-CdrkzuY3.js → PreferencesTab-BXkrfdNS.js} +1 -1
- package/dist/assets/{ProjectPage-MZ9pfIea.js → ProjectPage-u5Zbldt0.js} +1 -1
- package/dist/assets/{PromptInjectionsTab-BiynJSD3.js → PromptInjectionsTab-BMZROwau.js} +1 -1
- package/dist/assets/{RolesTab-BM2zOyLw.js → RolesTab-B_YbBBXC.js} +1 -1
- package/dist/assets/{ScheduledTab-BQSbjoZM.js → ScheduledTab-C-0Lokx_.js} +1 -1
- package/dist/assets/{ServiceAccountsTab-C6HWauET.js → ServiceAccountsTab-DOcs-VU3.js} +1 -1
- package/dist/assets/{SubAgentReportsTab-XlPZnH2k.js → SubAgentReportsTab-BCuAGsRD.js} +1 -1
- package/dist/assets/{ThemeShowroom-BxvDwHhY.js → ThemeShowroom-BudrZBVa.js} +1 -1
- package/dist/assets/{TimeRangePicker-BUrfipct.js → TimeRangePicker-Cgf77qy5.js} +1 -1
- package/dist/assets/{TimezoneCombobox-DAcSoa-v.js → TimezoneCombobox-B6dL9fFG.js} +1 -1
- package/dist/assets/{TracesTab-g0feaQwD.js → TracesTab-DDn4A81J.js} +1 -1
- package/dist/assets/{UsersTab-hygxYWM3.js → UsersTab-uCx1h5JL.js} +1 -1
- package/dist/assets/{VoiceTab-F9Y302WC.js → VoiceTab-Dr48C_we.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-DCfSxTbs.js → highlighted-body-OFNGDK62-CYygbYpM.js} +1 -1
- package/dist/assets/index-7VpXzGMb.css +1 -0
- package/dist/assets/{index-C6y-Zg32.js → index-DI3wVm5g.js} +26 -26
- package/dist/assets/mermaid-GHXKKRXX-Q9KS1K9K.js +1 -0
- package/dist/assets/{pdf-BGco1DwX.js → pdf-DRifwjPA.js} +1 -1
- package/dist/assets/{tabs-DNVRkGA5.js → tabs-CNjvgr2F.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/index-CX1S7Sqd.css +0 -1
- package/dist/assets/mermaid-GHXKKRXX-Ci5Jr2Ma.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$s as r,BL as i,HL as a,Qs as o,UL as s,Zs as c,aD as l,ac as u,cD as d,dD as f,ec as p,fD as m,iD as h,ic as g,lD as _,mD as v,nD as y,nc as b,oD as x,pD as S,rD as C,rc as w,sD as T,t as E,tD as D,tc as O,uD as k}from"./api-CZm__5my.js";import{t as A}from"./button-DMpgqct_.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{$s as r,BL as i,HL as a,Qs as o,UL as s,Zs as c,aD as l,ac as u,cD as d,dD as f,ec as p,fD as m,iD as h,ic as g,lD as _,mD as v,nD as y,nc as b,oD as x,pD as S,rD as C,rc as w,sD as T,t as E,tD as D,tc as O,uD as k}from"./api-CZm__5my.js";import{t as A}from"./button-DMpgqct_.js";import{P as j,jt as M,ut as N}from"./index-DI3wVm5g.js";var P=t(e(),1),F=n();function I(){let e=s(E.integrations.status.status,{}),t=a(E.admin.setIntegrationConfig),[n,r]=(0,P.useState)(null);if((0,P.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,F.jsx)(`p`,{className:`oc-admin__hint`,children:v()});let i=n,o=(e,t,n)=>r({...i,[e]:{...i[e],[t]:n}}),c=(e,n)=>void t({[e]:n});return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`oc-admin__hint`,children:[S(),` `,(0,F.jsx)(`strong`,{children:m()}),` `,f()]}),(0,F.jsxs)(L,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,F.jsx)(N,{variant:`secondary`,children:k()}):(0,F.jsx)(N,{variant:`outline`,children:_()}):(0,F.jsx)(N,{variant:`outline`,children:d()}),note:T(),children:[(0,F.jsx)(R,{label:l(),children:(0,F.jsx)(M,{value:i.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>o(`langfuse`,`host`,e.target.value),onBlur:()=>c(`langfuse`,{host:i.langfuse.host??``})})}),(0,F.jsx)(z,{label:D(),checked:i.langfuse.enabled??!0,onChange:e=>{o(`langfuse`,`enabled`,e),c(`langfuse`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,F.jsx)(N,{variant:`secondary`,children:k()}):(0,F.jsx)(N,{variant:`outline`,children:_()}):(0,F.jsx)(N,{variant:`outline`,children:d()}),note:x(),children:[(0,F.jsx)(R,{label:h(),children:(0,F.jsx)(M,{value:i.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>o(`opik`,`baseUrl`,e.target.value),onBlur:()=>c(`opik`,{baseUrl:i.opik.baseUrl??``})})}),(0,F.jsx)(R,{label:C(),children:(0,F.jsx)(M,{value:i.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||y(),onChange:e=>o(`opik`,`workspace`,e.target.value),onBlur:()=>c(`opik`,{workspace:i.opik.workspace??``})})}),(0,F.jsx)(z,{label:D(),checked:i.opik.enabled??!0,onChange:e=>{o(`opik`,`enabled`,e),c(`opik`,{enabled:e})}})]}),(0,F.jsxs)(L,{title:`OpenTelemetry (OTLP)`,status:e.otlp.configured?e.otlp.enabled?(0,F.jsx)(N,{variant:`secondary`,children:k()}):(0,F.jsx)(N,{variant:`outline`,children:_()}):(0,F.jsx)(N,{variant:`outline`,children:u()}),note:g(),children:[(0,F.jsx)(R,{label:w(),children:(0,F.jsx)(M,{value:i.otlp.endpoint??``,placeholder:e.otlp.effectiveEndpoint||`https://otlp.example.com/v1/traces`,onChange:e=>o(`otlp`,`endpoint`,e.target.value),onBlur:()=>c(`otlp`,{endpoint:i.otlp.endpoint??``})})}),(0,F.jsx)(B,{headersSet:e.otlp.headersSet}),(0,F.jsx)(z,{label:D(),checked:i.otlp.enabled??!0,onChange:e=>{o(`otlp`,`enabled`,e),c(`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=i(E.integrations.otlpSecret.setOtlpHeaders),n=a(E.integrations.otlpSecret.clearOtlpHeaders),[s,l]=(0,P.useState)(``),[u,d]=(0,P.useState)(null),[f,m]=(0,P.useState)(!1),h=async()=>{m(!0),d(null);try{await t({headersJson:s}),l(``)}catch(e){d(e instanceof Error?e.message:String(e))}finally{m(!1)}};return(0,F.jsxs)(R,{label:b(),children:[(0,F.jsx)(M,{value:s,placeholder:e?O():p(),onChange:e=>l(e.target.value)}),(0,F.jsxs)(`div`,{className:`oc-int__otlp-headers-actions`,children:[(0,F.jsx)(A,{size:`sm`,disabled:f||s.trim().length===0,onClick:()=>void h(),children:r()}),e?(0,F.jsx)(A,{variant:`ghost`,size:`sm`,disabled:f,onClick:()=>void n({}),children:o()}):null]}),u?(0,F.jsx)(`p`,{className:`oc-int__otlp-headers-error`,children:u}):null,(0,F.jsx)(`p`,{className:`oc-uipa__note`,children:c()})]})}export{I as IntegrationsTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BD as r,B_ as i,F_ as a,H_ as o,I_ as s,JD as c,L_ as l,M_ as u,N_ as d,P_ as f,R_ as p,SO as m,UL as h,U_ as g,VD as _,V_ as ee,W_ as te,XD as v,YD as y,ZD as b,j_ as x,t as S,z_ as C}from"./api-CZm__5my.js";import{Fn as w,Pn as T,i as E,o as D,r as ne,wt as re}from"./index-
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{BD as r,B_ as i,F_ as a,H_ as o,I_ as s,JD as c,L_ as l,M_ as u,N_ as d,P_ as f,R_ as p,SO as m,UL as h,U_ as g,VD as _,V_ as ee,W_ as te,XD as v,YD as y,ZD as b,j_ as x,t as S,z_ as C}from"./api-CZm__5my.js";import{Fn as w,Pn as T,i as E,o as D,r as ne,wt as re}from"./index-DI3wVm5g.js";import{a as O,n as k,o as A,r as j,t as M}from"./card-CgG4ub16.js";import{n as N,t as P}from"./TimeRangePicker-Cgf77qy5.js";var F=t(e(),1),I=n(),L=15,R=e=>String(Math.round(e));function z(){let e=h(S.me.getMe,{host:re})?.permissions?.includes(`traces.read`)??!1,t=h(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:m()}),(0,I.jsxs)(M,{children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{children:b()}),(0,I.jsx)(j,{children:y()})]}),(0,I.jsx)(k,{children:n.length<2?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:c()}):(0,I.jsx)(B,{series:n})})]})]})}function B({series:e}){let t=e.map(e=>e.cP50),n=e.map(e=>e.aP50),i=Math.max(1,...t,...n),a=t=>6+t*468/(e.length-1),o=e=>74-e*68/i,s=e=>e.map((e,t)=>`${t===0?`M`:`L`}${a(t).toFixed(1)},${o(e).toFixed(1)}`).join(` `),c=e[e.length-1];return(0,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:[r(),` p50 `,R(c.cP50),` `,v()]}),(0,I.jsxs)(`span`,{children:[_(),` p50 `,R(c.aP50),` `,v()]})]}),(0,I.jsxs)(`svg`,{viewBox:`0 0 480 80`,className:`h-20 w-full`,preserveAspectRatio:`none`,role:`img`,"aria-label":b(),children:[(0,I.jsx)(`path`,{d:s(n),fill:`none`,style:{stroke:`var(--muted-foreground)`},strokeWidth:1.5}),(0,I.jsx)(`path`,{d:s(t),fill:`none`,style:{stroke:`var(--primary)`},strokeWidth:1.5})]})]})}var V=[{metric:`api.calls`,label:te(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:g(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:o(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:ee(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:i(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:C(),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=w({from:`/settings/kpi`}),t=T({from:`/settings/kpi`}),n=E(e.from,e.to,ne,`now`),r=e=>void t({search:t=>({...t,...D(e)})}),{from:i,to:o}=N(n),{rowLimit:c,buckets:u}=K(i,o),d=h(S.kpi.listKpis,{limit:c,filter:{from:i,to:o}}),f=(0,F.useMemo)(()=>{let e=new Map;for(let t of d??[]){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>u&&e.set(t,n.slice(n.length-u));return e},[d,u]),m=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[p(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:l()})]}),(0,I.jsx)(J,{value:n,onChange:r})]});return d===void 0?(0,I.jsxs)(I.Fragment,{children:[m,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:s()})]}):d.length===0?(0,I.jsxs)(I.Fragment,{children:[m,(0,I.jsx)(z,{}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:a()})]}):(0,I.jsxs)(I.Fragment,{children:[m,(0,I.jsx)(z,{}),U.map(e=>{let t=V.filter(t=>t.group===e);return t.some(e=>(f.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:f.get(e.metric)??[]},e.metric))})]},e):null})]})}function J({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(P,{value:e,onChange:t})})}function Y({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(M,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(O,{children:[(0,I.jsx)(A,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(j,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(k,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:Q(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(ae,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:f({value:$(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:d()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:u({count:t.length})})]})]})]})}var X=240,Z=48,ie=1;function ae({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=X/e.length,a=Math.max(i-ie,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${X} ${Z}`,preserveAspectRatio:`none`,role:`img`,"aria-label":x({max:Q(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(Z-1):0,c=o*i,l=Z-s;return(0,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.jsxs)(`title`,{children:[$(e.bucket),` · `,Q(e.value),` `,n]})},e.bucket)})})}function Q(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function $(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}export{q as KpiTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{AM as r,BM as i,CL as a,CM as o,DM as s,EL as c,EM as l,Et as u,FM as d,HL as f,HM as p,IM as m,LM as h,MM as ee,Mt as te,NM as g,OM as ne,PL as re,PM as ie,RM as ae,SL as oe,SM as se,TL as ce,TM as le,UL as _,UM as ue,VM as de,_L as fe,_M as v,_t as pe,aL as me,aM as he,bL as ge,bM as y,cL as b,cM as x,dL as S,dM as C,dt as w,fL as T,fM as E,ft as D,gL as O,gM as k,gt as A,hL as j,hM as M,ht as N,iL as P,iM as F,jM as I,jt as L,kL as _e,kM as ve,lL as ye,lM as be,mL as xe,mM as Se,mt as Ce,oL as we,oM as Te,pL as Ee,pM as R,pt as De,r as z,rL as Oe,rT as ke,sL as Ae,sM as je,t as B,uL as Me,uM as Ne,vL as Pe,vM as Fe,vt as Ie,wL as Le,wM as Re,xL as ze,xM as Be,yL as Ve,yM as He,zM as Ue}from"./api-CZm__5my.js";import{t as V}from"./button-DMpgqct_.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-C6y-Zg32.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-DAcSoa-v.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>ue()},{id:`composer`,label:()=>p()},{id:`sidebar`,label:()=>de()},{id:`notifications`,label:()=>Re()},{id:`other`,label:()=>i()}],X={showSource:{category:`messages`,label:()=>Ue(),help:()=>ae()},showReport:{category:`messages`,label:()=>h(),help:()=>m()},copyAssistant:{category:`messages`,label:()=>d()},copyUser:{category:`messages`,label:()=>ie()},showDelete:{category:`messages`,label:()=>g()},showTools:{category:`messages`,label:()=>ee(),help:()=>I()},voiceInput:{category:`composer`,label:()=>r(),help:()=>ve()},showUsage:{category:`composer`,label:()=>ne(),help:()=>s()},autoReadAloud:{category:`composer`,label:()=>te(),help:()=>L()},showChatAge:{category:`sidebar`,label:()=>l(),help:()=>le()},notifSound:{category:`notifications`,label:()=>o(),help:()=>se()},notifSystem:{category:`notifications`,label:()=>Be(),help:()=>y()},replySound:{category:`notifications`,label:()=>He(),help:()=>Fe()}};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:()=>x()};function ut({prefKey:e,ui:t}){let n=f(B.admin.setUiPrefDefault),r=f(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:E()}),(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:Te()}),(0,J.jsx)(K,{value:`off`,children:he()}),(0,J.jsx)(K,{value:`inherit`,children:F()})]})]}),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":C()}),C()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=f(B.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:[Ie(),e?(0,J.jsx)(W,{variant:`secondary`,children:We(e,Ke())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?N():r?A():pe()})]}),(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:w()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?D():e?De():Ce()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=_(B.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=f(B.me.setUiPref).withOptimisticUpdate(Xe),c=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(H,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":R()}),R()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:Ne()}),(0,J.jsx)(`p`,{children:be()}),(0,J.jsx)(`p`,{children:je()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:v(),"aria-label":v(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:k()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(W,{variant:`outline`,children:M()}):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 s({key:e,value:null}),children:Se()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:re()})}var pt={sm:()=>xe(),md:()=>Ee(),lg:()=>T(),xl:()=>S(),"2xl":()=>Me(),"3xl":()=>ye()};function mt(){let e=_(B.me.getMe,{host:G}),t=f(B.me.setLocale),n=f(B.me.setTimezone),r=f(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:G});n&&e.setQuery(B.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=f(B.me.setMyName),o=Ge(),s=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),p=u??l,m=p.trim()!==l.trim();async function h(){try{await i({name:p}),d(null),o.success(oe())}catch(e){o.error(ze(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:c()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:p,maxLength:120,placeholder:Le(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,J.jsx)(V,{size:`sm`,disabled:!m,onClick:()=>void h(),children:ke()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:a()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ge()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ve()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:_e()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Pe()})]}),(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:b()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(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:we()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:me()})]}),(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:fe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:O()})]}),(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 r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(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:P()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Oe()})]}),(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{AM as r,BM as i,CL as a,CM as o,DM as s,EL as c,EM as l,Et as u,FM as d,HL as f,HM as p,IM as m,LM as h,MM as ee,Mt as te,NM as g,OM as ne,PL as re,PM as ie,RM as ae,SL as oe,SM as se,TL as ce,TM as le,UL as _,UM as ue,VM as de,_L as fe,_M as v,_t as pe,aL as me,aM as he,bL as ge,bM as y,cL as b,cM as x,dL as S,dM as C,dt as w,fL as T,fM as E,ft as D,gL as O,gM as k,gt as A,hL as j,hM as M,ht as N,iL as P,iM as F,jM as I,jt as L,kL as _e,kM as ve,lL as ye,lM as be,mL as xe,mM as Se,mt as Ce,oL as we,oM as Te,pL as Ee,pM as R,pt as De,r as z,rL as Oe,rT as ke,sL as Ae,sM as je,t as B,uL as Me,uM as Ne,vL as Pe,vM as Fe,vt as Ie,wL as Le,wM as Re,xL as ze,xM as Be,yL as Ve,yM as He,zM as Ue}from"./api-CZm__5my.js";import{t as V}from"./button-DMpgqct_.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-DI3wVm5g.js";import{t as et}from"./localePickerView-C2RmOS86.js";import{t as tt}from"./TimezoneCombobox-B6dL9fFG.js";var q=t(e(),1),J=n();function nt({className:e,checked:t,onCheckedChange:n,disabled:r,...i}){return(0,J.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"data-state":t?`checked`:`unchecked`,disabled:r,onClick:()=>n(!t),className:z(`peer inline-flex h-5 w-9 shrink-0 items-center rounded-full border border-transparent transition-colors outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/50`,`disabled:cursor-not-allowed disabled:opacity-50`,t?`bg-primary`:`bg-input`,e),...i,children:(0,J.jsx)(`span`,{className:z(`pointer-events-none block size-4 rounded-full bg-background shadow transition-transform`,t?`translate-x-[18px]`:`translate-x-[2px]`)})})}var Y=[{id:`messages`,label:()=>ue()},{id:`composer`,label:()=>p()},{id:`sidebar`,label:()=>de()},{id:`notifications`,label:()=>Re()},{id:`other`,label:()=>i()}],X={showSource:{category:`messages`,label:()=>Ue(),help:()=>ae()},showReport:{category:`messages`,label:()=>h(),help:()=>m()},copyAssistant:{category:`messages`,label:()=>d()},copyUser:{category:`messages`,label:()=>ie()},showDelete:{category:`messages`,label:()=>g()},showTools:{category:`messages`,label:()=>ee(),help:()=>I()},voiceInput:{category:`composer`,label:()=>r(),help:()=>ve()},showUsage:{category:`composer`,label:()=>ne(),help:()=>s()},autoReadAloud:{category:`composer`,label:()=>te(),help:()=>L()},showChatAge:{category:`sidebar`,label:()=>l(),help:()=>le()},notifSound:{category:`notifications`,label:()=>o(),help:()=>se()},notifSystem:{category:`notifications`,label:()=>Be(),help:()=>y()},replySound:{category:`notifications`,label:()=>He(),help:()=>Fe()}};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:()=>x()};function ut({prefKey:e,ui:t}){let n=f(B.admin.setUiPrefDefault),r=f(B.admin.setFeatureEnabled),i=ct(e),a=i?lt[e]?.():void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,J.jsx)(`span`,{className:`oc-prefs__gov-label`,children:E()}),(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:Te()}),(0,J.jsx)(K,{value:`off`,children:he()}),(0,J.jsx)(K,{value:`inherit`,children:F()})]})]}),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":C()}),C()]}):null]}),a?(0,J.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function dt({current:e,enabled:t}){let n=f(B.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:[Ie(),e?(0,J.jsx)(W,{variant:`secondary`,children:We(e,Ke())}):null]}),(0,J.jsx)(`span`,{className:`oc-prefs__help`,children:a?N():r?A():pe()})]}),(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:w()}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,disabled:!t,"aria-pressed":r,onClick:()=>i(e=>!e),children:r?D():e?De():Ce()})]})]})}function ft(){let[e,t]=(0,q.useState)(``),[n,r]=(0,q.useState)(!1),i=_(B.me.getMe,{host:G}),a=i?.ui,o=$(i?.role)&&n,s=f(B.me.setUiPref).withOptimisticUpdate(Xe),c=(0,q.useMemo)(()=>a?Q(Object.keys(a.effective),e):[],[a,e]);return a?(0,J.jsxs)(`div`,{className:`oc-prefs-panel`,children:[$(i?.role)?(0,J.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,J.jsx)(H,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":R()}),R()]}):null,o?(0,J.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,J.jsx)(`p`,{children:Ne()}),(0,J.jsx)(`p`,{children:be()}),(0,J.jsx)(`p`,{children:je()})]}):null,(0,J.jsx)(U,{value:e,onChange:e=>t(e.target.value),placeholder:v(),"aria-label":v(),className:`mb-2`}),c.length===0?(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:k()}):(0,J.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,J.jsxs)(`section`,{className:`oc-prefs__card`,children:[(0,J.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=X[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,J.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}`,children:[(0,J.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,J.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,J.jsx)(W,{variant:`outline`,children:M()}):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 s({key:e,value:null}),children:Se()}):null,(0,J.jsx)(nt,{checked:c,disabled:i,onCheckedChange:t=>{e===`notifSystem`&&t&&typeof Notification<`u`&&Notification.permission==="default"&&Notification.requestPermission(),s({key:e,value:t})},"aria-label":n})]}),o?(0,J.jsx)(ut,{prefKey:e,ui:a}):null]},e)})]},e.id))}),(0,J.jsx)(dt,{current:i?.dictationShortcut??null,enabled:a.effective.voiceInput===!0})]}):(0,J.jsx)(`div`,{className:`oc-prefs__empty`,children:re()})}var pt={sm:()=>xe(),md:()=>Ee(),lg:()=>T(),xl:()=>S(),"2xl":()=>Me(),"3xl":()=>ye()};function mt(){let e=_(B.me.getMe,{host:G}),t=f(B.me.setLocale),n=f(B.me.setTimezone),r=f(B.me.setFontScale).withOptimisticUpdate((e,{scale:t})=>{let n=e.getQuery(B.me.getMe,{host:G});n&&e.setQuery(B.me.getMe,{host:G},{...n,fontScale:t,resolvedFontScale:t??`md`})}),i=f(B.me.setMyName),o=Ge(),s=e?.locale??`default`,l=e?.name??``,[u,d]=(0,q.useState)(null),p=u??l,m=p.trim()!==l.trim();async function h(){try{await i({name:p}),d(null),o.success(oe())}catch(e){o.error(ze(),e)}}return(0,J.jsxs)(`div`,{className:`oc-appearance`,children:[(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:c()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:ce()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[(0,J.jsx)(U,{className:`max-w-xs`,value:p,maxLength:120,placeholder:Le(),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&(e.preventDefault(),h())}}),(0,J.jsx)(V,{size:`sm`,disabled:!m,onClick:()=>void h(),children:ke()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:a()})]}),(0,J.jsxs)(`section`,{className:`oc-show__section`,children:[(0,J.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-show__title`,children:ge()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ve()})]}),(0,J.jsxs)(`div`,{className:`oc-show__row`,children:[et().map(e=>(0,J.jsx)(V,{variant:s===e.value?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e.value}),children:e.label},e.value)),(0,J.jsx)(V,{variant:s==="default"?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:null}),children:_e()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Pe()})]}),(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:b()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Ae()})]}),(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:we()})]}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:me()})]}),(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:fe()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:O()})]}),(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 r({scale:t}),children:pt[t]()},t))}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:j()})]}),(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:P()}),(0,J.jsx)(`p`,{className:`oc-show__desc`,children:Oe()})]}),(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{$g as r,Ag as i,Bg as a,Cg as o,D as s,Dg as c,Eg as l,Fg as u,Fm as d,Gg as f,HL as p,Ig as m,Kg as h,Lg as g,Mg as _,Ng as v,Og as y,PL as b,Pg as x,Qg as ee,Rg as te,Sg as ne,Tg as re,UL as S,Ug as ie,Vg as ae,Wg as oe,Xg as se,Yg as ce,Zg as le,a_ as ue,bg as de,c_ as C,cg as fe,dg as w,f_ as pe,fg as T,gg as me,hg as he,i_ as ge,ig as _e,jg as ve,kg as ye,lg as E,m_ as be,mg as D,og as O,p_ as xe,qg as k,s_ as A,sg as Se,t as j,t_ as M,ug as Ce,xg as N,zg as we}from"./api-CZm__5my.js";import{r as Te}from"./dist-51K385p9.js";import{t as Ee}from"./list-Bb-2S9oG.js";import{t as P}from"./button-DMpgqct_.js";import{A as De,C as Oe,Cn as ke,D as F,Dt as Ae,E as je,En as Me,Et as Ne,F as Pe,Fn as Fe,Ft as Ie,In as Le,It as Re,Lt as ze,Mt as Be,Nt as Ve,O as I,Pn as L,Pt as R,Q as He,S as Ue,Sn as z,T as We,Tt as Ge,Z as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as H,h as U,hn as W,in as Qe,j as G,jn as $e,jt as K,k as et,m as tt,p as nt,pn as rt,v as q,vn as it,w as at,wn as J,x as Y,y as ot}from"./index-C6y-Zg32.js";var st=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`}]]),ct=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`}]]),lt=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`}]]),ut=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function Q({className:e}){return(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":T(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Me,{})})})}function dt({folderId:e,name:t,color:n,currentParentId:i,className:o,onOpen:s}){let c=p(j.projects.renameProject),l=p(j.projects.setProjectColor),u=p(j.projects.moveProject),d=p(j.projects.deleteProject),f=p(j.projects.createProject),m=Ke(),h=He(),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(t),[b,x]=(0,X.useState)(!1),[te,re]=(0,X.useState)(!1),ie=S(j.projects.projectTreeCount,te?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Be,{onOpenChange:e=>e&&re(!0),children:[(0,Z.jsx)(Q,{className:o}),(0,Z.jsxs)(Ve,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>s(),children:[(0,Z.jsx)(J,{}),` `,ce()]}),(0,Z.jsxs)(R,{onSelect:()=>{y(t),_(!0)},children:[(0,Z.jsx)(rt,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await h({title:a(),label:be(),placeholder:xe(),confirmLabel:pe()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,a()]}),(0,Z.jsxs)(R,{onSelect:()=>x(!0),children:[(0,Z.jsx)(ct,{}),` `,ne()]}),(0,Z.jsx)(Ie,{children:fe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":Se(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Re,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=ie?.folders??0,i=ie?.chats??0;await m({title:ee({name:t}),description:n>0?se({folders:n,chats:i}):i>0?le({count:i}):he(),confirmWord:D(),confirmLabel:r(),destructive:!0})&&await d({projectId:e})})},children:[(0,Z.jsx)(Qe,{}),` `,D()]})]})]}),(0,Z.jsx)(qe,{open:g,onOpenChange:_,title:ge(),canSubmit:v.trim().length>0,onSubmit:async()=>{await c({projectId:e,name:v.trim()}),_(!1)},submitLabel:w(),children:(0,Z.jsx)(K,{value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),b?(0,Z.jsx)(nt,{open:b,onOpenChange:x,title:de(),movingFolderId:e,currentId:i,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=p(j.chats.pinChat),i=p(j.chats.deleteChat),a=p(j.chats.renameChat),s=p(j.chats.setChatSidebar),c=p(j.chats.moveChatToProject),l=Ke(),[u,d]=(0,X.useState)(!1),[f,m]=(0,X.useState)(e.title??``),[g,_]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Be,{children:[(0,Z.jsx)(Q,{className:n}),(0,Z.jsxs)(Ve,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{m(e.title??``),d(!0)},children:[(0,Z.jsx)(rt,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(Xe,{}):(0,Z.jsx)(V,{}),e.pinned?Ce():E()]}),(0,Z.jsxs)(R,{onSelect:()=>_(!0),children:[(0,Z.jsx)(ct,{}),` `,o()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void s({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{}),e.inSidebar?h():k()]}),(0,Z.jsx)(Re,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await l({title:O(),description:he(),confirmLabel:D(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(Qe,{}),` `,D()]})]})]}),(0,Z.jsx)(qe,{open:u,onOpenChange:d,title:_e(),canSubmit:f.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:f.trim()}),d(!1)},submitLabel:w(),children:(0,Z.jsx)(K,{value:f,onChange:e=>m(e.target.value),autoFocus:!0})}),g?(0,Z.jsx)(nt,{open:g,onOpenChange:_,title:N(),currentId:t,onPick:t=>void c({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}=Le({from:`/project/$projectId`}),t=L(),n=S(j.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:y()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:c()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:l()})]}):(0,Z.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=Ke(),o=He(),s=Ae(),c=p(j.projects.renameProject),l=p(j.projects.setProjectColor),h=p(j.projects.deleteProject),v=p(j.projects.createProject),y=p(j.projects.moveProject),b=p(j.chats.moveChatToProject),x=p(j.chats.reorderChat),te=p(j.projects.reorderProject),ce=S(j.projects.projectTreeCount,{projectId:e.project._id}),[T,_e]=(0,X.useState)(gt),E=e=>{localStorage.setItem(ht,e),_e(e)},O=S(j.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),k=S(j.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:A}=Fe({from:`/project/$projectId`}),M=S(j.projects.listProjects,{}),Ce=S(j.chatReads.myBusyChats,{}),N=(0,X.useMemo)(()=>new Set(Ce??[]),[Ce]),we=S(j.chatReads.myChatReads,{}),Te=(0,X.useMemo)(()=>mt(e.chats,we??[]),[e.chats,we]),{startNewChat:Le,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,X.useState)(``),[Ze,V]=(0,X.useState)(!1),[U,W]=(0,X.useState)(e.project.name),[G,$e]=(0,X.useState)(!1),[J,ut]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ut(B.trim()),180);return()=>clearTimeout(e)},[B]);let Q=S(j.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),dt=De(et(at,{activationConstraint:{distance:4}}),et(We,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,X.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=O?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||C()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(M??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=F(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=F(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=F(n(`crumb:`));if(a.length>0)return a;let o=F(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(T===`columns`){for(let e of O?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=k?.chats.find(e=>e._id===t);return e?{list:k.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(T===`columns`){for(let e of O?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=k?.folders.find(e=>e._id===t);if(!e||!k)return null;let n=e.parentId??k.rootId;return{list:Ne(k.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(a)await b({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Ge(M??[],t,e)){s.error(ae());return}await y({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await b({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ge(M??[],e,n.parentId)){s.error(ae());return}await y({projectId:e,parentId:n.parentId})}let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await te({projectId:e,...a});return}}catch{s.error(ae())}},[,Mt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=H(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ue,{sensors:dt,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":re(),children:[It.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Ct,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":f(),children:[(0,Z.jsx)(P,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":T===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(lt,{})}),(0,Z.jsx)(P,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":oe(),title:oe(),"aria-pressed":T===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(st,{})}),(0,Z.jsx)(P,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ie(),title:ie(),"aria-pressed":T===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Ee,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Le({projectId:e.project._id}),children:[(0,Z.jsx)(it,{}),u()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:a(),label:be(),placeholder:xe(),confirmLabel:pe()});t&&await v({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),a()]}),(0,Z.jsxs)(Be,{children:[(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ue(),children:(0,Z.jsx)(Me,{})})}),(0,Z.jsxs)(Ve,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{W(e.project.name),V(!0)},children:[(0,Z.jsx)(rt,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>$e(!0),children:[(0,Z.jsx)(ct,{}),` `,ne()]}),(0,Z.jsx)(Ie,{children:fe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":Se(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Re,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let i=e.project.parentId;requestAnimationFrame(async()=>{let a=ce?.folders??0,o=ce?.chats??0;await n({title:ee({name:e.project.name}),description:a>0?se({folders:a,chats:o}):o>0?le({count:o}):he(),confirmWord:D(),confirmLabel:r(),destructive:!0})&&(await h({projectId:e.project._id}),t(i===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:i}}))})},children:[(0,Z.jsx)(Qe,{}),` `,D()]})]})]})]})]}),T===`columns`?(0,Z.jsx)(jt,{data:O,currentId:e.project._id,busyIds:N,suppressClick:$,locateChatId:A??null}):T===`list`?(0,Z.jsx)(Ot,{data:k,busyIds:N,suppressClick:$,locateChatId:A??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:g()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:ot,children:e.children.map(t=>(0,Z.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:m()}),e.chats.length>0?(0,Z.jsx)(K,{value:B,onChange:e=>Xe(e.target.value),placeholder:_(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?i():ye()}):Ft.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve({term:B.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Ft.map(e=>`chat:${e._id}`),strategy:Y,children:Ft.map(t=>(0,Z.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:N.has(t._id),unread:Te.has(t._id),locate:t._id===A,suppressClick:$},t._id))})})]}),J.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:me()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve({term:J})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Pe(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||d()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(qe,{open:Ze,onOpenChange:V,title:ge(),canSubmit:U.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:w(),children:(0,Z.jsx)(K,{value:U,onChange:e=>W(e.target.value),autoFocus:!0})}),G?(0,Z.jsx)(nt,{open:G,onOpenChange:$e,title:de(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void y({projectId:e.project._id,parentId:t})}):null,I]}),(0,Z.jsx)(Oe,{children:vt?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(z,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?x({count:e.folderCount})+` · `:``,v({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=p(j.chats.setChatSidebar),n=e.inSidebar?h():k();return(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=L(),c=U(e.color),l=B({id:`chat:${e._id}`}),u=Dt(a);return(0,Z.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(l.transform),transition:l.transition},children:[(0,Z.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,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||C()}),e.pinned?(0,Z.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:A(),"aria-label":A()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:M(),"aria-label":M()}):null]}),(0,Z.jsx)(Tt,{chat:e}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[a,o]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()});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}),l=(i,o)=>{let u=s.get(i??e.rootId)??[],d=Ne(e.folders,i);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:Y,children:u.map(e=>(0,Z.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:Y,children:d.map(t=>(0,Z.jsx)(kt,{folder:t,parentId:i??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ne(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:i()}):l(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?we():te(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)($e,{size:13}):(0,Z.jsx)(Te,{size:13})}),(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||C()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:Y,children:e.folders.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:Y,children:e.chats.map(t=>(0,Z.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:ye()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||C()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
|
|
1
|
+
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{$g as r,Ag as i,Bg as a,Cg as o,D as s,Dg as c,Eg as l,Fg as u,Fm as d,Gg as f,HL as p,Ig as m,Kg as h,Lg as g,Mg as _,Ng as v,Og as y,PL as b,Pg as x,Qg as ee,Rg as te,Sg as ne,Tg as re,UL as S,Ug as ie,Vg as ae,Wg as oe,Xg as se,Yg as ce,Zg as le,a_ as ue,bg as de,c_ as C,cg as fe,dg as w,f_ as pe,fg as T,gg as me,hg as he,i_ as ge,ig as _e,jg as ve,kg as ye,lg as E,m_ as be,mg as D,og as O,p_ as xe,qg as k,s_ as A,sg as Se,t as j,t_ as M,ug as Ce,xg as N,zg as we}from"./api-CZm__5my.js";import{r as Te}from"./dist-51K385p9.js";import{t as Ee}from"./list-Bb-2S9oG.js";import{t as P}from"./button-DMpgqct_.js";import{A as De,C as Oe,Cn as ke,D as F,Dt as Ae,E as je,En as Me,Et as Ne,F as Pe,Fn as Fe,Ft as Ie,In as Le,It as Re,Lt as ze,Mt as Be,Nt as Ve,O as I,Pn as L,Pt as R,Q as He,S as Ue,Sn as z,T as We,Tt as Ge,Z as Ke,_ as qe,_n as Je,b as B,d as Ye,dn as Xe,f as Ze,fn as V,g as H,h as U,hn as W,in as Qe,j as G,jn as $e,jt as K,k as et,m as tt,p as nt,pn as rt,v as q,vn as it,w as at,wn as J,x as Y,y as ot}from"./index-DI3wVm5g.js";var st=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`}]]),ct=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`}]]),lt=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`}]]),ut=s(`panel-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),X=t(e(),1),Z=n();function Q({className:e}){return(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":T(),className:e,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,Z.jsx)(Me,{})})})}function dt({folderId:e,name:t,color:n,currentParentId:i,className:o,onOpen:s}){let c=p(j.projects.renameProject),l=p(j.projects.setProjectColor),u=p(j.projects.moveProject),d=p(j.projects.deleteProject),f=p(j.projects.createProject),m=Ke(),h=He(),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(t),[b,x]=(0,X.useState)(!1),[te,re]=(0,X.useState)(!1),ie=S(j.projects.projectTreeCount,te?{projectId:e}:`skip`);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Be,{onOpenChange:e=>e&&re(!0),children:[(0,Z.jsx)(Q,{className:o}),(0,Z.jsxs)(Ve,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>s(),children:[(0,Z.jsx)(J,{}),` `,ce()]}),(0,Z.jsxs)(R,{onSelect:()=>{y(t),_(!0)},children:[(0,Z.jsx)(rt,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>{requestAnimationFrame(async()=>{let t=await h({title:a(),label:be(),placeholder:xe(),confirmLabel:pe()});t&&await f({name:t,parentId:e})})},children:[(0,Z.jsx)(ke,{}),` `,a()]}),(0,Z.jsxs)(R,{onSelect:()=>x(!0),children:[(0,Z.jsx)(ct,{}),` `,ne()]}),(0,Z.jsx)(Ie,{children:fe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e,color:null}),"aria-label":Se(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(n===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e,color:t.value})},t.value))]}),(0,Z.jsx)(Re,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let n=ie?.folders??0,i=ie?.chats??0;await m({title:ee({name:t}),description:n>0?se({folders:n,chats:i}):i>0?le({count:i}):he(),confirmWord:D(),confirmLabel:r(),destructive:!0})&&await d({projectId:e})})},children:[(0,Z.jsx)(Qe,{}),` `,D()]})]})]}),(0,Z.jsx)(qe,{open:g,onOpenChange:_,title:ge(),canSubmit:v.trim().length>0,onSubmit:async()=>{await c({projectId:e,name:v.trim()}),_(!1)},submitLabel:w(),children:(0,Z.jsx)(K,{value:v,onChange:e=>y(e.target.value),autoFocus:!0})}),b?(0,Z.jsx)(nt,{open:b,onOpenChange:x,title:de(),movingFolderId:e,currentId:i,onPick:t=>void u({projectId:e,parentId:t})}):null]})}function $({chat:e,currentFolderId:t,className:n}){let r=p(j.chats.pinChat),i=p(j.chats.deleteChat),a=p(j.chats.renameChat),s=p(j.chats.setChatSidebar),c=p(j.chats.moveChatToProject),l=Ke(),[u,d]=(0,X.useState)(!1),[f,m]=(0,X.useState)(e.title??``),[g,_]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(Be,{children:[(0,Z.jsx)(Q,{className:n}),(0,Z.jsxs)(Ve,{align:`end`,className:`w-52`,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(R,{onSelect:()=>{m(e.title??``),d(!0)},children:[(0,Z.jsx)(rt,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>void r({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,Z.jsx)(Xe,{}):(0,Z.jsx)(V,{}),e.pinned?Ce():E()]}),(0,Z.jsxs)(R,{onSelect:()=>_(!0),children:[(0,Z.jsx)(ct,{}),` `,o()]}),e.pinned&&e.inSidebar?null:(0,Z.jsxs)(R,{onSelect:()=>void s({chatId:e._id,hidden:e.inSidebar}),children:[e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{}),e.inSidebar?h():k()]}),(0,Z.jsx)(Re,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await l({title:O(),description:he(),confirmLabel:D(),destructive:!0})&&await i({chatId:e._id})})},children:[(0,Z.jsx)(Qe,{}),` `,D()]})]})]}),(0,Z.jsx)(qe,{open:u,onOpenChange:d,title:_e(),canSubmit:f.trim().length>0,onSubmit:async()=>{await a({chatId:e._id,title:f.trim()}),d(!1)},submitLabel:w(),children:(0,Z.jsx)(K,{value:f,onChange:e=>m(e.target.value),autoFocus:!0})}),g?(0,Z.jsx)(nt,{open:g,onOpenChange:_,title:N(),currentId:t,onPick:t=>void c({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}=Le({from:`/project/$projectId`}),t=L(),n=S(j.projects.projectPage,{projectId:e});return(0,Z.jsx)(`div`,{className:`oc-projpage`,children:n===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):n===null?(0,Z.jsxs)(`div`,{className:`oc-projpage__notfound`,children:[(0,Z.jsx)(`h2`,{children:y()}),(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:c()}),(0,Z.jsx)(P,{variant:`outline`,onClick:()=>void t({to:`/`}),children:l()})]}):(0,Z.jsx)(St,{page:n})})}function St({page:e}){let t=L(),n=Ke(),o=He(),s=Ae(),c=p(j.projects.renameProject),l=p(j.projects.setProjectColor),h=p(j.projects.deleteProject),v=p(j.projects.createProject),y=p(j.projects.moveProject),b=p(j.chats.moveChatToProject),x=p(j.chats.reorderChat),te=p(j.projects.reorderProject),ce=S(j.projects.projectTreeCount,{projectId:e.project._id}),[T,_e]=(0,X.useState)(gt),E=e=>{localStorage.setItem(ht,e),_e(e)},O=S(j.projects.folderColumns,T===`columns`?{projectId:e.project._id}:`skip`),k=S(j.projects.projectTreeList,T===`list`?{projectId:e.project._id}:`skip`),{c:A}=Fe({from:`/project/$projectId`}),M=S(j.projects.listProjects,{}),Ce=S(j.chatReads.myBusyChats,{}),N=(0,X.useMemo)(()=>new Set(Ce??[]),[Ce]),we=S(j.chatReads.myChatReads,{}),Te=(0,X.useMemo)(()=>mt(e.chats,we??[]),[e.chats,we]),{startNewChat:Le,picker:I}=Ye(e=>void t({to:`/chat/$chatId`,params:{chatId:e}})),[B,Xe]=(0,X.useState)(``),[Ze,V]=(0,X.useState)(!1),[U,W]=(0,X.useState)(e.project.name),[G,$e]=(0,X.useState)(!1),[J,ut]=(0,X.useState)(``);(0,X.useEffect)(()=>{let e=setTimeout(()=>ut(B.trim()),180);return()=>clearTimeout(e)},[B]);let Q=S(j.search.searchConversations,J.length>=2?{query:J,projectId:e.project._id}:`skip`),dt=De(et(at,{activationConstraint:{distance:4}}),et(We,{activationConstraint:{delay:250,tolerance:8}})),$=(0,X.useRef)(!1),_t=()=>{$.current=!0,setTimeout(()=>{$.current=!1},0)},[vt,yt]=(0,X.useState)(null),xt=t=>{if(t.startsWith(`chat:`)){let n=t.slice(5),r=e.chats.find(e=>e._id===n),i=O?.columns.flatMap(e=>e.chats).find(e=>e._id===n);return{kind:`chat`,label:(r??i)?.title||C()}}if(t.startsWith(`folder:`)){let e=t.slice(7);return{kind:`folder`,label:(M??[]).find(t=>t._id===e)?.name??``}}return null},St=e=>yt(xt(String(e.active.id))),Tt=(0,X.useCallback)(e=>{let t=String(e.active.id).startsWith(`folder:`),n=t=>({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(t))}),r=F(n(`into:`));if(r.length>0){if(!t)return r;let n=r[0],i=e.droppableRects.get(n.id),a=e.pointerCoordinates?.y;if(i&&a!=null){let e=i.height*.3;if(a>i.top+e&&a<i.top+i.height-e)return r}}let i=F(n(t?`folder:`:`chat:`));if(i.length>0)return i;let a=F(n(`crumb:`));if(a.length>0)return a;let o=F(n(`col:`));return o.length>0?o:je(n(t?`folder:`:`chat:`))},[]),Dt=t=>{if(T===`columns`){for(let e of O?.columns??[])if(e.chats.some(e=>e._id===t))return{list:e.chats,folderId:e.folderId};return null}if(T===`list`){let e=k?.chats.find(e=>e._id===t);return e?{list:k.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(T===`columns`){for(let e of O?.columns??[])if(e.folders.some(e=>e._id===t))return{list:e.folders,parentId:e.folderId};return null}if(T===`list`){let e=k?.folders.find(e=>e._id===t);if(!e||!k)return null;let n=e.parentId??k.rootId;return{list:Ne(k.folders,e.parentId),parentId:n}}return e.children.some(e=>e._id===t)?{list:e.children,parentId:e.project._id}:null},At=async e=>{yt(null),_t();let{active:t,over:n}=e;if(!n)return;let r=String(n.id),i=String(t.id),a=i.startsWith(`chat:`);try{let e=bt(r);if(e!==void 0){if(a)await b({chatId:i.slice(5),projectId:e});else{let t=i.slice(7);if(t===e)return;if(!Ge(M??[],t,e)){s.error(ae());return}await y({projectId:t,parentId:e})}return}if(a&&r.startsWith(`chat:`)){let e=i.slice(5),t=r.slice(5);if(e===t)return;let n=Dt(t);if(!n)return;n.list.some(t=>t._id===e)||await b({chatId:e,projectId:n.folderId});let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await x({chatId:e,...a});return}if(!a&&r.startsWith(`folder:`)){let e=i.slice(7),t=r.slice(7);if(e===t)return;let n=kt(t);if(!n)return;if(!n.list.some(t=>t._id===e)){if(!Ge(M??[],e,n.parentId)){s.error(ae());return}await y({projectId:e,parentId:n.parentId})}let a=pt(n.list,e=>e._id,e=>e.sortKey,e,t);a&&await te({projectId:e,...a});return}}catch{s.error(ae())}},[,Mt]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=window.setInterval(()=>Mt(e=>e+1),6e4);return()=>window.clearInterval(e)},[]);let Nt=Date.now(),Pt=H(e.project),Ft=ft(e.chats,B),It=e.breadcrumb.slice(0,-1),Lt=e=>()=>{$.current||e()};return(0,Z.jsxs)(Ue,{sensors:dt,collisionDetection:Tt,onDragStart:St,onDragEnd:At,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__body`,style:{"--proj-hue":Pt},children:[(0,Z.jsxs)(`nav`,{className:`oc-projpage__crumbs`,"aria-label":re(),children:[It.map(e=>(0,Z.jsxs)(`span`,{className:`oc-projpage__crumb`,children:[(0,Z.jsx)(Ct,{folderId:e._id,children:(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__crumblink`,onClick:Lt(()=>void t({to:`/project/$projectId`,params:{projectId:e._id}})),children:e.name})}),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbsep`,"aria-hidden":!0,children:`›`})]},e._id)),(0,Z.jsx)(`span`,{className:`oc-projpage__crumbcur`,children:e.project.name})]}),(0,Z.jsxs)(`header`,{className:`oc-projpage__head`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__dot`,"aria-hidden":!0}),(0,Z.jsx)(`h1`,{className:`oc-projpage__title`,children:e.project.name}),(0,Z.jsxs)(`div`,{className:`oc-projpage__actions`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__viewtoggle`,role:`group`,"aria-label":f(),children:[(0,Z.jsx)(P,{variant:T===`cards`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":f(),title:f(),"aria-pressed":T===`cards`,onClick:()=>E(`cards`),children:(0,Z.jsx)(lt,{})}),(0,Z.jsx)(P,{variant:T===`columns`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":oe(),title:oe(),"aria-pressed":T===`columns`,onClick:()=>E(`columns`),children:(0,Z.jsx)(st,{})}),(0,Z.jsx)(P,{variant:T===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":ie(),title:ie(),"aria-pressed":T===`list`,onClick:()=>E(`list`),children:(0,Z.jsx)(Ee,{})})]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>void Le({projectId:e.project._id}),children:[(0,Z.jsx)(it,{}),u()]}),(0,Z.jsxs)(P,{variant:`outline`,size:`sm`,onClick:async()=>{let t=await o({title:a(),label:be(),placeholder:xe(),confirmLabel:pe()});t&&await v({name:t,parentId:e.project._id})},children:[(0,Z.jsx)(ke,{}),a()]}),(0,Z.jsxs)(Be,{children:[(0,Z.jsx)(ze,{asChild:!0,children:(0,Z.jsx)(P,{variant:`ghost`,size:`icon-sm`,"aria-label":ue(),children:(0,Z.jsx)(Me,{})})}),(0,Z.jsxs)(Ve,{align:`end`,className:`w-48`,children:[(0,Z.jsxs)(R,{onSelect:()=>{W(e.project.name),V(!0)},children:[(0,Z.jsx)(rt,{}),` `,w()]}),(0,Z.jsxs)(R,{onSelect:()=>$e(!0),children:[(0,Z.jsx)(ct,{}),` `,ne()]}),(0,Z.jsx)(Ie,{children:fe()}),(0,Z.jsxs)(`div`,{className:`oc-colorgrid`,children:[(0,Z.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void l({projectId:e.project._id,color:null}),"aria-label":Se(),children:`✕`}),tt.map(t=>(0,Z.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.project.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void l({projectId:e.project._id,color:t.value})},t.value))]}),(0,Z.jsx)(Re,{}),(0,Z.jsxs)(R,{variant:`destructive`,onSelect:()=>{let i=e.project.parentId;requestAnimationFrame(async()=>{let a=ce?.folders??0,o=ce?.chats??0;await n({title:ee({name:e.project.name}),description:a>0?se({folders:a,chats:o}):o>0?le({count:o}):he(),confirmWord:D(),confirmLabel:r(),destructive:!0})&&(await h({projectId:e.project._id}),t(i===null?{to:`/`}:{to:`/project/$projectId`,params:{projectId:i}}))})},children:[(0,Z.jsx)(Qe,{}),` `,D()]})]})]})]})]}),T===`columns`?(0,Z.jsx)(jt,{data:O,currentId:e.project._id,busyIds:N,suppressClick:$,locateChatId:A??null}):T===`list`?(0,Z.jsx)(Ot,{data:k,busyIds:N,suppressClick:$,locateChatId:A??null}):(0,Z.jsxs)(Z.Fragment,{children:[e.children.length>0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:g()}),(0,Z.jsx)(`div`,{className:`oc-projpage__cards`,children:(0,Z.jsx)(q,{items:e.children.map(e=>`folder:${e._id}`),strategy:ot,children:e.children.map(t=>(0,Z.jsx)(wt,{child:t,parentId:e.project._id,now:Nt,suppressClick:$},t._id))})})]}):null,(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsxs)(`div`,{className:`oc-projpage__convhead`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:m()}),e.chats.length>0?(0,Z.jsx)(K,{value:B,onChange:e=>Xe(e.target.value),placeholder:_(),className:`oc-projpage__filter`}):null]}),e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:e.children.length===0?i():ye()}):Ft.length===0&&(Q??[]).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve({term:B.trim()})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:(0,Z.jsx)(q,{items:Ft.map(e=>`chat:${e._id}`),strategy:Y,children:Ft.map(t=>(0,Z.jsx)(Et,{chat:t,currentFolderId:e.project._id,now:Nt,busy:N.has(t._id),unread:Te.has(t._id),locate:t._id===A,suppressClick:$},t._id))})})]}),J.length>=2&&Q!==void 0?(0,Z.jsxs)(`section`,{className:`oc-projpage__section`,children:[(0,Z.jsx)(`h2`,{className:`oc-projpage__subtitle`,children:me()}),Q.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:ve({term:J})}):(0,Z.jsx)(`ul`,{className:`oc-projpage__chats`,children:Q.map(e=>(0,Z.jsx)(`li`,{className:`oc-projpage__chatrow`,children:(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__chatbtn`,onClick:()=>{e.messageId&&J&&Pe(e.messageId,J),t({to:`/chat/$chatId`,params:{chatId:e.chatId},...e.messageId?{search:{m:e.messageId}}:{}})},children:[(0,Z.jsx)(Je,{size:13,"aria-hidden":!0,className:`oc-projpage__hitico`}),(0,Z.jsxs)(`span`,{className:`oc-projpage__hitbody`,children:[(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||d()}),e.projectPath&&e.projectPath.length>1?(0,Z.jsx)(`span`,{className:`oc-projpage__hitpath`,children:e.projectPath.join(` › `)}):null,e.snippet?(0,Z.jsx)(`span`,{className:`oc-projpage__hitsnippet`,children:e.snippet}):null]})]})},`${e.chatId}:${e.messageId??`t`}`))})]}):null]}),(0,Z.jsx)(qe,{open:Ze,onOpenChange:V,title:ge(),canSubmit:U.trim().length>0,onSubmit:async()=>{await c({projectId:e.project._id,name:U.trim()}),V(!1)},submitLabel:w(),children:(0,Z.jsx)(K,{value:U,onChange:e=>W(e.target.value),autoFocus:!0})}),G?(0,Z.jsx)(nt,{open:G,onOpenChange:$e,title:de(),movingFolderId:e.project._id,currentId:e.project.parentId,onPick:t=>void y({projectId:e.project._id,parentId:t})}):null,I]}),(0,Z.jsx)(Oe,{children:vt?(0,Z.jsxs)(`div`,{className:`oc-projpage__dragghost`,children:[vt.kind===`folder`?(0,Z.jsx)(z,{size:13,"aria-hidden":!0}):(0,Z.jsx)(Je,{size:13,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:vt.label})]}):null})]})}function Ct({folderId:e,children:t}){let{setNodeRef:n,isOver:r}=I({id:yt(e)});return(0,Z.jsx)(`span`,{ref:n,className:r?`oc-projpage__cdrop is-over`:`oc-projpage__cdrop`,children:t})}function wt({child:e,parentId:t,now:n,suppressClick:r}){let i=L(),a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__card`+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&i({to:`/project/$projectId`,params:{projectId:e._id}})},...a.listeners,...a.attributes,role:`link`,tabIndex:0,children:[(0,Z.jsxs)(`span`,{className:`oc-projpage__cardhead`,children:[(0,Z.jsx)(z,{size:15,"aria-hidden":!0,className:`oc-projpage__cardico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__cardname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__cardmenu`,onOpen:()=>void i({to:`/project/$projectId`,params:{projectId:e._id}})})]}),(0,Z.jsxs)(`span`,{className:`oc-projpage__cardmeta`,children:[e.folderCount>0?x({count:e.folderCount})+` · `:``,v({count:e.recursiveChatCount})]}),e.lastActivityAt===null?null:(0,Z.jsx)(`span`,{className:`oc-projpage__cardage`,children:Ze(e.lastActivityAt,n)})]})}function Tt({chat:e}){let t=p(j.chats.setChatSidebar),n=e.inSidebar?h():k();return(0,Z.jsx)(P,{variant:`ghost`,size:`icon-xs`,"aria-label":n,title:n,className:`oc-projpage__barbtn`+(e.inSidebar?` is-on`:``),disabled:e.pinned&&e.inSidebar,onClick:n=>{n.stopPropagation(),t({chatId:e._id,hidden:e.inSidebar})},children:e.inSidebar?(0,Z.jsx)(W,{}):(0,Z.jsx)(ut,{})})}function Et({chat:e,currentFolderId:t,now:n,busy:r,unread:i,locate:a,suppressClick:o}){let s=L(),c=U(e.color),l=B({id:`chat:${e._id}`}),u=Dt(a);return(0,Z.jsxs)(`li`,{ref:e=>{l.setNodeRef(e),u.current=e},className:`oc-projpage__chatrow`+(l.isDragging?` is-dragging`:``)+(a?` is-locate`:``),style:{transform:G.Transform.toString(l.transform),transition:l.transition},children:[(0,Z.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,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__chattitle`,children:e.title||C()}),e.pinned?(0,Z.jsx)(V,{size:12,"aria-hidden":!0,className:`oc-projpage__chatpin`}):null,(0,Z.jsx)(`span`,{className:`oc-projpage__chatage`,children:Ze(e.updatedAt,n)}),r?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,title:A(),"aria-label":A()}):null,i&&!r?(0,Z.jsx)(`span`,{className:`oc-chatitem__unread`,title:M(),"aria-label":M()}):null]}),(0,Z.jsx)(Tt,{chat:e}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__chatmenu`})]})}function Dt(e){let t=(0,X.useRef)(null);return(0,X.useEffect)(()=>{e&&t.current&&t.current.scrollIntoView({block:`center`})},[e]),t}function Ot({data:e,busyIds:t,suppressClick:n,locateChatId:r}){let[a,o]=(0,X.useState)(new Set),s=(0,X.useMemo)(()=>{let t=new Map;for(let n of e?.chats??[]){let e=t.get(n.folderId);e===void 0?t.set(n.folderId,[n]):e.push(n)}return t},[e]);if(e===void 0)return(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()});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}),l=(i,o)=>{let u=s.get(i??e.rootId)??[],d=Ne(e.folders,i);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{items:u.map(e=>`chat:${e._id}`),strategy:Y,children:u.map(e=>(0,Z.jsx)(At,{chat:e,depth:o,busy:t.has(e._id),locate:e._id===r,suppressClick:n},e._id))}),(0,Z.jsx)(q,{items:d.map(e=>`folder:${e._id}`),strategy:Y,children:d.map(t=>(0,Z.jsx)(kt,{folder:t,parentId:i??e.rootId,depth:o,folded:a.has(t._id),onToggle:()=>c(t._id),suppressClick:n,children:a.has(t._id)?null:l(t._id,o+1)},t._id))})]})};return(0,Z.jsx)(`div`,{className:`oc-projpage__tree`,children:(s.get(e.rootId)??[]).length===0&&Ne(e.folders,null).length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:i()}):l(null,0)})}function kt({folder:e,parentId:t,depth:n,folded:r,onToggle:i,suppressClick:a,children:o}){let s=L(),c=B({id:`folder:${e._id}`}),l=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{className:`oc-projpage__treegroup`,children:[(0,Z.jsxs)(`div`,{ref:e=>{c.setNodeRef(e),l.setNodeRef(e)},className:`oc-projpage__treerow oc-projpage__treerow--folder`+(l.isOver?` is-over`:``)+(c.isDragging?` is-dragging`:``),style:{"--tree-depth":n,"--proj-hue":H(e),transform:G.Transform.toString(c.transform),transition:c.transition},...c.listeners,...c.attributes,role:`button`,tabIndex:0,onClick:()=>{a.current||s({to:`/project/$projectId`,params:{projectId:e._id}})},onKeyDown:t=>{t.key===`Enter`&&s({to:`/project/$projectId`,params:{projectId:e._id}})},children:[(0,Z.jsx)(`button`,{type:`button`,className:`oc-projpage__treechev`,"aria-label":r?we():te(),"aria-expanded":!r,onClick:e=>{e.stopPropagation(),!a.current&&i()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:r?(0,Z.jsx)($e,{size:13}):(0,Z.jsx)(Te,{size:13})}),(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__treemenu`,onOpen:()=>void s({to:`/project/$projectId`,params:{projectId:e._id}})})]}),o]})}function At({chat:e,depth:t,busy:n,locate:r,suppressClick:i}){let a=L(),o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__treerow oc-projpage__treerow--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{"--tree-depth":t,transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a({to:`/chat/$chatId`,params:{chatId:e._id}})},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||C()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:e.folderId,className:`oc-projpage__treemenu`}),(0,Z.jsx)(Tt,{chat:e})]})}function jt({data:e,currentId:t,busyIds:n,suppressClick:r,locateChatId:i}){let a=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let e=a.current;e&&(e.scrollLeft=e.scrollWidth)},[e?.columns.length??0,t]),e===void 0?(0,Z.jsx)(`p`,{className:`oc-projpage__hint`,children:b()}):(0,Z.jsx)(`div`,{className:`oc-projpage__cols`,ref:a,children:e.columns.map((a,o)=>(0,Z.jsx)(Mt,{col:a,isLast:o===e.columns.length-1,currentId:t,busyIds:n,suppressClick:r,locateChatId:i},a.folderId??`root`))})}function Mt({col:e,isLast:t,currentId:n,busyIds:r,suppressClick:i,locateChatId:a}){let o=L(),s=I({id:vt(e.folderId)});return(0,Z.jsxs)(`div`,{ref:s.setNodeRef,className:`oc-projpage__col`+(s.isOver?` is-over`:``)+(t?` is-last`:``),children:[(0,Z.jsx)(q,{items:e.folders.map(e=>`folder:${e._id}`),strategy:Y,children:e.folders.map(t=>(0,Z.jsx)(Nt,{folder:t,parentId:e.folderId,isCurrent:t._id===n,suppressClick:i,onOpen:()=>void o({to:`/project/$projectId`,params:{projectId:t._id}})},t._id))}),(0,Z.jsx)(q,{items:e.chats.map(e=>`chat:${e._id}`),strategy:Y,children:e.chats.map(t=>(0,Z.jsx)(Pt,{chat:t,folderId:e.folderId,busy:r.has(t._id),locate:t._id===a,suppressClick:i,onOpen:()=>void o({to:`/chat/$chatId`,params:{chatId:t._id}})},t._id))}),e.folders.length===0&&e.chats.length===0?(0,Z.jsx)(`p`,{className:`oc-projpage__colempty`,children:ye()}):null]})}function Nt({folder:e,parentId:t,isCurrent:n,suppressClick:r,onOpen:i}){let a=B({id:`folder:${e._id}`}),o=I({id:_t(e._id)});return(0,Z.jsxs)(`div`,{ref:e=>{a.setNodeRef(e),o.setNodeRef(e)},className:`oc-projpage__colentry oc-projpage__colentry--folder`+(e.selected||n?` is-selected`:``)+(o.isOver?` is-over`:``)+(a.isDragging?` is-dragging`:``),style:{"--proj-hue":H(e),transform:G.Transform.toString(a.transform),transition:a.transition},onClick:()=>{r.current||i()},onKeyDown:e=>{e.key===`Enter`&&e.target===e.currentTarget&&i()},...a.listeners,...a.attributes,role:`button`,tabIndex:0,children:[(0,Z.jsx)(z,{size:13,"aria-hidden":!0,className:`oc-projpage__colico`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.name}),(0,Z.jsx)(`span`,{className:`oc-projpage__colchev`,"aria-hidden":!0,children:`›`}),(0,Z.jsx)(dt,{folderId:e._id,name:e.name,color:e.color,currentParentId:t,className:`oc-projpage__colmenu`,onOpen:i})]})}function Pt({chat:e,folderId:t,busy:n,locate:r,suppressClick:i,onOpen:a}){let o=B({id:`chat:${e._id}`}),s=Dt(r),c=U(e.color);return(0,Z.jsxs)(`div`,{ref:e=>{o.setNodeRef(e),s.current=e},className:`oc-projpage__colentry oc-projpage__colentry--chat`+(o.isDragging?` is-dragging`:``)+(r?` is-locate`:``),style:{transform:G.Transform.toString(o.transform),transition:o.transition},children:[(0,Z.jsxs)(`button`,{type:`button`,className:`oc-projpage__colchatbtn`,onClick:()=>{i.current||a()},...o.listeners,...o.attributes,children:[c?(0,Z.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:c}}):(0,Z.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,Z.jsx)(`span`,{className:`oc-projpage__colname`,children:e.title||C()}),n?(0,Z.jsx)(`span`,{className:`oc-chatitem__busy`,"aria-hidden":!0}):null]}),(0,Z.jsx)($,{chat:e,currentFolderId:t,className:`oc-projpage__colmenu oc-projpage__colmenu--chat`}),(0,Z.jsx)(Tt,{chat:e})]})}export{xt as ProjectPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,l as t,r as n}from"./bundle-mjs-C73ZY4La.js";import{Ay as r,Bo as i,Gi as a,HL as o,Ho as s,Ji as c,Ki as l,Sy as u,UL as d,Uo as f,Vo as p,Yi as m,_r as ee,_y as h,aa as g,ay as _,by as v,cy as y,dy as b,fy as x,gr as S,gy as C,hr as te,hy as ne,ia as re,iy as ie,ky as w,ly as ae,my as oe,na as se,oy as ce,py as T,qi as E,ra as D,ry as O,sy as k,t as A,uy as j,vy as M,xy as N,yy as P,zo as F}from"./api-CZm__5my.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{Ay as r,Bo as i,Gi as a,HL as o,Ho as s,Ji as c,Ki as l,Sy as u,UL as d,Uo as f,Vo as p,Yi as m,_r as ee,_y as h,aa as g,ay as _,by as v,cy as y,dy as b,fy as x,gr as S,gy as C,hr as te,hy as ne,ia as re,iy as ie,ky as w,ly as ae,my as oe,na as se,oy as ce,py as T,qi as E,ra as D,ry as O,sy as k,t as A,uy as j,vy as M,xy as N,yy as P,zo as F}from"./api-CZm__5my.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-TkK78Rxe.js";import{t as U}from"./button-DMpgqct_.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-DI3wVm5g.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:h,help:C},documentary_fetch:{label:ne,help:oe},inbound_files:{label:T,help:x},history_summary:{label:f,help:s},file_curation:{label:g,help:m},quote_reply:{label:re,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:_,references:ie,files:O,previous_summary:p,new_messages:i,max_chars:F,file_name:c,budget_chars:E,feedback:l,content:a,excerpt:se};function ge(){let e=d(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:j()})});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:u(),help:N()}),(0,Q.jsxs)(`label`,{className:`oc-injtab__picker`,children:[(0,Q.jsx)(`span`,{children:b()}),(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=o(A.admin.upsertInstanceConfig),n=W(),i=d(A.me.getMe,{host:de}),a=e.config??{},s=X(e.config?.contentLocale,i?.defaultLocale??void 0),[c,l]=(0,Z.useState)(()=>R(a,s));(0,Z.useEffect)(()=>{l(R(a,s))},[s,e._id]);let[u,f]=(0,Z.useState)(!1),p=c.promptInjections,m=(e,t)=>l({...c,promptInjections:{...p,[e]:{...p[e],...t}}});async function h(){f(!0);try{await t({instanceId:e._id,config:le(c,a,s)})}catch(e){n.error(w(),e)}finally{f(!1)}}async function g(r){let i={...e.config??{}};r==="default"?delete i.contentLocale:i.contentLocale=r;try{await t({instanceId:e._id,config:i})}catch(e){n.error(w(),e)}}let _=e.config?.contentLocale??`default`,v=fe[X(void 0,i?.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:ee()}),(0,Q.jsxs)(G,{value:_,onValueChange:e=>void g(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:te({locale:v})}),pe().map(e=>(0,Q.jsx)(Y,{value:e.value,children:e.label},e.value))]})]}),(0,Q.jsx)(`p`,{className:`oc-admin__hint`,children:S()})]}),H.map(e=>(0,Q.jsx)(ve,{injKey:e,def:z[e],i18n:$[e],row:p[e]??{enabled:!0,template:z[e].defaultTemplate[s]},contentLocale:s,onChange:t=>m(e,t)},e)),(0,Q.jsx)(`div`,{className:`oc-injtab__actions`,children:(0,Q.jsx)(U,{size:`sm`,onClick:()=>void h(),disabled:u,children:r()})})]})}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:P()})]}),(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:M()}),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?y():ae()}),c&&(0,Q.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>a({template:t.defaultTemplate[i]}),children:v()})]})]}),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:k()})]}):(0,Q.jsx)(`span`,{className:`oc-injection__ph`,children:ce()})})]})}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 i,FS as ee,GS as a,HL as o,IS as s,JS as c,KS as l,LS as te,MS as u,NS as d,PS as f,QS as p,UL as m,US as h,WS as g,XS as ne,YS as re,ZS as ie,_C as _,aC as v,cC as y,dC as b,eC as ae,fC as x,gC as S,hC 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,vC as z}from"./api-CZm__5my.js";import{t as B}from"./button-DMpgqct_.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 i,FS as ee,GS as a,HL as o,IS as s,JS as c,KS as l,LS as te,MS as u,NS as d,PS as f,QS as p,UL as m,US as h,WS as g,XS as ne,YS as re,ZS as ie,_C as _,aC as v,cC as y,dC as b,eC as ae,fC as x,gC as S,hC 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,vC as z}from"./api-CZm__5my.js";import{t as B}from"./button-DMpgqct_.js";import{Dt as V,P as H,Z as U,_ as W,jt as G,ut as K,yn as q}from"./index-DI3wVm5g.js";import{t as J}from"./roleDescriptions-Dn4-uXz-.js";var Y=t(e(),1),X=n(),Z=[{group:()=>z(),keys:[{key:`traces.read`,label:()=>M()},{key:`traces.read.content`,label:()=>x(),phi:!0},{key:`traces.write`,label:()=>b()}]},{group:()=>_(),keys:[{key:`kpi.read`,label:()=>M()},{key:`kpi.write`,label:()=>b()}]},{group:()=>S(),keys:[{key:`openclaw.query`,label:()=>R()},{key:`anomalies.read`,label:()=>O()},{key:`anomalies.report`,label:()=>y()}]},{group:()=>C(),keys:[{key:`chats.read`,label:()=>M()},{key:`selfheal`,label:()=>j()},{key:`feedback.respond`,label:()=>D()}]},{group:()=>k(),keys:[{key:`admin.manage`,label:()=>F()}]}],oe=Z.flatMap(e=>e.keys.map(e=>e.key));function Q(e){return e.includes(`*`)}var $={key:``,name:``,description:``};function se(){let e=m(I.apiKeys.listRoles,{}),t=o(I.apiKeys.createRole),n=o(I.apiKeys.ensureRolesSeeded),_=o(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))}),y=U(),b=V(),[x,S]=(0,Y.useState)(!1),[C,D]=(0,Y.useState)($),[O,k]=(0,Y.useState)(new Set);(0,Y.useEffect)(()=>{n({}).catch(e=>{b.error(w(),e)})},[n,b]);let j=e??[];async function M(e,t){if(Q(e.permissions))return;if(e.builtin){await y({title:P({name:e.name}),description:A(),confirmLabel:L()});return}if(O.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];k(t=>new Set(t).add(e._id));try{await _({roleId:e._id,permissions:n})}catch(e){b.error(ae(),e)}finally{k(t=>{let n=new Set(t);return n.delete(e._id),n})}}async function F(){try{await t({key:C.key,name:C.name,description:C.description||void 0,permissions:[]}),D($),S(!1)}catch(e){b.error(r(),e)}}let R=e===void 0,z=!R&&j.length===0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`oc-admin__hint`,children:[p(),` `,(0,X.jsx)(`code`,{children:`admin`}),` `,ie(),` `,(0,X.jsx)(`code`,{children:`traces.read.content`}),` `,ne()]}),(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:re()}),(0,X.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,X.jsx)(B,{size:`sm`,onClick:()=>{D($),S(!0)},children:c()})})]}),R?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:N()}):z?(0,X.jsx)(`p`,{className:`oc-admin__hint`,children:l()}):(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:a()}),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?v({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=O.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,{}),` `,g()]}):(0,X.jsx)(K,{variant:`secondary`,children:h()})]}),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?te():n?s():r,onCheckedChange:()=>void M(e,r)})},r))]},e.key)})})]})})]}),(0,X.jsx)(W,{open:x,onOpenChange:S,title:ee(),description:f(),canSubmit:!!(C.key&&C.name),onSubmit:F,submitLabel:d(),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:u()}),(0,X.jsx)(G,{value:C.key,placeholder:T(),onChange:e=>D({...C,key:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:i()}),(0,X.jsx)(G,{value:C.name,onChange:e=>D({...C,name:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`oc-field`,children:[(0,X.jsx)(`span`,{className:`oc-field__label`,children:E()}),(0,X.jsx)(G,{value:C.description,onChange:e=>D({...C,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,AP as a,BF as o,BL as s,CF as c,CP as l,D as u,DF as ee,DP as d,EP as f,FF as p,FP as m,IL as h,IP as g,LF as te,LP as ne,MF as re,MP as ie,NF as ae,NP as oe,OF as se,OP as ce,PF as le,PL as ue,PP as de,QP as fe,RF as pe,RP as me,SF as he,SP as ge,TP as _e,UL as ve,VF as ye,XP as _,YP as be,ZP as xe,_F as Se,_I as Ce,aF as v,aI as we,bF as Te,cF as Ee,cI as De,dI as Oe,eF as ke,fI as Ae,gF as je,gI as Me,gP as Ne,hF as Pe,hI as Fe,iF as Ie,iI as Le,jF as Re,jP as ze,kF as Be,kP as Ve,lF as He,lI as Ue,mI as We,nF as Ge,oF as y,oI as Ke,pI as qe,rF as Je,sF as Ye,sI as Xe,t as b,tF as x,uF as Ze,uI as Qe,vF as $e,vI as et,wP as tt,xF as nt,yF as rt,zF as it,zP as at}from"./api-CZm__5my.js";import{t as ot}from"./list-Bb-2S9oG.js";import{t as S}from"./button-DMpgqct_.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-C6y-Zg32.js";import{a as Nt,i as P,n as Pt,o as Ft,r as F,t as It}from"./table-CwZjj3ZU.js";import{t as Lt}from"./FilterBar-DlTMnvB-.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-DAcSoa-v.js";var Gt=u(`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=u(`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)),m=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},g=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},te=n===null?He():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,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":Ze(),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:te})]})}),(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":Ee(),onClick:()=>g(-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":Ye(),onClick:()=>g(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:()=>m(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":y(),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":v(),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:i,onCursorChange:a,onEventClick:o,footnote:s}){let c=h(),l=(0,R.useMemo)(()=>Yt(e),[e]),u=(0,R.useMemo)(()=>Xt(c),[c]),ee=(0,R.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),d=(0,R.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),f=(0,R.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),p=new Date,m=e=>{if(t===`year`){a({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);a({year:r.getFullYear(),month:r.getMonth()})},g=t===`year`?String(n.year):ee.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":fe(),onClick:()=>m(-1),children:(0,z.jsx)(w,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":xe(),onClick:()=>m(1),children:(0,z.jsx)(O,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>a({year:p.getFullYear(),month:p.getMonth()}),children:r()})]}),(0,z.jsx)(`span`,{className:`oc-cal__title`,children:g}),(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:()=>i(`month`),children:x()}),(0,z.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>i(`year`),children:ke()})]})]}),t===`month`?(0,z.jsx)(en,{cursor:n,byDay:l,weekdays:u,timeFmt:f,now:p,onEventClick:o}):(0,z.jsx)(tn,{year:n.year,byDay:l,monthShortFmt:d,now:p,onOpenMonth:e=>{a({year:n.year,month:e}),i(`month`)}}),s?(0,z.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):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:_({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:he()});case`error`:return(0,z.jsx)(k,{variant:`destructive`,children:nt()});case`running`:return(0,z.jsx)(k,{variant:`outline`,children:Te()});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=s(b.scheduled.listMyCrons),t=s(b.scheduled.getCronDetail),n=s(b.scheduled.listCronRuns),r=s(b.scheduled.updateCron),u=s(b.scheduled.removeCron),fe=s(b.scheduled.runCronNow),_=ct(),xe=ve(b.me.getMe,{host:Mt})?.timezone,[v,Ee]=(0,R.useState)(null),[ke,He]=(0,R.useState)(!1),[y,Ye]=(0,R.useState)(!1),[x,Ze]=(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 v??[]){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},[v,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()=>{He(!0),Ye(!1);try{Ee(await e({}))}catch{Ye(!0)}finally{He(!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)(()=>{v!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[v]);let Y=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{Ze(e);try{await t(),_.success(n),await K()}catch(e){_.toast({variant:`error`,title:p({code:on(e)})})}finally{Ze(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),_.toast({variant:`error`,title:p({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),_.toast({variant:`error`,title:p({code:on(e)})})}},ln=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){_.toast({variant:`error`,title:ge()});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){_.toast({variant:`error`,title:l()});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 r({instanceName:N.instanceName,jobId:N.jobId,patch:e}),_.success(g()),t===Q.current&&I(null),await K()}catch(e){_.toast({variant:`error`,title:p({code:on(e)})})}finally{Bt(!1)}},un=v?.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:et()}),(0,z.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Ie(),children:[(0,z.jsx)(S,{variant:V===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Je(),title:Je(),"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":Ge(),title:Ge(),"aria-pressed":V===`calendar`,onClick:()=>Yt(`calendar`),children:(0,z.jsx)(Gt,{})})]}),(0,z.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:ke,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,z.jsx)(pt,{size:14,"aria-hidden":!0}),Ce()]})]}),v!==null&&un>0?(0,z.jsxs)(Lt,{q:L.q,onQChange:e=>B(t=>({...t,q:e})),searchPlaceholder:$e(),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:Se()}),(0,z.jsx)(M,{value:`active`,children:Le()}),(0,z.jsx)(M,{value:`paused`,children:we()})]})]}),(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:je()}),(0,z.jsx)(M,{value:`ok`,children:he()}),(0,z.jsx)(M,{value:`error`,children:nt()}),(0,z.jsx)(M,{value:`running`,children:Te()}),(0,z.jsx)(M,{value:`none`,children:rt()})]})]})]}):null,v===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":ke,children:y?Me():ue()}):V===`calendar`?(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):null,v.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Fe()}):(0,z.jsx)($t,{events:nn.events,mode:H,cursor:U,onModeChange:Xt,onCursorChange:en,onEventClick:G,footnote:be()})]}):(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):null,v.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Fe()}):null,v.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:[v.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:qe({code:e.error})}):e.jobs.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ae()}):n?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,z.jsxs)(It,{children:[(0,z.jsx)(Nt,{children:(0,z.jsxs)(Ft,{children:[(0,z.jsx)(P,{children:Oe()}),(0,z.jsx)(P,{children:Qe()}),(0,z.jsx)(P,{children:Ue()}),(0,z.jsx)(P,{children:De()}),(0,z.jsx)(P,{children:Xe()}),(0,z.jsx)(P,{children:c()}),(0,z.jsx)(P,{children:at()})]})}),(0,z.jsx)(Pt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=x===i,s=e.manageSupported,c=e.kind===`openclaw`&&s;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??Ke()}),(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:Le()}):Ht(t.enabled)===`paused`?(0,z.jsx)(k,{variant:`outline`,children:we()}):(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:[c?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:o(),"aria-label":o(),disabled:x!==null,onClick:()=>void X(i,async()=>{let n=await fe({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},le()),children:(0,z.jsx)(kt,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:t.enabled?it():pe(),"aria-label":t.enabled?it():pe(),disabled:x!==null,onClick:()=>void X(i,()=>r({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?ae():re()),children:t.enabled?(0,z.jsx)(St,{size:14,"aria-hidden":!0}):(0,z.jsx)(jt,{size:14,"aria-hidden":!0})}):null,c?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:me(),"aria-label":me(),disabled:x!==null,onClick:()=>void cn(e.instanceName,t),children:(0,z.jsx)(Et,{size:14,"aria-hidden":!0})}):null,c?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:ne(),"aria-label":ne(),disabled:x!==null,onClick:()=>void rn(e.instanceName,t),children:(0,z.jsx)(Kt,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:te(),"aria-label":te(),disabled:x!==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:We()})]},e.instanceName)}),un>0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ne()}):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:i()}),(0,z.jsx)(Ot,{children:Be({name:C?.name??``})})]}),(0,z.jsxs)(bt,{children:[(0,z.jsx)(At,{children:se()}),(0,z.jsx)(ht,{onClick:()=>{let e=C;w(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>u({instanceName:e.instanceName,jobId:e.jobId}),Re())},children:ee()})]})]})}),(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:m({name:T?.name??``})})}),T?.entries===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):T!==null&&T.entries.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:de()}):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:oe()}),(0,z.jsx)(Dt,{children:ie()})]}),N===null?null:N.loading?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):(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:Oe()}),(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:ze()}),(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:a()}),(0,z.jsx)(M,{value:`every`,children:Ve()}),(0,z.jsx)(M,{value:`at`,children:ce()})]})]}),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:xe??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:d()}),(0,z.jsx)(M,{value:`hours`,children:f()}),(0,z.jsx)(M,{value:`days`,children:_e()})]})]})]}):(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:ye()}),(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:se()}),(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,tt()]})]})]})})]})}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,AP as a,BF as o,BL as s,CF as c,CP as l,D as u,DF as ee,DP as d,EP as f,FF as p,FP as m,IL as h,IP as g,LF as te,LP as ne,MF as re,MP as ie,NF as ae,NP as oe,OF as se,OP as ce,PF as le,PL as ue,PP as de,QP as fe,RF as pe,RP as me,SF as he,SP as ge,TP as _e,UL as ve,VF as ye,XP as _,YP as be,ZP as xe,_F as Se,_I as Ce,aF as v,aI as we,bF as Te,cF as Ee,cI as De,dI as Oe,eF as ke,fI as Ae,gF as je,gI as Me,gP as Ne,hF as Pe,hI as Fe,iF as Ie,iI as Le,jF as Re,jP as ze,kF as Be,kP as Ve,lF as He,lI as Ue,mI as We,nF as Ge,oF as y,oI as Ke,pI as qe,rF as Je,sF as Ye,sI as Xe,t as b,tF as x,uF as Ze,uI as Qe,vF as $e,vI as et,wP as tt,xF as nt,yF as rt,zF as it,zP as at}from"./api-CZm__5my.js";import{t as ot}from"./list-Bb-2S9oG.js";import{t as S}from"./button-DMpgqct_.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-DI3wVm5g.js";import{a as Nt,i as P,n as Pt,o as Ft,r as F,t as It}from"./table-CwZjj3ZU.js";import{t as Lt}from"./FilterBar-BBUyj-UI.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-B6dL9fFG.js";var Gt=u(`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=u(`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)),m=(e,t,n)=>{a({year:e,month:t}),p(e,t,n,d,f)},g=e=>{let t=new Date(i.year,i.month+e,1);a({year:t.getFullYear(),month:t.getMonth()})},te=n===null?He():u.format(new Date(n.year,n.month,n.day,n.hour,n.minute));return(0,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":Ze(),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:te})]})}),(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":Ee(),onClick:()=>g(-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":Ye(),onClick:()=>g(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:()=>m(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":y(),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":v(),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:i,onCursorChange:a,onEventClick:o,footnote:s}){let c=h(),l=(0,R.useMemo)(()=>Yt(e),[e]),u=(0,R.useMemo)(()=>Xt(c),[c]),ee=(0,R.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`,year:`numeric`}),[c]),d=(0,R.useMemo)(()=>new Intl.DateTimeFormat(c,{month:`long`}),[c]),f=(0,R.useMemo)(()=>new Intl.DateTimeFormat(c,{hour:`2-digit`,minute:`2-digit`}),[c]),p=new Date,m=e=>{if(t===`year`){a({year:n.year+e,month:n.month});return}let r=new Date(n.year,n.month+e,1);a({year:r.getFullYear(),month:r.getMonth()})},g=t===`year`?String(n.year):ee.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":fe(),onClick:()=>m(-1),children:(0,z.jsx)(w,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,"aria-label":xe(),onClick:()=>m(1),children:(0,z.jsx)(O,{})}),(0,z.jsx)(S,{variant:`ghost`,size:`sm`,onClick:()=>a({year:p.getFullYear(),month:p.getMonth()}),children:r()})]}),(0,z.jsx)(`span`,{className:`oc-cal__title`,children:g}),(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:()=>i(`month`),children:x()}),(0,z.jsx)(S,{variant:t===`year`?`secondary`:`ghost`,size:`sm`,"aria-pressed":t===`year`,onClick:()=>i(`year`),children:ke()})]})]}),t===`month`?(0,z.jsx)(en,{cursor:n,byDay:l,weekdays:u,timeFmt:f,now:p,onEventClick:o}):(0,z.jsx)(tn,{year:n.year,byDay:l,monthShortFmt:d,now:p,onOpenMonth:e=>{a({year:n.year,month:e}),i(`month`)}}),s?(0,z.jsx)(`p`,{className:`oc-cal__footnote`,children:s}):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:_({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:he()});case`error`:return(0,z.jsx)(k,{variant:`destructive`,children:nt()});case`running`:return(0,z.jsx)(k,{variant:`outline`,children:Te()});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=s(b.scheduled.listMyCrons),t=s(b.scheduled.getCronDetail),n=s(b.scheduled.listCronRuns),r=s(b.scheduled.updateCron),u=s(b.scheduled.removeCron),fe=s(b.scheduled.runCronNow),_=ct(),xe=ve(b.me.getMe,{host:Mt})?.timezone,[v,Ee]=(0,R.useState)(null),[ke,He]=(0,R.useState)(!1),[y,Ye]=(0,R.useState)(!1),[x,Ze]=(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 v??[]){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},[v,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()=>{He(!0),Ye(!1);try{Ee(await e({}))}catch{Ye(!0)}finally{He(!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)(()=>{v!==null&&J.current!==null&&J.current.scrollIntoView({block:`center`})},[v]);let Y=(0,R.useMemo)(()=>new Intl.DateTimeFormat(h(),{dateStyle:`medium`,timeStyle:`short`}),[]),X=async(e,t,n)=>{Ze(e);try{await t(),_.success(n),await K()}catch(e){_.toast({variant:`error`,title:p({code:on(e)})})}finally{Ze(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),_.toast({variant:`error`,title:p({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),_.toast({variant:`error`,title:p({code:on(e)})})}},ln=async()=>{if(N===null)return;let e={};if(N.nameDirty&&N.name.trim()===``||N.messageDirty&&N.hasMessage&&N.message.trim()===``){_.toast({variant:`error`,title:ge()});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){_.toast({variant:`error`,title:l()});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 r({instanceName:N.instanceName,jobId:N.jobId,patch:e}),_.success(g()),t===Q.current&&I(null),await K()}catch(e){_.toast({variant:`error`,title:p({code:on(e)})})}finally{Bt(!1)}},un=v?.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:et()}),(0,z.jsxs)(`div`,{className:`oc-sched__viewtoggle`,role:`group`,"aria-label":Ie(),children:[(0,z.jsx)(S,{variant:V===`list`?`secondary`:`ghost`,size:`icon-sm`,"aria-label":Je(),title:Je(),"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":Ge(),title:Ge(),"aria-pressed":V===`calendar`,onClick:()=>Yt(`calendar`),children:(0,z.jsx)(Gt,{})})]}),(0,z.jsxs)(S,{variant:`ghost`,size:`sm`,onClick:()=>void K(),disabled:ke,style:{display:`inline-flex`,alignItems:`center`,gap:4},children:[(0,z.jsx)(pt,{size:14,"aria-hidden":!0}),Ce()]})]}),v!==null&&un>0?(0,z.jsxs)(Lt,{q:L.q,onQChange:e=>B(t=>({...t,q:e})),searchPlaceholder:$e(),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:Se()}),(0,z.jsx)(M,{value:`active`,children:Le()}),(0,z.jsx)(M,{value:`paused`,children:we()})]})]}),(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:je()}),(0,z.jsx)(M,{value:`ok`,children:he()}),(0,z.jsx)(M,{value:`error`,children:nt()}),(0,z.jsx)(M,{value:`running`,children:Te()}),(0,z.jsx)(M,{value:`none`,children:rt()})]})]})]}):null,v===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,"aria-busy":ke,children:y?Me():ue()}):V===`calendar`?(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):null,v.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Fe()}):(0,z.jsx)($t,{events:nn.events,mode:H,cursor:U,onModeChange:Xt,onCursorChange:en,onEventClick:G,footnote:be()})]}):(0,z.jsxs)(z.Fragment,{children:[y?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Me()}):null,v.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Fe()}):null,v.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:[v.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:qe({code:e.error})}):e.jobs.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Ae()}):n?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:Pe()}):(0,z.jsxs)(It,{children:[(0,z.jsx)(Nt,{children:(0,z.jsxs)(Ft,{children:[(0,z.jsx)(P,{children:Oe()}),(0,z.jsx)(P,{children:Qe()}),(0,z.jsx)(P,{children:Ue()}),(0,z.jsx)(P,{children:De()}),(0,z.jsx)(P,{children:Xe()}),(0,z.jsx)(P,{children:c()}),(0,z.jsx)(P,{children:at()})]})}),(0,z.jsx)(Pt,{children:t.map((t,n)=>{let i=`${e.instanceName}:${t.id??n}`,a=x===i,s=e.manageSupported,c=e.kind===`openclaw`&&s;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??Ke()}),(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:Le()}):Ht(t.enabled)===`paused`?(0,z.jsx)(k,{variant:`outline`,children:we()}):(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:[c?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:o(),"aria-label":o(),disabled:x!==null,onClick:()=>void X(i,async()=>{let n=await fe({instanceName:e.instanceName,jobId:t.id});if(n.ran!==!0&&n.runId===null)throw{data:{code:n.reason??`run_not_started`}}},le()),children:(0,z.jsx)(kt,{size:14,"aria-hidden":!0})}):null,c&&t.enabled!==null?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:t.enabled?it():pe(),"aria-label":t.enabled?it():pe(),disabled:x!==null,onClick:()=>void X(i,()=>r({instanceName:e.instanceName,jobId:t.id,patch:{enabled:!t.enabled}}),t.enabled?ae():re()),children:t.enabled?(0,z.jsx)(St,{size:14,"aria-hidden":!0}):(0,z.jsx)(jt,{size:14,"aria-hidden":!0})}):null,c?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:me(),"aria-label":me(),disabled:x!==null,onClick:()=>void cn(e.instanceName,t),children:(0,z.jsx)(Et,{size:14,"aria-hidden":!0})}):null,c?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:ne(),"aria-label":ne(),disabled:x!==null,onClick:()=>void rn(e.instanceName,t),children:(0,z.jsx)(Kt,{size:14,"aria-hidden":!0})}):null,s?(0,z.jsx)(S,{variant:`ghost`,size:`icon-sm`,title:te(),"aria-label":te(),disabled:x!==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:We()})]},e.instanceName)}),un>0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:4},children:Ne()}):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:i()}),(0,z.jsx)(Ot,{children:Be({name:C?.name??``})})]}),(0,z.jsxs)(bt,{children:[(0,z.jsx)(At,{children:se()}),(0,z.jsx)(ht,{onClick:()=>{let e=C;w(null),e!==null&&X(`${e.instanceName}:${e.jobId}`,()=>u({instanceName:e.instanceName,jobId:e.jobId}),Re())},children:ee()})]})]})}),(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:m({name:T?.name??``})})}),T?.entries===null?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):T!==null&&T.entries.length===0?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:de()}):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:oe()}),(0,z.jsx)(Dt,{children:ie()})]}),N===null?null:N.loading?(0,z.jsx)(`p`,{className:`oc-admin__hint`,children:ue()}):(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:Oe()}),(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:ze()}),(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:a()}),(0,z.jsx)(M,{value:`every`,children:Ve()}),(0,z.jsx)(M,{value:`at`,children:ce()})]})]}),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:xe??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:d()}),(0,z.jsx)(M,{value:`hours`,children:f()}),(0,z.jsx)(M,{value:`days`,children:_e()})]})]})]}):(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:ye()}),(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:se()}),(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,tt()]})]})]})})]})}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,BL as te,Bj as ne,Cj as re,Dj as ie,Ej as ae,Fj as oe,GA as o,Gj as se,HA as s,HL as c,Hj as ce,Ij as le,JA as ue,Jj as de,KA as l,Kj as fe,LA as u,Lj as pe,Mj as me,Nj as he,Oj as ge,Pj as _e,QA as d,Qj as f,RA as p,Rj as ve,Sj as ye,Tj as be,UA as m,UL as h,Uj as xe,VA as Se,Vj as Ce,WA as we,Wj as Te,XA as g,Xj as Ee,YA as _,Yj as De,ZA as v,Zj as y,_j as Oe,aj as b,bj as ke,cj as Ae,dj as je,eM as Me,ej as x,fj as Ne,gj as Pe,hj as Fe,ij as S,jj as Ie,kj as Le,lj as Re,mj as ze,nM as Be,nj as C,oj as w,pj as Ve,qA as T,qj as He,rM as Ue,rj as E,sj as We,t as D,tM as Ge,tj as O,uj as Ke,vj as qe,wj as Je,xj as Ye,yj as Xe,zA as k,zj as Ze}from"./api-CZm__5my.js";import{t as A}from"./check-la1GHs3B.js";import{r as Qe}from"./dist-51K385p9.js";import{t as j}from"./button-DMpgqct_.js";import{Dt as $e,Fn as et,On as tt,Pn as nt,Z as rt,_ as it,_t as M,bt as N,ct as P,dt as F,ft as I,gt as L,ht as R,jn as at,jt as z,mt as B,pt as V,st as H,ut as U,vt as W,xt as G,yt as K}from"./index-C6y-Zg32.js";import{t as ot}from"./FilterBar-DlTMnvB-.js";import{t as st}from"./DataTableShell-BmkE6ZKo.js";import{t as ct}from"./roleDescriptions-Dn4-uXz-.js";var q=t(e(),1),J=n(),Y=[{value:`never`,label:()=>m(),days:null},{value:`30`,label:()=>s(),days:30},{value:`90`,label:()=>Se(),days:90}],X=720*60*60*1e3,Z=`__all__`,Q={name:``,roleKey:``,description:``};function $(){let e=et({from:`/settings/serviceAccounts`}),t=nt({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??Z,[a,o]=(0,q.useState)(Z),s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),ue=e=>void t({search:t=>({...t,status:e===Z?void 0:e})}),l=h(D.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===Z?void 0:a,disabled:r===Z?void 0:r===`disabled`}}),u=h(D.apiKeys.listKeys,{}),d=h(D.apiKeys.listRoles,{}),p=c(D.apiKeys.createServiceAccount),m=c(D.apiKeys.updateServiceAccount),Se=c(D.apiKeys.deleteServiceAccount),we=te(D.apiKeys.mintApiKey),g=c(D.apiKeys.revokeApiKey),_=rt(),v=$e(),b=n!==``||a!==Z||r!==Z;function x(){o(Z),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Q),[E,O]=(0,q.useState)(null),[k,A]=(0,q.useState)(new Set),[tt,P]=(0,q.useState)(null),F=(0,q.useRef)(!1),[I,L]=(0,q.useState)(new Set),[R,B]=(0,q.useState)({}),[V,H]=(0,q.useState)(null),X=(0,q.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 $(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function dt(){try{E?(await m({serviceAccountId:E,name:w.name,roleKey:w.roleKey,description:w.description}),v.success(Ye())):await p({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Q),O(null),C(!1)}catch(e){v.error(E?ye():re(),e)}}function ft(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),O(e._id),C(!0)}async function pt(e){if(F.current)return;F.current=!0;let t=R[e._id]??`never`,n=Y.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;P(e._id);try{let t=await we({serviceAccountId:e._id,expiresAt:r});H({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){v.error(ke(),e)}finally{F.current=!1,P(null)}}async function mt(e){if(await _({title:Xe(),description:(0,J.jsxs)(J.Fragment,{children:[qe(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Oe(),` `,(0,J.jsx)(`strong`,{children:Pe()}),` `,Fe()]}),confirmWord:e.name,confirmLabel:ze(),destructive:!0}))try{await Se({serviceAccountId:e._id}),v.success(Ve(),e.name)}catch(e){v.error(Ne(),e)}}async function ht(e){if(await _({title:je(),description:(0,J.jsxs)(J.Fragment,{children:[Ke(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Re()]}),confirmLabel:Ae(),destructive:!0})&&!I.has(e._id)){L(t=>new Set(t).add(e._id));try{await g({keyId:e._id})}catch(e){v.error(We(),e)}finally{L(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Ue()}),(0,J.jsxs)(ot,{q:n,onQChange:s,searchPlaceholder:Be(),onReset:x,canReset:b,children:[(0,J.jsxs)(M,{value:a,onValueChange:o,children:[(0,J.jsx)(N,{size:`sm`,className:`w-40`,children:(0,J.jsx)(G,{placeholder:Ge()})}),(0,J.jsxs)(W,{children:[(0,J.jsx)(K,{value:Z,children:Me()}),(d??[]).map(e=>(0,J.jsx)(K,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(M,{value:r,onValueChange:ue,children:[(0,J.jsx)(N,{size:`sm`,className:`w-36`,children:(0,J.jsx)(G,{})}),(0,J.jsxs)(W,{children:[(0,J.jsx)(K,{value:Z,children:i()}),(0,J.jsx)(K,{value:`active`,children:f()}),(0,J.jsx)(K,{value:`disabled`,children:y()})]})]})]}),(0,J.jsx)(st,{title:Ee(),rows:l,addLabel:De(),onAdd:()=>{T(Q),O(null),C(!0)},emptyHint:de(),isExpanded:e=>k.has(e._id),renderExpanded:e=>(0,J.jsx)(lt,{account:e,keys:X.get(e._id)??[],onRevoke:ht,revoking:I}),rowActions:e=>[{label:Te(),onSelect:()=>ft(e)},{label:He(),onSelect:()=>void pt(e)},{label:k.has(e._id)?fe():se(),onSelect:()=>$(e._id)},{label:xe(),variant:`destructive`,onSelect:()=>void mt(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":k.has(e._id)?ce():Ce(),onClick:()=>$(e._id),children:k.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(at,{})})},{header:ne(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:Ze(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})},{header:ve(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:y()}):(0,J.jsx)(U,{variant:`outline`,children:f()})},{header:pe(),cell:e=>(0,J.jsxs)(M,{value:R[e._id]??`never`,onValueChange:t=>B(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(N,{size:`sm`,className:`w-32`,children:(0,J.jsx)(G,{})}),(0,J.jsx)(W,{children:Y.map(e=>(0,J.jsx)(K,{value:e.value,children:e.label()},e.value))})]})},{header:le(),sort:e=>(X.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(X.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:tt===e._id?oe():_e({count:t})})}}]}),(0,J.jsx)(it,{open:S,onOpenChange:e=>{C(e),e||O(null)},title:E?he():ee(),description:E?me():Le(),canSubmit:!!(w.name&&w.roleKey),onSubmit:dt,submitLabel:E?Ie():ge(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ie()}),(0,J.jsx)(z,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ae()}),(0,J.jsxs)(M,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(N,{className:`w-full`,children:(0,J.jsx)(G,{placeholder:be()})}),(0,J.jsx)(W,{children:(d??[]).map(e=>(0,J.jsxs)(K,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(d??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:Je()}),(0,J.jsx)(z,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(ut,{minted:V,onClose:()=>H(null)})]})}function lt({account:e,keys:t,onRevoke:n,revoking:i}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[w(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:S()}),(0,J.jsx)(`th`,{children:E()}),(0,J.jsx)(`th`,{children:C()}),(0,J.jsx)(`th`,{children:O()}),(0,J.jsx)(`th`,{children:x()}),(0,J.jsx)(`th`,{children:r()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:P(t.createdAt)}),(0,J.jsx)(`td`,{className:dt(t.lastUsedAt)?`oc-sa__stale`:``,children:ft(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:pt(t.expiresAt)}),(0,J.jsx)(`td`,{children:mt(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:i.has(t._id),onClick:()=>n(t),children:i.has(t._id)?d():v()})})]},t._id))})]})]})}function ut({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(F,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(I,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(R,{children:[(0,J.jsx)(L,{children:g()}),(0,J.jsx)(V,{children:_({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:ue()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":T(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(tt,{}),n?l():o()]})]}),(0,J.jsx)(B,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:we()})})]}):null})}function dt(e){return e===null?!1:Date.now()-e>X}function ft(e){return e===null?a():P(e)}function pt(e){return e===null?`—`:H(e)}function mt(e){return e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:k()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(U,{variant:`outline`,children:p()}):(0,J.jsx)(U,{variant:`outline`,children:u()})}export{$ 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,BL as te,Bj as ne,Cj as re,Dj as ie,Ej as ae,Fj as oe,GA as o,Gj as se,HA as s,HL as c,Hj as ce,Ij as le,JA as ue,Jj as de,KA as l,Kj as fe,LA as u,Lj as pe,Mj as me,Nj as he,Oj as ge,Pj as _e,QA as d,Qj as f,RA as p,Rj as ve,Sj as ye,Tj as be,UA as m,UL as h,Uj as xe,VA as Se,Vj as Ce,WA as we,Wj as Te,XA as g,Xj as Ee,YA as _,Yj as De,ZA as v,Zj as y,_j as Oe,aj as b,bj as ke,cj as Ae,dj as je,eM as Me,ej as x,fj as Ne,gj as Pe,hj as Fe,ij as S,jj as Ie,kj as Le,lj as Re,mj as ze,nM as Be,nj as C,oj as w,pj as Ve,qA as T,qj as He,rM as Ue,rj as E,sj as We,t as D,tM as Ge,tj as O,uj as Ke,vj as qe,wj as Je,xj as Ye,yj as Xe,zA as k,zj as Ze}from"./api-CZm__5my.js";import{t as A}from"./check-la1GHs3B.js";import{r as Qe}from"./dist-51K385p9.js";import{t as j}from"./button-DMpgqct_.js";import{Dt as $e,Fn as et,On as tt,Pn as nt,Z as rt,_ as it,_t as M,bt as N,ct as P,dt as F,ft as I,gt as L,ht as R,jn as at,jt as z,mt as B,pt as V,st as H,ut as U,vt as W,xt as G,yt as K}from"./index-DI3wVm5g.js";import{t as ot}from"./FilterBar-BBUyj-UI.js";import{t as st}from"./DataTableShell-BDPxsytR.js";import{t as ct}from"./roleDescriptions-Dn4-uXz-.js";var q=t(e(),1),J=n(),Y=[{value:`never`,label:()=>m(),days:null},{value:`30`,label:()=>s(),days:30},{value:`90`,label:()=>Se(),days:90}],X=720*60*60*1e3,Z=`__all__`,Q={name:``,roleKey:``,description:``};function $(){let e=et({from:`/settings/serviceAccounts`}),t=nt({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??Z,[a,o]=(0,q.useState)(Z),s=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),ue=e=>void t({search:t=>({...t,status:e===Z?void 0:e})}),l=h(D.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:a===Z?void 0:a,disabled:r===Z?void 0:r===`disabled`}}),u=h(D.apiKeys.listKeys,{}),d=h(D.apiKeys.listRoles,{}),p=c(D.apiKeys.createServiceAccount),m=c(D.apiKeys.updateServiceAccount),Se=c(D.apiKeys.deleteServiceAccount),we=te(D.apiKeys.mintApiKey),g=c(D.apiKeys.revokeApiKey),_=rt(),v=$e(),b=n!==``||a!==Z||r!==Z;function x(){o(Z),t({search:{},replace:!0})}let[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(Q),[E,O]=(0,q.useState)(null),[k,A]=(0,q.useState)(new Set),[tt,P]=(0,q.useState)(null),F=(0,q.useRef)(!1),[I,L]=(0,q.useState)(new Set),[R,B]=(0,q.useState)({}),[V,H]=(0,q.useState)(null),X=(0,q.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 $(e){A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function dt(){try{E?(await m({serviceAccountId:E,name:w.name,roleKey:w.roleKey,description:w.description}),v.success(Ye())):await p({name:w.name,roleKey:w.roleKey,description:w.description||void 0}),T(Q),O(null),C(!1)}catch(e){v.error(E?ye():re(),e)}}function ft(e){T({name:e.name,roleKey:e.roleKey,description:e.description??``}),O(e._id),C(!0)}async function pt(e){if(F.current)return;F.current=!0;let t=R[e._id]??`never`,n=Y.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;P(e._id);try{let t=await we({serviceAccountId:e._id,expiresAt:r});H({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){v.error(ke(),e)}finally{F.current=!1,P(null)}}async function mt(e){if(await _({title:Xe(),description:(0,J.jsxs)(J.Fragment,{children:[qe(),` `,(0,J.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,Oe(),` `,(0,J.jsx)(`strong`,{children:Pe()}),` `,Fe()]}),confirmWord:e.name,confirmLabel:ze(),destructive:!0}))try{await Se({serviceAccountId:e._id}),v.success(Ve(),e.name)}catch(e){v.error(Ne(),e)}}async function ht(e){if(await _({title:je(),description:(0,J.jsxs)(J.Fragment,{children:[Ke(),` `,(0,J.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,Re()]}),confirmLabel:Ae(),destructive:!0})&&!I.has(e._id)){L(t=>new Set(t).add(e._id));try{await g({keyId:e._id})}catch(e){v.error(We(),e)}finally{L(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:Ue()}),(0,J.jsxs)(ot,{q:n,onQChange:s,searchPlaceholder:Be(),onReset:x,canReset:b,children:[(0,J.jsxs)(M,{value:a,onValueChange:o,children:[(0,J.jsx)(N,{size:`sm`,className:`w-40`,children:(0,J.jsx)(G,{placeholder:Ge()})}),(0,J.jsxs)(W,{children:[(0,J.jsx)(K,{value:Z,children:Me()}),(d??[]).map(e=>(0,J.jsx)(K,{value:e.key,children:e.key},e._id))]})]}),(0,J.jsxs)(M,{value:r,onValueChange:ue,children:[(0,J.jsx)(N,{size:`sm`,className:`w-36`,children:(0,J.jsx)(G,{})}),(0,J.jsxs)(W,{children:[(0,J.jsx)(K,{value:Z,children:i()}),(0,J.jsx)(K,{value:`active`,children:f()}),(0,J.jsx)(K,{value:`disabled`,children:y()})]})]})]}),(0,J.jsx)(st,{title:Ee(),rows:l,addLabel:De(),onAdd:()=>{T(Q),O(null),C(!0)},emptyHint:de(),isExpanded:e=>k.has(e._id),renderExpanded:e=>(0,J.jsx)(lt,{account:e,keys:X.get(e._id)??[],onRevoke:ht,revoking:I}),rowActions:e=>[{label:Te(),onSelect:()=>ft(e)},{label:He(),onSelect:()=>void pt(e)},{label:k.has(e._id)?fe():se(),onSelect:()=>$(e._id)},{label:xe(),variant:`destructive`,onSelect:()=>void mt(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,J.jsx)(j,{variant:`ghost`,size:`icon-sm`,"aria-label":k.has(e._id)?ce():Ce(),onClick:()=>$(e._id),children:k.has(e._id)?(0,J.jsx)(Qe,{}):(0,J.jsx)(at,{})})},{header:ne(),sort:e=>e.name,cell:e=>(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{children:e.name}),e.description?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:Ze(),sort:e=>e.roleKey,cell:e=>(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})},{header:ve(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:y()}):(0,J.jsx)(U,{variant:`outline`,children:f()})},{header:pe(),cell:e=>(0,J.jsxs)(M,{value:R[e._id]??`never`,onValueChange:t=>B(n=>({...n,[e._id]:t})),children:[(0,J.jsx)(N,{size:`sm`,className:`w-32`,children:(0,J.jsx)(G,{})}),(0,J.jsx)(W,{children:Y.map(e=>(0,J.jsx)(K,{value:e.value,children:e.label()},e.value))})]})},{header:le(),sort:e=>(X.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(X.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,J.jsx)(`span`,{className:`oc-sa__keycount`,children:tt===e._id?oe():_e({count:t})})}}]}),(0,J.jsx)(it,{open:S,onOpenChange:e=>{C(e),e||O(null)},title:E?he():ee(),description:E?me():Le(),canSubmit:!!(w.name&&w.roleKey),onSubmit:dt,submitLabel:E?Ie():ge(),children:(0,J.jsxs)(`div`,{className:`oc-form`,children:[(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ie()}),(0,J.jsx)(z,{value:w.name,onChange:e=>T({...w,name:e.target.value})})]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:ae()}),(0,J.jsxs)(M,{value:w.roleKey||void 0,onValueChange:e=>T({...w,roleKey:e}),children:[(0,J.jsx)(N,{className:`w-full`,children:(0,J.jsx)(G,{placeholder:be()})}),(0,J.jsx)(W,{children:(d??[]).map(e=>(0,J.jsxs)(K,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(d??[]).find(e=>e.key===w.roleKey),t=e?ct(e):null;return t?(0,J.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:Je()}),(0,J.jsx)(z,{value:w.description,onChange:e=>T({...w,description:e.target.value})})]})]})}),(0,J.jsx)(ut,{minted:V,onClose:()=>H(null)})]})}function lt({account:e,keys:t,onRevoke:n,revoking:i}){return(0,J.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,J.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[w(),` `,(0,J.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,J.jsx)(`p`,{className:`oc-admin__hint`,children:b()}):(0,J.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{children:S()}),(0,J.jsx)(`th`,{children:E()}),(0,J.jsx)(`th`,{children:C()}),(0,J.jsx)(`th`,{children:O()}),(0,J.jsx)(`th`,{children:x()}),(0,J.jsx)(`th`,{children:r()}),(0,J.jsx)(`th`,{})]})}),(0,J.jsx)(`tbody`,{children:t.map(t=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`td`,{children:(0,J.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,J.jsx)(`td`,{children:(0,J.jsx)(U,{variant:`secondary`,children:e.roleKey})}),(0,J.jsx)(`td`,{children:P(t.createdAt)}),(0,J.jsx)(`td`,{className:dt(t.lastUsedAt)?`oc-sa__stale`:``,children:ft(t.lastUsedAt)}),(0,J.jsx)(`td`,{children:pt(t.expiresAt)}),(0,J.jsx)(`td`,{children:mt(t)}),(0,J.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,J.jsx)(j,{variant:`destructive`,size:`sm`,disabled:i.has(t._id),onClick:()=>n(t),children:i.has(t._id)?d():v()})})]},t._id))})]})]})}function ut({minted:e,onClose:t}){let[n,r]=(0,q.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,J.jsx)(F,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,J.jsxs)(I,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,J.jsxs)(R,{children:[(0,J.jsx)(L,{children:g()}),(0,J.jsx)(V,{children:_({name:e.accountName})})]}),(0,J.jsx)(`div`,{className:`oc-sa__minted-warning`,children:ue()}),(0,J.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,J.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,J.jsxs)(j,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":T(),children:[n?(0,J.jsx)(A,{}):(0,J.jsx)(tt,{}),n?l():o()]})]}),(0,J.jsx)(B,{children:(0,J.jsx)(j,{onClick:()=>{r(!1),t()},children:we()})})]}):null})}function dt(e){return e===null?!1:Date.now()-e>X}function ft(e){return e===null?a():P(e)}function pt(e){return e===null?`—`:H(e)}function mt(e){return e.disabled?(0,J.jsx)(U,{variant:`destructive`,children:k()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,J.jsx)(U,{variant:`outline`,children:p()}):(0,J.jsx)(U,{variant:`outline`,children:u()})}export{$ 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,HL as c,Jo as l,Ms as u,Os as d,Qo as f,Ss as p,Ts as m,UL as h,Xo as g,Yo as _,Zo as v,_s as y,as as b,bs as x,cs as S,ds as C,es as w,fs as T,gs as E,hs as D,is as O,js as k,ks as A,ls as j,ms as M,ns as N,os as P,ps as F,rs as I,ss as L,t as R,ts as ee,us as z,vs as B,ws as V,xs as H,ys as U}from"./api-CZm__5my.js";import{t as W}from"./button-DMpgqct_.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,HL as c,Jo as l,Ms as u,Os as d,Qo as f,Ss as p,Ts as m,UL as h,Xo as g,Yo as _,Zo as v,_s as y,as as b,bs as x,cs as S,ds as C,es as w,fs as T,gs as E,hs as D,is as O,js as k,ks as A,ls as j,ms as M,ns as N,os as P,ps as F,rs as I,ss as L,t as R,ts as ee,us as z,vs as B,ws as V,xs as H,ys as U}from"./api-CZm__5my.js";import{t as W}from"./button-DMpgqct_.js";import{Z as G,ct as K}from"./index-DI3wVm5g.js";import{t as q}from"./DataTableShell-BDPxsytR.js";var J=t(e(),1),Y=n(),X={hung:()=>D(),wrong_result:()=>M(),error:()=>F(),other:()=>T()},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=c(R.subAgentReports.respondToReport),[i,a]=(0,J.useState)(e.thread),[o,s]=(0,J.useState)(``),[l,u]=(0,J.useState)(!1);async function d(){let t=o.trim();if(!(!t||l)){u(!0);try{await n({reportId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),s(``)}finally{u(!1)}}}return(0,Y.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,children:(0,Y.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[Z(e.category),` · `,C({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:z()}),(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:j()}),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`?S():L()}),(0,Y.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,Y.jsx)(`p`,{className:`oc-fbadmin__meta`,children:P()}),(0,Y.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:b(),value:o,maxLength:2e3,rows:3,onChange:e=>s(e.target.value.slice(0,2e3))}),(0,Y.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,Y.jsx)(W,{size:`sm`,onClick:()=>void d(),disabled:!o.trim()||l,children:l?I():O()})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`h4`,{className:`oc-fbadmin__h`,children:[N({count:t.children.length}),t.childrenTruncated?` ${ee()}`:``,t.textTruncated?` ${w()}`:``]}),(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:f()}),(0,Y.jsx)(`pre`,{className:`oc-msg__source-pre`,children:t.parentText})]}):null,(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h4`,{className:`oc-fbadmin__h`,children:v()}),(0,Y.jsx)(`p`,{className:`oc-fbadmin__env`,children:[t.parentStatus?`status: ${t.parentStatus}`:null,t.parentErrorCode?`code: ${t.parentErrorCode}`:null,t.parentRunId?`run ${t.parentRunId.slice(0,12)}…`:null,e.correlationId?`corr ${e.correlationId.slice(0,16)}…`:null,t.openclawProvider].filter(Boolean).join(` · `)||`—`})]})]})}function te(){let e=h(R.subAgentReports.listForAdmin,{}),t=c(R.subAgentReports.readReport),n=c(R.subAgentReports.deleteReport),r=G(),[f,v]=(0,J.useState)(null),[b,S]=(0,J.useState)({});async function C(e){if(f===e._id){v(null);return}if(!b[e._id]){let n=await t({reportId:e._id});S(t=>({...t,[e._id]:n}))}v(e._id)}async function w(e){await r({title:g(),description:_(),confirmLabel:l(),destructive:!0})&&(await n({reportId:e._id}),f===e._id&&v(null))}return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`oc-admin__hint`,children:[i(),` `,(0,Y.jsx)(`strong`,{children:A()}),` `,d()]}),(0,Y.jsx)(q,{title:u(),rows:e,emptyHint:k(),isExpanded:e=>f===e._id&&!!b[e._id],renderExpanded:e=>b[e._id]?(0,Y.jsx)($,{data:b[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:V(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${H({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:x()}):(0,Y.jsx)(`span`,{className:`oc-fbadmin__pill`,children:U()}),sort:e=>+!!e.answered}],rowActions:e=>[{label:f===e._id?y():B(),onSelect:()=>void C(e)},{label:E(),onSelect:()=>void w(e),variant:`destructive`}]})]})}export{te as SubAgentReportsTab};
|