// THE SLUR FILTER (operator, 3 Nov: "add a censor-slurs feature ... that can // be turned off for an uncensored cut -- black out the visual and skip the // word in narration, or maybe replace it with a TOS friendly but similar // placeholder visually distinct on the tweet"). umtool/docs/knobs.md, "The // slur filter". // // Built on the REDACTION (post-redact.mjs): like it, it changes only what is // PUBLISHED -- the rendered card, the read a voice synthesizes or the take // that plays, a chapter line, an attachment's burnt-in captions -- and never // the archive's rows, the manifest's snapshot or a script. Unlike it, it is a // LIST OF SLURS shipped as data (slurs.json: each slur's forms, a level, its // masked form and its spoken stand-in), matched whole-word and without case, // through the common ways of writing one past a filter (a letter swapped for // a look-alike -- "@" for a, "0" for o, "*" for a vowel -- or the word spelt // out letter by letter with a space, dot, dash or underscore between). // // render.posts.slurs = { // on?: true (default) | false false: the uncensored cut // level?: "all" (default) | "strong" strong: only the strong slurs // add?: ["" | {word, forms?, mask?, say?}] the project's own (always masked) // except?: ["
"] never masked in this project // edges?: [""] those slurs EDGE-masked: every form its first letter, stars, its // last letter, in the case written ("n***a" is not "-er") // visual?: "placeholder" (default) a dark pill with the masked form ("f*****") // | "blackout" the redaction's solid bar // voice?: "beep" (default) said, and a tone laid over it at its time // | "skip" left out of a synthesized read // | "placeholder" its stand-in said instead ("f-slur") // (the operator's choice, 3 Nov: "pill + beep" -- "skip seems like it'd be unnatural") // } // // THE SWITCH: `on: false` -- a take's patch (`umtool take

… --uncensored`) // or build-video's --uncensored -- renders the same cut with the slurs left as // they are. The redaction (private words) and an attachment's censoring are // NOT part of it: they stay on. // // PURE and dependency-free (post-redact.mjs builds on it; the readers hand it // the list, post-redact-files.mjs). export const SLUR_LEVELS = Object.freeze(["all", "strong"]); export const SLUR_VISUALS = Object.freeze(["blackout", "placeholder"]); export const SLUR_VOICES = Object.freeze(["skip", "beep", "placeholder"]); export const SLURS_DEFAULTS = Object.freeze({ on: true, level: "all", visual: "placeholder", voice: "beep" }); export const SLUR_LIST_LEVELS = Object.freeze(["strong", "mild"]); export const SLURS_ADD_MAX = 100; export const SLUR_KEYS = Object.freeze(["on", "level", "add", "except", "edges", "visual", "voice", "note"]); /** The redaction's mark (post-redact.mjs REDACT_MARK): a blacked-out slur is drawn as its bar. */ export const BLACKOUT_MARK = ""; /** A slur's second and later letters spelt apart ("f a g …"): kept as a token so the card's word indices hold, drawn as nothing. */ export const SLUR_GAP = ""; /** A placeholder's characters, each moved into the private-use area (U+E100 + its ASCII code): never typed, decoded only where drawn. */ const PH_BASE = 0xe100; export const PLACEHOLDER_RE = /[-]+/g; const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v); const str = (v) => (typeof v === "string" ? v : ""); const lc = (v) => str(v).trim().toLowerCase(); const WORD_RE = /^[a-z]{2,40}$/; const MASK_RE = /^[\x21-\x7E]{1,40}$/; // --------------------------------------------------------------------------- // The list. // --------------------------------------------------------------------------- /** Every reason a slur list document (slurs.json's shape) is refused. */ export function slurListErrors(doc, where = "slurs.json") { if (!isObj(doc) || !Array.isArray(doc.entries)) return [`${where} must be {entries: [{id, level, word, forms, say}]}`]; const errors = []; const ids = new Set(); doc.entries.forEach((e, i) => { const w = `${where} entries[${i}]`; if (!isObj(e)) return errors.push(`${w} must be an object`); if (typeof e.id !== "string" || !/^[a-z0-9-]{1,40}$/.test(e.id) || ids.has(e.id)) errors.push(`${w}.id must be a unique short id`); ids.add(e.id); if (!SLUR_LIST_LEVELS.includes(e.level)) errors.push(`${w}.level must be ${SLUR_LIST_LEVELS.join(" or ")}`); if (!WORD_RE.test(str(e.word))) errors.push(`${w}.word must be lower-case letters`); if (!Array.isArray(e.forms) || !e.forms.length || !e.forms.every((f) => WORD_RE.test(str(f)))) errors.push(`${w}.forms must be a list of lower-case words`); if (e.mask !== undefined && !MASK_RE.test(str(e.mask))) errors.push(`${w}.mask must be printable ASCII, no spaces`); if (typeof e.say !== "string" || !e.say.trim() || e.say.length > 40) errors.push(`${w}.say must be the words said in its place`); }); return errors; } /** A project's added slur as an entry of the list (a bare word: that word alone, its default mask, said "slur"). */ function addedEntry(a) { const x = typeof a === "string" ? { word: a } : a; const word = lc(x?.word); const forms = Array.isArray(x?.forms) && x.forms.length ? x.forms.map(lc) : [word]; return { id: `add:${word}`, level: "strong", word, forms: forms.includes(word) ? forms : [word, ...forms], mask: x?.mask ? x.mask : maskOfOwnWord(word), say: str(x?.say).trim() || "slur", added: true }; } /** * THE FILTER this cut publishes with: `render.posts.slurs` over the list -- * `{ on, level, visual, voice, entries }`, the entries those of the level * (strong, or strong and mild), the project's additions, the exceptions taken * out (a form, a slur's word or its id). `uncensored` turns it off (the * entries kept: what WOULD be masked is still known). * * @param {Record|undefined} cfg render.posts.slurs * @param {{ entries: any[] }|null|undefined} list the default list (slurs.json) * @param {{ uncensored?: boolean }} [o] */ export function resolveSlurs(cfg, list, { uncensored = false } = {}) { const c = isObj(cfg) ? cfg : {}; const level = SLUR_LEVELS.includes(c.level) ? c.level : SLURS_DEFAULTS.level; const ex = new Set((Array.isArray(c.except) ? c.except : []).map(lc).filter(Boolean)); const edges = new Set((Array.isArray(c.edges) ? c.edges : []).map(lc).filter(Boolean)); // An edge names a slur by its word, its id or any of its forms: the whole slur is edge-masked. const edged = (e) => edges.size > 0 && (edges.has(e.id) || edges.has(e.word) || e.forms.some((f) => edges.has(f))); const base = (Array.isArray(list?.entries) ? list.entries : []).filter((e) => level === "all" || e.level === "strong"); const added = (Array.isArray(c.add) ? c.add : []).filter((a) => WORD_RE.test(lc(typeof a === "string" ? a : a?.word))).map(addedEntry); const entries = [...base, ...added] .filter((e) => !ex.has(e.id) && !ex.has(e.word)) .map((e) => ({ id: e.id, level: e.level, word: e.word, forms: e.forms.filter((f) => !ex.has(f)), mask: e.mask ?? maskOfWord(e.word), say: e.say, ...(e.added ? { added: true } : {}), ...(edged(e) ? { edge: true } : {}) })) .filter((e) => e.forms.length); return { on: !uncensored && c.on !== false, level, visual: SLUR_VISUALS.includes(c.visual) ? c.visual : SLURS_DEFAULTS.visual, voice: SLUR_VOICES.includes(c.voice) ? c.voice : SLURS_DEFAULTS.voice, entries, ...(uncensored ? { uncensored: true } : {}), }; } /** Does the filter mask anything? */ export const slursOn = (s) => !!s && s.on === true && Array.isArray(s.entries) && s.entries.length > 0; /** Every reason `render.posts.slurs` is refused. */ export function validateSlursRender(s, where = "render.posts.slurs") { if (s === undefined) return []; if (!isObj(s)) return [`${where} must be {on?, level?, add?, except?, edges?, visual?, voice?}`]; const errors = []; for (const k of Object.keys(s)) if (!SLUR_KEYS.includes(k)) errors.push(`${where}.${k} is not a knob of the slur filter (${SLUR_KEYS.join(", ")})`); if (s.on !== undefined && typeof s.on !== "boolean") errors.push(`${where}.on must be true or false`); if (s.level !== undefined && !SLUR_LEVELS.includes(s.level)) errors.push(`${where}.level must be one of ${SLUR_LEVELS.join(", ")}`); if (s.visual !== undefined && !SLUR_VISUALS.includes(s.visual)) errors.push(`${where}.visual must be one of ${SLUR_VISUALS.join(", ")}`); if (s.voice !== undefined && !SLUR_VOICES.includes(s.voice)) errors.push(`${where}.voice must be one of ${SLUR_VOICES.join(", ")}`); if (s.note !== undefined && typeof s.note !== "string") errors.push(`${where}.note must be words`); for (const key of ["add", "except", "edges"]) { const list = s[key]; if (list === undefined) continue; if (!Array.isArray(list) || list.length > SLURS_ADD_MAX) { errors.push(`${where}.${key} must be a list of at most ${SLURS_ADD_MAX} words`); continue; } list.forEach((a, i) => { const w = `${where}.${key}[${i}]`; if (key !== "add" || typeof a === "string") { if (typeof a !== "string" || !/^[a-z0-9-]{2,40}$/.test(lc(a))) errors.push(`${w} must be a word (letters, 2–40)`); return; } if (!isObj(a)) return errors.push(`${w} must be a word or {word, forms?, mask?, say?}`); for (const k of Object.keys(a)) if (!["word", "forms", "mask", "say"].includes(k)) errors.push(`${w}.${k} is not a key of an added slur (word, forms, mask, say)`); if (!WORD_RE.test(lc(a.word))) errors.push(`${w}.word must be a word (letters, 2–40)`); if (a.forms !== undefined && !(Array.isArray(a.forms) && a.forms.length <= 20 && a.forms.every((f) => WORD_RE.test(lc(f))))) errors.push(`${w}.forms must be a list of words`); if (a.mask !== undefined && !MASK_RE.test(str(a.mask))) errors.push(`${w}.mask must be printable ASCII, no spaces`); if (a.say !== undefined && !(typeof a.say === "string" && a.say.length <= 40)) errors.push(`${w}.say must be words (at most 40 characters)`); }); } return errors; } // --------------------------------------------------------------------------- // The matcher. // --------------------------------------------------------------------------- /** The look-alikes a letter may be written as (a filter-dodger's spellings): "*" stands in for a vowel only. */ const SWAPS = Object.freeze({ a: "a@4*", e: "e3*", i: "i1!*", o: "o0*", u: "u*", s: "s$5", t: "t7", l: "l1" }); /** What may sit between the letters of a word spelt out ("f a g …", "f.a.g", "f-a-g"): one, between every pair. */ const SPELT_SEP = "[ .\\-_]"; const escRe = (s) => s.replace(/[.*+?^${}()|[\]\\/-]/g, "\\$&"); const letterRe = (c) => (SWAPS[c] ? `[${SWAPS[c].replace(/[\]\\^-]/g, "\\$&")}]` : escRe(c)); /** One form's pattern: its letters (each with its look-alikes), together or spelt out (three letters or more). */ export function formPattern(form) { const letters = [...lc(form)].map(letterRe); const together = letters.join(""); return letters.length >= 3 ? `(?:${together}|${letters.join(SPELT_SEP)})` : together; } const COMPILED = new WeakMap(); /** The filter's one pattern (a capture group per slur, its forms longest first), or null. */ function compiled(s) { if (!s || !Array.isArray(s.entries) || !s.entries.length) return null; const hit = COMPILED.get(s); if (hit) return hit; const groups = s.entries.map((e) => `(${[...e.forms].sort((a, b) => b.length - a.length).map(formPattern).join("|")})`); const re = new RegExp(`(? x !== undefined); out.push({ start: m.index, end: m.index + m[0].length, id: s.entries[g]?.id ?? null }); } return out; } /** A slur's entry in the filter. */ export const slurEntryOf = (s, id) => (Array.isArray(s?.entries) ? s.entries.find((e) => e.id === id) ?? null : null); /** A word's default masked form: its first letter, an asterisk for each other. */ /** A project's own word (a name kept off the card, most often) is masked whole: no first letter to spell it. */ export const maskOfOwnWord = (word) => "*".repeat(Math.max(1, str(word).length)); export const maskOfWord = (word) => (str(word) ? `${str(word)[0]}${"*".repeat(Math.max(1, str(word).length - 1))}` : "*"); /** A slur as written with a spelt-apart word's separators gone: one character per letter (a look-alike is one too). */ const lettersOf = (matched) => str(matched).replace(/[\s.\-_]/g, ""); const isUpper = (c) => /\p{L}/u.test(c) && c !== c.toLowerCase(); const isLower = (c) => /\p{L}/u.test(c) && c !== c.toUpperCase(); /** * An EDGE mask (`render.posts.slurs.edges`): the form as written, its first * letter, an asterisk for each letter between, its last letter -- each end the * form's own letter (a look-alike, "@" or "0", read back as the letter it * stands for) in the case the text wrote it; a look-alike at an end follows * the word's case (upper only when every letter is). Two letters: the first * and one asterisk. * * @param {{ forms?: string[], mask?: string } | null | undefined} entry * @param {string} matched the slur as the text wrote it */ export function edgeMask(entry, matched) { const w = lettersOf(matched); if (w.length < 2) return entry?.mask ?? "*****"; const forms = Array.isArray(entry?.forms) ? entry.forms : []; const form = forms.find((f) => f.length === w.length && new RegExp(`^${[...f].map(letterRe).join("")}$`, "iu").test(w)) ?? w.toLowerCase(); const letters = [...w].filter((c) => /\p{L}/u.test(c)); const allUpper = letters.length > 1 && letters.every(isUpper); const at = (i) => { const c = form[i]; const as = w[i]; return isUpper(as) || (!isLower(as) && !isUpper(as) && allUpper) ? c.toUpperCase() : c.toLowerCase(); }; return w.length === 2 ? `${at(0)}*` : `${at(0)}${"*".repeat(w.length - 2)}${at(w.length - 1)}`; } /** * THE MASK A HIT IS DRAWN AS -- the one source for every place a mask is * shown (the card's pill, Play, the bench, a chapter line, a burnt-in * caption, `posts slurs ls`): an edged slur's edge mask (edgeMask); else the * slur's mask, its first letter in the case the text wrote it. * * @param {{ mask?: string, edge?: boolean, forms?: string[] } | null | undefined} entry the slur's entry in the filter (resolveSlurs) * @param {string} matched the slur as the text wrote it */ export function maskOfHit(entry, matched) { if (entry?.edge && lettersOf(matched).length >= 2) return edgeMask(entry, matched); const mask = entry?.mask ?? "*****"; const first = str(matched)[0] ?? ""; return first && first !== first.toLowerCase() && /\p{L}/u.test(first) ? mask[0].toUpperCase() + mask.slice(1) : mask; } /** The masked form a hit is drawn as (maskOfHit, its entry found in the filter). */ export const maskFor = (s, hit, matched) => maskOfHit(slurEntryOf(s, hit.id), matched); /** The words a read says in a hit's place (voice placeholder). */ export const sayFor = (s, hit) => slurEntryOf(s, hit.id)?.say ?? "slur"; /** A mask moved into the private-use area (one character each), decoded only where it is drawn. */ export const encodePlaceholder = (mask) => [...str(mask)].map((c) => String.fromCharCode(PH_BASE + Math.min(0x7e, Math.max(0x21, c.charCodeAt(0))))).join(""); /** And back. */ export const decodePlaceholder = (marked) => str(marked).replace(PLACEHOLDER_RE, (run) => [...run].map((c) => String.fromCharCode(c.charCodeAt(0) - PH_BASE)).join("")); /** Does `text` hold a masked slur (a placeholder or a gap)? */ export const hasSlurMarks = (text) => /[-]/.test(str(text)); /** * `text` with every slur MASKED as the card draws it: `visual` blackout, the * redaction's mark for each letter (a bar of its width); placeholder, the * mask in the private-use area. A slur spelt apart keeps its tokens (the * card's word indices hold): the first holds the mark, the others a gap * drawn as nothing. Returns `{ text, hits }`. */ export function maskSlurs(text, s, visual = s?.visual ?? SLURS_DEFAULTS.visual) { const t = str(text); const hits = slursOn(s) ? slurMatches(t, s) : []; if (!hits.length) return { text: t, hits }; let out = ""; let at = 0; for (const h of hits) { out += t.slice(at, h.start); const seg = t.slice(h.start, h.end); let first = true; for (const p of seg.split(/(\s+)/)) { if (!p) continue; if (/^\s+$/.test(p)) out += p; else if (first) { out += visual === "placeholder" ? encodePlaceholder(maskFor(s, h, seg)) : BLACKOUT_MARK.repeat(seg.replace(/\s/g, "").length); first = false; } else out += SLUR_GAP; } at = h.end; } return { text: out + t.slice(at), hits }; } /** HTML (already escaped) with each placeholder drawn as the censor pill and each gap as nothing. */ export const placeholdersHtml = (html) => str(html) .replace(//g, "") .replace(PLACEHOLDER_RE, (run) => `${decodePlaceholder(run).replace(/&/g, "&").replace(//g, ">")}`); /** The pill's CSS: a dark capsule, the mask in the card's colour, spaced a little -- not to be read as the post's own letters. */ export const SLUR_CSS = (fg) => `.slur { display: inline-block; padding: 0 0.32em; border-radius: 0.5em; background: #0b0b0b; color: ${fg}; box-shadow: inset 0 0 0 0.06em rgba(255,255,255,0.28); letter-spacing: 0.08em; font-size: 0.86em; line-height: 1.25; vertical-align: 0.04em; }`; // --------------------------------------------------------------------------- // The voice. // --------------------------------------------------------------------------- /** A word reduced as word-zoom.mjs normWord does (lower case, its edge punctuation gone). */ const normWord = (w) => str(w).toLowerCase().normalize("NFKC").replace(/[‘’]/g, "'").replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, ""); /** A script's spoken words with their offsets: word-zoom.mjs scriptWordsOf's words (a take's `words` are one per each), in order. */ export function scriptTokens(script) { const clean = str(script).replace(/<[^<>]*>/g, (m) => " ".repeat(m.length)); const out = []; for (const m of clean.matchAll(/\S+/g)) if (normWord(m[0])) out.push({ w: m[0], start: m.index, end: m.index + m[0].length }); return out; } /** Each take's slur state: what its audio does with the slurs its script holds. Absent: it says them (a recording; a take from before the filter). */ export const TAKE_SLUR_STATES = Object.freeze(["said", "skip", "placeholder"]); /** The before/after pad of a beep or a mute around the word, seconds. */ export const SLUR_BLEEP_PAD = Object.freeze({ before: 0.04, after: 0.06 }); /** The beep: a sine at this pitch and amplitude, under the narrator's chain. */ export const SLUR_BEEP = Object.freeze({ hz: 1000, amp: 0.18 }); /** * A TAKE's slurs to cover, in take seconds: `{ mode: "beep" | "mute", spans: * [[from, to]] }` (beep: the voice's choice beep or placeholder -- a * recorded take cannot say a stand-in; mute: skip), null when there is none * (the filter off, the take's audio leaves them out, its script holds none), * or `{ error }` when the take says one and has no word timings to find it by. * * @param {{ script?: string, words?: Array<{w: string, start: number, end: number}>, slurs?: string, file?: string, seconds?: number }} take * @param {ReturnType | null | undefined} s * @param {{ script?: string, state?: string | null }} [o] the script it read (default its own), its state (default its own) */ export function takeBleeps(take, s, { script = undefined, state = undefined } = {}) { if (!slursOn(s) || !take) return null; const st = state ?? take.slurs ?? "said"; if (st !== "said") return null; const text = str(script ?? take.script); const hits = slurMatches(text, s); if (!hits.length) return null; const words = Array.isArray(take.words) ? take.words : []; const toks = scriptTokens(text); const masks = [...new Set(hits.map((h) => maskFor(s, h, text.slice(h.start, h.end).toLowerCase())))].join(", "); if (!words.length) return { error: `its take ${take.file ?? ""} says ${hits.length} slur(s) (${masks}) and has no word timings to ${s.voice === "skip" ? "silence" : "beep"} them by` }; if (words.length !== toks.length) return { error: `its take ${take.file ?? ""}'s word timings are not of its script (${words.length} timed, ${toks.length} in the script)` }; const spans = []; for (const h of hits) { const ks = toks.map((t, k) => (t.end > h.start && t.start < h.end ? k : -1)).filter((k) => k >= 0); if (!ks.length) continue; const a = Math.max(0, Math.min(...ks.map((k) => words[k].start)) - SLUR_BLEEP_PAD.before); const b = Math.max(...ks.map((k) => words[k].end)) + SLUR_BLEEP_PAD.after; spans.push([Math.round(a * 1000) / 1000, Math.round(b * 1000) / 1000]); } spans.sort((x, y) => x[0] - y[0]); const merged = []; for (const sp of spans) { const last = merged[merged.length - 1]; if (last && sp[0] <= last[1]) last[1] = Math.max(last[1], sp[1]); else merged.push([...sp]); } return merged.length ? { mode: s.voice === "skip" ? "mute" : "beep", spans: merged } : null; } /** * The narrator's filters that cover the spans (before its levelling and * tempo, on the take's own clock): `[inLabel]` → `[outLabel]`, the voice * silenced over each span and, for a beep, a tone mixed in over it. */ export function bleepFilters(inLabel, outLabel, bleeps, { audioRate = 48000, seconds = 600 } = {}) { const gate = bleeps.spans.map(([a, b]) => `between(t,${a},${b})`).join("+"); const out = [`[${inLabel}]aresample=${audioRate},aformat=sample_fmts=fltp:channel_layouts=stereo,volume=0:enable='${gate}'[${outLabel}_m]`]; if (bleeps.mode !== "beep") return [...out, `[${outLabel}_m]anull[${outLabel}]`]; const tone = `${SLUR_BEEP.amp}*sin(2*PI*${SLUR_BEEP.hz}*t)*(${gate})`; return [ ...out, `aevalsrc=exprs='${tone}|${tone}':s=${audioRate}:d=${Math.ceil(seconds + 1)}[${outLabel}_t]`, `[${outLabel}_m][${outLabel}_t]amix=inputs=2:normalize=0:duration=first[${outLabel}]`, ]; } // --------------------------------------------------------------------------- // What a cut would mask (`umtool posts slurs ls`). // --------------------------------------------------------------------------- /** The words of a post item a slur may be in, by where: its words, its authors' names, the posts it answers and quotes, its read. */ export function postSlurTexts(entry) { const out = []; const add = (where, v) => typeof v === "string" && v && out.push({ where, text: v }); add("text", entry?.text); add("author", entry?.author); if (isObj(entry?.repostedBy)) add("repostedBy", entry.repostedBy.author); (Array.isArray(entry?.parents) ? entry.parents : []).forEach((p, i) => { add(`parents[${i}].text`, p?.text); add(`parents[${i}].paraphrase`, p?.paraphrase); add(`parents[${i}].author`, p?.author); }); if (isObj(entry?.quoted)) { add("quoted.text", entry.quoted.text); add("quoted.paraphrase", entry.quoted.paraphrase); add("quoted.author", entry.quoted.author); } add("script", entry?.narration?.script); return out; } /** * The slurs a cut's post items hold: `{ total, posts: [{ id, hits: {: n}, where: [...] }], bySlur: {: { mask, n, posts: [ids] }} }`. * The filter's state does not matter (an uncensored cut is counted as if on). */ export function slurReport(timeline, s) { const on = { ...s, on: true }; const posts = []; const bySlur = {}; const edgeMasks = {}; let total = 0; for (const e of Array.isArray(timeline) ? timeline : []) { if (e?.type !== "post") continue; const hits = {}; const where = new Set(); for (const { where: w, text } of postSlurTexts(e)) { for (const h of slurMatches(text, on)) { hits[h.id] = (hits[h.id] ?? 0) + 1; where.add(w.replace(/\[\d+\]/, "")); total += 1; const se = slurEntryOf(on, h.id); const b = (bySlur[h.id] ??= { mask: se?.mask ?? "*", n: 0, posts: [], ...(se?.added ? { added: true } : {}), ...(se?.edge ? { edge: true } : {}) }); // An edged slur's masks are its forms' (maskOfHit, lower case): each one the cut draws, "/" between. if (se?.edge) { const m = maskOfHit(se, text.slice(h.start, h.end).toLowerCase()); const seen = (edgeMasks[h.id] ??= []); if (!seen.includes(m)) seen.push(m); b.mask = seen.join("/"); } b.n += 1; if (!b.posts.includes(e.id)) b.posts.push(e.id); } } if (Object.keys(hits).length) posts.push({ id: e.id, hits, where: [...where] }); } return { total, posts, bySlur }; } /** A take's record of the cut's slur state (take.json `slurs`): the cut has post items, and whether it publishes them censored. */ export function cutSlurState(manifest) { const tl = Array.isArray(manifest?.timeline) ? manifest.timeline : []; if (!tl.some((e) => e?.type === "post")) return null; return manifest?.render?.posts?.slurs?.on === false ? "uncensored" : "censored"; }