/* ============================================================
   Fynch AI — walkthrough.jsx  (slides 20–28)  — v2
   One deal (Harborview) through the platform. Product screens
   are labeled drop-slots for the user's real screenshots.
   ============================================================ */
(function () {
  const HV = { name: "Harborview Apartments", units: 184 };

  /* ---- Slide 20 — deal journey grid (fills the screen) ---- */
  const JOURNEY = [
    ["Intake", "Broker email, rent roll, T12 & sponsor docs arrive in one pipeline", "23"],
    ["Package", "Checklist scores completeness for this stage of the deal", "22"],
    ["Extraction", "PDFs & spreadsheets parsed into ~150 CRE facts", "24"],
    ["Evidence", "Every fact linked to a page, cell, or computed metric", "26"],
    ["Review", "Conflicts & low-confidence values routed to underwriters", "27"],
    ["Policy", "DSCR, LTV, debt yield & credit policy run from facts", "28"],
    ["Quote", "Sizing & terms checked against eligibility", "28"],
    ["Memo", "Screening & credit memos generated from approved facts", "28"],
    ["Audit", "Full lineage — who changed what, and what depends on it", "28"],
  ];
  function Journey() {
    return (
      <div className="slide-pad">
        <Reveal variant="up"><div className="eyebrow-row" style={{ marginBottom: 10 }}><Kicker>Walkthrough</Kicker></div></Reveal>
        <Reveal variant="up" delay={60} style={{ display: "flex", alignItems: "baseline", gap: 18, marginBottom: 8 }}>
          <h2 className="slide-h2">One deal through the platform.</h2>
        </Reveal>
        <Reveal variant="up" delay={120} as="p" className="lead" style={{ marginBottom: 22, fontSize: 23 }}>
          {HV.name} — {HV.units}-unit multifamily acquisition. Watch it transform from raw documents into a defensible, evidence-backed file.
        </Reveal>
        <Reveal variant="fade" delay={180} className="grow" style={{ minHeight: 0 }}><DealJourney /></Reveal>
        <Foot no={20} section="Walkthrough" />
      </div>
    );
  }

  /* ---- persistent journey bar (walkthrough 21–28) ---- */
  const WALK_STEPS = ["Workspace", "Package", "Intake", "Parsing", "Fact base", "Evidence", "Review", "Outputs"];
  function JourneyBar({ step }) {
    return (
      <div className="walkbar">
        {WALK_STEPS.map((s, i) => (
          <React.Fragment key={s}>
            {i > 0 && <span className="walkbar-sep"></span>}
            <span className={"walkbar-step" + (i === step ? " active" : "") + (i < step ? " done" : "")}>{s}</span>
          </React.Fragment>
        ))}
      </div>
    );
  }

  /* ---- generic product-screen slide (drop-slot) ---- */
  function ScreenSlide({ no, kicker, title, solves, status, statusLabel, label, tab, note }) {
    return (
      <div className="slide-pad">
        <SolvesTag solves={solves} status={status} statusLabel={statusLabel} />
        <Reveal variant="fade"><JourneyBar step={no - 21} /></Reveal>
        <Reveal variant="up" delay={80} style={{ maxWidth: 1160, margin: "16px 0 18px" }}><Kicker>{kicker}</Kicker><h1 className="slide-title" style={{ fontSize: 38, marginTop: 8 }}>{title}</h1></Reveal>
        <div className="grow" style={{ minHeight: 0 }}><ScreenSlot label={label} tab={tab} note={note} /></div>
        <Foot no={no} section="Walkthrough" />
      </div>
    );
  }

  window.registerSlides([
    { no: 20, section: "Walkthrough", Comp: Journey },
    { no: 21, section: "Walkthrough", Comp: () => <ScreenSlide no={21} kicker="Deal workspace" title="The property becomes the system of record." solves="Workflow fragmentation" status="live" label="Deal Workspace — full record" tab="Documents · facts · borrower · external data · review · quotes · outputs · audit" note="Drop the workspace with all tabs visible — one property record replacing inbox + folders + spreadsheets + memos." /> },
    { no: 22, section: "Walkthrough", Comp: () => <ScreenSlide no={22} kicker="Deal package" title="The checklist knows what underwriting requires." solves="Package completeness · quote readiness" status="live" label="Deal Package — completeness checklist" tab="Rent roll · T12 · appraisal · sponsor · S&U · third-party · environmental · PCA · title" note="Drop the checklist with status pills — show one Blocking item (Phase I) and one Weak item." /> },
    { no: 23, section: "Walkthrough", Comp: () => <ScreenSlide no={23} kicker="Document & email intake" title="Every deal material enters one pipeline." solves="Intake fragmentation · revised materials" status="live" label="Company Inbox → document pipeline" tab="Validate sender · capture attachments · classify · link to deal · route for review" note="Drop the intake flow: a broker email with a revised rent roll flowing into the workspace as controlled inputs." /> },
    { no: 24, section: "Walkthrough", Comp: () => <ScreenSlide no={24} kicker="Parsing" title="PDFs & spreadsheets become structured CRE facts." solves="Manual spreading · data entry" status="live" label="Parsing — document → structured fields" tab="Rent roll & T12 → units, occupancy, rent, NOI, expenses, cap rate" note="Drop the parsing view: a source spreadsheet/PDF on one side, extracted fields with confidence on the other." /> },
    { no: 25, section: "Walkthrough", Comp: () => <ScreenSlide no={25} kicker="Fact base" title="The core asset is the CRE data model." solves="Reusable underwriting data" status="live" label="Fact Base — ~150-field CRE schema" tab="Property · Financials · Borrower/Sponsor · Loan terms · Market · Risk · Diligence" note="Drop the schema view grouped by domain — documents are temporary, the fact base is the reusable asset." /> },
    { no: 26, section: "Walkthrough", Comp: () => <ScreenSlide no={26} kicker="Knowledge base" title="Inspect the deal by field." solves="Evidence risk · review confidence" status="live" label="Knowledge Base — field-level evidence browser" tab="Fact list ↔ source preview with highlighted page / cell" note="Drop the evidence browser: pick a fact, see the exact source that supports it. 'What supports NOI? What changed? Who approved it?'" /> },
    { no: 27, section: "Walkthrough", Comp: () => <ScreenSlide no={27} kicker="Review queues" title="Underwriters review exceptions, not whole files." solves="Human review · conflict resolution" status="live" label="Review Queue — exceptions by severity" tab="Blocking · Warning · Review · Informational — with owner, source & downstream impact" note="Drop the review queue sorted by severity. Theme: controlled exception handling." /> },
    { no: 28, section: "Walkthrough", Comp: () => <ScreenSlide no={28} kicker="Outputs" title="Approved facts feed policy, memos, Q&A & audit." solves="Quote readiness · memo prep · defensibility" status="config" statusLabel="Live + configurable" label="Outputs — policy, metrics, memo & audit" tab="DSCR / LTV / debt yield · screening & credit memos · audit timeline" note="Drop the outputs view: computed metrics vs. policy, generated memos, and the audit/lineage timeline." /> },
  ]);
})();
