@commentray/render 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/block-stretch-layout.d.ts +30 -0
  2. package/dist/block-stretch-layout.d.ts.map +1 -0
  3. package/dist/block-stretch-layout.js +116 -0
  4. package/dist/block-stretch-layout.js.map +1 -0
  5. package/dist/build-commentray-nav-search.d.ts +52 -0
  6. package/dist/build-commentray-nav-search.d.ts.map +1 -0
  7. package/dist/build-commentray-nav-search.js +79 -0
  8. package/dist/build-commentray-nav-search.js.map +1 -0
  9. package/dist/code-browser-client.bundle.js +7 -5
  10. package/dist/code-browser-client.js +428 -69
  11. package/dist/code-browser-client.js.map +1 -1
  12. package/dist/code-browser-embedded-payload.d.ts +10 -0
  13. package/dist/code-browser-embedded-payload.d.ts.map +1 -0
  14. package/dist/code-browser-embedded-payload.js +18 -0
  15. package/dist/code-browser-embedded-payload.js.map +1 -0
  16. package/dist/code-browser-encoding.d.ts +9 -0
  17. package/dist/code-browser-encoding.d.ts.map +1 -0
  18. package/dist/code-browser-encoding.js +24 -0
  19. package/dist/code-browser-encoding.js.map +1 -0
  20. package/dist/code-browser-scroll-sync.d.ts +13 -0
  21. package/dist/code-browser-scroll-sync.d.ts.map +1 -0
  22. package/dist/code-browser-scroll-sync.js +15 -0
  23. package/dist/code-browser-scroll-sync.js.map +1 -0
  24. package/dist/code-browser-web-storage.d.ts +7 -0
  25. package/dist/code-browser-web-storage.d.ts.map +1 -0
  26. package/dist/code-browser-web-storage.js +21 -0
  27. package/dist/code-browser-web-storage.js.map +1 -0
  28. package/dist/code-browser.d.ts +76 -0
  29. package/dist/code-browser.d.ts.map +1 -1
  30. package/dist/code-browser.js +400 -39
  31. package/dist/code-browser.js.map +1 -1
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +2 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/markdown-pipeline.d.ts +23 -1
  37. package/dist/markdown-pipeline.d.ts.map +1 -1
  38. package/dist/markdown-pipeline.js +142 -2
  39. package/dist/markdown-pipeline.js.map +1 -1
  40. package/dist/mermaid-runtime-html.d.ts +7 -0
  41. package/dist/mermaid-runtime-html.d.ts.map +1 -0
  42. package/dist/mermaid-runtime-html.js +26 -0
  43. package/dist/mermaid-runtime-html.js.map +1 -0
  44. package/dist/package-version.d.ts +5 -0
  45. package/dist/package-version.d.ts.map +1 -0
  46. package/dist/package-version.js +14 -0
  47. package/dist/package-version.js.map +1 -0
  48. package/dist/side-by-side.d.ts +5 -0
  49. package/dist/side-by-side.d.ts.map +1 -1
  50. package/dist/side-by-side.js +11 -9
  51. package/dist/side-by-side.js.map +1 -1
  52. package/package.json +6 -4
