"use strict";(()=>{var e={};e.id=9532,e.ids=[9532],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")},86868:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>g,requestAsyncStorage:()=>l,routeModule:()=>c,serverHooks:()=>h,staticGenerationAsyncStorage:()=>x});var o={};t.r(o),t.d(o,{GET:()=>d,POST:()=>m});var s=t(49303),n=t(88716),i=t(60670),a=t(87070),u=t(97425),p=t(75748);async function d(e,{params:r}){try{let e=(0,u.n)();if(!(0,p.gU)(e,r.id))return a.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let t=(0,p.Db)(e,r.id);return a.NextResponse.json({memos:t},{status:200})}catch(e){return console.error("Error fetching memos:",e),a.NextResponse.json({error:"Failed to fetch memos"},{status:500})}}async function m(e,{params:r}){try{let t;let o=(0,u.n)();if(!(0,p.gU)(o,r.id))return a.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let{title:s,content:n,position:i}=await e.json().catch(()=>({}));if(void 0!==s&&s.length>100)return a.NextResponse.json({error:"title must be 100 characters or less"},{status:400});if(void 0!==n&&n.length>1e4)return a.NextResponse.json({error:"content must be 10000 characters or less"},{status:400});let d=(0,p.Db)(o,r.id);if(d.length>=5)return a.NextResponse.json({error:"Maximum memo limit (5) reached"},{status:400});if(void 0!==i&&"number"==typeof i)t=i;else{let e=new Set(d.map(e=>e.position));for(t=0;e.has(t)&&t<5;)t++}let m=(0,p.dD)(o,r.id,{title:s,content:n,position:t});return a.NextResponse.json({memo:m},{status:201})}catch(e){return console.error("Error creating memo:",e),a.NextResponse.json({error:"Failed to create memo"},{status:500})}}let c=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/worktrees/[id]/memos/route",pathname:"/api/worktrees/[id]/memos",filename:"route",bundlePath:"app/api/worktrees/[id]/memos/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/memos/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:l,staticGenerationAsyncStorage:x,serverHooks:h}=c,f="/api/worktrees/[id]/memos/route";function g(){return(0,i.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:x})}}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[8948,5972,7425],()=>t(86868));module.exports=o})();