Files

1046 lines
60 KiB
JavaScript

// /workspace/hyperstitionstudio-core/site/quant/quant-tutorials.js
// Option B Zero-MP4 Interactive HTML5 Canvas Tutorial Player, Spoken Voice Narration & Per-Scene UI Element Indicators (v2.11.0)
(function () {
"use strict";
const rootObj = typeof window !== "undefined" ? window : globalThis;
rootObj.HyperstitionStudio = rootObj.HyperstitionStudio || {};
const ALL_HIGHLIGHTABLE_DOM_IDS = [
"guildFilterPills",
"tickerQuickFilter",
"tickerSelect",
"openTradingViewBtn",
"lensSelect",
"metricModePills",
"timeWindowPills",
"activeDateBadge",
"tsCanvas",
"heatmapTable",
"heatmapPaginationBar",
"panel3TvBtn",
"dateMetricsGrid",
"lensProjectionCard",
"docReferencesCard",
"wireTapeFilterInput",
"wireEqTape",
"lagBarsContainer",
"exportCsvBtn",
"exportJsonBtn",
"periodicityAuditFooter",
"macroIndicatorsPanel",
"dailyBriefPanel"
];
const EPISODES = [
{
id: "ep01",
code: "Ep 01",
title: "The Strict Periodicity Gate & Watchlist Topology",
keyframes: [
{
title: "1.1 Strict Periodicity Gate (21:30 UTC Close x 00:00 UTC Wire)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.89, yRatio: 0.22, label: "Strict Periodicity Gate: 19 Real US Equity Sessions in Nov 2026" },
uiTargets: ["timeWindowPills", "activeDateBadge", "tsCanvas"],
uiElementLabel: "Temporal Window Pills (#timeWindowPills) & Active Date Badge (#activeDateBadge)",
subtitle: "Only real periodic timestamp-indexed observations (21:30 UTC US Closing-Bell bars and 00:00 UTC dated news dossiers) enter this workbench. Closed weekend/holiday dates explicitly report 'No data available'.",
speechText: "Scene 1.1. Inspecting the Temporal Window pills and Active Date badge in the top toolbar alongside Panel 1. Only real periodic timestamp-indexed observations, twenty-one thirty UTC US closing-bell bars and midnight UTC dated news dossiers, enter this workbench. Closed weekend and holiday dates explicitly report No data available.",
citations: [
{ label: "Vol 08A PDF (Room Filter)", href: "/encyclopedia/08-stakeholder-registers-idioms-and-pokedex-semiotics/a-to-h-ai-powered-race-to-hidden-chokepoint-screen.pdf#page=2&search=Room%20Filter" },
{ label: "Archive Methodology", href: "/archive/00-index-and-methodology.md#:~:text=closing-bell" },
{ label: "Graph Hub aq:137", href: "/graph/index.html?select=aq:137" }
]
},
{
title: "1.2 Guild S1 — Autoregressive AI Syndicate (Coordinate 292)",
state: { guildFilter: "S1", selectedSymbol: "MSFT", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 24 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.83, yRatio: 0.28, label: "S1 AI Guild Filter Active (MSFT 2026-11-25 Close $489.93)" },
uiTargets: ["guildFilterPills", "tickerSelect"],
uiElementLabel: "Guild Filter Pills (#guildFilterPills -> S1) & Ticker Select (#tickerSelect)",
subtitle: "Filtering by Guild S1 isolates the Autoregressive AI Syndicate anchored on Coordinate 292 (shizohnalizis == abstrakt masheen == sinthetik dayta == asset management [Gen 0]).",
speechText: "Scene 1.2. Highlighting the Guild Filter pills and Ticker selector in the toolbar. Filtering by Guild S1 isolates the Autoregressive AI Syndicate anchored on Coordinate 292, where schizoanalysis, abstract machine, and synthetic data all converge in phonemic Ingglish.",
citations: [
{ label: "Vol 03A PDF (S1 AI)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s1-autoregressive-ai-and-abstract-machine-a-to-z.pdf#page=1&search=292" },
{ label: "Dossier 65 (292 Lock)", href: "/zoology/dossiers/65-dossier-technocapital-singularity-autoregressive-ai.md#:~:text=292" },
{ label: "Graph Build S1", href: "/graph/index.html?select=build:S1" }
]
},
{
title: "1.3 Guild S3 — Silicon-Photonic War Machine (137 & 81)",
state: { guildFilter: "S3", selectedSymbol: "ASML", selectedLens: "corporate_board", metricMode: "close_usd", selectedDateIdx: 26 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.89, yRatio: 0.30, label: "S3 Isometric Chokepoint: ASML = asml = 81 (Δ = 0)" },
uiTargets: ["guildFilterPills", "tickerQuickFilter", "tickerSelect"],
uiElementLabel: "Guild Filter (#guildFilterPills -> S3) & Ticker Quick-Filter (#tickerQuickFilter)",
subtitle: "Guild S3 maps physical wafer and EUV lithography chokepoints: ASML (81, Δ = 0 isometric), TSMC (95, Δ = 0), and Nvidia (envideea = 137 [33rd Prime]).",
speechText: "Scene 1.3. Highlighting Guild Filter S3 and the Ticker Quick-Filter input in the toolbar. Guild S3 maps physical wafer and extreme ultraviolet lithography chokepoints: ASML at coordinate 81 with zero phonemic drift, TSMC at 95, and Nvidia at 137, the thirty-third prime.",
citations: [
{ label: "Vol 03C PDF (p.5 ASML/envideea)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=5&search=envideea" },
{ label: "Dossier 67 (Silicon War Machine)", href: "/zoology/dossiers/67-dossier-technocapital-singularity-silicon-war-machine.md#:~:text=137" },
{ label: "Graph Hub aq:81", href: "/graph/index.html?select=aq:81" }
]
},
{
title: "1.4 Guild S6 — Apparatus of Capture (Coordinate 125)",
state: { guildFilter: "S6", selectedSymbol: "BLK", selectedLens: "corporate_board", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.86, yRatio: 0.26, label: "S6 Capture Ring: kapatal == kapcher == fohldz = 125" },
uiTargets: ["guildFilterPills", "tickerSelect"],
uiElementLabel: "Guild Filter Pills (#guildFilterPills -> S6) & Ticker Select (#tickerSelect -> BLK)",
subtitle: "Guild S6 tracks sovereign and balance-sheet capture around Coordinate 125 (kapatal == kapcher == fohldz = 125) and charter/sloth (136).",
speechText: "Scene 1.4. Highlighting Guild Filter S6 and the Ticker dropdown list selected to BlackRock. Guild S6 tracks sovereign and balance-sheet capture around Coordinate 125, where capital, capture, and folds all evaluate to 125.",
citations: [
{ label: "Vol 04A PDF (S6 Capture)", href: "/encyclopedia/04-capital-organizational-capture-s6/a-to-f-acquisition-to-fund.pdf#page=1&search=125" },
{ label: "Dossier 68 (Capture)", href: "/zoology/dossiers/68-dossier-technocapital-singularity-apparatus-of-capture.md#:~:text=125" },
{ label: "Graph Hub aq:125", href: "/graph/index.html?select=aq:125" }
]
},
{
title: "1.5 Periodicity Audit Footer & IPLD dag-json CIDv1",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "panel4", xRatio: 0.50, yRatio: 0.85, label: "Cryptographic CIDv1 & Periodicity Audit Footer" },
uiTargets: ["periodicityAuditFooter"],
uiElementLabel: "Periodicity Audit & CIDv1 Footer (#periodicityAuditFooter)",
subtitle: "The bottom footer verifies 21 dated 00:00 UTC dossiers + real exchange closing-bell bars (missing/closed days = null / No data available), and the deterministic IPLD dag-json CIDv1 digest.",
speechText: "Scene 1.5. Inspecting the Periodicity Audit footer at the bottom of Panel 4. This footer verifies the dated midnight UTC dossiers, real exchange closing-bell bars, and the deterministic IPLD dag-json CIDv1 content identifier.",
citations: [
{ label: "Static Bundle quant-timeseries.json", href: "/quant/quant-timeseries.json" },
{ label: "REST API /api/v1/quant/timeseries", href: "/api/v1/quant/timeseries?symbol=NVDA" },
{ label: "Schema quant-timeseries.schema.json", href: "/schemas/v1/quant-timeseries.schema.json" }
]
}
]
},
{
id: "ep02",
code: "Ep 02",
title: "Reading Panel 1: Spoken AQ Curves, Gold/Cyan Beacons & Regimes",
keyframes: [
{
title: "2.1 Top Pane: Dashed Crimson Identity Line & Real Scope 1 Self-Lock (PLTR)",
state: { guildFilter: "ALL", selectedSymbol: "PLTR", selectedLens: "fund_manager", metricMode: "close_usd", selectedDateIdx: 22 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.76, yRatio: 0.25, label: "Real Scope 1 Self-Lock: PLTR Close $159.36 (159 == palanter)" },
uiTargets: ["metricModePills", "tsCanvas"],
uiElementLabel: "Metric Mode Pills (#metricModePills -> Close Price USD) & Panel 1 Canvas (#tsCanvas)",
subtitle: "On 2026-11-23, Palantir (PLTR) closed at $159.36 on the exchange: its rounded integer price (159) lands directly on the dashed crimson threshold marking its own Gen 1 Ingglish name (palanter = 159), firing a real Scope 1 Gold Beacon.",
speechText: "Scene 2.1. Highlighting the Metric Mode pills in the toolbar and the Top Pane of the Panel 1 trajectory canvas. On November 23, 2026, Palantir closed at 159 dollars and 36 cents: its rounded integer price 159 lands directly on the dashed crimson threshold marking its own Ingglish name palanter equals 159, firing a real Scope 1 Gold Beacon.",
citations: [
{ label: "Vol 03C PDF (S3 War Machine)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=5&search=palanter" },
{ label: "Dossier 67 (Silicon War Machine)", href: "/zoology/dossiers/67-dossier-technocapital-singularity-silicon-war-machine.md#:~:text=137" },
{ label: "Graph Hub aq:159", href: "/graph/index.html?select=aq:159" }
]
},
{
title: "2.2 Move (BPS) Mode: TSMC (TSM) +81 bps Ring Migration & Microsoft -125 bps",
state: { guildFilter: "ALL", selectedSymbol: "TSM", selectedLens: "fund_manager", metricMode: "change_bps", selectedDateIdx: 17 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.59, yRatio: 0.24, label: "Real Exchange Move: TSM +81 bps on 2026-11-18 (Ring 81 == asml)" },
uiTargets: ["metricModePills", "tsCanvas"],
uiElementLabel: "Metric Mode Pills (#metricModePills -> Move BPS) & Panel 1 Canvas (#tsCanvas)",
subtitle: "Switching Metric Mode to Move (BPS) on 2026-11-18 shows TSMC (TSM) moving +81 bps ($359.70 -> $362.62), landing on the S3 lithography coordinate 81 (asml = 81).",
speechText: "Scene 2.2. Highlighting the Metric Mode pills switched to Move in Basis Points. On November 18, 2026, TSMC moved plus 81 basis points, landing directly on the S3 lithography coordinate 81, matching ASML equals 81.",
citations: [
{ label: "Vol 03C PDF (ASML = 81)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=1&search=ASML" },
{ label: "Graph Hub aq:81", href: "/graph/index.html?select=aq:81" }
]
},
{
title: "2.3 Real Repdigit Attractor Lock: Broadcom (AVGO) at $333.40 & NVDA Spoken 333",
state: { guildFilter: "ALL", selectedSymbol: "AVGO", selectedLens: "fund_manager", metricMode: "close_usd", selectedDateIdx: 15 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.52, yRatio: 0.20, label: "Real Exchange Repdigit Lock: AVGO $333.40 on 2026-11-16 (333 = 3 x 111)" },
uiTargets: ["tickerSelect", "metricModePills", "tsCanvas"],
uiElementLabel: "Ticker Select (#tickerSelect -> AVGO) & Panel 1 Top Pane (#tsCanvas)",
subtitle: "On 2026-11-16, Broadcom (AVGO) closed at $333.40 (rounded integer 333 = 3 x 111), and on 2026-11-03 Nvidia (NVDA) closed at $206.69 ('too huhndrad siks' = 333), firing real Scope 1 Repdigit Gold Beacons.",
speechText: "Scene 2.3. Inspecting Ticker Select set to Broadcom and the Panel 1 trajectory canvas. On November 16, 2026, Broadcom closed at 333 dollars and 40 cents, rounding to the repdigit attractor 333, while Nvidia closed at 206 dollars and 69 cents whose spoken Ingglish phrase two hundred six also sums to 333.",
citations: [
{ label: "Vol 03C PDF (S3 Guild)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=1&search=333" },
{ label: "Graph Hub aq:333", href: "/graph/index.html?select=aq:333" }
]
},
{
title: "2.4 Middle Pane: 00:00 GMT Wire Velocity & Emerald Scope 3 Bars",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 28 },
spotlight: { target: "canvas", pane: "mid", xRatio: 0.93, yRatio: 0.63, label: "Emerald Bar = Scope 3 News-Wire Co-Presence" },
uiTargets: ["tsCanvas", "activeDateBadge"],
uiElementLabel: "Panel 1 Middle Pane (#tsCanvas Wire Velocity) & Active Date Badge (#activeDateBadge)",
subtitle: "In the middle pane, Violet bars show daily 333/666/777 equation counts; Emerald bars highlight UTC dates where the selected ticker co-occurred in breaking 00:00 GMT news headlines.",
speechText: "Scene 2.4. Inspecting the Middle Pane of the Panel 1 canvas. Violet bars show daily 333, 666, and 777 equation counts, while Emerald bars highlight UTC dates where the selected ticker co-occurred in breaking midnight GMT news headlines.",
citations: [
{ label: "Dossier 71 (2026-11-29)", href: "/archive/71-dossier-news-2026-11-29.md#:~:text=333" },
{ label: "REST Highlight Preview", href: "/api/v1/dossiers/71?highlight=envideea" }
]
},
{
title: "2.5 Bottom Pane: 20-Day Volume Ratio & M1/M2/M3 Thermodynamic Regimes",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 25 },
spotlight: { target: "canvas", pane: "bot", xRatio: 0.83, yRatio: 0.86, label: "Thermodynamic Regime Color Coding (M1 Gold / M2 Crimson / M3 Sky)" },
uiTargets: ["tsCanvas"],
uiElementLabel: "Panel 1 Bottom Pane (#tsCanvas 20-Day Volume & M1/M2/M3 Regimes)",
subtitle: "The bottom pane color-codes 20d relative volume by objective thermodynamic state: Gold (<0.45x) = M1 Stagnation (137), Crimson (>=2.5x or <=-5%) = M2 Flash-Crash Surge (193), Sky-Blue = M3 Leviathan.",
speechText: "Scene 2.5. Inspecting the Bottom Pane of the Panel 1 canvas. Twenty-day relative volume bars are color-coded by thermodynamic regime: Gold for M1 Stagnation, Crimson for M2 Flash-Crash Surge, and Sky-Blue for M3 Leviathan.",
citations: [
{ label: "Vol 05A PDF (Subclass M1)", href: "/encyclopedia/05-memetic-superclass-and-emergent-m7/m1-vampiric-entropic-and-anti-productive-a-to-m.pdf#page=1&search=M1" },
{ label: "Vol 05C PDF (M2-M6)", href: "/encyclopedia/05-memetic-superclass-and-emergent-m7/m2-to-m6-kinetic-leviathan-mimetic-oracle-abyssal-a-to-z.pdf#page=1&search=M2" }
]
}
]
},
{
id: "ep03",
code: "Ep 03",
title: "Panels 2 & 3: The 24x30 Lock Heatmap, TradingView & Deep Citations",
keyframes: [
{
title: "3.1 Panel 2: 24x30 Heatmap & Explicit 'No Data Available' Handling (ANTHR-PVT & Weekends)",
state: { guildFilter: "ALL", selectedSymbol: "ANTHR-PVT", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 17 },
spotlight: { target: "panel2", xRatio: 0.50, yRatio: 0.40, label: "Zero Synthetic Data: ANTHR-PVT & Closed Market Days Show 'No data available'" },
uiTargets: ["heatmapTable", "dateMetricsGrid"],
uiElementLabel: "Panel 2 Spatiotemporal Lock Heatmap (#heatmapTable) & Panel 3 Metrics Grid (#dateMetricsGrid)",
subtitle: "This workbench never synthesizes or interpolates missing market data. Because Anthropic (ANTHR-PVT) is a private entity with no public exchange feed (and US stock markets close on weekends and Thanksgiving), those cells explicitly state 'No data available'.",
speechText: "Scene 3.1. Highlighting the Panel 2 Spatiotemporal Lock Heatmap table and the Panel 3 Date Metrics grid. This workbench never synthesizes or interpolates missing market data. Because Anthropic is a private entity with no public exchange feed, and US stock markets close on weekends and holidays, those cells explicitly report No data available.",
citations: [
{ label: "Vol 06A PDF (Anchor Revision)", href: "/encyclopedia/06-genealogical-vectors-and-quantitative-repricing/a-to-m-attractors-to-multi-build-flex-singularities.pdf#page=1&search=193" },
{ label: "Dossier 66 (193 Flash Crash)", href: "/zoology/dossiers/66-dossier-technocapital-singularity-flash-crash-liquidity.md#:~:text=193" },
{ label: "Graph Hub aq:193", href: "/graph/index.html?select=aq:193" }
]
},
{
title: "3.2 TradingView Superchart Launcher (Shortcut: T)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "panel3", xRatio: 0.85, yRatio: 0.12, label: "Open TradingView Chart ↗ (Zero External Script Embeds)" },
uiTargets: ["openTradingViewBtn", "panel3TvBtn"],
uiElementLabel: "Open TradingView Chart Buttons (#openTradingViewBtn & #panel3TvBtn)",
subtitle: "Every ticker resolves deterministically to EXCHANGE:SYMBOL (e.g. NASDAQ:NVDA, closing at $150.49 on 2026-11-27). Clicking 'TradingView ↗' or pressing 'T' opens the live Superchart in a new window while keeping 0 external scripts embedded.",
speechText: "Scene 3.2. Highlighting the Open TradingView Chart buttons in the toolbar and Panel 3 header. Every ticker resolves deterministically to its exchange and symbol, such as NASDAQ colon NVDA. Clicking TradingView or pressing key T opens the live Superchart in a new window while keeping zero external tracking scripts embedded.",
citations: [
{ label: "Launch TradingView (NASDAQ:NVDA)", href: "https://www.tradingview.com/chart/?symbol=NASDAQ%3ANVDA" },
{ label: "Operator's Manual (PDF)", href: "/quant/OPERATORS-MANUAL-QUANT-TIMESERIES-WORKBENCH.pdf#page=1&search=TradingView" }
]
},
{
title: "3.3 Panel 3: Knowledge-Graph-Modeled Documentation & Cited Passages Card",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 28 },
spotlight: { target: "docCard", xRatio: 0.50, yRatio: 0.50, label: "Passage-Encoded PDF (#page & search) + Dossier (#:~:text=) Links" },
uiTargets: ["docReferencesCard"],
uiElementLabel: "Panel 3 Documentation & Cited Passages Card (#docReferencesCard)",
subtitle: "Modeled directly on the Knowledge Graph's inspector drawer, the Documentation Card links every ticker to its exact Encyclopedia PDF page (#page=N&search=...), Dossier passage (#:~:text=...), and Graph node (?select=aq:N).",
speechText: "Scene 3.3. Highlighting the Documentation and Cited Passages card in Panel 3. Modeled directly on the Knowledge Graph inspector drawer, this card links every ticker to its exact Encyclopedia PDF page, Dossier scroll-to-text passage, and Knowledge Graph coordinate node.",
citations: [
{ label: "Vol 03C PDF (#page=5&search=envideea)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=5&search=envideea" },
{ label: "Graph Deep Link (?select=aq:137)", href: "/graph/index.html?select=aq:137" },
{ label: "REST API Highlight (/api/v1/dossiers/67?highlight=137)", href: "/api/v1/dossiers/67?highlight=137" }
]
},
{
title: "3.4 Panel 3: Verbatim Dated Memetic Equation Tape & Inline Passage Preview",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 28 },
spotlight: { target: "wireTape", xRatio: 0.50, yRatio: 0.50, label: "Dated 333 / 666 / 777 Equations with Scroll-to-Text Deep Links" },
uiTargets: ["wireTapeFilterInput", "wireEqTape"],
uiElementLabel: "Panel 3 Wire Equation Filter (#wireTapeFilterInput) & Equation Tape (#wireEqTape)",
subtitle: "Every equation in the Dated Wire Tape includes a WICG scroll-to-text link (#:~:text=...), a Knowledge Graph coordinate link, and an inline REST passage preview button.",
speechText: "Scene 3.4. Highlighting the Wire Equation filter input and Dated Equation Tape in Panel 3. Every equation in the tape includes a scroll-to-text deep link, a Knowledge Graph coordinate link, and an inline REST passage preview button.",
citations: [
{ label: "Dossier 71 Scroll-to-Text", href: "/archive/71-dossier-news-2026-11-29.md#:~:text=333" },
{ label: "REST Dossier 71 JSON", href: "/api/v1/dossiers/71?highlight=333" }
]
},
{
title: "3.5 Bidirectional Graph & Dossier Cross-Verification",
state: { guildFilter: "ALL", selectedSymbol: "COIN", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 27 },
spotlight: { target: "docCard", xRatio: 0.50, yRatio: 0.50, label: "Cross-Corpus Coordinate Verification" },
uiTargets: ["tickerSelect", "docReferencesCard"],
uiElementLabel: "Ticker Select (#tickerSelect -> COIN) & Documentation Card (#docReferencesCard)",
subtitle: "Clicking any coordinate pill jumps straight to the Encyclopedia Knowledge Graph with that node centered and isolated in the right-hand drawer.",
speechText: "Scene 3.5. Highlighting Ticker Select set to Coinbase and the Panel 3 Documentation Card. Clicking any coordinate pill jumps straight to the Encyclopedia Knowledge Graph with that node centered and isolated in the right-hand inspector drawer.",
citations: [
{ label: "Graph Node aq:211", href: "/graph/index.html?select=aq:211" },
{ label: "Dossier 68 (S6 Capture)", href: "/zoology/dossiers/68-dossier-technocapital-singularity-apparatus-of-capture.md#:~:text=125" }
]
}
]
},
{
id: "ep04",
code: "Ep 04",
title: "Hot-Swapping Projection Lenses (LENS_REGISTRY Reversibility)",
keyframes: [
{
title: "4.1 Lens 1: Neutral Mathematical Substrate (neutral_math)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "neutral_math", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "lensCard", xRatio: 0.50, yRatio: 0.50, label: "Pure Lens-Neutral Keys (struct_* & ts_*)" },
uiTargets: ["lensSelect", "lensProjectionCard"],
uiElementLabel: "Projection Lens Dropdown List (#lensSelect -> Neutral Math) & Lens Card (#lensProjectionCard)",
subtitle: "Under the hood, quant-timeseries.json stores 100% lens-neutral mathematical keys (struct_isometric_armor, ts_duty_cycle_pct, ts_weighted_resonance, ts_excess_over_replacement, ts_optimal_lag_days).",
speechText: "Scene 4.1. Highlighting the Projection Lens dropdown list in the top toolbar and the Lens Projection card in Panel 3. Under the hood, the workbench stores one hundred percent lens-neutral mathematical keys: structural isometric armor, duty cycle percentage, weighted resonance, excess over replacement, and optimal lag days. Use the Projection Lens dropdown list in the toolbar to switch lenses.",
citations: [
{ label: "Schema quant-timeseries.schema.json", href: "/schemas/v1/quant-timeseries.schema.json" },
{ label: "Vol 08A PDF (Stakeholder Registers)", href: "/encyclopedia/08-stakeholder-registers-idioms-and-pokedex-semiotics/a-to-h-ai-powered-race-to-hidden-chokepoint-screen.pdf#page=1&search=Register" }
]
},
{
title: "4.2 Lens 2: Out-of-Sample Quantitative Factor Register (fund_manager)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "lensCard", xRatio: 0.50, yRatio: 0.50, label: "Fund Manager Register: Signal Duty Cycle & Alpha Over Benchmark" },
uiTargets: ["lensSelect", "lensProjectionCard"],
uiElementLabel: "Projection Lens Dropdown List (#lensSelect -> Fund Manager) & Lens Card (#lensProjectionCard)",
subtitle: "Switching to 'Quant Factor (fund_manager)' translates the exact same 6 numbers into institutional factor terminology (Chokepoint Moat, Signal Duty Cycle %, Composite Resonance Load).",
speechText: "Scene 4.2. Highlighting the Projection Lens dropdown list switched to Quant Factor Fund Manager and the Panel 3 Lens Projection card. Selecting Fund Manager in the Projection Lens dropdown translates the exact same six mathematical invariants into institutional factor terminology: Chokepoint Moat, Signal Duty Cycle percentage, and Composite Resonance Load.",
citations: [
{ label: "Fund Manager Proposal (PDF)", href: "/zoology/proposal-fund-manager-novel-investment-discovery.pdf#page=1&search=Uncaptured" },
{ label: "REST Tier List (fund_manager)", href: "/api/v1/zoology/tier-list?register=fund_manager" }
]
},
{
title: "4.3 Lens 3: Corporate Board & Supply-Chain Governance (corporate_board)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "corporate_board", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "lensCard", xRatio: 0.50, yRatio: 0.50, label: "Corporate Board Register: Supply-Chain Moat & Stress-Test Delta" },
uiTargets: ["lensSelect", "lensProjectionCard"],
uiElementLabel: "Projection Lens Dropdown List (#lensSelect -> Corporate Board) & Lens Card (#lensProjectionCard)",
subtitle: "Switching to 'Corporate Board' frames those identical invariants as Supply-Chain Structural Moat, Cross-Unit Synergy, and Stress-Test Regime Delta.",
speechText: "Scene 4.3. Highlighting the Projection Lens dropdown list switched to Corporate Board and the Panel 3 Lens Projection card. Selecting Corporate Board in the Projection Lens dropdown frames those identical invariants as Supply-Chain Structural Moat, Cross-Unit Synergy, and Stress-Test Regime Delta.",
citations: [
{ label: "Corporate Board Proposal (PDF)", href: "/zoology/proposal-corporate-board-technocapital-allocation.pdf#page=1&search=Moat" },
{ label: "REST Tier List (corporate_board)", href: "/api/v1/zoology/tier-list?register=corporate_board" }
]
},
{
title: "4.4 Lens 4 & 5: TierZoo Ecology (ETI) & Fantasy Sabermetrics (SNAP% / WOPR / WAR)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fantasy_sabermetrics", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "lensCard", xRatio: 0.50, yRatio: 0.50, label: "Fantasy Sabermetrics: SNAP%, WOPR, WAR (30d) & Matchup Splits" },
uiTargets: ["lensSelect", "lensProjectionCard"],
uiElementLabel: "Projection Lens Dropdown List (#lensSelect -> Fantasy Sabermetrics) & Lens Card (#lensProjectionCard)",
subtitle: "Switching to 'Fantasy Sabermetrics' projects SNAP% (Active Lock Share), WOPR (1.5x Target Share + 0.7x Air-Yards Share), and WAR (30d Wins Above Tier D Replacement).",
speechText: "Scene 4.4. Highlighting the Projection Lens dropdown list switched to Fantasy Sabermetrics and the Panel 3 Lens Projection card. Selecting Fantasy Sabermetrics in the Projection Lens dropdown projects Snap Percentage, Weighted Opportunity Rating, and thirty-day Wins Above Replacement.",
citations: [
{ label: "ETI Tier List Scorecard (PDF)", href: "/zoology/tier-list-technocapital-assemblage-builds.pdf#page=1&search=ETI" },
{ label: "Vol 07A PDF (ETI Ontology)", href: "/encyclopedia/07-ecological-trophic-index-and-tier-list/a-to-z-arm-chokepoint-armor-to-zoological-tie-breaker.pdf#page=1&search=ETI" }
]
},
{
title: "4.5 Lens 6: Gen IV Pokédex Field-Scanner (DEX #137)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "pokedex_scanner", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "lensCard", xRatio: 0.50, yRatio: 0.50, label: "Gen IV Pokédex Scanner: DEX #137, Nature, Ability & EV Yield" },
uiTargets: ["lensSelect", "lensProjectionCard"],
uiElementLabel: "Projection Lens Dropdown List (#lensSelect -> Pokedex Scanner) & Lens Card (#lensProjectionCard)",
subtitle: "Switching to 'Pokédex Scanner' deterministically derives Gen IV attributes (DEX #137, Nature, Passive Ability, EV Yield) from the real time-series moments—and remains 100% removable via ENABLED_LENSES.",
speechText: "Scene 4.5. Highlighting the Projection Lens dropdown list switched to Pokedex Scanner and the Panel 3 Lens Projection card. Selecting Pokedex Scanner deterministically derives Gen 4 attributes including Dex number 137, Nature, Passive Ability, and Effort Value Yield from the real time-series moments.",
citations: [
{ label: "REST Pokédex Endpoint (/api/v1/zoology/pokedex/NVDA)", href: "/api/v1/zoology/pokedex/NVDA" },
{ label: "Vol 08B PDF (Pokédex Semiotics)", href: "/encyclopedia/08-stakeholder-registers-idioms-and-pokedex-semiotics/i-to-z-idiosyncratic-prime-screen-to-united-fidelity.pdf#page=1&search=Pokedex" }
]
}
]
},
{
id: "ep05",
code: "Ep 05",
title: "Panel 4: Lead-Lag Cross-Correlation r(tau), Exports & REST APIs",
keyframes: [
{
title: "5.1 Panel 4: Lead-Lag Cross-Correlation Curve r(tau) across [-5 .. +5] Days",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "panel4", xRatio: 0.50, yRatio: 0.45, label: "Pearson Cross-Correlation r(tau) & Gold Optimal Causal Lag tau*" },
uiTargets: ["lagBarsContainer"],
uiElementLabel: "Panel 4 Lead-Lag Cross-Correlation Bar Chart (#lagBarsContainer)",
subtitle: "Panel 4 computes the empirical Pearson cross-correlation r(tau) between daily 00:00 GMT news-wire equation velocity M_t and unsigned basis-point displacement |Δbps_{i, t+tau}| across lags tau in [-5, +5] days.",
speechText: "Scene 5.1. Highlighting the Lead-Lag Cross-Correlation bar chart in Panel 4. Panel 4 computes the empirical Pearson cross-correlation r of tau between daily midnight GMT news-wire equation velocity and unsigned basis-point price displacement across lags from minus 5 to plus 5 days.",
citations: [
{ label: "Operator's Manual (Panel 4 Math)", href: "/quant/OPERATORS-MANUAL-QUANT-TIMESERIES-WORKBENCH.pdf#page=2&search=Correlation" },
{ label: "Graph Mode 2 Concentric Radar", href: "/graph/index.html?select=aq:137&mode=mode2_radar" }
]
},
{
title: "5.2 Interpreting Optimal Causal Lag tau* (Leader vs. Synchronizer vs. Follower)",
state: { guildFilter: "ALL", selectedSymbol: "ASML", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "panel4", xRatio: 0.58, yRatio: 0.45, label: "Gold Bar Marks argmax |r(tau)|" },
uiTargets: ["tickerSelect", "lagBarsContainer"],
uiElementLabel: "Ticker Select (#tickerSelect -> ASML) & Panel 4 Lead-Lag Bars (#lagBarsContainer)",
subtitle: "The Gold bar highlights tau* = argmax |r(tau)|: tau* > 0 indicates a Teleoplexic Wire Leader (midnight wire velocity leads market volatility), tau* = 0 an Instantaneous Synchronizer, and tau* < 0 a Narrative Follower.",
speechText: "Scene 5.2. Highlighting the Gold optimal lag bar in Panel 4. The Gold bar marks tau star, the lag maximizing absolute correlation: positive tau star indicates a Teleoplexic Wire Leader, zero indicates an Instantaneous Synchronizer, and negative tau star indicates a Narrative Follower.",
citations: [
{ label: "Vol 03C PDF (ASML)", href: "/encyclopedia/03-machinic-phylum-guilds-s1-to-s5/class-s3-silicon-war-machine-and-euv-swarm-a-to-z.pdf#page=1&search=ASML" },
{ label: "Graph Node aq:81", href: "/graph/index.html?select=aq:81" }
]
},
{
title: "5.3 Portable .CSV & Lens-Neutral .JSON Slice Exports",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "neutral_math", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "panel4", xRatio: 0.82, yRatio: 0.14, label: "One-Click .CSV & Lens-Neutral .JSON Export" },
uiTargets: ["exportCsvBtn", "exportJsonBtn"],
uiElementLabel: "Panel 4 Export Buttons (#exportCsvBtn & #exportJsonBtn)",
subtitle: "Click 'Export Filtered Series (.CSV)' or 'Export Lens-Neutral Slice (.JSON)' in the Panel 4 header to download any ticker's 30-day periodic bar table and structural/time-series vectors for offline research.",
speechText: "Scene 5.3. Highlighting the Export Filtered Series CSV and Export Lens-Neutral Slice JSON buttons in the Panel 4 header. Click either button to download any ticker's thirty-day periodic bar table and structural vectors for offline research.",
citations: [
{ label: "Raw Bundle quant-timeseries.json", href: "/quant/quant-timeseries.json" },
{ label: "Schema quant-timeseries.schema.json", href: "/schemas/v1/quant-timeseries.schema.json" }
]
},
{
title: "5.4 Panel 5 FRED Macro Strip & Unified Stateless REST API v1 (/api/v1/*)",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "docCard", xRatio: 0.50, yRatio: 0.50, label: "Programmatic REST API v1 & OpenAPI 3.1.0" },
uiTargets: ["macroIndicatorsPanel", "docReferencesCard"],
uiElementLabel: "Panel 5 FRED Macroeconomic Telemetry (#macroIndicatorsPanel) & REST API Links (#docReferencesCard)",
subtitle: "Every readout on /quant/ is also queryable over HTTP GET/POST via /api/v1/quant/timeseries, /api/v1/quant/instruments/{symbol}, /api/v1/dossiers/{number}?highlight=..., and /api/v1/openapi.json.",
speechText: "Scene 5.4. Highlighting Panel 5 Federal Reserve Macroeconomic Telemetry and the Panel 3 REST API links. Every readout on the workbench is also queryable programmatically over HTTP via the version 1 REST API and OpenAPI 3.1 specification.",
citations: [
{ label: "OpenAPI 3.1.0 Spec (/api/v1/openapi.json)", href: "/api/v1/openapi.json" },
{ label: "REST Status (/api/v1/status)", href: "/api/v1/status" },
{ label: "REST NVDA Instrument", href: "/api/v1/quant/instruments/NVDA" }
]
},
{
title: "5.5 Panel 6 Daily Bayesian Brief & Complete Tour Summary",
state: { guildFilter: "ALL", selectedSymbol: "NVDA", selectedLens: "fund_manager", metricMode: "spoken_aq", selectedDateIdx: 26 },
spotlight: { target: "canvas", pane: "top", xRatio: 0.89, yRatio: 0.25, label: "Tour Complete — Explore Any Ticker, Lens, or Deep Citation" },
uiTargets: ["dailyBriefPanel", "lensSelect"],
uiElementLabel: "Panel 6 Daily Bayesian Regime Update (#dailyBriefPanel) & Projection Lens Dropdown (#lensSelect)",
subtitle: "You have completed all 5 episodes of the /quant/ guided walkthrough. Open the Companion Operator's Manual (PDF) or click any heatmap cell, lens, or deep citation link to continue exploring.",
speechText: "Scene 5.5. Highlighting Panel 6, the five-agenda Daily Bayesian Portfolio and Memetic Regime Update, and the Projection Lens dropdown list. You have completed all five episodes of the guided walkthrough. Open the Companion Operator's Manual PDF or click any heatmap cell, projection lens, or deep citation link to continue exploring.",
citations: [
{ label: "Operator's Manual (PDF)", href: "/quant/OPERATORS-MANUAL-QUANT-TIMESERIES-WORKBENCH.pdf" },
{ label: "Interactive Knowledge Graph (/graph/)", href: "/graph/index.html?select=aq:137" },
{ label: "Self-Paced Learning Track (/learn/)", href: "/learn/index.html" }
]
}
]
}
];
function adaptHrefForFileProtocol(href) {
if (!href || window.location.protocol !== "file:") return href;
if (href.startsWith("https://")) return href;
if (href.startsWith("/encyclopedia/")) {
return "../../../technocapital-singularity-zoology/encyclopedia/" + href.slice("/encyclopedia/".length);
}
if (href.startsWith("/zoology/")) {
return "../../../technocapital-singularity-zoology/" + href.slice("/zoology/".length);
}
if (href.startsWith("/archive/")) {
return "../../../ingglish-hyperdope-gematria/ingglish-aq-archive/" + href.slice("/archive/".length);
}
if (href.startsWith("/graph/")) {
return "../../../encyclopedia-knowledge-graph/" + href.slice("/graph/".length);
}
if (href.startsWith("/learn/")) {
return "../learn/" + href.slice("/learn/".length);
}
if (href.startsWith("/quant/")) {
return "./" + href.slice("/quant/".length);
}
if (href.startsWith("/schemas/")) {
return "../../schemas/" + href.slice("/schemas/".length);
}
if (href.startsWith("/api/v1/quant/")) {
return "./quant-timeseries.json";
}
if (href.startsWith("/api/v1/zoology/tier-list")) {
return "../../../technocapital-singularity-zoology/taxonomy/assemblage-builds-tier-list.json";
}
if (href.startsWith("/api/v1/dossiers/")) {
return "../../../ingglish-hyperdope-gematria/ingglish-aq-archive/71-dossier-news-2026-11-29.md";
}
return href;
}
let curEpIdx = 0;
let curStepIdx = 0;
let isPlaying = false;
let playTimer = null;
let speechEnabled = true; // Enabled by default so tour playback narrates immediately
let activeVoiceEngine = "Auto";
let cachedVoices = [];
let audioCtx = null;
let activeAudioEl = null;
let activeAudioEqConnected = false;
let formantStopFlag = false;
function refreshVoices() {
if (typeof window === "undefined" || typeof window.speechSynthesis === "undefined") return;
try {
cachedVoices = window.speechSynthesis.getVoices() || [];
} catch (_) {
cachedVoices = [];
}
}
if (typeof window !== "undefined" && typeof window.speechSynthesis !== "undefined") {
refreshVoices();
if (typeof window.speechSynthesis.onvoiceschanged !== "undefined") {
window.speechSynthesis.onvoiceschanged = refreshVoices;
}
}
function cleanTextForSpeech(rawText, uiElementLabel) {
let base = String(rawText || "");
if (uiElementLabel && base.indexOf("Inspecting") === -1 && base.indexOf("Highlighting") === -1) {
base = "Inspecting " + uiElementLabel + ". " + base;
}
return base
.replace(/\|Δbps_\{i,\s*t\+tau\}\|/g, "absolute basis point displacement at lag tau")
.replace(/r\(tau\)/g, "r of tau")
.replace(/tau\*/g, "tau star")
.replace(/Δ\s*=\s*0/g, "delta equals zero")
.replace(/==/g, " equals ")
.replace(/#:~:text=/g, "scroll to text ")
.replace(/struct_\*/g, "structural keys")
.replace(/ts_\*/g, "time series keys")
.replace(/24x30/g, "24 by 30")
.replace(/↗/g, "")
.replace(/\s+/g, " ")
.trim();
}
function playWebAudioTelemetryChime(stepIdx) {
try {
const Ctx = window.AudioContext || window.webkitAudioContext;
if (!Ctx) return;
if (!audioCtx) audioCtx = new Ctx();
if (audioCtx.state === "suspended") audioCtx.resume();
const baseFreqs = [292.0, 333.0, 394.0, 444.0, 528.0];
const f0 = baseFreqs[stepIdx % baseFreqs.length];
const now = audioCtx.currentTime;
// Strategy 3A: Duck chime gain by -50% (0.012 vs 0.025) when Voice: ON is active so opening words are never masked
const peakGain = speechEnabled ? 0.012 : 0.025;
[f0, f0 * 1.25, f0 * 1.5].forEach(function (freq, i) {
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.type = i === 0 ? "triangle" : "sine";
osc.frequency.setValueAtTime(freq, now + i * 0.09);
gain.gain.setValueAtTime(0.001, now + i * 0.09);
gain.gain.exponentialRampToValueAtTime(peakGain, now + i * 0.09 + 0.03);
gain.gain.exponentialRampToValueAtTime(0.0001, now + i * 0.09 + 0.35);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start(now + i * 0.09);
osc.stop(now + i * 0.09 + 0.38);
});
} catch (_) {}
}
function scheduleNextStep(delayMs) {
if (playTimer) clearTimeout(playTimer);
if (!isPlaying) return;
playTimer = setTimeout(function () {
if (isPlaying) stepNext();
}, delayMs);
}
function stopAllVoiceOutputs() {
formantStopFlag = true;
if (activeAudioEl) {
try {
activeAudioEl.pause();
activeAudioEl.currentTime = 0;
} catch (_) {}
}
if (typeof window !== "undefined" && typeof window.speechSynthesis !== "undefined") {
try {
if (window.speechSynthesis.speaking || window.speechSynthesis.pending) {
window.speechSynthesis.cancel();
}
} catch (_) {}
}
rootObj.__hsActiveUtterance = null;
}
// Tier 3 In-Browser Klatt Formant WebAudio Speech Synthesizer (for offline file:// when getVoices() === [])
function playInBrowserFormantSpeech(speechText, onFinish) {
try {
const Ctx = (typeof window !== "undefined") && (window.AudioContext || window.webkitAudioContext);
if (!Ctx) {
if (onFinish) onFinish();
return;
}
if (!audioCtx) audioCtx = new Ctx();
if (audioCtx.state === "suspended") audioCtx.resume();
formantStopFlag = false;
activeVoiceEngine = "Formant Synth";
renderTutorialUI();
const words = String(speechText || "").toLowerCase().match(/[a-z0-9]+|[.,;:!?]/g) || [];
const vowelMap = {
a: [660, 1350],
e: [510, 1880],
i: [370, 2050],
o: [520, 950],
u: [380, 1050],
y: [320, 2100]
};
let tOffset = audioCtx.currentTime + 0.04;
const maxWords = Math.min(words.length, 48);
for (let wi = 0; wi < maxWords; wi++) {
const w = words[wi];
if (w === "." || w === "!" || w === "?") {
tOffset += 0.14;
continue;
}
if (w === "," || w === ";" || w === ":") {
tOffset += 0.07;
continue;
}
const vowels = w.match(/[aeiouy]/g) || ["a"];
const f0 = 116.0 - 14.0 * ((wi % 10) / 10.0);
for (let vi = 0; vi < Math.min(vowels.length, 3); vi++) {
const vf = vowelMap[vowels[vi]] || [580, 1250];
const dur = 0.075;
const osc0 = audioCtx.createOscillator();
const osc1 = audioCtx.createOscillator();
const osc2 = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc0.type = "sawtooth";
osc1.type = "sine";
osc2.type = "sine";
osc0.frequency.setValueAtTime(f0, tOffset);
osc1.frequency.setValueAtTime(vf[0], tOffset);
osc2.frequency.setValueAtTime(vf[1], tOffset);
gain.gain.setValueAtTime(0.0001, tOffset);
gain.gain.linearRampToValueAtTime(0.045, tOffset + 0.015);
gain.gain.exponentialRampToValueAtTime(0.0001, tOffset + dur);
osc0.connect(gain);
osc1.connect(gain);
osc2.connect(gain);
gain.connect(audioCtx.destination);
osc0.start(tOffset);
osc1.start(tOffset);
osc2.start(tOffset);
osc0.stop(tOffset + dur + 0.01);
osc1.stop(tOffset + dur + 0.01);
osc2.stop(tOffset + dur + 0.01);
tOffset += dur;
}
tOffset += 0.025;
}
const totalDurMs = Math.max(2500, Math.round((tOffset - audioCtx.currentTime) * 1000));
setTimeout(function () {
if (!formantStopFlag && onFinish) onFinish();
}, totalDurMs);
} catch (_) {
if (onFinish) onFinish();
}
}
// Tier 2 Deploy-Time Untracked WAV Playback (/quant/audio/ep0X-sY.wav) -> Tier 3 Formant Fallback
function playDeployTimeWavOrFormant(clipId, rawSpeech, onFinish) {
if (typeof document === "undefined" || typeof Audio === "undefined") {
playInBrowserFormantSpeech(rawSpeech, onFinish);
return;
}
try {
if (!activeAudioEl) {
activeAudioEl = document.getElementById("tutVoiceAudio");
if (!activeAudioEl) {
activeAudioEl = document.createElement("audio");
activeAudioEl.id = "tutVoiceAudio";
activeAudioEl.preload = "auto";
activeAudioEl.style.display = "none";
document.body.appendChild(activeAudioEl);
}
}
// Strategy 3A: Route #tutVoiceAudio through a WebAudio BiquadFilterNode vocal warmth EQ (+2.5 dB @ 220 Hz, -3.0 dB @ 4.8 kHz)
if (!activeAudioEqConnected && typeof window !== "undefined" && window.location && window.location.protocol !== "file:") {
try {
const Ctx = window.AudioContext || window.webkitAudioContext;
if (Ctx) {
if (!audioCtx) audioCtx = new Ctx();
if (audioCtx.state === "suspended") audioCtx.resume();
const srcNode = audioCtx.createMediaElementSource(activeAudioEl);
const lowShelf = audioCtx.createBiquadFilter();
lowShelf.type = "lowshelf";
lowShelf.frequency.value = 220.0;
lowShelf.gain.value = 2.5;
const deEssPeak = audioCtx.createBiquadFilter();
deEssPeak.type = "peaking";
deEssPeak.frequency.value = 4800.0;
deEssPeak.Q.value = 1.4;
deEssPeak.gain.value = -3.0;
srcNode.connect(lowShelf);
lowShelf.connect(deEssPeak);
deEssPeak.connect(audioCtx.destination);
activeAudioEqConnected = true;
}
} catch (_) {
activeAudioEqConnected = true;
}
}
const wavUrl = "./audio/" + clipId + ".wav";
let handled = false;
const doneOnce = function () {
if (handled) return;
handled = true;
if (onFinish) onFinish();
};
activeAudioEl.onended = doneOnce;
activeAudioEl.onerror = function () {
if (handled) return;
handled = true;
playInBrowserFormantSpeech(rawSpeech, onFinish);
};
activeAudioEl.src = wavUrl;
const playPromise = activeAudioEl.play();
activeVoiceEngine = "WAV Audio";
renderTutorialUI();
if (playPromise && typeof playPromise.catch === "function") {
playPromise.catch(function () {
if (handled) return;
handled = true;
playInBrowserFormantSpeech(rawSpeech, onFinish);
});
}
} catch (_) {
playInBrowserFormantSpeech(rawSpeech, onFinish);
}
}
// Strategies 1A, 2A & 3A: Guarded cancel(), GC-pinned utterance, 250ms onstart watchdog & 3-tier fallback
function speakSubtitle(kfOrText, onDoneCallback) {
if (!speechEnabled) {
if (onDoneCallback) scheduleNextStep(7000);
return;
}
const rawSpeech = (kfOrText && typeof kfOrText === "object")
? (kfOrText.speechText || cleanTextForSpeech(kfOrText.subtitle, kfOrText.uiElementLabel))
: cleanTextForSpeech(String(kfOrText || ""), "");
const clipId = "ep0" + (curEpIdx + 1) + "-s" + (curStepIdx + 1);
stopAllVoiceOutputs();
playWebAudioTelemetryChime(curStepIdx);
refreshVoices();
let settled = false;
const finishSceneSpeech = function () {
if (settled) return;
settled = true;
rootObj.__hsActiveUtterance = null;
if (onDoneCallback && isPlaying) {
scheduleNextStep(1600);
}
};
const estMs = Math.max(8500, Math.min(22000, rawSpeech.split(/\s+/).length * 410));
if (onDoneCallback && isPlaying) {
scheduleNextStep(estMs);
}
// If browser has no speechSynthesis or 0 installed OS voices (common on Linux/Fedora desktops),
// immediately play the deploy-time WAV track (or Formant Synth fallback) so voice is 100% audible!
if (
typeof window === "undefined" ||
typeof window.speechSynthesis === "undefined" ||
typeof SpeechSynthesisUtterance === "undefined" ||
cachedVoices.length === 0
) {
playDeployTimeWavOrFormant(clipId, rawSpeech, finishSceneSpeech);
return;
}
try {
if (typeof window.speechSynthesis.resume === "function") {
window.speechSynthesis.resume();
}
const u = new SpeechSynthesisUtterance(rawSpeech);
// Strategy 2A: Pin u on rootObj so Chromium/WebKit GC never collects the utterance mid-speech
rootObj.__hsActiveUtterance = u;
const preferred = cachedVoices.find(function (v) {
return /en(-|_)(US|GB)/i.test(v.lang) && /natural|neural|google|english/i.test(v.name);
}) || cachedVoices.find(function (v) {
return /^en/i.test(v.lang);
}) || cachedVoices[0];
if (preferred) u.voice = preferred;
u.lang = "en-US";
u.rate = 1.03;
u.pitch = 1.0;
u.volume = 1.0;
let speechStarted = false;
let fallbackTriggered = false;
const triggerFallback = function () {
if (fallbackTriggered || settled || !speechEnabled) return;
fallbackTriggered = true;
try {
if (window.speechSynthesis.speaking || window.speechSynthesis.pending) {
window.speechSynthesis.cancel();
}
} catch (_) {}
playDeployTimeWavOrFormant(clipId, rawSpeech, finishSceneSpeech);
};
u.onstart = function () {
speechStarted = true;
activeVoiceEngine = "WebSpeech";
renderTutorialUI();
};
u.onend = function () {
if (!fallbackTriggered) finishSceneSpeech();
};
u.onerror = function () {
if (!speechStarted) triggerFallback();
else finishSceneSpeech();
};
window.speechSynthesis.speak(u);
// Strategy 2A: 250ms hardware watchdog — if OS speech-dispatcher socket is hung and onstart never fires,
// automatically switch to deploy-time WAV / WebAudio formant synth so the user always hears the narration!
setTimeout(function () {
if (!speechStarted && !settled && speechEnabled) {
triggerFallback();
}
}, 250);
} catch (_) {
playDeployTimeWavOrFormant(clipId, rawSpeech, finishSceneSpeech);
}
}
function getActiveKeyframe() {
const ep = EPISODES[curEpIdx] || EPISODES[0];
return ep.keyframes[curStepIdx] || ep.keyframes[0];
}
// Strategy 2A: Highlight all 18+ interactive DOM controls (including #lensSelect in Ep 04) + floating pointer badge
function highlightDomTarget(kfOrTargetId) {
ALL_HIGHLIGHTABLE_DOM_IDS.forEach(function (id) {
const el = document.getElementById(id);
if (el) {
el.style.boxShadow = "";
el.classList.remove("tut-ui-highlight");
}
});
const badge = document.getElementById("tutUiElementIndicator");
if (!kfOrTargetId) {
if (badge) badge.style.display = "none";
return;
}
const legacyMap = {
panel2: ["heatmapTable"],
lensCard: ["lensSelect", "lensProjectionCard"],
docCard: ["docReferencesCard"],
wireTape: ["wireTapeFilterInput", "wireEqTape"],
panel4: ["lagBarsContainer"],
panel3: ["openTradingViewBtn", "panel3TvBtn"],
canvas: ["tsCanvas"]
};
let targetIds = [];
let badgeText = "";
if (typeof kfOrTargetId === "object") {
if (Array.isArray(kfOrTargetId.uiTargets) && kfOrTargetId.uiTargets.length > 0) {
targetIds = kfOrTargetId.uiTargets.slice();
} else if (kfOrTargetId.spotlight && kfOrTargetId.spotlight.target) {
targetIds = legacyMap[kfOrTargetId.spotlight.target] || [kfOrTargetId.spotlight.target];
}
badgeText = kfOrTargetId.uiElementLabel || ("UI ELEMENT: #" + (targetIds[0] || "tsCanvas"));
} else if (typeof kfOrTargetId === "string") {
targetIds = legacyMap[kfOrTargetId] || [kfOrTargetId];
badgeText = "UI ELEMENT: #" + targetIds[0];
}
let primaryEl = null;
targetIds.forEach(function (domId) {
const el = document.getElementById(domId);
if (el) {
el.classList.add("tut-ui-highlight");
el.style.boxShadow = "0 0 0 2px #f5c630, 0 0 18px rgba(245, 198, 48, 0.45)";
if (!primaryEl) primaryEl = el;
}
});
if (badge && primaryEl && typeof primaryEl.getBoundingClientRect === "function") {
const rect = primaryEl.getBoundingClientRect();
const topPx = Math.max(8, Math.min(window.innerHeight - 36, rect.top - 28));
const leftPx = Math.max(8, Math.min(window.innerWidth - 320, rect.left));
badge.textContent = "\u25BC ACTIVE UI ELEMENT: " + badgeText;
badge.style.top = topPx + "px";
badge.style.left = leftPx + "px";
badge.style.display = "block";
} else if (badge) {
badge.style.display = "none";
}
}
function applyCurrentKeyframe(narrateNow) {
const kf = getActiveKeyframe();
const app = window.HyperstitionStudio.QuantWorkbenchApp;
if (app && typeof app.setStateAndRender === "function") {
app.setStateAndRender(kf.state, kf.spotlight);
}
highlightDomTarget(kf);
renderTutorialUI();
if (narrateNow || isPlaying) {
speakSubtitle(kf, isPlaying);
}
}
function stepNext() {
const ep = EPISODES[curEpIdx];
if (curStepIdx < ep.keyframes.length - 1) {
curStepIdx++;
} else if (curEpIdx < EPISODES.length - 1) {
curEpIdx++;
curStepIdx = 0;
} else {
stopPlayback();
return;
}
applyCurrentKeyframe(true);
}
function stepPrev() {
if (curStepIdx > 0) {
curStepIdx--;
} else if (curEpIdx > 0) {
curEpIdx--;
curStepIdx = EPISODES[curEpIdx].keyframes.length - 1;
}
applyCurrentKeyframe(true);
}
function startPlayback() {
isPlaying = true;
if (playTimer) clearTimeout(playTimer);
applyCurrentKeyframe(true);
renderTutorialUI();
}
function stopPlayback() {
isPlaying = false;
if (playTimer) {
clearTimeout(playTimer);
playTimer = null;
}
stopAllVoiceOutputs();
renderTutorialUI();
}
function renderTutorialUI() {
const epTabs = document.getElementById("tutEpisodeTabs");
const stepBadge = document.getElementById("tutStepBadge");
const scrubber = document.getElementById("tutScrubber");
const playBtn = document.getElementById("tutPlayPauseBtn");
const speechBtn = document.getElementById("tutSpeechBtn");
const titleEl = document.getElementById("tutKeyframeTitle");
const subEl = document.getElementById("tutSubtitleText");
const citesEl = document.getElementById("tutCitationPills");
if (!epTabs) return;
const ep = EPISODES[curEpIdx];
const kf = getActiveKeyframe();
epTabs.innerHTML = EPISODES.map(function (e, idx) {
const cls = "pill" + (idx === curEpIdx ? " active" : "");
return "<button type='button' class='" + cls + "' data-ep-idx='" + idx + "'>" + e.code + ": " + e.title + "</button>";
}).join("");
epTabs.querySelectorAll("[data-ep-idx]").forEach(function (b) {
b.onclick = function () {
curEpIdx = parseInt(b.getAttribute("data-ep-idx"), 10);
curStepIdx = 0;
applyCurrentKeyframe(speechEnabled);
};
});
if (playBtn) {
playBtn.textContent = isPlaying ? "\u23F8 Pause Tour" : "\u25B6 Play Guided Tour";
playBtn.className = isPlaying ? "btn tv-btn" : "btn primary";
}
if (speechBtn) {
speechBtn.textContent = speechEnabled ? "\uD83D\uDD0A Voice: ON" : "\uD83D\uDD07 Voice: OFF";
speechBtn.className = speechEnabled ? "btn primary" : "btn";
speechBtn.title = speechEnabled
? ("Active Voice Engine: " + activeVoiceEngine + " (Click to mute)")
: "Voice Narration Muted (Click to enable spoken narration)";
}
if (stepBadge) {
const voxTag = speechEnabled ? (" \u2022 \uD83D\uDD0A " + activeVoiceEngine) : "";
stepBadge.textContent = ep.code + " \u2022 Scene " + (curStepIdx + 1) + "/" + ep.keyframes.length + voxTag + (kf.uiElementLabel ? " \u2022 [" + kf.uiElementLabel + "]" : "");
}
if (scrubber) {
scrubber.max = String(ep.keyframes.length - 1);
scrubber.value = String(curStepIdx);
}
if (titleEl) {
titleEl.textContent = kf.title + (kf.uiElementLabel ? " \u2014 UI Element: " + kf.uiElementLabel : "");
}
if (subEl) {
subEl.textContent = kf.subtitle;
}
if (citesEl) {
citesEl.innerHTML = (kf.citations || []).map(function (c) {
const resolved = adaptHrefForFileProtocol(c.href);
return "<a class='pill tut-cite-link' data-raw-href='" + c.href + "' style='text-decoration:none;color:var(--cyan);border-color:var(--cyan);' href='" +
resolved + "' target='_blank' rel='noopener noreferrer'>\uD83D\uDCC4 " + c.label + " \u2197</a>";
}).join("");
}
}
function initTutorials() {
const playBtn = document.getElementById("tutPlayPauseBtn");
const prevBtn = document.getElementById("tutPrevBtn");
const nextBtn = document.getElementById("tutNextBtn");
const clearBtn = document.getElementById("tutClearSpotlightBtn");
const speechBtn = document.getElementById("tutSpeechBtn");
const scrubber = document.getElementById("tutScrubber");
if (playBtn) {
playBtn.onclick = function () {
if (isPlaying) stopPlayback();
else startPlayback();
};
}
if (prevBtn) prevBtn.onclick = function () { stopPlayback(); stepPrev(); };
if (nextBtn) nextBtn.onclick = function () { stopPlayback(); stepNext(); };
if (clearBtn) {
clearBtn.onclick = function () {
stopPlayback();
highlightDomTarget(null);
const app = window.HyperstitionStudio.QuantWorkbenchApp;
if (app && typeof app.setStateAndRender === "function") {
app.setStateAndRender({}, null);
}
};
}
if (speechBtn) {
speechBtn.onclick = function () {
speechEnabled = !speechEnabled;
if (speechEnabled) speakSubtitle(getActiveKeyframe(), isPlaying);
else stopAllVoiceOutputs();
renderTutorialUI();
};
}
if (scrubber) {
scrubber.oninput = function () {
stopPlayback();
curStepIdx = parseInt(scrubber.value, 10) || 0;
applyCurrentKeyframe(speechEnabled);
};
}
window.addEventListener("scroll", function () {
if (isPlaying) highlightDomTarget(getActiveKeyframe());
}, { passive: true });
renderTutorialUI();
}
const exportedApi = {
version: "2.17.0",
episodes: EPISODES,
allHighlightableDomIds: ALL_HIGHLIGHTABLE_DOM_IDS,
cleanTextForSpeech: cleanTextForSpeech,
highlightDomTarget: highlightDomTarget,
speakSubtitle: speakSubtitle,
adaptHrefForFileProtocol: adaptHrefForFileProtocol,
init: initTutorials
};
rootObj.HyperstitionStudio.QuantTutorials = exportedApi;
if (typeof module !== "undefined" && module.exports) {
module.exports = exportedApi;
}
if (typeof document !== "undefined") {
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", initTutorials);
} else {
initTutorials();
}
}
})();