import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { IotawattClient } from './iotawatt.classes.client.js';
import { IotawattConfigFlow } from './iotawatt.classes.configflow.js';
import { createIotawattDiscoveryDescriptor } from './iotawatt.discovery.js';
import type { IIotawattConfig } from './iotawatt.types.js';
import { iotawattDomain, iotawattProfile } from './iotawatt.types.js';

export class IotawattIntegration extends SimpleLocalIntegration<IIotawattConfig> {
  public readonly domain = iotawattDomain;
  public readonly discoveryDescriptor = createIotawattDiscoveryDescriptor();
  public readonly configFlow = new IotawattConfigFlow();

  constructor() {
    super(iotawattProfile);
  }

  public async setup(configArg: IIotawattConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(iotawattProfile, new IotawattClient(configArg));
  }
}
