"use strict";(()=>{var e={};e.id=303,e.ids=[303],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")},9862:(e,r,t)=>{t.r(r),t.d(r,{patchFetch:()=>w,routeModule:()=>v,serverHooks:()=>h,workAsyncStorage:()=>g,workUnitAsyncStorage:()=>m});var s={};t.r(s),t.d(s,{GET:()=>x,POST:()=>f});var a=t(2706),i=t(8203),n=t(5994),o=t(9187),p=t(9269),u=t(9748),d=t(3873),c=t(1820),l=t(2021);async function x(e,{params:r}){let t=r.deviceId,s=(0,l.y)(t),a=e.nextUrl.searchParams.get("mode");if(!s)return o.NextResponse.json({error:"Device ID is required"},{status:400});try{let e=p.J.getInstance(),r="basic"===a?await e.getBasicAppList(s):await e.getInstalledApps(s);return o.NextResponse.json({apps:r})}catch(e){return console.error("Error fetching apps:",e),o.NextResponse.json({error:e instanceof Error?e.message:"Failed to fetch apps"},{status:500})}}async function f(e,{params:r}){let t=r.deviceId,s=(0,l.y)(t),a=(await e.formData()).get("apkFile");if(!s)return o.NextResponse.json({error:"Device ID is required"},{status:400});if(!a)return o.NextResponse.json({error:"APK file is required"},{status:400});let i=p.J.getInstance();try{let e=Buffer.from(await a.arrayBuffer()),r=(0,d.join)((0,c.tmpdir)(),a.name);return await (0,u.writeFile)(r,e),await i.installApp(s,r),await (0,u.unlink)(r),o.NextResponse.json({success:!0})}catch(e){return console.error("Error installing app:",e),o.NextResponse.json({error:e instanceof Error?e.message:"Failed to install app"},{status:500})}}let v=new a.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/device/[deviceId]/apps/route",pathname:"/api/device/[deviceId]/apps",filename:"route",bundlePath:"app/api/device/[deviceId]/apps/route"},resolvedPagePath:"/Users/saleeh/codes/appmaker/adb-web/src/app/api/device/[deviceId]/apps/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:g,workUnitAsyncStorage:m,serverHooks:h}=v;function w(){return(0,n.patchFetch)({workAsyncStorage:g,workUnitAsyncStorage:m})}},2021:(e,r,t)=>{t.d(r,{y:()=>s});function s(e){return Buffer.from(e,"base64").toString()}}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[994,452,577],()=>t(9862));module.exports=s})();