import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LoqedClient } from './loqed.classes.client.js';
import { LoqedConfigFlow } from './loqed.classes.configflow.js';
import { createLoqedDiscoveryDescriptor } from './loqed.discovery.js';
import type { ILoqedConfig } from './loqed.types.js';
import { loqedDomain, loqedProfile } from './loqed.types.js';

export class LoqedIntegration extends SimpleLocalIntegration<ILoqedConfig> {
  public readonly domain = loqedDomain;
  public readonly discoveryDescriptor = createLoqedDiscoveryDescriptor();
  public readonly configFlow = new LoqedConfigFlow();

  constructor() {
    super(loqedProfile);
  }

  public async setup(configArg: ILoqedConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(loqedProfile, new LoqedClient(configArg));
  }
}
