Spaces:
Running
Running
| import{r as t,j as e}from"./react-D_B_5QVd.js";import{I as C,J as N,L as S,S as k}from"./index-CPYWJ7h_.js";import"./jszip-C9ownNzX.js";import"./react-dom-EAO2-NBm.js";import"./scheduler-DYLXRpC5.js";import"./@google-4tyssLU_.js";import"./marked-CesSW9Du.js";import"./idb-Dob3nYDb.js";const c=({label:n,value:o,onChange:i,options:l})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary",children:n}),e.jsxs("select",{value:o,onChange:a=>i(a.target.value),className:"w-full mt-1 px-3 py-2 rounded-md bg-surface border border-border",children:[e.jsx("option",{value:"*",children:"* (every)"}),l.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),_=({initialPrompt:n})=>{const[o,i]=t.useState("0"),[l,a]=t.useState("17"),[d,p]=t.useState("*"),[x,h]=t.useState("*"),[m,g]=t.useState("1-5"),[b,f]=t.useState(n||"every weekday at 5pm"),[y,j]=t.useState(!1),v=t.useMemo(()=>`${o} ${l} ${d} ${x} ${m}`,[o,l,d,x,m]),u=t.useCallback(async r=>{if(r){j(!0);try{const s=await C(r);i(s.minute),a(s.hour),p(s.dayOfMonth),h(s.month),g(s.dayOfWeek)}catch(s){console.error(s)}finally{j(!1)}}},[]);return t.useEffect(()=>{n&&(f(n),u(n))},[n,u]),e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(N,{}),e.jsx("span",{className:"ml-3",children:"AI Cron Job Builder"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Visually construct a cron expression or describe it in plain English."})]}),e.jsxs("div",{className:"flex gap-2 mb-6",children:[e.jsx("input",{type:"text",value:b,onChange:r=>f(r.target.value),placeholder:"Describe a schedule...",className:"flex-grow px-3 py-1.5 rounded-md bg-surface border border-border text-sm"}),e.jsxs("button",{onClick:()=>u(b),disabled:y,className:"btn-primary px-4 py-1.5 flex items-center gap-2",children:[y?e.jsx(S,{}):e.jsx(k,{})," AI Generate"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-6",children:[e.jsx(c,{label:"Minute",value:o,onChange:i,options:Array.from({length:60},(r,s)=>s)}),e.jsx(c,{label:"Hour",value:l,onChange:a,options:Array.from({length:24},(r,s)=>s)}),e.jsx(c,{label:"Day (Month)",value:d,onChange:p,options:Array.from({length:31},(r,s)=>s+1)}),e.jsx(c,{label:"Month",value:x,onChange:h,options:Array.from({length:12},(r,s)=>s+1)}),e.jsx(c,{label:"Day (Week)",value:m,onChange:g,options:Array.from({length:7},(r,s)=>s)})]}),e.jsxs("div",{className:"bg-surface p-4 rounded-lg text-center border border-border",children:[e.jsx("p",{className:"text-text-secondary text-sm",children:"Generated Expression"}),e.jsx("p",{className:"font-mono text-primary text-2xl mt-1",children:v}),e.jsx("button",{onClick:()=>navigator.clipboard.writeText(v),className:"mt-4 px-3 py-1 bg-gray-100 hover:bg-gray-200 rounded-md text-xs",children:"Copy"})]})]})};export{_ as CronJobBuilder}; | |
| //# sourceMappingURL=CronJobBuilder-Dn5lHAdw.js.map | |