import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LivisiClient } from './livisi.classes.client.js';
import { LivisiConfigFlow } from './livisi.classes.configflow.js';
import { createLivisiDiscoveryDescriptor } from './livisi.discovery.js';
import type { ILivisiConfig } from './livisi.types.js';
import { livisiDomain, livisiProfile } from './livisi.types.js';

export class LivisiIntegration extends SimpleLocalIntegration<ILivisiConfig> {
  public readonly domain = livisiDomain;
  public readonly discoveryDescriptor = createLivisiDiscoveryDescriptor();
  public readonly configFlow = new LivisiConfigFlow();

  constructor() {
    super(livisiProfile);
  }

  public override async setup(configArg: ILivisiConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(livisiProfile, new LivisiClient(configArg));
  }
}
