const SepSub = "%separator"; const SepSubRE = new RegExp(`${SepSub}(?:\\s*${SepSub})*`, "g"); function sub(p, token, isJson = false) { let val; if (token === "s" || token === "pageTitle") { val = p.pageTitle; } else if (token.includes(".")) { const dotIndex = token.indexOf("."); val = p[token.substring(0, dotIndex)]?.[token.substring(dotIndex + 1)]; } else { val = p[token]; } if (val !== void 0) { return isJson ? (val || "").replace(/ { if (token === SepSub || !tokens.includes(token)) { return token; } const re = sub(p, token.slice(1), isJson); return re !== void 0 ? re : token; }).trim(); if (hasSepSub) { if (s.endsWith(SepSub)) s = s.slice(0, -SepSub.length); if (s.startsWith(SepSub)) s = s.slice(SepSub.length); s = s.replace(SepSubRE, sep || "").trim(); } return s; } export { processTemplateParams as p };