"use strict"; (() => { const editable = "h1,h2,h3,p,strong,summary,label,button,small,figcaption,svg text"; const protectedAreas = "#run,#matching-query-form input,#encoder-values,#encoder-phrase,#results,#bridge-product,#bridge-adjustment,#bridge-score,#matching-detail,#bridge-calculation,#bridge-prompt,#bridge-region,#sigmoid-chart,#scene-panel .scene-footer,#status,#filename,#runtime,#matching-query-status,.architecture-input,select,option"; let edits = {}, enabled = false, selected = null, selectedKey = null; function keyFor(node) { const parts = []; for (let current = node; current && current !== document.body; current = current.parentElement) { if (current.id) {parts.unshift(`#${CSS.escape(current.id)}`); break;} const siblings = [...current.parentElement.children].filter(sibling => sibling.tagName === current.tagName); parts.unshift(`${current.localName}:nth-of-type(${siblings.indexOf(current) + 1})`); } let context = ""; if (["view-title", "view-copy", "view-reading"].includes(node.id)) context = document.querySelector("[data-view][aria-selected='true']")?.dataset.view || "matching"; if (node.id.startsWith("architecture-description-")) context = document.querySelector("[data-architecture-component].described")?.dataset.componentName || "default"; return `${parts.join(" > ")}||${context}`; } function targets() { return [...document.querySelectorAll(editable)].filter(node => !node.closest("#text-editor") && !node.closest(protectedAreas) && !node.querySelector("input,select,canvas,svg,img") && !node.querySelector(editable)); } function applyEdits() { for (const node of targets()) { const key = keyFor(node); if (Object.hasOwn(edits, key) && node.textContent !== edits[key]) node.textContent = edits[key]; } } // Saved copy also applies when the editing controls are disabled. fetch("/api/text-edits").then(response => { if (!response.ok) throw new Error("Could not load saved text."); return response.json(); }).then(value => {edits = value; applyEdits();}).catch(error => {if (message) message.textContent = error.message;}); const observer = new MutationObserver(applyEdits); observer.observe(document.querySelector("main"), {childList:true, subtree:true, characterData:true}); let message = null; if (document.getElementById("text-editor-script").dataset.enabled !== "true") return; const panel = document.createElement("aside"); panel.id = "text-editor"; panel.innerHTML = '
Click the text you want to change. Turn editing off to use the app.