// @requirements REQ-PRODUCT-CONSUMER-PACKS // @requirements REQ-PRODUCT-PRIVACY-PACKS // @requirements REQ-PRODUCT-CARTRIDGES REQ-PRODUCT-MOBILE REQ-PRODUCT-A11Y import {packLibrary,packGroups} from '@notabenda/core/packs'; import {fromMarkdown} from 'mdast-util-from-markdown'; const groups=packGroups().map(g=>[g.id,g.title]); const e=value=>String(value).replace(/[&<>"']/gu,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); /** A script-free overview, using the installed registry rather than a second list. */ export function packDirectory(){ const packs=packLibrary(); return ``; } export function packDirectoryMarkdown(){ const packs=packLibrary(); return groups.map(([id,title])=>`### ${title}\n\n`+packs.filter(p=>p.shelf===id).map(p=>`- [${p.title}](/start/#pack-${p.id}) — ${p.outcome}`).join('\n')).join('\n\n')+'\n\nRegional packs cover the named timing rules. Review applicability before enabling them.\n'; } export function expandPackDirectory(markdown,{graphical=false}={}){ const edits=[]; function visit(node){ if(node.type==='html'&&/^\s*$/u.test(node.value))edits.push({start:node.position.start.offset,end:node.position.end.offset,text:graphical?packDirectory():packDirectoryMarkdown()}); for(const child of node.children??[])visit(child); } visit(fromMarkdown(markdown)); for(const edit of edits.reverse())markdown=markdown.slice(0,edit.start)+edit.text+markdown.slice(edit.end); return markdown; }