"use strict";(()=>{var e={};e.id=6865,e.ids=[6865],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")},75144:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>j,patchFetch:()=>w,requestAsyncStorage:()=>g,routeModule:()=>f,serverHooks:()=>v,staticGenerationAsyncStorage:()=>y});var s={};t.r(s),t.d(s,{POST:()=>m});var o=t(49303),i=t(88716),a=t(60670),n=t(87070),p=t(55315),u=t.n(p),d=t(94925),c=t(55044),l=t(46155),x=t(98838),h=t(43112);let q=(0,t(43895).h)("api/repositories-scan");async function m(e){try{let{repositoryPath:r}=await e.json();if(!r||"string"!=typeof r)return n.NextResponse.json({error:"Repository path is required"},{status:400});let{CM_ROOT_DIR:t}=(0,x.dU)();if(!(0,l.jj)(r,t))return n.NextResponse.json({error:"Invalid or unsafe repository path"},{status:400});let s=u().resolve(t,r),o=await (0,c.e9)(s);if(0===o.length)return n.NextResponse.json({error:"No worktrees found in the specified path. Make sure it is a valid git repository."},{status:404});let i=(0,d.getDbInstance)(),{syncResult:a,cleanupWarnings:p}=await (0,h.Hz)(i,o);return n.NextResponse.json({success:!0,message:`Successfully scanned and added ${o.length} worktree(s)`,worktreeCount:o.length,repositoryPath:o[0].repositoryPath,repositoryName:o[0].repositoryName,deletedCount:a.deletedIds.length,cleanupWarnings:p},{status:200})}catch(r){q.error("repository:scan-failed",{error:r instanceof Error?r.message:String(r)});let e=r instanceof Error?r.message:"Failed to scan repository";return n.NextResponse.json({error:e},{status:500})}}let f=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/repositories/scan/route",pathname:"/api/repositories/scan",filename:"route",bundlePath:"app/api/repositories/scan/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/repositories/scan/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:g,staticGenerationAsyncStorage:y,serverHooks:v}=f,j="/api/repositories/scan/route";function w(){return(0,a.patchFetch)({serverHooks:v,staticGenerationAsyncStorage:y})}}};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(75144));module.exports=s})();