import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { KwbClient } from './kwb.classes.client.js';
import { KwbConfigFlow } from './kwb.classes.configflow.js';
import { createKwbDiscoveryDescriptor } from './kwb.discovery.js';
import type { IKwbConfig } from './kwb.types.js';
import { kwbDomain, kwbProfile } from './kwb.types.js';

export class KwbIntegration extends SimpleLocalIntegration<IKwbConfig> {
  public readonly domain = kwbDomain;
  public readonly discoveryDescriptor = createKwbDiscoveryDescriptor();
  public readonly configFlow = new KwbConfigFlow();

  constructor() {
    super(kwbProfile);
  }

  public async setup(configArg: IKwbConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(kwbProfile, new KwbClient(configArg));
  }
}
