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

export const pingDomain = "ping";
export const pingDefaultName = "Ping (ICMP)";

export type TPingRawData = TSimpleLocalRawData;
export interface IPingSnapshot extends ISimpleLocalSnapshot {}
export interface IPingConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
}
export interface IHomeAssistantPingConfig extends IPingConfig {}

export const pingProfile: ISimpleLocalIntegrationProfile = {
  domain: pingDomain,
  displayName: "Ping (ICMP)",
  manufacturer: "Ping (ICMP)",
  model: "Ping (ICMP) local integration",
  defaultName: pingDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "binary_sensor",
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "ping",
    "Ping (ICMP)",
    "Ping",
    "(ICMP)",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/ping",
    "upstreamDomain": "ping",
    "integrationType": "service",
    "iotClass": "local_polling",
    "qualityScale": "internal",
    "requirements": [
      "icmplib==3.0",
    ],
    "codeowners": [
      "@jpbede",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/ping",
    "loggers": [
      "icmplib",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "binary_sensor",
        "sensor",
      ],
      "controls": false,
    },
    "localApi": {
      "status": "native live Ping polling is unsupported here because Home Assistant uses ICMP via icmplib/raw sockets or the OS ping subprocess; ICMP is not an HTTP/TCP/TLS/file protocol available through existing integration dependencies",
      "implemented": [
        "manual local setup for Ping (ICMP) snapshots, rawData, snapshotProvider, and injected native clients",
        "runtime mapping for Ping (ICMP) device snapshots and Home Assistant platform metadata",
        "safe command delegation to injected client.execute or commandExecutor only; no native ICMP success is claimed",
      ],
      "explicitUnsupported": [
        "native Ping (ICMP) polling because HA requires icmplib/raw ICMP sockets or the OS ping subprocess, neither of which is an allowed HTTP/TCP/TLS/file implementation path here",
        "claiming live Ping (ICMP) 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",
      ],
    },
  },
};
