// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type JsonValue = any;

export interface ConfigField {
  key: string;
  label: string;
  type: "text" | "password" | "number" | "boolean" | "select" | "url";
  placeholder?: string;
  required?: boolean;
  options?: { value: string; label: string }[];
  helpText?: string;
}

export interface ExternalField {
  id: string;
  name: string;
  type: string;
}

export interface TestResult {
  success: boolean;
  message: string;
}

export interface PushResult {
  success: boolean;
  externalId?: string;
  message?: string;
}

export interface CardData {
  id: string;
  name?: string | null;
  email?: string | null;
  cellPhone?: string | null;
  homePhone?: string | null;
  address?: string | null;
  aptNumber?: string | null;
  city?: string | null;
  state?: string | null;
  zip?: string | null;
  gender?: string | null;
  dateOfBirth?: string | null;
  maritalStatus?: string | null;
  visitType?: string | null;
  prayerRequests?: string | null;
  followUp?: string | null;
  notes?: string | null;
  serviceAttended?: string | null;
  firstTimeGuestDate?: Date | null;
  salvationDate?: Date | null;
  messageTopics?: JsonValue;
  nextStep?: JsonValue;
  howHeard?: JsonValue;
  [key: string]: unknown;
}

export type ProviderCategory =
  | "chms"
  | "project_mgmt"
  | "spreadsheet"
  | "export"
  | "webhook";

export interface SetupStep {
  title: string;
  body: string;
  linkUrl?: string;
  linkLabel?: string;
}

export interface SetupGuide {
  summary: string;
  steps: SetupStep[];
  docsUrl?: string;
}

export interface IntegrationProvider {
  id: string;
  name: string;
  description: string;
  icon: string;
  category: ProviderCategory;
  configFields: ConfigField[];
  supportsFieldMapping: boolean;
  supportsOAuth: boolean;
  setupGuide?: SetupGuide;

  testConnection(config: JsonValue): Promise<TestResult>;
  getExternalFields?(config: JsonValue): Promise<ExternalField[]>;
  pushCard(
    card: CardData,
    config: JsonValue,
    mapping: JsonValue
  ): Promise<PushResult>;
}
