import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MaxcubeClient } from './maxcube.classes.client.js';
import { MaxcubeConfigFlow } from './maxcube.classes.configflow.js';
import { createMaxcubeDiscoveryDescriptor } from './maxcube.discovery.js';
import type { IMaxcubeConfig } from './maxcube.types.js';
import { maxcubeDomain, maxcubeProfile } from './maxcube.types.js';

export class MaxcubeIntegration extends SimpleLocalIntegration<IMaxcubeConfig> {
  public readonly domain = maxcubeDomain;
  public readonly discoveryDescriptor = createMaxcubeDiscoveryDescriptor();
  public readonly configFlow = new MaxcubeConfigFlow();

  constructor() {
    super(maxcubeProfile);
  }

  public async setup(configArg: IMaxcubeConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(maxcubeProfile, new MaxcubeClient(configArg));
  }
}

export class HomeAssistantMaxcubeIntegration extends MaxcubeIntegration {}
