import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { OverseerrClient } from './overseerr.classes.client.js';
import { OverseerrConfigFlow } from './overseerr.classes.configflow.js';
import { createOverseerrDiscoveryDescriptor } from './overseerr.discovery.js';
import type { IOverseerrConfig } from './overseerr.types.js';
import { overseerrDomain, overseerrProfile } from './overseerr.types.js';

export class OverseerrIntegration extends SimpleLocalIntegration<IOverseerrConfig> {
  public readonly domain = overseerrDomain;
  public readonly discoveryDescriptor = createOverseerrDiscoveryDescriptor();
  public readonly configFlow = new OverseerrConfigFlow();

  constructor() {
    super(overseerrProfile);
  }

  public override async setup(configArg: IOverseerrConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(overseerrProfile, new OverseerrClient(configArg));
  }
}

export class HomeAssistantOverseerrIntegration extends OverseerrIntegration {}
