import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { LunatoneClient } from './lunatone.classes.client.js';
import { LunatoneConfigFlow } from './lunatone.classes.configflow.js';
import { createLunatoneDiscoveryDescriptor } from './lunatone.discovery.js';
import type { ILunatoneConfig } from './lunatone.types.js';
import { lunatoneDomain, lunatoneProfile } from './lunatone.types.js';

export class LunatoneIntegration extends SimpleLocalIntegration<ILunatoneConfig> {
  public readonly domain = lunatoneDomain;
  public readonly discoveryDescriptor = createLunatoneDiscoveryDescriptor();
  public readonly configFlow = new LunatoneConfigFlow();

  constructor() {
    super(lunatoneProfile);
  }

  public async setup(configArg: ILunatoneConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(lunatoneProfile, new LunatoneClient(configArg));
  }
}
