import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { IntellifireClient } from './intellifire.classes.client.js';
import { IntellifireConfigFlow } from './intellifire.classes.configflow.js';
import { createIntellifireDiscoveryDescriptor } from './intellifire.discovery.js';
import type { IIntellifireConfig } from './intellifire.types.js';
import { intellifireDomain, intellifireProfile } from './intellifire.types.js';

export class IntellifireIntegration extends SimpleLocalIntegration<IIntellifireConfig> {
  public readonly domain = intellifireDomain;
  public readonly discoveryDescriptor = createIntellifireDiscoveryDescriptor();
  public readonly configFlow = new IntellifireConfigFlow();

  constructor() {
    super(intellifireProfile);
  }

  public async setup(configArg: IIntellifireConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(intellifireProfile, new IntellifireClient(configArg));
  }
}
