import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { Enigma2Client } from './enigma2.classes.client.js';
import { Enigma2ConfigFlow } from './enigma2.classes.configflow.js';
import { createEnigma2DiscoveryDescriptor } from './enigma2.discovery.js';
import type { IEnigma2Config } from './enigma2.types.js';
import { enigma2Domain, enigma2Profile } from './enigma2.types.js';

export class Enigma2Integration extends SimpleLocalIntegration<IEnigma2Config> {
  public readonly domain = enigma2Domain;
  public readonly discoveryDescriptor = createEnigma2DiscoveryDescriptor();
  public readonly configFlow = new Enigma2ConfigFlow();

  constructor() {
    super(enigma2Profile);
  }

  public async setup(configArg: IEnigma2Config, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(enigma2Profile, new Enigma2Client(configArg));
  }
}

export class HomeAssistantEnigma2Integration extends Enigma2Integration {}
