import { sectionOrder } from "./section-order.mjs"; const choices = Object.freeze({ filter: Object.freeze(["all", "waiting", "connections"]), context: Object.freeze(["source", "work", "action"]), }); export function createState() { return { filter: "waiting", context: "source" }; } export function selectState(state, key, value) { const allowed = Object.hasOwn(choices, key) && choices[key].includes(value); return allowed ? { ...state, [key]: value } : { ...state }; } export function isCaptureMode(search) { return new URLSearchParams(search).get("capture") === "1"; } export function getCaptureSection(search) { const section = new URLSearchParams(search).get("section"); return isCaptureMode(search) && sectionOrder.includes(section) ? section : null; }