import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const epsonDomain = 'epson';
export const epsonDefaultName = 'Epson Projector';

export type TEpsonConnectionType = 'http' | 'serial' | string;
export type TEpsonRawData = TSimpleLocalRawData;
export interface IEpsonSnapshot extends ISimpleLocalSnapshot {}
export interface IEpsonConfig extends ISimpleLocalConfig {
  connectionType?: TEpsonConnectionType;
  serialNumber?: string;
  source?: string;
  cmode?: string;
}
export interface IHomeAssistantEpsonConfig extends IEpsonConfig {}

const epsonControlServices = [
  'turn_on',
  'turn_off',
  'select_source',
  'volume_mute',
  'volume_up',
  'volume_down',
  'media_play',
  'media_pause',
  'media_next_track',
  'media_previous_track',
  'select_cmode',
];

export const epsonProfile: ISimpleLocalIntegrationProfile = {
  domain: epsonDomain,
  displayName: 'Epson',
  manufacturer: 'Epson',
  model: 'Projector',
  defaultName: epsonDefaultName,
  defaultProtocol: 'http',
  status: 'control-runtime',
  platforms: [
    'media_player',
  ],
  serviceDomains: [
    'media_player',
    'epson',
  ],
  controlServices: epsonControlServices,
  discoverySources: [
    'manual',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'epson',
    'projector',
    'epson_projector',
    'emp',
    'serial',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/epson',
    upstreamDomain: 'epson',
    integrationType: 'device',
    iotClass: 'local_polling',
    qualityScale: undefined,
    requirements: [
      'epson-projector==0.6.0',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@pszafer',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/epson',
    haPlatforms: [
      'media_player',
    ],
    connectionTypes: [
      'http',
      'serial',
    ],
    runtime: {
      type: 'control-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        ...epsonControlServices,
      ],
      platforms: [
        'media_player',
      ],
      controls: true,
    },
    localApi: {
      implemented: [
        'manual projector endpoint setup for host or serial path metadata',
        'snapshot, raw data, snapshotProvider, and injected native epson-projector client operation',
        'executor-gated media player and Epson color mode service dispatch',
      ],
      explicitUnsupported: [
        'claiming projector command success without injected client.execute or commandExecutor',
        'direct epson-projector HTTP or serial protocol operation without an injected native client',
        'initial powered-on projector validation without a supplied native client',
      ],
    },
  },
};
