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

export const itunesDomain = "itunes";
export const itunesDefaultName = "Apple iTunes";

export type TItunesRawData = TSimpleLocalRawData;
export interface IItunesSnapshot extends ISimpleLocalSnapshot {}
export interface IItunesConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  ssl?: boolean;
  useSsl?: boolean;
}
export interface IHomeAssistantItunesConfig extends IItunesConfig {}

export const itunesProfile: ISimpleLocalIntegrationProfile = {
  domain: itunesDomain,
  displayName: "Apple iTunes",
  manufacturer: "Apple iTunes",
  model: "Apple iTunes local integration",
  defaultName: itunesDefaultName,
  defaultPort: 8181,
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "media_player",
  ],
  serviceDomains: [
    "media_player",
  ],
  controlServices: [
    "media_pause",
    "media_play",
    "volume_down",
    "volume_up",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "itunes",
    "Apple iTunes",
    "Itunes",
    "Apple",
    "iTunes",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/itunes",
    "upstreamDomain": "itunes",
    "iotClass": "local_polling",
    "qualityScale": "legacy",
    "requirements": [],
    "configFlow": false,
    "documentation": "https://www.home-assistant.io/integrations/itunes",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "media_pause",
        "media_play",
        "volume_down",
        "volume_up",
      ],
      "platforms": [
        "media_player",
      ],
      "controls": "native itunes-api HTTP control when host/url is configured; otherwise delegated to an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "native HTTP polling of the documented itunes-api /now_playing and /airplay_devices endpoints",
        "native HTTP control through itunes-api PUT endpoints for playback, volume, shuffle, playlists, and AirPlay device selection",
        "manual snapshots, rawData, snapshotProvider, and injected native clients remain supported when no host/url is configured",
      ],
      "explicitUnsupported": [
        "controlling Apple iTunes directly without the third-party local itunes-api HTTP server used by Home Assistant",
        "pairing, cloud auth, or native Apple Music/iTunes process automation outside the documented itunes-api HTTP surface",
        "Home Assistant entity registry migrations and repair flows",
        "claiming command success when neither itunes-api host/url nor injected client.execute/commandExecutor is configured",
      ],
    },
  },
};
