(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5315],{21:(e,r,a)=>{Promise.resolve().then(a.bind(a,4763))},4763:(e,r,a)=>{"use strict";a.r(r),a.d(r,{default:()=>i});var t=a(5155),s=a(2115),d=a(8373);function l(e){let{onDeviceSelect:r,selectedDevice:a}=e,[d,l]=(0,s.useState)([]),[i,n]=(0,s.useState)(!0),[c,o]=(0,s.useState)(null),x=async()=>{try{let e=await fetch("/api/devices"),t=await e.json();if(!e.ok)throw Error(t.error||"Failed to fetch devices");l(t.devices),a&&!t.devices.find(e=>e.id===a.id)?r(null):!a&&t.devices.length>0&&r(t.devices[0]),o(null)}catch(e){o(e instanceof Error?e.message:"An error occurred")}finally{n(!1)}};return((0,s.useEffect)(()=>{x();let e=setInterval(x,5e3);return()=>clearInterval(e)},[]),i)?(0,t.jsx)("div",{className:"h-16 flex items-center",children:(0,t.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-primary border-t-transparent"})}):c?(0,t.jsx)("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4",children:(0,t.jsxs)("div",{className:"flex items-center",children:[(0,t.jsx)("span",{className:"text-2xl mr-2",children:"⚠️"}),(0,t.jsxs)("p",{className:"text-red-800 dark:text-red-200",children:["Error: ",c]})]})}):0===d.length?(0,t.jsxs)("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-8 text-center",children:[(0,t.jsx)("div",{className:"text-4xl mb-4",children:"\uD83D\uDCF1"}),(0,t.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Devices Connected"}),(0,t.jsx)("p",{className:"text-gray-500 dark:text-gray-400",children:"Connect an Android device via USB or set up wireless debugging"})]}):(0,t.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,t.jsx)("label",{className:"text-gray-700 dark:text-gray-300",children:"Select Device:"}),(0,t.jsx)("select",{value:(null==a?void 0:a.id)||"",onChange:e=>{r(d.find(r=>r.id===e.target.value)||null)},className:"flex-1 max-w-xs px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",children:d.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.model||e.id," ","device"!==e.status?"(".concat(e.status,")"):""]},e.id))}),(0,t.jsx)("button",{onClick:x,className:"px-4 py-2 bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-200 rounded-lg hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:"Refresh"})]})}function i(){let[e,r]=(0,s.useState)(null);return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsx)("div",{className:"flex items-center justify-between",children:(0,t.jsx)("h1",{className:"text-3xl font-bold",children:"App Management"})}),(0,t.jsx)(l,{onDeviceSelect:r,selectedDevice:e}),e&&(0,t.jsx)(d.A,{deviceId:e.id})]})}}},e=>{var r=r=>e(e.s=r);e.O(0,[4129,3333,8280,210,814,4706,8373,8441,1517,7358],()=>r(21)),_N_E=e.O()}]);