markupress 0.0.2 → 0.2.0

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 (49) hide show
  1. package/README.md +292 -22
  2. package/dist/cli.js +1 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/content.d.ts +69 -3
  5. package/dist/content.d.ts.map +1 -1
  6. package/dist/content.js +191 -62
  7. package/dist/content.js.map +1 -1
  8. package/dist/controllers/code.d.ts +7 -0
  9. package/dist/controllers/code.d.ts.map +1 -0
  10. package/dist/controllers/code.js +31 -0
  11. package/dist/controllers/code.js.map +1 -0
  12. package/dist/controllers/outline.d.ts +8 -0
  13. package/dist/controllers/outline.d.ts.map +1 -0
  14. package/dist/controllers/outline.js +45 -0
  15. package/dist/controllers/outline.js.map +1 -0
  16. package/dist/controllers/shell.d.ts +5 -1
  17. package/dist/controllers/shell.d.ts.map +1 -1
  18. package/dist/controllers/shell.js +12 -25
  19. package/dist/controllers/shell.js.map +1 -1
  20. package/dist/index.d.ts +6 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/markdown.d.ts +24 -0
  25. package/dist/markdown.d.ts.map +1 -0
  26. package/dist/markdown.js +46 -0
  27. package/dist/markdown.js.map +1 -0
  28. package/dist/navigation.d.ts +37 -0
  29. package/dist/navigation.d.ts.map +1 -0
  30. package/dist/navigation.js +52 -0
  31. package/dist/navigation.js.map +1 -0
  32. package/dist/site.d.ts +31 -10
  33. package/dist/site.d.ts.map +1 -1
  34. package/dist/site.js +174 -262
  35. package/dist/site.js.map +1 -1
  36. package/dist/theme.d.ts +2 -1
  37. package/dist/theme.d.ts.map +1 -1
  38. package/dist/theme.js +4 -34
  39. package/dist/theme.js.map +1 -1
  40. package/dist/versions.d.ts +4 -1
  41. package/dist/versions.d.ts.map +1 -1
  42. package/dist/versions.js +30 -45
  43. package/dist/versions.js.map +1 -1
  44. package/package.json +22 -12
  45. package/styles/base.css +1 -21
  46. package/styles/prose.css +38 -0
  47. package/theme/outline.html +11 -0
  48. package/theme/shell.html +66 -0
  49. package/theme/theme.css +52 -0
