import { MobileDevice } from '../types';

export type DeviceApp = 'app2' | 'legacy' | 'rpi';

/**
 * Classifies a device into one of the two apps (plus a separate bucket for
 * RPI/kiosk hardware):
 *  - 'app2'   → modern TASKO App (2), runs on Android / iOS
 *  - 'legacy' → old app, no longer updated (the blue "switch to App 2" devices)
 *  - 'rpi'    → RPI / kiosk devices, shown in their own row
 */
export const getDeviceApp = (device: MobileDevice): DeviceApp => {
  if (device.mcl_type === 'RPI') {
    return 'rpi';
  }
  const version = (device.mcl_ver || '').toLowerCase();
  const isModern = version.includes('android') || version.includes('ios');
  return isModern ? 'app2' : 'legacy';
};
