import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { NetdataClient } from './netdata.classes.client.js';
import { NetdataConfigFlow } from './netdata.classes.configflow.js';
import { createNetdataDiscoveryDescriptor } from './netdata.discovery.js';
import type { INetdataConfig } from './netdata.types.js';
import { netdataDomain, netdataProfile } from './netdata.types.js';

export class NetdataIntegration extends SimpleLocalIntegration<INetdataConfig> {
  public readonly domain = netdataDomain;
  public readonly discoveryDescriptor = createNetdataDiscoveryDescriptor();
  public readonly configFlow = new NetdataConfigFlow();

  constructor() {
    super(netdataProfile);
  }

  public override async setup(configArg: INetdataConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(netdataProfile, new NetdataClient(configArg));
  }
}

export class HomeAssistantNetdataIntegration extends NetdataIntegration {}
