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

export const mycroftDomain = "mycroft";
export const mycroftDefaultName = "Mycroft";
export const mycroftDefaultPort = 8181;
export const mycroftDefaultPath = '/core';
export const mycroftDefaultTimeoutMs = 5000;

export type TMycroftRawData = TSimpleLocalRawData;
export interface IMycroftSnapshot extends ISimpleLocalSnapshot {}
export interface IMycroftConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantMycroftConfig extends IMycroftConfig {}

export const mycroftProfile: ISimpleLocalIntegrationProfile = {
  domain: mycroftDomain,
  displayName: "Mycroft",
  manufacturer: "Mycroft",
  model: "Mycroft local integration",
  defaultName: mycroftDefaultName,
  defaultPort: mycroftDefaultPort,
  defaultProtocol: 'websocket',
  status: "control-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [
    "notify",
  ],
  controlServices: [
    "mycroft",
    "notify",
    "send_message",
    "speak",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "mycroft",
    "Mycroft",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/mycroft",
    "upstreamDomain": "mycroft",
    "iotClass": "local_push",
    "qualityScale": "legacy",
    "requirements": [
      "mycroftapi==2.0",
    ],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/mycroft",
    "loggers": [
      "mycroftapi",
    ],
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "mycroft",
        "notify",
        "send_message",
        "speak",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": "native local WebSocket notification/speak messages or delegated injected executor",
    },
    "localApi": {
      "implemented": [
        "native local WebSocket status checks and speak/notification sends to ws://host:8181/core, matching mycroftapi 2.0 speak_text behavior",
        "manual local setup for Mycroft endpoints, snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Mycroft device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor when supplied",
      ],
      "explicitUnsupported": [
        "claiming Mycroft pairing, account/cloud API, wake-word, subscription, or conversational session management",
        "generic WebSocket event subscription beyond one-shot local command/status checks",
        "Home Assistant entity registry migrations and repair flows",
      ],
    },
  },
};
