import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { EmoncmsHistoryClient } from './emoncms_history.classes.client.js';
import { EmoncmsHistoryConfigFlow } from './emoncms_history.classes.configflow.js';
import { createEmoncmsHistoryDiscoveryDescriptor } from './emoncms_history.discovery.js';
import type { IEmoncmsHistoryConfig } from './emoncms_history.types.js';
import { emoncmsHistoryDomain, emoncmsHistoryProfile } from './emoncms_history.types.js';

export class EmoncmsHistoryIntegration extends SimpleLocalIntegration<IEmoncmsHistoryConfig> {
  public readonly domain = emoncmsHistoryDomain;
  public readonly discoveryDescriptor = createEmoncmsHistoryDiscoveryDescriptor();
  public readonly configFlow = new EmoncmsHistoryConfigFlow();

  constructor() {
    super(emoncmsHistoryProfile);
  }

  public async setup(configArg: IEmoncmsHistoryConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(emoncmsHistoryProfile, new EmoncmsHistoryClient(configArg));
  }
}

export class HomeAssistantEmoncmsHistoryIntegration extends EmoncmsHistoryIntegration {}
