import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { ItunesClient } from './itunes.classes.client.js';
import { ItunesConfigFlow } from './itunes.classes.configflow.js';
import { createItunesDiscoveryDescriptor } from './itunes.discovery.js';
import type { IItunesConfig } from './itunes.types.js';
import { itunesDomain, itunesProfile } from './itunes.types.js';

export class ItunesIntegration extends SimpleLocalIntegration<IItunesConfig> {
  public readonly domain = itunesDomain;
  public readonly discoveryDescriptor = createItunesDiscoveryDescriptor();
  public readonly configFlow = new ItunesConfigFlow();

  constructor() {
    super(itunesProfile);
  }

  public async setup(configArg: IItunesConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(itunesProfile, new ItunesClient(configArg));
  }
}

export class HomeAssistantItunesIntegration extends ItunesIntegration {}
