import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MillClient } from './mill.classes.client.js';
import { MillConfigFlow } from './mill.classes.configflow.js';
import { createMillDiscoveryDescriptor } from './mill.discovery.js';
import type { IMillConfig } from './mill.types.js';
import { millDomain, millProfile } from './mill.types.js';

export class MillIntegration extends SimpleLocalIntegration<IMillConfig> {
  public readonly domain = millDomain;
  public readonly discoveryDescriptor = createMillDiscoveryDescriptor();
  public readonly configFlow = new MillConfigFlow();

  constructor() {
    super(millProfile);
  }

  public async setup(configArg: IMillConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(millProfile, new MillClient(configArg));
  }
}
