// adminData.jsx — initial mock data for the Ascend Admin prototype.
// The App lifts these into React state so admin actions (pause / freeze /
// approve / reject / revoke / clawback) mutate them live, fire a toast, and
// append to the audit log.
//
// Renée notes applied in the *naming*:
//   · C-2: pool rows carry a distinguishing pair (settlement token + linked CF)
//     instead of eight identical "USDC Lending Pool" labels.
//   · C-5: facility/module names are neutral institutional language.
//   · A-1: all timestamps are ISO strings, rendered through fmtDateTime.

// ── Credit facilities ───────────────────────────────────────────────────
const ADMIN_FACILITIES = [
  { id: "cf-usdc-core",   name: "USDC core facility",        token: "USDC", status: "active",   tvl: 12400000, utilization: 60.0, accounts: 6, rate: 5.5, warn: 1, default: 1, tranche: "Senior tranche",               lastActor: "ops@ascend.io",   lastAction: "RATE_UPDATE", lastAt: "2026-05-14T09:15:00Z" },
  { id: "cf-horizon",     name: "Horizon yield facility",    token: "USDT", status: "paused",   tvl: 2400000,  utilization: 50.0, accounts: 3, rate: 7.8, warn: 1, default: 0, tranche: "Mezzanine",                       lastActor: "ops@ascend.io",   lastAction: "PAUSE",       lastAt: "2026-05-29T14:30:00Z" },
  { id: "cf-prime-inst",  name: "Prime institutional facility", token: "USDC", status: "active", tvl: 1900000, utilization: 72.0, accounts: 3, rate: 4.0, warn: 1, default: 1, tranche: "Senior · institutional",         lastActor: "admin@ascend.io", lastAction: "DEPLOY",      lastAt: "2025-06-01T09:00:00Z" },
  { id: "cf-zenith",      name: "Zenith multi facility",     token: "USDC", status: "shutdown", tvl: 0,        utilization: 0.0,  accounts: 0, rate: 5.8, warn: 0, default: 0, tranche: "Balanced",                        lastActor: "admin@ascend.io", lastAction: "SHUTDOWN",    lastAt: "2026-01-10T16:00:00Z" },
  { id: "cf-abn-yield",   name: "ABN yield facility",        token: "USDC", status: "active",   tvl: 8600000,  utilization: 40.0, accounts: 3, rate: 4.2, warn: 2, default: 0, tranche: "Senior tranche",               lastActor: "ops@ascend.io",   lastAction: "DEPLOY",      lastAt: "2025-07-22T11:00:00Z" },
  { id: "cf-sng-stable",  name: "SNG stable facility",       token: "USDC", status: "active",   tvl: 22100000, utilization: 87.5, accounts: 4, rate: 3.8, warn: 0, default: 1, tranche: "Stable income",                  lastActor: "ops@ascend.io",   lastAction: "RATE_UPDATE", lastAt: "2026-04-18T09:15:00Z" },
  { id: "cf-inst-abn",    name: "Institutional ABN prime",   token: "USD1", status: "active",   tvl: 1200000,  utilization: 16.6, accounts: 3, rate: 12.5, warn: 0, default: 1, tranche: "Premium",                       lastActor: "admin@ascend.io", lastAction: "DEPLOY",      lastAt: "2026-02-03T14:30:00Z" },
  { id: "cf-fmm",         name: "FMM reserve facility",      token: "USDC", status: "active",   tvl: 900000,   utilization: 58.0, accounts: 3, rate: 5.0, warn: 1, default: 1, tranche: "Reserve",                        lastActor: "admin@ascend.io", lastAction: "UNPAUSE",     lastAt: "2026-05-22T08:30:00Z" },
  { id: "cf-msm",         name: "MSM income facility",       token: "USDT", status: "active",   tvl: 1100000,  utilization: 42.0, accounts: 2, rate: 6.5, warn: 1, default: 0, tranche: "Income",                         lastActor: "ops@ascend.io",   lastAction: "DEPLOY",      lastAt: "2025-11-14T10:00:00Z" },
  { id: "cf-meridian",    name: "Meridian credit facility",  token: "USDC", status: "active",   tvl: 5000000,  utilization: 67.1, accounts: 6, rate: 6.2, warn: 2, default: 0, tranche: "Balanced",                        lastActor: "ops@ascend.io",   lastAction: "UNPAUSE",     lastAt: "2026-05-20T16:00:00Z" },
  { id: "cf-sbc",         name: "SBC capital facility",      token: "USD1", status: "active",   tvl: 489000,   utilization: 86.3, accounts: 6, rate: 8.3, warn: 0, default: 0, tranche: "Capital",                        lastActor: "admin@ascend.io", lastAction: "DEPLOY",      lastAt: "2026-03-07T11:00:00Z" },
  { id: "cf-apx",         name: "APX opportunity facility",  token: "USDC", status: "active",   tvl: 291000,   utilization: 78.8, accounts: 5, rate: 9.7, warn: 0, default: 0, tranche: "Growth",                         lastActor: "ops@ascend.io",   lastAction: "DEPLOY",      lastAt: "2026-04-02T13:30:00Z" },
];