@@ -0,0 +1,24 @@
1
+ import type { HtmlKitPlugin } from '@nextwebwg/htmlkit';
2
+ import { type CompiledMarkdown, type FrontMatter } from './content.js';
3
+ export interface MarkdownPluginOptions {
4
+ /** Directory that a page's root-relative images and files (/logo.svg) come from; without one they stay site URLs. */
5
+ readonly publicDir?: (file: string) => string | undefined;
6
+ /** Called with each compiled page and its URL, for example to catalog documents. */
7
+ readonly onPage?: (page: CompiledMarkdown & {
8
+ readonly file: string;
9
+ readonly href: string | undefined;
10
+ }) => void;
11
+ /** Stylesheet files every Markdown page component imports, such as a theme's prose styles. */
12
+ readonly styles?: readonly string[];
13
+ /** Number the lines of every highlighted code block unless its fence says `:no-line-numbers`. */
14
+ readonly lineNumbers?: boolean;
15
+ /** Front matter for a page that its own fields override, such as a site-wide default. */
16
+ readonly frontmatter?: (file: string) => FrontMatter | undefined;
17
+ }
18
+ /**
19
+ * An HTMLKit page plugin: each .md file compiles to an HTML Next page, which HTMLKit routes, orders,
20
+ * renders, and builds like an .html page. Links to other .md files and referenced files resolve
21
+ * through HTMLKit, so the plugin holds no routing of its own.
22
+ */
23
+ export declare function markdown(options?: MarkdownPluginOptions): HtmlKitPlugin;
24
+ //# sourceMappingURL=markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAmB,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAExF,MAAM,WAAW,qBAAqB;IACpC,qHAAqH;IACrH,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC1D,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,GAAG;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,KAAK,IAAI,CAAC;IAClH,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,iGAAiG;IACjG,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,CAAC;CAClE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,qBAA0B,GAAG,aAAa,CAW3E"}
@@ -0,0 +1,46 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { dirname, resolve } from 'node:path';
3
+ import { compileMarkdown } from './content.js';
4
+ /**
5
+ * An HTMLKit page plugin: each .md file compiles to an HTML Next page, which HTMLKit routes, orders,
6
+ * renders, and builds like an .html page. Links to other .md files and referenced files resolve
7
+ * through HTMLKit, so the plugin holds no routing of its own.
8
+ */
9
+ export function markdown(options = {}) {
10
+ return { name: 'markdown', pages: { extensions: ['.md'], async compile(source, page) {
11
+ const href = page.href(page.file);
12
+ // The URL, not the machine's path, names the page, so builds are reproducible.
13
+ const pageName = 'page-md-' + createHash('sha256').update(href ?? page.file).digest('hex').slice(0, 20);
14
+ const frontmatter = options.frontmatter?.(page.file);
15
+ const compiled = await compileMarkdown(source, { file: page.file, pageName, ...(options.styles ? { styles: options.styles } : {}),
16
+ ...(options.lineNumbers === undefined ? {} : { lineNumbers: options.lineNumbers }), ...(frontmatter ? { frontmatter } : {}), resolveLink: (target, kind) => link(target, kind, page, options) });
17
+ options.onPage?.({ ...compiled, file: page.file, href });
18
+ return compiled.resource;
19
+ } } };
20
+ }
21
+ function link(href, kind, page, options) {
22
+ if (/^(?:[A-Za-z][A-Za-z\d+.-]*:|#|\/\/)/.test(href))
23
+ return href;
24
+ if (href.startsWith('/') && kind === 'link')
25
+ return href;
26
+ const [path, suffix = ''] = href.split(/(?=[?#])/, 2);
27
+ let target;
28
+ if (path.startsWith('/')) {
29
+ const directory = options.publicDir?.(page.file);
30
+ if (directory === undefined)
31
+ return href;
32
+ target = resolve(directory, '.' + decodeURIComponent(path));
33
+ }
34
+ else
35
+ target = resolve(dirname(page.file), decodeURIComponent(path));
36
+ if (path.endsWith('.md')) {
37
+ const url = page.href(target);
38
+ if (url === undefined)
39
+ throw new Error(`${page.file}: missing document ${href}.`);
40
+ return url + suffix;
41
+ }
42
+ if (kind === 'asset' || path.includes('.'))
43
+ return page.asset(target) + suffix;
44
+ return href;
45
+ }
46
+ //# sourceMappingURL=markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAE,eAAe,EAA2C,MAAM,cAAc,CAAC;AAexF;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAO,GAA0B,EAAE;IAC1D,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI;gBACjF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAClC,+EAA+E;gBAC/E,MAAM,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAA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AG,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC,CAAsB,CAAC;IAC3E,IAAI,MAAc,CAAC;IACnB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,IAAI,SAAS,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACzC,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;;QAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,sBAAsB,IAAI,GAAG,CAAC,CAAC;QAClF,OAAO,GAAG,GAAG,MAAM,CAAC;IACtB,CAAC;IACD,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC/E,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { NavigationNode } from '@nextwebwg/htmlkit';
2
+ /** A top navigation or footer link. A path starting with `/` is a page of the selected version. */
3
+ export interface Link {
4
+ readonly label: string;
5
+ readonly href: string;
6
+ }
7
+ /** A top navigation link after the sections, shown as its `icon` image (a path starting with `/` is in `public/`) or its label. */
8
+ export type NavItem = Link & {
9
+ readonly icon?: string;
10
+ };
11
+ /** A sidebar entry as `<hk-nav>` renders it: a page or link with `href`, and a folder or group with `children`. */
12
+ export interface SidebarNode {
13
+ readonly label: string;
14
+ readonly href?: string;
15
+ readonly current: string;
16
+ readonly open: boolean;
17
+ readonly depth: number;
18
+ readonly children: readonly SidebarNode[];
19
+ }
20
+ /**
21
+ * HTMLKit's navigation tree with Markupress's group policy: a folder stays open unless its index page's front
22
+ * matter says `navigation: collapsed`, and one holding the current page is always open. `collapsed` tells whether
23
+ * a folder's index page URL starts closed.
24
+ */
25
+ export declare function generatedSidebar(tree: readonly NavigationNode[], collapsed: (href: string) => boolean): SidebarNode[];
26
+ /**
27
+ * A version's footer, from the `_footer.md` in its content directory (HTMLKit routes no `_` file): each heading
28
+ * starts a column, its list items are links, and a paragraph after them is the copyright line.
29
+ */
30
+ export declare function footer(file: string): {
31
+ columns: {
32
+ title: string;
33
+ items: Link[];
34
+ }[];
35
+ copyright: string;
36
+ };
37
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIzD,mGAAmG;AACnG,MAAM,WAAW,IAAI;IAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AACvE,mIAAmI;AACnI,MAAM,MAAM,OAAO,GAAG,IAAI,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,mHAAmH;AACnH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,cAAc,EAAE,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,WAAW,EAAE,CAGrH;AAID;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,IAAI,EAAE,CAAA;KAAE,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CA0BvG"}
@@ -0,0 +1,52 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { createLoomaMarkdownIt } from '@threadlabs/looma/markdown/markdown-it';
3
+ /**
4
+ * HTMLKit's navigation tree with Markupress's group policy: a folder stays open unless its index page's front
5
+ * matter says `navigation: collapsed`, and one holding the current page is always open. `collapsed` tells whether
6
+ * a folder's index page URL starts closed.
7
+ */
8
+ export function generatedSidebar(tree, collapsed) {
9
+ return tree.map(node => ({ ...node, open: node.open || (node.children.length > 0 && !(node.href !== undefined && collapsed(node.href))),
10
+ children: generatedSidebar(node.children, collapsed) }));
11
+ }
12
+ const markdown = createLoomaMarkdownIt();
13
+ /**
14
+ * A version's footer, from the `_footer.md` in its content directory (HTMLKit routes no `_` file): each heading
15
+ * starts a column, its list items are links, and a paragraph after them is the copyright line.
16
+ */
17
+ export function footer(file) {
18
+ const result = { columns: [], copyright: '' };
19
+ if (!existsSync(file))
20
+ return result;
21
+ const fail = (message) => { throw new Error(`${file}: ${message}`); };
22
+ // A list item's first link, labelled by its text.
23
+ const link = (inline) => {
24
+ const children = inline.children ?? [], open = children.findIndex(child => child.type === 'link_open');
25
+ if (open < 0)
26
+ return undefined;
27
+ const close = children.findIndex((child, index) => index > open && child.type === 'link_close');
28
+ return { label: children.slice(open + 1, close).map(child => child.content).join(''), href: children[open].attrGet('href') ?? '' };
29
+ };
30
+ const tokens = markdown.parse(readFileSync(file, 'utf8'), {});
31
+ for (const [index, token] of tokens.entries()) {
32
+ if (token.level !== 0 || token.nesting === -1)
33
+ continue;
34
+ if (token.type === 'heading_open')
35
+ result.columns.push({ title: tokens[index + 1].content, items: [] });
36
+ else if (token.type === 'bullet_list_open' || token.type === 'ordered_list_open') {
37
+ const column = result.columns.at(-1) ?? fail('a footer list follows a heading, which titles its column.');
38
+ for (let item = index + 1; tokens[item].level > 0; item++) {
39
+ if (tokens[item].type !== 'list_item_open' || tokens[item].level !== 1)
40
+ continue;
41
+ const inline = tokens.slice(item).find(next => next.type === 'inline');
42
+ column.items.push(link(inline) ?? fail(`the footer list item "${inline.content}" is a link.`));
43
+ }
44
+ }
45
+ else if (token.type === 'paragraph_open')
46
+ result.copyright = tokens[index + 1].content;
47
+ else
48
+ fail(`a footer holds headings, lists of links, and a copyright paragraph, not ${token.type.replace(/_open$/, '')}.`);
49
+ }
50
+ return result;
51
+ }
52
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../src/navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAkB/E;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAA+B,EAAE,SAAoC;IACpG,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAA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AAO,cAAc,CAAC,CAAC,CAAC;YACjG,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB;YAAE,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,OAAO,CAAC;;YACrF,IAAI,CAAC,2EAA2E,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/site.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type ApplicationOptions, type ApplicationServer, type BuildResult } from '@nextwebwg/htmlkit';
1
+ import { type ApplicationOptions, type ApplicationServer, type BuildResult, type HtmlKitPlugin, type ServerOptions } from '@nextwebwg/htmlkit';
2
+ import { type NavItem } from './navigation.js';
2
3
  export interface DocumentationVersion {
3
4
  readonly id: string;
4
5
  readonly label?: string;
@@ -16,23 +17,43 @@ export interface MarkupressOptions {
16
17
  readonly defaultVersion?: string;
17
18
  readonly host?: string;
18
19
  readonly port?: number;
20
+ /** Number the lines of every highlighted code block unless its fence says `:no-line-numbers`. */
21
+ readonly lineNumbers?: boolean;
22
+ /** The logo before the title, in place of `public/logo.svg` and `public/logo-dark.svg`: one image, or one per theme. */
23
+ readonly logo?: string | {
24
+ readonly light: string;
25
+ readonly dark?: string;
26
+ };
27
+ /** The site's icon, in place of `public/favicon.svg`. */
28
+ readonly favicon?: string;
29
+ /** Links after the sections in the top navigation, each shown as its `icon` image or its label. */
30
+ readonly nav?: readonly NavItem[];
19
31
  }
20
32
  export interface DocumentationPage {
21
33
  readonly id: string;
22
34
  readonly version: string;
23
35
  readonly source: string;
36
+ /** Application-relative URL in its version, such as /v/current/guide/install/. */
24
37
  readonly pathname: string;
25
- readonly label: string;
26
- readonly pageName: string;
27
38
  }
28
- export interface PreparedSite {
29
- readonly application: ApplicationOptions;
30
- readonly documents: readonly DocumentationPage[];
31
- readonly sourceFiles: readonly string[];
32
- }
33
- /** Compile author content into an owned HTMLKit application, preserving original import locations. */
34
- export declare function prepareSite(options?: MarkupressOptions): Promise<PreparedSite>;
39
+ /**
40
+ * A snapshot recorded in `versions/<id>/`, which keeps the project's layout: its content is `versions/<id>/<contentDir>`
41
+ * and its public files `versions/<id>/public`. Snapshots follow the current version, highest number first.
42
+ */
43
+ export declare function snapshotOf(root: string, id: string, contentDir: string): DocumentationVersion;
44
+ /**
45
+ * Versioned documentation as an HTMLKit plugin. Markdown pages come from the markdown plugin, and
46
+ * HTMLKit routes them: each version's directory serves /v/<id>/, and the default version's also
47
+ * serves the site root. Markupress keeps only the version catalog its switcher needs.
48
+ */
49
+ export declare function markupress(options?: MarkupressOptions): HtmlKitPlugin;
50
+ /**
51
+ * HTMLKit options for a Markupress site, as the CLI runs it: the site's own HTMLKit options (its `htmlkit.config.ts`)
52
+ * with `markupress()` added after their plugins. Markupress's own `base` and `outDir`, when set, win over HTMLKit's.
53
+ */
54
+ export declare function siteOptions(options?: MarkupressOptions, htmlkit?: ApplicationOptions): ServerOptions;
35
55
  export declare function buildSite(options?: MarkupressOptions): Promise<BuildResult>;
36
56
  export declare function previewSite(options?: MarkupressOptions): Promise<ApplicationServer>;
57
+ /** HTMLKit's watcher recompiles Markdown and reloads open pages after each edit. */
37
58
  export declare function devSite(options?: MarkupressOptions): Promise<ApplicationServer>;
38
59
  //# sourceMappingURL=site.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAKA,OAAO,EAAwD,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAI7J,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CA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