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

export const hikvisioncamDomain = 'hikvisioncam';
export const hikvisioncamDefaultName = 'Hikvision Camera Motion Detection';
export const hikvisioncamDefaultPort = 80;
export const hikvisioncamDefaultUsername = 'admin';

export type THikvisioncamRawData = TSimpleLocalRawData;
export interface IHikvisioncamSnapshot extends ISimpleLocalSnapshot {}
export interface IHikvisioncamConfig extends ISimpleLocalConfig {}
export interface IHomeAssistantHikvisioncamConfig extends IHikvisioncamConfig {}

const hikvisioncamControlServices = [
  'turn_on',
  'turn_off',
  'toggle',
];

export const hikvisioncamProfile: ISimpleLocalIntegrationProfile = {
  domain: hikvisioncamDomain,
  displayName: 'Hikvision',
  manufacturer: 'Hikvision',
  model: 'IP camera',
  defaultName: hikvisioncamDefaultName,
  defaultPort: hikvisioncamDefaultPort,
  defaultProtocol: 'http',
  status: 'read-only-runtime',
  platforms: [
    'switch',
  ],
  serviceDomains: [
    'switch',
  ],
  controlServices: hikvisioncamControlServices,
  discoverySources: [
    'manual',
    'http',
    'custom',
  ],
  discoveryKeywords: [
    'hikvision',
    'hikvisioncam',
    'camera',
    'motion detection',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/hikvisioncam',
    upstreamDomain: 'hikvisioncam',
    iotClass: 'local_polling',
    qualityScale: 'legacy',
    requirements: [
      'hikvision==0.4',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@fbradyirl',
    ],
    configFlow: false,
    documentation: 'https://www.home-assistant.io/integrations/hikvisioncam',
    loggers: [
      'hikvision',
    ],
    defaults: {
      port: hikvisioncamDefaultPort,
      username: hikvisioncamDefaultUsername,
      password: '12345',
    },
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        ...hikvisioncamControlServices,
      ],
      platforms: [
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local host setup with Hikvision default port and credentials metadata',
        'snapshot, raw motion-detection state, snapshotProvider, and injected native client operation',
        'motion detection switch mapping from Hikvision camera snapshots',
      ],
      explicitUnsupported: [
        'calling the hikvision Python package camera methods directly from this TypeScript package',
        'claiming live motion detection enable or disable success without injected client.execute or commandExecutor',
      ],
    },
  },
};
