import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { InfluxdbClient } from './influxdb.classes.client.js';
import { InfluxdbConfigFlow } from './influxdb.classes.configflow.js';
import { createInfluxdbDiscoveryDescriptor } from './influxdb.discovery.js';
import type { IInfluxdbConfig } from './influxdb.types.js';
import { influxdbDomain, influxdbProfile } from './influxdb.types.js';

export class InfluxdbIntegration extends SimpleLocalIntegration<IInfluxdbConfig> {
  public readonly domain = influxdbDomain;
  public readonly discoveryDescriptor = createInfluxdbDiscoveryDescriptor();
  public readonly configFlow = new InfluxdbConfigFlow();

  constructor() {
    super(influxdbProfile);
  }

  public async setup(configArg: IInfluxdbConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(influxdbProfile, new InfluxdbClient(configArg));
  }
}

export class HomeAssistantInfluxdbIntegration extends InfluxdbIntegration {}
