import{r as e,j as s}from"./vendor-react-Dp9pL_Wn.js";import{aQ as t,aR as a,aS as n,aT as l,aU as i,aV as r,aW as d,ak as x,aX as o}from"./c4b350ac1-KLFM4jkb.js";import{ah as c,ai as u,aj as m}from"./index-CSvjYuL_.js";import{u as p,M as j}from"./vendor-intl-BDR1NhN_.js";function h({isScheduledDuringPeakHours:e,peakHoursWindowPst:s,variant:a}){return p(),t(),null}function f(e){return!e.enabled&&!!e.fireAt&&!!e.lastRunAt}const g="group relative flex h-28 flex-col justify-between p-3 rounded-lg bg-bg-100 ring-1 ring-inset ring-border-300 hover:bg-bg-200 outline-none focus-visible:shadow-focus transition-colors text-left text-sm no-underline cursor-pointer",N="inline-flex items-center gap-1 h-[18px] max-w-[8rem] px-1.5 rounded bg-bg-300 text-xs text-text-300 shrink-0 truncate";e.memo(({scheduledTask:t,detailRoutePrefix:b,displayName:v,contextLabel:w,scheduleTextFallback:k,triggerCount:M=0,sourceBadge:A,statusOverride:H,onClick:R})=>{const S=p(),P="string"==typeof w?[w]:w,y=e.useMemo(()=>a(t.cronExpression,Math.round((t.jitterSeconds??0)/60),S,t.fireAt),[t.cronExpression,t.jitterSeconds,t.fireAt,S]),C=t.enabled?t.fireAt&&!t.lastRunAt?n(new Date(t.fireAt),S,"future"):l(i(t.cronExpression),t.nextRunAt,Math.round((t.jitterSeconds??0)/60),S):null,F=!C&&t.enabled&&t.lastRunAt?n(new Date(t.lastRunAt),S,"past"):null,T=H??(t.enabled?null:f(t)?"completed":"paused"),z=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium text-text-100 truncate",children:v??r(t.id)}),s.jsx(h,{variant:"icon",isScheduledDuringPeakHours:t.isScheduledDuringPeakHours,peakHoursWindowPst:t.peakHoursWindowPst}),P&&P.length>0&&s.jsx("span",{className:`${N} ml-auto`,title:P.join("\n"),children:P.length>1?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"truncate",children:P[0].split("/").pop()}),s.jsx("span",{className:"shrink-0 text-text-500",children:s.jsx(j,{defaultMessage:"+{n}",id:"gxFSojQzTJ",values:{n:P.length-1}})})]}):P[0].split("/").pop()}),"local"===A&&s.jsxs("span",{className:N,children:[s.jsx(c,{size:12}),s.jsx(j,{defaultMessage:"Local",id:"W4SaxYXWRk"})]}),"remote"===A&&s.jsxs("span",{className:N,children:[s.jsx(u,{size:12}),s.jsx(j,{defaultMessage:"Cloud",id:"fiPvwYljok"})]})]}),s.jsxs("div",{className:"text-text-400 font-small",children:[y||k||"\xa0",M>1&&s.jsx("span",{className:"ml-1.5 text-text-500",children:s.jsx(j,{defaultMessage:"+{n} more",id:"Fo49VHwJiZ",values:{n:M-1}})})]})]}),s.jsxs("div",{className:"flex items-center justify-between text-text-400 font-small",children:[s.jsx("span",{children:C?t.fireAt?s.jsx(j,{defaultMessage:"Runs at: {when}",id:"Ncpy/sig/G",values:{when:s.jsx("span",{className:"text-text-200",children:C})}}):s.jsx(j,{defaultMessage:"Next run: {when}",id:"tXnyVYHFxs",values:{when:s.jsx("span",{className:"text-text-200",children:C})}}):F?s.jsx(j,{defaultMessage:"Last run: {when}",id:"4AXNTH5eDF",values:{when:s.jsx("span",{className:"text-text-200",children:F})}}):"\xa0"}),"paused"===T&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-text-300",children:[s.jsx(m,{size:12}),s.jsx(j,{defaultMessage:"Paused",id:"C2iTEHtK//"})]}),"completed"===T&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-text-300",children:[s.jsx(d,{size:12}),s.jsx(j,{defaultMessage:"Ran",id:"+CuLVSpi4n"})]}),"auto-disabled"===T&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-danger-000",children:[s.jsx(x,{size:12}),s.jsx(j,{defaultMessage:"Auto-disabled",id:"oKQHGunEG3"})]})]})]});return R?s.jsx("button",{type:"button",onClick:R,className:g,children:z}):s.jsx(o,{href:b?`${b}/${encodeURIComponent(t.id)}`:"#",className:g,children:z})}).displayName="ScheduledTaskCard";export{h as P,f as i};
