import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { PioneerClient } from './pioneer.classes.client.js';
import { PioneerConfigFlow } from './pioneer.classes.configflow.js';
import { createPioneerDiscoveryDescriptor } from './pioneer.discovery.js';
import type { IPioneerConfig } from './pioneer.types.js';
import { pioneerDomain, pioneerProfile } from './pioneer.types.js';

export class PioneerIntegration extends SimpleLocalIntegration<IPioneerConfig> {
  public readonly domain = pioneerDomain;
  public readonly discoveryDescriptor = createPioneerDiscoveryDescriptor();
  public readonly configFlow = new PioneerConfigFlow();

  constructor() {
    super(pioneerProfile);
  }

  public override async setup(configArg: IPioneerConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(pioneerProfile, new PioneerClient(configArg));
  }
}

export class HomeAssistantPioneerIntegration extends PioneerIntegration {}
