import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { KankunClient } from './kankun.classes.client.js';
import { KankunConfigFlow } from './kankun.classes.configflow.js';
import { createKankunDiscoveryDescriptor } from './kankun.discovery.js';
import type { IKankunConfig } from './kankun.types.js';
import { kankunDomain, kankunProfile } from './kankun.types.js';

export class KankunIntegration extends SimpleLocalIntegration<IKankunConfig> {
  public readonly domain = kankunDomain;
  public readonly discoveryDescriptor = createKankunDiscoveryDescriptor();
  public readonly configFlow = new KankunConfigFlow();

  constructor() {
    super(kankunProfile);
  }

  public async setup(configArg: IKankunConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(kankunProfile, new KankunClient(configArg));
  }
}

export class HomeAssistantKankunIntegration extends KankunIntegration {}
