"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")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},21764:e=>{e.exports=require("util")},28841:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>j,patchFetch:()=>v,requestAsyncStorage:()=>m,routeModule:()=>g,serverHooks:()=>b,staticGenerationAsyncStorage:()=>x});var o={};t.r(o),t.d(o,{POST:()=>l});var s=t(49303),a=t(88716),n=t(60670),i=t(87070),c=t(97425),u=t(98838),p=t(65488);let d="[Clone API]";async function l(e){try{let{cloneUrl:r,targetDir:t}=await e.json();if(!r||"string"!=typeof r||""===r.trim())return i.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 i.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 o=(0,c.getDbInstance)(),{CM_ROOT_DIR:s}=(0,u.dU)(),a=new p.v9(o,{basePath:s});console.info(`${d} Starting clone job for: ${r}`);let n=await a.startCloneJob(r.trim(),t);if(!n.success){let e=400;return(n.error?.code==="DUPLICATE_CLONE_URL"||n.error?.code==="CLONE_IN_PROGRESS")&&(e=409),console.warn(`${d} Clone job failed: ${n.error?.code} - ${n.error?.message}`),i.NextResponse.json({success:!1,error:n.error,jobId:n.jobId},{status:e})}return console.info(`${d} Clone job created: ${n.jobId}`),i.NextResponse.json({success:!0,jobId:n.jobId,status:"pending",message:"Clone job started"},{status:202})}catch(e){return console.error(`${d} Unexpected error:`,e),i.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 s.AppRouteRouteModule({definition:{kind:a.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:o}),{requestAsyncStorage:m,staticGenerationAsyncStorage:x,serverHooks:b}=g,j="/api/repositories/clone/route";function v(){return(0,n.patchFetch)({serverHooks:b,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,5488],()=>t(28841));module.exports=o})();