import { esc, table } from "./ui.js"; export function versionFromHash(hash) { const id = hash.split("/")[2]; return /^(001|002|003|004|005|006)$/.test(id) ? id : "006"; } function rows(headers, values, className = "") { return table( headers, values.map((row) => `${row.map((v) => `${esc(v)}`).join("")}`), "synth-table synth-version-table " + (headers.length === 2 ? "synth-facts-table " : "") + className, ); } export function versionDetail(version, history) { const detail = history.versions.find((v) => v.id === version.id); return `

V${esc(version.id)} · ${esc(version.title)}

${esc(version.state)}

${esc(detail.delta)}

${detail.groups.map((group) => `

${esc(group.title)}

${rows(group.headers, group.rows)}${(group.notes || []).map((note) => `

${esc(note)}

`).join("")}
`).join("")}
使用边界与来源${detail.references?.length ? `` : ""}
`; } export function versionsView(content, history, selected) { const version = content.versions.find((v) => v.id === selected); return `

版本对照

${rows(["版本", "改变什么", "RGB", "深度", "覆盖与边界"], history.comparison, "synth-version-overview")}
数据版本、渲染批次、执行修订${rows(["层级", "例子", "含义"], history.naming)}
${versionDetail(version, history)}
`; }