import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { PjlinkClient } from './pjlink.classes.client.js';
import { PjlinkConfigFlow } from './pjlink.classes.configflow.js';
import { createPjlinkDiscoveryDescriptor } from './pjlink.discovery.js';
import type { IPjlinkConfig } from './pjlink.types.js';
import { pjlinkDomain, pjlinkProfile } from './pjlink.types.js';

export class PjlinkIntegration extends SimpleLocalIntegration<IPjlinkConfig> {
  public readonly domain = pjlinkDomain;
  public readonly discoveryDescriptor = createPjlinkDiscoveryDescriptor();
  public readonly configFlow = new PjlinkConfigFlow();

  constructor() {
    super(pjlinkProfile);
  }

  public override async setup(configArg: IPjlinkConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(pjlinkProfile, new PjlinkClient(configArg));
  }
}

export class HomeAssistantPjlinkIntegration extends PjlinkIntegration {}
