import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { MqttJsonClient } from './mqtt_json.classes.client.js';
import { MqttJsonConfigFlow } from './mqtt_json.classes.configflow.js';
import { createMqttJsonDiscoveryDescriptor } from './mqtt_json.discovery.js';
import type { IMqttJsonConfig } from './mqtt_json.types.js';
import { mqttJsonDomain, mqttJsonProfile } from './mqtt_json.types.js';

export class MqttJsonIntegration extends SimpleLocalIntegration<IMqttJsonConfig> {
  public readonly domain = mqttJsonDomain;
  public readonly discoveryDescriptor = createMqttJsonDiscoveryDescriptor();
  public readonly configFlow = new MqttJsonConfigFlow();

  constructor() {
    super(mqttJsonProfile);
  }

  public async setup(configArg: IMqttJsonConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(mqttJsonProfile, new MqttJsonClient(configArg));
  }
}

export class HomeAssistantMqttJsonIntegration extends MqttJsonIntegration {}
