import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LametricClient } from './lametric.classes.client.js';
import { LametricConfigFlow } from './lametric.classes.configflow.js';
import { createLametricDiscoveryDescriptor } from './lametric.discovery.js';
import type { ILametricConfig } from './lametric.types.js';
import { lametricDomain, lametricProfile } from './lametric.types.js';

export class LametricIntegration extends SimpleLocalIntegration<ILametricConfig> {
  public readonly domain = lametricDomain;
  public readonly discoveryDescriptor = createLametricDiscoveryDescriptor();
  public readonly configFlow = new LametricConfigFlow();

  constructor() {
    super(lametricProfile);
  }

  public async setup(configArg: ILametricConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(lametricProfile, new LametricClient(configArg));
  }
}
