import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { HitronCodaClient } from './hitron_coda.classes.client.js';
import { HitronCodaConfigFlow } from './hitron_coda.classes.configflow.js';
import { createHitronCodaDiscoveryDescriptor } from './hitron_coda.discovery.js';
import type { IHitronCodaConfig } from './hitron_coda.types.js';
import { hitronCodaDomain, hitronCodaProfile } from './hitron_coda.types.js';

export class HitronCodaIntegration extends SimpleLocalIntegration<IHitronCodaConfig> {
  public readonly domain = hitronCodaDomain;
  public readonly discoveryDescriptor = createHitronCodaDiscoveryDescriptor();
  public readonly configFlow = new HitronCodaConfigFlow();

  constructor() {
    super(hitronCodaProfile);
  }

  public async setup(configArg: IHitronCodaConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(hitronCodaProfile, new HitronCodaClient(configArg));
  }
}

export class HomeAssistantHitronCodaIntegration extends HitronCodaIntegration {}
