// CRUCIBLE — Seed data, externalized from CruciblePlatform.jsx for parity with
// RiskData.jsx / NexusData.jsx / CalendarData.jsx.
//
// Exposes:
//   window.CRUCIBLE_DATA = {
//     argumentGraph: { nodes, edges },
//     arguments,        // top-level arguments (Adversary tab list)
//     attorneys,        // opposing-counsel dossiers (Recon)
//     citations,        // Authority Stack (Authorities)
//     briefs,           // Brief Bank templates
//     telemetry,        // Telemetry analytics
//     transcript,       // sample for Dialectic
//     nodeTypes,        // Workbench palette spec (also exposed as window.CRUCIBLE_NODE_TYPES)
//   }
(function () {
  const NODE_TYPES = {
    issue:      { label: 'Issue',      hint: 'the legal question',     color: '#475569', bg: 'rgba(71,85,105,0.10)',  shape: 'diamond', w: 200, h: 60 },
    claim:      { label: 'Claim',      hint: 'our position',           color: '#2563EB', bg: 'rgba(37,99,235,0.08)',   shape: 'rect',    w: 220, h: 80 },
    premise:    { label: 'Premise',    hint: 'logical support',        color: '#D97706', bg: 'rgba(217,119,6,0.10)',   shape: 'rect',    w: 200, h: 70 },
    support:    { label: 'Support',    hint: 'citation / evidence',    color: '#C9A84C', bg: 'rgba(201,168,76,0.12)',  shape: 'rect',    w: 180, h: 70 },
    counter:    { label: 'Counter',    hint: 'opposition argument',    color: '#DC2626', bg: 'rgba(220,38,38,0.08)',   shape: 'rect',    w: 200, h: 70 },
    concession: { label: 'Concession', hint: 'acknowledged weakness',  color: '#6B7280', bg: 'rgba(107,114,128,0.10)', shape: 'rect',    w: 180, h: 60 },
  };

  const argumentGraph = {
    nodes: [
      { id: 'iss',  type: 'issue',   x: 380, y: 24,  label: 'Whether defendant breached fiduciary duty by self-dealing', strength: 100, citations: [] },
      { id: 'cl1',  type: 'claim',   x: 380, y: 130, label: 'Defendant breached duty of loyalty by approving the Pelican Bay transaction', strength: 78,
        citations: [{ short: 'Meinhard', full: 'Meinhard v. Salmon, 249 N.Y. 458', binding: 'binding' }] },
      { id: 'pr1',  type: 'premise', x: 100, y: 280, label: 'Director was on both sides of the Pelican Bay deal', strength: 88,
        citations: [{ short: 'Bd Min Q3', full: 'Board Minutes Q3 2024', binding: 'binding' }] },
      { id: 'pr2',  type: 'premise', x: 380, y: 280, label: 'Transaction was not disclosed to disinterested directors before approval', strength: 82,
        citations: [{ short: '8 Del.C.§144', full: '8 Del. C. § 144', binding: 'binding' }] },
      { id: 'pr3',  type: 'premise', x: 660, y: 280, label: 'Pricing was 18% below contemporaneous market comparable', strength: 70,
        citations: [{ short: 'Expert Rpt', full: 'Mitchell Forensic Report', binding: 'persuasive' }] },
      { id: 'sup1', type: 'support', x: 100, y: 420, label: 'Email — defendant solicited Pelican Bay terms', strength: 86,
        citations: [{ short: 'EXH-047', full: 'Email Oct 14, 2024', binding: 'binding' }] },
      { id: 'sup2', type: 'support', x: 380, y: 420, label: 'Defendant\'s deposition admits no prior disclosure', strength: 92,
        citations: [{ short: 'Depo p.142', full: 'Smith Depo. 142:8-15', binding: 'binding' }] },
      { id: 'cnt1', type: 'counter', x: 660, y: 420, label: 'Business judgment rule presumption applies; transaction was arms-length', strength: 42,
        citations: [] },
    ],
    edges: [
      { id: 'e1', from: 'pr1',  to: 'cl1' },
      { id: 'e2', from: 'pr2',  to: 'cl1' },
      { id: 'e3', from: 'pr3',  to: 'cl1' },
      { id: 'e4', from: 'sup1', to: 'pr1' },
      { id: 'e5', from: 'sup2', to: 'pr2' },
      { id: 'e6', from: 'cnt1', to: 'cl1' },
      { id: 'e7', from: 'iss',  to: 'cl1' },
    ],
  };

  const argumentList = [
    { id: 'a1', label: 'MSJ — Breach of Fiduciary Duty',  matter: 'Redstone v. Meridian',  filed: 'draft',  strength: 78 },
    { id: 'a2', label: 'MTD — 12(b)(6) Failure to State', matter: 'Pacific Shipping',      filed: 'filed',  strength: 64 },
    { id: 'a3', label: 'Daubert — Exclude Dr. Mitchell',  matter: 'Blackwell IP',          filed: 'pending',strength: 55 },
    { id: 'a4', label: 'Class Cert Opposition',           matter: 'Chen v. Atlas',         filed: 'draft',  strength: 70 },
  ];

  const attorneys = [
    { id: 't1', firm: 'Coastal & Banks LLP', lead: 'A. Robertson',  bar: 'NY · 1998', cases: 142, winRate: 71, style: 'Aggressive · citation-heavy', avatar: 'AR' },
    { id: 't2', firm: 'Pelican Strategies',  lead: 'M. Vance',      bar: 'CA · 2004', cases:  88, winRate: 64, style: 'Procedural · narrow-issue',    avatar: 'MV' },
    { id: 't3', firm: 'Whitfield & Hayes',   lead: 'D. Hayes',      bar: 'DE · 1991', cases: 211, winRate: 78, style: 'Strategic · settlement-prone', avatar: 'DH' },
    { id: 't4', firm: 'Thornton Defense',    lead: 'J. Park',       bar: 'NY · 2010', cases:  61, winRate: 52, style: 'Volume · template-driven',     avatar: 'JP' },
  ];

  const motionPlaybook = [
    { type: 'Motion to Dismiss',         filed: 38, won: 24, rate: 63, signature: 'Twombly + plausibility' },
    { type: 'Summary Judgment',          filed: 22, won: 13, rate: 59, signature: 'Anderson + entire-fairness frame' },
    { type: 'Motion to Compel',          filed: 51, won: 37, rate: 73, signature: 'Rule 26(b)(1) proportionality push' },
    { type: 'Motion in Limine',          filed: 19, won: 11, rate: 58, signature: 'Daubert + FRE 403 stacking' },
    { type: 'Discovery Sanctions',       filed: 12, won:  4, rate: 33, signature: 'Rule 37(c)(1) — narrow asks' },
    { type: 'Class Certification (opp)', filed:  9, won:  5, rate: 56, signature: 'Comcast + commonality attack' },
  ];

  const judges = [
    { name: 'Hon. L. Reynolds (SDNY)', alignment: 78, prior: 6, ruling: 'mostly grants',   note: 'Tightly enforces page limits.' },
    { name: 'Hon. K. Chen (SDNY)',     alignment: 52, prior: 3, ruling: 'split',           note: 'Skeptical of expert testimony.' },
    { name: 'Hon. A. Martinez (CDCA)', alignment: 41, prior: 1, ruling: 'unfavorable',     note: 'Has imposed sanctions twice.' },
    { name: 'Hon. D. Kaplan (NDNY)',   alignment: 88, prior: 9, ruling: 'highly favorable',note: 'Reuses opinion language.' },
  ];

  const witnessVulns = [
    { name: 'Dr. C. Mitchell', role: 'Damages expert',  exposure: 88, basis: 'Methodology overturned in Hartwell (2023)' },
    { name: 'R. Thornton',     role: 'Custodian',       exposure: 61, basis: 'Email retention gaps' },
    { name: 'L. Park (CFO)',   role: 'Fact witness',    exposure: 42, basis: 'Inconsistent prior testimony' },
    { name: 'K. Vance',        role: 'Industry expert', exposure: 30, basis: 'Solid methodology, tight CV' },
  ];

  const linguistic = {
    avgBriefLength: 24,
    avgCites:       58,
    sentenceLen:    19.4,
    flesch:         42,
    hedging:        'low',
    tone:           'declarative',
    rhetorical:     'few rhetorical questions; heavy reliance on case lineage',
  };

  const citations = [
    { id: 'c1',  short: 'Meinhard',   full: 'Meinhard v. Salmon, 249 N.Y. 458 (1928)',                strength: 92, binding: 'binding',     status: 'good',            topic: 'Fiduciary duty',       uses: 14 },
    { id: 'c2',  short: 'Aronson',    full: 'Aronson v. Lewis, 473 A.2d 805 (Del. 1984)',             strength: 88, binding: 'binding',     status: 'good',            topic: 'Demand futility',      uses: 22 },
    { id: 'c3',  short: 'Caremark',   full: 'In re Caremark, 698 A.2d 959 (Del. Ch. 1996)',           strength: 84, binding: 'binding',     status: 'good',            topic: 'Oversight liability',  uses:  9 },
    { id: 'c4',  short: 'Disney',     full: 'In re Walt Disney, 906 A.2d 27 (Del. 2006)',             strength: 80, binding: 'binding',     status: 'good',            topic: 'Business judgment',    uses: 11 },
    { id: 'c5',  short: 'Twombly',    full: 'Bell Atl. Corp. v. Twombly, 550 U.S. 544 (2007)',        strength: 95, binding: 'binding',     status: 'good',            topic: 'Pleading standard',    uses: 38 },
    { id: 'c6',  short: 'Iqbal',      full: 'Ashcroft v. Iqbal, 556 U.S. 662 (2009)',                 strength: 95, binding: 'binding',     status: 'good',            topic: 'Pleading standard',    uses: 31 },
    { id: 'c7',  short: 'Daubert',    full: 'Daubert v. Merrell Dow, 509 U.S. 579 (1993)',            strength: 90, binding: 'binding',     status: 'good',            topic: 'Expert reliability',   uses: 18 },
    { id: 'c8',  short: 'Spokeo',     full: 'Spokeo v. Robins, 578 U.S. 330 (2016)',                  strength: 76, binding: 'binding',     status: 'narrowed',        topic: 'Standing',             uses:  7 },
    { id: 'c9',  short: 'Hartwell',   full: 'Hartwell Mfg. v. Coastal, 14 F.4th 322 (3d Cir 2024)',   strength: 48, binding: 'persuasive',  status: 'distinguishable', topic: 'Damages methodology',  uses:  4 },
    { id: 'c10', short: 'Pelican Bd', full: 'Pelican Bay Bd. Min. Q3 2024',                           strength: 70, binding: 'evidentiary', status: 'good',            topic: 'Disclosure timing',    uses:  6 },
  ];

  const briefs = [
    { id: 'b1', name: 'MSJ — Breach of Fiduciary Duty (Delaware)', uses:  38, wins: 28, wr: 74, judges:  6, jurisdictions: 'DE, NY' },
    { id: 'b2', name: 'MTD — Twombly/Iqbal failure to state',       uses: 142, wins: 91, wr: 64, judges: 22, jurisdictions: 'Federal' },
    { id: 'b3', name: 'Daubert — exclude opposing damages expert',  uses:  24, wins: 18, wr: 75, judges:  9, jurisdictions: 'SDNY, EDVA' },
    { id: 'b4', name: 'Class Cert opposition (Comcast)',            uses:  19, wins: 12, wr: 63, judges:  4, jurisdictions: 'Federal' },
    { id: 'b5', name: 'Motion to Compel (proportionality)',         uses:  67, wins: 49, wr: 73, judges: 14, jurisdictions: 'All' },
    { id: 'b6', name: 'Discovery sanctions — Rule 37(c)(1)',        uses:  28, wins: 20, wr: 71, judges: 11, jurisdictions: 'Federal' },
  ];

  const telemetry = {
    byType: [
      { type: 'MSJ',         wins: 28, total: 38,  rate: 74 },
      { type: 'MTD',         wins: 91, total: 142, rate: 64 },
      { type: 'Daubert',     wins: 18, total:  24, rate: 75 },
      { type: 'Class Cert',  wins: 12, total:  19, rate: 63 },
      { type: 'MTC',         wins: 49, total:  67, rate: 73 },
      { type: 'Sanctions',   wins: 20, total:  28, rate: 71 },
    ],
    trend: [62, 64, 66, 68, 70, 71, 73, 72, 74, 75, 76, 77],
    authors: [
      { name: 'M. Kirkland', wins: 84, total: 102, rate: 82 },
      { name: 'S. Chen',     wins: 38, total:  56, rate: 68 },
      { name: 'L. Torres',   wins: 51, total:  78, rate: 65 },
      { name: 'J. Park',     wins: 22, total:  41, rate: 54 },
      { name: 'R. Torres',   wins: 18, total:  25, rate: 72 },
    ],
  };

  const transcript = `Your Honor, may it please the court. We come before you on Plaintiff's motion for summary judgment on Count I, breach of fiduciary duty. The record is clear: defendant approved the Pelican Bay transaction without disclosing his economic interest, in violation of 8 Del. C. § 144 and the duty of loyalty articulated in Meinhard v. Salmon. Um, we believe the email of October 14 — exhibit 47 in the record — establishes scienter beyond any reasonable dispute. Defendant's deposition testimony, basically, confirms the disclosure was made post-hoc, after the contract had been signed. Under Aronson v. Lewis, this falls outside the business judgment rule presumption. We respectfully submit that no reasonable jury could find for defendant on this record.`;

  // ── Wargame decision tree (kept as nested structure for tree render) ─────
  const wargameTree = {
    label: 'Current — file MSJ',
    ev: 8400000, prob: 1.0, kind: 'edge',
    children: [
      { label: 'Granted (full)', prob: 0.22, ev: 14200000, kind: 'weld', terminal: true },
      { label: 'Granted in part', prob: 0.31, ev: 6200000, kind: 'weld',
        children: [
          { label: 'Settle remaining counts', prob: 0.55, ev: 4100000, kind: 'weld',  terminal: true },
          { label: 'Trial on remaining',      prob: 0.45, ev: 7300000, kind: 'ember', terminal: true },
        ] },
      { label: 'Denied', prob: 0.36, ev: -1200000, kind: 'flame',
        children: [
          { label: 'Cross-MSJ filed',  prob: 0.30, ev: -800000,  kind: 'ember', terminal: true },
          { label: 'Settle pre-trial', prob: 0.45, ev:  3600000, kind: 'weld',  terminal: true },
          { label: 'Trial',            prob: 0.25, ev: -2400000, kind: 'flame', terminal: true },
        ] },
      { label: 'Dismissed without prejudice', prob: 0.11, ev: 0, kind: 'ash', terminal: true },
    ],
  };

  window.CRUCIBLE_NODE_TYPES = NODE_TYPES;
  window.CRUCIBLE_DATA = {
    argumentGraph,
    arguments: argumentList,
    attorneys,
    motionPlaybook,
    judges,
    witnessVulns,
    linguistic,
    citations,
    briefs,
    telemetry,
    transcript,
    wargameTree,
  };
})();
