import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MqttRoomClient } from './mqtt_room.classes.client.js';
import { MqttRoomConfigFlow } from './mqtt_room.classes.configflow.js';
import { createMqttRoomDiscoveryDescriptor } from './mqtt_room.discovery.js';
import type { IMqttRoomConfig } from './mqtt_room.types.js';
import { mqttRoomDomain, mqttRoomProfile } from './mqtt_room.types.js';

export class MqttRoomIntegration extends SimpleLocalIntegration<IMqttRoomConfig> {
  public readonly domain = mqttRoomDomain;
  public readonly discoveryDescriptor = createMqttRoomDiscoveryDescriptor();
  public readonly configFlow = new MqttRoomConfigFlow();

  constructor() {
    super(mqttRoomProfile);
  }

  public async setup(configArg: IMqttRoomConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(mqttRoomProfile, new MqttRoomClient(configArg));
  }
}

export class HomeAssistantMqttRoomIntegration extends MqttRoomIntegration {}
