import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { KiraClient } from './kira.classes.client.js';
import { KiraConfigFlow } from './kira.classes.configflow.js';
import { createKiraDiscoveryDescriptor } from './kira.discovery.js';
import type { IKiraConfig } from './kira.types.js';
import { kiraDomain, kiraProfile } from './kira.types.js';

export class KiraIntegration extends SimpleLocalIntegration<IKiraConfig> {
  public readonly domain = kiraDomain;
  public readonly discoveryDescriptor = createKiraDiscoveryDescriptor();
  public readonly configFlow = new KiraConfigFlow();

  constructor() {
    super(kiraProfile);
  }

  public async setup(configArg: IKiraConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(kiraProfile, new KiraClient(configArg));
  }
}
