import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { KonnectedClient } from './konnected.classes.client.js';
import { KonnectedConfigFlow } from './konnected.classes.configflow.js';
import { createKonnectedDiscoveryDescriptor } from './konnected.discovery.js';
import type { IKonnectedConfig } from './konnected.types.js';
import { konnectedDomain, konnectedProfile } from './konnected.types.js';

export class KonnectedIntegration extends SimpleLocalIntegration<IKonnectedConfig> {
  public readonly domain = konnectedDomain;
  public readonly discoveryDescriptor = createKonnectedDiscoveryDescriptor();
  public readonly configFlow = new KonnectedConfigFlow();

  constructor() {
    super(konnectedProfile);
  }

  public async setup(configArg: IKonnectedConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(konnectedProfile, new KonnectedClient(configArg));
  }
}
