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

export const overseerrDomain = "overseerr";
export const overseerrDefaultName = "Seerr";

export type TOverseerrRawData = TSimpleLocalRawData;
export interface IOverseerrSnapshot extends ISimpleLocalSnapshot {}
export interface IOverseerrConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  api_key?: string;
  ssl?: boolean;
  protocol?: 'http' | 'https';
}
export interface IHomeAssistantOverseerrConfig extends IOverseerrConfig {}

export const overseerrProfile: ISimpleLocalIntegrationProfile = {
  domain: overseerrDomain,
  displayName: "Seerr",
  manufacturer: "Seerr",
  model: "Seerr local integration",
  defaultName: overseerrDefaultName,
  defaultPort: 5055,
  defaultHttpPath: '/api/v1/status',
  defaultProtocol: 'http',
  status: "control-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [
    "get_requests",
  ],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "overseerr",
    "Seerr",
    "Overseerr",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/overseerr",
    "upstreamDomain": "overseerr",
    "integrationType": "service",
    "iotClass": "local_push",
    "qualityScale": "platinum",
    "requirements": [
      "python-overseerr==0.9.0",
    ],
    "dependencies": [
      "http",
      "webhook",
    ],
    "afterDependencies": [
      "cloud",
    ],
    "codeowners": [
      "@joostlek",
      "@AmGarera",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/overseerr",
    "runtime": {
      "type": "control-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
        "get_requests",
      ],
      "platforms": [
        "sensor",
      ],
      "polling": "local Seerr HTTP API snapshots via /api/v1/request/count and /api/v1/issue/count with X-Api-Key authentication",
      "controls": "get_requests is implemented through the local Seerr HTTP API; other controls require an injected client.execute or commandExecutor",
    },
    "localApi": {
      "implemented": [
        "GET /api/v1/request/count and GET /api/v1/issue/count with X-Api-Key authentication for live local snapshots",
        "GET /api/v1/request with optional filter/sort/requestedBy query parameters for get_requests service responses",
        "GET /api/v1/movie/{tmdbId} and GET /api/v1/tv/{tmdbId} best-effort detail enrichment for request service results",
        "runtime mapping for Seerr device snapshots and Home Assistant platform metadata",
        "manual snapshots, rawData, snapshotProvider, and injected native clients",
      ],
      "explicitUnsupported": [
        "registering or receiving Seerr webhook push callbacks because this runtime has no inbound webhook server contract",
        "creating, approving, or modifying Seerr requests; only the Home Assistant get_requests service path is implemented",
        "Home Assistant entity registry migrations and repair flows",
        "claiming non-get_requests command success without injected client.execute or commandExecutor",
      ],
    },
  },
};
