/* FinanceBench viewer — Corpus, Eval, full runs, and prejoined comparison. */ (function () { "use strict"; var $ = function (id) { return document.getElementById(id); }; var RUN_REGISTRY = {}; function esc(s) { if (s === null || s === undefined) return ""; return String(s) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """); } function shorten(s, n) { s = String(s || "").replace(/\s+/g, " ").trim(); return s.length > n ? s.slice(0, n - 1) + "…" : s; } function field(label, valueHtml, cls) { return '
' + esc(label) + '
' + valueHtml + "
"; } function formatPairs(value) { if (!value || typeof value !== "object") return "—"; var parts = []; Object.keys(value).forEach(function (key) { if (value[key] !== null && value[key] !== undefined) { parts.push(esc(key) + ": " + esc(value[key]) + ""); } }); return parts.length ? parts.join(" · ") : "—"; } function statusFor(record) { if (!record.answered) return "missing"; return record.correct === true ? "correct" : "incorrect"; } function statusBadge(record) { var status = statusFor(record); var label = status === "correct" ? "✓ Correct" : (status === "missing" ? "∅ Missing" : "✕ Incorrect"); return '' + label + ""; } var state = { mode: "corpus", corpus: [], corpusView: [], corpusIdx: 0, corpusTextIndex: {}, corpusTextCache: {}, corpusChunkIdx: 0, corpusTextSequence: 0, questions: [], evalView: [], evalIdx: 0, manifest: null, runs: {}, compare: null, }; /* ---------------- data loading ---------------- */ function parseJSONL(text) { var out = []; text.split("\n").forEach(function (line) { var trimmed = line.trim(); if (!trimmed) return; try { out.push(JSON.parse(trimmed)); } catch (e) { /* skip bad line */ } }); return out; } function fetchJSON(path) { return fetch(path).then(function (response) { if (!response.ok) throw new Error(path + ": HTTP " + response.status); return response.json(); }); } function loadAll() { return Promise.all([ fetchJSON("corpus_index.json"), fetch("financebench_open_source.jsonl").then(function (response) { if (!response.ok) throw new Error("financebench_open_source.jsonl: HTTP " + response.status); return response.text(); }), fetchJSON("corpus_text/index.json"), fetchJSON("runs/manifest.json"), ]).then(function (results) { state.corpus = results[0] || []; state.questions = parseJSONL(results[1]); (results[2].rows || []).forEach(function (row) { state.corpusTextIndex[row.doc_name] = row; }); state.manifest = results[3]; (state.manifest.runs || []).forEach(function (run) { RUN_REGISTRY[run.slot] = run; state.runs[run.slot] = { meta: run, index: null, view: [], idx: 0, cache: {}, }; }); }); } function isRunMode(mode) { return Object.prototype.hasOwnProperty.call(RUN_REGISTRY, mode); } function rememberQid(qid) { if (qid) window.TrajectoryUI.setQid(qid); } function findQidIndex(records) { var qid = window.TrajectoryUI.getQid(); if (!qid) return -1; return records.findIndex(function (record) { return (record.financebench_id || record.qid) === qid; }); } function loadRun(slot) { var runState = state.runs[slot]; if (runState.index) return Promise.resolve(runState); $("runCard").innerHTML = '
Loading ' + esc(runState.meta.label) + "…
"; return fetchJSON(runState.meta.index).then(function (index) { runState.index = index; runState.view = index.records || []; return runState; }); } function loadCompare() { if (state.compare) return Promise.resolve(state.compare); $("compareCard").innerHTML = '
Loading comparison…
'; return fetchJSON(state.manifest.compare.index).then(function (index) { state.compare = { index: index, view: index.records || [], idx: 0, cache: {}, }; renderCompareSummaries(); return state.compare; }); } function loadShard(cache, item) { if (cache[item.qid]) return Promise.resolve(cache[item.qid]); return fetchJSON(item.path).then(function (record) { cache[item.qid] = record; return record; }); } function loadCompressedJSON(path) { return fetch(path).then(function (response) { if (!response.ok) throw new Error(path + ": HTTP " + response.status); return response.text(); }).then(function (encoded) { var binary = atob(encoded.trim()); var bytes = new Uint8Array(binary.length); for (var i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i); if (typeof DecompressionStream === "undefined") { throw new Error("This browser cannot decompress FinanceBench text shards."); } var stream = new Blob([bytes]).stream().pipeThrough(new DecompressionStream("gzip")); return new Response(stream).text(); }).then(JSON.parse); } /* ---------------- corpus tab ---------------- */ function populateCorpusFilters() { var sectors = {}, types = {}; state.corpus.forEach(function (doc) { if (doc.gics_sector) sectors[doc.gics_sector] = true; if (doc.doc_type) types[doc.doc_type] = true; }); Object.keys(sectors).sort().forEach(function (sector) { var option = document.createElement("option"); option.value = sector; option.textContent = sector; $("sectorFilter").appendChild(option); }); Object.keys(types).sort().forEach(function (type) { var option = document.createElement("option"); option.value = type; option.textContent = type; $("docTypeFilter").appendChild(option); }); } function filterCorpus() { var query = $("corpusFilter").value.trim().toLowerCase(); var sector = $("sectorFilter").value; var type = $("docTypeFilter").value; state.corpusView = state.corpus.filter(function (doc) { if (sector && doc.gics_sector !== sector) return false; if (type && doc.doc_type !== type) return false; if (query) { var haystack = (doc.doc_name + " " + (doc.company || "")).toLowerCase(); if (haystack.indexOf(query) === -1) return false; } return true; }); if (state.corpusIdx >= state.corpusView.length) state.corpusIdx = 0; rebuildDocSelect(); renderCorpus(); } function rebuildDocSelect() { var select = $("docSelect"); select.innerHTML = ""; state.corpusView.forEach(function (doc, index) { var option = document.createElement("option"); option.value = String(index); option.textContent = doc.doc_name + (doc.company ? " · " + doc.company : ""); select.appendChild(option); }); select.value = String(state.corpusIdx); } function renderCorpus() { var meta = $("docMetaCard"); var textHost = $("docTextContent"); if (!state.corpusView.length) { meta.innerHTML = '
No documents match the filter.
'; textHost.innerHTML = ""; $("corpusCounter").textContent = "0 / 0"; return; } var doc = state.corpusView[state.corpusIdx]; $("docSelect").value = String(state.corpusIdx); $("corpusCounter").textContent = (state.corpusIdx + 1) + " / " + state.corpusView.length; var pills = []; if (doc.company) pills.push('' + esc(doc.company) + ""); if (doc.gics_sector) pills.push('Sector: ' + esc(doc.gics_sector) + ""); if (doc.doc_type) pills.push('Type: ' + esc(doc.doc_type) + ""); if (doc.doc_period) pills.push('Period: ' + esc(doc.doc_period) + ""); if (!doc.has_meta) pills.push('no metadata'); var link = doc.doc_link ? 'Official source ↗' : ""; var bundled = doc.pdf ? 'Open bundled PDF ↗' : ""; meta.innerHTML = "

" + esc(doc.doc_name) + "

" + '
' + pills.join("") + bundled + link + "
"; state.corpusChunkIdx = 0; textHost.innerHTML = '
Loading extracted filing text…
'; var indexRow = state.corpusTextIndex[doc.doc_name]; if (!indexRow) { textHost.innerHTML = '
No extracted text shard is available for this filing.
'; return; } var sequence = ++state.corpusTextSequence; var request = state.corpusTextCache[doc.doc_name] ? Promise.resolve(state.corpusTextCache[doc.doc_name]) : loadCompressedJSON("corpus_text/" + indexRow.path).then(function (record) { state.corpusTextCache[doc.doc_name] = record; return record; }); request.then(function (record) { if (sequence !== state.corpusTextSequence) return; renderCorpusText(record); }).catch(function (error) { textHost.innerHTML = '
Failed to load filing text: ' + esc(error) + "
"; }); } function renderCorpusText(record) { var chunks = record.chunks || []; if (!chunks.length) { $("docTextContent").innerHTML = '
This filing has no extracted chunks.
'; return; } if (state.corpusChunkIdx >= chunks.length) state.corpusChunkIdx = chunks.length - 1; var chunk = chunks[state.corpusChunkIdx]; var options = chunks.map(function (item, index) { var label = "Pages " + item.page_start + "–" + item.page_end; return '"; }).join(""); $("docTextContent").innerHTML = '
' + '" + '' + (state.corpusChunkIdx + 1) + " / " + chunks.length + "" + '
' + '
Pages ' + esc(chunk.page_start) + "–" + esc(chunk.page_end) + '' + esc(chunk.id) + "
" + '
' + esc(chunk.contents) + "
"; $("chunkSelect").addEventListener("change", function () { state.corpusChunkIdx = parseInt(this.value, 10) || 0; renderCorpusText(record); }); $("chunkPrevBtn").disabled = state.corpusChunkIdx === 0; $("chunkNextBtn").disabled = state.corpusChunkIdx === chunks.length - 1; $("chunkPrevBtn").addEventListener("click", function () { if (state.corpusChunkIdx > 0) { state.corpusChunkIdx--; renderCorpusText(record); } }); $("chunkNextBtn").addEventListener("click", function () { if (state.corpusChunkIdx < chunks.length - 1) { state.corpusChunkIdx++; renderCorpusText(record); } }); } function selectDocByName(name) { $("corpusFilter").value = ""; $("sectorFilter").value = ""; $("docTypeFilter").value = ""; state.corpusView = state.corpus.slice(); state.corpusIdx = 0; state.corpusView.some(function (doc, index) { if (doc.doc_name !== name) return false; state.corpusIdx = index; return true; }); rebuildDocSelect(); renderCorpus(); } /* ---------------- eval tab ---------------- */ function filterEval() { var query = $("evalSearch").value.trim().toLowerCase(); var type = $("qTypeFilter").value; state.evalView = state.questions.filter(function (question) { if (type && question.question_type !== type) return false; if (query) { var haystack = [ question.question, question.company, question.financebench_id, question.answer, question.doc_name, question.justification, ].join(" ").toLowerCase(); if (haystack.indexOf(query) === -1) return false; } return true; }); var target = findQidIndex(state.evalView); if (target >= 0) state.evalIdx = target; else if (state.evalIdx >= state.evalView.length) state.evalIdx = 0; renderEval(); } function selectEvalByQid(qid) { $("evalSearch").value = ""; $("qTypeFilter").value = ""; state.evalView = state.questions.slice(); state.evalIdx = 0; state.evalView.some(function (question, index) { if (question.financebench_id !== qid) return false; state.evalIdx = index; return true; }); setMode("eval"); renderEval(); } function renderEval() { var card = $("evalCard"); if (!state.evalView.length) { card.innerHTML = '
No questions match the search.
'; $("evalCounter").textContent = "0 / 0"; return; } var question = state.evalView[state.evalIdx]; rememberQid(question.financebench_id); $("evalCounter").textContent = (state.evalIdx + 1) + " / " + state.evalView.length; var typeClass = "type-" + (question.question_type || ""); var badges = '' + esc(question.financebench_id) + "" + (question.question_type ? '' + esc(question.question_type) + "" : "") + (question.company ? '' + esc(question.company) + "" : ""); var fields = ""; if (question.question_reasoning) fields += field("Reasoning type", esc(question.question_reasoning)); if (question.domain_question_num) fields += field("Domain question #", esc(question.domain_question_num)); fields += field( "Source document", '' + esc(question.doc_name) + " ↗" ); if (question.justification) fields += field("Justification", esc(question.justification)); var evidence = (question.evidence || []).map(function (item) { var head = '
page ' + esc(item.evidence_page_num) + "" + (item.doc_name ? "" + esc(item.doc_name) + "" : "") + "
"; var text = '
' + esc(item.evidence_text) + "
"; var full = ""; if (item.evidence_text_full_page && item.evidence_text_full_page !== item.evidence_text) { full = '
Show full page extract' + '
' + esc(item.evidence_text_full_page) + "
"; } return '
' + head + text + full + "
"; }).join(""); card.innerHTML = '
' + badges + "
" + "

" + esc(question.question) + "

" + window.TrajectoryUI.gold(question.answer, "Gold") + fields + field( "Evidence (" + (question.evidence || []).length + ")", evidence || 'none' ); wireContextLinks(card); } /* ---------------- run tabs ---------------- */ function buildRunTabs() { var host = $("runTabButtons"); host.innerHTML = ""; (state.manifest.runs || []).forEach(function (run) { var button = document.createElement("button"); button.type = "button"; button.dataset.mode = run.slot; button.textContent = run.label; button.style.setProperty("--tab-accent", run.accent); button.addEventListener("click", function () { activateMode(run.slot); }); host.appendChild(button); }); var compare = document.createElement("button"); compare.type = "button"; compare.dataset.mode = "compare"; compare.textContent = "Compare"; compare.style.setProperty("--tab-accent", "#fb7185"); compare.addEventListener("click", function () { activateMode("compare"); }); host.appendChild(compare); } function filterRun() { var runState = state.runs[state.mode]; if (!runState || !runState.index) return; var selected = runState.view[runState.idx] && runState.view[runState.idx].qid; var query = $("runSearch").value.trim().toLowerCase(); var status = $("runStatusFilter").value; runState.view = runState.index.records.filter(function (record) { if (status !== "all" && record.status !== status) return false; if (!query) return true; var haystack = [ record.qid, record.question, record.gold, record.prediction, record.company, record.doc_name, ].join(" ").toLowerCase(); return haystack.indexOf(query) !== -1; }); runState.idx = 0; var sharedIndex = findQidIndex(runState.view); if (sharedIndex >= 0) { runState.idx = sharedIndex; } else if (selected) { runState.view.some(function (record, index) { if (record.qid !== selected) return false; runState.idx = index; return true; }); } rebuildRunQidSelect(runState); renderRun(); } function rebuildRunQidSelect(runState) { var select = $("runQidSelect"); select.innerHTML = ""; runState.view.forEach(function (record, index) { var option = document.createElement("option"); option.value = String(index); option.textContent = record.qid + " · " + shorten(record.question, 72); select.appendChild(option); }); select.value = String(runState.idx); } function renderRunSummary(runState) { var meta = runState.meta; $("runSummary").style.setProperty("--run-accent", meta.accent); $("runSummary").innerHTML = '
' + esc(meta.label) + "" + '' + esc(meta.score.numerator) + "/" + esc(meta.score.denominator) + " · " + Number(meta.score.percent).toFixed(2) + "%
" + '
' + esc(meta.answered) + " answered · " + esc(meta.missing) + " missing · full-denominator score
"; } function renderRun() { var runState = state.runs[state.mode]; if (!runState || !runState.index) return; renderRunSummary(runState); if (!runState.view.length) { $("runCard").innerHTML = '
No records match these filters.
'; $("runCounter").textContent = "0 / 0"; $("runQidSelect").innerHTML = ""; return; } var item = runState.view[runState.idx]; $("runCounter").textContent = (runState.idx + 1) + " / " + runState.view.length; $("runQidSelect").value = String(runState.idx); $("runCard").innerHTML = '
Loading ' + esc(item.qid) + "…
"; var expectedMode = state.mode; loadShard(runState.cache, item).then(function (record) { if (state.mode !== expectedMode) return; var current = runState.view[runState.idx]; if (!current || current.qid !== record.qid) return; renderRunRecord(record); }).catch(function (error) { $("runCard").innerHTML = '
Failed to load record: ' + esc(error) + "
"; }); } function renderRunRecord(record) { rememberQid(record.qid); var metadata = record.metadata || {}; var isE2E = state.mode.indexOf("e2e") === 0; var badges = '' + esc(record.qid) + "" + statusBadge(record) + (metadata.company ? '' + esc(metadata.company) + "" : "") + (metadata.question_type ? '' + esc(metadata.question_type) + "" : "") + (metadata.question_reasoning ? '' + esc(metadata.question_reasoning) + "" : ""); var documentLink = metadata.doc_name ? 'Open ' + esc(metadata.doc_name) + " ↗" : ""; var links = '"; var prediction = record.answered ? '
' + esc(record.prediction) + "
" : '
No response was produced. This record counts as incorrect.
'; var judge = ""; if (record.extracted_answer !== null && record.extracted_answer !== undefined) { judge += field("Extracted judge answer", esc(record.extracted_answer)); } if (record.judge_confidence !== null && record.judge_confidence !== undefined) { judge += field("Judge confidence", esc(record.judge_confidence) + "%"); } if (record.judge_text) { judge += '
Judge details' + '
' + esc(record.judge_text) + "
"; } var operational = '
' + metric("Stop", record.stop_reason) + metric("Finish", record.finish_reason) + metric("Turns", record.turns) + metric("Tools", formatPairs(record.tool_counts), "", true) + metric("Tokens", formatPairs(record.token_usage), "wide", true) + (record.failure_reason ? metric("Failure", record.failure_reason, "wide failure") : "") + "
"; $("runCard").innerHTML = '
' + badges + "
" + "

" + esc(record.question) + "

" + links + window.TrajectoryUI.gold(record.gold, "Gold") + (isE2E && documentLink ? window.TrajectoryUI.supporting("Supporting filing", documentLink) : "") + field("Prediction", prediction) + judge + field("Run details", operational) + renderTrajectory(record.events || []); wireContextLinks($("runCard")); window.TrajectoryUI.bind($("runCard")); } function metric(label, value, cls, isHtml) { var display = value === null || value === undefined || value === "" ? "—" : value; return '
' + esc(label) + "
" + (isHtml ? display : esc(display)) + "
"; } function renderTrajectory(events) { return window.TrajectoryUI.render(events, "Agent trajectory"); } /* ---------------- comparison tab ---------------- */ function renderCompareSummaries() { if (!state.compare) return; $("compareSummaries").innerHTML = state.compare.index.runs.map(function (run) { return '
' + '
' + esc(run.label) + "
" + '
' + esc(run.score.numerator) + "/" + esc(run.score.denominator) + " " + Number(run.score.percent).toFixed(2) + "%
" + '
' + esc(run.answered) + " answered · " + esc(run.missing) + " missing
"; }).join(""); } function filterCompare() { if (!state.compare) return; var selected = state.compare.view[state.compare.idx] && state.compare.view[state.compare.idx].qid; var query = $("compareSearch").value.trim().toLowerCase(); var filter = $("compareFilter").value; state.compare.view = state.compare.index.records.filter(function (record) { if (filter === "disagreement" && !record.flags.disagreement) return false; if (filter === "missing" && !record.flags.any_missing) return false; if (filter === "e2e-only" && !record.flags.only_e2e_correct) return false; if (!query) return true; return [record.qid, record.question, record.company].join(" ").toLowerCase().indexOf(query) !== -1; }); state.compare.idx = 0; var sharedIndex = findQidIndex(state.compare.view); if (sharedIndex >= 0) { state.compare.idx = sharedIndex; } else if (selected) { state.compare.view.some(function (record, index) { if (record.qid !== selected) return false; state.compare.idx = index; return true; }); } rebuildCompareQidSelect(); renderCompare(); } function rebuildCompareQidSelect() { var select = $("compareQidSelect"); select.innerHTML = ""; state.compare.view.forEach(function (record, index) { var option = document.createElement("option"); option.value = String(index); option.textContent = record.qid + " · " + shorten(record.question, 72); select.appendChild(option); }); select.value = String(state.compare.idx); } function renderCompare() { if (!state.compare) return; if (!state.compare.view.length) { $("compareCard").innerHTML = '
No questions match this comparison filter.
'; $("compareCounter").textContent = "0 / 0"; $("compareQidSelect").innerHTML = ""; return; } var item = state.compare.view[state.compare.idx]; $("compareCounter").textContent = (state.compare.idx + 1) + " / " + state.compare.view.length; $("compareQidSelect").value = String(state.compare.idx); $("compareCard").innerHTML = '
Loading ' + esc(item.qid) + "…
"; loadShard(state.compare.cache, item).then(function (record) { if (state.mode !== "compare") return; var current = state.compare.view[state.compare.idx]; if (!current || current.qid !== record.qid) return; renderCompareRecord(record); }).catch(function (error) { $("compareCard").innerHTML = '
Failed to load record: ' + esc(error) + "
"; }); } function renderCompareRecord(record) { rememberQid(record.qid); var metadata = record.metadata || {}; var badges = '' + esc(record.qid) + "" + (metadata.company ? '' + esc(metadata.company) + "" : "") + (metadata.question_reasoning ? '' + esc(metadata.question_reasoning) + "" : "") + (record.flags.disagreement ? 'disagreement' : "") + (record.flags.any_missing ? 'any missing' : ""); var links = '"; var columns = state.compare.index.runs.map(function (run) { var value = record.runs[run.slot]; var prediction = value.answered ? '
' + esc(value.prediction) + "
" : '
No response; counted incorrect.
'; var details = []; if (value.extracted_answer !== null && value.extracted_answer !== undefined) { details.push("Extracted: " + esc(value.extracted_answer)); } if (value.judge_confidence !== null && value.judge_confidence !== undefined) { details.push("Confidence: " + esc(value.judge_confidence) + "%"); } if (value.stop_reason || value.finish_reason) { details.push("Stop / finish: " + esc(value.stop_reason || "—") + " / " + esc(value.finish_reason || "—")); } if (value.failure_reason) details.push("Failure: " + esc(value.failure_reason)); return '
' + '

' + esc(run.label) + "

" + statusBadge(value) + "
" + prediction + (details.length ? '
' + details.join("
") + "
" : "") + "
"; }).join(""); $("compareCard").innerHTML = '
' + badges + "
" + "

" + esc(record.question) + "

" + links + window.TrajectoryUI.gold(record.gold, "Gold") + "
" + '
' + columns + "
"; wireContextLinks($("compareCard")); } /* ---------------- mode switching and links ---------------- */ function wireContextLinks(container) { Array.prototype.forEach.call(container.querySelectorAll("[data-doc]"), function (link) { link.addEventListener("click", function () { setMode("corpus"); selectDocByName(this.getAttribute("data-doc")); }); }); Array.prototype.forEach.call(container.querySelectorAll("[data-eval-qid]"), function (link) { link.addEventListener("click", function () { selectEvalByQid(this.getAttribute("data-eval-qid")); }); }); } function setMode(mode) { var previousMode = state.mode; var leftStructures = Boolean(window.__e2eStructuresJustClosed); window.__e2eStructuresJustClosed = false; state.mode = mode; if (mode === "eval" && (previousMode !== "eval" || leftStructures)) { $("evalSearch").value = ""; $("qTypeFilter").value = ""; state.evalView = state.questions.slice(); } if (mode === "eval" && state.evalView.length) { var sharedIndex = findQidIndex(state.evalView); if (sharedIndex >= 0) state.evalIdx = sharedIndex; } Array.prototype.forEach.call($("viewToggle").querySelectorAll("[data-mode]"), function (button) { button.classList.toggle("active", button.dataset.mode === mode); }); $("corpusControls").style.display = mode === "corpus" ? "" : "none"; $("evalControls").style.display = mode === "eval" ? "" : "none"; $("runControls").style.display = isRunMode(mode) ? "" : "none"; $("compareControls").style.display = mode === "compare" ? "" : "none"; $("corpusView").style.display = mode === "corpus" ? "flex" : "none"; $("evalView").style.display = mode === "eval" ? "block" : "none"; $("runView").style.display = isRunMode(mode) ? "block" : "none"; $("compareView").style.display = mode === "compare" ? "block" : "none"; if (mode === "eval" && state.evalView.length) renderEval(); } function activateMode(mode) { setMode(mode); if (isRunMode(mode)) { loadRun(mode).then(function () { if (state.mode !== mode) return; $("runSearch").value = ""; $("runStatusFilter").value = "all"; filterRun(); }).catch(showLoadError); } else if (mode === "compare") { loadCompare().then(function () { if (state.mode !== "compare") return; $("compareSearch").value = ""; $("compareFilter").value = "all"; filterCompare(); }).catch(showLoadError); } } function showLoadError(error) { var target = state.mode === "compare" ? $("compareCard") : $("runCard"); target.innerHTML = '
Failed to load data: ' + esc(error) + "
"; } /* ---------------- wiring ---------------- */ function wire() { $("modeCorpusBtn").addEventListener("click", function () { setMode("corpus"); }); $("modeEvalBtn").addEventListener("click", function () { setMode("eval"); }); $("corpusFilter").addEventListener("input", filterCorpus); $("sectorFilter").addEventListener("change", filterCorpus); $("docTypeFilter").addEventListener("change", filterCorpus); $("docSelect").addEventListener("change", function () { state.corpusIdx = parseInt(this.value, 10) || 0; renderCorpus(); }); $("corpusPrevBtn").addEventListener("click", function () { if (state.corpusIdx > 0) { state.corpusIdx--; renderCorpus(); } }); $("corpusNextBtn").addEventListener("click", function () { if (state.corpusIdx < state.corpusView.length - 1) { state.corpusIdx++; renderCorpus(); } }); $("evalSearchBtn").addEventListener("click", filterEval); $("evalSearch").addEventListener("keydown", function (event) { if (event.key === "Enter") filterEval(); }); $("evalClearBtn").addEventListener("click", function () { $("evalSearch").value = ""; $("qTypeFilter").value = ""; filterEval(); }); $("qTypeFilter").addEventListener("change", filterEval); $("evalPrevBtn").addEventListener("click", function () { if (state.evalIdx > 0) { state.evalIdx--; renderEval(); } }); $("evalNextBtn").addEventListener("click", function () { if (state.evalIdx < state.evalView.length - 1) { state.evalIdx++; renderEval(); } }); $("runSearch").addEventListener("input", filterRun); $("runStatusFilter").addEventListener("change", filterRun); $("runQidSelect").addEventListener("change", function () { var runState = state.runs[state.mode]; runState.idx = parseInt(this.value, 10) || 0; renderRun(); }); $("runPrevBtn").addEventListener("click", function () { var runState = state.runs[state.mode]; if (runState && runState.idx > 0) { runState.idx--; renderRun(); } }); $("runNextBtn").addEventListener("click", function () { var runState = state.runs[state.mode]; if (runState && runState.idx < runState.view.length - 1) { runState.idx++; renderRun(); } }); $("compareSearch").addEventListener("input", filterCompare); $("compareFilter").addEventListener("change", filterCompare); $("compareQidSelect").addEventListener("change", function () { state.compare.idx = parseInt(this.value, 10) || 0; renderCompare(); }); $("comparePrevBtn").addEventListener("click", function () { if (state.compare && state.compare.idx > 0) { state.compare.idx--; renderCompare(); } }); $("compareNextBtn").addEventListener("click", function () { if (state.compare && state.compare.idx < state.compare.view.length - 1) { state.compare.idx++; renderCompare(); } }); document.addEventListener("keydown", function (event) { var tag = (event.target.tagName || "").toLowerCase(); if (tag === "input" || tag === "select" || tag === "textarea") return; if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return; var direction = event.key === "ArrowLeft" ? "Prev" : "Next"; if (state.mode === "corpus") $("corpus" + direction + "Btn").click(); else if (state.mode === "eval") $("eval" + direction + "Btn").click(); else if (state.mode === "compare") $("compare" + direction + "Btn").click(); else if (isRunMode(state.mode)) $("run" + direction + "Btn").click(); }); } /* ---------------- boot ---------------- */ loadAll().then(function () { $("loading").style.display = "none"; $("sidebarFooter").innerHTML = state.corpus.length + " documents · " + state.questions.length + " questions
" + "Run scores use all " + esc(state.manifest.denominator) + " questions.
" + 'FinanceBench · ' + 'HF dataset'; populateCorpusFilters(); buildRunTabs(); wire(); setMode("corpus"); filterCorpus(); filterEval(); }).catch(function (error) { $("loading").textContent = "Failed to load data: " + error; }); })();