// ═══════════════════════════════════════════════════════════════════
// RAISABLE — THE INVESTMENT PROJECT (window.RAISABLE)
// Canonical source: Raisable-Investor-Hub (uploads/Raisable-Investor-Hub.html)
// + founder corrections of Jun 12, 2026.
//
// HONEST BASELINE (by design — no fake data):
//   · NOT YET INCORPORATED — docs in draft · target Jul 1, 2026 · no EIN
//   · $0 committed · $0 revenue · $0 cash — pre-revenue by design
//   · Team: 4 founders, no other employees
//   · Brokers: SPCP · Texture Capital · tZero — handshakes, NO contracts
//
// SEPARATION OF CONCERNS (explicit, by design):
//   · RAISABLE BUSINESS    — the operating company twin (Control plane).
//   · RAISABLE INVESTMENT  — Raisable AS AN ISSUER on its own platform:
//     offerings under Operations · Projects; objects under Ontology;
//     the investor-facing DOSSIER under Analytics · Investor Intelligence.
//
// PII POLICY: no investor identities at rest. Account-level data stays
// with the broker of record (once engaged). Demand aggregates only.
// ═══════════════════════════════════════════════════════════════════
(function () {
  // ── SOURCE REGISTRY — every datapoint cites exactly ONE source:
  // a data-room Document (DOC-NNN · all drafts), the offering Settings,
  // or the issuer Onboarding profile.
  const SRC = {
    "DOC-001": { kind: "doc", name: "Business Plan / Investor Hub (draft)",  file: "data-room/DOC-001-business-plan.md", uploaded: "28 May", parsed: "28 May" },
    "DOC-002": { kind: "doc", name: "Articles of Incorporation (draft · WY)", file: "uploads/1_Articles_of_Incorporation_Raisable.docx", uploaded: "28 May", parsed: "28 May" },
    "DOC-003": { kind: "doc", name: "YC Post-Money SAFE Instrument (draft)", file: "data-room/DOC-003-safe-instrument.md", uploaded: "30 May", parsed: "30 May" },
    "DOC-004": { kind: "doc", name: "Investor List (broker-held · empty)",   file: "data-room/DOC-004-investor-list.md", uploaded: "30 May", parsed: "30 May" },
    "DOC-005": { kind: "doc", name: "Private Placement Memorandum (draft)",  file: "data-room/DOC-005-ppm.md", uploaded: "30 May", parsed: "31 May" },
    "DOC-006": { kind: "doc", name: "Form D Worksheet (draft)",              file: "data-room/DOC-006-form-d-worksheet.md", uploaded: "31 May", parsed: "31 May" },
    "DOC-007": { kind: "doc", name: "Form C Outline (draft · Reg CF)",       file: "data-room/DOC-007-form-c-outline.md", uploaded: "31 May", parsed: "31 May" },
    "DOC-008": { kind: "doc", name: "Campaign Perks Schedule (draft)",       file: "data-room/DOC-008-campaign-perks.md", uploaded: "31 May", parsed: "1 Jun" },
    "DOC-009": { kind: "doc", name: "Broker Conversations Log (unsigned)",   file: "data-room/DOC-009-broker-mou-notes.md", uploaded: "1 Jun", parsed: "1 Jun" },
    "DOC-010": { kind: "doc", name: "Financial Model (projections)",         file: "data-room/DOC-010-financial-model.md", uploaded: "28 May", parsed: "29 May" },
    "DOC-011": { kind: "doc", name: "Initial Stock Ledger (draft)",          file: "uploads/4_Initial_Stock_Ledger_Raisable.docx", uploaded: "30 May", parsed: "30 May" },
    "DOC-012": { kind: "doc", name: "TX Strategic Alliance Proposal (unsigned · 14 May 2026)", file: "uploads/Raisable-tx-Partnership-Memo.docx", uploaded: "16 Jun", parsed: "16 Jun" },
    "DOC-013": { kind: "doc", name: "CoreNest Call Brief (internal)",         file: "uploads/CoreNest-Call-Brief.pdf", uploaded: "16 Jun", parsed: "16 Jun" },
    "settings":   { kind: "settings",   name: "Offering Settings",  file: "platform · offering configuration", uploaded: "live", parsed: "live" },
    "onboarding": { kind: "onboarding", name: "Onboarding Profile", file: "platform · issuer onboarding", uploaded: "live", parsed: "live" },
  };
  const DOC_COUNT = Object.values(SRC).filter((s) => s.kind === "doc").length;

  // ── CLASSIFICATION VOCABULARY — every fact & claim carries one ─────
  const CLASS = {
    V: { label: "verified",     tone: "ok",      note: "externally checkable — filed, registered or public data" },
    P: { label: "self-reported",tone: "warn",    note: "issuer-stated · unverified until evidence lands" },
    A: { label: "assumption",   tone: "info",    note: "market narrative without a cited source" },
    H: { label: "hypothesis",   tone: "neutral", note: "forward-looking plan or model target — not a present fact" },
    Q: { label: "questionable", tone: "err",     note: "in the contradiction register — resolve before launch" },
  };

  // ── KB MEMORY KEYS — instances of ENT-kbkey, one source each ──────
  // [key, value, source, group, class, confidence 0–100]
  // confidence → tone: ≥75 green · 45–74 yellow · <45 red (confTone)
  const KB = [
    // company — nothing exists legally yet; profile is issuer-stated
    ["company.legal_name",     "Raisable Inc. — WY articles in DRAFT, unfiled",     "DOC-002",    "company",   "P", 72],
    ["company.status",         "Not yet incorporated · target July 1, 2026",        "onboarding", "company",   "P", 85],
    ["company.entity_type",    "C-Corporation — per draft WY articles",             "DOC-002",    "company",   "P", 70],
    ["company.state",          "Wyoming — W.S. §§17-16-101 (draft articles)",       "DOC-002",    "company",   "P", 70],
    ["company.registered_agent","InCorp Services · 1910 Thomes Ave, Cheyenne WY",   "DOC-002",    "company",   "P", 75],
    ["company.authorized_shares","10,000,000 @ $0.001 par — Class A 9M (10× votes) + Class B 1M pool", "DOC-002", "company", "P", 78],
    ["company.founder_split",  "Class A 30 / 20 / 20 / 20 — all unvested per RSPA", "DOC-011",    "company",   "P", 75],
    ["company.parent",         "Stobox group — operating since 2018 · 100+ issuer engagements", "DOC-013", "company", "P", 70],
    ["company.ein",            "None — SS-4 filed after incorporation",             "onboarding", "company",   "P", 80],
    ["company.website",        "raisable.ai",                                       "onboarding", "company",   "P", 85],
    ["company.team",           "4 founders — no other employees",                   "onboarding", "company",   "P", 88],
    ["company.industry",       "FinTech / RegTech — capital-formation intelligence","onboarding", "company",   "P", 78],
    // traction — honest zero baseline
    ["traction.status",        "Pre-revenue · pre-incorporation — product in dev",  "onboarding", "traction",  "P", 80],
    ["traction.customers",     "0 — design-partner conversations only",             "onboarding", "traction",  "P", 72],
    ["traction.partnerships",  "TX & Texture Capital alliance — at signature · SPCP · tZero conversations", "DOC-012", "traction", "P", 68],
    ["alliance.parties",       "Stobox · Raisable · TX · Texture Capital — alliance · definitive docs in signing", "DOC-012", "traction", "P", 75],
    ["alliance.tx_equity",     "TX 5–10% founding tier — contingent: capital intro + Texture BD of record · vests on both", "DOC-012", "traction", "P", 72],
    ["alliance.tokenization",  "TX — tokenization provider for the post-raise token path", "DOC-012", "traction", "P", 68],
    ["alliance.capital_intro", "CoreNest Capital + TX relationships — anticipated capital channel", "DOC-012", "traction", "H", 45],
    ["traction.parent_pipeline","Stobox issuer pipeline feeds top-of-funnel from day one", "DOC-013", "traction", "H", 45],
    // financials — no entity, no statements
    ["fin.revenue",            "$0 — pre-revenue",                                  "onboarding", "financials","P", 85],
    ["fin.cash",               "$0 — founder-funded to date",                       "onboarding", "financials","P", 78],
    ["fin.debt",               "$0 — no entity, no facilities",                     "onboarding", "financials","P", 78],
    ["fin.runway",             "None independent — raise-dependent",                "onboarding", "financials","P", 80],
    // market — from the Investor Hub; EDGAR-checkable rows are V
    ["mkt.problem_pool",       "$3–5B/yr US legal + compliance spend on offerings", "DOC-001",    "market",    "A", 40],
    ["mkt.revenue_tam",        "$400–600M/yr addressable at ~$7K ACV",              "DOC-001",    "market",    "A", 38],
    ["mkt.sam",                "$120–180M/yr — reachable issuers via CBS + broker", "DOC-001",    "market",    "A", 35],
    ["mkt.som",                "3-yr SOM $5–10M ARR (~700–1,400 issuers)",          "DOC-001",    "market",    "H", 30],
    ["mkt.formd_volume",       "~75,000 Form D claim · SEC EO stats: 55,162 exempt-offering filings in 2024 (−4.5% YoY)", "DOC-001", "market", "V", 86],
    ["mkt.median_raise",       "Median operating-company raise ~$3M",               "DOC-001",    "market",    "V", 75],
    ["mkt.exit_comp",          "Computershare ÷ Corporate Creations · $142.9M · ~4.1× revenue (verified 5 Feb 2020)", "DOC-001", "market", "V", 92],
    // offering — Reg D 506(c) — issuer-configured, nothing signed/filed
    ["rd.amount",              "$2,000,000 of the $2.7M combined",                  "settings",   "reg-d",     "P", 78],
    ["rd.security",            "YC post-money SAFE · $16M valuation cap",           "DOC-003",    "reg-d",     "P", 80],
    ["rd.dilution",            "~16.9% combined SAFE dilution at full $2.7M",       "settings",   "reg-d",     "P", 72],
    ["rd.min_investment",      "$1,000 per investor",                               "settings",   "reg-d",     "P", 70],
    ["rd.broker",              "Texture Capital — alliance BD of record (at signature) · SPCP / tZero backup", "DOC-012", "reg-d", "P", 65],
    ["rd.verification",        "506(c) accreditation check — provider TBD",         "settings",   "reg-d",     "P", 55],
    ["rd.launch",              "Target Sep 2026 — after incorporation + BD signed", "settings",   "reg-d",     "H", 45],
    ["rd.form_d",              "Within 15 days AFTER first sale (Rule 503)",        "DOC-006",    "reg-d",     "V", 90],
    // offering — Reg CF — sequenced after incorporation
    ["cf.target",              "$700,000 of the $2.7M combined",                    "settings",   "reg-cf",    "P", 78],
    ["cf.security",            "Same YC SAFE via funding portal",                   "settings",   "reg-cf",    "P", 65],
    ["cf.portal",              "Funding portal — not yet selected",                 "settings",   "reg-cf",    "P", 50],
    ["cf.form_c",              "Cannot file pre-incorporation — drafting after Jul 1", "DOC-007", "reg-cf",    "V", 85],
    ["cf.window",              "Target Q4 2026 — post-filing",                      "settings",   "reg-cf",    "H", 45],
    // plan — model targets from the hub; all forward-looking
    ["plan.pricing",           "ARPA $3.6–12K/yr (Launch·Growth·Scale) · base tiers $199–499/mo", "DOC-001", "plan", "H", 58],
    ["plan.economics",         "Targets: GM ~80% · CAC $500–800 · LTV/CAC 17–28×",  "DOC-010",    "plan",      "H", 35],
    ["plan.use_of_proceeds",   "Team 35 · AI infra 30 · Product 20 · GTM 15",       "DOC-001",    "plan",      "H", 60],
    ["plan.milestones",        "5–10 closes on-platform · 30–50 paying · ~$1M ARR run-rate", "DOC-001", "plan", "H", 40],
    ["plan.series_a",          "$8–12M priced A in 15–18 mo at $25–50M pre",        "DOC-001",    "plan",      "H", 25],
    ["plan.exit",              "Strategic M&A Series B/C · CSC · Vistra · TMF · Computershare", "DOC-001", "plan", "H", 30],
  ].map(([key, value, source, group, cls, conf]) => ({ key, value, source, group, cls, conf }));

  // confidence → traffic-light tone (shared by every datapoint renderer)
  const confTone = (n) => (n >= 75 ? "ok" : n >= 45 ? "warn" : "err");

  const classCounts = () => {
    const c = { V: 0, P: 0, A: 0, H: 0, Q: 0 };
    KB.forEach((f) => { c[f.cls] = (c[f.cls] || 0) + 1; });
    return c;
  };

  // ── FOUNDERS (cap table set at incorporation — DOC-011) ───────────
  const CAPTABLE = [
    // per draft Initial Stock Ledger (DOC-011 · unfiled). All Class A
    // unvested per RSPA; struck-through vesting clauses in the draft are
    // pending CLO removal and are NOT cited here.
    { holder: "Yevgen Dyeyev",             role: "CEO & Chairman · Sole Director", cls: "A", shares: 3000000, pct: 30 },
    { holder: "Rostyslav-Pavlo Shemeliak", role: "COO",                            cls: "A", shares: 2000000, pct: 20 },
    { holder: "Maksym Rafalsky",           role: "Head Legal Officer",             cls: "A", shares: 2000000, pct: 20 },
    { holder: "Vladyslav Gudzenko",        role: "CTO",                            cls: "A", shares: 2000000, pct: 20 },
    { holder: "Advisor pool — reserved",   role: "unissued until Board RSAs",      cls: "B", shares: 1000000, pct: 10 },
  ];

  // ── THE TWO OFFERINGS — $2.7M combined on one YC post-money SAFE ──
  const OFFERINGS = [
    {
      id: "OFF-RD-2026", label: "Seed · Reg D 506(c)", exemption: "EX-506c", state: "in-prep",
      security: "YC post-money SAFE — same instrument across both paths",
      unitPrice: "$16M valuation cap", units: "~16.9% dilution at full $2.7M",
      target: 2000000, max: 2000000, raisedCommitted: 0, minInvestment: 1000,
      valuation: "$16M post-money cap", broker: null, portal: null,
      rails: "Texture Capital — alliance BD of record (at signature) · SPCP / tZero backup",
      fees: "Placement fees — set in the alliance definitive documents (in signing)",
      verification: "506(c) — accreditation verification required before any sale; provider to be selected",
      audience: "Accredited only (no investor cap) · general solicitation permitted",
      timeline: [
        { date: "Jun 12, 2026", what: "Data-room drafts staged (plan · SAFE · PPM · worksheet)", done: true  },
        { date: "Jul 1, 2026",  what: "Incorporation — articles filed (target start date)",     done: false },
        { date: "Jul 15, 2026", what: "EIN · bank account · SAFE becomes issuable",             done: false },
        { date: "Aug 2026",     what: "Alliance definitive docs executed — Texture Capital BD of record", done: false },
        { date: "Sep 2026",     what: "Launch — general solicitation (anchor preferred)",       done: false },
        { date: "Q4 2026",      what: "Target first close · Form D within 15 days after",      done: false },
      ],
      perks: [
        { tier: "$1,000 – $9,999",   perk: "Founder access · quarterly CEO briefings + community event", cap: "Unlimited" },
        { tier: "$10,000 – $49,999", perk: "Executive mentorship (2×1h) + monthly investor newsletter",   cap: "First 15" },
        { tier: "$50,000+",          perk: "Board observer seat (24 mo) + quarterly partner summits",     cap: "Max 3" },
      ],
    },
    {
      id: "OFF-CF-2026", label: "Community · Reg CF", exemption: "EX-cf", state: "sequenced",
      security: "Same YC post-money SAFE, offered via funding portal",
      unitPrice: "$16M valuation cap", units: "shared across the $2.7M round",
      target: 700000, max: 700000, raisedCommitted: 0, minInvestment: 1000,
      valuation: "$16M post-money cap", broker: null, portal: null,
      rails: "Funding portal — not yet selected · broker advisor TBD",
      fees: "Portal + advisor fees — set when the portal is selected",
      verification: "Open to all investors via portal · Reg CF investment limits apply",
      audience: "Anyone (retail + accredited) via portal",
      timeline: [
        { date: "Jun 12, 2026", what: "Form C outline + perks schedule drafted",                done: true  },
        { date: "Jul 1, 2026",  what: "Incorporation (shared gate with Reg D)",                 done: false },
        { date: "Aug 2026",     what: "Portal selected · inception statements CPA-reviewed",    done: false },
        { date: "Sep 2026",     what: "Form C files with the SEC (target)",                     done: false },
        { date: "Oct 2026",     what: "Campaign opens (target)",                                done: false },
        { date: "Q1 2027",      what: "Close window",                                           done: false },
      ],
      perks: [
        { tier: "$1,000 – $4,999",   perk: "1-year Early Access beta license + priority support",       cap: "Unlimited" },
        { tier: "$5,000 – $24,999",  perk: "Enterprise onboarding + quarterly business reviews",        cap: "First 12" },
        { tier: "$25,000+",          perk: "18-mo white-label license + advisory board seat",           cap: "First 3" },
      ],
    },
  ];

  // ── INVESTOR DEMAND — AGGREGATES ONLY · honest zero state ──────────
  const DEMAND = {
    source: "DOC-004", asOf: "Jun 12, 2026",
    piiNote: "Account-level names, checks and subscription documents will stay with the broker of record (once engaged). The platform stores demand aggregates only — no investor PII at rest.",
    accounts: 0, committedAccounts: 0,
    committed: 0, target: 2000000, largestCheck: 0, leadProfile: "none yet",
    verification: "506(c) accreditation verification required before any sale — provider not yet selected",
    byType: [], byGeo: [], byBand: [], funnel: [],
  };

  // ── FINANCIAL BASELINE + PLAN — no entity, no statements ───────────
  const FINANCIALS = {
    asOf: "Jun 12, 2026 · pre-incorporation — no entity, no statements",
    revenueYTD: 0, cash: 0,
    snapshot: [
      ["entity status",          "not incorporated — docs in draft (Jul 1)"],
      ["revenue to date",        "$0 — pre-revenue"],
      ["cash on hand",           "$0 — founder-funded"],
      ["debt",                   "$0 — no entity, no facilities"],
      ["independent runway",     "none — raise-dependent"],
      ["post-raise runway",      "12–18 mo · milestone-bound"],
      ["planned burn (full team)","~$150–185K / mo"],
    ],
    revMix: [],
    revMixNote: "No revenue yet. Base tiers $199–499/mo; blended ARPA $3.6–12K/yr — typical issuer ~$5–10K (DOC-001).",
    arrRamp: [
      { year: "2026", arr: 0,        customers: 0 },
      { year: "2027", arr: 1000000,  customers: 40 },
      { year: "2028", arr: 3000000,  customers: 250 },
      { year: "2029", arr: 6500000,  customers: 700 },
      { year: "2030", arr: 10000000, customers: 1400 },
    ],
    milestones: [
      { when: "M3–6",   what: "First 5–10 offerings close on-platform — the PMF signal" },
      { when: "M6–9",   what: "30–50 paying issuers · rails locked (BD + 2 CBS partnerships signed)" },
      { when: "M12",    what: "~$1M ARR run-rate (~$80–100K MRR) · modules 2–3 shipped" },
      { when: "M15–18", what: "Series A · $8–12M at $25–50M pre (hypothesis)" },
    ],
  };

  const USE_OF_PROCEEDS = [
    { cat: "Team & agentic engineering", pct: 35, note: "~$945K — CMO, Head of Product, Agentic dev lead + eng/ops on the founding team" },
    { cat: "AI infrastructure",          pct: 30, note: "~$810K — token consumption and the agent stack behind the documentation engine" },
    { cat: "Product — modules 2–3",      pct: 20, note: "~$540K — fit-scoring and distribution modules on the same agentic backbone" },
    { cat: "GTM & partnerships",         pct: 15, note: "~$405K — BD network and CBS-provider partnerships, the partner-led channel" },
  ];

  const FILINGS = [
    { id: "FIL-inc",    name: "Incorporation (articles)",  status: "due",     detail: "In draft — target filing Jul 1, 2026. Gates EIN, bank, SAFE issuance and every filing below" },
    { id: "FIL-ein",    name: "EIN (Form SS-4)",           status: "pending", detail: "Filed immediately after incorporation — required for bank, escrow and any SEC filing" },
    { id: "FIL-formc",  name: "Form C (Reg CF)",           status: "future",  detail: "Cannot file pre-incorporation — requires CPA-reviewed inception statements · target Sep 2026" },
    { id: "FIL-formd",  name: "Form D (Reg D 506(c))",     status: "future",  detail: "Within 15 days AFTER first sale (Rule 503) — first close targeted Q4 2026" },
    { id: "FIL-bluesky",name: "State blue-sky notices",    status: "future",  detail: "Per-state notices within 15 days of first sale in each state" },
  ];

  // ── THE DOSSIER — the analysis layer over the facts ────────────────
  const DOSSIER = {
    thesis: {
      headline: "The financial socket of regulated capital formation — raising on the story it sells.",
      pillars: [
        { t: "The wedge",            d: "$50–150K / 3–6 mo of legal work collapsed to a $3.6–12K/yr subscription. ~75K Form D filings/yr (DOC-001)." },
        { t: "The compounding loop", d: "Each offering feeds the broker-acceptance dataset. The moat is the learning loop over what clears review — not the documents." },
        { t: "Partner-led CAC",      d: "CBS providers and brokers already hold the issuers, paid on success. CAC $500–800 vs ~$14K GM-LTV (target)." },
        { t: "Honest baseline",      d: "Pre-incorporation, pre-revenue, $0 committed. Priced on the milestone set, not on traction." },
      ],
      counterweight: "Counterweight: no company yet — incorporation, EIN, bank, a signed broker and first paying issuers all sit between this story and a closeable round.",
    },
    verdict: {
      headline: "A pre-company with a complete story. Everything gates on July 1 — incorporate first, then sign one rail.",
      body: "Coherent narrative; market primary-sourced (SEC: 55,162 exempt offerings 2024; exit comp ~4.1× rev) and corporate package drafted to filing standard. But nothing exists legally — no entity, EIN, bank, signed broker or portal; $0 committed. TX & Texture alliance at signature, not executed. The zero baseline is the strength; the incorporate → EIN → BD → launch chain is the critical path, and every date moves with Jul 1.",
      confidence: 48,
      pills: [["facts sourced", KB.length + " / " + KB.length], ["contradictions", "3 open · 2 noted · 1 resolved"], ["committed capital", "$0 — pre-launch"]],
    },
    findings: [
      { cls: "V", text: "Market is real and primary-sourced — 55,162 exempt offerings in 2024 (SEC); exit comp ~4.1× revenue (Computershare / Corporate Creations, $142.9M)." },
      { cls: "P", text: "Everything company-side is self-reported — no entity, EIN or statements until Jul 1 incorporation." },
      { cls: "P", text: "TX & Texture alliance at signature, not executed; no portal selected. SPCP / tZero are backup rails." },
      { cls: "H", text: "All economics (GM ~80%, CAC $500–800, LTV/CAC 17–28×) are model targets — zero operating data." },
      { cls: "A", text: "Market sizing ($3–5B pool · $400–600M TAM) states a method but cites no source (GAP-04)." },
    ],
    strengths: [
      "One instrument, two paths — a single YC SAFE ($16M cap) across Reg D 506(c) + Reg CF.",
      "Corporate package drafted to filing standard — WY articles, Class A/B, 4-founder ledger (DOC-002 · DOC-011).",
      "Honest zero baseline — no traction claims to defend, no restatement risk.",
      "Founding-tier alliance at signature — capital intro (CoreNest), BD of record and the TX tokenization rail in one package.",
      "Milestone-priced — 5–10 closes, 30–50 paying, ~$1M run-rate; not on what exists today.",
    ],
    watch: [
      "No legal entity — every downstream date (EIN, bank, SAFE issuance, filings) moves with the Jul 1 incorporation.",
      "The raise is existential — $0 cash, founder funding only; a failed close is a shutdown scenario.",
      "Alliance at signature but not executed — portal and verification provider are still open selections.",
      "Concurrent-offering communications: 506(c) solicitation vs portal-only Reg CF rules must not cross once live.",
      "Dilution stack unmodeled — SAFE ~16.9% + TX 5–10% founding tier + 10% Class B pool compound before any priced round (GAP-07).",
    ],
    asks: [
      "Articles filed on Jul 1; EIN and bank account within two weeks (GAP-01 · GAP-02).",
      "Alliance definitive docs executed — Texture Capital as BD of record (GAP-03).",
      "1–2 anchor commitments ($250K+) before general solicitation opens (GAP-05).",
      "'Live product' claim reconciled to demo-stage reality across investor materials (X-01).",
    ],
    verification: [
      { claim: "~75,000 Form D filings/yr · $2T+ raised",        finding: "SEC Exempt-Offering stats: 55,162 filings in 2024 (−4.5% YoY). Hub's ~75K figure runs above SEC's count — re-source from DERA before quoting (GAP-04).", cls: "V" },
      { claim: "Exit comp — Corporate Creations at $142.9M",     finding: "Confirmed — Computershare acquired Corporate Creations for $142.9M (Feb 2020); ~$34.9M LTM rev → ~4.1×. Primary source.", cls: "V" },
      { claim: "Cap table & ownership — WY public record",       finding: "WY discloses no owners — only name, agent, address. The 9M/1M split and 30/20/20/20 ledger rest on draft articles + RSPA (GAP-07).", cls: "P" },
      { claim: "Entity of record — WY Secretary of State",       finding: "No 'Raisable Inc.' on the WY register at diligence — consistent with pre-incorporation (GAP-01).", cls: "P" },
      { claim: "Core IP — template library + fine-tuned models", finding: "IP asserted via work-for-hire assignments (internal). No registered US trademark/patent found — unregistered, self-attested.", cls: "P" },
      { claim: "Form D timing — after first sale",               finding: "Rule 503 confirmed: 15 days after first sale. Worksheet had it backwards; corrected (X-02).",                 cls: "V" },
      { claim: "Raisable Inc. — Wyoming C-Corp",                  finding: "Does not exist yet. Articles drafted to filing standard (DOC-002); nothing filed.",        cls: "P" },
      { claim: "4 founders · product in development",            finding: "Onboarding-stated. No employees, no payroll, no entity to employ them.",                       cls: "P" },
      { claim: "TX & Texture alliance · SPCP · tZero",  finding: "At signature (DOC-012): TX 5–10% founding tier contingent on cap intro (CoreNest) + Texture as BD; TX provides tokenization. Not executed; SPCP / tZero backup.", cls: "P" },
      { claim: "Dual-class cap structure — 9M Class A + 1M Class B", finding: "Draft articles and ledger consistent (30/20/20/20, unvested per RSPA). Struck vesting clauses pending CLO removal.", cls: "P" },
      { claim: "$2.7M on a YC SAFE at $16M cap (~16.9%)",        finding: "Issuer-configured; SAFE drafted (DOC-003). No entity exists to issue it.",                   cls: "P" },
      { claim: "GM ~80% · CAC $500–800 · LTV/CAC 17–28×",        finding: "Model targets (DOC-010) — zero operating data; Series A gates on proving them.",                        cls: "H" },
      { claim: "$3–5B problem pool · $400–600M revenue TAM",     finding: "Method stated (filings × cost) but no named source (GAP-04).",                                       cls: "A" },
    ],
    contradictions: [
      { id: "X-01", a: "DOC-001 hub: 'Live, agent-driven product'", b: "Onboarding: product in development · 0 customers", conflict: "'Live' reads as in-production; reality is demo-stage", sev: "high",
        fix: "Reconcile to 'working agent demo' until a first issuer runs end-to-end." },
      { id: "X-02", a: "DOC-006 worksheet: 'Form D due before first sale'", b: "Rule 503: Form D due within 15 days AFTER first sale", conflict: "Worksheet draft has the filing trigger backwards", sev: "med",
        fix: "Corrected here; fix the worksheet before counsel." },
      { id: "X-03", a: "Settings: Reg CF campaign target Q4 2026", b: "Dependency chain: incorporation → CPA-reviewed inception statements → portal → Form C", conflict: "Four sequential gates against a one-quarter window", sev: "low",
        fix: "Schedule risk: any Jul 1 slip pushes the CF window into 2027." },
      { id: "X-04", a: "DOC-002 / DOC-011: Effective Date May 20, 2026", b: "Onboarding: not incorporated · target start Jul 1", conflict: "Draft corp docs carry a stale effective date", sev: "med",
        fix: "Refresh effective dates at filing; CLO to strip struck vesting/repurchase clauses." },
      { id: "X-05", a: "DOC-001 hub: $3.6–12K / yr (ARPA)", b: "DOC-013 brief: subscription tiers $199–499 / mo", conflict: "Resolved — not a conflict: ARPA vs base tiers", sev: "low",
        fix: "Resolved — hub figure is blended ARPA, brief lists base tiers. Label each consistently." },
      { id: "X-06", a: "DOC-013 brief: '100k+ Reg D filings per year'", b: "DOC-001 hub canon: ~75K filings · ~35K new — 'don't quote 100k+'", conflict: "The brief uses the exact figure the hub bans", sev: "low",
        fix: "Align the brief to the ~75K / ~35K framing before the CoreNest call." },
    ],
    gaps: [
      { id: "GAP-01", gap: "Incorporation",                       affects: "company.* — everything gates on it", today: "Articles drafted (DOC-002), unfiled; no entity.", closes: "File WY articles (Jul 1), dates refreshed (X-04) — unlocks EIN, bank, SAFE, filings.", due: "Jul 1, 2026", sev: "high" },
      { id: "GAP-02", gap: "EIN + bank / escrow account",         affects: "fin.* · SAFE closing mechanics",     today: "No EIN, no account — checks can't clear.", closes: "SS-4 post-incorporation; account on the EIN.", due: "mid-Jul 2026", sev: "high" },
      { id: "GAP-03", gap: "Alliance execution",                  affects: "rd.broker (P · conf 65)",            today: "Alliance at signature — docs circulating, not countersigned (DOC-012).", closes: "Execute definitive docs — Texture as BD, TX vesting starts; SPCP / tZero backup.", due: "before launch", sev: "high" },
      { id: "GAP-04", gap: "Market-sizing citations",             affects: "mkt.* — 3 facts (A)",                today: "Pool/TAM/SAM cite no source; SEC's 55,162 (2024) anchors below the hub's ~75K.", closes: "Re-derive from SEC DERA; retire the ~75K figure.", due: "before PPM final", sev: "med" },
      { id: "GAP-05", gap: "Anchor commitment",                   affects: "DEMAND — $0 committed",              today: "Opens cold; no lead to anchor the SAFE.", closes: "1–2 anchor checks ($250K+) before solicitation.", due: "before launch", sev: "high" },
      { id: "GAP-06", gap: "Portal + verification provider",      affects: "cf.portal · rd.verification",        today: "No portal selected; no 506(c) verifier contracted.", closes: "Contract both — portal gates Form C, verifier gates any Reg D sale.", due: "Aug 2026", sev: "med" },
      { id: "GAP-07", gap: "Dilution stack model",                 affects: "rd.dilution · alliance.tx_equity · company.founder_split", today: "SAFE ~16.9% + TX 5–10% + 10% Class B stated, never compounded.", closes: "One pro-forma cap table across all three before the TX session.", due: "before TX session", sev: "med" },
    ],
    readiness: [
      { path: "Reg D 506(c) — Seed · $2.0M", verdict: "blocked on incorporation", note: "Drafts are staged; nothing can launch until the entity exists and one broker contract is signed.",
        items: [
          { what: "Data-room drafts staged (plan · SAFE · PPM · worksheet)", ok: true,  note: "DOC-001 · DOC-003 · DOC-005 · DOC-006" },
          { what: "Entity incorporated",                                     ok: false, note: "GAP-01 · target Jul 1" },
          { what: "EIN + bank account",                                      ok: false, note: "GAP-02 · after incorporation" },
          { what: "Alliance definitive docs executed",                       ok: false, note: "GAP-03 · at signature" },
          { what: "Accreditation verification provider",                     ok: false, note: "GAP-06 · provider TBD" },
          { what: "Anchor demand secured",                                   ok: false, note: "GAP-05 · $0 committed" },
        ] },
      { path: "Reg CF — Community · $700K", verdict: "sequenced behind Reg D", note: "Four gates stack ahead of the Form C: entity → reviewed inception statements → portal → filing. Window: Q4 2026, at risk (X-03).",
        items: [
          { what: "Form C outline drafted",                                  ok: true,  note: "DOC-007" },
          { what: "Perks schedule drafted",                                  ok: true,  note: "DOC-008 · portal review later" },
          { what: "Entity + CPA-reviewed inception statements",              ok: false, note: "GAP-01 · GAP-02" },
          { what: "Funding portal selected",                                 ok: false, note: "GAP-06" },
          { what: "Form C filed with the SEC",                               ok: false, note: "target Sep 2026" },
        ] },
    ],
    actions: [
      { n: 1, action: "File the drafted WY articles on Jul 1 (effective dates refreshed); EIN and bank within two weeks", rationale: "Everything downstream of the entity existing (GAP-01/02 · X-04).", pri: "P0", impact: "Critical" },
      { n: 2, action: "Execute the TX & Texture alliance definitive documents", rationale: "At signature ≠ signed — BD, cap intro and tokenization rail all hang on it (GAP-03).", pri: "P0", impact: "Critical" },
      { n: 3, action: "Reconcile the 'live product' language to demo-stage reality", rationale: "Diligence will test the claim; hub canon requires honesty on status (X-01).", pri: "P1", impact: "High" },
      { n: 4, action: "Secure 1–2 anchor commitments before solicitation opens", rationale: "A cold $2.7M ask needs a lead; CoreNest (via TX) is the live candidate (GAP-05).", pri: "P1", impact: "High" },
      { n: 5, action: "Model the full dilution stack before the TX principal-level session", rationale: "Three dilution layers stated separately, never compounded (GAP-07).", pri: "P1", impact: "High" },
      { n: 6, action: "Select and contract the portal + verification provider", rationale: "The portal gates the Form C; the verifier gates any 506(c) sale (GAP-06).", pri: "P2", impact: "Med" },
      { n: 7, action: "Label pricing figures as ARPA vs base tier everywhere; align the filing-volume figure", rationale: "Label ARPA vs tiers consistently; brief still quotes the banned 100k+ stat (X-06).", pri: "P2", impact: "Med" },
    ],
    capital: {
      note: "One YC SAFE ($16M cap, ~16.9% dilution) split $2.0M Reg D 506(c) + $700K Reg CF. No token at issuance; TX provides the tokenization rail as post-raise optionality.",
      paths: [
        { id: "OFF-RD-2026", name: "Reg D 506(c) — the anchor · $2.0M", role: "institutional capital", points: [
          "$16M-cap YC SAFE — standard paper, no priced round before Series A.",
          "506(c): general solicitation; every check accreditation-verified (provider TBD).",
          "$0 committed; anchor-first launch (GAP-05).",
        ] },
        { id: "OFF-CF-2026", name: "Reg CF — the community · $700K", role: "customers as holders", points: [
          "Same SAFE via funding portal — one cap-table entry.",
          "Open to everyone; Reg CF investment limits protect retail.",
          "Sequenced behind incorporation + CPA-reviewed statements + portal (X-03).",
        ] },
      ],
      steps: [
        { n: "T0", title: "Drafts staged · Jun 2026",   body: "Plan, SAFE, PPM, worksheets, Form C outline — all drafts. Nothing filed or signed; $0 committed.", pills: ["DOC-001", "GAP-03"] },
        { n: "T1", title: "Incorporate · Jul 1",        body: "Articles filed → EIN → bank/escrow. SAFE becomes issuable; statements begin.", pills: ["GAP-01", "GAP-02"] },
        { n: "T2", title: "Rails signed · Aug 2026",    body: "Alliance docs executed — Texture as BD, TX vests on cap intro; portal + verifier contracted.", pills: ["GAP-03", "GAP-06"] },
        { n: "T3", title: "Launch · Sep 2026 (target)", body: "506(c) opens — anchored if GAP-05 closes; Form C files on statement review.", pills: ["GAP-05"] },
        { n: "T4", title: "First close · Q4 2026",      body: "Form D ≤15 days after first sale (Rule 503); blue-sky follows; CF into Q1 2027 if needed.", pills: ["X-02", "X-03"] },
      ],
      discipline: "Once live, keep 506(c) and CF materials segregated — portal-only for Reg CF, accredited-targeted for Reg D — so the offerings don't integrate.",
    },
  };

  // ── RISK REGISTER — the downside, categorized & rated ──────────────
  DOSSIER.risks = [
    { id: "RK-01", cat: "Existential", title: "The raise is the runway", sev: "high",
      desc: "$0 cash, founder-funded only — a failed close is a shutdown scenario, not a down round.",
      mitig: "Anchor-first launch (GAP-05); hold burn near $0 until the entity and one rail are live." },
    { id: "RK-02", cat: "Execution", title: "Everything gates on Jul 1 incorporation", sev: "high",
      desc: "No entity, EIN, bank or issuable SAFE until the WY articles file — every downstream date moves with it.",
      mitig: "File on the target date with refreshed effective dates (X-04); EIN + bank within two weeks (GAP-02)." },
    { id: "RK-03", cat: "Counterparty", title: "Alliance at signature, not signed", sev: "high",
      desc: "TX's 5–10% founding tier, Texture as BD of record, and the tokenization rail all hang on an unexecuted countersignature.",
      mitig: "Execute the definitive documents before launch (GAP-03); SPCP / tZero stay as backup rails." },
    { id: "RK-04", cat: "Regulatory", title: "Concurrent-offering integration", sev: "med",
      desc: "506(c) general solicitation running alongside portal-only Reg CF — comms that cross could integrate the two offerings.",
      mitig: "Segregate materials once live: portal-only for CF, accredited-targeted for Reg D." },
    { id: "RK-05", cat: "Dilution", title: "Unmodeled dilution stack", sev: "med",
      desc: "SAFE ~16.9% + TX 5–10% founding tier + 10% Class B pool compound before any priced round.",
      mitig: "One pro-forma cap table across all three layers before the TX principal session (GAP-07)." },
    { id: "RK-06", cat: "Narrative", title: "'Live product' overstatement", sev: "med",
      desc: "Hub language reads as in-production; reality is demo-stage with 0 customers — diligence will test it.",
      mitig: "Reconcile to 'working agent demo' across all investor materials (X-01)." },
    { id: "RK-07", cat: "Schedule", title: "Reg CF window compression", sev: "low",
      desc: "Four sequential gates (entity → reviewed statements → portal → Form C) against a one-quarter window.",
      mitig: "Treat Q4 2026 as soft; any Jul 1 slip pushes the CF window into 2027 (X-03)." },
  ];

  // ── LEGAL FRAMEWORK — one instrument under two exemptions ──────────
  DOSSIER.legal = {
    note: "One YC SAFE under two exemptions. Each path has its own audience, comms and filing rules; the discipline is keeping them from integrating.",
    exemptions: [
      { id: "EX-506c", reg: "Reg D · Rule 506(c)", offering: "Seed · $2.0M",
        audience: "Accredited investors only — no investor cap.",
        solicitation: "General solicitation permitted.",
        verification: "Reasonable-steps accreditation verification required before any sale (provider TBD).",
        filing: "Form D within 15 days AFTER first sale (Rule 503).",
        bluesky: "State notice filings per state of first sale." },
      { id: "EX-cf", reg: "Reg CF · Section 4(a)(6)", offering: "Community · $700K",
        audience: "Anyone — retail + accredited, subject to Reg CF investment limits.",
        solicitation: "Portal-only communications; 'testing the waters' permitted before filing.",
        verification: "Handled by the registered funding portal (not yet selected).",
        filing: "Form C filed with the SEC before the campaign opens — needs CPA-reviewed inception statements.",
        bluesky: "Federal preemption — no state blue-sky filings." },
    ],
    instrument: [
      ["Instrument", "YC post-money SAFE — one paper, both paths"],
      ["Conversion", "Next priced round — targeted Series A"],
      ["Discount / MFN", "Cap-only on the draft; per executed SAFE (DOC-003)"],
      ["Transfer", "Restricted; no secondary venue at issuance"],
    ],
    discipline: DOSSIER.capital.discipline,
  };

  // ── ONTOLOGY OBJECT GRAPH — the deal architecture as an instance of the
  // INTELLIGENCE ontology (window.ONTOLOGY · the Compass World Model). Every
  // node's `of` is a World-Model SUBJECT id — Company · Project · Offering ·
  // Security · Asset · Valuation · Holding · Document · Exemption ·
  // Jurisdiction · Chain · Broker-Dealer · Party — wired with the model's own
  // edges (runs · raises capital via · sells · wraps · deployed on · owned by ·
  // offered under …). All 13 subjects of the World Model are instantiated.
  //
  // It deliberately EXCLUDES C2-ontology objects — RouteRecommendation
  // (ENT-route), AcceptanceReview (ENT-acceptance), FitScore — which are
  // command-plane decision / loop concepts in window.FOUNDATION, NOT deal
  // objects. The two ontologies are distinct; keep C2 objects out of here.
  function graph() {
    const nodes = [
      // ── issuer · venture (the deal spine) ──
      { id: "CO-raisable",   of: "Company",       name: "Raisable Inc. (pre-inc.)", kicker: "issuer — incorporates Jul 1" },
      { id: "PRJ-raisable",  of: "Project",       name: "Raisable Investment",      kicker: "the venture being financed" },
      // ── offerings ──
      { id: "OFF-RD-2026",   of: "Offering",      name: "Reg D 506(c) · $2.0M",     kicker: "general solicitation · verified only" },
      { id: "OFF-CF-2026",   of: "Offering",      name: "Reg CF · $700K",           kicker: "community round · sequenced" },
      // ── security · asset · valuation · cap table · provenance ──
      { id: "SEC-safe",      of: "Security",      name: "YC post-money SAFE",       kicker: "token-optional · $16M cap" },
      { id: "ASSET-equity",  of: "Asset",         name: "Raisable equity",          kicker: "company-equity class" },
      { id: "VAL-cap",       of: "Valuation",     name: "$16M post-money cap",      kicker: "valuation cap · ~16.9% dilution" },
      { id: "HLD-founders",  of: "Holding",       name: "Founder cap table",        kicker: "Class A 30/20/20/20 · all unvested" },
      { id: "DOC-room",      of: "Document",      name: "Data room (drafts)",       kicker: "plan · SAFE · PPM · worksheets" },
      // ── chain (the deferred token deployment target) ──
      { id: "CHAIN-target",  of: "Chain",         name: "Base",                     kicker: "Coinbase L2 · token deployment target" },
      // ── exemption (reified legal-basis) · jurisdiction ──
      { id: "EX-506c",       of: "Exemption",     name: "Reg D 506(c)",             kicker: "general solicitation · verified only" },
      { id: "EX-cf",         of: "Exemption",     name: "Reg CF",                   kicker: "$5M/12mo · portal-only comms" },
      { id: "JUR-us",        of: "Jurisdiction",  name: "United States",            kicker: "SEC + FINRA · WY at filing" },
      // ── distribution rails (broker-dealer entity) ──
      { id: "BRK-texture",   of: "Broker-Dealer", name: "Texture Capital",          kicker: "alliance BD of record · at signature" },
      { id: "BRK-spcp",      of: "Broker-Dealer", name: "Silicon Prairie CP",       kicker: "backup rail · conversation" },
      { id: "BRK-tzero",     of: "Broker-Dealer", name: "tZero",                    kicker: "backup rail · conversation" },
      { id: "BRK-portal",    of: "Broker-Dealer", name: "Funding portal (TBD)",     kicker: "Reg CF rail · not selected" },
      // ── parties (capital intro · channel · holders) ──
      { id: "PTY-tx",        of: "Party",         name: "TX (alliance)",            kicker: "cap intro + tokenization · at signature" },
      { id: "PTY-corenest",  of: "Party",         name: "CoreNest Capital",         kicker: "capital intro · anchor candidate" },
      { id: "PTY-cbs",       of: "Party",         name: "CBS providers",            kicker: "issuer channel · 2 partnerships targeted" },
      { id: "PTY-founders",  of: "Party",         name: "Founders (4)",             kicker: "Class A holders · per draft ledger" },
    ];
    const edges = [
      // ── deal spine: Company → Project → Offering → Security → Asset → Company ──
      ["CO-raisable",  "PRJ-raisable", "runs"],
      ["PRJ-raisable", "OFF-RD-2026",  "raises capital via"],
      ["PRJ-raisable", "OFF-CF-2026",  "raises capital via"],
      ["OFF-RD-2026",  "SEC-safe",     "sells"],
      ["OFF-CF-2026",  "SEC-safe",     "sells"],
      ["SEC-safe",     "ASSET-equity", "wraps"],
      ["SEC-safe",     "CHAIN-target", "deployed on"],
      ["ASSET-equity", "CO-raisable",  "owned by"],
      ["ASSET-equity", "PRJ-raisable", "developed under"],
      // ── exemption (reified) · jurisdiction ──
      ["OFF-RD-2026",  "EX-506c",      "offered under"],
      ["OFF-CF-2026",  "EX-cf",        "offered under"],
      ["EX-506c",      "JUR-us",       "scoped to"],
      ["EX-cf",        "JUR-us",       "scoped to"],
      ["CO-raisable",  "JUR-us",       "incorporated in"],
      ["ASSET-equity", "JUR-us",       "located in"],
      // ── valuation · cap table · provenance ──
      ["VAL-cap",      "ASSET-equity", "appraises"],
      ["HLD-founders", "CO-raisable",  "position in"],
      ["PTY-founders", "HLD-founders", "holds"],
      ["DOC-room",     "CO-raisable",  "evidences"],
      ["DOC-room",     "OFF-RD-2026",  "evidences"],
      // ── distribution rails (broker-dealer) ──
      ["OFF-RD-2026",  "BRK-texture",  "distributed via"],
      ["OFF-RD-2026",  "BRK-spcp",     "distributed via"],
      ["OFF-RD-2026",  "BRK-tzero",    "distributed via"],
      ["OFF-CF-2026",  "BRK-portal",   "distributed via"],
      ["BRK-texture",  "EX-506c",      "clears"],
      // ── parties: capital intro · channel · tokenization ──
      ["PTY-tx",       "CO-raisable",  "founding partner"],
      ["PTY-tx",       "BRK-texture",  "alliance BD agreement"],
      ["PTY-tx",       "PTY-corenest", "capital intro via"],
      ["PTY-tx",       "SEC-safe",     "tokenization provider"],
      ["PTY-corenest", "OFF-RD-2026",  "anchor candidate"],
      ["PTY-cbs",      "CO-raisable",  "issuer channel"],
    ].map(([from, to, label]) => ({ from, to, label }));
    return { nodes, edges };
  }

  function validate() {
    const { nodes, edges } = graph();
    const ids = new Set(nodes.map((n) => n.id));
    const issues = [];
    edges.forEach((e) => { if (!ids.has(e.from)) issues.push(e.from); if (!ids.has(e.to)) issues.push(e.to); });
    const S = window.ONTOLOGY;
    nodes.forEach((n) => { if (S && !S.SUBJECTS.some((s) => s.id === n.of)) issues.push(n.id + " of " + n.of); });
    const adj = {};
    nodes.forEach((n) => { adj[n.id] = []; });
    edges.forEach((e) => { if (adj[e.from] && adj[e.to]) { adj[e.from].push(e.to); adj[e.to].push(e.from); } });
    const seen = new Set(["CO-raisable"]); const q = ["CO-raisable"];
    while (q.length) { const cur = q.shift(); (adj[cur] || []).forEach((nx) => { if (!seen.has(nx)) { seen.add(nx); q.push(nx); } }); }
    const unreachable = nodes.filter((n) => !seen.has(n.id)).map((n) => n.id);
    return { ok: issues.length === 0 && unreachable.length === 0, issues, unreachable, classes: [...new Set(nodes.map((n) => n.of))].length, objects: nodes.length, links: edges.length };
  }

  window.RAISABLE = { SRC, KB, CLASS, classCounts, confTone, CAPTABLE, OFFERINGS, DEMAND, FINANCIALS, USE_OF_PROCEEDS, FILINGS, DOSSIER, graph, validate,
    SEPARATION: {
      business:   { name: "Raisable Business",   note: "The operating company — FinOps twin, C&C plane, agents. Financial intelligence & proceeds live under Control · Execution.", route: "execution" },
      investment: { name: "Raisable Investment", note: "Raisable as an ISSUER on its own platform. Offerings under Operations · Projects; objects under Ontology; this dossier reads them for investors.", route: "analytics" },
    },
  };
})();
