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

export const hlkSw16Domain = 'hlk_sw16';
export const hlkSw16DefaultName = 'Hi-Link HLK-SW16';
export const hlkSw16DefaultPort = 8080;

export type THlkSw16RawData = TSimpleLocalRawData;
export interface IHlkSw16Snapshot extends ISimpleLocalSnapshot {}
export interface IHlkSw16Config extends ISimpleLocalConfig {
  switches?: Record<string, string | { name?: string }>;
}
export interface IHomeAssistantHlkSw16Config extends IHlkSw16Config {}

export const hlkSw16Profile: ISimpleLocalIntegrationProfile = {
  domain: 'hlk_sw16',
  displayName: 'Hi-Link HLK-SW16',
  manufacturer: 'Hi-Link',
  model: 'HLK-SW16',
  defaultName: hlkSw16DefaultName,
  defaultPort: hlkSw16DefaultPort,
  defaultProtocol: 'tcp',
  status: 'read-only-runtime',
  platforms: [
    'switch',
  ],
  serviceDomains: [
    'switch',
  ],
  controlServices: [
    'toggle',
    'turn_off',
    'turn_on',
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    'hlk-sw16',
    'hlk_sw16',
    'hi-link',
    'relay',
    'switch',
  ],
  metadata: {
    source: 'home-assistant/core',
    upstreamPath: 'homeassistant/components/hlk_sw16',
    upstreamDomain: 'hlk_sw16',
    integrationType: 'device',
    iotClass: 'local_push',
    qualityScale: undefined,
    requirements: [
      'hlk-sw16==0.0.9',
    ],
    dependencies: [],
    afterDependencies: [],
    codeowners: [
      '@jameshilliard',
    ],
    configFlow: true,
    documentation: 'https://www.home-assistant.io/integrations/hlk_sw16',
    defaults: {
      port: hlkSw16DefaultPort,
      reconnectIntervalSeconds: 10,
      keepAliveIntervalSeconds: 3,
      connectionTimeoutSeconds: 10,
      relayIds: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'],
    },
    platforms: [
      'switch',
    ],
    runtime: {
      type: 'read-only-runtime',
      services: [
        'snapshot',
        'status',
        'refresh',
        'toggle',
        'turn_off',
        'turn_on',
      ],
      platforms: [
        'switch',
      ],
      controls: 'delegated only to an injected client.execute or commandExecutor',
    },
    localApi: {
      implemented: [
        'manual local setup for host/port metadata, snapshots, relay state arrays or maps, snapshotProvider, and injected native clients',
        'runtime mapping of sixteen HLK-SW16 relays to switch entities',
        'safe switch control delegation to injected client.execute or commandExecutor only',
      ],
      explicitUnsupported: [
        'native hlk-sw16 protocol connection, push callbacks, keepalive, and reconnect loop in this TypeScript package',
        'claiming relay turn_on, turn_off, or toggle success without an injected client.execute or commandExecutor',
        'Home Assistant YAML import of per-relay switch names',
      ],
    },
  },
};
