// Mock data for the Agentic Review Center prototype.
window.RC_DATA = {
  user: { name: "Jakee Demoo" },

  tabs: [
    { key: "contracts", label: "Contracts", icon: "Contact", count: 25 },
    { key: "payroll", label: "Payroll", icon: "Banknote", count: 75 },
    { key: "expenses", label: "Expenses", icon: "ReceiptText", count: 4 },
    { key: "timeoff", label: "Time Off", icon: "Plane", count: 4 },
    { key: "works", label: "Works", icon: "Briefcase", count: 7 },
    { key: "documents", label: "Documents", icon: "Paperclip", count: 7 },
    { key: "bills", label: "Bills", icon: "ScrollText", count: 2 },
    { key: "sessions", label: "Time sessions", icon: "Timer", count: 8 },
  ],

  // The pre-agent flat queue (a slice of the 75 payroll items)
  queue: [
    { id: "q1", name: "Sarah Maliki", ref: "BJC79CWJ", flag: "za", amount: "MAD 5,000.00", due: "01/06/2026" },
    { id: "q2", name: "Jakee Demoo", ref: "R9CQ93KJ", flag: "ae", amount: "AED 2,000.00", due: "08/06/2026" },
    { id: "q3", name: "Kamal KamalR", ref: "LAFN1O2T", flag: "sa", amount: "AED 1,749.00", due: "10/06/2026" },
    { id: "q4", name: "Lina Haddad", ref: "PQ5T22AB", flag: "ma", amount: "MAD 8,400.00", due: "10/06/2026" },
    { id: "q5", name: "Omar Said", ref: "TZ91KKLP", flag: "ae", amount: "AED 6,200.00", due: "10/06/2026" },
    { id: "q6", name: "Diego Ramirez", ref: "ARS44A2C", flag: "ar", amount: "ARS 480,000.00", due: "11/06/2026" },
    { id: "q7", name: "Priya Nair", ref: "IN77QZ1B", flag: "in", amount: "₹ 1,20,000.00", due: "11/06/2026" },
  ],

  // Issues the agent finds (18 total found; these are the surfaced ones)
  found: 18,

  // The 114 routine items the agent checked and cleared on its own — grouped so you can
  // inspect what it did (and undo). 69+22+7+7+5+2+2 = 114.
  routineGroups: [
    { label: "Unchanged salaries", category: "Payroll", count: 69, icon: "Banknote", note: "Same amount as the prior cycle" },
    { label: "No-change renewals", category: "Contracts", count: 22, icon: "Contact", note: "No term or rate change" },
    { label: "Within-scope milestones", category: "Works", count: 7, icon: "Briefcase", note: "Matches the agreed scope" },
    { label: "In-range time sessions", category: "Time sessions", count: 7, icon: "Timer", note: "Within contracted hours" },
    { label: "Verified document re-uploads", category: "Documents", count: 5, icon: "Paperclip", note: "Already-verified ID" },
    { label: "In-balance time off", category: "Time Off", count: 2, icon: "Plane", note: "Within accrued balance" },
    { label: "Bills matching their PO", category: "Bills", count: 2, icon: "ScrollText", note: "Amount matches the purchase order" },
  ],

  issues: [
    {
      id: "dup", bucket: "clarify", severity: "HIGH", risk: "AED 2,000", riskNum: 2000,
      category: "Expenses", title: "Possible duplicate submission",
      who: "Jakee Demoo", ref: "R9CQ93KJ", flag: "ae",
      summary: "“Jakee Demoo · AED 2,000” appears twice, dated 08/06 and 25/05. The amount, payee and memo match.",
      evidence: [
        { label: "Expense #EX-4471 · AED 2,000.00 · 08/06/2026 · “Client dinner”", flagged: true },
        { label: "Expense #EX-4198 · AED 2,000.00 · 25/05/2026 · “Client dinner”", flagged: true },
        { label: "Same payee, same amount, same memo, 14 days apart", flagged: false },
      ],
      action: "Ask the contractor to confirm",
      draft: "Hi Jakee, we noticed two AED 2,000 submissions dated 08/06 and 25/05. Is one a duplicate? Thanks!",
      kind: "ask",
    },
    {
      id: "missing", bucket: "clarify", severity: "HIGH", risk: "AED 30,000", riskNum: 30000,
      category: "Payroll", title: "Missing previous-month payment",
      who: "Kamal KamalR", ref: "LAFN1O2T", flag: "sa",
      summary: "No payment was found for Kamal for May 2026, but a contract was active. This month’s run may be understated.",
      evidence: [
        { label: "Active contract LAFN1O2T · AED 30,000 / mo", flagged: false },
        { label: "Payments: Apr 2026 ✓ · May 2026 ✗ · Jun 2026 (this run)", flagged: true },
      ],
      action: "Ask the contractor to confirm",
      draft: "Hi Kamal, we couldn’t find your May 2026 payment on file. Did you receive it? We want to make sure nothing was missed.",
      kind: "ask",
    },
    {
      id: "meals", bucket: "decide", severity: "MED", risk: "A$500", riskNum: 335,
      category: "Expenses", title: "Meals expense above policy",
      who: "Jakee Demoo", ref: "D20ON6YE", flag: "ae",
      summary: "A “Meals” expense of A$500.00 is 3.3× the team’s A$150 per-meal policy.",
      evidence: [
        { label: "Expense #EX-4502 · A$500.00 · category “Meals”", flagged: true },
        { label: "Team policy: A$150 / meal", flagged: false },
      ],
      action: "Decline with reason",
      kind: "decline",
    },
    {
      id: "fx", bucket: "decide", severity: "MED", risk: "ARS 480,000", riskNum: 520,
      category: "Payroll", title: "Currency mismatch on payout",
      who: "Diego Ramirez", ref: "ARS44A2C", flag: "ar",
      summary: "Contract is set in USD but this payout is requested in ARS at a rate 6% off today’s reference.",
      evidence: [
        { label: "Contract currency: USD · Payout currency: ARS", flagged: true },
        { label: "Applied rate 6% above reference (Open Exchange)", flagged: true },
      ],
      action: "Correct the value",
      kind: "correct",
    },
    {
      id: "round1", bucket: "decide", severity: "LOW", risk: "$0.21", riskNum: 0.21, lowExpense: true,
      category: "Expenses", title: "Sub-$5 currency-rounding difference",
      who: "Jakee Demoo", ref: "D20ON6YE", flag: "ae",
      summary: "Converted total differs from the receipt by $0.21 due to FX rounding.",
      evidence: [{ label: "Receipt ARS 300.00 → $0.21 vs computed $0.00", flagged: true }],
      action: "Approve", kind: "approve",
    },
    {
      id: "round2", bucket: "decide", severity: "LOW", risk: "$0.77", riskNum: 0.77, lowExpense: true,
      category: "Expenses", title: "Sub-$5 currency-rounding difference",
      who: "Jakee Demoo", ref: "D20ON6YE", flag: "ae",
      summary: "Converted total differs from the receipt by $0.77 due to FX rounding.",
      evidence: [{ label: "Receipt DZD 100.00 → $0.77 vs computed $0.00", flagged: true }],
      action: "Approve", kind: "approve",
    },
    {
      id: "round3", bucket: "decide", severity: "LOW", risk: "$4.58", riskNum: 4.58, lowExpense: true,
      category: "Expenses", title: "Sub-$5 currency-rounding difference",
      who: "Jakee Demoo", ref: "D20ON6YE", flag: "ae",
      summary: "Converted total differs from the receipt by $4.58 due to FX rounding.",
      evidence: [{ label: "Receipt AFN 300.00 → $4.58 vs computed $0.00", flagged: true }],
      action: "Approve", kind: "approve",
    },
  ],

  // Items the agent can auto-handle once Trust Levels permit (low-risk only)
  trustCategories: [
    { category: "Payroll", icon: "Banknote", value: "suggest", lowRisk: "Salary unchanged vs the prior cycle", autoEligible: 41, gated: "Amount changes, new payees, missing payments" },
    { category: "Expenses", icon: "ReceiptText", value: "suggest", lowRisk: "Sub-$5 currency-rounding differences", autoEligible: 3, gated: "Duplicates, over-policy amounts, missing receipts" },
    { category: "Contracts", icon: "Contact", value: "ask", lowRisk: "Renewals with no term or rate change", autoEligible: 6, gated: "New terms, rate changes, new jurisdictions" },
    { category: "Time off", icon: "Plane", value: "suggest", lowRisk: "Requests within accrued balance & policy", autoEligible: 4, gated: "Negative balance, overlapping cover, unpaid leave" },
    { category: "Documents", icon: "Paperclip", value: "ask", lowRisk: "Re-upload of an already-verified document", autoEligible: 2, gated: "First-time IDs, compliance docs, expiring permits" },
  ],

  // Plain-language definitions for the Trust Levels dial
  trustLevels: [
    { key: "ask", label: "Ask", icon: "Hand", desc: "The agent does nothing until you ask. It still surfaces issues, but never acts." },
    { key: "suggest", label: "Suggest", icon: "Lightbulb", desc: "The agent recommends an action and shows its evidence. You approve every change." },
    { key: "auto", label: "Auto", icon: "WandSparkles", desc: "The agent handles items by itself, but only ones we classify as low-risk, and every action is reversible with one click." },
  ],

  // What "low-risk" means, and what can never auto (today)
  riskBands: {
    low: { label: "Low risk", note: "Routine, deterministic, small $-at-risk. Eligible for Auto.", examples: ["Sub-$5 currency-rounding", "Salary unchanged vs last cycle", "Within-policy amounts", "Re-upload of a verified doc"] },
    med: { label: "Medium risk", note: "Always comes to you. Never auto, even on Auto.", examples: ["Over-policy expense", "Currency mismatch", "Rate change on renewal"] },
    high: { label: "High risk", note: "Always comes to you. Never auto, even on Auto.", examples: ["Possible duplicate", "Missing previous payment", "First-time compliance doc"] },
  },

  // Per-category review queues so the tabs are clickable (pre-agent, manual review).
  // patternKey groups similar decisions so the agent can transparently offer to learn a rule.
  reviewQueues: {
    contracts: [
      { id: "c1", who: "Lina Haddad", flag: "ma", ref: "PQ5T22AB", line: "Renewal · no term change", amount: "MAD 8,400 / mo", band: "low", patternKey: "contract-renewal", pattern: "renewals with no term change" },
      { id: "c2", who: "Omar Said", flag: "ae", ref: "TZ91KKLP", line: "Renewal · no term change", amount: "AED 6,200 / mo", band: "low", patternKey: "contract-renewal", pattern: "renewals with no term change" },
      { id: "c3", who: "Diego Ramirez", flag: "ar", ref: "ARS44A2C", line: "New rate · +18% vs prior", amount: "USD 3,500 / mo", band: "med", patternKey: null },
      { id: "c4", who: "Aïcha Benali", flag: "ma", ref: "MA22LKP9", line: "Renewal · no term change", amount: "MAD 12,000 / mo", band: "low", patternKey: "contract-renewal", pattern: "renewals with no term change" },
    ],
    payroll: [
      { id: "p1", who: "Sarah Maliki", flag: "za", ref: "BJC79CWJ", line: "Salary unchanged vs May", amount: "MAD 5,000.00", band: "low", patternKey: "salary-unchanged", pattern: "salaries unchanged vs the prior cycle" },
      { id: "p2", who: "Jakee Demoo", flag: "ae", ref: "R9CQ93KJ", line: "Salary unchanged vs May", amount: "AED 2,000.00", band: "low", patternKey: "salary-unchanged", pattern: "salaries unchanged vs the prior cycle" },
      { id: "p3", who: "Kamal KamalR", flag: "sa", ref: "LAFN1O2T", line: "No May payment on file", amount: "AED 1,749.00", band: "high", patternKey: null },
      { id: "p4", who: "Priya Nair", flag: "in", ref: "IN77QZ1B", line: "Salary unchanged vs May", amount: "₹ 1,20,000.00", band: "low", patternKey: "salary-unchanged", pattern: "salaries unchanged vs the prior cycle" },
    ],
    expenses: [
      { id: "e1", who: "Jakee Demoo", flag: "ae", ref: "EX-4471", line: "Possible duplicate · AED 2,000", amount: "AED 2,000.00", band: "high", patternKey: null },
      { id: "e2", who: "Jakee Demoo", flag: "ae", ref: "EX-4502", line: "Meals · 3.3× policy", amount: "A$500.00", band: "med", patternKey: null },
      { id: "e3", who: "Jakee Demoo", flag: "ae", ref: "EX-4198", line: "Currency-rounding · $0.21", amount: "$0.21", band: "low", patternKey: "rounding", pattern: "sub-$5 currency-rounding differences" },
      { id: "e4", who: "Omar Said", flag: "ae", ref: "EX-4533", line: "Currency-rounding · $0.77", amount: "$0.77", band: "low", patternKey: "rounding", pattern: "sub-$5 currency-rounding differences" },
    ],
    timeoff: [
      { id: "t1", who: "Priya Nair", flag: "in", ref: "TO-2291", line: "3 days · within balance", amount: "12 days left", band: "low", patternKey: "timeoff-inbalance", pattern: "time off within accrued balance" },
      { id: "t2", who: "Sarah Maliki", flag: "za", ref: "TO-2294", line: "2 days · within balance", amount: "8 days left", band: "low", patternKey: "timeoff-inbalance", pattern: "time off within accrued balance" },
      { id: "t3", who: "Diego Ramirez", flag: "ar", ref: "TO-2301", line: "10 days · negative balance", amount: "−2 days", band: "med", patternKey: null },
    ],
    works: [
      { id: "w1", who: "Omar Said", flag: "ae", ref: "WK-771", line: "Milestone · within scope", amount: "AED 4,000", band: "low", patternKey: null },
      { id: "w2", who: "Lina Haddad", flag: "ma", ref: "WK-780", line: "Milestone · within scope", amount: "MAD 6,000", band: "low", patternKey: null },
    ],
    documents: [
      { id: "d1", who: "Sarah Maliki", flag: "za", ref: "DOC-5521", line: "Re-upload of verified ID", amount: "Passport", band: "low", patternKey: "doc-reupload", pattern: "re-uploads of an already-verified document" },
      { id: "d2", who: "Aïcha Benali", flag: "ma", ref: "DOC-5530", line: "First-time tax ID", amount: "Tax ID", band: "high", patternKey: null },
      { id: "d3", who: "Priya Nair", flag: "in", ref: "DOC-5533", line: "Re-upload of verified ID", amount: "Address proof", band: "low", patternKey: "doc-reupload", pattern: "re-uploads of an already-verified document" },
    ],
    bills: [
      { id: "b1", who: "AWS EMEA", flag: "lu", ref: "BILL-9001", line: "Recurring · matches PO", amount: "USD 1,240.00", band: "low", patternKey: null },
      { id: "b2", who: "Notion Labs", flag: "us", ref: "BILL-9007", line: "Recurring · matches PO", amount: "USD 320.00", band: "low", patternKey: null },
    ],
    sessions: [
      { id: "s1", who: "Diego Ramirez", flag: "ar", ref: "TS-3310", line: "38h · within contract", amount: "38h", band: "low", patternKey: "session-inrange", pattern: "time sessions within the contracted hours" },
      { id: "s2", who: "Priya Nair", flag: "in", ref: "TS-3318", line: "41h · within contract", amount: "41h", band: "low", patternKey: "session-inrange", pattern: "time sessions within the contracted hours" },
      { id: "s3", who: "Omar Said", flag: "ae", ref: "TS-3325", line: "62h · over contract +18h", amount: "62h", band: "med", patternKey: null },
    ],
  },

  playbooks: [
    { name: "Flag duplicate submissions", scope: "Expenses · same payee/amount ≤ 30 days", auto: "compliance policy", on: true, system: true, confidence: "High" },
    { name: "Auto-approve unchanged salaries", scope: "Payroll · amount unchanged vs prior cycle", auto: "9 cycles of your approvals", on: true, system: false, confidence: "High" },
    { name: "Auto-approve sub-$5 FX rounding", scope: "Expenses · |diff| < $5", auto: "your last 6 approvals", on: false, system: false, confidence: "High", suggested: true },
    { name: "Auto-approve no-change renewals", scope: "Contracts · no term or rate change", auto: "your last 4 approvals", on: false, system: false, confidence: "Medium", suggested: true },
    { name: "Auto-approve re-uploaded verified docs", scope: "Documents · already-verified ID re-upload", auto: "your last 3 approvals", on: false, system: false, confidence: "Medium", suggested: true },
    { name: "Auto-approve in-balance time off", scope: "Time off · within accrued balance & policy", auto: "your last 5 approvals", on: false, system: false, confidence: "Medium", suggested: true },
  ],

  // Reviewer Profile — a human-readable, evolving memory of how this approver works.
  reviewerProfile: [
    { text: "You verify with the contractor before declining a possible duplicate.", source: "8 of your decisions" },
    { text: "You personally review every payroll item above AED 25,000.", source: "12 of your decisions" },
    { text: "You auto-accept sub-$5 FX-rounding differences.", source: "your last 6 approvals" },
  ],

  askAiSuggestions: [
    { icon: "TriangleAlert", text: "Any issues in this payroll run?" },
    { icon: "Plane", text: "Who has not taken time off in the past 6 months?" },
    { icon: "TrendingUp", text: "What is our turnover rate over the past 12 months?" },
  ],
  // Scripted Ask AI answer for the demo (reactive / pull state)
  askAiAnswer: "I found 3 things worth a look in this payroll run:\n• A possible duplicate: Jakee Demoo · AED 2,000 appears on 08/06 and 25/05.\n• A missing May 2026 payment for Kamal KamalR (AED 30,000).\n• A meals expense of A$500, above the A$150 policy.\n\nWant me to open any of these? (I can only point them out here. Running the Review Agent can triage and act on them.)",
};
