"use strict";(()=>{var e={};e.id=5361,e.ids=[5361],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")},92639:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>k,requestAsyncStorage:()=>g,routeModule:()=>f,serverHooks:()=>q,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{DELETE:()=>m});var o=t(49303),i=t(88716),n=t(60670),p=t(87070),a=t(94925),u=t(30721),l=t(4709),d=t(43112),c=t(11425);let x=(0,t(43895).h)("api/repositories");async function m(e){try{let r;let{repositoryPath:t}=await e.json(),s=(0,l.VZ)(t);if(!s.valid)return p.NextResponse.json({success:!1,error:s.error},{status:400});let o=(0,a.getDbInstance)();(0,l.mm)(o,t);let i=(0,u.Pv)(o,t);if(0===i.length)return p.NextResponse.json({success:!1,error:"Repository not found"},{status:404});x.info("repository:delete-start",{repositoryPath:t,worktreeCount:i.length});let n=await (0,d.hs)(i,d.vk);for(let e of n.results)e.sessionsKilled.length>0&&x.info("session:killed",{worktreeId:e.worktreeId,sessions:e.sessionsKilled}),e.sessionErrors.length>0&&x.warn("session:kill-errors",{worktreeId:e.worktreeId,errors:e.sessionErrors});(0,c.ZV)(i);try{r=(0,u.DF)(o,t).deletedCount,x.info("repository:deleted",{repositoryPath:t,deletedCount:r})}catch(e){return x.error("repository:db-delete-failed",{repositoryPath:t,error:e instanceof Error?e.message:String(e)}),p.NextResponse.json({success:!1,error:"Database deletion failed"},{status:500})}(0,c.ps)("repository_deleted",{worktreeId:"global",repositoryPath:t,deletedWorktreeIds:i});let m={success:!0,deletedWorktreeCount:r,deletedWorktreeIds:i};return n.warnings.length>0?(m.warnings=n.warnings,x.info("repository:delete-completed",{repositoryPath:t,warningCount:n.warnings.length})):x.info("repository:delete-completed",{repositoryPath:t}),p.NextResponse.json(m,{status:200})}catch(e){return x.error("repository:delete-failed",{error:e instanceof Error?e.message:String(e)}),p.NextResponse.json({success:!1,error:"Failed to delete repository"},{status:500})}}let f=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/repositories/route",pathname:"/api/repositories",filename:"route",bundlePath:"app/api/repositories/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/repositories/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:g,staticGenerationAsyncStorage:h,serverHooks:q}=f,w="/api/repositories/route";function k(){return(0,n.patchFetch)({serverHooks:q,staticGenerationAsyncStorage:h})}},4709:(e,r,t)=>{t.d(r,{Bj:()=>s.Bj,RT:()=>s.RT,VZ:()=>s.VZ,j$:()=>s.j$,mm:()=>s.mm,nJ:()=>s.nJ});var s=t(95280)}};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,3895,4925,721,9228,550,3112],()=>t(92639));module.exports=s})();