import type { OcrEvalCase } from "../ocrEvalHarness";

// Seed corpus transcribed from src/lib/artifactOcrParser.test.ts. Every label
// here is an exact assertion that already passes, so a fresh run starts at (or
// very near) 100% - which is what makes the accuracy thresholds meaningful as a
// regression gate. Cases that deliberately expect conservative "Unknown ..."
// behavior contribute only their positively-identified fields (level, value)
// so field accuracy stays a measure of correct reads, not correct refusals.
//
// Grow this corpus from human-confirmed review samples via reviewSampleCorpus.ts.

const SOURCE = "test-seed" as const;

export const seedCorpus: OcrEvalCase[] = [
  {
    id: "spring-sands-em",
    ocr: {
      "artifact-title": "A Note in Spring's Lei\n| Sands of Eon Vi",
      "artifact-main-stat": "Elemental Mastery\n187",
      "artifact-substats": "+20\n+ ATK+29\n+ CRIT DMG+15.5%\n+ CRIT Rate+2.7%\nATK + 15",
      "artifact-set-effects": "A Day Carved From Rising Winds\n2-Piece Set: ATK +18%.",
      "artifact-footer": "WV Equipped: Citlali\naR 0",
    },
    expect: {
      slot: "Sands of Eon",
      level: 20,
      mainStat: "Elemental Mastery",
      setName: "A Day Carved From Rising Winds",
      equipped: "Citlali",
    },
    meta: { source: SOURCE },
  },
  {
    id: "moonlit-flower-hp",
    ocr: {
      "artifact-title": "Moonlit Offering's Opulent Dr\n| Flower of Life 2",
      "artifact-main-stat": "4,780\nAhhh",
      "artifact-substats": "+ Elemental Mastery+54\n+ CRIT Rate+7.4%\n+ ATK+4.7%",
      "artifact-set-effects": "Aubade of Morningstar and Moor\n2-Piece Set: Increases Elemental Mastery by 80.",
      "artifact-footer": "? Equipped: Ineffa\naR 0",
    },
    expect: {
      slot: "Flower of Life",
      mainStat: "HP",
      mainValue: "4,780",
      setName: "Aubade of Morningstar and Moon",
      equipped: "Ineffa",
    },
    meta: { source: SOURCE },
  },
  {
    id: "vv-determination-sands-er",
    ocr: {
      "artifact-title": "Viridescent Venerer's Determination\nSands of Eon Vi",
      "artifact-main-stat": "Energy Recharge\n51.8%",
      "artifact-substats": "+ ATK+5.8%\n+ Elemental Mastery+37\n+ HP+11.7%\n+ ATK+54",
      "artifact-set-effects": "Viridescent Venerer:\n2-Piece Set: Anemo DMG Bonus +15%",
      "artifact-footer": "Equipped: Sucrose",
    },
    expect: { slot: "Sands of Eon", mainStat: "Energy Recharge" },
    meta: { source: SOURCE },
  },
  {
    id: "pristine-plume-atk",
    ocr: {
      "artifact-title": "Pristine Plume of the Bles\n| Plume of Death",
      "artifact-main-stat": "31 !\npr",
      "artifact-substats": "+20\n+ CRIT DMG+7.0%\n+ DEF+30.6%\n+ Elemental Mastery+40\nATK +5.8%",
      "artifact-set-effects": "Silken Moon's Serenade:\n2-Piece Set: Energy Recharge +20%.",
      "artifact-footer": "Equipped: Aino\nBR",
    },
    expect: {
      slot: "Plume of Death",
      mainStat: "ATK",
      mainValue: "311",
      setName: "Silken Moon's Serenade",
      equipped: "Aino",
    },
    meta: { source: SOURCE },
  },
  {
    id: "deep-gallery-goblet-cryo",
    ocr: {
      "artifact-title": "Deep Gallery's Bestowed Banquet\nGoblet of Eonothem",
      "artifact-main-stat": "Cryo DMG Bonus\n46.6%",
      "artifact-substats": "+ CRIT Rate+6.6%\n+ CRIT DMG+12.4%\n+ HP+269\n+ ATK+16.3%",
      "artifact-set-effects": "Finale of the Deep Galleries:\n2-Piece Set: Cryo DMG Bonus +15%",
      "artifact-footer": "Equipped: Skirk",
    },
    expect: { slot: "Goblet of Eonothem", mainStat: "Cryo DMG Bonus", mainValue: "46.6%" },
    meta: { source: SOURCE },
  },
  {
    id: "holy-crown-circlet-crit",
    ocr: {
      "artifact-title": "Holy Crown of the Believer\nCirclet of Logos",
      "artifact-main-stat": "CRIT Rate\n31.1%",
      "artifact-substats": "+ ATK+4.7%\n+ Elemental Mastery+56\n+ DEF+37\n+ Energy Recharge+11.7%",
      "artifact-set-effects": "Silken Moon's Serenade:\n2-Piece Set: Energy Recharge +20%.",
      "artifact-footer": "Equipped: Chongyun",
    },
    expect: { slot: "Circlet of Logos", mainStat: "CRIT Rate", mainValue: "31.1%" },
    meta: { source: SOURCE },
  },
  {
    id: "beast-tamer-flower-set",
    ocr: {
      "artifact-title": "Beast Tamer's Talisman\nFlower of Life",
      "artifact-main-stat": "HP\n4,780",
      "artifact-substats": "+ HP+16.3%\n+ CRIT DMG+7.0%\n+ Energy Recharge+6.5%\n+ Elemental Mastery+68",
      "artifact-set-effects": "Scroll of the Hero of Cinder City:\n2-Piece Set: When a nearby party member triggers a Nightsoul Burst",
      "artifact-footer": "Equipped: Citlali",
    },
    expect: { setName: "Scroll of the Hero of Cinder City" },
    meta: { source: SOURCE },
  },
  {
    id: "piece-name-to-set-fallback",
    ocr: {
      "artifact-title": "Holy Crown of the Believer\nCirclet of Logos",
      "artifact-main-stat": "CRIT Rate\n31.1%",
      "artifact-substats": "+ ATK+4.7%\n+ Elemental Mastery+56\n+ DEF+37",
      "artifact-set-effects": "unreadable noisy set text",
      "artifact-footer": "Equipped: Chongyun",
    },
    expect: { setName: "Silken Moon's Serenade" },
    meta: { source: SOURCE, note: "set derived from piece name when set-effect OCR is noise" },
  },
  {
    id: "piece-name-to-slot-fallback",
    ocr: {
      "artifact-title": "Viridescent Venerer's Determination",
      "artifact-main-stat": "Energy Recharge\n51.8%",
      "artifact-substats": "+ ATK+5.8%\n+ Elemental Mastery+37\n+ HP+11.7%\n+ ATK+54",
      "artifact-set-effects": "Viridescent Venerer:\n2-Piece Set: Anemo DMG Bonus +15%",
      "artifact-footer": "Equipped: Sucrose",
    },
    expect: { slot: "Sands of Eon", setName: "Viridescent Venerer" },
    meta: { source: SOURCE },
  },
  {
    id: "hourglass-atk-percent",
    ocr: {
      "artifact-title": "Hourglass of Thunder\nSands of Eon",
      "artifact-main-stat": "ATK\n40.7%",
      "artifact-substats": "+17\n+ CRIT DMG+14.8%\n+ Elemental Mastery+21\n+ ATK+53\n+ DEF+19",
      "artifact-set-effects": "Thundering Fury:\n2-Piece Set: Electro DMG Bonus +15%",
      "artifact-footer": "Equipped: Fischl",
    },
    expect: { level: 17, slot: "Sands of Eon", mainStat: "ATK%", mainValue: "40.7%" },
    meta: { source: SOURCE },
  },
  {
    id: "night-realm-sands-ambiguous",
    ocr: {
      "artifact-title": "Myths of the Night Realm\nSands of Eon",
      "artifact-main-stat": "30.8%",
      "artifact-substats": "+12\n+ Elemental Mastery+16\n+ CRIT DMG+6.2%\n+ DEF+42\n+ HP+9.9%",
      "artifact-set-effects": "Obsidian Codex:\n2-Piece Set: While the equipping character is in Nightsoul's Blessing",
      "artifact-footer": "Equipped: Sandrone",
    },
    expect: { level: 12, mainValue: "30.8%" },
    meta: { source: SOURCE, note: "mainStat intentionally stays Unknown (ambiguous family)" },
  },
  {
    id: "footer-noise-equipped",
    ocr: {
      "artifact-title": "Gladiator's Nostalgia\nFlower of Life",
      "artifact-main-stat": "HP\n4,780",
      "artifact-substats": "+ Energy Recharge+11.0%\n+ ATK+9.9%\n+ HP+14.6%\n+ CRIT DMG+12.4%",
      "artifact-set-effects": "Gladiator's Finale:\n2-Piece Set: ATK +18%",
      "artifact-footer": "1 gv 0RY If tha anuninnina\nJl Equipped: Bennett\nCEE",
    },
    expect: { equipped: "Bennett" },
    meta: { source: SOURCE },
  },
  {
    id: "atk-percent-sands",
    ocr: {
      "artifact-title": "Myths of the Night Realm\nSands of Eon",
      "artifact-main-stat": "ATK\n30.8%",
      "artifact-substats": "+ Elemental Mastery+16\n+ CRIT DMG+6.2%\n+ DEF+42\n+ HP+9.9%",
      "artifact-set-effects": "Obsidian Codex:\n2-Piece Set: While the equipping character is in Nightsoul's Blessing",
      "artifact-footer": "Equipped: Sandrone",
    },
    expect: { mainStat: "ATK%", mainValue: "30.8%" },
    meta: { source: SOURCE },
  },
  {
    id: "atk-percent-circlet",
    ocr: {
      "artifact-title": "Maiden's Fading Beauty\nCirclet of Logos",
      "artifact-main-stat": "ATK\n46.6%",
      "artifact-substats": "+ ATK+29\n+ CRIT DMG+10.9%\n+ CRIT Rate+7.0%",
      "artifact-set-effects": "Maiden Beloved:\n2-Piece Set: Character Healing Effectiveness +15%",
      "artifact-footer": "Equipped: Qiqi",
    },
    expect: { mainStat: "ATK%", mainValue: "46.6%" },
    meta: { source: SOURCE },
  },
  {
    id: "atk-percent-goblet",
    ocr: {
      "artifact-title": "Viridescent Venerer's Vessel\nGoblet of Eonothem",
      "artifact-main-stat": "ATK\n46.6%",
      "artifact-substats": "+ HP+209\n+ CRIT DMG+25.6%\n+ Elemental Mastery+37",
      "artifact-set-effects": "Viridescent Venerer:\n2-Piece Set: Anemo DMG Bonus +15%",
      "artifact-footer": "Equipped: Ganyu",
    },
    expect: { mainStat: "ATK%", mainValue: "46.6%" },
    meta: { source: SOURCE },
  },
  {
    id: "garbled-percent-punctuation",
    ocr: {
      "artifact-title": "Pristine Circlet of the Bles\n| Circlet of Logos",
      "artifact-main-stat": "ATK\n46",
      "artifact-substats": `+ Elemental Mastery+20·5%\n+ CRIT DMG+6.3%\n+ ATK+19\n+ DEF+12`,
      "artifact-set-effects": "Gladiator's Finale:\n2-Piece Set: ATK +18%",
      "artifact-footer": "Equipped: Aino",
    },
    expect: { slot: "Circlet of Logos" },
    meta: { source: SOURCE },
  },
  {
    id: "garbled-quotes",
    ocr: {
      "artifact-title": "Aloy's “Gift”\n| Circlet of Logos",
      "artifact-main-stat": "Elemental Mastery\n46.6%",
      "artifact-substats": "+ ATK+4.7\n+ CRIT DMG+12.4%\n+ Energy Recharge+8.1%\n+ HP+11",
      "artifact-set-effects": "Maiden’s Beloved:\n2-Piece Set: Energy Recharge +16%",
      "artifact-footer": "Equipped: Shenhe",
    },
    expect: { slot: "Circlet of Logos", mainStat: "Elemental Mastery", setName: "Maiden Beloved" },
    meta: { source: SOURCE },
  },
  {
    id: "substats-overflow-into-set-crop",
    ocr: {
      "artifact-title": "Moonlit Offering's Opulent Dr\nFlower of Life",
      "artifact-main-stat": "HP\n4,780",
      "artifact-substats": "+ CRIT DMG+13.2%",
      "artifact-set-effects": "+ HP+15.7%\n+ DEF+12.4%\n+ Energy Recharge+5.2%\nAubade of Morningstar and Moon\n2-Piece Set: Increases Elemental Mastery by 80.",
      "artifact-footer": "Equipped: Venti",
    },
    expect: {
      substats: ["CRIT DMG+13.2%", "HP%+15.7%", "DEF%+12.4%", "Energy Recharge+5.2%"],
    },
    meta: { source: SOURCE },
  },
  {
    id: "percent-main-value-no-label",
    ocr: {
      "artifact-title": "Moonlit Offering's Final\nSands of Eon",
      "artifact-main-stat": "46.6%\n1S 2.5.8 J\nSe",
      "artifact-substats": "+ ATK+19\n+ Energy Recharge+6.5%\n+ CRIT DMG+18.7%",
      "artifact-set-effects": "Aubade of Morningstar and Moon\n2-Piece Set: Increases Elemental Mastery by 80.",
      "artifact-footer": "",
    },
    expect: { mainValue: "46.6%" },
    meta: { source: SOURCE, note: "mainStat stays Unknown; value must survive" },
  },
  {
    id: "derive-main-from-value-sands-def",
    ocr: {
      "artifact-title": "Revelation's Toll\nSands of Eon",
      "artifact-main-stat": "58.3%\n1S 2.5.8 J\nSe",
      "artifact-substats": "+ CRIT Rate+14.0%\n+ Elemental Mastery+33\n+ Energy Recharge+6.5%",
      "artifact-set-effects": "Night of the Sky's Unveiling:\n2-Piece Set: Increases Elemental Mastery by 80.",
      "artifact-footer": "Equipped: Zibai",
    },
    expect: { mainValue: "58.3%", mainStat: "DEF%" },
    meta: { source: SOURCE },
  },
  {
    id: "derive-main-from-value-circlet-critdmg",
    ocr: {
      "artifact-title": "Crown of the Saints\nCirclet of Logos",
      "artifact-main-stat": "62.2%",
      "artifact-substats": "+ ATK+18\n+ ATK+10.5%\n+ DEF+17.5%",
      "artifact-set-effects": "Obsidian Codex:\n2-Piece Set: While the equipping character is in Nightsoul's Blessing",
      "artifact-footer": "Equipped: Aino",
    },
    expect: { mainValue: "62.2%", mainStat: "CRIT DMG" },
    meta: { source: SOURCE },
  },
  {
    id: "noisy-fragment-circlet-critdmg",
    ocr: {
      "artifact-title": "Moonlit Offering's Silver Crown\nCirclet of Logos",
      "artifact-main-stat": "6\n2 D",
      "artifact-substats": "+ ATK+29\n+ ATK+5.8%\n+ Elemental Mastery+77\n- DEF+5.1%",
      "artifact-set-effects": "Aubade of Morningstar and Moon\n2-Piece Set: Increases Elemental Mastery by 80.",
      "artifact-footer": "",
    },
    expect: { mainValue: "62.2%", mainStat: "CRIT DMG" },
    meta: { source: SOURCE, note: "recovers unique max-value main from noisy digit fragment" },
  },
  {
    id: "noisy-fragment-sands-conservative",
    ocr: {
      "artifact-title": "Moonlit Offering's Final Hour\nSands of Eon",
      "artifact-main-stat": "46.6% |\nPEE",
      "artifact-substats": "+ ATK+19\n+ Energy Recharge+6.5%\n+ CRIT DMG+18.7%\n- DEF+53",
      "artifact-set-effects": "Aubade of Morningstar and Moon\n2-Piece Set: Increases Elemental Mastery by 80.",
      "artifact-footer": "",
    },
    expect: { mainValue: "46.6%" },
    meta: { source: SOURCE, note: "ambiguous 46.6 value stays conservative on mainStat" },
  },
];
