import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { KmtronicClient } from './kmtronic.classes.client.js';
import { KmtronicConfigFlow } from './kmtronic.classes.configflow.js';
import { createKmtronicDiscoveryDescriptor } from './kmtronic.discovery.js';
import type { IKmtronicConfig } from './kmtronic.types.js';
import { kmtronicDomain, kmtronicProfile } from './kmtronic.types.js';

export class KmtronicIntegration extends SimpleLocalIntegration<IKmtronicConfig> {
  public readonly domain = kmtronicDomain;
  public readonly discoveryDescriptor = createKmtronicDiscoveryDescriptor();
  public readonly configFlow = new KmtronicConfigFlow();

  constructor() {
    super(kmtronicProfile);
  }

  public async setup(configArg: IKmtronicConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(kmtronicProfile, new KmtronicClient(configArg));
  }
}