@@ -0,0 +1,30 @@
1
+ import { type CommentrayIndex } from "@commentray/core";
2
+ import { type CommentrayOutputUrlOptions } from "./markdown-pipeline.js";
3
+ export type BlockStretchTableOptions = {
4
+ code: string;
5
+ language: string;
6
+ commentrayMarkdown: string;
7
+ index: CommentrayIndex;
8
+ sourceRelative: string;
9
+ commentrayPathRel: string;
10
+ commentrayOutputUrls?: CommentrayOutputUrlOptions;
11
+ };
12
+ export declare function splitCommentrayMarkdownSegments(markdown: string): {
13
+ preamble: string;
14
+ segments: {
15
+ id: string;
16
+ body: string;
17
+ }[];
18
+ };
19
+ /**
20
+ * When index blocks + markdown markers align, builds a two-column table in the spirit of
21
+ * GitHub **blame**: **one row per block** (plus one row per unmapped source line). The code
22
+ * and commentary cells share the **same row height** — whichever side is taller sets the
23
+ * row; the shorter side is top-aligned with natural empty space below inside its cell.
24
+ * A single outer scroll (`shell--stretch-rows`) keeps both columns in lockstep.
25
+ */
26
+ export declare function tryBuildBlockStretchTableHtml(opts: BlockStretchTableOptions): Promise<{
27
+ preambleHtml: string;
28
+ tableInnerHtml: string;
29
+ } | null>;
30
+ //# sourceMappingURL=block-stretch-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-stretch-layout.d.ts","sourceRoot":"","sources":["../src/block-stretch-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,KAAK,0BAA0B,EAGhC,MAAM,wBAAwB,CAAC;AAOhC,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,eAAe,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;CACnD,CAAC;AAEF,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1C,CA6BA;AAwCD;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA2ElE"}
@@ -0,0 +1,116 @@
1
+ import { MARKER_ID_BODY, buildBlockScrollLinks, } from "@commentray/core";
2
+ import { escapeHtml } from "./html-utils.js";
3
+ import { renderFencedCode, renderMarkdownToHtml, } from "./markdown-pipeline.js";
4
+ const BLOCK_MARKER_LINE = new RegExp(`^<!--\\s*commentray:block\\s+id=(${MARKER_ID_BODY})\\s*-->$`, "i");
5
+ export function splitCommentrayMarkdownSegments(markdown) {
6
+ const lines = markdown.split("\n");
7
+ const preambleLines = [];
8
+ const segments = [];
9
+ let seenMarker = false;
10
+ let currentId = null;
11
+ const currentBody = [];
12
+ function flush() {
13
+ if (currentId !== null) {
14
+ segments.push({ id: currentId, body: currentBody.join("\n").trimEnd() });
15
+ currentBody.length = 0;
16
+ }
17
+ }
18
+ for (const line of lines) {
19
+ const m = BLOCK_MARKER_LINE.exec(line);
20
+ if (m && m[1] !== undefined) {
21
+ seenMarker = true;
22
+ flush();
23
+ currentId = m[1];
24
+ }
25
+ else if (!seenMarker) {
26
+ preambleLines.push(line);
27
+ }
28
+ else {
29
+ currentBody.push(line);
30
+ }
31
+ }
32
+ flush();
33
+ return { preamble: preambleLines.join("\n").trimEnd(), segments };
34
+ }
35
+ function extractPreCodeInner(html) {
36
+ const m = /<pre(?:\s[^>]*)?>\s*<code(?:\s[^>]*)?>([\s\S]*?)<\/code>\s*<\/pre>/i.exec(html.trim());
37
+ return m ? m[1] : escapeHtml(html);
38
+ }
39
+ async function renderSingleCodeLine(line, lineIndex0, language) {
40
+ const display = line === "" ? " " : line;
41
+ const fence = "```" + language + "\n" + display + "\n```\n";
42
+ const block = await renderFencedCode(fence);
43
+ const inner = extractPreCodeInner(block);
44
+ const langAttr = escapeHtml(language);
45
+ const num = lineIndex0 + 1;
46
+ return (`<div class="code-line" id="code-line-${lineIndex0}" data-line="${lineIndex0}">` +
47
+ `<span class="ln" aria-hidden="true">${num}</span>` +
48
+ `<pre><code class="hljs language-${langAttr}">${inner}</code></pre>` +
49
+ `</div>`);
50
+ }
51
+ /** Renders a contiguous 0-based inclusive range of source lines into one stacked column. */
52
+ async function renderCodeLineStack(lines, startLine0, endLine0, language) {
53
+ const parts = [];
54
+ for (let j = startLine0; j <= endLine0; j++) {
55
+ parts.push(await renderSingleCodeLine(lines[j] ?? "", j, language));
56
+ }
57
+ return `<div class="stretch-code-stack">${parts.join("\n")}</div>`;
58
+ }
59
+ /**
60
+ * When index blocks + markdown markers align, builds a two-column table in the spirit of
61
+ * GitHub **blame**: **one row per block** (plus one row per unmapped source line). The code
62
+ * and commentary cells share the **same row height** — whichever side is taller sets the
63
+ * row; the shorter side is top-aligned with natural empty space below inside its cell.
64
+ * A single outer scroll (`shell--stretch-rows`) keeps both columns in lockstep.
65
+ */
66
+ export async function tryBuildBlockStretchTableHtml(opts) {
67
+ const links = buildBlockScrollLinks(opts.index, opts.sourceRelative, opts.commentrayPathRel, opts.commentrayMarkdown, opts.code);
68
+ if (links.length === 0)
69
+ return null;
70
+ const { preamble, segments } = splitCommentrayMarkdownSegments(opts.commentrayMarkdown);
71
+ const mdOpts = { commentrayOutputUrls: opts.commentrayOutputUrls };
72
+ const renderedById = new Map();
73
+ for (const s of segments) {
74
+ renderedById.set(s.id, await renderMarkdownToHtml(s.body.trim().length > 0 ? s.body : " ", mdOpts));
75
+ }
76
+ const lines = opts.code.split("\n");
77
+ const lineToBlock = new Map();
78
+ for (const b of links) {
79
+ for (let L = b.sourceStart; L <= b.sourceEnd; L++) {
80
+ lineToBlock.set(L, b);
81
+ }
82
+ }
83
+ const rows = [];
84
+ let i = 0;
85
+ while (i < lines.length) {
86
+ const L = i + 1;
87
+ const b = lineToBlock.get(L);
88
+ if (!b) {
89
+ const codeLineHtml = await renderSingleCodeLine(lines[i] ?? "", i, opts.language);
90
+ rows.push(`<tr class="stretch-row stretch-row--gap"><td class="stretch-code">${codeLineHtml}</td>` +
91
+ `<td class="stretch-doc stretch-doc--gap"><span class="stretch-gap-mark" aria-hidden="true">—</span></td></tr>`);
92
+ i += 1;
93
+ continue;
94
+ }
95
+ if (i !== b.sourceStart - 1) {
96
+ throw new Error(`block-stretch desync at 0-based index ${String(i)} (block ${b.id} should start at index ${String(b.sourceStart - 1)})`);
97
+ }
98
+ const start0 = b.sourceStart - 1;
99
+ const end0 = b.sourceEnd - 1;
100
+ const stackHtml = await renderCodeLineStack(lines, start0, end0, opts.language);
101
+ const docInner = renderedById.get(b.id) ??
102
+ `<p class="stretch-doc-missing"><em>No commentary segment for block <code>${escapeHtml(b.id)}</code>.</em></p>`;
103
+ rows.push(`<tr class="stretch-row stretch-row--block"><td class="stretch-code">${stackHtml}</td>` +
104
+ `<td class="stretch-doc"><div class="stretch-doc-inner">${docInner}</div></td></tr>`);
105
+ i = end0 + 1;
106
+ }
107
+ const preambleHtml = preamble.trim().length > 0
108
+ ? `<section class="stretch-preamble" aria-label="Introduction">${await renderMarkdownToHtml(preamble, mdOpts)}</section>`
109
+ : "";
110
+ const tableInnerHtml = `<table class="block-stretch pane--code" id="code-pane" role="presentation">` +
111
+ `<colgroup><col class="stretch-col-code" /><col class="stretch-col-doc" /></colgroup>` +
112
+ `<tbody>\n${rows.join("\n")}\n</tbody>` +
113
+ `</table>`;
114
+ return { preambleHtml, tableInnerHtml };
115
+ }
116
+ //# sourceMappingURL=block-stretch-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-stretch-layout.js","sourceRoot":"","sources":["../src/block-stretch-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAEL,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAClC,oCAAoC,cAAc,WAAW,EAC7D,GAAG,CACJ,CAAC;AAYF,MAAM,UAAU,+BAA+B,CAAC,QAAgB;IAI9D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAmC,EAAE,CAAC;IACpD,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,SAAS,KAAK;QACZ,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,IA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ARCH_SCHEMA_VERSION: 1;
2
+ /** One searchable unit for a future hub or external tooling — never primary source lines. */
3
+ export type CommentrayNavSearchRow = {
4
+ kind: "sourcePath";
5
+ sourcePath: string;
6
+ commentrayPath: string;
7
+ } | {
8
+ kind: "commentrayPath";
9
+ sourcePath: string;
10
+ commentrayPath: string;
11
+ } | {
12
+ kind: "commentrayLine";
13
+ sourcePath: string;
14
+ commentrayPath: string;
15
+ line: number;
16
+ text: string;
17
+ };
18
+ /** One indexed source ↔ commentray pair with absolute GitHub blob links for static hub pages. */
19
+ export type DocumentedPairNav = {
20
+ sourcePath: string;
21
+ commentrayPath: string;
22
+ sourceOnGithub: string;
23
+ commentrayOnGithub: string;
24
+ };
25
+ export type CommentrayNavSearchDocument = {
26
+ schemaVersion: typeof COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION;
27
+ rows: CommentrayNavSearchRow[];
28
+ /** Present when `githubBlobBase` was passed to the builder — drives the documented-files tree. */
29
+ documentedPairs?: DocumentedPairNav[];
30
+ };
31
+ export type BuildCommentrayNavSearchFallback = {
32
+ /** Repo-relative primary path (toolbar / manifest label). */
33
+ sourcePath: string;
34
+ /** Repo-relative commentray Markdown path. */
35
+ commentrayPath: string;
36
+ /** Absolute path to that Markdown file on disk. */
37
+ markdownAbs: string;
38
+ };
39
+ export type BuildCommentrayNavSearchGithubBlobBase = {
40
+ owner: string;
41
+ repo: string;
42
+ branch: string;
43
+ };
44
+ /**
45
+ * Builds a JSON-serialisable search corpus: **filenames / paths** plus **commentray Markdown lines**
46
+ * for each indexed pair. Primary source file contents are intentionally omitted.
47
+ *
48
+ * When `githubBlobBase` is set, `documentedPairs` lists every pair with GitHub **blob** URLs for
49
+ * the static hub tree and outbound links.
50
+ */
51
+ export declare function buildCommentrayNavSearchDocument(repoRoot: string, fallback?: BuildCommentrayNavSearchFallback, githubBlobBase?: BuildCommentrayNavSearchGithubBlobBase): Promise<CommentrayNavSearchDocument>;
52
+ //# sourceMappingURL=build-commentray-nav-search.d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AAM,CAAC;CAChB,CAAC;AA4CF;;;;;;GAMG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,gCAAgC,EAC3C,cAAc,CAAC,EAAE,sCAAsC,GACtD,OAAO,CAAC,2BAA2B,CAAC,CAgDtC"}
@@ -0,0 +1,79 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { githubRepoBlobFileUrl, readIndex } from "@commentray/core";
4
+ export const COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION = 1;
5
+ function buildDocumentedPairs(pairs, gh) {
6
+ const { owner, repo, branch } = gh;
7
+ const uniq = new Map();
8
+ for (const { sourcePath, commentrayPath } of pairs) {
9
+ const key = `${sourcePath}\0${commentrayPath}`;
10
+ if (uniq.has(key))
11
+ continue;
12
+ uniq.set(key, {
13
+ sourcePath,
14
+ commentrayPath,
15
+ sourceOnGithub: githubRepoBlobFileUrl(owner, repo, branch, sourcePath),
16
+ commentrayOnGithub: githubRepoBlobFileUrl(owner, repo, branch, commentrayPath),
17
+ });
18
+ }
19
+ return [...uniq.values()].sort((a, b) => a.sourcePath === b.sourcePath
20
+ ? a.commentrayPath.localeCompare(b.commentrayPath)
21
+ : a.sourcePath.localeCompare(b.sourcePath));
22
+ }
23
+ async function appendPairRowsSync(rows, sourcePath, commentrayPath, markdownAbs) {
24
+ rows.push({ kind: "sourcePath", sourcePath, commentrayPath });
25
+ rows.push({ kind: "commentrayPath", sourcePath, commentrayPath });
26
+ try {
27
+ const md = await readFile(markdownAbs, "utf8");
28
+ const lines = md.split("\n");
29
+ for (let i = 0; i < lines.length; i++) {
30
+ rows.push({ kind: "commentrayLine", sourcePath, commentrayPath, line: i, text: lines[i] });
31
+ }
32
+ }
33
+ catch {
34
+ /* keep path rows when the companion file is missing */
35
+ }
36
+ }
37
+ /**
38
+ * Builds a JSON-serialisable search corpus: **filenames / paths** plus **commentray Markdown lines**
39
+ * for each indexed pair. Primary source file contents are intentionally omitted.
40
+ *
41
+ * When `githubBlobBase` is set, `documentedPairs` lists every pair with GitHub **blob** URLs for
42
+ * the static hub tree and outbound links.
43
+ */
44
+ export async function buildCommentrayNavSearchDocument(repoRoot, fallback, githubBlobBase) {
45
+ const rows = [];
46
+ const idx = await readIndex(repoRoot);
47
+ const fromIndex = idx !== null && Object.keys(idx.byCommentrayPath).length > 0
48
+ ? Object.entries(idx.byCommentrayPath).sort(([a], [b]) => a.localeCompare(b))
49
+ : [];
50
+ if (fromIndex.length > 0) {
51
+ for (const [crPath, entry] of fromIndex) {
52
+ await appendPairRowsSync(rows, entry.sourcePath, crPath, path.join(repoRoot, crPath));
53
+ }
54
+ const pairInputs = fromIndex.map(([, e]) => ({
55
+ sourcePath: e.sourcePath,
56
+ commentrayPath: e.commentrayPath,
57
+ }));
58
+ const documentedPairs = githubBlobBase
59
+ ? buildDocumentedPairs(pairInputs, githubBlobBase)
60
+ : undefined;
61
+ return {
62
+ schemaVersion: COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION,
63
+ rows,
64
+ ...(documentedPairs ? { documentedPairs } : {}),
65
+ };
66
+ }
67
+ if (fallback !== undefined) {
68
+ await appendPairRowsSync(rows, fallback.sourcePath, fallback.commentrayPath, fallback.markdownAbs);
69
+ }
70
+ const documentedPairs = githubBlobBase && fallback !== undefined
71
+ ? buildDocumentedPairs([{ sourcePath: fallback.sourcePath, commentrayPath: fallback.commentrayPath }], githubBlobBase)
72
+ : undefined;
73
+ return {
74
+ schemaVersion: COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION,
75
+ rows,
76
+ ...(documentedPairs ? { documentedPairs } : {}),
77
+ };
78
+ }
79
+ //# sourceMappingURL=build-commentray-nav-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-commentray-nav-search.js","sourceRoot":"","sources":["../src/build-commentray-nav-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,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CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -1,5 +1,7 @@
1
- "use strict";(()=>{var T=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,s=e.length;r<s;r++)t[r]=e[r];return t}},F=class{static getHashCode(e){let t=5381,r=t;for(let s=0,i=e.length;s<i&&e[s]!="\0"&&(t=(t<<5)+t^e.charCodeAt(s),s!==i-1&&e[s+1]!=="\0");s+=2)r=(r<<5)+r^e.charCodeAt(s+1);return t+1566083941*r|0}},g=class{constructor(e){this.entries=void 0,this.entries=e!==void 0?e:new Map}add(e,t){if(this.entries.has(e))throw new Error(`A meta entry with key ${e} is already present.`);this.entries.set(e,t)}get(e){return this.entries.get(e)}get allEntries(){return this.entries}toJSON(){return{entries:Object.fromEntries(this.entries)}}},N=class{static mergeMeta(e){if(e.length===0)return new g;if(e.length===1)return e[0];let t=new Map;for(let s of e)for(let[i,n]of s.allEntries){let h=t.get(i);h===void 0?t.set(i,[n]):h.push(n)}let r=new Map;for(let[s,i]of t)if(i.length!==1){if(i.every(n=>typeof n=="number")){let n=i.reduce((h,o)=>h+o,0);r.set(s,n);continue}for(let n=0;n<i.length;n++)r.set(`${s}_${n}`,i[n])}else r.set(s,i[0]);return new g(r)}},Q=class{static isSurrogate(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}static isAlphanumeric(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122}static isLowerAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122}},H=class{constructor(e,t){this.usableSearchers=void 0,this.usableSearchers=new Map;for(let r of t)e.includes(r.type)&&this.usableSearchers.set(r.type,r)}has(e){return this.usableSearchers.has(e)}minQuality(e){return this.usableSearchers.get(e).minQuality}spec(e){return this.usableSearchers.get(e)}},z=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},m,q;(function(a){a.Fuzzy="fuzzy",a.Substring="substring",a.Prefix="prefix"})(m||(m={}));var L=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},R=class extends L{constructor(e){super(m.Fuzzy,e)}},b=class extends L{constructor(e){super(m.Substring,e)}},C=class extends L{constructor(e){super(m.Prefix,e)}},I=class{constructor(e,t=10,r=[new R(.3),new b(0),new C(0)]){this.string=void 0,this.topN=void 0,this.searchers=void 0,this.string=e,this.topN=Math.max(0,t),this.searchers=r}},V=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},W=class{static mergeResults(e,t){let r=e.query,s=this.mergeMatches(e.matches,t.matches,r.topN),i=N.mergeMeta([e.meta,t.meta]);return new z(s,r,i)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let s=[...e,...t];return s.sort((i,n)=>i.quality>n.quality?-1:i.quality<n.quality?1:0),s.length<=r?s:s.slice(0,r)}},J=class{constructor(e,t,r){this.maxQueryLength=void 0,this.mainSearcher=void 0,this.secondarySearcher=void 0,this.maxQueryLength=e,this.mainSearcher=t,this.secondarySearcher=r}indexEntities(e,t,r){return this.secondarySearcher.indexEntities([],t,r),this.mainSearcher.indexEntities(e,t,r)}getMatches(e){return e.string?(e.string.length>this.maxQueryLength&&(e=new I(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),W.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new z([],e,new g)}tryGetTerms(e){let t=this.mainSearcher.tryGetTerms(e);return t!==null?t:this.secondarySearcher.tryGetTerms(e)}getTerms(){return this.mainSearcher.getTerms().concat(this.secondarySearcher.getTerms())}tryGetEntity(e){var t,r;return(t=(r=this.mainSearcher.tryGetEntity(e))!=null?r:this.secondarySearcher.tryGetEntity(e))!=null?t:null}getEntities(){return this.mainSearcher.getEntities().concat(this.secondarySearcher.getEntities())}removeEntities(e){let t=[];for(let s=0,i=e.length;s<i;s++)(this.mainSearcher.removeEntity(e[s])||this.secondarySearcher.removeEntity(e[s]))&&t.push(e[s]);let r=new g;return new V(t,r)}upsertEntities(e,t,r){let s=[],i=[];for(let n=0,h=e.length;n<h;n++){let o=e[n],c=t(o);this.tryUpdate(o,c,r)||(s.push(c),i.push(o))}return this.removeEntities(s),i.length>0?this.reindexSecondarySearcher(i,t,r):new g}reindexSecondarySearcher(e,t,r){let s=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(s,t,r)}tryUpdate(e,t,r){return this.tryUpdateSearcher(e,t,r,this.mainSearcher)||this.tryUpdateSearcher(e,t,r,this.secondarySearcher)}tryUpdateSearcher(e,t,r,s){let i=s.tryGetTerms(t);if(i===null)return!1;if(this.termsAreEqual(i,r(e))){if(!s.replaceEntity(t,e,t))throw new Error(`Entity with id ${t} was not present.`);return!0}return!1}termsAreEqual(e,t){return e===t||e!=null&&t!=null&&e.length===t.length&&e.every((r,s)=>r===t[s])}removeEntity(e){return this.mainSearcher.removeEntity(e)||this.secondarySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.mainSearcher.replaceEntity(e,t,r)||this.secondarySearcher.replaceEntity(e,t,r)}save(e){this.mainSearcher.save(e),this.secondarySearcher.save(e)}load(e){this.mainSearcher.load(e),this.secondarySearcher.load(e)}},X=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),s=Math.round(performance.now()-t);return r.meta.add("removalDuration",s),r}upsertEntities(e,t,r){let s=performance.now(),i=this.dynamicSearcher.upsertEntities(e,t,r),n=Math.round(performance.now()-s);return i.add("upsertDuration",n),i}indexEntities(e,t,r){let s=performance.now(),i=this.dynamicSearcher.indexEntities(e,t,r),n=Math.round(performance.now()-s);return i.add("indexingDurationTotal",n),i}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),s=Math.round(performance.now()-t);return r.meta.add("queryDuration",s),r}tryGetEntity(e){return this.dynamicSearcher.tryGetEntity(e)}getEntities(){return this.dynamicSearcher.getEntities()}tryGetTerms(e){return this.dynamicSearcher.tryGetTerms(e)}getTerms(){return this.dynamicSearcher.getTerms()}removeEntity(e){return this.dynamicSearcher.removeEntity(e)}replaceEntity(e,t,r){return this.dynamicSearcher.replaceEntity(e,t,r)}save(e){this.dynamicSearcher.save(e)}load(e){this.dynamicSearcher.load(e)}},Y=class{constructor(e,t,r){this.entity=void 0,this.quality=void 0,this.matchedString=void 0,this.entity=e,this.quality=t,this.matchedString=r}},Z=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},k=class{constructor(e,t=0,r){this.string=void 0,this.minQuality=void 0,this.searcherType=void 0,this.string=e,this.minQuality=Math.max(0,Math.min(1,t)),this.searcherType=r}},_=class{constructor(e,t){this.stringSearcher=void 0,this.searcherTypes=void 0,this.entities=void 0,this.idToIndex=void 0,this.terms=void 0,this.termIndexToEntityIndex=void 0,this.entityIndexToFirstTermIndex=void 0,this.searchersAndQualityOffsets=[{searcherType:m.Prefix,qualityOffset:2},{searcherType:m.Substring,qualityOffset:1},{searcherType:m.Fuzzy,qualityOffset:0}],this.stringSearcher=e,this.searcherTypes=t,this.entities=[],this.idToIndex=new Map,this.terms=[],this.termIndexToEntityIndex=new Int32Array(0),this.entityIndexToFirstTermIndex=new Int32Array(0)}indexEntities(e,t,r){this.entities=[...e],this.idToIndex=new Map,this.terms=[];let s=[],i=[];for(let h=0,o=e.length;h<o;h++){this.idToIndex.set(t(e[h]),h);let c=r(e[h]);i.push(this.terms.length),this.terms.push(...c),s.push(...c.map(()=>h))}this.termIndexToEntityIndex=T.ToInt32Array(s),this.entityIndexToFirstTermIndex=T.ToInt32Array(i);let n=this.stringSearcher.index(this.terms);return n.add("numberOfEntities",this.entities.length),n.add("numberOfTerms",this.terms.length),n}getMatches(e){let t=new Z(e),r=new H(this.searcherTypes,e.searchers);for(let{searcherType:i,qualityOffset:n}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(i)&&this.addMatchesFromSearcher(t,r.spec(i),n)}let s=N.mergeMeta(t.meta);return new z(t.matches,e,s)}addMatchesFromSearcher(e,t,r){let s=Math.max(0,t.minQuality-r);if(s>1)return;let i=new k(e.query.string,s,t.type),n=this.stringSearcher.getMatches(i);this.addMatchesFromResult(e,n,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let s=0,i=t.matches.length;s<i;s++){let n=t.matches[s],h=this.termIndexToEntityIndex[n.index];if(!e.matchedIndexes.has(h)&&this.entities[h]!==null&&(e.matchedIndexes.add(h),e.matches.push(new Y(this.entities[h],n.quality+r,this.terms[n.index])),e.matches.length===e.query.topN))break}}tryGetEntity(e){let t=this.idToIndex.get(e);return t===void 0?null:this.entities[t]}getEntities(){return this.entities.filter(e=>e!==null)}tryGetTerms(e){let t=this.idToIndex.get(e);return t===void 0?null:this.terms.slice(this.entityIndexToFirstTermIndex[t],t===this.entities.length-1?this.terms.length:this.entityIndexToFirstTermIndex[t+1])}getTerms(){let e=[];for(let t=0,r=this.termIndexToEntityIndex.length;t<r;t++)this.entities[this.termIndexToEntityIndex[t]]!==null&&e.push(this.terms[t]);return e}removeEntity(e){let t=this.idToIndex.get(e);return t!==void 0&&(this.entities[t]=null,this.idToIndex.delete(e),!0)}replaceEntity(e,t,r){let s=this.idToIndex.get(e);return s!==void 0&&(this.entities[s]=t,this.idToIndex.delete(e),this.idToIndex.set(r,s),!0)}save(e){e.add(this.entities),e.add(this.idToIndex),e.add(this.terms),e.add(this.termIndexToEntityIndex),e.add(this.entityIndexToFirstTermIndex),this.stringSearcher.save(e)}load(e){this.entities=e.get(),this.idToIndex=e.get(),this.terms=e.get(),this.termIndexToEntityIndex=e.get(),this.entityIndexToFirstTermIndex=e.get(),this.stringSearcher.load(e)}},w=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},ee=class{constructor(e,t){this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.numberOfSurrogateCharacters=0,this.treatCharacterAsSpace=e,this.allowCharacter=t}normalize(e){let t=new Array(e.length),r=0,s=!1,i=!1;for(let n=0,h=e.length;n<h;n++){let o=this.getNormalizedCharacter(e[n]);o!==""&&(o===" "?s=!0:(s&&i&&(t[r++]=" "),t[r++]=o,i=!0,s=!1))}return i?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!Q.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(s=>this.normalize(s)),r=new g;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new w(t,r)}},te=class{constructor(e){this.normalizationFunction=void 0,this.normalizationFunction=e}normalize(e){return this.normalizationFunction(e)}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new w(t,new g)}},re=class{constructor(e){this.normalizers=void 0,this.normalizers=e}normalize(e){for(let t=0,r=this.normalizers.length;t<r;t++)e=this.normalizers[t].normalize(e);return e}normalizeBulk(e){let t=new g;for(let r=0,s=this.normalizers.length;r<s;r++){let i=this.normalizers[r].normalizeBulk(e);e=i.strings;for(let n of i.meta.allEntries)t.add(n[0],n[1])}return new w(e,t)}},se=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new w(t,new g)}},ie=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let s=new Map;for(let[i,n]of r)for(let h of n){let o=t(h);s.set(o,i)}this.replacements.push(s)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let s=0,i=e.length;s<i;s++)for(let n of this.replacements){let h=n.get(e[s]);if(h!==void 0){t[r++]=h;break}t[r++]=e[s]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new w(t,new g)}},ne=class{static create(e){let t=new se,r=new ie(e.replacements,n=>n.toLowerCase().normalize("NFKC")),s=new te(n=>n.normalize("NFKD")),i=new ee(e.treatCharacterAsSpace,e.allowCharacter);return new re([t,r,s,i])}},D=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},S=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},ae=class{constructor(e){this.stringSearcher=void 0,this.distinctMapping=void 0,this.sortMapping=void 0,this.stringSearcher=e,this.distinctMapping=new Int32Array(0),this.sortMapping=new Int32Array(0)}index(e){let t=e.map((o,c)=>({term:o,index:c}));t.sort((o,c)=>o.term<c.term?-1:o.term>c.term?1:0),this.sortMapping=new Int32Array(t.length);for(let o=0,c=t.length;o<c;o++)this.sortMapping[o]=t[o].index;let r=[],s=[],i=0,n=null;for(let o=0,c=t.length;o<c;o++){let d=t[o].term;d!=n&&(r[i]=d,s[i]=o,i++),n=d}s[i++]=t.length,this.distinctMapping=T.ToInt32Array(s);let h=this.stringSearcher.index(r);return h.add("numberOfDistinctTerms",r.length),h}getMatches(e){let t=this.stringSearcher.getMatches(e),r=new Array(t.matches.length),s=0;return t.matches.forEach(i=>{let n=this.distinctMapping[i.index+1];for(let h=this.distinctMapping[i.index];h<n;h++)r[s++]=new D(this.sortMapping[h],i.quality)}),new S(r,e,t.meta)}save(e){e.add(this.distinctMapping),e.add(this.sortMapping),this.stringSearcher.save(e)}load(e){this.distinctMapping=e.get(),this.sortMapping=e.get(),this.stringSearcher.load(e)}},he=class{constructor(e,t){this.entitySearcher=void 0,this.searcherTypes=void 0,this.entitySearcher=e,this.searcherTypes=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=new H(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(m.Prefix)&&t.minQuality(m.Prefix)<2.2){let r=new I(e.string,e.topN,[new C(2.3)]),s=this.entitySearcher.getMatches(r);if(s.matches.length==e.topN)return new z(s.matches,e,s.meta)}if(e.string.length<=3&&!t.has(m.Prefix)&&t.has(m.Substring)&&t.minQuality(m.Substring)<1.2){let r=new I(e.string,e.topN,[new b(1.3)]),s=this.entitySearcher.getMatches(r);if(s.matches.length==e.topN)return new z(s.matches,e,s.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},P=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=T.ToInt32Array(this.ids),this.frequencies=T.ToInt32Array(this.frequencies)}get length(){return this.ids.length}save(e){e.add(this.ids),e.add(this.frequencies)}load(e){this.ids=e.get(),this.frequencies=e.get()}},A=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let s=this.ngramToTermIds.get(e);s||(s=new P,this.ngramToTermIds.set(e,s)),s.addId(t,r)}seal(){for(let e of this.ngramToTermIds.values())e.seal()}getIds(e){return this.ngramToTermIds.get(e)}get size(){return this.ngramToTermIds.size}save(e){e.add(this.ngramToTermIds.size);for(let[t,r]of this.ngramToTermIds)e.add(t),r.save(e)}load(e){let t=e.get();for(let r=0;r<t;r++){let s=e.get(),i=new P;i.load(e),this.ngramToTermIds.set(s,i)}}},oe=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},ce=class{constructor(e){this.ngramComputer=void 0,this.invertedIndex=void 0,this.numberOfNgrams=void 0,this.commonNgramCounts=void 0,this.ngramComputer=e,this.invertedIndex=new A,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new A,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let n=0,h=e.length;n<h;n++){let o=e[n];if(!this.isValidTerm(o)){this.numberOfNgrams[n]=0,r++;continue}let c=this.ngramComputer.computeNgrams(o);this.numberOfNgrams[n]=c.length;let d=this.getNgramsToFrequency(c);for(let[l,u]of d)this.invertedIndex.add(l,n,u)}this.invertedIndex.seal();let s=Math.round(performance.now()-t),i=new g;return i.add("numberOfInvalidTerms",r),i.add("indexingDurationFuzzySearcher",s),i}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new S([],e,new g);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),s=t.length;this.computeCommonNgramCounts(r);let i=this.getMatchesFromCommonNgrams(s,e.minQuality);return new S(i,e,new g)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let s=this.invertedIndex.getIds(t);if(s!=null)for(let i=0,n=s.length;i<n;i++)this.commonNgramCounts[s.ids[i]]+=Math.min(r,s.frequencies[i])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,s=e.length;r<s;r++){let i=e[r],n=t.get(i);t.set(i,n!==void 0?n+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let s=0,i=this.numberOfNgrams.length;s<i;s++){let n=oe.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[s],this.commonNgramCounts[s]);n>t&&r.push(new D(s,n))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new A,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},de=class{constructor(e,t){this.stringSearcher=void 0,this.penaltyFactor=void 0,this.hashCodes=void 0,this.stringSearcher=e,this.penaltyFactor=1-t,this.hashCodes=new Int32Array(0)}index(e){this.hashCodes=new Int32Array(e.length);for(let t=0,r=e.length;t<r;t++)this.hashCodes[t]=F.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=F.getHashCode(e.string),r=this.stringSearcher.getMatches(e),s=r.matches.map(i=>this.penalizeMatch(i,t)).filter(i=>i.quality>=e.minQuality);return new S(s,r.query,r.meta)}penalizeMatch(e,t){return e.quality*=this.hashCodes[e.index]===t?1:this.penaltyFactor,e}save(e){e.add(this.hashCodes),this.stringSearcher.save(e)}load(e){this.hashCodes=e.get(),this.stringSearcher.load(e)}},ue=class{constructor(e,t){this.ngramN=void 0,this.transformNgram=void 0,this.ngramN=e,this.transformNgram=t??(r=>r)}computeNgrams(e){if(e.length===0)return[];if(e.length<=this.ngramN){let r=this.transformNgram(e);return r?[r]:[]}let t=[];for(let r=0,s=this.maximumNumberOfNgrams(e);r<s;r++){let i=this.transformNgram(e.substring(r,r+this.ngramN));i&&t.push(i)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},le=class{constructor(e,t,r){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r}normalize(e){return e&&`${this.paddingLeft}${e.split(" ").join(this.paddingMiddle)}${this.paddingRight}`}normalizeBulk(e){let t=e.map(s=>this.normalize(s)),r=new g;return new w(t,r)}},$=class{};$.Value=new Map([["a",["\u1D8F","\u2C65","\u0251","\u1D00","\u0250","\u0252"]],["aa",["\xE5","\uA733"]],["ae",["\xE4","\xE6","\u1D01","\u1D2D","\u1D46","\u01FD","\u01E3","\u1D02"]],["ao",["\uA735"]],["au",["\uA737"]],["av",["\uA739","\uA73B"]],["ay",["\uA73D"]],["b",["\u0180","\u0253","\u0183","\u1D6C","\u1D80","\u0299"]],["c",["\u023C","\u0188","\u0255","\u1D04","\uA73F","\u2184"]],["d",["\u0111","\xF0","\u0256","\u0257","\u018C","\u1D6D","\u1D81","\u1D91","\u0221","\u1D05","\uA77A"]],["db",["\u0238"]],["e",["\u1D92","\u0247","\u2C78","\u1D07","\u0259","\u01DD","\u025B"]],["eo",["\u1D14"]],["f",["\u0192","\u1D6E","\u1D82","\uA730","\uA77C"]],["g",["\u01E5","\u0260","\u1D83","\u0262","\u021D","\u014B","\uA7A1","\u1D79","\uA77F"]],["h",["\u0127","\u2C68","\u0266","\u029C","\u0303","\u0267","\u2C76","\u0265"]],["hv",["\u0195"]],["i",["\u0268","\u1D7B","\u1D96","\u0131","\u026A","\u0269"]],["j",["\u0249","\u0237","\u029D","\u025F","\u0284","\u1D0A"]],["k",["\u0199","\u2C6A","\u1D84","\uA741","\u1D0B","\uA743","\uA745","\uA7A3"]],["l",["\u0142","\u019A","\u2C61","\u026B","\u026C","\u1D85","\u026D","\u0234","\u029F","\uA749","\uA781","\uA747"]],["m",["\u1D6F","\u1D86","\u0271","\u1D0D","\u026F"]],["n",["\u0272","\u019E","\u1D70","\u1D87","\u0273","\u0235","\u0274","\uA791","\uA7A5"]],["o",["\xF8","\u01FF","\u0275","\u0254","\u2C7A","\u1D0F","\uA74B","\uA74D"]],["oe",["\xF6","\u0153"]],["oi",["\u01A3"]],["oo",["\uA74F"]],["ou",["\u0223"]],["p",["\u1D7D","\u01A5","\u1D71","\u1D88","\u1D18","\u01BF","\uA751","\uA753","\uA755"]],["q",["\u024B","\u02A0","\uA757","\uA759"]],["qp",["\u0239"]],["r",["\u024D","\u027D","\uA75B","\u1D72","\u1D89","\u027C","\u027E","\u1D73","\u0280","\u0279","\u0281","\uA7A7","\uA783"]],["s",["\u1D74","\u1D8A","\u0282","\u023F","\uA731","\u0283","\uA7A9","\uA785","\u017F"]],["ss",["\xDF"]],["t",["\u0167","\u2C66","\u01AD","\u0288","\u1D75","\u01AB","\u0236","\u1D1B","\uA787"]],["th",["\xFE"]],["tz",["\uA729"]],["u",["\u0289","\u028A","\u1D7E","\u1D1C","\u1D99"]],["ue",["\xFC","\u1D6B"]],["v",["\u028B","\u1D8C","\u2C71","\u2C74","\u1D20","\u028C","\uA75F"]],["vy",["\uA761"]],["w",["\u2C73","\u1D21","\u028D"]],["x",["\u1D8D"]],["y",["\u024F","\u01B4","\u028F","\u1EFF"]],["z",["\u01B6","\u0225","\u2C6C","\u1D76","\u1D8E","\u0290","\u0291","\u0240","\u1D22","\u0292","\u01B9","\uA763"]]]);var G=class a{constructor(e,t,r){this.replacements=void 0,this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.replacements=e,this.treatCharacterAsSpace=t,this.allowCharacter=r}static createDefaultConfig(){let e=new Set(["_","-","\u2013","/",","," "]);return new a([$.Value],t=>e.has(t),t=>Q.isAlphanumeric(t))}},B=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),s=Math.round(performance.now()-t),i=this.stringSearcher.index(r.strings);i.add(this.normalizationDurationMetaKey,s);for(let n of r.meta.allEntries)i.add(n[0],n[1]);return i}getMatches(e){let t=new k(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new S(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},me=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new S([],e,new g);let t=this.modifyQueryString(e.string),r=new k(t,e.minQuality,e.searcherType);return this.suffixArraySearcher.getMatches(r,e.string.length)}modifyQueryString(e){return`${this.suffixArraySearcher.separator}${e}`}save(e){this.suffixArraySearcher.save(e)}load(e){this.suffixArraySearcher.load(e)}},ge=class{constructor(e,t,r){this.prefixSearcher=void 0,this.substringSearcher=void 0,this.fuzzySearcher=void 0,this.prefixSearcher=e,this.substringSearcher=t,this.fuzzySearcher=r}index(e){let t=[];if(this.prefixSearcher&&!this.substringSearcher){let r=this.prefixSearcher.index(e);t.push(r)}if(this.substringSearcher){let r=this.substringSearcher.index(e);t.push(r)}if(this.fuzzySearcher){let r=this.fuzzySearcher.index(e);t.push(r)}return N.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case m.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case m.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case m.Fuzzy:if(!this.fuzzySearcher)throw new Error("No fuzzy searcher has been indexed.");return this.fuzzySearcher.getMatches(e);default:throw new Error(`Unknown searcher type: ${e.searcherType}`)}}save(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.save(e),this.substringSearcher&&this.substringSearcher.save(e),this.fuzzySearcher&&this.fuzzySearcher.save(e)}load(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.load(e),this.substringSearcher&&this.substringSearcher.load(e),this.fuzzySearcher&&this.fuzzySearcher.load(e)}};(function(a){a.QualityAndIndex="qualityAndIndex",a.QualityAndMatchedString="qualityAndMatchedString"})(q||(q={}));var fe=class{constructor(e,t){this.sortOrder=void 0,this.entitySearcher=void 0,this.collator=new Intl.Collator(void 0,{numeric:!0}),this.sortOrder=e,this.entitySearcher=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=this.entitySearcher.getMatches(e);switch(this.sortOrder){case q.QualityAndIndex:return t;case q.QualityAndMatchedString:return this.sortMatchesByQualityAndMatchedString(t.matches),t;default:throw new Error(`Unsupported sort order: ${this.sortOrder}`)}}sortMatchesByQualityAndMatchedString(e){e.sort((t,r)=>t.quality>r.quality?-1:t.quality<r.quality?1:this.collator.compare(t.matchedString,r.matchedString))}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}save(e){this.entitySearcher.save(e)}load(e){this.entitySearcher.load(e)}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}},ye=class{constructor(e){this.stringSearcher=void 0,this.stringSearcher=e}index(e){return this.stringSearcher.index(e)}getMatches(e){let t=this.stringSearcher.getMatches(e);return t.matches.sort(this.compareMatchesByQualityAndIndex),t}compareMatchesByQualityAndIndex(e,t){return e.quality>t.quality?-1:e.quality<t.quality?1:e.index<t.index?-1:e.index>t.index?1:0}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},O=class{static compareOrdinal(e,t,r,s,i){let n=Math.min(t+i,e.length),h=Math.min(s+i,r.length),o=t,c=s;for(;o<n&&c<h;){let u=e.charCodeAt(o),x=r.charCodeAt(c);if(u<x)return-1;if(u>x)return 1;o++,c++}let d=n-t,l=h-s;return d===l?0:d<l?-1:1}},pe=class a{static create(e){if(e==null)throw new Error("Input string cannot be null.");let t=new a(e);return t.FormInitialChains(),t.BuildSufixArray(),t.sa}constructor(e){this.inputString=void 0,this.eoc=2147483647,this.sa=void 0,this.isa=void 0,this.chainHeadsDict=void 0,this.chainStack=[],this.subChains=[],this.nextRank=1,this.inputString=e;let t=e.length;this.sa=new Int32Array(t),this.isa=new Int32Array(t),this.chainHeadsDict=new Map}FormInitialChains(){this.FindInitialChains(),this.SortAndPushSubchains()}FindInitialChains(){for(let e=0;e<this.inputString.length;e++){let t=this.inputString.charCodeAt(e),r=this.chainHeadsDict.get(t);this.isa[e]=r!==void 0?r:this.eoc,this.chainHeadsDict.set(t,e)}for(let e of this.chainHeadsDict.values()){let t=new U(e,1);this.subChains.push(t)}}BuildSufixArray(){for(;this.chainStack.length>0;){let e=this.chainStack.pop();this.isa[e.head]===this.eoc?this.RankSuffix(e.head):this.RefineChainWithInductionSorting(e)}}RankSuffix(e){this.isa[e]=-this.nextRank,this.sa[this.nextRank-1]=e,this.nextRank++}RefineChainWithInductionSorting(e){let t=[];for(this.chainHeadsDict.clear(),this.subChains=[];e.head!==this.eoc;){let r=this.isa[e.head];if(e.head+e.length>this.inputString.length-1)this.RankSuffix(e.head);else if(this.isa[e.head+e.length]<0){let s=new Se(e.head,-this.isa[e.head+e.length]);t.push(s)}else this.ExtendChain(e);e.head=r}this.SortAndPushSubchains(),this.SortAndRankNotedSuffixes(t)}ExtendChain(e){let t=this.inputString.charCodeAt(e.head+e.length);if(this.chainHeadsDict.has(t))this.isa[this.chainHeadsDict.get(t)]=e.head,this.isa[e.head]=this.eoc;else{this.isa[e.head]=this.eoc;let r=new U(e.head,e.length+1);this.subChains.push(r)}this.chainHeadsDict.set(t,e.head)}SortAndRankNotedSuffixes(e){e.sort((t,r)=>t.rank-r.rank);for(let t=0;t<e.length;t++)this.RankSuffix(e[t].head)}SortAndPushSubchains(){this.subChains.sort((e,t)=>{let r=Math.min(e.length,t.length);return O.compareOrdinal(this.inputString,e.head,this.inputString,t.head,r)});for(let e=this.subChains.length-1;e>=0;e--)this.chainStack.push(this.subChains[e])}},Se=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},U=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},ve=class{constructor(e){this.separator=void 0,this.str=void 0,this.suffixArray=void 0,this.indexToTermIndex=void 0,this.termLengths=void 0,this.separator=e,this.str="",this.suffixArray=new Int32Array(0),this.indexToTermIndex=new Int32Array(0),this.termLengths=new Int32Array(0)}index(e){let t=performance.now();this.str=e.length>0?this.separator+e.join(this.separator)+this.separator:"",this.suffixArray=pe.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let n=0;n<e.length;n++){this.termLengths[n]=e[n].length;for(let h=0;h<=e[n].length;h++)this.indexToTermIndex[r++]=n}this.indexToTermIndex[r++]=-1;let s=Math.round(performance.now()-t),i=new g;return i.add("indexingDurationSuffixArraySearcher",s),i}getMatches(e,t){if(!e.string)return new S([],e,new g);let[r,s]=this.GetPositionsInSuffixArray(e.string),i=new Int32Array(s-r),n=new Set,h=0;for(let d=r;d<s;d++){let l=this.indexToTermIndex[this.suffixArray[d]];n.has(l)||(n.add(l),i[h++]=l)}let o=[];t=t??e.string.length;let c=0;for(let d=0;d<h;d++)c=this.computeQuality(t,this.termLengths[i[d]]),c>e.minQuality&&o.push(new D(i[d],c));return new S(o,e,new g)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,s=0;for(;t<r;)s=Math.floor((t+r)/2),O.compareOrdinal(e,0,this.str,this.suffixArray[s],e.length)>0?t=s+1:r=s;let i=t;for(r=this.suffixArray.length;t<r;)s=Math.floor((t+r)/2),O.compareOrdinal(e,0,this.str,this.suffixArray[s],e.length)==0?t=s+1:r=s;return[i,r]}save(e){e.add(this.str),e.add(this.suffixArray),e.add(this.indexToTermIndex),e.add(this.termLengths)}load(e){this.str=e.get(),this.suffixArray=e.get(),this.indexToTermIndex=e.get(),this.termLengths=e.get()}},j=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),s=this.tryCreateSubstringSearcher(e),i=this.tryCreatePrefixSearcher(e,s),n=new ge(i,s,r);n=new ae(n),n=new ye(n),n=new B(n,t,"normalizationDurationDefault");let h=new _(n,e.searcherTypes);return h=new he(h,e.searcherTypes),h=new fe(e.sortOrder,h),h}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(s=>t.add(s)),e.fuzzySearchConfig.paddingRight.split("").forEach(s=>t.add(s)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(s=>t.add(s))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(s=>t.add(s));let r=new G(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,s=>e.normalizerConfig.allowCharacter(s)&&!t.has(s));return ne.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(m.Fuzzy))return null;if(e.fuzzySearchConfig===void 0)throw new Error("Unable to create fuzzy searcher: No fuzzy search config provided.");return this.createFuzzySearcher(e.fuzzySearchConfig)}static createFuzzySearcher(e){let t=new ue(e.ngramN,e.transformNgram),r=new le(e.paddingLeft,e.paddingRight,e.paddingMiddle),s=new ce(t);return s=new de(s,e.inequalityPenalty),s=new B(s,r,"normalizationDurationNgrams"),s}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(m.Substring))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create substring searcher: No substring search config provided.");return this.createSubstringSearcher(e.substringSearchConfig)}static createSubstringSearcher(e){return new ve(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(m.Prefix))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create prefix searcher: No substring search config provided.");return this.createPrefixSearcher(e.substringSearchConfig,t)}static createPrefixSearcher(e,t){return t===null&&(t=this.createSubstringSearcher(e)),new me(t)}},we=class a{constructor(e,t,r,s,i,n){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.ngramN=void 0,this.transformNgram=void 0,this.inequalityPenalty=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r,this.ngramN=s,this.transformNgram=i,this.inequalityPenalty=n}static createDefaultConfig(){return new a("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var xe=class a{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new a("$")}},Te=class a{constructor(e,t,r,s,i,n){this.searcherTypes=void 0,this.maxQueryLength=void 0,this.sortOrder=void 0,this.normalizerConfig=void 0,this.fuzzySearchConfig=void 0,this.substringSearchConfig=void 0,this.searcherTypes=e,this.maxQueryLength=t,this.sortOrder=r,this.normalizerConfig=s,this.fuzzySearchConfig=i,this.substringSearchConfig=n}static createDefaultConfig(){let e=[m.Fuzzy,m.Substring,m.Prefix],t=q.QualityAndMatchedString,r=G.createDefaultConfig(),s=we.createDefaultConfig(),i=xe.createDefaultConfig();return new a(e,150,t,r,s,i)}},K=class{static createSearcher(e){let t=j.createSearcher(e),r=j.createSearcher(e),s=new J(e.maxQueryLength,t,r);return s=new X(s),s}static createDefaultSearcher(){let e=Te.createDefaultConfig();return this.createSearcher(e)}};function ze(a,e){let t=e.map(o=>o.trim()).filter(Boolean);if(t.length===0)return[];let r=a.toLowerCase(),s=t.map(o=>o.toLowerCase()),i=[],n=0,h=0;for(;n<a.length&&h<400;){let o=n,c=-1,d=!0;for(let l of s){if(l.length===0)continue;let u=r.indexOf(l,o);if(u<0){d=!1;break}c<0&&(c=u),o=u+l.length}if(!d||c<0)break;i.push({start:c,end:o}),h++,n=c+1}return i}function Ie(a,e){let t=Math.max(0,Math.min(e,a.length)),r=0;for(let s=0;s<t;s++)a[s]===`
2
- `&&r++;return r}function Me(a,e){let t=a.split(`
3
- `);return e<0||e>=t.length?"":t[e]??""}function Ne(a){return a.trim().split(/\s+/).filter(Boolean)}function Ae(a,e,t){return Math.max(e,Math.min(t,a))}function be(a){try{return decodeURIComponent(escape(atob(a)))}catch{try{return atob(a)}catch{return""}}}function qe(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Le(a,e){let t=a.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function Re(a,e){let t=new Map;for(let r of a){let s=`${r.kind}:${r.line}`,i=t.get(s);(!i||r.score>i.score)&&t.set(s,r)}return[...t.values()].sort((r,s)=>s.score-r.score).slice(0,e)}function Ce(a,e,t){let r=ze(a,t),s=new Set,i=[];for(let n of r){let h=Ie(a,n.start);s.has(h)||(s.add(h),i.push({kind:e,line:h,text:Me(a,h),score:1e3,source:"ordered"}))}return i}function ke(a,e,t){let r=e.trim();if(!r)return[];let s=new I(r,t,[new R(.22),new b(0),new C(0)]),i=a.getMatches(s),n=[];for(let h of i.matches){let o=h.entity;n.push({kind:o.kind,line:o.line,text:o.text,score:100+h.quality,source:"fuzzy"})}return n}function De(a){let{rawCode:e,rawMd:t,mdLines:r,searcher:s,searchInput:i,searchClear:n,searchResults:h,docPane:o}=a;function c(){let l=Ne(i.value);if(l.length===0){h.hidden=!0,h.innerHTML="";return}let u=Ce(e,"code",l),x=Ce(t,"md",l),M=ke(s,i.value,60),f=Re([...u,...x,...M],80);if(h.hidden=!1,f.length===0){h.innerHTML='<div class="hint">No matches. Try fewer tokens or looser spelling (fuzzy matches per line).</div>';return}let v=[];v.push(`<div class="hint">Whole source: whitespace tokens in order (may span lines). Per-line fuzzy ranking for typos. ${f.length} hit(s).</div>`);for(let y of f){let p=y.kind==="code"?`Code L${y.line+1}`:`Commentray L${y.line+1}`,E=y.source==="ordered"?"ordered":"fuzzy";v.push(`<button type="button" class="hit" data-kind="${y.kind}" data-line="${String(y.line)}"><span class="meta">${p} <span class="src-tag">(${E})</span></span><div class="snippet">${qe(Le(y.text,200))}</div></button>`)}h.innerHTML=v.join("")}h.addEventListener("click",l=>{let u=l.target;for(;u&&u!==h&&(!u.classList||!u.classList.contains("hit"));)u=u.parentElement;if(!u||!u.classList||!u.classList.contains("hit"))return;let x=u.getAttribute("data-kind"),M=parseInt(u.getAttribute("data-line")||"0",10);if(x==="code"){let f=document.getElementById(`code-line-${String(M)}`);f&&f.scrollIntoView({block:"nearest",behavior:"smooth"})}else{let f=r.length;if(f<=0)return;let v=M/Math.max(1,f-1),y=o.scrollHeight-o.clientHeight;o.scrollTo({top:v*Math.max(0,y),behavior:"smooth"})}});let d;i.addEventListener("input",()=>{clearTimeout(d),d=setTimeout(c,200)}),n.addEventListener("click",()=>{clearTimeout(d),i.value="",h.innerHTML="",h.hidden=!0})}function Oe(a,e,t){let r=localStorage.getItem(a)==="1";t.checked=r,r&&e.classList.add("wrap"),t.addEventListener("change",()=>{t.checked?(e.classList.add("wrap"),localStorage.setItem(a,"1")):(e.classList.remove("wrap"),localStorage.setItem(a,"0"))})}function Fe(a,e,t,r,s){let i=!1,n=s;function h(c){if(!i)return;let d=e.getBoundingClientRect(),l=c.clientX-d.left,u=Ae(l/d.width*100,15,85);n=u,t.style.flex=`0 0 ${u}%`}function o(){i=!1,window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",o),document.body.style.cursor="",document.body.style.userSelect="",localStorage.setItem(a,String(n))}r.addEventListener("mousedown",c=>{c.preventDefault(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",h),window.addEventListener("mouseup",o)})}function Ee(){let a="commentray.codeCommentrayStatic.splitPct",e="commentray.codeCommentrayStatic.wrap",t=document.getElementById("shell"),r=document.getElementById("code-pane"),s=document.getElementById("doc-pane"),i=document.getElementById("gutter"),n=document.getElementById("wrap-lines"),h=document.getElementById("search-q"),o=document.getElementById("search-clear"),c=document.getElementById("search-results");if(!t||!r||!s||!i||!n||!h||!o||!c)return;let d=be(r.getAttribute("data-raw-code-b64")||""),l=be(r.getAttribute("data-raw-md-b64")||""),u=l.split(`
4
- `),M=[...d.split(`
5
- `).map((p,E)=>({kind:"code",line:E,text:p})),...u.map((p,E)=>({kind:"md",line:E,text:p}))],f=K.createDefaultSearcher();f.indexEntities(M,p=>`${p.kind}:${p.line}`,p=>[p.text]),De({rawCode:d,rawMd:l,mdLines:u,searcher:f,searchInput:h,searchClear:o,searchResults:c,docPane:s});let v=parseFloat(localStorage.getItem(a)||"50"),y=Ae(Number.isFinite(v)?v:50,15,85);r.style.flex=`0 0 ${y}%`,Oe(e,r,n),Fe(a,t,r,i,y)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ee):Ee();})();
1
+ "use strict";(()=>{var T=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,n=e.length;r<n;r++)t[r]=e[r];return t}},$=class{static getHashCode(e){let t=5381,r=t;for(let n=0,s=e.length;n<s&&e[n]!="\0"&&(t=(t<<5)+t^e.charCodeAt(n),n!==s-1&&e[n+1]!=="\0");n+=2)r=(r<<5)+r^e.charCodeAt(n+1);return t+1566083941*r|0}},g=class{constructor(e){this.entries=void 0,this.entries=e!==void 0?e:new Map}add(e,t){if(this.entries.has(e))throw new Error(`A meta entry with key ${e} is already present.`);this.entries.set(e,t)}get(e){return this.entries.get(e)}get allEntries(){return this.entries}toJSON(){return{entries:Object.fromEntries(this.entries)}}},N=class{static mergeMeta(e){if(e.length===0)return new g;if(e.length===1)return e[0];let t=new Map;for(let n of e)for(let[s,a]of n.allEntries){let o=t.get(s);o===void 0?t.set(s,[a]):o.push(a)}let r=new Map;for(let[n,s]of t)if(s.length!==1){if(s.every(a=>typeof a=="number")){let a=s.reduce((o,h)=>o+h,0);r.set(n,a);continue}for(let a=0;a<s.length;a++)r.set(`${n}_${a}`,s[a])}else r.set(n,s[0]);return new g(r)}},P=class{static isSurrogate(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}static isAlphanumeric(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122}static isLowerAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122}},G=class{constructor(e,t){this.usableSearchers=void 0,this.usableSearchers=new Map;for(let r of t)e.includes(r.type)&&this.usableSearchers.set(r.type,r)}has(e){return this.usableSearchers.has(e)}minQuality(e){return this.usableSearchers.get(e).minQuality}spec(e){return this.usableSearchers.get(e)}},b=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},d,k;(function(i){i.Fuzzy="fuzzy",i.Substring="substring",i.Prefix="prefix"})(d||(d={}));var H=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},R=class extends H{constructor(e){super(d.Fuzzy,e)}},z=class extends H{constructor(e){super(d.Substring,e)}},A=class extends H{constructor(e){super(d.Prefix,e)}},M=class{constructor(e,t=10,r=[new R(.3),new z(0),new A(0)]){this.string=void 0,this.topN=void 0,this.searchers=void 0,this.string=e,this.topN=Math.max(0,t),this.searchers=r}},Y=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},Z=class{static mergeResults(e,t){let r=e.query,n=this.mergeMatches(e.matches,t.matches,r.topN),s=N.mergeMeta([e.meta,t.meta]);return new b(n,r,s)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let n=[...e,...t];return n.sort((s,a)=>s.quality>a.quality?-1:s.quality<a.quality?1:0),n.length<=r?n:n.slice(0,r)}},ee=class{constructor(e,t,r){this.maxQueryLength=void 0,this.mainSearcher=void 0,this.secondarySearcher=void 0,this.maxQueryLength=e,this.mainSearcher=t,this.secondarySearcher=r}indexEntities(e,t,r){return this.secondarySearcher.indexEntities([],t,r),this.mainSearcher.indexEntities(e,t,r)}getMatches(e){return e.string?(e.string.length>this.maxQueryLength&&(e=new M(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),Z.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new b([],e,new g)}tryGetTerms(e){let t=this.mainSearcher.tryGetTerms(e);return t!==null?t:this.secondarySearcher.tryGetTerms(e)}getTerms(){return this.mainSearcher.getTerms().concat(this.secondarySearcher.getTerms())}tryGetEntity(e){var t,r;return(t=(r=this.mainSearcher.tryGetEntity(e))!=null?r:this.secondarySearcher.tryGetEntity(e))!=null?t:null}getEntities(){return this.mainSearcher.getEntities().concat(this.secondarySearcher.getEntities())}removeEntities(e){let t=[];for(let n=0,s=e.length;n<s;n++)(this.mainSearcher.removeEntity(e[n])||this.secondarySearcher.removeEntity(e[n]))&&t.push(e[n]);let r=new g;return new Y(t,r)}upsertEntities(e,t,r){let n=[],s=[];for(let a=0,o=e.length;a<o;a++){let h=e[a],c=t(h);this.tryUpdate(h,c,r)||(n.push(c),s.push(h))}return this.removeEntities(n),s.length>0?this.reindexSecondarySearcher(s,t,r):new g}reindexSecondarySearcher(e,t,r){let n=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(n,t,r)}tryUpdate(e,t,r){return this.tryUpdateSearcher(e,t,r,this.mainSearcher)||this.tryUpdateSearcher(e,t,r,this.secondarySearcher)}tryUpdateSearcher(e,t,r,n){let s=n.tryGetTerms(t);if(s===null)return!1;if(this.termsAreEqual(s,r(e))){if(!n.replaceEntity(t,e,t))throw new Error(`Entity with id ${t} was not present.`);return!0}return!1}termsAreEqual(e,t){return e===t||e!=null&&t!=null&&e.length===t.length&&e.every((r,n)=>r===t[n])}removeEntity(e){return this.mainSearcher.removeEntity(e)||this.secondarySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.mainSearcher.replaceEntity(e,t,r)||this.secondarySearcher.replaceEntity(e,t,r)}save(e){this.mainSearcher.save(e),this.secondarySearcher.save(e)}load(e){this.mainSearcher.load(e),this.secondarySearcher.load(e)}},te=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),n=Math.round(performance.now()-t);return r.meta.add("removalDuration",n),r}upsertEntities(e,t,r){let n=performance.now(),s=this.dynamicSearcher.upsertEntities(e,t,r),a=Math.round(performance.now()-n);return s.add("upsertDuration",a),s}indexEntities(e,t,r){let n=performance.now(),s=this.dynamicSearcher.indexEntities(e,t,r),a=Math.round(performance.now()-n);return s.add("indexingDurationTotal",a),s}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),n=Math.round(performance.now()-t);return r.meta.add("queryDuration",n),r}tryGetEntity(e){return this.dynamicSearcher.tryGetEntity(e)}getEntities(){return this.dynamicSearcher.getEntities()}tryGetTerms(e){return this.dynamicSearcher.tryGetTerms(e)}getTerms(){return this.dynamicSearcher.getTerms()}removeEntity(e){return this.dynamicSearcher.removeEntity(e)}replaceEntity(e,t,r){return this.dynamicSearcher.replaceEntity(e,t,r)}save(e){this.dynamicSearcher.save(e)}load(e){this.dynamicSearcher.load(e)}},re=class{constructor(e,t,r){this.entity=void 0,this.quality=void 0,this.matchedString=void 0,this.entity=e,this.quality=t,this.matchedString=r}},ne=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},q=class{constructor(e,t=0,r){this.string=void 0,this.minQuality=void 0,this.searcherType=void 0,this.string=e,this.minQuality=Math.max(0,Math.min(1,t)),this.searcherType=r}},ie=class{constructor(e,t){this.stringSearcher=void 0,this.searcherTypes=void 0,this.entities=void 0,this.idToIndex=void 0,this.terms=void 0,this.termIndexToEntityIndex=void 0,this.entityIndexToFirstTermIndex=void 0,this.searchersAndQualityOffsets=[{searcherType:d.Prefix,qualityOffset:2},{searcherType:d.Substring,qualityOffset:1},{searcherType:d.Fuzzy,qualityOffset:0}],this.stringSearcher=e,this.searcherTypes=t,this.entities=[],this.idToIndex=new Map,this.terms=[],this.termIndexToEntityIndex=new Int32Array(0),this.entityIndexToFirstTermIndex=new Int32Array(0)}indexEntities(e,t,r){this.entities=[...e],this.idToIndex=new Map,this.terms=[];let n=[],s=[];for(let o=0,h=e.length;o<h;o++){this.idToIndex.set(t(e[o]),o);let c=r(e[o]);s.push(this.terms.length),this.terms.push(...c),n.push(...c.map(()=>o))}this.termIndexToEntityIndex=T.ToInt32Array(n),this.entityIndexToFirstTermIndex=T.ToInt32Array(s);let a=this.stringSearcher.index(this.terms);return a.add("numberOfEntities",this.entities.length),a.add("numberOfTerms",this.terms.length),a}getMatches(e){let t=new ne(e),r=new G(this.searcherTypes,e.searchers);for(let{searcherType:s,qualityOffset:a}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(s)&&this.addMatchesFromSearcher(t,r.spec(s),a)}let n=N.mergeMeta(t.meta);return new b(t.matches,e,n)}addMatchesFromSearcher(e,t,r){let n=Math.max(0,t.minQuality-r);if(n>1)return;let s=new q(e.query.string,n,t.type),a=this.stringSearcher.getMatches(s);this.addMatchesFromResult(e,a,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let n=0,s=t.matches.length;n<s;n++){let a=t.matches[n],o=this.termIndexToEntityIndex[a.index];if(!e.matchedIndexes.has(o)&&this.entities[o]!==null&&(e.matchedIndexes.add(o),e.matches.push(new re(this.entities[o],a.quality+r,this.terms[a.index])),e.matches.length===e.query.topN))break}}tryGetEntity(e){let t=this.idToIndex.get(e);return t===void 0?null:this.entities[t]}getEntities(){return this.entities.filter(e=>e!==null)}tryGetTerms(e){let t=this.idToIndex.get(e);return t===void 0?null:this.terms.slice(this.entityIndexToFirstTermIndex[t],t===this.entities.length-1?this.terms.length:this.entityIndexToFirstTermIndex[t+1])}getTerms(){let e=[];for(let t=0,r=this.termIndexToEntityIndex.length;t<r;t++)this.entities[this.termIndexToEntityIndex[t]]!==null&&e.push(this.terms[t]);return e}removeEntity(e){let t=this.idToIndex.get(e);return t!==void 0&&(this.entities[t]=null,this.idToIndex.delete(e),!0)}replaceEntity(e,t,r){let n=this.idToIndex.get(e);return n!==void 0&&(this.entities[n]=t,this.idToIndex.delete(e),this.idToIndex.set(r,n),!0)}save(e){e.add(this.entities),e.add(this.idToIndex),e.add(this.terms),e.add(this.termIndexToEntityIndex),e.add(this.entityIndexToFirstTermIndex),this.stringSearcher.save(e)}load(e){this.entities=e.get(),this.idToIndex=e.get(),this.terms=e.get(),this.termIndexToEntityIndex=e.get(),this.entityIndexToFirstTermIndex=e.get(),this.stringSearcher.load(e)}},v=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},se=class{constructor(e,t){this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.numberOfSurrogateCharacters=0,this.treatCharacterAsSpace=e,this.allowCharacter=t}normalize(e){let t=new Array(e.length),r=0,n=!1,s=!1;for(let a=0,o=e.length;a<o;a++){let h=this.getNormalizedCharacter(e[a]);h!==""&&(h===" "?n=!0:(n&&s&&(t[r++]=" "),t[r++]=h,s=!0,n=!1))}return s?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!P.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(n=>this.normalize(n)),r=new g;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new v(t,r)}},ae=class{constructor(e){this.normalizationFunction=void 0,this.normalizationFunction=e}normalize(e){return this.normalizationFunction(e)}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new v(t,new g)}},oe=class{constructor(e){this.normalizers=void 0,this.normalizers=e}normalize(e){for(let t=0,r=this.normalizers.length;t<r;t++)e=this.normalizers[t].normalize(e);return e}normalizeBulk(e){let t=new g;for(let r=0,n=this.normalizers.length;r<n;r++){let s=this.normalizers[r].normalizeBulk(e);e=s.strings;for(let a of s.meta.allEntries)t.add(a[0],a[1])}return new v(e,t)}},he=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new v(t,new g)}},ce=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let n=new Map;for(let[s,a]of r)for(let o of a){let h=t(o);n.set(h,s)}this.replacements.push(n)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let n=0,s=e.length;n<s;n++)for(let a of this.replacements){let o=a.get(e[n]);if(o!==void 0){t[r++]=o;break}t[r++]=e[n]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new v(t,new g)}},le=class{static create(e){let t=new he,r=new ce(e.replacements,a=>a.toLowerCase().normalize("NFKC")),n=new ae(a=>a.normalize("NFKD")),s=new se(e.treatCharacterAsSpace,e.allowCharacter);return new oe([t,r,n,s])}},D=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},S=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},ue=class{constructor(e){this.stringSearcher=void 0,this.distinctMapping=void 0,this.sortMapping=void 0,this.stringSearcher=e,this.distinctMapping=new Int32Array(0),this.sortMapping=new Int32Array(0)}index(e){let t=e.map((h,c)=>({term:h,index:c}));t.sort((h,c)=>h.term<c.term?-1:h.term>c.term?1:0),this.sortMapping=new Int32Array(t.length);for(let h=0,c=t.length;h<c;h++)this.sortMapping[h]=t[h].index;let r=[],n=[],s=0,a=null;for(let h=0,c=t.length;h<c;h++){let l=t[h].term;l!=a&&(r[s]=l,n[s]=h,s++),a=l}n[s++]=t.length,this.distinctMapping=T.ToInt32Array(n);let o=this.stringSearcher.index(r);return o.add("numberOfDistinctTerms",r.length),o}getMatches(e){let t=this.stringSearcher.getMatches(e),r=new Array(t.matches.length),n=0;return t.matches.forEach(s=>{let a=this.distinctMapping[s.index+1];for(let o=this.distinctMapping[s.index];o<a;o++)r[n++]=new D(this.sortMapping[o],s.quality)}),new S(r,e,t.meta)}save(e){e.add(this.distinctMapping),e.add(this.sortMapping),this.stringSearcher.save(e)}load(e){this.distinctMapping=e.get(),this.sortMapping=e.get(),this.stringSearcher.load(e)}},de=class{constructor(e,t){this.entitySearcher=void 0,this.searcherTypes=void 0,this.entitySearcher=e,this.searcherTypes=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=new G(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(d.Prefix)&&t.minQuality(d.Prefix)<2.2){let r=new M(e.string,e.topN,[new A(2.3)]),n=this.entitySearcher.getMatches(r);if(n.matches.length==e.topN)return new b(n.matches,e,n.meta)}if(e.string.length<=3&&!t.has(d.Prefix)&&t.has(d.Substring)&&t.minQuality(d.Substring)<1.2){let r=new M(e.string,e.topN,[new z(1.3)]),n=this.entitySearcher.getMatches(r);if(n.matches.length==e.topN)return new b(n.matches,e,n.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},U=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=T.ToInt32Array(this.ids),this.frequencies=T.ToInt32Array(this.frequencies)}get length(){return this.ids.length}save(e){e.add(this.ids),e.add(this.frequencies)}load(e){this.ids=e.get(),this.frequencies=e.get()}},L=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let n=this.ngramToTermIds.get(e);n||(n=new U,this.ngramToTermIds.set(e,n)),n.addId(t,r)}seal(){for(let e of this.ngramToTermIds.values())e.seal()}getIds(e){return this.ngramToTermIds.get(e)}get size(){return this.ngramToTermIds.size}save(e){e.add(this.ngramToTermIds.size);for(let[t,r]of this.ngramToTermIds)e.add(t),r.save(e)}load(e){let t=e.get();for(let r=0;r<t;r++){let n=e.get(),s=new U;s.load(e),this.ngramToTermIds.set(n,s)}}},me=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},ge=class{constructor(e){this.ngramComputer=void 0,this.invertedIndex=void 0,this.numberOfNgrams=void 0,this.commonNgramCounts=void 0,this.ngramComputer=e,this.invertedIndex=new L,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new L,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let a=0,o=e.length;a<o;a++){let h=e[a];if(!this.isValidTerm(h)){this.numberOfNgrams[a]=0,r++;continue}let c=this.ngramComputer.computeNgrams(h);this.numberOfNgrams[a]=c.length;let l=this.getNgramsToFrequency(c);for(let[u,m]of l)this.invertedIndex.add(u,a,m)}this.invertedIndex.seal();let n=Math.round(performance.now()-t),s=new g;return s.add("numberOfInvalidTerms",r),s.add("indexingDurationFuzzySearcher",n),s}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new S([],e,new g);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),n=t.length;this.computeCommonNgramCounts(r);let s=this.getMatchesFromCommonNgrams(n,e.minQuality);return new S(s,e,new g)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let n=this.invertedIndex.getIds(t);if(n!=null)for(let s=0,a=n.length;s<a;s++)this.commonNgramCounts[n.ids[s]]+=Math.min(r,n.frequencies[s])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,n=e.length;r<n;r++){let s=e[r],a=t.get(s);t.set(s,a!==void 0?a+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let n=0,s=this.numberOfNgrams.length;n<s;n++){let a=me.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[n],this.commonNgramCounts[n]);a>t&&r.push(new D(n,a))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new L,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},fe=class{constructor(e,t){this.stringSearcher=void 0,this.penaltyFactor=void 0,this.hashCodes=void 0,this.stringSearcher=e,this.penaltyFactor=1-t,this.hashCodes=new Int32Array(0)}index(e){this.hashCodes=new Int32Array(e.length);for(let t=0,r=e.length;t<r;t++)this.hashCodes[t]=$.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=$.getHashCode(e.string),r=this.stringSearcher.getMatches(e),n=r.matches.map(s=>this.penalizeMatch(s,t)).filter(s=>s.quality>=e.minQuality);return new S(n,r.query,r.meta)}penalizeMatch(e,t){return e.quality*=this.hashCodes[e.index]===t?1:this.penaltyFactor,e}save(e){e.add(this.hashCodes),this.stringSearcher.save(e)}load(e){this.hashCodes=e.get(),this.stringSearcher.load(e)}},ye=class{constructor(e,t){this.ngramN=void 0,this.transformNgram=void 0,this.ngramN=e,this.transformNgram=t??(r=>r)}computeNgrams(e){if(e.length===0)return[];if(e.length<=this.ngramN){let r=this.transformNgram(e);return r?[r]:[]}let t=[];for(let r=0,n=this.maximumNumberOfNgrams(e);r<n;r++){let s=this.transformNgram(e.substring(r,r+this.ngramN));s&&t.push(s)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},pe=class{constructor(e,t,r){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r}normalize(e){return e&&`${this.paddingLeft}${e.split(" ").join(this.paddingMiddle)}${this.paddingRight}`}normalizeBulk(e){let t=e.map(n=>this.normalize(n)),r=new g;return new v(t,r)}},j=class{};j.Value=new Map([["a",["\u1D8F","\u2C65","\u0251","\u1D00","\u0250","\u0252"]],["aa",["\xE5","\uA733"]],["ae",["\xE4","\xE6","\u1D01","\u1D2D","\u1D46","\u01FD","\u01E3","\u1D02"]],["ao",["\uA735"]],["au",["\uA737"]],["av",["\uA739","\uA73B"]],["ay",["\uA73D"]],["b",["\u0180","\u0253","\u0183","\u1D6C","\u1D80","\u0299"]],["c",["\u023C","\u0188","\u0255","\u1D04","\uA73F","\u2184"]],["d",["\u0111","\xF0","\u0256","\u0257","\u018C","\u1D6D","\u1D81","\u1D91","\u0221","\u1D05","\uA77A"]],["db",["\u0238"]],["e",["\u1D92","\u0247","\u2C78","\u1D07","\u0259","\u01DD","\u025B"]],["eo",["\u1D14"]],["f",["\u0192","\u1D6E","\u1D82","\uA730","\uA77C"]],["g",["\u01E5","\u0260","\u1D83","\u0262","\u021D","\u014B","\uA7A1","\u1D79","\uA77F"]],["h",["\u0127","\u2C68","\u0266","\u029C","\u0303","\u0267","\u2C76","\u0265"]],["hv",["\u0195"]],["i",["\u0268","\u1D7B","\u1D96","\u0131","\u026A","\u0269"]],["j",["\u0249","\u0237","\u029D","\u025F","\u0284","\u1D0A"]],["k",["\u0199","\u2C6A","\u1D84","\uA741","\u1D0B","\uA743","\uA745","\uA7A3"]],["l",["\u0142","\u019A","\u2C61","\u026B","\u026C","\u1D85","\u026D","\u0234","\u029F","\uA749","\uA781","\uA747"]],["m",["\u1D6F","\u1D86","\u0271","\u1D0D","\u026F"]],["n",["\u0272","\u019E","\u1D70","\u1D87","\u0273","\u0235","\u0274","\uA791","\uA7A5"]],["o",["\xF8","\u01FF","\u0275","\u0254","\u2C7A","\u1D0F","\uA74B","\uA74D"]],["oe",["\xF6","\u0153"]],["oi",["\u01A3"]],["oo",["\uA74F"]],["ou",["\u0223"]],["p",["\u1D7D","\u01A5","\u1D71","\u1D88","\u1D18","\u01BF","\uA751","\uA753","\uA755"]],["q",["\u024B","\u02A0","\uA757","\uA759"]],["qp",["\u0239"]],["r",["\u024D","\u027D","\uA75B","\u1D72","\u1D89","\u027C","\u027E","\u1D73","\u0280","\u0279","\u0281","\uA7A7","\uA783"]],["s",["\u1D74","\u1D8A","\u0282","\u023F","\uA731","\u0283","\uA7A9","\uA785","\u017F"]],["ss",["\xDF"]],["t",["\u0167","\u2C66","\u01AD","\u0288","\u1D75","\u01AB","\u0236","\u1D1B","\uA787"]],["th",["\xFE"]],["tz",["\uA729"]],["u",["\u0289","\u028A","\u1D7E","\u1D1C","\u1D99"]],["ue",["\xFC","\u1D6B"]],["v",["\u028B","\u1D8C","\u2C71","\u2C74","\u1D20","\u028C","\uA75F"]],["vy",["\uA761"]],["w",["\u2C73","\u1D21","\u028D"]],["x",["\u1D8D"]],["y",["\u024F","\u01B4","\u028F","\u1EFF"]],["z",["\u01B6","\u0225","\u2C6C","\u1D76","\u1D8E","\u0290","\u0291","\u0240","\u1D22","\u0292","\u01B9","\uA763"]]]);var K=class i{constructor(e,t,r){this.replacements=void 0,this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.replacements=e,this.treatCharacterAsSpace=t,this.allowCharacter=r}static createDefaultConfig(){let e=new Set(["_","-","\u2013","/",","," "]);return new i([j.Value],t=>e.has(t),t=>P.isAlphanumeric(t))}},_=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),n=Math.round(performance.now()-t),s=this.stringSearcher.index(r.strings);s.add(this.normalizationDurationMetaKey,n);for(let a of r.meta.allEntries)s.add(a[0],a[1]);return s}getMatches(e){let t=new q(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new S(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},Se=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new S([],e,new g);let t=this.modifyQueryString(e.string),r=new q(t,e.minQuality,e.searcherType);return this.suffixArraySearcher.getMatches(r,e.string.length)}modifyQueryString(e){return`${this.suffixArraySearcher.separator}${e}`}save(e){this.suffixArraySearcher.save(e)}load(e){this.suffixArraySearcher.load(e)}},we=class{constructor(e,t,r){this.prefixSearcher=void 0,this.substringSearcher=void 0,this.fuzzySearcher=void 0,this.prefixSearcher=e,this.substringSearcher=t,this.fuzzySearcher=r}index(e){let t=[];if(this.prefixSearcher&&!this.substringSearcher){let r=this.prefixSearcher.index(e);t.push(r)}if(this.substringSearcher){let r=this.substringSearcher.index(e);t.push(r)}if(this.fuzzySearcher){let r=this.fuzzySearcher.index(e);t.push(r)}return N.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case d.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case d.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case d.Fuzzy:if(!this.fuzzySearcher)throw new Error("No fuzzy searcher has been indexed.");return this.fuzzySearcher.getMatches(e);default:throw new Error(`Unknown searcher type: ${e.searcherType}`)}}save(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.save(e),this.substringSearcher&&this.substringSearcher.save(e),this.fuzzySearcher&&this.fuzzySearcher.save(e)}load(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.load(e),this.substringSearcher&&this.substringSearcher.load(e),this.fuzzySearcher&&this.fuzzySearcher.load(e)}};(function(i){i.QualityAndIndex="qualityAndIndex",i.QualityAndMatchedString="qualityAndMatchedString"})(k||(k={}));var ve=class{constructor(e,t){this.sortOrder=void 0,this.entitySearcher=void 0,this.collator=new Intl.Collator(void 0,{numeric:!0}),this.sortOrder=e,this.entitySearcher=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=this.entitySearcher.getMatches(e);switch(this.sortOrder){case k.QualityAndIndex:return t;case k.QualityAndMatchedString:return this.sortMatchesByQualityAndMatchedString(t.matches),t;default:throw new Error(`Unsupported sort order: ${this.sortOrder}`)}}sortMatchesByQualityAndMatchedString(e){e.sort((t,r)=>t.quality>r.quality?-1:t.quality<r.quality?1:this.collator.compare(t.matchedString,r.matchedString))}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}save(e){this.entitySearcher.save(e)}load(e){this.entitySearcher.load(e)}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}},xe=class{constructor(e){this.stringSearcher=void 0,this.stringSearcher=e}index(e){return this.stringSearcher.index(e)}getMatches(e){let t=this.stringSearcher.getMatches(e);return t.matches.sort(this.compareMatchesByQualityAndIndex),t}compareMatchesByQualityAndIndex(e,t){return e.quality>t.quality?-1:e.quality<t.quality?1:e.index<t.index?-1:e.index>t.index?1:0}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},F=class{static compareOrdinal(e,t,r,n,s){let a=Math.min(t+s,e.length),o=Math.min(n+s,r.length),h=t,c=n;for(;h<a&&c<o;){let m=e.charCodeAt(h),y=r.charCodeAt(c);if(m<y)return-1;if(m>y)return 1;h++,c++}let l=a-t,u=o-n;return l===u?0:l<u?-1:1}},Te=class i{static create(e){if(e==null)throw new Error("Input string cannot be null.");let t=new i(e);return t.FormInitialChains(),t.BuildSufixArray(),t.sa}constructor(e){this.inputString=void 0,this.eoc=2147483647,this.sa=void 0,this.isa=void 0,this.chainHeadsDict=void 0,this.chainStack=[],this.subChains=[],this.nextRank=1,this.inputString=e;let t=e.length;this.sa=new Int32Array(t),this.isa=new Int32Array(t),this.chainHeadsDict=new Map}FormInitialChains(){this.FindInitialChains(),this.SortAndPushSubchains()}FindInitialChains(){for(let e=0;e<this.inputString.length;e++){let t=this.inputString.charCodeAt(e),r=this.chainHeadsDict.get(t);this.isa[e]=r!==void 0?r:this.eoc,this.chainHeadsDict.set(t,e)}for(let e of this.chainHeadsDict.values()){let t=new V(e,1);this.subChains.push(t)}}BuildSufixArray(){for(;this.chainStack.length>0;){let e=this.chainStack.pop();this.isa[e.head]===this.eoc?this.RankSuffix(e.head):this.RefineChainWithInductionSorting(e)}}RankSuffix(e){this.isa[e]=-this.nextRank,this.sa[this.nextRank-1]=e,this.nextRank++}RefineChainWithInductionSorting(e){let t=[];for(this.chainHeadsDict.clear(),this.subChains=[];e.head!==this.eoc;){let r=this.isa[e.head];if(e.head+e.length>this.inputString.length-1)this.RankSuffix(e.head);else if(this.isa[e.head+e.length]<0){let n=new be(e.head,-this.isa[e.head+e.length]);t.push(n)}else this.ExtendChain(e);e.head=r}this.SortAndPushSubchains(),this.SortAndRankNotedSuffixes(t)}ExtendChain(e){let t=this.inputString.charCodeAt(e.head+e.length);if(this.chainHeadsDict.has(t))this.isa[this.chainHeadsDict.get(t)]=e.head,this.isa[e.head]=this.eoc;else{this.isa[e.head]=this.eoc;let r=new V(e.head,e.length+1);this.subChains.push(r)}this.chainHeadsDict.set(t,e.head)}SortAndRankNotedSuffixes(e){e.sort((t,r)=>t.rank-r.rank);for(let t=0;t<e.length;t++)this.RankSuffix(e[t].head)}SortAndPushSubchains(){this.subChains.sort((e,t)=>{let r=Math.min(e.length,t.length);return F.compareOrdinal(this.inputString,e.head,this.inputString,t.head,r)});for(let e=this.subChains.length-1;e>=0;e--)this.chainStack.push(this.subChains[e])}},be=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},V=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},Me=class{constructor(e){this.separator=void 0,this.str=void 0,this.suffixArray=void 0,this.indexToTermIndex=void 0,this.termLengths=void 0,this.separator=e,this.str="",this.suffixArray=new Int32Array(0),this.indexToTermIndex=new Int32Array(0),this.termLengths=new Int32Array(0)}index(e){let t=performance.now();this.str=e.length>0?this.separator+e.join(this.separator)+this.separator:"",this.suffixArray=Te.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let a=0;a<e.length;a++){this.termLengths[a]=e[a].length;for(let o=0;o<=e[a].length;o++)this.indexToTermIndex[r++]=a}this.indexToTermIndex[r++]=-1;let n=Math.round(performance.now()-t),s=new g;return s.add("indexingDurationSuffixArraySearcher",n),s}getMatches(e,t){if(!e.string)return new S([],e,new g);let[r,n]=this.GetPositionsInSuffixArray(e.string),s=new Int32Array(n-r),a=new Set,o=0;for(let l=r;l<n;l++){let u=this.indexToTermIndex[this.suffixArray[l]];a.has(u)||(a.add(u),s[o++]=u)}let h=[];t=t??e.string.length;let c=0;for(let l=0;l<o;l++)c=this.computeQuality(t,this.termLengths[s[l]]),c>e.minQuality&&h.push(new D(s[l],c));return new S(h,e,new g)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,n=0;for(;t<r;)n=Math.floor((t+r)/2),F.compareOrdinal(e,0,this.str,this.suffixArray[n],e.length)>0?t=n+1:r=n;let s=t;for(r=this.suffixArray.length;t<r;)n=Math.floor((t+r)/2),F.compareOrdinal(e,0,this.str,this.suffixArray[n],e.length)==0?t=n+1:r=n;return[s,r]}save(e){e.add(this.str),e.add(this.suffixArray),e.add(this.indexToTermIndex),e.add(this.termLengths)}load(e){this.str=e.get(),this.suffixArray=e.get(),this.indexToTermIndex=e.get(),this.termLengths=e.get()}},J=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),n=this.tryCreateSubstringSearcher(e),s=this.tryCreatePrefixSearcher(e,n),a=new we(s,n,r);a=new ue(a),a=new xe(a),a=new _(a,t,"normalizationDurationDefault");let o=new ie(a,e.searcherTypes);return o=new de(o,e.searcherTypes),o=new ve(e.sortOrder,o),o}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(n=>t.add(n)),e.fuzzySearchConfig.paddingRight.split("").forEach(n=>t.add(n)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(n=>t.add(n))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(n=>t.add(n));let r=new K(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,n=>e.normalizerConfig.allowCharacter(n)&&!t.has(n));return le.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(d.Fuzzy))return null;if(e.fuzzySearchConfig===void 0)throw new Error("Unable to create fuzzy searcher: No fuzzy search config provided.");return this.createFuzzySearcher(e.fuzzySearchConfig)}static createFuzzySearcher(e){let t=new ye(e.ngramN,e.transformNgram),r=new pe(e.paddingLeft,e.paddingRight,e.paddingMiddle),n=new ge(t);return n=new fe(n,e.inequalityPenalty),n=new _(n,r,"normalizationDurationNgrams"),n}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(d.Substring))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create substring searcher: No substring search config provided.");return this.createSubstringSearcher(e.substringSearchConfig)}static createSubstringSearcher(e){return new Me(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(d.Prefix))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create prefix searcher: No substring search config provided.");return this.createPrefixSearcher(e.substringSearchConfig,t)}static createPrefixSearcher(e,t){return t===null&&(t=this.createSubstringSearcher(e)),new Se(t)}},Ee=class i{constructor(e,t,r,n,s,a){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.ngramN=void 0,this.transformNgram=void 0,this.inequalityPenalty=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r,this.ngramN=n,this.transformNgram=s,this.inequalityPenalty=a}static createDefaultConfig(){return new i("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var Ce=class i{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new i("$")}},Ie=class i{constructor(e,t,r,n,s,a){this.searcherTypes=void 0,this.maxQueryLength=void 0,this.sortOrder=void 0,this.normalizerConfig=void 0,this.fuzzySearchConfig=void 0,this.substringSearchConfig=void 0,this.searcherTypes=e,this.maxQueryLength=t,this.sortOrder=r,this.normalizerConfig=n,this.fuzzySearchConfig=s,this.substringSearchConfig=a}static createDefaultConfig(){let e=[d.Fuzzy,d.Substring,d.Prefix],t=k.QualityAndMatchedString,r=K.createDefaultConfig(),n=Ee.createDefaultConfig(),s=Ce.createDefaultConfig();return new i(e,150,t,r,n,s)}},W=class{static createSearcher(e){let t=J.createSearcher(e),r=J.createSearcher(e),n=new ee(e.maxQueryLength,t,r);return n=new te(n),n}static createDefaultSearcher(){let e=Ie.createDefaultConfig();return this.createSearcher(e)}};function ze(i,e){if(i.length===0)return null;let t=i.find(n=>n.sourceStart<=e&&e<=n.sourceEnd);if(t)return t.commentrayLine;if(e<i[0].sourceStart)return i[0].commentrayLine;let r=i[0];for(let n of i)if(n.sourceStart<=e)r=n;else break;return r.commentrayLine}function Ae(i,e){if(i.length===0)return null;let t=i[0];for(let r of i)if(r.commentrayLine<=e)t=r;else break;return t.sourceStart-1}function E(i,e,t,r,n){let s=Math.max(0,e-t),a=Math.max(0,r-n);return s<=0?0:i/s*a}function O(i){let e=i.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function ke(i,e){function t(r){let n=i.getAttribute(r);return n!==null&&n.trim()!==""?n:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function He(i,e){let t=e.map(h=>h.trim()).filter(Boolean);if(t.length===0)return[];let r=i.toLowerCase(),n=t.map(h=>h.toLowerCase()),s=[],a=0,o=0;for(;a<i.length&&o<400;){let h=a,c=-1,l=!0;for(let u of n){if(u.length===0)continue;let m=r.indexOf(u,h);if(m<0){l=!1;break}c<0&&(c=m),h=m+u.length}if(!l||c<0)break;s.push({start:c,end:h}),o++,a=c+1}return s}function Re(i,e){let t=Math.max(0,Math.min(e,i.length)),r=0;for(let n=0;n<t;n++)i[n]===`
2
+ `&&r++;return r}function qe(i,e){let t=i.split(`
3
+ `);return e<0||e>=t.length?"":t[e]??""}function Le(i,e){try{return i.getItem(e)}catch{return null}}function X(i,e,t){try{i.setItem(e,t)}catch{}}function je(i){return i.trim().split(/\s+/).filter(Boolean)}function Oe(i,e,t){return Math.max(e,Math.min(t,i))}function B(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ke(i,e){let t=i.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function _e(i,e){let t=new Map;for(let r of i){let n=r.kind==="path"?`path:${String(r.line)}:${r.text.slice(0,64)}`:`${r.kind}:${r.line}`,s=t.get(n);(!s||r.score>s.score)&&t.set(n,r)}return[...t.values()].sort((r,n)=>n.score-r.score).slice(0,e)}function Ne(i,e,t){let r=He(i,t),n=new Set,s=[];for(let a of r){let o=Re(i,a.start);n.has(o)||(n.add(o),s.push({kind:e,line:o,text:qe(i,o),score:1e3,source:"ordered"}))}return s}function Ve(i,e,t){let r=e.trim();if(!r)return[];let n=new M(r,t,[new R(.22),new z(0),new A(0)]),s=i.getMatches(n),a=[];for(let o of s.matches){let h=o.entity;a.push({kind:h.kind,line:h.line,text:h.text,score:100+o.quality,source:"fuzzy"})}return a}function Je(i){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:n,rawMd:s,searcher:a,queryRaw:o,tokens:h}=i,c=[t,r].filter(C=>C.trim().length>0).join(`
4
+ `),l=e==="commentray-and-paths"?[]:Ne(n,"code",h),u=e==="commentray-and-paths"&&c?Ne(c,"path",h):[],m=Ne(s,"md",h),y=Ve(a,o,60);return _e([...l,...u,...m,...y],80)}function We(i,e){if(e.length===0)return'<div class="hint">No matches. Try fewer tokens or looser spelling (fuzzy matches per line).</div>';let t=i==="commentray-and-paths"?"Paths + commentray only (no code-body indexing): ordered tokens and per-line fuzzy ranking.":"Whole source: whitespace tokens in order (may span lines). Per-line fuzzy ranking for typos.",r=[];r.push(`<div class="hint">${t} ${e.length} hit(s).</div>`);for(let n of e){let s=n.kind==="code"?`Code L${n.line+1}`:n.kind==="path"?`Path L${n.line+1}`:`Commentray L${n.line+1}`,a=n.source==="ordered"?"ordered":"fuzzy";r.push(`<button type="button" class="hit" data-kind="${n.kind}" data-line="${String(n.line)}"><span class="meta">${s} <span class="src-tag">(${a})</span></span><div class="snippet">${B(Ke(n.text,200))}</div></button>`)}return r.join("")}function Xe(i){return{scope:(i.getAttribute("data-search-scope")||"")==="commentray-and-paths"?"commentray-and-paths":"full",filePathLabel:i.getAttribute("data-search-file-path")||"",commentrayPathLabel:i.getAttribute("data-search-commentray-path")||""}}function Ye(i,e,t,r,n){let s=t.split(`
5
+ `),a=e.split(`
6
+ `),o=[];return i==="commentray-and-paths"&&(r.trim()&&o.push({kind:"path",line:o.length,text:r}),n.trim()&&o.push({kind:"path",line:o.length,text:n})),[...i==="full"?a.map((h,c)=>({kind:"code",line:c,text:h})):[],...o,...s.map((h,c)=>({kind:"md",line:c,text:h}))]}function Ze(i){let e=W.createDefaultSearcher();return e.indexEntities(i,t=>`${t.kind}:${t.kind==="path"?t.text:t.line}`,t=>[t.text]),e}function et(i){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:n,rawMd:s,mdLines:a,searcher:o,searchInput:h,searchClear:c,searchResults:l,docPane:u}=i,m;function y(){clearTimeout(m),m=void 0,h.value="",l.innerHTML="",l.hidden=!0}function C(){let p=je(h.value);if(p.length===0){l.hidden=!0,l.innerHTML="";return}let f=Je({scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:n,rawMd:s,searcher:o,queryRaw:h.value,tokens:p});l.hidden=!1,l.innerHTML=We(e,f)}l.addEventListener("click",p=>{let f=p.target;for(;f&&f!==l&&(!f.classList||!f.classList.contains("hit"));)f=f.parentElement;if(!f||!f.classList||!f.classList.contains("hit"))return;let x=f.getAttribute("data-kind"),I=parseInt(f.getAttribute("data-line")||"0",10);if(x==="code"){let w=document.getElementById(`code-line-${String(I)}`);w&&w.scrollIntoView({block:"nearest",behavior:"smooth"})}else if(x==="path")u.scrollTo({top:0,behavior:"smooth"});else{let w=a.length;if(w<=0)return;let Q=I/Math.max(1,w-1),Ue=u.scrollHeight-u.clientHeight;u.scrollTo({top:Q*Math.max(0,Ue),behavior:"smooth"})}}),h.addEventListener("input",()=>{clearTimeout(m),m=setTimeout(C,200)}),c.addEventListener("click",y),document.addEventListener("keydown",p=>{if(p.key!=="Escape")return;let f=h.value.trim().length>0,x=document.activeElement===h,I=!l.hidden;!f&&!x&&!I||(y(),x&&h.blur(),p.preventDefault())})}function Be(i,e,t){let r=Le(localStorage,i)==="1";t.checked=r,r&&e.classList.add("wrap"),t.addEventListener("change",()=>{t.checked?(e.classList.add("wrap"),X(localStorage,i,"1")):(e.classList.remove("wrap"),X(localStorage,i,"0"))})}function tt(i){let e=i.trim();if(!e)return[];try{let t=JSON.parse(O(e));if(!Array.isArray(t))return[];let r=[];for(let n of t){if(typeof n!="object"||n===null)continue;let s=n;typeof s.id=="string"&&typeof s.commentrayLine=="number"&&typeof s.sourceStart=="number"&&typeof s.sourceEnd=="number"&&r.push({id:s.id,commentrayLine:s.commentrayLine,sourceStart:s.sourceStart,sourceEnd:s.sourceEnd})}return r}catch{return[]}}function rt(i){let e=i.getBoundingClientRect().top+2,t=i.querySelectorAll('[id^="code-line-"]');for(let r of t)if(r.getBoundingClientRect().bottom>e){let s=/^code-line-(\d+)$/.exec(r.id);return s?Number(s[1])+1:1}return t.length>0?t.length:1}function nt(i){let e=i.getBoundingClientRect().top+2,t=i.querySelectorAll(".commentray-block-anchor"),r=0;for(let n of t){let s=n.getAttribute("data-commentray-line");if(!(s===null||s===""))if(n.getBoundingClientRect().top<=e+1)r=Number(s);else break}return r}function Qe(i,e,t,r){let n="none";i.addEventListener("scroll",()=>{n!=="doc"&&(n="code",t(),n="none")},{passive:!0}),e.addEventListener("scroll",()=>{n!=="code"&&(n="doc",r(),n="none")},{passive:!0})}function it(i,e,t){Qe(i,e,()=>{let r=rt(i),n=ze(t,r);if(n===null)e.scrollTop=E(i.scrollTop,i.scrollHeight,i.clientHeight,e.scrollHeight,e.clientHeight);else{let s=e.querySelector(`[data-commentray-line="${String(n)}"]`);if(s instanceof HTMLElement){let a=s.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=Math.max(0,a-2)}else e.scrollTop=E(i.scrollTop,i.scrollHeight,i.clientHeight,e.scrollHeight,e.clientHeight)}},()=>{let r=nt(e),n=Ae(t,r);if(n===null)i.scrollTop=E(e.scrollTop,e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight);else{let s=document.getElementById(`code-line-${String(n)}`);if(s){let a=s.getBoundingClientRect().top-i.getBoundingClientRect().top+i.scrollTop;i.scrollTop=Math.max(0,a-2)}else i.scrollTop=E(e.scrollTop,e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight)}})}function st(i,e){Qe(i,e,()=>{e.scrollTop=E(i.scrollTop,i.scrollHeight,i.clientHeight,e.scrollHeight,e.clientHeight)},()=>{i.scrollTop=E(e.scrollTop,e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight)})}function at(i){if(typeof i!="object"||i===null)return!1;let e=i;return typeof e.sourcePath=="string"&&typeof e.commentrayPath=="string"&&typeof e.sourceOnGithub=="string"&&typeof e.commentrayOnGithub=="string"}function $e(i){let e=[];if(!Array.isArray(i))return e;for(let t of i)at(t)&&e.push(t);return e}function ot(i){let e=i.trim();if(e==="")return[];try{let t=JSON.parse(O(e));return $e(t)}catch{return[]}}function ht(i,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=i;for(let n=0;n<t.length;n++){let s=t[n];if(s===void 0)continue;r.children.has(s)||r.children.set(s,{children:new Map,pairs:[]});let a=r.children.get(s);if(a===void 0)return;n===t.length-1&&a.pairs.push(e),r=a}}function Pe(i){let e=[...i.children.keys()].sort((r,n)=>r.localeCompare(n));if(e.length===0)return"";let t=[];for(let r of e){let n=i.children.get(r);if(n!==void 0){if(n.children.size>0){let s=Pe(n);t.push(`<li><div class="tree-dir">${B(r)}</div>${s}</li>`)}if(n.pairs.length>0)for(let s of n.pairs)t.push(`<li><div class="tree-file"><span class="tree-file-name">${B(s.sourcePath)}</span><span class="tree-file-links"><a href="${B(s.sourceOnGithub)}" target="_blank" rel="noopener noreferrer">source</a><a href="${B(s.commentrayOnGithub)}" target="_blank" rel="noopener noreferrer">commentray</a></span></div></li>`)}}return`<ul>${t.join("")}</ul>`}function ct(i,e,t){e.hidden=!t,i.setAttribute("aria-expanded",t?"true":"false")}function lt(i,e){if(e.length===0){i.innerHTML='<p class="documented-files-panel__hint">No <code class="documented-files-panel__code">documentedPairs</code> in this export (build with a GitHub repo URL).</p>';return}let t={children:new Map,pairs:[]};for(let r of e)ht(t,r);i.innerHTML=Pe(t)}function ut(i,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=ot(e),t.length>0))return;if(i.length===0){t=[];return}let n=await fetch(i,{credentials:"same-origin"});if(!n.ok)throw new Error(`nav json ${String(n.status)}`);let s=await n.json();t=$e(s.documentedPairs)})()),await r,t??[])}function dt(){let i=document.getElementById("documented-files-toggle"),e=document.getElementById("documented-files-panel"),t=document.getElementById("documented-files-tree"),r=document.getElementById("shell");if(!(i instanceof HTMLButtonElement)||!e||!t)return;let n=i.getAttribute("data-nav-json-url")?.trim()??"",s=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(n.length===0&&s.length===0)return;let a=ut(n,s);i.addEventListener("click",()=>{let o=e.hidden!==!1;ct(i,e,o),o&&(async()=>{try{let h=await a();lt(t,h)}catch{t.innerHTML='<p class="documented-files-panel__hint">Could not load the file list. Check the browser network tab.</p>'}})()})}function mt(i,e,t,r,n){let s=!1,a=n;function o(c){if(!s)return;let l=e.getBoundingClientRect(),u=c.clientX-l.left,m=Oe(u/l.width*100,15,85);a=m,t.style.flex=`0 0 ${m}%`}function h(){s=!1,window.removeEventListener("mousemove",o),window.removeEventListener("mouseup",h),document.body.style.cursor="",document.body.style.userSelect="",X(localStorage,i,String(a))}r.addEventListener("mousedown",c=>{c.preventDefault(),s=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",o),window.addEventListener("mouseup",h)})}var De="commentray.codeCommentrayStatic.splitPct",Ge="commentray.codeCommentrayStatic.wrap";function gt(i){let e=document.getElementById("wrap-lines");e&&Be(Ge,i,e)}function ft(i,e){let t=document.getElementById("doc-pane"),r=document.getElementById("gutter"),n=document.getElementById("wrap-lines"),s=document.getElementById("search-q"),a=document.getElementById("search-clear"),o=document.getElementById("search-results");if(!t||!r||!n||!s||!a||!o)return;let{rawCodeB64:h,rawMdB64:c}=ke(i,e),l=O(h),u=O(c),m=tt(i.getAttribute("data-scroll-block-links-b64")||""),{scope:y,filePathLabel:C,commentrayPathLabel:p}=Xe(i),f=u.split(`
7
+ `),x=Ye(y,l,u,C,p),I=Ze(x);et({scope:y,filePathLabel:C,commentrayPathLabel:p,rawCode:l,rawMd:u,mdLines:f,searcher:I,searchInput:s,searchClear:a,searchResults:o,docPane:t});let w=parseFloat(Le(localStorage,De)||"50"),Q=Oe(Number.isFinite(w)?w:50,15,85);e.style.flex=`0 0 ${Q}%`,Be(Ge,e,n),mt(De,i,e,r,Q),m.length>0?it(e,t,m):st(e,t)}function Fe(){dt();let i=document.getElementById("shell"),e=document.getElementById("code-pane");if(!i||!e)return;if((i.getAttribute("data-layout")||"dual")==="stretch"){gt(e);return}ft(i,e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Fe):Fe();})();