/**
 * Shared types for the per-step communication template configuration feature.
 * Used across the read service, repositories, and the master clone path.
 */

/**
 * Admin's per-step selection coming from the Add Program form. One entry per step,
 * listing the master template ids ticked for that step.
 */
export interface CommunicationStepSelection {
  step: string;
  enabledMasterTemplateIds: number[];
}

/**
 * Per-(program, master) attachment state. Returned by the clone repo and consumed
 * by the read service to compute `isEnabled` for every (step, master) pair.
 */
export interface ProgramTemplateAttachment {
  masterTemplateId: number;
  attachedSteps: string[];
}

/**
 * One template row inside a step in the read response. Every step lists the FULL
 * template universe for the program type — natives pre-ticked, others tickable.
 */
export interface CommunicationConfigTemplate {
  masterTemplateId: number;
  templateAccessKey: string;
  templateName: string | null;
  channel: string;
  templateId: string | null;
  sandboxTemplateId: string | null;
  /** true if this template is attached & enabled for THIS step */
  isEnabled: boolean;
  /** true when master.step === step.value — drives default pre-tick + "native" badge */
  isNativeToStep: boolean;
}

/**
 * One step accordion in the read response.
 */
export interface CommunicationConfigStep {
  value: string;
  label: string;
  templates: CommunicationConfigTemplate[];
}

/**
 * Full Add Program communication-config read payload (same shape for both the
 * by-program-type preview and the by-program edit endpoints).
 */
export interface CommunicationConfigResponse {
  steps: CommunicationConfigStep[];
}
