import{r as u,j as e}from"./vendor-tanstack-DE4ALVGD.js";import{c as m}from"./cronstrue-Dgg2IuMf.js";import{aZ as j,X as f,Y as p,H as i,Z as g,bW as c,bT as l,bU as o,bV as d,au as v,f as T}from"./index-CNL5pSma.js";import{f as $,$ as w}from"./vendor-date-Bck8LDfw.js";import{u as y}from"./use-is-overflowing-CSPqjSAE.js";const x=({schedule:a,...r})=>{const{schedule:n}=a;if("cron"in n)return e.jsx(S,{schedule:n,active:a.active,...r});if("interval"in n)return e.jsx(N,{schedule:n,active:a.active,...r});if("rrule"in n)return e.jsx(z,{schedule:n,active:a.active,...r})},S=({active:a,schedule:r,...n})=>{const t=m.toString(r.cron),s=`${a?"":"(Paused)"} ${t} (${r.timezone})`;return e.jsx(c,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(i,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:t})})}),e.jsx(d,{children:s})]})})},N=({active:a,schedule:r,...n})=>{const t=`Every ${v(r.interval*1e3)}`;let s=`${a?"":"(Paused)"} ${t}`;return r.anchor_date&&(s+=` using ${$(new Date(r.anchor_date),"MMM do, yyyy 'at' hh:mm:ss aa")} (${r.timezone}) as the anchor date`),e.jsx(c,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(i,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:t})})}),e.jsx(d,{children:s})]})})},z=({active:a,schedule:r,...n})=>{const t=w(r.rrule).toText(),s=T(t),h=`${a?"":"(Paused)"} ${s} (${r.timezone})`;return e.jsx(c,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(i,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:s})})}),e.jsx(d,{children:h})]})})},P=({schedules:a,className:r})=>{const n=u.useRef(null),t=y(n);return!a||a.length===0?null:t?e.jsx("div",{className:j("flex flex-row gap-2 items-center no-wrap",r),children:e.jsxs(f,{children:[e.jsx(p,{children:e.jsxs(i,{variant:"secondary",className:"whitespace-nowrap",children:[a.length," schedules"]})}),e.jsx(g,{className:"flex flex-col flex-wrap gap-1 w-fit",children:a.map(s=>e.jsx(x,{schedule:s},s.id))})]})}):e.jsx("div",{className:"flex flex-row gap-2 items-center no-wrap",ref:n,children:a.map(s=>e.jsx(x,{schedule:s,className:"max-w-28"},s.id))})};export{P as S};
//# sourceMappingURL=index-DpZOgCYZ.js.map
