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

export const localCalendarDomain = "local_calendar";
export const localCalendarDefaultName = "Local Calendar";

export type TLocalCalendarRawData = TSimpleLocalRawData;
export interface ILocalCalendarEvent extends Record<string, unknown> {
  uid?: string;
  summary?: string;
  description?: string;
  location?: string;
  start?: string;
  end?: string;
  startRaw?: string;
  endRaw?: string;
  rrule?: string;
  allDay?: boolean;
}
export interface ILocalCalendarSnapshot extends ISimpleLocalSnapshot {}
export interface ILocalCalendarConfig extends ISimpleLocalConfig {
  url?: string;
  macAddress?: string;
  deviceId?: string;
  filePath?: string;
  file_path?: string;
  icsFile?: string;
  ics_file?: string;
  calendarName?: string;
  calendar_name?: string;
}

export const localCalendarProfile: ISimpleLocalIntegrationProfile = {
  domain: localCalendarDomain,
  displayName: "Local Calendar",
  manufacturer: "Local Calendar",
  model: "Local Calendar local integration",
  defaultName: localCalendarDefaultName,
  defaultProtocol: 'local',
  status: "read-only-runtime",
  platforms: [
    "sensor",
  ],
  serviceDomains: [],
  controlServices: [],
  discoverySources: [
    'manual',
    'custom',
  ],
  discoveryKeywords: [
    "local_calendar",
    "Local Calendar",
    "Local",
    "Calendar",
  ],
  metadata: {
    "source": "home-assistant/core",
    "upstreamPath": "homeassistant/components/local_calendar",
    "upstreamDomain": "local_calendar",
    "iotClass": "local_polling",
    "requirements": [
      "ical==13.2.2",
    ],
    "dependencies": [
      "file_upload",
    ],
    "codeowners": [
      "@allenporter",
    ],
    "configFlow": true,
    "documentation": "https://www.home-assistant.io/integrations/local_calendar",
    "loggers": [
      "ical",
    ],
    "runtime": {
      "type": "read-only-runtime",
      "services": [
        "snapshot",
        "status",
        "refresh",
      ],
      "platforms": [
        "sensor",
      ],
      "controls": false,
    },
    "localApi": {
      "implemented": [
        "local .ics file snapshots from config.filePath, config.file_path, config.icsFile, or config.ics_file",
        "basic VEVENT parsing for UID, SUMMARY, DESCRIPTION, LOCATION, DTSTART, DTEND, and RRULE fields",
        "manual snapshots, rawData, snapshotProvider, and injected native clients",
      ],
      "explicitUnsupported": [
        "recurrence expansion and recurrence-range edit/delete require Home Assistant's Python ical EventStore; the native runtime exposes raw RRULE only",
        "Home Assistant file_upload processing and uploaded file validation flows",
        "calendar create/update/delete write success without injected client.execute or commandExecutor",
      ],
    },
  },
};
