(()=>{var e={};e.id=604,e.ids=[604],e.modules={846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},4870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},3033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},9646:e=>{"use strict";e.exports=require("child_process")},6028:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>m,routeModule:()=>c,serverHooks:()=>g,workAsyncStorage:()=>l,workUnitAsyncStorage:()=>p});var s={};r.r(s),r.d(s,{GET:()=>u});var a=r(2706),o=r(8203),n=r(5994),i=r(9646),d=r(2021);async function u(e,{params:t}){let r=t.deviceId,s=(0,d.y)(r),a=e.nextUrl.searchParams.get("app");if(!s)return new Response("Device ID is required",{status:400});let o=null;try{let e=new ReadableStream({start(e){let t=["-s",s,"logcat"];if(a)(0,i.spawn)("adb",["-s",s,"shell","pidof",a]).stdout.on("data",t=>{let r=t.toString().trim();if(r){if(!(o=(0,i.spawn)("adb",["-s",s,"logcat","--pid",r])).stdout||!o.stderr)throw Error("Failed to start logcat process");o.stdout.on("data",t=>{e.enqueue(`data: ${JSON.stringify(t.toString())}

`)}),o.stderr.on("data",t=>{e.enqueue(`data: ${JSON.stringify({error:t.toString()})}

`)}),o.on("close",t=>{e.enqueue(`data: ${JSON.stringify({closed:!0,code:t})}

`),e.close()})}else e.enqueue(`data: ${JSON.stringify({error:"App not running"})}

`),e.close()});else{if(!(o=(0,i.spawn)("adb",t)).stdout||!o.stderr)throw Error("Failed to start logcat process");o.stdout.on("data",t=>{e.enqueue(`data: ${JSON.stringify(t.toString())}

`)}),o.stderr.on("data",t=>{e.enqueue(`data: ${JSON.stringify({error:t.toString()})}

`)}),o.on("close",t=>{e.enqueue(`data: ${JSON.stringify({closed:!0,code:t})}

`),e.close()})}},cancel(){o&&!o.killed&&o.kill()}});return new Response(e,{headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}catch(e){return o&&!o.killed&&o.kill(),console.error("Error in logcat stream:",e),new Response("Internal Server Error",{status:500})}}let c=new a.AppRouteRouteModule({definition:{kind:o.RouteKind.APP_ROUTE,page:"/api/device/[deviceId]/system/logcat/stream/route",pathname:"/api/device/[deviceId]/system/logcat/stream",filename:"route",bundlePath:"app/api/device/[deviceId]/system/logcat/stream/route"},resolvedPagePath:"/Users/saleeh/codes/appmaker/adb-web/src/app/api/device/[deviceId]/system/logcat/stream/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:l,workUnitAsyncStorage:p,serverHooks:g}=c;function m(){return(0,n.patchFetch)({workAsyncStorage:l,workUnitAsyncStorage:p})}},6487:()=>{},8335:()=>{},2706:(e,t,r)=>{"use strict";e.exports=r(4870)},2021:(e,t,r)=>{"use strict";function s(e){return Buffer.from(e,"base64").toString()}r.d(t,{y:()=>s})}};var t=require("../../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[994],()=>r(6028));module.exports=s})();