import{r as u,j as e}from"./vendor-tanstack-BVzzyDEt.js";import{c as m}from"./cronstrue-qXVYKoA_.js";import{cA as j,aU as p,cB as f,cC as g,C as c,cD as v,bS as i,bP as l,bQ as o,bR as d,aa as $,i as T}from"./index-BJkJ93Lr.js";import{f as S,$ as w}from"./vendor-date-2jFo9aCm.js";const x=({schedule:a,...r})=>{const{schedule:n}=a;if("cron"in n)return e.jsx(y,{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(C,{schedule:n,active:a.active,...r})},y=({active:a,schedule:r,...n})=>{const t=m.toString(r.cron),s=`${a?"":"(Paused)"} ${t} (${r.timezone})`;return e.jsx(i,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(c,{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 ${$(r.interval*1e3)}`;let s=`${a?"":"(Paused)"} ${t}`;return r.anchor_date&&(s+=` using ${S(new Date(r.anchor_date),"MMM do, yyyy 'at' hh:mm:ss aa")} (${r.timezone}) as the anchor date`),e.jsx(i,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(c,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:t})})}),e.jsx(d,{children:s})]})})},C=({active:a,schedule:r,...n})=>{const t=w(r.rrule).toText(),s=T(t),h=`${a?"":"(Paused)"} ${s} (${r.timezone})`;return e.jsx(i,{children:e.jsxs(l,{children:[e.jsx(o,{children:e.jsx(c,{variant:"secondary",className:`${a?"":"opacity-50"}`,...n,children:e.jsx("span",{className:"truncate",children:s})})}),e.jsx(d,{children:h})]})})},b=({schedules:a,className:r})=>{const n=u.useRef(null),t=j(n);return!a||a.length===0?null:t?e.jsx("div",{className:p("flex flex-row gap-2 items-center no-wrap",r),children:e.jsxs(f,{children:[e.jsx(g,{children:e.jsxs(c,{variant:"secondary",className:"whitespace-nowrap",children:[a.length," schedules"]})}),e.jsx(v,{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{b as S};
//# sourceMappingURL=index-DcdvPWsR.js.map
