import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MusicAssistantClient } from './music_assistant.classes.client.js';
import { MusicAssistantConfigFlow } from './music_assistant.classes.configflow.js';
import { createMusicAssistantDiscoveryDescriptor } from './music_assistant.discovery.js';
import type { IMusicAssistantConfig } from './music_assistant.types.js';
import { musicAssistantDomain, musicAssistantProfile } from './music_assistant.types.js';

export class MusicAssistantIntegration extends SimpleLocalIntegration<IMusicAssistantConfig> {
  public readonly domain = musicAssistantDomain;
  public readonly discoveryDescriptor = createMusicAssistantDiscoveryDescriptor();
  public readonly configFlow = new MusicAssistantConfigFlow();

  constructor() {
    super(musicAssistantProfile);
  }

  public async setup(configArg: IMusicAssistantConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(musicAssistantProfile, new MusicAssistantClient(configArg));
  }
}

export class HomeAssistantMusicAssistantIntegration extends MusicAssistantIntegration {}
