"use strict";(()=>{var e={};e.id=322,e.ids=[322],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},78893:e=>{e.exports=require("buffer")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},98216:e=>{e.exports=require("net")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},76162:e=>{e.exports=require("stream")},82452:e=>{e.exports=require("tls")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},24452:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>_,patchFetch:()=>j,requestAsyncStorage:()=>q,routeModule:()=>g,serverHooks:()=>E,staticGenerationAsyncStorage:()=>R});var s={};t.r(s),t.d(s,{GET:()=>f,POST:()=>m});var o=t(49303),n=t(88716),i=t(60670),u=t(87070),a=t(84770),p=t(97425),d=t(75748),l=t(38693),c=t(95614),x=t(41124),h=t(8186);async function f(e,{params:r}){try{if(!(0,l.m$)(r.id))return u.NextResponse.json({error:"Invalid worktree ID format"},{status:400});let e=(0,p.getDbInstance)();if(!(0,d.gU)(e,r.id))return u.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let t=e.prepare("SELECT * FROM scheduled_executions WHERE worktree_id = ? AND enabled = 1 ORDER BY created_at DESC").all(r.id);return u.NextResponse.json({schedules:t},{status:200})}catch(e){return console.error("Error fetching schedules:",e),u.NextResponse.json({error:"Failed to fetch schedules"},{status:500})}}async function m(e,{params:r}){try{if(!(0,l.m$)(r.id))return u.NextResponse.json({error:"Invalid worktree ID format"},{status:400});let t=(0,p.getDbInstance)();if(!(0,d.gU)(t,r.id))return u.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let s=await e.json().catch(()=>({})),{cronExpression:o,cliToolId:n,enabled:i}=s,f="string"==typeof s.name?s.name.trim():"",m="string"==typeof s.message?s.message.trim():"";if(!f)return u.NextResponse.json({error:"name is required"},{status:400});if(f.length>c.ME)return u.NextResponse.json({error:`name must be ${c.ME} characters or less`},{status:400});if(!m)return u.NextResponse.json({error:"message is required"},{status:400});if(m.length>c.xT)return u.NextResponse.json({error:`message must be ${c.xT} characters or less`},{status:400});if(!o||"string"!=typeof o)return u.NextResponse.json({error:"cronExpression is required"},{status:400});if(!(0,h.oU)(o))return u.NextResponse.json({error:"Invalid cron expression format"},{status:400});let g=n||"claude";if(!x.pu.has(g))return u.NextResponse.json({error:"Invalid CLI tool"},{status:400});let q=Date.now(),R=(0,a.randomUUID)();t.prepare(`
      INSERT INTO scheduled_executions (id, worktree_id, name, message, cron_expression, cli_tool_id, enabled, created_at, updated_at)
      VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
    `).run(R,r.id,f,m,o,g,!1!==i?1:0,q,q);let E=t.prepare("SELECT * FROM scheduled_executions WHERE id = ?").get(R);return u.NextResponse.json({schedule:E},{status:201})}catch(e){return console.error("Error creating schedule:",e),u.NextResponse.json({error:"Failed to create schedule"},{status:500})}}let g=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/worktrees/[id]/schedules/route",pathname:"/api/worktrees/[id]/schedules",filename:"route",bundlePath:"app/api/worktrees/[id]/schedules/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/schedules/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:q,staticGenerationAsyncStorage:R,serverHooks:E}=g,_="/api/worktrees/[id]/schedules/route";function j(){return(0,i.patchFetch)({serverHooks:E,staticGenerationAsyncStorage:R})}},8186:(e,r,t)=>{t.d(r,{C4:()=>s,oU:()=>o});let s=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F\x80-\x9F\u200B-\u200F\u2028-\u202F\uFEFF]/;function o(e){if(e.length>100)return!1;let r=e.trim().split(/\s+/);return r.length>=5&&r.length<=6}},95614:(e,r,t)=>{t.d(r,{ME:()=>s,wx:()=>i,xT:()=>o});let s=100,o=1e4,n=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function i(e){return n.test(e)}},41124:(e,r,t)=>{t.d(r,{U_:()=>o,pu:()=>s}),t(61282),t(19377);let s=new Set(["claude","codex","gemini","vibe-local","opencode"]);function o(){return globalThis.__scheduleActiveProcesses||(globalThis.__scheduleActiveProcesses=new Map),globalThis.__scheduleActiveProcesses}}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972,3853,4893,2509,7425,7566,4952,8693],()=>t(24452));module.exports=s})();