// ── Margin accounts (representative slice of 33) ─────────────────────────
const ADMIN_ACCOUNTS = [
  { id: "ma-1015", wallet: "0x5321a4f7c2bd9013f8a92e1c43d8c0e5912aea39", facility: "USDC core facility",      collateral: 734249, collToken: "1,200 ABN",  borrowed: 553596, available: 0,      hf: 0.00, status: "frozen",    adminLastActor: "admin@ascend.io", adminLastAction: "FREEZE",    adminLastAt: "2026-05-27T11:45:00Z" },
  { id: "ma-1018", wallet: "0x9e4ab5f7c2bd9013f8a92e1c43d8c0e5912ac3d6", facility: "USDC core facility",      collateral: 862843, collToken: "4,200 SNG",  borrowed: 636397, available: 0,      hf: 0.00, status: "paused",    adminLastActor: "admin@ascend.io", adminLastAction: "PAUSE",     adminLastAt: "2026-05-30T09:15:00Z" },
  { id: "ma-1035", wallet: "0xfc13f5f7c2bd9013f8a92e1c43d8c0e5912aea5a", facility: "SNG stable facility",     collateral: 475467, collToken: "5,000 SNG",  borrowed: 152222, available: 0,      hf: 0.00, status: "frozen",    adminLastActor: "admin@ascend.io", adminLastAction: "FREEZE",    adminLastAt: "2026-05-28T14:00:00Z" },
  { id: "ma-1038", wallet: "0x23acf7f7c2bd9013f8a92e1c43d8c0e5912ab673", facility: "SNG stable facility",     collateral: 495459, collToken: "7,000 MSM",  borrowed: 0,      available: 0,      hf: 0.00, status: "paused",    adminLastActor: "ops@ascend.io",   adminLastAction: "PAUSE",     adminLastAt: "2026-05-25T10:30:00Z" },
  { id: "ma-1100", wallet: "0x71c1a3f7c2bd9013f8a92e1c43d8c0e5912a3cd1", facility: "Institutional ABN prime", collateral: 88000,  collToken: "4.1 APX",    borrowed: 0,      available: 0,      hf: 0.00, status: "liquidated", adminLastActor: "admin@ascend.io", adminLastAction: "LIQUIDATION", adminLastAt: "2026-05-20T09:00:00Z" },
  { id: "ma-1040", wallet: "0x63db0df7c2bd9013f8a92e1c43d8c0e5912a7a6d", facility: "SNG stable facility",     collateral: 840194, collToken: "8,200 MSM",  borrowed: 798185, available: 0,      hf: 0.51, status: "default",   adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-1020", wallet: "0xbc6e51f7c2bd9013f8a92e1c43d8c0e5912a0857", facility: "USDC core facility",      collateral: 681758, collToken: "3,100 FMM",  borrowed: 647670, available: 0,      hf: 0.85, status: "default",   adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-2103", wallet: "0xaaa0f1f7c2bd9013f8a92e1c43d8c0e5912a9031", facility: "FMM reserve facility",    collateral: 512300, collToken: "12,000 FMM", borrowed: 478400, available: 0,      hf: 0.94, status: "default",   adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-1160", wallet: "0xae32f1f7c2bd9013f8a92e1c43d8c0e5912a94ab", facility: "Institutional ABN prime", collateral: 121000, collToken: "6.9 SBC",    borrowed: 103000, available: 0,      hf: 0.95, status: "default",   adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-2114", wallet: "0xbbb0f2f7c2bd9013f8a92e1c43d8c0e5912a1190", facility: "FMM reserve facility",    collateral: 230450, collToken: "1.8 ABN",    borrowed: 194200, available: 14260, hf: 1.08, status: "warn",      adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-9002", wallet: "0x9002f1f7c2bd9013f8a92e1c43d8c0e5912a0002", facility: "Meridian credit facility", collateral: 950000, collToken: "9,500 SNG", borrowed: 820000, available: 22000, hf: 1.08, status: "warn",      adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-3302", wallet: "0xccc0f3f7c2bd9013f8a92e1c43d8c0e5912a22a1", facility: "MSM income facility",     collateral: 120055, collToken: "1,200 MSM",  borrowed: 98021,  available: 6800,  hf: 1.17, status: "warn",      adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-1005", wallet: "0x1005f1f7c2bd9013f8a92e1c43d8c0e5912a1005", facility: "USDC core facility",      collateral: 412200, collToken: "2,400 ABN",  borrowed: 190540, available: 85420, hf: 2.18, status: "active",    adminLastActor: null, adminLastAction: null, adminLastAt: null },
  { id: "ma-1078", wallet: "0x1078f1f7c2bd9013f8a92e1c43d8c0e5912a1078", facility: "ABN yield facility",      collateral: 104500, collToken: "900 ABN",    borrowed: 22000,  available: 58365, hf: 3.42, status: "active",    adminLastActor: null, adminLastAction: null, adminLastAt: null },
];

// Totals for the global slice (the 33-account population the slice represents).
const ADMIN_ACCOUNT_TOTALS = { total: 33, collateral: 19600000, borrowed: 12100000, avgHF: 1.33, warn: 8, frozen: 2, default: 4, paused: 4, liquidated: 1, active: 14 };

// ── Stablecoin pools (C-2: distinct labels) ──────────────────────────────
const ADMIN_POOLS = [
  { id: "pool-sng",      token: "USDC", facility: "SNG stable facility",       tvl: 15400000, utilization: 68.2, apy: 8.3, lenders: 3, status: "normal" },
  { id: "pool-abn",      token: "USDC", facility: "ABN yield facility",        tvl: 5800000,  utilization: 77.2, apy: 9.0, lenders: 5, status: "normal" },
  { id: "pool-usdc-core", token: "USDC", facility: "USDC core facility",       tvl: 3900000,  utilization: 53.9, apy: 4.7, lenders: 4, status: "normal" },
  { id: "pool-meridian", token: "USDC", facility: "Meridian credit facility",  tvl: 3300000,  utilization: 67.1, apy: 6.2, lenders: 6, status: "normal" },
  { id: "pool-prime",    token: "USDC", facility: "Prime institutional facility", tvl: 971000, utilization: 57.0, apy: 3.9, lenders: 3, status: "normal" },
  { id: "pool-msm",      token: "USDT", facility: "MSM income facility",       tvl: 711000,   utilization: 77.2, apy: 6.8, lenders: 3, status: "normal" },
  { id: "pool-inst-abn", token: "USD1", facility: "Institutional ABN prime",   tvl: 546000,   utilization: 70.3, apy: 7.8, lenders: 3, status: "normal" },
  { id: "pool-sbc",      token: "USD1", facility: "SBC capital facility",      tvl: 489000,   utilization: 86.3, apy: 8.7, lenders: 6, status: "high" },
  { id: "pool-fmm",      token: "USDC", facility: "FMM reserve facility",      tvl: 373000,   utilization: 74.9, apy: 6.2, lenders: 3, status: "normal" },
  { id: "pool-apx",      token: "USDC", facility: "APX opportunity facility",  tvl: 291000,   utilization: 78.8, apy: 3.6, lenders: 5, status: "normal" },
];

// ── Liquidation monitor (read-only) ──────────────────────────────────────
const ADMIN_LIQUIDATIONS = [
  { id: "ma-1040", facility: "SNG stable facility",  wallet: "0x63db0d…7a6d", collateral: 840194, debt: 798185, hf: 0.51, resolution: "ddf-eligible", timeInDefault: "17h", severity: "critical" },
  { id: "ma-1020", facility: "USDC core facility",   wallet: "0xbc6e51…0857", collateral: 681758, debt: 647670, hf: 0.85, resolution: "ddf-eligible", timeInDefault: "1h",  severity: "critical" },
  { id: "ma-2103", facility: "FMM reserve facility", wallet: "0xaaa0f1…9031", collateral: 512300, debt: 478400, hf: 0.94, resolution: "ddf-auction",  timeInDefault: "53m", severity: "high" },
  { id: "ma-2114", facility: "FMM reserve facility", wallet: "0xbbb0f2…1190", collateral: 230450, debt: 194200, hf: 1.08, resolution: "ddf-eligible", timeInDefault: "11m", severity: "high" },
  { id: "ma-3302", facility: "MSM income facility",  wallet: "0xccc0f3…22a1", collateral: 120055, debt: 98021,  hf: 1.17, resolution: "monitoring",  timeInDefault: "4m",  severity: "medium" },
  { id: "ma-3322", facility: "MSM income facility",  wallet: "0xddd0f4…ab31", collateral: 99500,  debt: 76000,  hf: 1.31, resolution: "monitoring",  timeInDefault: "2m",  severity: "medium" },
];

// ── Claims (global queue) ────────────────────────────────────────────────
const ADMIN_CLAIMS = [
  { caseId: "ocr-008", type: "Qualified premium", facility: "Prime institutional facility", investor: "Vista Capital",    email: "compliance@vistacapital.com", onchainId: "0xb234…5678", wallet: "0x6666…5555", jurisdiction: "UK", provider: "Ascend", status: "under-review", submitted: "2026-05-30T14:10:00Z" },
  { caseId: "rev-005", type: "KYC",               facility: "ABN yield facility",          investor: "Aline North",      email: "aline@north.io",            onchainId: "0x1111…0000", wallet: "0x9c2d…77b8", jurisdiction: "CH", provider: "Onfido", status: "under-review", submitted: "2026-05-30T09:30:00Z" },
  { caseId: "ocr-001", type: "Partner membership", facility: "USDC core facility",         investor: "Default Searcher", email: "searcher@ascend.dev",       onchainId: "0x1234…5678", wallet: "0x1b75…f94e", jurisdiction: "US", provider: "Ascend", status: "approved",     submitted: "2026-05-29T16:00:00Z" },
  { caseId: "rev-002", type: "KYC",               facility: "USDC core facility",          investor: "Sarah Connor",     email: "s.connor@skynet.com",       onchainId: "—",          wallet: "0x3a2b…9a0b", jurisdiction: "US", provider: "Sumsub", status: "under-review", submitted: "2026-05-29T11:20:00Z" },
  { caseId: "ocr-002", type: "Qualified premium", facility: "ABN yield facility",          investor: "North Harbor LLC", email: "ops@northharbor.com",       onchainId: "0x7234…5678", wallet: "0x2222…1111", jurisdiction: "US", provider: "Ascend", status: "approved",     submitted: "2026-05-28T13:45:00Z" },
  { caseId: "rev-001", type: "KYC",               facility: "USDC core facility",          investor: "Bob Smith",        email: "bob.smith@email.com",       onchainId: "—",          wallet: "0x90F8…c9C1", jurisdiction: "US", provider: "Onfido", status: "rejected",     submitted: "2026-05-28T08:05:00Z" },
  { caseId: "rev-010", type: "KYC",               facility: "USDC core facility",          investor: "Vista Capital",    email: "compliance@vistacapital.com", onchainId: "0xb234…5678", wallet: "0x6666…5555", jurisdiction: "UK", provider: "Onfido", status: "under-review", submitted: "2026-05-27T17:30:00Z" },
  { caseId: "ocr-003", type: "Corporate email",   facility: "SNG stable facility",         investor: "MegaCorp Inc",     email: "legal@megacorp.com",        onchainId: "0x5234…5678", wallet: "0x1234…5678", jurisdiction: "US", provider: "Ascend", status: "approved",     submitted: "2026-05-27T10:00:00Z" },
  { caseId: "rev-003", type: "KYC",               facility: "USDC core facility",          investor: "MegaCorp Inc",     email: "legal@megacorp.com",        onchainId: "0x5234…5678", wallet: "0x1234…5678", jurisdiction: "US", provider: "Onfido", status: "under-review", submitted: "2026-05-26T15:15:00Z" },
  { caseId: "rev-004", type: "Accredited investor", facility: "Prime institutional facility", investor: "Helix Partners", email: "kyc@helix.fund",          onchainId: "0x8234…5678", wallet: "0x7777…2222", jurisdiction: "SG", provider: "Sumsub", status: "under-review", submitted: "2026-05-26T09:40:00Z" },
  { caseId: "rev-006", type: "KYC",               facility: "MSM income facility",         investor: "Crest Advisors",   email: "ops@crest.co",              onchainId: "0x4234…5678", wallet: "0x8888…3333", jurisdiction: "DE", provider: "Onfido", status: "rejected",     submitted: "2026-05-25T12:00:00Z" },
  { caseId: "ocr-004", type: "Qualified premium", facility: "SBC capital facility",        investor: "Lumen Capital",    email: "compliance@lumen.io",       onchainId: "0x2234…5678", wallet: "0x9999…4444", jurisdiction: "US", provider: "Ascend", status: "under-review", submitted: "2026-05-25T08:30:00Z" },
  { caseId: "rev-007", type: "KYC",               facility: "ABN yield facility",          investor: "Sable Group",      email: "kyc@sable.co",              onchainId: "0x3334…5678", wallet: "0xaaaa…5555", jurisdiction: "FR", provider: "Sumsub", status: "approved",     submitted: "2026-05-24T14:20:00Z" },
  { caseId: "rev-008", type: "KYC",               facility: "USDC core facility",          investor: "Orion Trading",    email: "compliance@orion.tr",       onchainId: "0x5554…5678", wallet: "0xbbbb…6666", jurisdiction: "US", provider: "Onfido", status: "under-review", submitted: "2026-05-24T10:10:00Z" },
  { caseId: "rev-009", type: "Accredited investor", facility: "Meridian credit facility",  investor: "Pinnacle LP",      email: "ops@pinnacle.fund",         onchainId: "0x6664…5678", wallet: "0xcccc…7777", jurisdiction: "US", provider: "Sumsub", status: "rejected",     submitted: "2026-05-23T16:45:00Z" },
  { caseId: "rev-011", type: "KYC",               facility: "FMM reserve facility",        investor: "Atlas Reserve",    email: "kyc@atlas.re",              onchainId: "0x7774…5678", wallet: "0xdddd…8888", jurisdiction: "US", provider: "Onfido", status: "under-review", submitted: "2026-05-23T09:00:00Z" },
  { caseId: "ocr-005", type: "Corporate email",   facility: "Institutional ABN prime",     investor: "Verda Holdings",   email: "legal@verda.co",            onchainId: "0x8884…5678", wallet: "0xeeee…9999", jurisdiction: "US", provider: "Ascend", status: "rejected",     submitted: "2026-05-22T13:30:00Z" },
  { caseId: "rev-012", type: "KYC",               facility: "APX opportunity facility",    investor: "Quanta Fund",      email: "kyc@quanta.fund",           onchainId: "0x9994…5678", wallet: "0xffff…0000", jurisdiction: "SG", provider: "Sumsub", status: "under-review", submitted: "2026-05-22T08:15:00Z" },
];

// ── Audit log (compliance actions) ───────────────────────────────────────
const ADMIN_AUDIT = [
  { id: "au-1", action: "FREEZE",  status: "pending",  target: "user-2",    description: "KYC recertification required",                   ts: "2026-05-31T11:45:00Z", actor: "admin@ascend.io" },
  { id: "au-2", action: "FREEZE",  status: "executed", target: "user-4",    description: "Suspicious transaction pattern flagged by AML bot", ts: "2026-05-30T09:15:00Z", actor: "admin@ascend.io" },
  { id: "au-3", action: "PAUSE",   status: "executed", target: "cf-meridian", description: "High volatility in underlying asset (UNI) detected", ts: "2026-05-29T14:30:00Z", actor: "ops@ascend.io" },
  { id: "au-4", action: "UNPAUSE", status: "executed", target: "cf-horizon", description: "Maintenance window completed",                  ts: "2026-05-27T16:00:00Z", actor: "ops@ascend.io" },
  { id: "au-5", action: "PAUSE",   status: "reverted", target: "cf-fmm",     description: "Emergency circuit breaker test",                 ts: "2026-05-22T08:00:00Z", actor: "admin@ascend.io" },
];

Object.assign(window, {
  ADMIN_FACILITIES, ADMIN_ACCOUNTS, ADMIN_ACCOUNT_TOTALS, ADMIN_POOLS,
  ADMIN_LIQUIDATIONS, ADMIN_CLAIMS, ADMIN_AUDIT,
});
