import type { ISimpleLocalConfig, ISimpleLocalIntegrationProfile, ISimpleLocalSnapshot, TSimpleLocalRawData } from '../../core/index.js';

export const mqttEventstreamDomain = "mqtt_eventstream";
export const mqttEventstreamDefaultName = "MQTT Eventstream";
export const mqttEventstreamLiveUnsupportedReason = "MQTT Eventstream live operation requires Home Assistant's mqtt.async_publish/mqtt.async_subscribe broker semantics on configured publish_topic/subscribe_topic values; the HA source documents no direct local HTTP/TCP/TLS/file protocol for events.";

export type TMqttEventstreamRawData = TSimpleLocalRawData;
export interface IMqttEventstreamSnapshot extends ISimpleLocalSnapshot {}
export interface IMqttEventstreamConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantMqttEventstreamConfig extends IMqttEventstreamConfig {}

export const mqttEventstreamProfile: ISimpleLocalIntegrationProfile = {
  domain: mqttEventstreamDomain,
  displayName: "MQTT Eventstream",
  manufacturer: "MQTT Eventstream",
  model: "MQTT Eventstream local integration",
  defaultName: mqttEventstreamDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "mqtt_eventstream",
    "MQTT Eventstream",
    "Mqtt Eventstream",
    "MQTT",
    "Eventstream",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/mqtt_eventstream",
    "upstreamDomain": "mqtt_eventstream",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [],
    "dependencies": [
      "mqtt",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/mqtt_eventstream",
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
      "blocker": mqttEventstreamLiveUnsupportedReason,
    },
    "localApi": {
      "status": "snapshot/injected-client only: Home Assistant mqtt_eventstream publishes and subscribes through the HA MQTT integration and requires broker topic semantics; no direct local HTTP/TCP/TLS/file protocol is available in HA source.",
      "implemented": [
        "safe manual snapshots, rawData, snapshotProvider, and injected native-client snapshot behavior for MQTT Eventstream",
        "runtime mapping for MQTT Eventstream device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only",
      ],
      "explicitUnsupported": [
        "native MQTT Eventstream event publish/subscribe handling because Home Assistant delegates it to mqtt.async_publish and mqtt.async_subscribe broker semantics",
        "opening or emulating an MQTT broker/client session, topic subscription, QoS, retained-message, or wildcard behavior without adding an MQTT dependency",
        "claiming live MQTT Eventstream polling, pairing, subscription, or write success without an injected native client or snapshotProvider",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
