// Shared, plain-language explanations surfaced as hover/focus tooltips across the
// admin UI (pipeline steps, services, and the Quality-Score shortcodes). Keeping
// them in one place means the Vertex settings, Feature Flags, Services and
// Cost & Quality screens all describe the same thing the same way.

/** Per pipeline-step / feature-flag descriptions (covers Vertex steps + flags). */
export const PIPELINE_STEP_INFO: Record<string, string> = {
  ingestion: "Polls Ergonode for products in status “New” and claims them for processing.",
  research: "Finds each attribute’s value from trusted web sources, always with a citation (source URL + excerpt).",
  manipulation: "Cleans and formats a researched value per the manipulation rules — units, casing, clean HTML, tone of voice.",
  scoring: "Runs the Business-Rule Compliance gate and computes the Attribute Quality Score (AQS) for every value.",
  alt_text: "Writes multilingual alt text (DE / EN / FR / IT) for each accepted image.",
  image: "Generates product and mood images with the Gemini image model, seeded with the sourced reference images.",
  "image-sourcing": "Collects candidate images from the trusted-source whitelist to seed image creation.",
  "image-creation": "Generates, normalises (background removal, optical centring) and WebP-encodes the final images.",
  segmentation: "Removes the image background (foreground mask) so the product can be optically centred on a clean canvas.",
  video: "Generates one or more product videos with Vertex Veo (image-to-video, seeded from the hero image) — a studio turntable clip and/or a lifestyle scene, per the product's category or a targeted run.",
  "video-creation": "Generates AI product videos (Vertex Veo) for products whose category selects one or more video styles. Off by default — enabling it incurs per-clip Veo cost (one clip per selected style).",
  push: "Writes accepted attributes + images back to Ergonode, uploads the ai-product-log CSV and sets Done / Review.",
};

/** Service descriptions for the Services tab (keyed by service name). */
export const SERVICE_INFO: Record<string, string> = {
  ingestion: PIPELINE_STEP_INFO.ingestion,
  research: PIPELINE_STEP_INFO.research,
  manipulation: PIPELINE_STEP_INFO.manipulation,
  scoring: PIPELINE_STEP_INFO.scoring,
  "image-sourcing": PIPELINE_STEP_INFO["image-sourcing"],
  "image-creation": PIPELINE_STEP_INFO["image-creation"],
  "video-creation": PIPELINE_STEP_INFO["video-creation"],
  push: PIPELINE_STEP_INFO.push,
};

export type ScoreTerm = { code: string; name: string; desc: string };

/** Quality-Score shortcodes (AQS formula + sub-scores), reused on several screens. */
export const SCORE_TERMS: ScoreTerm[] = [
  { code: "AQS", name: "Attribute Quality Score", desc: "Overall 0–1 score for an enriched attribute. An attribute needs AQS ≥ the threshold (default 0.8) to be pushed. AQS = 0.35·TSQ + 0.35·FPV + 0.25·CSC + 0.05·VFQ (and 0 if BRC fails)." },
  { code: "BRC", name: "Business-Rule Compliance", desc: "Knock-out gate. If the value breaks a business rule, BRC = 0 and the whole AQS becomes 0 regardless of the other sub-scores." },
  { code: "TSQ", name: "Trustworthy Source Quality", desc: "How authoritative the source is (manufacturer 1.0 … unknown 0.40). Weight 35%." },
  { code: "FPV", name: "Factual Plausibility", desc: "Is the value sensible for this product? Weight 35%." },
  { code: "CSC", name: "Cross-Source Consistency", desc: "Do multiple independent sources agree on the value? Weight 25%." },
  { code: "VFQ", name: "Visual Formatting Quality", desc: "Correct units, encoding and clean HTML. Weight 5%." },
];

/** Quick lookup of a single score term by code (e.g. "AQS"). */
export const SCORE_TERM_BY_CODE: Record<string, ScoreTerm> = Object.fromEntries(
  SCORE_TERMS.map((t) => [t.code, t]),
);
