import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LektricoClient } from './lektrico.classes.client.js';
import { LektricoConfigFlow } from './lektrico.classes.configflow.js';
import { createLektricoDiscoveryDescriptor } from './lektrico.discovery.js';
import type { ILektricoConfig } from './lektrico.types.js';
import { lektricoDomain, lektricoProfile } from './lektrico.types.js';

export class LektricoIntegration extends SimpleLocalIntegration<ILektricoConfig> {
  public readonly domain = lektricoDomain;
  public readonly discoveryDescriptor = createLektricoDiscoveryDescriptor();
  public readonly configFlow = new LektricoConfigFlow();

  constructor() {
    super(lektricoProfile);
  }

  public override async setup(configArg: ILektricoConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(lektricoProfile, new LektricoClient(configArg));
  }
}
