"use strict";(()=>{var e={};e.id=662,e.ids=[662],e.modules={846:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},4870:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},3295:e=>{e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},9294:e=>{e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},3033:e=>{e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},9646:e=>{e.exports=require("child_process")},9748:e=>{e.exports=require("fs/promises")},1820:e=>{e.exports=require("os")},3873:e=>{e.exports=require("path")},8354:e=>{e.exports=require("util")},9109:(e,r,t)=>{t.r(r),t.d(r,{patchFetch:()=>h,routeModule:()=>x,serverHooks:()=>m,workAsyncStorage:()=>w,workUnitAsyncStorage:()=>f});var s={};t.r(s),t.d(s,{GET:()=>c});var o=t(2706),a=t(8203),n=t(5994),i=t(9187),p=t(9269),d=t(9748),u=t(3873),l=t(1820);async function c(e){let r=e.nextUrl.searchParams,t=r.get("deviceId"),s=r.get("path");if(!t)return i.NextResponse.json({error:"Device ID is required"},{status:400});if(!s)return i.NextResponse.json({error:"Path is required"},{status:400});try{let e=p.J.getInstance(),r=(0,u.join)((0,l.tmpdir)(),s.split("/").pop()||"download");await e.downloadFile(t,s,r);let o=await (0,d.readFile)(r);await (0,d.unlink)(r);let a=s.split("/").pop()||"download",n=new Headers;return n.set("Content-Disposition",`attachment; filename="${a}"`),n.set("Content-Type","application/octet-stream"),new i.NextResponse(o,{status:200,headers:n})}catch(e){return console.error("Error downloading file:",e),i.NextResponse.json({error:e instanceof Error?e.message:"Failed to download file"},{status:500})}}let x=new o.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/files/download/route",pathname:"/api/files/download",filename:"route",bundlePath:"app/api/files/download/route"},resolvedPagePath:"/Users/saleeh/codes/appmaker/adb-web/src/app/api/files/download/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:w,workUnitAsyncStorage:f,serverHooks:m}=x;function h(){return(0,n.patchFetch)({workAsyncStorage:w,workUnitAsyncStorage:f})}}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[994,452,577],()=>t(9109));module.exports=s})();