"use strict";(()=>{var e={};e.id=541,e.ids=[541],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")},28841:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>q,patchFetch:()=>v,requestAsyncStorage:()=>x,routeModule:()=>g,serverHooks:()=>b,staticGenerationAsyncStorage:()=>m});var s={};t.r(s),t.d(s,{POST:()=>l});var o=t(49303),i=t(88716),a=t(60670),n=t(87070),u=t(94925),p=t(98838),c=t(11796);let d=(0,t(43895).h)("api/repositories-clone");async function l(e){try{let{cloneUrl:r,targetDir:t}=await e.json();if(!r||"string"!=typeof r||""===r.trim())return n.NextResponse.json({success:!1,error:{category:"validation",code:"EMPTY_URL",message:"Clone URL is required",recoverable:!0,suggestedAction:"Please enter a valid git clone URL"}},{status:400});if(void 0!==t&&"string"!=typeof t)return n.NextResponse.json({success:!1,error:{category:"validation",code:"INVALID_TARGET_PATH",message:"targetDir must be a string",recoverable:!0,suggestedAction:"Provide a valid string path for targetDir"}},{status:400});let s=(0,u.getDbInstance)(),{CM_ROOT_DIR:o}=(0,p.dU)(),i=new c.v9(s,{basePath:o});d.info("clone:start",{cloneUrl:r});let a=t?.trim()||void 0;if(a&&a.length>1024)return n.NextResponse.json({success:!1,error:{category:"validation",code:"INVALID_TARGET_PATH",message:"Target directory path is too long",recoverable:!0,suggestedAction:"Use a path within the configured base directory"}},{status:400});let l=await i.startCloneJob(r.trim(),a);if(!l.success){let e=400;return(l.error?.code==="DUPLICATE_CLONE_URL"||l.error?.code==="CLONE_IN_PROGRESS")&&(e=409),d.warn("clone-job-failed:-"),n.NextResponse.json({success:!1,error:l.error,jobId:l.jobId},{status:e})}return d.info("clone:job-created",{jobId:l.jobId}),n.NextResponse.json({success:!0,jobId:l.jobId,status:"pending",message:"Clone job started"},{status:202})}catch(e){return d.error("unexpected-error:",{error:e instanceof Error?e.message:String(e)}),n.NextResponse.json({success:!1,error:{category:"system",code:"INTERNAL_ERROR",message:"Failed to start clone job",recoverable:!1,suggestedAction:"Please try again later"}},{status:500})}}let g=new o.AppRouteRouteModule({definition:{kind:i.x.APP_ROUTE,page:"/api/repositories/clone/route",pathname:"/api/repositories/clone",filename:"route",bundlePath:"app/api/repositories/clone/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/repositories/clone/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:x,staticGenerationAsyncStorage:m,serverHooks:b}=g,q="/api/repositories/clone/route";function v(){return(0,a.patchFetch)({serverHooks:b,staticGenerationAsyncStorage:m})}}};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,1796],()=>t(28841));module.exports=s})();