"use strict";(()=>{var e={};e.id=3546,e.ids=[3546],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")},98165:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>g,requestAsyncStorage:()=>q,routeModule:()=>x,serverHooks:()=>y,staticGenerationAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{POST:()=>m});var o=t(49303),i=t(88716),n=t(60670),p=t(87070),a=t(94925),u=t(55044),c=t(4709),l=t(43112);let d=(0,t(43895).h)("api/repositories-sync");async function m(){try{let e=(0,u.a$)(),r=(0,a.getDbInstance)(),t=(0,c.j$)(r).filter(e=>e.enabled).map(e=>e.path),s=[...new Set([...e,...t])];if(0===s.length)return p.NextResponse.json({error:"No repositories configured. Please set WORKTREE_REPOS or CM_ROOT_DIR environment variable."},{status:400});let{filteredPaths:o}=(0,c.nJ)(r,s),i=await (0,u.Lj)(o),{syncResult:n,cleanupWarnings:d}=await (0,l.Hz)(r,i),m=new Set(i.map(e=>e.repositoryPath));return p.NextResponse.json({success:!0,message:`Successfully synced ${i.length} worktree(s) from ${m.size} repository/repositories`,worktreeCount:i.length,repositoryCount:m.size,repositories:Array.from(m),deletedCount:n.deletedIds.length,cleanupWarnings:d},{status:200})}catch(r){d.error("repositories:sync-failed",{error:r instanceof Error?r.message:String(r)});let e=r instanceof Error?r.message:"Failed to sync repositories";return p.NextResponse.json({error:e},{status:500})}}let x=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/repositories/sync/route",pathname:"/api/repositories/sync",filename:"route",bundlePath:"app/api/repositories/sync/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/repositories/sync/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:q,staticGenerationAsyncStorage:h,serverHooks:y}=x,f="/api/repositories/sync/route";function g(){return(0,n.patchFetch)({serverHooks:y,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(98165));module.exports=s})();