import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { NzbgetClient } from './nzbget.classes.client.js';
import { NzbgetConfigFlow } from './nzbget.classes.configflow.js';
import { createNzbgetDiscoveryDescriptor } from './nzbget.discovery.js';
import type { INzbgetConfig } from './nzbget.types.js';
import { nzbgetDomain, nzbgetProfile } from './nzbget.types.js';

export class NzbgetIntegration extends SimpleLocalIntegration<INzbgetConfig> {
  public readonly domain = nzbgetDomain;
  public readonly discoveryDescriptor = createNzbgetDiscoveryDescriptor();
  public readonly configFlow = new NzbgetConfigFlow();

  constructor() {
    super(nzbgetProfile);
  }

  public override async setup(configArg: INzbgetConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(nzbgetProfile, new NzbgetClient(configArg));
  }
}

export class HomeAssistantNzbgetIntegration extends NzbgetIntegration {}
