"use strict";(()=>{var e={};e.id=4552,e.ids=[4552],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")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},68360:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>h,patchFetch:()=>v,requestAsyncStorage:()=>g,routeModule:()=>c,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var s={};r.r(s),r.d(s,{GET:()=>l});var o=r(49303),i=r(88716),n=r(60670),a=r(87070),u=r(94925),p=r(30721),d=r(83513);let m=(0,r(43895).h)("api/messages");async function l(e,{params:t}){try{let r=(0,u.getDbInstance)();if(!(0,p.gU)(r,t.id))return a.NextResponse.json({error:`Worktree '${t.id}' not found`},{status:404});let{searchParams:s}=new URL(e.url),o=s.get("before"),i=s.get("limit"),n=s.get("cliTool"),m=o?new Date(o):void 0,l=i?parseInt(i,10):50,c=s.get("includeArchived");if(n&&!d.tK.includes(n))return a.NextResponse.json({error:`Invalid cliTool parameter (must be one of: ${d.tK.join(", ")})`},{status:400});if(isNaN(l)||l<1||l>100)return a.NextResponse.json({error:"Invalid limit parameter (must be 1-100)"},{status:400});let g=[...(0,p._U)(r,t.id,{before:m,limit:l,cliToolId:n,includeArchived:"true"===c}).filter(e=>e.content&&""!==e.content.trim())].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());return a.NextResponse.json(g,{status:200})}catch(e){return m.error("error-fetching-messages:",{error:e instanceof Error?e.message:String(e)}),a.NextResponse.json({error:"Failed to fetch messages"},{status:500})}}let c=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/worktrees/[id]/messages/route",pathname:"/api/worktrees/[id]/messages",filename:"route",bundlePath:"app/api/worktrees/[id]/messages/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/messages/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:g,staticGenerationAsyncStorage:x,serverHooks:f}=c,h="/api/worktrees/[id]/messages/route";function v(){return(0,n.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972,3895,4925,721],()=>r(68360));module.exports=s})();