import { useAppStore } from '@/store/app-store'

/**
 * Returns the profiled device ID — the device all feature panels monitor.
 * `isMonitoring` is false when no device is being profiled.
 *
 * This is separate from `selectedDeviceId` (info panel view).
 * Data in `deviceCache` is never cleared on device switch.
 */
export function useActiveDevice() {
  const { profiledDeviceId, deviceCache, patchDeviceCache, clearDeviceCache } = useAppStore()

  return {
    activeDeviceId: profiledDeviceId,
    isMonitoring: profiledDeviceId !== null,
    deviceCache,
    patchDeviceCache,
    clearDeviceCache,
  }
}
