orz-paged 0.2.0 → 0.3.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.
- package/dist/browser-entry.d.ts +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +31 -68
- package/dist/doc/dynamic.d.ts +31 -0
- package/dist/doc/elements.d.ts +16 -0
- package/dist/doc/fonts.d.ts +25 -0
- package/dist/doc/nyml.d.ts +33 -0
- package/dist/doc/page-css.d.ts +15 -0
- package/dist/doc/settings.d.ts +35 -0
- package/dist/doc/templates.d.ts +49 -0
- package/dist/doc/theme-fonts.d.ts +12 -0
- package/dist/lib.d.ts +59 -0
- package/dist/lib.js +136 -0
- package/dist/orz-paged.browser.js +1 -1
- package/dist/paged.d.ts +9 -0
- package/dist/render-paged.d.ts +21 -0
- package/dist/template.d.ts +60 -0
- package/dist/types.d.ts +144 -0
- package/package.json +9 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
CHANGED
|
@@ -8,57 +8,11 @@
|
|
|
8
8
|
* references the published `orz-paged-browser` on jsDelivr. Fonts, images, and the
|
|
9
9
|
* math/diagram libs always load from CDN at view time (DESIGN §4).
|
|
10
10
|
*/
|
|
11
|
-
import { readFileSync, writeFileSync
|
|
11
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { dirname, join, basename, resolve } from 'node:path';
|
|
13
|
-
import { fileURLToPath } from 'node:url';
|
|
14
13
|
import { getBrowserRuntimeScript } from 'orz-markdown/runtime';
|
|
15
|
-
import { PREVIEW_CDN } from 'orz-markdown/preview-frame';
|
|
16
14
|
import { buildHtml } from './template.js';
|
|
17
|
-
import {
|
|
18
|
-
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const ROOT = join(HERE, '..');
|
|
20
|
-
const selfVersion = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version || '0.0.0';
|
|
21
|
-
/** Pinned CDN assets used at view time — sourced from orz-markdown's shared
|
|
22
|
-
* preview-frame helper so every host app loads identical, tested versions.
|
|
23
|
-
* Paged is light-only, so highlight.js uses the light (github) stylesheet. */
|
|
24
|
-
const CDN = {
|
|
25
|
-
katexCss: PREVIEW_CDN.katexCss,
|
|
26
|
-
mermaidJs: PREVIEW_CDN.mermaidJs,
|
|
27
|
-
smilesJs: PREVIEW_CDN.smilesJs,
|
|
28
|
-
chartJs: PREVIEW_CDN.chartJs,
|
|
29
|
-
hljsJs: PREVIEW_CDN.hljsJs,
|
|
30
|
-
hljsCss: PREVIEW_CDN.hljsLightCss,
|
|
31
|
-
};
|
|
32
|
-
function findAsset(rel) {
|
|
33
|
-
const p = join(ROOT, rel);
|
|
34
|
-
if (!existsSync(p))
|
|
35
|
-
throw new Error('missing asset: ' + rel + ' (run `npm run build` first)');
|
|
36
|
-
return p;
|
|
37
|
-
}
|
|
38
|
-
/** Drop a theme's `@import url("./base.css")` — base is inlined separately, so the
|
|
39
|
-
* relative import points nowhere (404 on http; a fetch hazard on file://). */
|
|
40
|
-
function stripBaseImport(css) {
|
|
41
|
-
return css.replace(/@import\s+url\(\s*['"]?\.\/base\.css['"]?\s*\)\s*;?/gi, '');
|
|
42
|
-
}
|
|
43
|
-
function loadThemes() {
|
|
44
|
-
const dir = findAsset('assets/themes');
|
|
45
|
-
const baseCss = readFileSync(join(dir, 'base.css'), 'utf8');
|
|
46
|
-
const themes = readdirSync(dir)
|
|
47
|
-
.filter((f) => f.endsWith('.css') && f !== 'base.css')
|
|
48
|
-
.map((f) => ({ id: f.replace(/\.css$/, ''), css: stripBaseImport(readFileSync(join(dir, f), 'utf8')) }));
|
|
49
|
-
return { baseCss, themes };
|
|
50
|
-
}
|
|
51
|
-
/** Load every template's starter skeleton from `assets/templates/<stem>.md`. */
|
|
52
|
-
function loadTemplates() {
|
|
53
|
-
const dir = findAsset('assets/templates');
|
|
54
|
-
return templateList().map((t) => ({
|
|
55
|
-
id: t.id,
|
|
56
|
-
label: t.label,
|
|
57
|
-
description: t.description,
|
|
58
|
-
group: t.group,
|
|
59
|
-
skeleton: readFileSync(join(dir, t.skeleton + '.md'), 'utf8'),
|
|
60
|
-
}));
|
|
61
|
-
}
|
|
15
|
+
import { selfVersion, CDN, findAsset, loadThemes, loadTemplates, pickDefaultTheme, composeInlineHtml, } from './lib.js';
|
|
62
16
|
function parseArgs(argv) {
|
|
63
17
|
const a = { mode: 'inline' };
|
|
64
18
|
for (let i = 0; i < argv.length; i++) {
|
|
@@ -138,30 +92,39 @@ function main() {
|
|
|
138
92
|
const inDir = args.input ? dirname(resolve(args.input)) : process.cwd();
|
|
139
93
|
const outPath = args.out ? resolve(args.out) : join(inDir, base + '.paged.html');
|
|
140
94
|
const title = args.title || base;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const runtime = getBrowserRuntimeScript(); // copy-as-Markdown (+ qr) from orz-markdown
|
|
144
|
-
let renderer;
|
|
95
|
+
let html;
|
|
96
|
+
let themeCount;
|
|
145
97
|
if (args.mode === 'cdn') {
|
|
146
|
-
|
|
98
|
+
// CDN mode references the published engine on jsDelivr (not inlined), so it
|
|
99
|
+
// has its own composition; the default inline path shares composeInlineHtml.
|
|
100
|
+
const { baseCss, themes } = loadThemes();
|
|
101
|
+
const appJs = readFileSync(findAsset('assets/app.js'), 'utf8');
|
|
102
|
+
const runtime = getBrowserRuntimeScript(); // copy-as-Markdown (+ qr) from orz-markdown
|
|
103
|
+
const renderer = {
|
|
104
|
+
mode: 'cdn',
|
|
105
|
+
src: `https://cdn.jsdelivr.net/npm/orz-paged-browser@${selfVersion}/orz-paged.browser.js`,
|
|
106
|
+
};
|
|
107
|
+
themeCount = themes.length;
|
|
108
|
+
html = buildHtml({
|
|
109
|
+
source,
|
|
110
|
+
title,
|
|
111
|
+
rendererVersion: selfVersion,
|
|
112
|
+
renderer,
|
|
113
|
+
baseCss,
|
|
114
|
+
themes,
|
|
115
|
+
defaultTheme: pickDefaultTheme(themes),
|
|
116
|
+
templates,
|
|
117
|
+
cdn: CDN,
|
|
118
|
+
appJs,
|
|
119
|
+
runtime,
|
|
120
|
+
});
|
|
147
121
|
}
|
|
148
122
|
else {
|
|
149
|
-
|
|
123
|
+
// Default: fully-inline, via the shared composition used by the library.
|
|
124
|
+
themeCount = loadThemes().themes.length;
|
|
125
|
+
html = composeInlineHtml(source, title);
|
|
150
126
|
}
|
|
151
|
-
const html = buildHtml({
|
|
152
|
-
source,
|
|
153
|
-
title,
|
|
154
|
-
rendererVersion: selfVersion,
|
|
155
|
-
renderer,
|
|
156
|
-
baseCss,
|
|
157
|
-
themes,
|
|
158
|
-
defaultTheme: themes.some((t) => t.id === 'light-neat-1') ? 'light-neat-1' : (themes[0]?.id ?? 'none'),
|
|
159
|
-
templates,
|
|
160
|
-
cdn: CDN,
|
|
161
|
-
appJs,
|
|
162
|
-
runtime,
|
|
163
|
-
});
|
|
164
127
|
writeFileSync(outPath, html, 'utf8');
|
|
165
|
-
console.log(`Wrote ${outPath} (${args.mode}, ${
|
|
128
|
+
console.log(`Wrote ${outPath} (${args.mode}, ${themeCount} themes)`);
|
|
166
129
|
}
|
|
167
130
|
main();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic switch — conditional content driven by the `dynamic_choices` document
|
|
3
|
+
* setting. Elements carry `data-show-when="key=value"` / `data-hide-when="key=value"`;
|
|
4
|
+
* at render time non-matching ones are removed and the attribute is stripped from
|
|
5
|
+
* those that stay. One source can then print several versions (e.g. an exam with
|
|
6
|
+
* `answer-key: hide` for students and `show` for the instructor key).
|
|
7
|
+
*
|
|
8
|
+
* Operates on a live DOM (browser render) so nested removals are correct.
|
|
9
|
+
*/
|
|
10
|
+
/** Normalize a choice key: lowercase, hyphens → underscores (matches settings). */
|
|
11
|
+
export declare function normalizeChoiceKey(key: string): string;
|
|
12
|
+
interface CondEl {
|
|
13
|
+
getAttribute(name: string): string | null;
|
|
14
|
+
removeAttribute(name: string): void;
|
|
15
|
+
remove(): void;
|
|
16
|
+
}
|
|
17
|
+
interface CondRoot {
|
|
18
|
+
querySelectorAll(sel: string): ArrayLike<CondEl>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve every `data-show-when` / `data-hide-when` under `root` against
|
|
22
|
+
* `choices`, mutating the DOM in place: drop non-matching elements, strip the
|
|
23
|
+
* attribute from the rest.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyDynamicChoices(root: CondRoot, choices: Record<string, string>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Collect the dynamic keys present under `root` and the set of values each is
|
|
28
|
+
* used with — for building a live switcher UI. Returns key → sorted values.
|
|
29
|
+
*/
|
|
30
|
+
export declare function collectDynamicChoices(root: CondRoot): Record<string, string[]>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orz-paged — built-in document elements.
|
|
3
|
+
*
|
|
4
|
+
* `renderElement(spec, ctx)` turns one `{{nyml kind: element}}` block into
|
|
5
|
+
* semantic HTML + a small scoped stylesheet. Every element is wrapped in
|
|
6
|
+
* `<section class="orz-element orz-el-<kind>">…</section>`. Markdown-typed
|
|
7
|
+
* fields go through the injected `ctx.renderInline` / `ctx.renderBlock` so this
|
|
8
|
+
* module never depends on orz-markdown directly.
|
|
9
|
+
*
|
|
10
|
+
* The `css` returned per kind is identical on every call (the assembler dedupes
|
|
11
|
+
* by kind), uses `var(--accent)` for the accent color, and stays light-only.
|
|
12
|
+
*
|
|
13
|
+
* Spec: docs/document-model.md (Built-in Elements) — reimplemented cleanly.
|
|
14
|
+
*/
|
|
15
|
+
import type { ElementSpec, ElementCtx, ElementResult } from '../types.js';
|
|
16
|
+
export declare function renderElement(spec: ElementSpec, ctx: ElementCtx): ElementResult;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font presets — M3.
|
|
3
|
+
*
|
|
4
|
+
* Maps each curated {@link FontPresetName} to a {@link FontPreset}: a CDN
|
|
5
|
+
* stylesheet URL (`@fontsource/*` served via jsDelivr) plus the matching CSS
|
|
6
|
+
* `font-family` stack. orz-paged assumes internet access, so fonts load from
|
|
7
|
+
* the CDN rather than being bundled.
|
|
8
|
+
*
|
|
9
|
+
* `system-serif` is the one preset with **no** webfont — it relies on the
|
|
10
|
+
* platform's Times-style serif and ships an empty `cssUrl`.
|
|
11
|
+
*
|
|
12
|
+
* Source of truth for the curated list: `docs/document-model.md` (Tier A) and
|
|
13
|
+
* `src/types.ts` (`FontPresetName`).
|
|
14
|
+
*/
|
|
15
|
+
import type { FontPreset, FontPresetName } from '../types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Every curated preset → its CDN stylesheet + CSS family stack. `system-serif`
|
|
18
|
+
* carries an empty `cssUrl` (no network font).
|
|
19
|
+
*/
|
|
20
|
+
export declare const FONT_PRESETS: Record<FontPresetName, FontPreset>;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a preset by name. Unknown names fall back to a webfont-less system
|
|
23
|
+
* serif (empty `cssUrl`) rather than throwing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function fontPreset(name: string): FontPreset;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic nyml-block scanner — shared by the settings reader (M1) and the
|
|
3
|
+
* assembler (A1).
|
|
4
|
+
*
|
|
5
|
+
* `settings.ts` parses the single `kind: document` block inline; this module is
|
|
6
|
+
* the reusable version: it finds **every** `{{nyml … }}` block in a source,
|
|
7
|
+
* parses its YAML-ish `key: value` body (including `key: |` multiline blocks),
|
|
8
|
+
* reads the `kind:` discriminator, and reports the block's char offsets so a
|
|
9
|
+
* caller can splice it out / replace it.
|
|
10
|
+
*
|
|
11
|
+
* Values are always strings: surrounding quotes are stripped, multiline `|`
|
|
12
|
+
* blocks are dedented and joined with `\n`. The `{{nyml … }}` grammar matches
|
|
13
|
+
* what `parseDocSettings` already accepts (`}` is allowed inside the body; only
|
|
14
|
+
* the first `}}` terminates the block).
|
|
15
|
+
*/
|
|
16
|
+
/** One scanned `{{nyml … }}` block: its kind, parsed fields, and char range. */
|
|
17
|
+
export interface NymlBlock {
|
|
18
|
+
/** The `kind:` value (e.g. `'document'`, `'element'`), or `''` if absent. */
|
|
19
|
+
kind: string;
|
|
20
|
+
/** snake_case field → raw string value (multiline values preserved). */
|
|
21
|
+
fields: Record<string, string>;
|
|
22
|
+
/** Offset of the opening `{` of `{{nyml` in `source`. */
|
|
23
|
+
start: number;
|
|
24
|
+
/** Offset just past the closing `}}` (so `source.slice(start, end)` is the block). */
|
|
25
|
+
end: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Scan a source for every `{{nyml … }}` block, in document order. Each result
|
|
29
|
+
* carries its parsed `kind`, `fields`, and `[start, end)` char offsets. Blocks
|
|
30
|
+
* inside an HTML comment (`<!-- … -->`) are skipped — so a commented-out element
|
|
31
|
+
* (e.g. content the editor's template picker preserves) does not render.
|
|
32
|
+
*/
|
|
33
|
+
export declare function scanNymlBlocks(source: string): NymlBlock[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page CSS — M5.
|
|
3
|
+
*
|
|
4
|
+
* Turns a fully-resolved {@link DocSettings} into the `@page` rules, margin-box
|
|
5
|
+
* running headers/footers, page-number counters, `:root` design tokens, and
|
|
6
|
+
* layout-behavior CSS that paged.js realizes into physical page boxes.
|
|
7
|
+
*
|
|
8
|
+
* Behavior SPEC: `docs/document-model.md`; token set + page model:
|
|
9
|
+
* `docs/dom-contract.md`. Reimplemented cleanly in TS (light-only output).
|
|
10
|
+
*/
|
|
11
|
+
import type { DocSettings } from '../types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build the full page CSS string for a document. Pure: depends only on `s`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildPageCss(s: DocSettings): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document settings — M1.
|
|
3
|
+
*
|
|
4
|
+
* Reads the single `{{nyml kind: document}}` block from a Markdown source,
|
|
5
|
+
* normalizes its snake_case keys into a {@link DocSettingsLayer}, and merges
|
|
6
|
+
* template + user layers over {@link DEFAULTS} into a fully-resolved
|
|
7
|
+
* {@link DocSettings}.
|
|
8
|
+
*
|
|
9
|
+
* Source of truth for defaults and aliases: `docs/document-model.md`
|
|
10
|
+
* (the curated subset; see DESIGN.md §8).
|
|
11
|
+
*/
|
|
12
|
+
import type { DocSettings, RawDocSettings, DocSettingsLayer } from '../types.js';
|
|
13
|
+
/** Every field at its documented default (docs/document-model.md). */
|
|
14
|
+
export declare const DEFAULTS: DocSettings;
|
|
15
|
+
/**
|
|
16
|
+
* Locate the first `{{nyml ... }}` block whose body declares `kind: document`,
|
|
17
|
+
* parse its `key: value` lines (including `key: |` multiline blocks) into a
|
|
18
|
+
* {@link RawDocSettings}, and return the source with that block removed so it
|
|
19
|
+
* is not rendered as content. No document block → `{ raw: {}, body: source }`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseDocSettings(source: string): {
|
|
22
|
+
raw: RawDocSettings;
|
|
23
|
+
body: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Map snake_case raw keys → camelCase {@link DocSettings} fields, coercing
|
|
27
|
+
* types and normalizing aliases. Only keys present in `raw` are included;
|
|
28
|
+
* unknown keys are ignored.
|
|
29
|
+
*/
|
|
30
|
+
export declare function normalizeRawToLayer(raw: RawDocSettings): DocSettingsLayer;
|
|
31
|
+
/**
|
|
32
|
+
* Shallow-merge layers left → right (later wins). Intended use:
|
|
33
|
+
* `mergeSettings(DEFAULTS, templateLayer, userLayer)`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function mergeSettings(...layers: DocSettingsLayer[]): DocSettings;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated document templates — LAYOUT defaults + a starter skeleton.
|
|
3
|
+
*
|
|
4
|
+
* Responsibility split: a **template** owns layout only (page size, margins,
|
|
5
|
+
* furniture, and which elements appear / where). A **theme** owns the look —
|
|
6
|
+
* font, accent/decoration color, and element styling — so the same theme renders
|
|
7
|
+
* the same across every template (see ../doc/theme-fonts.ts + assets/themes/*).
|
|
8
|
+
* The default theme is `light-academic-1` (settings.ts DEFAULTS.theme).
|
|
9
|
+
*
|
|
10
|
+
* Each template carries:
|
|
11
|
+
* - a {@link DocSettingsLayer} of *layout defaults* (page size; no font/theme),
|
|
12
|
+
* merged under any `kind: document` field the user sets,
|
|
13
|
+
* - picker metadata (`label`, `description`, `group`),
|
|
14
|
+
* - a `skeleton` stem naming the starter Markdown in `assets/templates/<stem>.md`.
|
|
15
|
+
*
|
|
16
|
+
* `article` / `report` / `exam` ship in two variants — `-page` (a dedicated
|
|
17
|
+
* title/cover page) and `-section` (title-on-content) — that differ only in their
|
|
18
|
+
* skeleton (the title element's `placement: page | section`). Legacy names
|
|
19
|
+
* (`article`/`report`/`exam`) resolve to the `-section` variant.
|
|
20
|
+
*/
|
|
21
|
+
import type { TemplateName, DocSettingsLayer } from '../types.js';
|
|
22
|
+
export interface TemplateDef {
|
|
23
|
+
/** Friendly name for the picker, e.g. "Article — title page". */
|
|
24
|
+
label: string;
|
|
25
|
+
/** One-line description (picker tooltip). */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Grouping for the picker, e.g. "Article". */
|
|
28
|
+
group: string;
|
|
29
|
+
/** Starter-markdown file stem: `assets/templates/<skeleton>.md`. */
|
|
30
|
+
skeleton: string;
|
|
31
|
+
/** Settings defaults this template applies. */
|
|
32
|
+
settings: DocSettingsLayer;
|
|
33
|
+
}
|
|
34
|
+
/** The 10 curated templates. */
|
|
35
|
+
export declare const TEMPLATES: Record<TemplateName, TemplateDef>;
|
|
36
|
+
/** Canonicalize a (possibly legacy) template name, or `undefined` if unknown. */
|
|
37
|
+
export declare function canonicalTemplate(name: string): TemplateName | undefined;
|
|
38
|
+
/** Return a template's *settings* defaults layer, or `{}` for an unknown name. */
|
|
39
|
+
export declare function resolveTemplate(name: TemplateName | string): DocSettingsLayer;
|
|
40
|
+
/** The starter-markdown file stem for a template, or `undefined` if unknown. */
|
|
41
|
+
export declare function templateSkeletonName(name: TemplateName | string): string | undefined;
|
|
42
|
+
/** Picker catalog: id + metadata for every template (no settings/skeleton text). */
|
|
43
|
+
export declare function templateList(): Array<{
|
|
44
|
+
id: TemplateName;
|
|
45
|
+
label: string;
|
|
46
|
+
description: string;
|
|
47
|
+
group: string;
|
|
48
|
+
skeleton: string;
|
|
49
|
+
}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme typography — each theme OWNS its font (alongside its colors + element
|
|
3
|
+
* style in the theme CSS). The engine loads the active theme's webfonts at view
|
|
4
|
+
* time and the theme CSS sets the matching `--font-body` / `--font-heading`, so
|
|
5
|
+
* the same theme yields the same font across every template. An explicit
|
|
6
|
+
* `font_preset` in the document settings still overrides this (page CSS wins).
|
|
7
|
+
*/
|
|
8
|
+
import type { ThemeName, FontPresetName } from '../types.js';
|
|
9
|
+
export declare const THEME_FONTS: Record<ThemeName, {
|
|
10
|
+
body: FontPresetName;
|
|
11
|
+
heading: FontPresetName;
|
|
12
|
+
}>;
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ThemeAsset, type TemplateAsset } from './template.js';
|
|
2
|
+
export declare const selfVersion: string;
|
|
3
|
+
/** Pinned CDN assets used at view time — sourced from orz-markdown's shared
|
|
4
|
+
* preview-frame helper so every host app loads identical, tested versions.
|
|
5
|
+
* Paged is light-only, so highlight.js uses the light (github) stylesheet. */
|
|
6
|
+
export declare const CDN: {
|
|
7
|
+
katexCss: "https://cdn.jsdelivr.net/npm/katex@0.16.35/dist/katex.min.css";
|
|
8
|
+
mermaidJs: "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js";
|
|
9
|
+
smilesJs: "https://unpkg.com/smiles-drawer@1.0.10/dist/smiles-drawer.min.js";
|
|
10
|
+
chartJs: "https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js";
|
|
11
|
+
hljsJs: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js";
|
|
12
|
+
hljsCss: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css";
|
|
13
|
+
};
|
|
14
|
+
export declare function findAsset(rel: string): string;
|
|
15
|
+
/** Drop a theme's `@import url("./base.css")` — base is inlined separately, so the
|
|
16
|
+
* relative import points nowhere (404 on http; a fetch hazard on file://). */
|
|
17
|
+
export declare function stripBaseImport(css: string): string;
|
|
18
|
+
export declare function loadThemes(): {
|
|
19
|
+
baseCss: string;
|
|
20
|
+
themes: ThemeAsset[];
|
|
21
|
+
};
|
|
22
|
+
/** Load every template's starter skeleton from `assets/templates/<stem>.md`. */
|
|
23
|
+
export declare function loadTemplates(): TemplateAsset[];
|
|
24
|
+
/** The default theme id, matching the CLI: prefer `light-neat-1`, else the first
|
|
25
|
+
* loaded theme, else `'none'`. */
|
|
26
|
+
export declare function pickDefaultTheme(themes: ThemeAsset[]): string;
|
|
27
|
+
/**
|
|
28
|
+
* The shared inline composition — called by both the CLI (`--inline`, the
|
|
29
|
+
* default) and {@link buildPagedHtml}. Loads all assets from the package, builds
|
|
30
|
+
* an inline renderer, and returns the full document string. Deterministic: paged
|
|
31
|
+
* has no per-document random id, so the same `(source, title, theme?)` always
|
|
32
|
+
* yields byte-identical output.
|
|
33
|
+
*
|
|
34
|
+
* @param theme optional theme id; when omitted (or unknown) the default theme
|
|
35
|
+
* ({@link pickDefaultTheme}) drives the picker's initial selection.
|
|
36
|
+
*/
|
|
37
|
+
export declare function composeInlineHtml(source: string, title: string, theme?: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Generate a self-contained `.paged.html` document, fully inline.
|
|
40
|
+
*
|
|
41
|
+
* Mirrors the CLI's default `--inline` mode; the returned string is
|
|
42
|
+
* byte-identical to CLI inline output for the same source/title/theme.
|
|
43
|
+
*
|
|
44
|
+
* @param opts.markdown the document source (the host passes content).
|
|
45
|
+
* @param opts.title `<title>` + generator title; defaults to `'Untitled'`.
|
|
46
|
+
* @param opts.theme initial theme id; unknown/omitted → the default theme.
|
|
47
|
+
* @param opts.template a starter-skeleton selector, mirroring the CLI's
|
|
48
|
+
* `--template <name>` with no input file: used as the source ONLY when
|
|
49
|
+
* `opts.markdown` is empty/whitespace. When `markdown` has content, it wins.
|
|
50
|
+
* The full template catalog is always embedded regardless (it powers the
|
|
51
|
+
* in-editor picker), so this never changes the catalog — only the initial
|
|
52
|
+
* source. An unknown template name is ignored (falls back to `markdown`).
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildPagedHtml(opts: {
|
|
55
|
+
markdown: string;
|
|
56
|
+
title?: string;
|
|
57
|
+
theme?: string;
|
|
58
|
+
template?: string;
|
|
59
|
+
}): string;
|
package/dist/lib.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orz-paged library entry — generate a self-contained `.paged.html` in-process.
|
|
3
|
+
*
|
|
4
|
+
* This is the programmatic twin of the CLI's default (`--inline`) render path: a
|
|
5
|
+
* host platform calls {@link buildPagedHtml} and gets back the FULL document
|
|
6
|
+
* string, fully inline (inlined engine bundle + inlined base/theme CSS + full
|
|
7
|
+
* template catalog + embedded source). Math/diagram/font libs still load from
|
|
8
|
+
* CDN at view time — exactly as the CLI's inline output does.
|
|
9
|
+
*
|
|
10
|
+
* Both the CLI and this module compose through {@link composeInlineHtml}, so
|
|
11
|
+
* there is a single render path. The CLI keeps its argument parsing, template
|
|
12
|
+
* scaffolding (`--new`/`--list-templates`), source-selection (`--template`), and
|
|
13
|
+
* the `--cdn` mode; the shared inline composition lives here.
|
|
14
|
+
*
|
|
15
|
+
* Asset resolution is relative to this module (`import.meta.url`), never
|
|
16
|
+
* `process.cwd()`, so it works from an installed npm package.
|
|
17
|
+
*/
|
|
18
|
+
import { readFileSync, readdirSync, existsSync } from 'node:fs';
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
import { fileURLToPath } from 'node:url';
|
|
21
|
+
import { getBrowserRuntimeScript } from 'orz-markdown/runtime';
|
|
22
|
+
import { PREVIEW_CDN } from 'orz-markdown/preview-frame';
|
|
23
|
+
import { buildHtml } from './template.js';
|
|
24
|
+
import { templateList } from './doc/templates.js';
|
|
25
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
const ROOT = join(HERE, '..');
|
|
27
|
+
export const selfVersion = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version || '0.0.0';
|
|
28
|
+
/** Pinned CDN assets used at view time — sourced from orz-markdown's shared
|
|
29
|
+
* preview-frame helper so every host app loads identical, tested versions.
|
|
30
|
+
* Paged is light-only, so highlight.js uses the light (github) stylesheet. */
|
|
31
|
+
export const CDN = {
|
|
32
|
+
katexCss: PREVIEW_CDN.katexCss,
|
|
33
|
+
mermaidJs: PREVIEW_CDN.mermaidJs,
|
|
34
|
+
smilesJs: PREVIEW_CDN.smilesJs,
|
|
35
|
+
chartJs: PREVIEW_CDN.chartJs,
|
|
36
|
+
hljsJs: PREVIEW_CDN.hljsJs,
|
|
37
|
+
hljsCss: PREVIEW_CDN.hljsLightCss,
|
|
38
|
+
};
|
|
39
|
+
export function findAsset(rel) {
|
|
40
|
+
const p = join(ROOT, rel);
|
|
41
|
+
if (!existsSync(p))
|
|
42
|
+
throw new Error('missing asset: ' + rel + ' (run `npm run build` first)');
|
|
43
|
+
return p;
|
|
44
|
+
}
|
|
45
|
+
/** Drop a theme's `@import url("./base.css")` — base is inlined separately, so the
|
|
46
|
+
* relative import points nowhere (404 on http; a fetch hazard on file://). */
|
|
47
|
+
export function stripBaseImport(css) {
|
|
48
|
+
return css.replace(/@import\s+url\(\s*['"]?\.\/base\.css['"]?\s*\)\s*;?/gi, '');
|
|
49
|
+
}
|
|
50
|
+
export function loadThemes() {
|
|
51
|
+
const dir = findAsset('assets/themes');
|
|
52
|
+
const baseCss = readFileSync(join(dir, 'base.css'), 'utf8');
|
|
53
|
+
const themes = readdirSync(dir)
|
|
54
|
+
.filter((f) => f.endsWith('.css') && f !== 'base.css')
|
|
55
|
+
.map((f) => ({ id: f.replace(/\.css$/, ''), css: stripBaseImport(readFileSync(join(dir, f), 'utf8')) }));
|
|
56
|
+
return { baseCss, themes };
|
|
57
|
+
}
|
|
58
|
+
/** Load every template's starter skeleton from `assets/templates/<stem>.md`. */
|
|
59
|
+
export function loadTemplates() {
|
|
60
|
+
const dir = findAsset('assets/templates');
|
|
61
|
+
return templateList().map((t) => ({
|
|
62
|
+
id: t.id,
|
|
63
|
+
label: t.label,
|
|
64
|
+
description: t.description,
|
|
65
|
+
group: t.group,
|
|
66
|
+
skeleton: readFileSync(join(dir, t.skeleton + '.md'), 'utf8'),
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
/** The default theme id, matching the CLI: prefer `light-neat-1`, else the first
|
|
70
|
+
* loaded theme, else `'none'`. */
|
|
71
|
+
export function pickDefaultTheme(themes) {
|
|
72
|
+
return themes.some((t) => t.id === 'light-neat-1') ? 'light-neat-1' : (themes[0]?.id ?? 'none');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The shared inline composition — called by both the CLI (`--inline`, the
|
|
76
|
+
* default) and {@link buildPagedHtml}. Loads all assets from the package, builds
|
|
77
|
+
* an inline renderer, and returns the full document string. Deterministic: paged
|
|
78
|
+
* has no per-document random id, so the same `(source, title, theme?)` always
|
|
79
|
+
* yields byte-identical output.
|
|
80
|
+
*
|
|
81
|
+
* @param theme optional theme id; when omitted (or unknown) the default theme
|
|
82
|
+
* ({@link pickDefaultTheme}) drives the picker's initial selection.
|
|
83
|
+
*/
|
|
84
|
+
export function composeInlineHtml(source, title, theme) {
|
|
85
|
+
const templates = loadTemplates();
|
|
86
|
+
const { baseCss, themes } = loadThemes();
|
|
87
|
+
const appJs = readFileSync(findAsset('assets/app.js'), 'utf8');
|
|
88
|
+
const runtime = getBrowserRuntimeScript(); // copy-as-Markdown (+ qr) from orz-markdown
|
|
89
|
+
const renderer = {
|
|
90
|
+
mode: 'inline',
|
|
91
|
+
js: readFileSync(findAsset('dist/orz-paged.browser.js'), 'utf8'),
|
|
92
|
+
};
|
|
93
|
+
const known = theme && themes.some((t) => t.id === theme);
|
|
94
|
+
const defaultTheme = known ? theme : pickDefaultTheme(themes);
|
|
95
|
+
return buildHtml({
|
|
96
|
+
source,
|
|
97
|
+
title,
|
|
98
|
+
rendererVersion: selfVersion,
|
|
99
|
+
renderer,
|
|
100
|
+
baseCss,
|
|
101
|
+
themes,
|
|
102
|
+
defaultTheme,
|
|
103
|
+
templates,
|
|
104
|
+
cdn: CDN,
|
|
105
|
+
appJs,
|
|
106
|
+
runtime,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Generate a self-contained `.paged.html` document, fully inline.
|
|
111
|
+
*
|
|
112
|
+
* Mirrors the CLI's default `--inline` mode; the returned string is
|
|
113
|
+
* byte-identical to CLI inline output for the same source/title/theme.
|
|
114
|
+
*
|
|
115
|
+
* @param opts.markdown the document source (the host passes content).
|
|
116
|
+
* @param opts.title `<title>` + generator title; defaults to `'Untitled'`.
|
|
117
|
+
* @param opts.theme initial theme id; unknown/omitted → the default theme.
|
|
118
|
+
* @param opts.template a starter-skeleton selector, mirroring the CLI's
|
|
119
|
+
* `--template <name>` with no input file: used as the source ONLY when
|
|
120
|
+
* `opts.markdown` is empty/whitespace. When `markdown` has content, it wins.
|
|
121
|
+
* The full template catalog is always embedded regardless (it powers the
|
|
122
|
+
* in-editor picker), so this never changes the catalog — only the initial
|
|
123
|
+
* source. An unknown template name is ignored (falls back to `markdown`).
|
|
124
|
+
*/
|
|
125
|
+
export function buildPagedHtml(opts) {
|
|
126
|
+
let source = opts.markdown;
|
|
127
|
+
if (opts.template && !opts.markdown.trim()) {
|
|
128
|
+
const templates = loadTemplates();
|
|
129
|
+
const t = templates.find((x) => x.id === opts.template)
|
|
130
|
+
?? templates.find((x) => x.id === opts.template + '-section'); // legacy: article→article-section
|
|
131
|
+
if (t)
|
|
132
|
+
source = t.skeleton;
|
|
133
|
+
}
|
|
134
|
+
const title = opts.title || 'Untitled';
|
|
135
|
+
return composeInlineHtml(source, title, opts.theme);
|
|
136
|
+
}
|
|
@@ -1521,4 +1521,4 @@ ${M.join(`
|
|
|
1521
1521
|
height: 100% !important;
|
|
1522
1522
|
}
|
|
1523
1523
|
}
|
|
1524
|
-
`;b();async function Lo(e,t={}){return new Promise(function(r,a){let n=new XMLHttpRequest;n.open(t.method||"get",e,!0);for(let i in t.headers)n.setRequestHeader(i,t.headers[i]);n.withCredentials=t.credentials==="include",n.onload=()=>{let i=n.status===0&&e.startsWith("file://")?200:n.status;r(new Response(n.responseText,{status:i}))},n.onerror=a,n.send(t.body||null)})}var Sd=class{constructor(t){this.sheets=[],this.inserted=[],this.hooks={},this.hooks.onUrl=new ue(this),this.hooks.onAtPage=new ue(this),this.hooks.onAtMedia=new ue(this),this.hooks.onRule=new ue(this),this.hooks.onDeclaration=new ue(this),this.hooks.onContent=new ue(this),this.hooks.onSelector=new ue(this),this.hooks.onPseudoSelector=new ue(this),this.hooks.onImport=new ue(this),this.hooks.beforeTreeParse=new ue(this),this.hooks.beforeTreeWalk=new ue(this),this.hooks.afterTreeWalk=new ue(this),t!==!1&&this.setup()}setup(){return this.base=this.insert(t3),this.styleEl=document.createElement("style"),document.head.appendChild(this.styleEl),this.styleSheet=this.styleEl.sheet,this.styleSheet}async add(){let t=[],r=[];for(var a=0;a<arguments.length;a++){let n;if(typeof arguments[a]=="object")for(let i in arguments[a]){let l=arguments[a];n=new Promise(function(c,d){r.push(i),c(l[i])})}else r.push(arguments[a]),n=Lo(arguments[a]).then(i=>i.text());t.push(n)}return await Promise.all(t).then(async n=>{let i="";for(let l=0;l<n.length;l++)i=await this.convertViaSheet(n[l],r[l]),this.insert(i);return i})}async convertViaSheet(t,r){let a=new e3(r,this.hooks);await a.parse(t);for(let n of a.imported){let i=await Lo(n).then(c=>c.text()),l=await this.convertViaSheet(i,n);this.insert(l)}return this.sheets.push(a),typeof a.width<"u"&&(this.width=a.width),typeof a.height<"u"&&(this.height=a.height),typeof a.orientation<"u"&&(this.orientation=a.orientation),a.toString()}insert(t){let r=document.querySelector("head"),a=document.createElement("style");return a.setAttribute("data-pagedjs-inserted-styles","true"),a.appendChild(document.createTextNode(t)),r.appendChild(a),this.inserted.push(a),a}destroy(){this.styleEl.remove(),this.inserted.forEach(t=>{t.remove()}),this.sheets=[]}},zd=Sd;b();var r6=He(aa(),1);b();b();b();b();var r3=He(aa(),1),Po=class{constructor(t,r,a){let n=Object.assign({},t&&t.hooks,r&&r.hooks,a&&a.hooks);this.chunker=t,this.polisher=r,this.caller=a;for(let i in n)i in this&&n[i].register(this[i].bind(this))}};(0,r3.default)(Po.prototype);var xe=Po;var ce=He(bt(),1);b();var Cd={A0:{width:{value:841,unit:"mm"},height:{value:1189,unit:"mm"}},A1:{width:{value:594,unit:"mm"},height:{value:841,unit:"mm"}},A2:{width:{value:420,unit:"mm"},height:{value:594,unit:"mm"}},A3:{width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},A4:{width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A5:{width:{value:148,unit:"mm"},height:{value:210,unit:"mm"}},A6:{width:{value:105,unit:"mm"},height:{value:148,unit:"mm"}},A7:{width:{value:74,unit:"mm"},height:{value:105,unit:"mm"}},A8:{width:{value:52,unit:"mm"},height:{value:74,unit:"mm"}},A9:{width:{value:37,unit:"mm"},height:{value:52,unit:"mm"}},A10:{width:{value:26,unit:"mm"},height:{value:37,unit:"mm"}},B4:{width:{value:250,unit:"mm"},height:{value:353,unit:"mm"}},B5:{width:{value:176,unit:"mm"},height:{value:250,unit:"mm"}},letter:{width:{value:8.5,unit:"in"},height:{value:11,unit:"in"}},legal:{width:{value:8.5,unit:"in"},height:{value:14,unit:"in"}},ledger:{width:{value:11,unit:"in"},height:{value:17,unit:"in"}}};var Ad=class extends xe{constructor(t,r,a){super(t,r,a),this.pages={},this.width=void 0,this.height=void 0,this.orientation=void 0,this.marginalia={}}pageModel(t){return{selector:t,name:void 0,psuedo:void 0,nth:void 0,marginalia:{},width:void 0,height:void 0,orientation:void 0,margin:{top:{},right:{},left:{},bottom:{}},padding:{top:{},right:{},left:{},bottom:{}},border:{top:{},right:{},left:{},bottom:{}},backgroundOrigin:void 0,block:{},marks:void 0,notes:void 0,added:!1}}onAtPage(t,r,a){let n,i,l="",c,d,h,k=!1;t.prelude?(c=this.getTypeSelector(t),d=this.getPsuedoSelector(t),h=this.getNthSelector(t),l=ce.default.generate(t.prelude)):l="*",l in this.pages?(n=this.pages[l],i=this.replaceMarginalia(t),k=!0,n.added=!1):(n=this.pageModel(l),i=this.replaceMarginalia(t),this.pages[l]=n),n.name=c,n.psuedo=d,n.nth=h,k?n.marginalia=Object.assign(n.marginalia,i):n.marginalia=i;let x=this.replaceNotes(t);n.notes=x;let p=this.replaceDeclarations(t);if(p.size&&(n.size=p.size,n.width=p.size.width,n.height=p.size.height,n.orientation=p.size.orientation,n.format=p.size.format),p.bleed&&p.bleed[0]!="auto")switch(p.bleed.length){case 4:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[3]};break;case 3:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[1]};break;case 2:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[0],left:p.bleed[1]};break;default:n.bleed={top:p.bleed[0],right:p.bleed[0],bottom:p.bleed[0],left:p.bleed[0]}}p.marks&&((!p.bleed||p.bleed&&p.bleed[0]==="auto")&&(n.bleed={top:{value:6,unit:"mm"},right:{value:6,unit:"mm"},bottom:{value:6,unit:"mm"},left:{value:6,unit:"mm"}}),n.marks=p.marks),p.margin&&(n.margin=p.margin),p.padding&&(n.padding=p.padding),p.border&&(n.border=p.border),p.marks&&(n.marks=p.marks),k?n.block.children.appendList(t.block.children):n.block=t.block,a.remove(r)}afterTreeWalk(t,r){let a="*"in this.pages&&this.pages["*"].added===!1;if(this.addPageClasses(this.pages,t,r),a){let n=this.pages["*"].width,i=this.pages["*"].height,l=this.pages["*"].format,c=this.pages["*"].orientation,d=this.pages["*"].bleed,h=this.pages["*"].marks,k,x;":left"in this.pages&&(k=this.pages[":left"].bleed),":right"in this.pages&&(x=this.pages[":right"].bleed),n&&i&&(this.width!==n||this.height!==i)&&(this.width=n,this.height=i,this.format=l,this.orientation=c,this.addRootVars(t,n,i,c,d,x,k,h),this.addRootPage(t,this.pages["*"].size,d,x,k),this.emit("size",{width:n,height:i,orientation:c,format:l,bleed:d}),this.emit("atpages",this.pages))}}getTypeSelector(t){let r;return ce.default.walk(t,{visit:"TypeSelector",enter:(a,n,i)=>{r=a.name}}),r}getPsuedoSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name!=="nth"&&(r=a.name)}}),r}getNthSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name==="nth"&&a.children&&(r=a.children.first().value)}}),r}replaceMarginalia(t){let r={},a=["top-left-corner","top-left","top","top-center","top-right","top-right-corner","bottom-left-corner","bottom-left","bottom","bottom-center","bottom-right","bottom-right-corner","left-top","left-middle","left","left-bottom","top-right-corner","right-top","right-middle","right","right-bottom","right-right-corner"];return ce.default.walk(t.block,{visit:"Atrule",enter:(n,i,l)=>{let c=n.name;a.includes(c)&&(c==="top"&&(c="top-center"),c==="right"&&(c="right-middle"),c==="left"&&(c="left-middle"),c==="bottom"&&(c="bottom-center"),r[c]=n.block,l.remove(i))}}),r}replaceNotes(t){let r={};return ce.default.walk(t.block,{visit:"Atrule",enter:(a,n,i)=>{let l=a.name;l==="footnote"&&(r[l]=a.block,i.remove(n))}}),r}replaceDeclarations(t){let r={};return ce.default.walk(t.block,{visit:"Declaration",enter:(a,n,i)=>{let l=ce.default.property(a.property).name;if(l==="marks")r.marks=[],ce.default.walk(a,{visit:"Identifier",enter:c=>{r.marks.push(c.name)}}),i.remove(n);else if(l==="margin")r.margin=this.getMargins(a),i.remove(n);else if(l.indexOf("margin-")===0){let c=l.substring(7);r.margin||(r.margin={top:{},right:{},left:{},bottom:{}}),r.margin[c]=a.value.children.first(),i.remove(n)}else if(l==="padding")r.padding=this.getPaddings(a.value),i.remove(n);else if(l.indexOf("padding-")===0){let c=l.substring(8);r.padding||(r.padding={top:{},right:{},left:{},bottom:{}}),r.padding[c]=a.value.children.first(),i.remove(n)}else if(l==="border")r.border||(r.border={top:{},right:{},left:{},bottom:{}}),r.border.top=ce.default.generate(a.value),r.border.right=ce.default.generate(a.value),r.border.left=ce.default.generate(a.value),r.border.bottom=ce.default.generate(a.value),i.remove(n);else if(l.indexOf("border-")===0){r.border||(r.border={top:{},right:{},left:{},bottom:{}});let c=l.substring(7);r.border[c]=ce.default.generate(a.value),i.remove(n)}else l==="size"?(r.size=this.getSize(a),i.remove(n)):l==="bleed"&&(r.bleed=[],ce.default.walk(a,{enter:c=>{switch(c.type){case"String":c.value.indexOf("auto")>-1&&r.bleed.push("auto");break;case"Dimension":r.bleed.push({value:c.value,unit:c.unit});break;case"Number":r.bleed.push({value:c.value,unit:"px"});break;default:}}}),i.remove(n))}}),r}getSize(t){let r,a,n,i;return ce.default.walk(t,{visit:"Dimension",enter:(l,c,d)=>{let{value:h,unit:k}=l;typeof r>"u"?r={value:h,unit:k}:typeof a>"u"&&(a={value:h,unit:k})}}),ce.default.walk(t,{visit:"String",enter:(l,c,d)=>{let h=l.value.replace(/["|']/g,""),k=Cd[h];k&&(r=k.width,a=k.height)}}),ce.default.walk(t,{visit:"Identifier",enter:(l,c,d)=>{let h=l.name;if(h==="landscape"||h==="portrait")n=l.name;else if(h!=="auto"){let k=Cd[h];k&&(r=k.width,a=k.height),i=h}}}),{width:r,height:a,orientation:n,format:i}}getMargins(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getPaddings(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getBorders(t){let r={top:{},right:{},left:{},bottom:{}};return t.prop=="border"?(r.top=ce.default.generate(t.value),r.right=ce.default.generate(t.value),r.bottom=ce.default.generate(t.value),r.left=ce.default.generate(t.value)):t.prop=="border-top"?r.top=ce.default.generate(t.value):t.prop=="border-right"?r.right=ce.default.generate(t.value):t.prop=="border-bottom"?r.bottom=ce.default.generate(t.value):t.prop=="border-left"&&(r.left=ce.default.generate(t.value)),r}addPageClasses(t,r,a){if("*"in t&&t["*"].added===!1){let n=this.createPage(t["*"],r.children,a);a.insertRule(n),t["*"].added=!0}if(":left"in t&&t[":left"].added===!1){let n=this.createPage(t[":left"],r.children,a);a.insertRule(n),t[":left"].added=!0}if(":right"in t&&t[":right"].added===!1){let n=this.createPage(t[":right"],r.children,a);a.insertRule(n),t[":right"].added=!0}if(":first"in t&&t[":first"].added===!1){let n=this.createPage(t[":first"],r.children,a);a.insertRule(n),t[":first"].added=!0}if(":blank"in t&&t[":blank"].added===!1){let n=this.createPage(t[":blank"],r.children,a);a.insertRule(n),t[":blank"].added=!0}for(let n in t)if(t[n].nth&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}for(let n in t)if(t[n].name&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}}createPage(t,r,a){let n=this.selectorsForPage(t),i=t.block.children.copy(),l={type:"Block",loc:0,children:i},c=this.createRule(n,l);return this.addMarginVars(t.margin,i,i.first()),this.addPaddingVars(t.padding,i,i.first()),this.addBorderVars(t.border,i,i.first()),t.width&&this.addDimensions(t.width,t.height,t.orientation,i,i.first()),t.marginalia&&(this.addMarginaliaStyles(t,r,c,a),this.addMarginaliaContent(t,r,c,a)),t.notes&&this.addNotesStyles(t.notes,t,r,c,a),c}addMarginVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-margin-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addPaddingVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-padding-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addBorderVars(t,r,a){for(let n of Object.keys(t)){let i=t[n];if(typeof i=="string"){let l=r.createItem({type:"Declaration",property:"--pagedjs-border-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}}addDimensions(t,r,a,n,i){let l,c;l=le(t),c=le(r),a&&a!=="portrait"&&([l,c]=[c,l]);let d=this.createVariable("--pagedjs-pagebox-width",l);n.appendData(d);let h=this.createVariable("--pagedjs-pagebox-height",c);n.appendData(h)}addMarginaliaStyles(t,r,a,n){for(let i in t.marginalia){let l=ce.default.clone(t.marginalia[i]),c=!1;if(l.children.isEmpty())continue;ce.default.walk(l,{visit:"Declaration",enter:(x,p,g)=>{if(x.property==="content"&&(x.value.children&&x.value.children.first().name==="none"?c=!1:c=!0,g.remove(p)),x.property==="vertical-align"&&(ce.default.walk(x,{visit:"Identifier",enter:(v,q,L)=>{let O=v.name;O==="top"?v.name="flex-start":O==="middle"?v.name="center":O==="bottom"&&(v.name="flex-end")}}),x.property="align-items"),x.property==="width"&&(i==="top-left"||i==="top-center"||i==="top-right"||i==="bottom-left"||i==="bottom-center"||i==="bottom-right")){let v=ce.default.clone(x);v.property="max-width",g.appendData(v)}if(x.property==="height"&&(i==="left-top"||i==="left-middle"||i==="left-bottom"||i==="right-top"||i==="right-middle"||i==="right-bottom")){let v=ce.default.clone(x);v.property="max-height",g.appendData(v)}}});let d=this.selectorsForPageMargin(t,i),h=this.createRule(d,l);r.appendData(h);let k=ce.default.generate({type:"Selector",children:d});this.marginalia[k]={page:t,selector:k,block:t.marginalia[i],hasContent:c}}}addMarginaliaContent(t,r,a,n){let i;for(let l in t.marginalia){let c=ce.default.clone(t.marginalia[l]);if(ce.default.walk(c,{visit:"Declaration",enter:(g,v,q)=>{g.property!=="content"&&q.remove(v),g.value.children&&g.value.children.first().name==="none"&&(i=!0)}}),c.children.isEmpty())continue;let d=this.selectorsForPageMargin(t,l),h;d.insertData({type:"Combinator",name:">"}),d.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),d.insertData({type:"Combinator",name:">"}),d.insertData({type:"TypeSelector",name:"*"}),i?h=this.createDeclaration("display","none"):h=this.createDeclaration("display","block");let k=this.createRule(d,[h]);n.insertRule(k);let x=this.selectorsForPageMargin(t,l);x.insertData({type:"Combinator",name:">"}),x.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),x.insertData({type:"PseudoElementSelector",name:"after",children:null});let p=this.createRule(x,c);n.insertRule(p)}}addRootVars(t,r,a,n,i,l,c,d){let h=[],k=new ce.default.List;k.insertData({type:"PseudoClassSelector",name:"root",children:null});let x,p,g,v,q,L;if(!i)x=le(r),p=le(a),g=le(r),v=le(a),q=le(r),L=le(a);else{x=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,p=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,g=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,v=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,q=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,L=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`;let X=this.createVariable("--pagedjs-bleed-top",le(i.top)),ne=this.createVariable("--pagedjs-bleed-right",le(i.right)),ve=this.createVariable("--pagedjs-bleed-bottom",le(i.bottom)),be=this.createVariable("--pagedjs-bleed-left",le(i.left)),Le=this.createVariable("--pagedjs-bleed-right-top",le(i.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(i.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(i.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(i.left)),ie=this.createVariable("--pagedjs-bleed-left-top",le(i.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(i.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(i.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(i.left));l&&(Le=this.createVariable("--pagedjs-bleed-right-top",le(l.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(l.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(l.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(l.left)),g=`calc( ${le(r)} + ${le(l.left)} + ${le(l.right)} )`,v=`calc( ${le(a)} + ${le(l.top)} + ${le(l.bottom)} )`),c&&(ie=this.createVariable("--pagedjs-bleed-left-top",le(c.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(c.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(c.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(c.left)),q=`calc( ${le(r)} + ${le(c.left)} + ${le(c.right)} )`,L=`calc( ${le(a)} + ${le(c.top)} + ${le(c.bottom)} )`);let zi=this.createVariable("--pagedjs-width",le(r)),Nr=this.createVariable("--pagedjs-height",le(a));h.push(X,ne,ve,be,Le,Ne,Ae,Te,ie,Yt,da,pa,zi,Nr)}if(d&&d.forEach(X=>{let ne=this.createVariable("--pagedjs-mark-"+X+"-display","block");h.push(ne)}),n){let X=this.createVariable("--pagedjs-orientation",n);h.push(X),n!=="portrait"&&([x,p]=[p,x],[g,v]=[v,g],[q,L]=[L,q])}let O=this.createVariable("--pagedjs-width",x),M=this.createVariable("--pagedjs-height",p),H=this.createVariable("--pagedjs-width-right",g),F=this.createVariable("--pagedjs-height-right",v),U=this.createVariable("--pagedjs-width-left",q),G=this.createVariable("--pagedjs-height-left",L);h.push(O,M,H,F,U,G);let Y=this.createRule(k,h);t.children.appendData(Y)}addNotesStyles(t,r,a,n,i){for(let l in t){let c=this.selectorsForPage(r);c.insertData({type:"Combinator",name:" "}),c.insertData({type:"ClassSelector",name:"pagedjs_"+l+"_content"});let d=this.createRule(c,t[l]);a.appendData(d)}}addRootPage(t,r,a,n,i){let{width:l,height:c,orientation:d,format:h}=r,k=new ce.default.List,x=new ce.default.List,p=new ce.default.List,g=new ce.default.List,v=new ce.default.List,q=new ce.default.List;if(a){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.left.unit,value:a.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.right.unit,value:a.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.top.unit,value:a.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.bottom.unit,value:a.bottom.value}),g.appendData({type:"Function",name:"calc",children:O}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Function",name:"calc",children:M})}else h?(g.appendData({type:"Identifier",name:h}),d&&(g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Identifier",name:d}))):(g.appendData({type:"Dimension",unit:l.unit,value:l.value}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Dimension",unit:c.unit,value:c.value}));k.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:g}}),k.appendData({type:"Declaration",property:"margin",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}});let L=t.children.createItem({type:"Atrule",prelude:null,name:"page",block:{type:"Block",loc:null,children:k}});if(t.children.append(L),i){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.left.unit,value:i.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.right.unit,value:i.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.top.unit,value:i.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.bottom.unit,value:i.bottom.value}),v.appendData({type:"Function",name:"calc",children:O}),v.appendData({type:"WhiteSpace",value:" "}),v.appendData({type:"Function",name:"calc",children:M}),x.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:v}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :left",block:{type:"Block",loc:null,children:x}});t.children.append(H)}if(n){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.left.unit,value:n.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.right.unit,value:n.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.top.unit,value:n.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.bottom.unit,value:n.bottom.value}),q.appendData({type:"Function",name:"calc",children:O}),q.appendData({type:"WhiteSpace",value:" "}),q.appendData({type:"Function",name:"calc",children:M}),p.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:q}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :right",block:{type:"Block",loc:null,children:p}});t.children.append(H)}}getNth(t){let r=t.indexOf("n"),a=t.indexOf("+"),n=t.split("n"),i=t.split("+"),l=null,c=null;return r>-1?(l=n[0],a>-1&&(c=i[1])):c=t,{type:"Nth",loc:null,selector:null,nth:{type:"AnPlusB",loc:null,a:l,b:c}}}addPageAttributes(t,r,a){let n=[r.dataset.page];if(n&&n.length)for(let i of n)i&&(t.name=i,t.element.classList.add("pagedjs_named_page"),t.element.classList.add("pagedjs_"+i+"_page"),r.dataset.splitFrom||t.element.classList.add("pagedjs_"+i+"_first_page"))}getStartElement(t,r){let a=r&&r.node;if(!t&&!r)return;if(!a)return t.children[0];if(a.nodeType===1&&a.parentNode.nodeType===11||a.nodeType===1&&a.dataset.page)return a;let n=qs(a),i=n.querySelectorAll("[data-page]");return i.length?i[i.length-1]:n.children[0]}beforePageLayout(t,r,a,n){let i=this.getStartElement(r,a);i&&this.addPageAttributes(t,i,n.pages)}finalizePage(t,r,a,n){for(let i in this.marginalia){let l=this.marginalia[i],c=i.split(" "),d;r.element.matches(c[0])&&l.hasContent&&(d=r.element.querySelector(c[1]),d.classList.add("hasContent"))}["top","bottom"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i),c=r.element.querySelector(".pagedjs_margin-"+i+"-center"),d=r.element.querySelector(".pagedjs_margin-"+i+"-left"),h=r.element.querySelector(".pagedjs_margin-"+i+"-right"),k=c.classList.contains("hasContent"),x=d.classList.contains("hasContent"),p=h.classList.contains("hasContent"),g,v,q;if(x&&(v=window.getComputedStyle(d)["max-width"]),p&&(q=window.getComputedStyle(h)["max-width"]),k)if(g=window.getComputedStyle(c)["max-width"],g==="none"||g==="auto")if(!x&&!p)l.style["grid-template-columns"]="0 1fr 0";else if(x)if(p)if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 1fr "+v;else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=h.offsetWidth,H=L+O+M,F=O*100/H;F>40?l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+F+"%) minmax(16.66%, 1fr)":l.style["grid-template-columns"]="repeat(3, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal",h.style["white-space"]="normal"}else if(v!=="none"&&v!=="auto")l.style["grid-template-columns"]=v+" 1fr "+v;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal"}else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",h.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=h.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",h.style["white-space"]="normal",c.style["white-space"]="normal"}else g!=="none"&&g!=="auto"&&(x&&v!=="none"&&v!=="auto"?l.style["grid-template-columns"]=v+" "+g+" 1fr":p&&q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr "+g+" "+q:l.style["grid-template-columns"]="1fr "+g+" 1fr");else if(x)if(!p)l.style["grid-template-columns"]="1fr 0 0";else if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 0 1fr";else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]="1fr 0 "+q;else{l.style["grid-template-columns"]="auto 1fr auto",d.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=h.offsetWidth,M=L+O,H=L*100/M;l.style["grid-template-columns"]="minmax(16.66%, "+H+"%) 0 1fr",d.style["white-space"]="normal",h.style["white-space"]="normal"}else q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr 0 "+q:l.style["grid-template-columns"]="0 0 1fr"}),["left","right"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i+"-middle.hasContent"),c=r.element.querySelector(".pagedjs_margin-"+i),d=r.element.querySelector(".pagedjs_margin-"+i+"-top"),h=r.element.querySelector(".pagedjs_margin-"+i+"-bottom"),k=d.classList.contains("hasContent"),x=h.classList.contains("hasContent"),p,g,v;k&&(g=window.getComputedStyle(d)["max-height"]),x&&(v=window.getComputedStyle(h)["max-height"]),l?(p=window.getComputedStyle(l)["max-height"],p==="none"||p==="auto"?!k&&!x?c.style["grid-template-rows"]="0 1fr 0":k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" calc(100% - "+g+" - "+v+") "+v:c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g:v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):g!=="none"&&g!=="auto"&&(c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g):v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):k&&g!=="none"&&g!=="auto"?c.style["grid-template-rows"]=g+" "+p+" calc(100% - ("+g+" + "+p+"))":x&&v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr "+p+" "+v:c.style["grid-template-rows"]="calc((100% - "+p+")/2) "+p+" calc((100% - "+p+")/2)"):k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" 1fr "+v:c.style["grid-template-rows"]=g+" 0 1fr":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="1fr 0 1fr":c.style["grid-template-rows"]="1fr 0 0":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="0 0 1fr"})}selectorsForPage(t){let r,a,n=new ce.default.List;return n.insertData({type:"ClassSelector",name:"pagedjs_page"}),t.name&&(n.insertData({type:"ClassSelector",name:"pagedjs_named_page"}),n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_page"})),t.psuedo&&!(t.name&&t.psuedo==="first")&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.psuedo+"_page"}),t.name&&t.psuedo==="first"&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_"+t.psuedo+"_page"}),t.nth&&(r=new ce.default.List,a=this.getNth(t.nth),r.insertData(a),n.insertData({type:"PseudoClassSelector",name:"nth-of-type",children:r})),n}selectorsForPageMargin(t,r){let a=this.selectorsForPage(t);return a.insertData({type:"Combinator",name:" "}),a.insertData({type:"ClassSelector",name:"pagedjs_margin-"+r}),a}createDeclaration(t,r,a){let n=new ce.default.List;return n.insertData({type:"Identifier",loc:null,name:r}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createVariable(t,r){return{type:"Declaration",loc:null,property:t,value:{type:"Raw",value:r}}}createCalculatedDimension(t,r,a,n="+"){let i=new ce.default.List,l=new ce.default.List;return r.forEach((c,d)=>{l.appendData({type:"Dimension",unit:c.unit,value:c.value}),l.appendData({type:"WhiteSpace",value:" "}),d+1<r.length&&(l.appendData({type:"Operator",value:n}),l.appendData({type:"WhiteSpace",value:" "}))}),i.insertData({type:"Function",loc:null,name:"calc",children:l}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:i}}}createDimension(t,r,a){let n=new ce.default.List;return n.insertData({type:"Dimension",loc:null,value:r.value,unit:r.unit}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createBlock(t){let r=new ce.default.List;return t.forEach(a=>{r.insertData(a)}),{type:"Block",loc:null,children:r}}createRule(t,r){let a=new ce.default.List;return a.insertData({type:"Selector",children:t}),Array.isArray(r)&&(r=this.createBlock(r)),{type:"Rule",prelude:{type:"SelectorList",children:a},block:r}}},a3=Ad;b();var Td=He(bt(),1);var Ed=class extends xe{constructor(t,r,a){super(t,r,a),this.breaks={}}onDeclaration(t,r,a,n){let i=t.property;if(i==="page"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude),k={property:i,value:c,selector:d,name:c};d.split(",").forEach(x=>{this.breaks[x]?this.breaks[x].push(k):this.breaks[x]=[k]}),a.remove(r)}if(i==="break-before"||i==="break-after"||i==="page-break-before"||i==="page-break-after"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude);i==="page-break-before"?i="break-before":i==="page-break-after"&&(i="break-after");let h={property:i,value:c,selector:d};d.split(",").forEach(k=>{this.breaks[k]?this.breaks[k].push(h):this.breaks[k]=[h]}),a.remove(r)}}afterParsed(t){this.processBreaks(t,this.breaks)}processBreaks(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++)for(let l of r[n])if(l.property==="break-after"){let c=jc(i[a],t);i[a].setAttribute("data-break-after",l.value),c&&c.setAttribute("data-previous-break-after",l.value)}else if(l.property==="break-before"){let c=cg(i[a],t);if(c){if(l.value==="page"&&Ds(i[a],c))continue;i[a].setAttribute("data-break-before",l.value),c.setAttribute("data-next-break-before",l.value)}}else if(l.property==="page"){i[a].setAttribute("data-page",l.value);let c=jc(i[a],t);c&&c.setAttribute("data-after-page",l.value)}else i[a].setAttribute("data-"+l.property,l.value)}}mergeBreaks(t,r){for(let a in r)a in t?t[a]=t[a].concat(r[a]):t[a]=r[a];return t}addBreakAttributes(t,r){let a=t.querySelector("[data-break-before]"),n=t.querySelector("[data-break-after]"),i=t.querySelector("[data-previous-break-after]");a&&(a.dataset.splitFrom?(r.splitFrom=a.dataset.splitFrom,t.setAttribute("data-split-from",a.dataset.splitFrom)):a.dataset.breakBefore&&a.dataset.breakBefore!=="avoid"&&(r.breakBefore=a.dataset.breakBefore,t.setAttribute("data-break-before",a.dataset.breakBefore))),n&&n.dataset&&(n.dataset.splitTo?(r.splitTo=n.dataset.splitTo,t.setAttribute("data-split-to",n.dataset.splitTo)):n.dataset.breakAfter&&n.dataset.breakAfter!=="avoid"&&(r.breakAfter=n.dataset.breakAfter,t.setAttribute("data-break-after",n.dataset.breakAfter))),i&&i.dataset&&i.dataset.previousBreakAfter&&i.dataset.previousBreakAfter!=="avoid"&&(r.previousBreakAfter=i.dataset.previousBreakAfter)}afterPageLayout(t,r){this.addBreakAttributes(t,r)}},n3=Ed;b();var i3=He(bt(),1),qd=class extends xe{constructor(t,r,a){super(t,r,a)}onAtMedia(t,r,a){let n=this.getMediaName(t),i;n.includes("print")?(i=t.block.children,a.appendList(i),a.remove(r)):!n.includes("all")&&!n.includes("pagedjs-ignore")&&a.remove(r)}getMediaName(t){let r=[];if(!(typeof t.prelude>"u"||t.prelude.type!=="AtrulePrelude"))return i3.default.walk(t.prelude,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),r}},s3=qd;b();var Od=class extends xe{constructor(t,r,a){super(t,r,a)}afterPageLayout(t,r,a,n){let i=Array.from(t.querySelectorAll("[data-split-from]")),l=t.parentNode,c=Array.prototype.indexOf.call(l.children,t),d;if(c===0)return;d=l.children[c-1];let h;i.forEach(k=>{let x=k.dataset.ref;h=d.querySelector("[data-ref='"+x+"']:not([data-split-to])"),h&&(h.dataset.splitTo=x,h.dataset.splitFrom||(h.dataset.splitOriginal=!0))}),h&&this.handleAlignment(h)}handleAlignment(t){let r=window.getComputedStyle(t),a=r["text-align"],n=r["text-align-last"];t.dataset.lastSplitElement="true",a==="justify"&&n==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=n}},o3=Od;b();var Io=He(bt(),1),Dd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counters={},this.resetCountersMap=new Map}onDeclaration(t,r,a,n){let i=t.property;if(i==="counter-increment"){this.handleIncrement(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}else if(i==="counter-reset"){this.handleReset(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}}afterParsed(t){this.processCounters(t,this.counters),this.scopeCounters(this.counters)}addCounter(t){return t in this.counters?this.counters[t]:(this.counters[t]={name:t,increments:{},resets:{}},this.counters[t])}handleIncrement(t,r){let a=[],n=t.value.children;return n.forEach((i,l)=>{if(i.type&&i.type==="Identifier"){let c=i.name;if(c==="page"||c.indexOf("target-counter-")===0)return;let d,h,k;l.next&&l.next.data.type==="WhiteSpace"&&(d=l.next),d&&d.next&&d.next.data.type==="Number"&&(h=d.next,k=parseInt(h.data.value));let x=Io.default.generate(r.ruleNode.prelude),p;c in this.counters?p=this.counters[c]:p=this.addCounter(c);let g={selector:x,number:k||1};p.increments[x]=g,a.push(g),n.remove(l),d&&n.remove(d),h&&n.remove(h)}}),a}handleReset(t,r){let a=t.value.children;a.forEach((n,i)=>{if(n.type&&n.type==="Identifier"){let l=n.name,c,d,h;i.next&&i.next.data.type==="WhiteSpace"&&(c=i.next),c&&c.next&&(c.next.data.type==="Number"?(d=c.next,h=parseInt(d.data.value)):c.next.data.type==="Function"&&c.next.data.name==="var"&&(d=c.next,h=c.next.data.children.head.data.name));let k,x,p=r.ruleNode.prelude;r.ruleNode.type==="Atrule"&&r.ruleNode.name==="page"?x=".pagedjs_page":x=Io.default.generate(p||r.ruleNode),l==="footnote"&&this.addFootnoteMarkerCounter(t.value.children),l in this.counters?k=this.counters[l]:k=this.addCounter(l);let g={selector:x,number:h||0};k.resets[x]=g,x!==".pagedjs_page"&&(a.remove(i),c&&a.remove(c),d&&a.remove(d))}})}processCounters(t,r){let a;for(let n in r)a=this.counters[n],this.processCounterIncrements(t,a),this.processCounterResets(t,a),n!=="page"&&this.addCounterValues(t,a)}scopeCounters(t){let r=[];for(let a in t)a!=="page"&&r.push(`${t[a].name} 0`);this.insertRule(`.pagedjs_pages { counter-reset: ${r.join(" ")} page 0 pages var(--pagedjs-page-count) footnote var(--pagedjs-footnotes-count) footnote-marker var(--pagedjs-footnotes-count)}`)}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}processCounterIncrements(t,r){let a;for(let n in r.increments){a=r.increments[n];let i=t.querySelectorAll(a.selector);for(let l=0;l<i.length;l++)i[l].setAttribute("data-counter-"+r.name+"-increment",a.number),i[l].getAttribute("data-counter-increment")?i[l].setAttribute("data-counter-increment",i[l].getAttribute("data-counter-increment")+" "+r.name):i[l].setAttribute("data-counter-increment",r.name)}}processCounterResets(t,r){let a;for(let i in r.resets){a=r.resets[i];let l=t.querySelectorAll(a.selector);for(var n=0;n<l.length;n++){let c=a.number;typeof c=="string"&&c.startsWith("--")&&(c=l[n].style.getPropertyValue(c)||0),l[n].setAttribute("data-counter-"+r.name+"-reset",c),l[n].getAttribute("data-counter-reset")?l[n].setAttribute("data-counter-reset",l[n].getAttribute("data-counter-reset")+" "+r.name):l[n].setAttribute("data-counter-reset",r.name)}}}addCounterValues(t,r){let a=r.name;if(a==="page"||a==="footnote")return;let n=t.querySelectorAll("[data-counter-"+a+"-reset], [data-counter-"+a+"-increment]"),i=0,l,c,d,h,k,x,p;for(let g=0;g<n.length;g++)l=n[g],x=0,p=[],l.hasAttribute("data-counter-"+a+"-reset")&&(d=l.getAttribute("data-counter-"+a+"-reset"),h=parseInt(d),x=h-i,p.push(`${a} ${x}`),i=h),l.hasAttribute("data-counter-"+a+"-increment")&&(c=l.getAttribute("data-counter-"+a+"-increment"),k=parseInt(c),i+=k,l.setAttribute("data-counter-"+a+"-value",i),p.push(`${a} ${k}`)),p.length>0&&this.incrementCounterForElement(l,p)}addFootnoteMarkerCounter(t){let r=[];Io.default.walk(t,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),!r.includes("footnote-maker")&&(t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Identifier",name:"footnote-marker"}),t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Number",value:0}))}incrementCounterForElement(t,r){if(!t||!r||r.length===0)return;let a=t.dataset.ref,n=Array.from(this.styleSheet.cssRules).filter(l=>l.selectorText===`[data-ref="${t.dataset.ref}"]:not([data-split-from])`&&l.style[0]==="counter-increment").map(l=>l.style.counterIncrement);n.push(this.mergeIncrements(r,(l,c)=>(parseInt(l)||0)+(parseInt(c)||0)));let i=this.mergeIncrements(n,(l,c)=>c);this.insertRule(`[data-ref="${a}"]:not([data-split-from]) { counter-increment: ${i} }`)}mergeIncrements(t,r){let a={};return t.forEach(n=>{let i=n.split(" ");for(let l=0;l<i.length;l+=2)a[i[l]]=r(a[i[l]],i[l+1])}),Object.entries(a).map(([n,i])=>`${n} ${i}`).join(" ")}afterPageLayout(t,r){let a=[];t.querySelectorAll("[data-counter-page-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset&&l.dataset.ref;if(!(c&&this.resetCountersMap.has(c))){c&&this.resetCountersMap.set(c,"");let d=l.dataset.counterPageReset;a.push(`page ${d}`)}}),t.querySelectorAll("[data-counter-footnote-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset.counterFootnoteReset;a.push(`footnote ${c}`),a.push(`footnote-marker ${c}`)}),a.length&&this.styleSheet.insertRule(`[data-page-number="${t.dataset.pageNumber}"] { counter-increment: none; counter-reset: ${a.join(" ")} }`,this.styleSheet.cssRules.length)}},l3=Dd;b();var Md=class extends xe{constructor(t,r,a){super(t,r,a)}afterParsed(t){let r=t.querySelectorAll("ol");for(var a of r)this.addDataNumbers(a)}afterPageLayout(t,r,a,n){var i=t.getElementsByTagName("ol");for(var l of i)l.firstElementChild&&(l.start=l.firstElementChild.dataset.itemNum)}addDataNumbers(t){let r=1;t.hasAttribute("start")&&(r=parseInt(t.getAttribute("start"),10),isNaN(r)&&(r=1));let a=t.children;for(var n=0;n<a.length;n++)a[n].setAttribute("data-item-num",n+r)}},c3=Md;b();var u3=He(bt(),1),jd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.fixedElementsSelector=[],this.fixedElements=[]}onDeclaration(t,r,a,n){if(t.property==="position"&&t.value.children.first().name==="fixed"){let i=u3.default.generate(n.ruleNode.prelude);this.fixedElementsSelector.push(i),a.remove(r)}}afterParsed(t){this.fixedElementsSelector.forEach(r=>{t.querySelectorAll(`${r}`).forEach(a=>{a.style.setProperty("position","absolute"),this.fixedElements.push(a),a.remove()})})}afterPageLayout(t,r,a){this.fixedElements.forEach(n=>{let i=n.cloneNode(!0);t.querySelector(".pagedjs_pagebox").insertAdjacentElement("afterbegin",i)})}},d3=jd;b();var p3=He(bt(),1),Bd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.pageCounter={name:"page",increments:{},resets:{}}}onDeclaration(t,r,a,n){t.property==="counter-increment"&&this.handleIncrement(t,n)&&a.remove(r)}afterParsed(t){for(let r in this.pageCounter.increments){let a=this.pageCounter.increments[r];this.insertRule(`${a.selector} { --pagedjs-page-counter-increment: ${a.number} }`)}}handleIncrement(t,r){let a=t.value.children.first(),n=t.value.children.getSize()>1?t.value.children.last().value:1,i=a&&a.name;if(i&&i.indexOf("target-counter-")===0||i!=="page"||r.ruleNode.name==="page"&&r.ruleNode.type==="Atrule")return;let l=p3.default.generate(r.ruleNode.prelude);return this.pageCounter.increments[l]={selector:l,number:n}}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}},f3=Bd;b();var Ld=He(bt(),1);var Pd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Ld.default.generate(t.prelude);if(n.match(/:(first|last|nth)-of-type/)){let i=Ld.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="nth-of-type-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-nth-of-type");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-nth-of-type",c)):i[a].setAttribute("data-nth-of-type",r[n][0])}let l=`*[data-nth-of-type*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},h3=Pd;b();var Id=He(bt(),1);var Rd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Id.default.generate(t.prelude);if(n.match(/\+/)){let i=Id.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="following-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-following");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-following",c)):i[a].setAttribute("data-following",r[n][0])}let l=`*[data-following*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},m3=Rd;b();var gn=He(bt(),1),Nd=class extends xe{constructor(t,r,a){super(t,r,a),this.footnotes={},this.needsLayout=[]}onDeclaration(t,r,a,n){let i=t.property;if(i==="float"){let l=t.value.children&&t.value.children.first();if((l&&l.name)==="footnote"){let d=gn.default.generate(n.ruleNode.prelude);this.footnotes[d]={selector:d,policy:"auto",display:"block"},a.remove(r)}}if(i==="footnote-policy"){let l=t.value.children&&t.value.children.first(),c=l&&l.name;if(c){let d=gn.default.generate(n.ruleNode.prelude),h=this.footnotes[d];h&&(h.policy=c)}}if(i==="footnote-display"){let l=t.value.children&&t.value.children.first(),c=l&&l.name,d=gn.default.generate(n.ruleNode.prelude);if(c&&this.footnotes[d]){let h=this.footnotes[d];h&&(h.display=c)}}}onPseudoSelector(t,r,a,n,i){let l=t.name;if(l==="footnote-marker"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-marker"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"marker",loc:null,children:null}),c.children.first().children=d}if(l==="footnote-call"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-call"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"after",loc:null,children:null}),c.children.first().children=d}}afterParsed(t){this.processFootnotes(t,this.footnotes)}processFootnotes(t,r){for(let n in r){let i=t.querySelectorAll(n),l,c=r[n];for(var a=0;a<i.length;a++)l=i[a],l.setAttribute("data-note","footnote"),l.setAttribute("data-break-before","avoid"),l.setAttribute("data-note-policy",c.policy||"auto"),l.setAttribute("data-note-display",c.display||"block"),this.processFootnoteContainer(l)}}processFootnoteContainer(t){let r=t.parentElement,a=r;for(;r;){if(Ms(r)){a.setAttribute("data-has-notes","true");break}a=r,r=r.parentElement,r||a.setAttribute("data-has-notes","true")}}renderNode(t){if(t.nodeType==1){let r;if(!t.dataset)return;t.dataset.note==="footnote"?r=[t]:(t.dataset.hasNotes||t.querySelectorAll("[data-note='footnote']"))&&(r=t.querySelectorAll("[data-note='footnote']")),r&&r.length&&this.findVisibleFootnotes(r,t)}}findVisibleFootnotes(t,r){let a,n,i;a=r.closest(".pagedjs_page_content"),n=a.getBoundingClientRect(),i=n.left+n.width;for(let l=0;l<t.length;++l){let c=t[l];c.getBoundingClientRect().left<i&&this.moveFootnote(c,r.closest(".pagedjs_area"),!0)}}moveFootnote(t,r,a){let n=r.querySelector(".pagedjs_footnote_area"),i=n.querySelector(".pagedjs_footnote_content"),l=i.querySelector(".pagedjs_footnote_inner_content");if(!ft(t))return;let c;if(a&&(c=this.createFootnoteCall(t)),t.removeAttribute("data-break-before"),l.querySelector(`[data-ref="${t.dataset.ref}"]`)){t.remove();return}l.appendChild(t),i.classList.contains("pagedjs_footnote_empty")&&i.classList.remove("pagedjs_footnote_empty"),t.dataset.footnoteMarker=t.dataset.ref,t.id=`note-${t.dataset.ref}`;let h=i.scrollHeight,x=r.querySelector(".pagedjs_page_content").getBoundingClientRect(),p=x.left+x.width,g=c&&c.getBoundingClientRect(),v=n.getBoundingClientRect(),q=this.marginsHeight(i),L=this.paddingHeight(i),O=this.borderHeight(i),M=q+L+O,H=Math.floor(v.top);v.height===0&&(H-=this.marginsHeight(i,!1),H-=this.paddingHeight(i,!1),H-=this.borderHeight(i,!1));let F=t.dataset.notePolicy,U=0,G=0;if(c){let be=c.previousSibling,Le=new Range;be?Le.setStartBefore(be):Le.setStartBefore(c),Le.setEndAfter(c);let Ne=Le.getBoundingClientRect();if(U=Ne.bottom,!F||F==="auto")G=Math.ceil(Ne.bottom);else if(F==="line")G=Math.ceil(Ne.top);else if(F==="block"){let Ae=c.closest("p").previousElementSibling;Ae?G=Math.ceil(Ae.getBoundingClientRect().bottom):G=Math.ceil(Ne.bottom)}}let Y=h+M-v.height,X=U?H-U:0,ne=U?Math.floor(v.top)-G:0,ve=n.querySelector("[data-note='footnote']");if(a&&g.left>p)t.remove();else if(!ve&&a&&M>X){r.style.setProperty("--pagedjs-footnotes-height","0px");let be=document.createElement("div");be.appendChild(t),this.needsLayout.push(be)}else a?U<v.top-Y?r.style.setProperty("--pagedjs-footnotes-height",`${h+q+O}px`):(r.style.setProperty("--pagedjs-footnotes-height",`${v.height+ne}px`),l.style.height=v.height+ne-M+"px"):r.style.setProperty("--pagedjs-footnotes-height",`${h+M}px`)}createFootnoteCall(t){let r=t.parentElement,a=document.createElement("a");for(let n of t.classList)a.classList.add(`${n}`);return a.dataset.footnoteCall=t.dataset.ref,a.dataset.ref=t.dataset.ref,a.dataset.dataCounterFootnoteIncrement=1,a.href=`#note-${t.dataset.ref}`,r.insertBefore(a,t),a}afterPageLayout(t,r,a,n){let i=t.querySelector(".pagedjs_area"),l=r.footnotesArea,c=l.querySelector(".pagedjs_footnote_content"),d=l.querySelector(".pagedjs_footnote_inner_content"),h=c.getBoundingClientRect(),{width:k}=h;d.style.columnWidth=Math.round(k)+"px",d.style.columnGap="calc(var(--pagedjs-margin-right) + var(--pagedjs-margin-left))";let p=new $s(l,void 0,n.settings).findOverflow(d,h);if(p){let{startContainer:g,startOffset:v}=p,q;if(ft(g)){let G=g.childNodes[v];q=ft(G)&&G.hasAttribute("data-footnote-marker")}let L=p.extractContents();if(!q){let G=L.firstElementChild;G.dataset.splitFrom=G.dataset.ref,this.handleAlignment(d.lastElementChild)}this.needsLayout.push(L),c.style.removeProperty("height"),d.style.removeProperty("height");let O=d.getBoundingClientRect(),{height:M}=O,H=this.marginsHeight(c),F=this.paddingHeight(c),U=this.borderHeight(c);if(i.style.setProperty("--pagedjs-footnotes-height",`${M+H+U+F}px`),d.childNodes.length===0&&c.classList.add("pagedjs_footnote_empty"),!a)n.clonePage(r);else{let G,Y;a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.previousBreakAfter<"u"&&(Y=a.node.dataset.previousBreakAfter),a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.breakBefore<"u"&&(G=a.node.dataset.breakBefore),(G||Y)&&n.clonePage(r)}}d.style.height="auto"}handleAlignment(t){let a=window.getComputedStyle(t)["text-align-last"];t.dataset.lastSplitElement="true",a==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=a}beforePageLayout(t){for(;this.needsLayout.length;){let r=this.needsLayout.shift();Array.from(r.childNodes).forEach(a=>{this.moveFootnote(a,t.element.querySelector(".pagedjs_area"),!1)})}}afterOverflowRemoved(t,r){let a=r.closest(".pagedjs_area"),n=a.querySelectorAll(".pagedjs_footnote_area [data-note='footnote']");for(let l=0;l<n.length;l++){let c=n[l];t.querySelector(`[data-footnote-call="${c.dataset.ref}"]`)&&c.remove()}let i=a.querySelector(".pagedjs_footnote_inner_content");i&&i.childNodes.length===0&&i.parentElement.classList.add("pagedjs_footnote_empty")}marginsHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.marginTop),i=parseInt(a.marginBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}paddingHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.paddingTop),i=parseInt(a.paddingBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}borderHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.borderTop),i=parseInt(a.borderBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}},g3=Nd;var y3=[s3,a3,n3,o3,l3,c3,d3,f3,h3,m3,g3];b();b();var ki=He(bt(),1),Fd=class extends xe{constructor(t,r,a){super(t,r,a),this.runningSelectors={},this.elements={}}onDeclaration(t,r,a,n){if(t.property==="position"){let i=ki.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;if(l==="running"){let c;ki.default.walk(t,{visit:"Function",enter:(d,h,k)=>{c=d.children.first().name}}),this.runningSelectors[c]={identifier:l,value:c,selector:i}}}t.property==="content"&&ki.default.walk(t,{visit:"Function",enter:(i,l,c)=>{if(i.name.indexOf("element")>-1){let d=ki.default.generate(n.ruleNode.prelude),h=i.name,k=i.children.first().name,x=[k],p="first";d.split(",").forEach(g=>{g=g.replace(/::after|::before/,""),this.elements[g]={func:h,args:x,value:k,style:p||"first",selector:g,fullSelector:d}})}}})}afterParsed(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=Array.from(t.querySelectorAll(a.selector));if(a.identifier==="running")for(let i of n)i.style.display="none"}}afterPageLayout(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=t.querySelector(a.selector);n&&(a.identifier==="running"?a.first=n:console.warn(a.value+"needs css replacement"))}this.orderedSelectors||(this.orderedSelectors=this.orderSelectors(this.elements));for(let r of this.orderedSelectors)if(r){let a=this.elements[r],n=t.querySelector(r);if(n){let i=this.runningSelectors[a.args[0]];if(i&&i.first){n.innerHTML="";let l=i.first.cloneNode(!0);l.style.display=null,n.appendChild(l)}}}}pageWeight(t){let r=1,a=t.split(" "),n=a.length&&a[0].split(".");switch(n.shift(),n.length){case 4:/^pagedjs_[\w-]+_first_page$/.test(n[3])?r=7:(n[3]==="pagedjs_left_page"||n[3]==="pagedjs_right_page")&&(r=6);break;case 3:n[1]==="pagedjs_named_page"&&(n[2].indexOf(":nth-of-type")>-1?r=7:r=5);break;case 2:n[1]==="pagedjs_first_page"?r=4:n[1]==="pagedjs_blank_page"?r=3:(n[1]==="pagedjs_left_page"||n[1]==="pagedjs_right_page")&&(r=2);break;default:n[0].indexOf(":nth-of-type")>-1?r=4:r=1}return r}orderSelectors(t){let r=Object.keys(t),a={1:[],2:[],3:[],4:[],5:[],6:[],7:[]},n=[];for(let l of r){let c=this.pageWeight(l);a[c].unshift(l)}for(var i=1;i<=7;i++)n=n.concat(a[i]);return n}beforeTreeParse(t,r){r.text=t.replace(/element[\s]*\(([^|^#)]*)\)/g,"element-ident($1)")}},b3=Fd;b();var Wd=He(bt(),1);b();function ua(e,t=`"' `){if(e!=null)return e.replace(new RegExp(`^[${t}]+`),"").replace(new RegExp(`[${t}]+$`),"").replace(/["']/g,r=>"\\"+r).replace(/[\n]/g,r=>"\\00000A")}function k3(e){if(e!=null)return e.replace(new RegExp("::footnote-call","g"),"").replace(new RegExp("::footnote-marker","g"),"")}var Hd=class extends xe{constructor(t,r,a){super(t,r,a),this.stringSetSelectors={},this.type,this.pageLastString}onDeclaration(t,r,a,n){if(t.property==="string-set"){let i=Wd.default.generate(n.ruleNode.prelude),l=[],c=[],d=[];t.value.children.forEach(h=>{h.type==="Identifier"&&l.push(h.name),h.type==="Function"&&(c.push(h.name),h.children.forEach(k=>{k.type==="Identifier"&&d.push(k.name)}))}),l.forEach((h,k)=>{let x=c[k],p=d[k];this.stringSetSelectors[h]={identifier:h,func:x,value:p,selector:i}})}}onContent(t,r,a,n,i){if(t.name==="string"){let l=t.children&&t.children.first().name;this.type=t.children.last().name,t.name="var",t.children=new Wd.default.List,this.type==="first"||this.type==="last"||this.type==="start"||this.type==="first-except"?t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-"+this.type+"-"+l})):t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-first-"+l}))}}afterPageLayout(t){this.pageLastString===void 0&&(this.pageLastString={});for(let r of Object.keys(this.stringSetSelectors)){let a=this.stringSetSelectors[r],n=a.value,i=a.func,l=t.querySelectorAll(a.selector),c=r in this.pageLastString?this.pageLastString[r]:"",d,h,k,x;if(l.length==0)d=c,h=c,k=c,x=c;else{l.forEach(q=>{i==="content"&&(this.pageLastString[r]=l[l.length-1].textContent),i==="attr"&&(this.pageLastString[r]=l[l.length-1].getAttribute(n)||"")}),i==="content"&&(d=l[0].textContent),i==="attr"&&(d=l[0].getAttribute(n)||""),i==="content"&&(h=l[l.length-1].textContent),i==="attr"&&(h=l[l.length-1].getAttribute(n)||"");let p=l[0].getBoundingClientRect().top,v=l[0].closest(".pagedjs_page_content").getBoundingClientRect().top;p==v?k=d:k=c,x=""}t.style.setProperty(`--pagedjs-string-first-${r}`,`"${ua(d)}`),t.style.setProperty(`--pagedjs-string-last-${r}`,`"${ua(h)}`),t.style.setProperty(`--pagedjs-string-start-${r}`,`"${ua(k)}`),t.style.setProperty(`--pagedjs-string-first-except-${r}`,`"${ua(x)}`)}}},_3=Hd;b();var _i=He(bt(),1),$d=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counterTargets={}}onContent(t,r,a,n,i){if(t.name==="target-counter"){let l=_i.default.generate(i.ruleNode.prelude),c=t.children.first(),d=c.name,h=_i.default.generate(t),k=[];c.children.forEach(q=>{q.type==="Identifier"&&k.push(q.name)});let x,p,g;t.children.forEach(q=>{q.type==="Identifier"&&(x?p||(g=_i.default.clone(q),p=q.name):x=q.name)});let v="target-counter-"+xt();l.split(",").forEach(q=>{this.counterTargets[q]={func:d,args:k,value:h,counter:x,style:p,selector:q,fullSelector:l,variable:v}}),t.name="counter",t.children=new _i.default.List,t.children.appendData({type:"Identifier",loc:0,name:v}),g&&(t.children.appendData({type:"Operator",loc:null,value:","}),t.children.appendData(g))}}afterPageLayout(t,r,a,n){Object.keys(this.counterTargets).forEach(i=>{let l=this.counterTargets[i],c=l.selector.split(/::?/g),d=c[0];n.pagesArea.querySelectorAll(d+":not([data-"+l.variable+"])").forEach((k,x)=>{if(l.func!=="attr")return;let p=zs(k,l.args),g=n.pagesArea.querySelector(Cs(p));if(g){let v=xt();k.setAttribute("data-"+l.variable,v);let q="";if(c.length>1&&(q+="::"+c[1]),l.counter==="page"){let O=n.pagesArea.querySelectorAll(".pagedjs_page"),M=0;for(let H=0;H<O.length;H++){let F=O[H],U=window.getComputedStyle(F),G=U["counter-reset"].replace("page","").trim(),Y=U["counter-increment"].replace("page","").trim();if(G!=="none"&&(M=parseInt(G)),Y!=="none"&&(M+=parseInt(Y)),F.contains(g))break}this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${M}; }`,this.styleSheet.cssRules.length)}else{let O=g.getAttribute(`data-counter-${l.counter}-value`);O&&this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${l.variable} ${parseInt(O)}; }`,this.styleSheet.cssRules.length)}let L=document.querySelector(`[data-${l.variable}="${v}"]`);L&&(L.style.display="none",L.clientHeight,L.style.removeProperty("display"))}})})}},w3=$d;b();var Ro=He(bt(),1),Gd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.textTargets={},this.beforeContent="",this.afterContent="",this.selector={}}onContent(t,r,a,n,i){if(t.name==="target-text"){this.selector=Ro.default.generate(i.ruleNode.prelude);let l=t.children.first(),c=t.children.last(),d=l.name,h=Ro.default.generate(t),k=[];l.children.forEach(g=>{g.type==="Identifier"&&k.push(g.name)});let x;c!==l&&(x=c.name);let p="--pagedjs-"+xt();this.selector.split(",").forEach(g=>{this.textTargets[g]={func:d,args:k,value:h,style:x||"content",selector:g,fullSelector:this.selector,variable:p}}),t.name="var",t.children=new Ro.default.List,t.children.appendData({type:"Identifier",loc:0,name:p})}}onPseudoSelector(t,r,a,n,i){i.ruleNode.block.children.forEach(l=>{t.name==="before"&&l.property==="content"?l.value.children.forEach(d=>{d.type==="String"&&(this.beforeContent=d.value)}):t.name==="after"&&l.property==="content"&&l.value.children.forEach(c=>{c.type==="String"&&(this.afterContent=c.value)})})}afterParsed(t){Object.keys(this.textTargets).forEach(r=>{let a=this.textTargets[r],n=a.selector.split("::"),i=n[0],l=t.querySelectorAll(i),c;l.forEach((d,h)=>{let k=zs(d,a.args),x=t.querySelector(Cs(k));if(x)if(a.style){this.selector=xt(),d.setAttribute("data-target-text",this.selector);let p="";if(n.length>1&&(p+="::"+n[1]),a.style==="before"||a.style==="after"){let g=`${a.style}Content`;c=ua(this[g])}else c=ua(x.textContent," ");c=a.style==="first-letter"?c.charAt(0):c,this.styleSheet.insertRule(`[data-target-text="${this.selector}"]${p} { ${a.variable}: "${c}" }`)}else console.warn("missed target",k)})})}},v3=Gd;var x3=[b3,_3,w3,v3];b();b();var Ud=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,r=>this.filterEmpty(r),NodeFilter.SHOW_TEXT)}filterEmpty(t){if(t.textContent.length>1&&Un(t)){let r=t.parentNode;if(ft(r)&&r.closest("pre"))return NodeFilter.FILTER_REJECT;let n=Ts(t),i=Es(t);return i===null&&n===null?(t.textContent=" ",NodeFilter.FILTER_REJECT):i===null||n===null?NodeFilter.FILTER_ACCEPT:(t.textContent=" ",NodeFilter.FILTER_REJECT)}else return NodeFilter.FILTER_REJECT}},S3=Ud;b();var Vd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,null,NodeFilter.SHOW_COMMENT)}},z3=Vd;b();var Yd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){t.querySelectorAll("script").forEach(r=>{r.remove()})}},C3=Yd;b();var q3=He(bt(),1),O3=He(E3(),1);var Kd=class extends xe{constructor(t,r,a){super(t,r,a),this.displayRules={}}onDeclaration(t,r,a,n){if(t.property==="display"){let i=q3.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;i.split(",").forEach(c=>{this.displayRules[c]={value:l,selector:c,specificity:(0,O3.calculateSpecificity)(c),important:t.important}})}}filter(t){let{matches:r,selectors:a}=this.sortDisplayedSelectors(t,this.displayRules);for(let i=0;i<r.length;i++){let l=r[i],c=a[i],d=c[c.length-1].value;this.removable(l)&&d==="none"&&(l.dataset.undisplayed="undisplayed")}let n=t.querySelectorAll("[style]");for(let i=0;i<n.length;i++){let l=n[i];this.removable(l)&&(l.dataset.undisplayed="undisplayed")}}sorter(t,r){return t.important&&!r.important?1:r.important&&!t.important?-1:t.specificity-r.specificity}sortDisplayedSelectors(t,r=[]){let a=[],n=[];for(let i in r){let l=r[i],c=l.selector,d=[];try{try{d=t.querySelectorAll(c)}catch{d=t.querySelectorAll(k3(c))}}catch{d=[]}let h=Array.from(d);for(let k of h)if(a.includes(k)){let x=a.indexOf(k);n[x].push(l),n[x]=n[x].sort(this.sorter)}else a.push(k),n.push([l])}return{matches:a,selectors:n}}removable(t){return!(t.style&&t.style.display!==""&&t.style.display!=="none")}},D3=Kd;var M3=[S3,z3,C3,D3];var e6=He(aa(),1),t6=He(Jw(),1),n0=[...y3,...x3,...M3],Wo=class{constructor(t,r,a){let n=[];n0.forEach(i=>{let l=new i(t,r,a);n.push(l),(0,t6.default)(l,this)})}};(0,e6.default)(Wo.prototype);function Ho(){for(var e=0;e<arguments.length;e++)n0.push(arguments[e])}function i0(e,t,r){return new Wo(e,t,r)}var $o=class{constructor(t){this.settings=t||{},this.polisher=new zd(!1),this.chunker=new eu(void 0,void 0,this.settings),this.hooks={},this.hooks.beforePreview=new ue(this),this.hooks.afterPreview=new ue(this),this.size={width:{value:8.5,unit:"in"},height:{value:11,unit:"in"},format:void 0,orientation:void 0},this.chunker.on("page",r=>{this.emit("page",r)}),this.chunker.on("rendering",()=>{this.emit("rendering",this.chunker)})}initializeHandlers(){let t=i0(this.chunker,this.polisher,this);return t.on("size",r=>{this.size=r,this.emit("size",r)}),t.on("atpages",r=>{this.atpages=r,this.emit("atpages",r)}),t}registerHandlers(){return Ho.apply(Ho,arguments)}getParams(t){let r,a=new URL(window.location),n=new URLSearchParams(a.search);for(var i of n.entries())i[0]===t&&(r=i[1]);return r}wrapContent(){let t=document.querySelector("body"),r;return r=t.querySelector(":scope > template[data-ref='pagedjs-content']"),r||(r=document.createElement("template"),r.dataset.ref="pagedjs-content",r.innerHTML=t.innerHTML,t.innerHTML="",t.appendChild(r)),r.content}removeStyles(t=document){let r=Array.from(t.querySelectorAll("link[rel='stylesheet']:not([data-pagedjs-ignore], [media~='screen'])")),a=Array.from(t.querySelectorAll("style:not([data-pagedjs-inserted-styles], [data-pagedjs-ignore], [media~='screen'])"));return[...r,...a].sort(function(i,l){let c=i.compareDocumentPosition(l);return c===Node.DOCUMENT_POSITION_PRECEDING?1:c===Node.DOCUMENT_POSITION_FOLLOWING?-1:0}).map(i=>{if(i.nodeName==="STYLE"){let l={};return l[window.location.href]=i.textContent,i.remove(),l}if(i.nodeName==="LINK")return i.remove(),i.href;console.warn(`Unable to process: ${i}, ignoring.`)})}async preview(t,r,a){await this.hooks.beforePreview.trigger(t,a),t||(t=this.wrapContent()),r||(r=this.removeStyles()),this.polisher.setup(),this.handlers=this.initializeHandlers(),await this.polisher.add(...r);let n=performance.now(),i=await this.chunker.flow(t,a),l=performance.now();return i.performance=l-n,i.size=this.size,this.emit("rendered",i),await this.hooks.afterPreview.trigger(i.pages),i}};(0,r6.default)($o.prototype);var s0=$o;async function a6(e,t,r){r.innerHTML="",document.querySelectorAll("style[data-pagedjs-inserted-styles]").forEach(n=>n.remove()),await new s0().preview(e,t,r)}function n6(){window.print()}b();var i6={none:{body:"system-serif",heading:"system-serif"},"light-neat-1":{body:"inter",heading:"inter"},"light-neat-2":{body:"ibm-plex-sans",heading:"ibm-plex-sans"},"light-neat-3":{body:"raleway",heading:"raleway"},"light-academic-1":{body:"source-serif-4",heading:"source-serif-4"},"light-academic-2":{body:"crimson-pro",heading:"inter"},"beige-decent-1":{body:"lora",heading:"lora"},"beige-decent-2":{body:"noto-serif",heading:"noto-serif"}};b();function s6(e){return e.trim().toLowerCase().replace(/-/g,"_")}function o0(e){let t=e.indexOf("=");return t<0?{key:s6(e),value:""}:{key:s6(e.slice(0,t)),value:e.slice(t+1).trim()}}function o6(e,t){Array.prototype.forEach.call(e.querySelectorAll("[data-show-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-show-when")||"");t[a]===n?r.removeAttribute("data-show-when"):r.remove()}),Array.prototype.forEach.call(e.querySelectorAll("[data-hide-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-hide-when")||"");t[a]===n?r.remove():r.removeAttribute("data-hide-when")})}function l6(e){let t={};for(let a of["data-show-when","data-hide-when"])Array.prototype.forEach.call(e.querySelectorAll("["+a+"]"),n=>{let{key:i,value:l}=o0(n.getAttribute(a)||"");(t[i]=t[i]||new Set).add(l)});let r={};for(let a of Object.keys(t))r[a]=Array.from(t[a]).sort();return r}var xM="0.2.0";function kn(){return window.__ORZ_PAGED__||{}}function Uo(){let e=document.getElementById("orz-src");return(e&&e.textContent||"").replace(/^\n/,"").replace(/\n\s*$/,"")}function u6(){let e=document.getElementById("orz-pages");return e||(e=document.createElement("div"),e.id="orz-pages",e.setAttribute("data-orz-copy",""),document.body.appendChild(e)),e}function Go(e){return new Promise((t,r)=>{if(!e||document.querySelector(`script[data-lib="${e}"]`))return t();let a=document.createElement("script");a.src=e,a.async=!0,a.setAttribute("data-lib",e),a.setAttribute("data-orz-runtime","1"),a.onload=()=>t(),a.onerror=()=>r(new Error("failed to load "+e)),document.head.appendChild(a)})}function Si(e,t){if(!e||t&&document.getElementById(t)||!t&&document.querySelector(`link[href="${e}"]`))return;let r=document.createElement("link");r.rel="stylesheet",r.href=e,t&&(r.id=t),r.setAttribute("data-orz-runtime","1"),document.head.appendChild(r)}function SM(e){try{let t=document.createElement("img");t.src=e.toDataURL("image/png"),t.className=e.className,t.style.maxWidth="100%";let r=e.getAttribute("data-md");r!=null&&t.setAttribute("data-md",r),e.replaceWith(t)}catch{}}async function zM(e){let t=kn().enhancers||{},r=window,a=[];t.hljsJs&&e.querySelector("pre code")&&(await Go(t.hljsJs),r.hljs&&e.querySelectorAll("pre code:not(.hljs)").forEach(n=>{try{r.hljs.highlightElement(n)}catch{}})),t.mermaidJs&&e.querySelector(".mermaid")&&(await Go(t.mermaidJs),r.mermaid&&(r.mermaid.initialize({startOnLoad:!1}),a.push(Promise.resolve(r.mermaid.run({nodes:e.querySelectorAll(".mermaid")})).catch(()=>{})))),t.smilesJs&&e.querySelector("canvas[data-smiles]")&&(await Go(t.smilesJs),r.SmilesDrawer&&e.querySelectorAll("canvas[data-smiles]").forEach(n=>{let i=new r.SmilesDrawer.Drawer({width:n.width,height:n.height});a.push(new Promise(l=>{r.SmilesDrawer.parse(n.getAttribute("data-smiles"),c=>{try{i.draw(c,n,"light",!1)}catch{}l()},()=>l())}))})),t.chartJs&&e.querySelector("canvas.orz-chart[data-chart]")&&(await Go(t.chartJs),r.Chart&&e.querySelectorAll("canvas.orz-chart[data-chart]").forEach(n=>{try{let i=JSON.parse(n.getAttribute("data-chart")||"{}");i.options={...i.options||{},responsive:!1,animation:!1},new r.Chart(n,i)}catch{}})),await Promise.all(a),e.querySelectorAll("canvas").forEach(n=>SM(n))}var Vo=null,Zo=null,l0={},d6={};function CM(e){let t=kn(),r=Zo||e.theme,a=[];return t.mode==="cdn"?(t.baseUrl&&a.push(t.baseUrl),r!=="none"&&t.themeUrls&&t.themeUrls[r]&&a.push(t.themeUrls[r])):(t.baseCss&&a.push({"orz-base.css":t.baseCss}),r!=="none"&&t.themes&&t.themes[r]&&a.push({"orz-theme.css":t.themes[r]})),a.push({"orz-page.css":e.css}),a}async function Yo(e){let t=Mc(e);Vo=t;let r=Zo||t.theme,a=i6[r];a&&(Si(Or(a.body).cssUrl),Si(Or(a.heading).cssUrl)),t.fontCssUrls.forEach(l=>Si(l)),kn().katexCss&&Si(kn().katexCss,"orz-katex"),kn().hljsCss&&Si(kn().hljsCss,"orz-hljs");let n=document.createElement("div");n.className="orz-stage",n.style.cssText="position:absolute;left:-99999px;top:0;width:680px;",n.innerHTML=t.bodyHtml,document.body.appendChild(n),d6=l6(n),l0={...t.settings.dynamicChoices},o6(n,l0);let i=document.createElement("div");i.style.cssText="position:absolute;left:-99999px;top:0;width:900px;",document.body.appendChild(i);try{if(await zM(n.querySelector(".orz-doc")||n),document.fonts&&document.fonts.ready)try{await document.fonts.ready}catch{}await a6(n.innerHTML,CM(t),i);let l=u6(),c=l.scrollTop;if(l.replaceChildren(...Array.prototype.slice.call(i.childNodes)),l.scrollTop=c,t.settings.frontMatterClean){let k=Array.prototype.slice.call(l.querySelectorAll(".pagedjs_page")).filter(x=>!x.classList.contains("pagedjs_orz-front_page"));document.documentElement.style.setProperty("--orz-body-pages",`"${k.length}"`),k.forEach((x,p)=>x.style.setProperty("--orz-pageno",`"${p+1}"`))}AM();let d=window.__orzPagedAfterRender;if(d)try{d()}catch{}}finally{n.remove(),i.remove()}}function AM(){let e=u6(),t=e.querySelector(".orz-toc");if(!t)return;let r=Number(t.getAttribute("data-max-level")||"3"),a=[];e.querySelectorAll(".pagedjs_page h1, .pagedjs_page h2, .pagedjs_page h3, .pagedjs_page h4").forEach(n=>{let i=Number(n.tagName.slice(1));if(i>r)return;let l=n.closest(".pagedjs_page"),c=l&&l.getAttribute("data-page-number")||"";a.push(`<li class="orz-toc-item orz-toc-l${i}"><span class="orz-toc-text">${n.textContent||""}</span><span class="orz-toc-page">${c}</span></li>`)}),a.length&&(t.innerHTML=`<ol class="orz-toc-list">${a.join("")}</ol>`)}var TM={version:xM,assemble:Mc,render:e=>Yo(e),refresh:()=>Yo(Uo()),exportPdf:()=>n6(),setTheme:e=>(Zo=e&&e!=="none"?e:null,Yo(Uo())),getTheme:()=>Zo||(Vo?Vo.theme:null),getDynamicState:()=>({options:d6,choices:l0}),get assembly(){return Vo},source:Uo};window.orzpaged=TM;function c6(){Yo(Uo()).catch(e=>console.error("[orz-paged]",e))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",c6):c6();})();
|
|
1524
|
+
`;b();async function Lo(e,t={}){return new Promise(function(r,a){let n=new XMLHttpRequest;n.open(t.method||"get",e,!0);for(let i in t.headers)n.setRequestHeader(i,t.headers[i]);n.withCredentials=t.credentials==="include",n.onload=()=>{let i=n.status===0&&e.startsWith("file://")?200:n.status;r(new Response(n.responseText,{status:i}))},n.onerror=a,n.send(t.body||null)})}var Sd=class{constructor(t){this.sheets=[],this.inserted=[],this.hooks={},this.hooks.onUrl=new ue(this),this.hooks.onAtPage=new ue(this),this.hooks.onAtMedia=new ue(this),this.hooks.onRule=new ue(this),this.hooks.onDeclaration=new ue(this),this.hooks.onContent=new ue(this),this.hooks.onSelector=new ue(this),this.hooks.onPseudoSelector=new ue(this),this.hooks.onImport=new ue(this),this.hooks.beforeTreeParse=new ue(this),this.hooks.beforeTreeWalk=new ue(this),this.hooks.afterTreeWalk=new ue(this),t!==!1&&this.setup()}setup(){return this.base=this.insert(t3),this.styleEl=document.createElement("style"),document.head.appendChild(this.styleEl),this.styleSheet=this.styleEl.sheet,this.styleSheet}async add(){let t=[],r=[];for(var a=0;a<arguments.length;a++){let n;if(typeof arguments[a]=="object")for(let i in arguments[a]){let l=arguments[a];n=new Promise(function(c,d){r.push(i),c(l[i])})}else r.push(arguments[a]),n=Lo(arguments[a]).then(i=>i.text());t.push(n)}return await Promise.all(t).then(async n=>{let i="";for(let l=0;l<n.length;l++)i=await this.convertViaSheet(n[l],r[l]),this.insert(i);return i})}async convertViaSheet(t,r){let a=new e3(r,this.hooks);await a.parse(t);for(let n of a.imported){let i=await Lo(n).then(c=>c.text()),l=await this.convertViaSheet(i,n);this.insert(l)}return this.sheets.push(a),typeof a.width<"u"&&(this.width=a.width),typeof a.height<"u"&&(this.height=a.height),typeof a.orientation<"u"&&(this.orientation=a.orientation),a.toString()}insert(t){let r=document.querySelector("head"),a=document.createElement("style");return a.setAttribute("data-pagedjs-inserted-styles","true"),a.appendChild(document.createTextNode(t)),r.appendChild(a),this.inserted.push(a),a}destroy(){this.styleEl.remove(),this.inserted.forEach(t=>{t.remove()}),this.sheets=[]}},zd=Sd;b();var r6=He(aa(),1);b();b();b();b();var r3=He(aa(),1),Po=class{constructor(t,r,a){let n=Object.assign({},t&&t.hooks,r&&r.hooks,a&&a.hooks);this.chunker=t,this.polisher=r,this.caller=a;for(let i in n)i in this&&n[i].register(this[i].bind(this))}};(0,r3.default)(Po.prototype);var xe=Po;var ce=He(bt(),1);b();var Cd={A0:{width:{value:841,unit:"mm"},height:{value:1189,unit:"mm"}},A1:{width:{value:594,unit:"mm"},height:{value:841,unit:"mm"}},A2:{width:{value:420,unit:"mm"},height:{value:594,unit:"mm"}},A3:{width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},A4:{width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A5:{width:{value:148,unit:"mm"},height:{value:210,unit:"mm"}},A6:{width:{value:105,unit:"mm"},height:{value:148,unit:"mm"}},A7:{width:{value:74,unit:"mm"},height:{value:105,unit:"mm"}},A8:{width:{value:52,unit:"mm"},height:{value:74,unit:"mm"}},A9:{width:{value:37,unit:"mm"},height:{value:52,unit:"mm"}},A10:{width:{value:26,unit:"mm"},height:{value:37,unit:"mm"}},B4:{width:{value:250,unit:"mm"},height:{value:353,unit:"mm"}},B5:{width:{value:176,unit:"mm"},height:{value:250,unit:"mm"}},letter:{width:{value:8.5,unit:"in"},height:{value:11,unit:"in"}},legal:{width:{value:8.5,unit:"in"},height:{value:14,unit:"in"}},ledger:{width:{value:11,unit:"in"},height:{value:17,unit:"in"}}};var Ad=class extends xe{constructor(t,r,a){super(t,r,a),this.pages={},this.width=void 0,this.height=void 0,this.orientation=void 0,this.marginalia={}}pageModel(t){return{selector:t,name:void 0,psuedo:void 0,nth:void 0,marginalia:{},width:void 0,height:void 0,orientation:void 0,margin:{top:{},right:{},left:{},bottom:{}},padding:{top:{},right:{},left:{},bottom:{}},border:{top:{},right:{},left:{},bottom:{}},backgroundOrigin:void 0,block:{},marks:void 0,notes:void 0,added:!1}}onAtPage(t,r,a){let n,i,l="",c,d,h,k=!1;t.prelude?(c=this.getTypeSelector(t),d=this.getPsuedoSelector(t),h=this.getNthSelector(t),l=ce.default.generate(t.prelude)):l="*",l in this.pages?(n=this.pages[l],i=this.replaceMarginalia(t),k=!0,n.added=!1):(n=this.pageModel(l),i=this.replaceMarginalia(t),this.pages[l]=n),n.name=c,n.psuedo=d,n.nth=h,k?n.marginalia=Object.assign(n.marginalia,i):n.marginalia=i;let x=this.replaceNotes(t);n.notes=x;let p=this.replaceDeclarations(t);if(p.size&&(n.size=p.size,n.width=p.size.width,n.height=p.size.height,n.orientation=p.size.orientation,n.format=p.size.format),p.bleed&&p.bleed[0]!="auto")switch(p.bleed.length){case 4:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[3]};break;case 3:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[1]};break;case 2:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[0],left:p.bleed[1]};break;default:n.bleed={top:p.bleed[0],right:p.bleed[0],bottom:p.bleed[0],left:p.bleed[0]}}p.marks&&((!p.bleed||p.bleed&&p.bleed[0]==="auto")&&(n.bleed={top:{value:6,unit:"mm"},right:{value:6,unit:"mm"},bottom:{value:6,unit:"mm"},left:{value:6,unit:"mm"}}),n.marks=p.marks),p.margin&&(n.margin=p.margin),p.padding&&(n.padding=p.padding),p.border&&(n.border=p.border),p.marks&&(n.marks=p.marks),k?n.block.children.appendList(t.block.children):n.block=t.block,a.remove(r)}afterTreeWalk(t,r){let a="*"in this.pages&&this.pages["*"].added===!1;if(this.addPageClasses(this.pages,t,r),a){let n=this.pages["*"].width,i=this.pages["*"].height,l=this.pages["*"].format,c=this.pages["*"].orientation,d=this.pages["*"].bleed,h=this.pages["*"].marks,k,x;":left"in this.pages&&(k=this.pages[":left"].bleed),":right"in this.pages&&(x=this.pages[":right"].bleed),n&&i&&(this.width!==n||this.height!==i)&&(this.width=n,this.height=i,this.format=l,this.orientation=c,this.addRootVars(t,n,i,c,d,x,k,h),this.addRootPage(t,this.pages["*"].size,d,x,k),this.emit("size",{width:n,height:i,orientation:c,format:l,bleed:d}),this.emit("atpages",this.pages))}}getTypeSelector(t){let r;return ce.default.walk(t,{visit:"TypeSelector",enter:(a,n,i)=>{r=a.name}}),r}getPsuedoSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name!=="nth"&&(r=a.name)}}),r}getNthSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name==="nth"&&a.children&&(r=a.children.first().value)}}),r}replaceMarginalia(t){let r={},a=["top-left-corner","top-left","top","top-center","top-right","top-right-corner","bottom-left-corner","bottom-left","bottom","bottom-center","bottom-right","bottom-right-corner","left-top","left-middle","left","left-bottom","top-right-corner","right-top","right-middle","right","right-bottom","right-right-corner"];return ce.default.walk(t.block,{visit:"Atrule",enter:(n,i,l)=>{let c=n.name;a.includes(c)&&(c==="top"&&(c="top-center"),c==="right"&&(c="right-middle"),c==="left"&&(c="left-middle"),c==="bottom"&&(c="bottom-center"),r[c]=n.block,l.remove(i))}}),r}replaceNotes(t){let r={};return ce.default.walk(t.block,{visit:"Atrule",enter:(a,n,i)=>{let l=a.name;l==="footnote"&&(r[l]=a.block,i.remove(n))}}),r}replaceDeclarations(t){let r={};return ce.default.walk(t.block,{visit:"Declaration",enter:(a,n,i)=>{let l=ce.default.property(a.property).name;if(l==="marks")r.marks=[],ce.default.walk(a,{visit:"Identifier",enter:c=>{r.marks.push(c.name)}}),i.remove(n);else if(l==="margin")r.margin=this.getMargins(a),i.remove(n);else if(l.indexOf("margin-")===0){let c=l.substring(7);r.margin||(r.margin={top:{},right:{},left:{},bottom:{}}),r.margin[c]=a.value.children.first(),i.remove(n)}else if(l==="padding")r.padding=this.getPaddings(a.value),i.remove(n);else if(l.indexOf("padding-")===0){let c=l.substring(8);r.padding||(r.padding={top:{},right:{},left:{},bottom:{}}),r.padding[c]=a.value.children.first(),i.remove(n)}else if(l==="border")r.border||(r.border={top:{},right:{},left:{},bottom:{}}),r.border.top=ce.default.generate(a.value),r.border.right=ce.default.generate(a.value),r.border.left=ce.default.generate(a.value),r.border.bottom=ce.default.generate(a.value),i.remove(n);else if(l.indexOf("border-")===0){r.border||(r.border={top:{},right:{},left:{},bottom:{}});let c=l.substring(7);r.border[c]=ce.default.generate(a.value),i.remove(n)}else l==="size"?(r.size=this.getSize(a),i.remove(n)):l==="bleed"&&(r.bleed=[],ce.default.walk(a,{enter:c=>{switch(c.type){case"String":c.value.indexOf("auto")>-1&&r.bleed.push("auto");break;case"Dimension":r.bleed.push({value:c.value,unit:c.unit});break;case"Number":r.bleed.push({value:c.value,unit:"px"});break;default:}}}),i.remove(n))}}),r}getSize(t){let r,a,n,i;return ce.default.walk(t,{visit:"Dimension",enter:(l,c,d)=>{let{value:h,unit:k}=l;typeof r>"u"?r={value:h,unit:k}:typeof a>"u"&&(a={value:h,unit:k})}}),ce.default.walk(t,{visit:"String",enter:(l,c,d)=>{let h=l.value.replace(/["|']/g,""),k=Cd[h];k&&(r=k.width,a=k.height)}}),ce.default.walk(t,{visit:"Identifier",enter:(l,c,d)=>{let h=l.name;if(h==="landscape"||h==="portrait")n=l.name;else if(h!=="auto"){let k=Cd[h];k&&(r=k.width,a=k.height),i=h}}}),{width:r,height:a,orientation:n,format:i}}getMargins(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getPaddings(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getBorders(t){let r={top:{},right:{},left:{},bottom:{}};return t.prop=="border"?(r.top=ce.default.generate(t.value),r.right=ce.default.generate(t.value),r.bottom=ce.default.generate(t.value),r.left=ce.default.generate(t.value)):t.prop=="border-top"?r.top=ce.default.generate(t.value):t.prop=="border-right"?r.right=ce.default.generate(t.value):t.prop=="border-bottom"?r.bottom=ce.default.generate(t.value):t.prop=="border-left"&&(r.left=ce.default.generate(t.value)),r}addPageClasses(t,r,a){if("*"in t&&t["*"].added===!1){let n=this.createPage(t["*"],r.children,a);a.insertRule(n),t["*"].added=!0}if(":left"in t&&t[":left"].added===!1){let n=this.createPage(t[":left"],r.children,a);a.insertRule(n),t[":left"].added=!0}if(":right"in t&&t[":right"].added===!1){let n=this.createPage(t[":right"],r.children,a);a.insertRule(n),t[":right"].added=!0}if(":first"in t&&t[":first"].added===!1){let n=this.createPage(t[":first"],r.children,a);a.insertRule(n),t[":first"].added=!0}if(":blank"in t&&t[":blank"].added===!1){let n=this.createPage(t[":blank"],r.children,a);a.insertRule(n),t[":blank"].added=!0}for(let n in t)if(t[n].nth&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}for(let n in t)if(t[n].name&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}}createPage(t,r,a){let n=this.selectorsForPage(t),i=t.block.children.copy(),l={type:"Block",loc:0,children:i},c=this.createRule(n,l);return this.addMarginVars(t.margin,i,i.first()),this.addPaddingVars(t.padding,i,i.first()),this.addBorderVars(t.border,i,i.first()),t.width&&this.addDimensions(t.width,t.height,t.orientation,i,i.first()),t.marginalia&&(this.addMarginaliaStyles(t,r,c,a),this.addMarginaliaContent(t,r,c,a)),t.notes&&this.addNotesStyles(t.notes,t,r,c,a),c}addMarginVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-margin-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addPaddingVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-padding-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addBorderVars(t,r,a){for(let n of Object.keys(t)){let i=t[n];if(typeof i=="string"){let l=r.createItem({type:"Declaration",property:"--pagedjs-border-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}}addDimensions(t,r,a,n,i){let l,c;l=le(t),c=le(r),a&&a!=="portrait"&&([l,c]=[c,l]);let d=this.createVariable("--pagedjs-pagebox-width",l);n.appendData(d);let h=this.createVariable("--pagedjs-pagebox-height",c);n.appendData(h)}addMarginaliaStyles(t,r,a,n){for(let i in t.marginalia){let l=ce.default.clone(t.marginalia[i]),c=!1;if(l.children.isEmpty())continue;ce.default.walk(l,{visit:"Declaration",enter:(x,p,g)=>{if(x.property==="content"&&(x.value.children&&x.value.children.first().name==="none"?c=!1:c=!0,g.remove(p)),x.property==="vertical-align"&&(ce.default.walk(x,{visit:"Identifier",enter:(v,q,L)=>{let O=v.name;O==="top"?v.name="flex-start":O==="middle"?v.name="center":O==="bottom"&&(v.name="flex-end")}}),x.property="align-items"),x.property==="width"&&(i==="top-left"||i==="top-center"||i==="top-right"||i==="bottom-left"||i==="bottom-center"||i==="bottom-right")){let v=ce.default.clone(x);v.property="max-width",g.appendData(v)}if(x.property==="height"&&(i==="left-top"||i==="left-middle"||i==="left-bottom"||i==="right-top"||i==="right-middle"||i==="right-bottom")){let v=ce.default.clone(x);v.property="max-height",g.appendData(v)}}});let d=this.selectorsForPageMargin(t,i),h=this.createRule(d,l);r.appendData(h);let k=ce.default.generate({type:"Selector",children:d});this.marginalia[k]={page:t,selector:k,block:t.marginalia[i],hasContent:c}}}addMarginaliaContent(t,r,a,n){let i;for(let l in t.marginalia){let c=ce.default.clone(t.marginalia[l]);if(ce.default.walk(c,{visit:"Declaration",enter:(g,v,q)=>{g.property!=="content"&&q.remove(v),g.value.children&&g.value.children.first().name==="none"&&(i=!0)}}),c.children.isEmpty())continue;let d=this.selectorsForPageMargin(t,l),h;d.insertData({type:"Combinator",name:">"}),d.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),d.insertData({type:"Combinator",name:">"}),d.insertData({type:"TypeSelector",name:"*"}),i?h=this.createDeclaration("display","none"):h=this.createDeclaration("display","block");let k=this.createRule(d,[h]);n.insertRule(k);let x=this.selectorsForPageMargin(t,l);x.insertData({type:"Combinator",name:">"}),x.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),x.insertData({type:"PseudoElementSelector",name:"after",children:null});let p=this.createRule(x,c);n.insertRule(p)}}addRootVars(t,r,a,n,i,l,c,d){let h=[],k=new ce.default.List;k.insertData({type:"PseudoClassSelector",name:"root",children:null});let x,p,g,v,q,L;if(!i)x=le(r),p=le(a),g=le(r),v=le(a),q=le(r),L=le(a);else{x=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,p=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,g=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,v=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,q=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,L=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`;let X=this.createVariable("--pagedjs-bleed-top",le(i.top)),ne=this.createVariable("--pagedjs-bleed-right",le(i.right)),ve=this.createVariable("--pagedjs-bleed-bottom",le(i.bottom)),be=this.createVariable("--pagedjs-bleed-left",le(i.left)),Le=this.createVariable("--pagedjs-bleed-right-top",le(i.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(i.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(i.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(i.left)),ie=this.createVariable("--pagedjs-bleed-left-top",le(i.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(i.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(i.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(i.left));l&&(Le=this.createVariable("--pagedjs-bleed-right-top",le(l.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(l.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(l.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(l.left)),g=`calc( ${le(r)} + ${le(l.left)} + ${le(l.right)} )`,v=`calc( ${le(a)} + ${le(l.top)} + ${le(l.bottom)} )`),c&&(ie=this.createVariable("--pagedjs-bleed-left-top",le(c.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(c.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(c.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(c.left)),q=`calc( ${le(r)} + ${le(c.left)} + ${le(c.right)} )`,L=`calc( ${le(a)} + ${le(c.top)} + ${le(c.bottom)} )`);let zi=this.createVariable("--pagedjs-width",le(r)),Nr=this.createVariable("--pagedjs-height",le(a));h.push(X,ne,ve,be,Le,Ne,Ae,Te,ie,Yt,da,pa,zi,Nr)}if(d&&d.forEach(X=>{let ne=this.createVariable("--pagedjs-mark-"+X+"-display","block");h.push(ne)}),n){let X=this.createVariable("--pagedjs-orientation",n);h.push(X),n!=="portrait"&&([x,p]=[p,x],[g,v]=[v,g],[q,L]=[L,q])}let O=this.createVariable("--pagedjs-width",x),M=this.createVariable("--pagedjs-height",p),H=this.createVariable("--pagedjs-width-right",g),F=this.createVariable("--pagedjs-height-right",v),U=this.createVariable("--pagedjs-width-left",q),G=this.createVariable("--pagedjs-height-left",L);h.push(O,M,H,F,U,G);let Y=this.createRule(k,h);t.children.appendData(Y)}addNotesStyles(t,r,a,n,i){for(let l in t){let c=this.selectorsForPage(r);c.insertData({type:"Combinator",name:" "}),c.insertData({type:"ClassSelector",name:"pagedjs_"+l+"_content"});let d=this.createRule(c,t[l]);a.appendData(d)}}addRootPage(t,r,a,n,i){let{width:l,height:c,orientation:d,format:h}=r,k=new ce.default.List,x=new ce.default.List,p=new ce.default.List,g=new ce.default.List,v=new ce.default.List,q=new ce.default.List;if(a){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.left.unit,value:a.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.right.unit,value:a.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.top.unit,value:a.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.bottom.unit,value:a.bottom.value}),g.appendData({type:"Function",name:"calc",children:O}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Function",name:"calc",children:M})}else h?(g.appendData({type:"Identifier",name:h}),d&&(g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Identifier",name:d}))):(g.appendData({type:"Dimension",unit:l.unit,value:l.value}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Dimension",unit:c.unit,value:c.value}));k.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:g}}),k.appendData({type:"Declaration",property:"margin",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}});let L=t.children.createItem({type:"Atrule",prelude:null,name:"page",block:{type:"Block",loc:null,children:k}});if(t.children.append(L),i){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.left.unit,value:i.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.right.unit,value:i.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.top.unit,value:i.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.bottom.unit,value:i.bottom.value}),v.appendData({type:"Function",name:"calc",children:O}),v.appendData({type:"WhiteSpace",value:" "}),v.appendData({type:"Function",name:"calc",children:M}),x.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:v}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :left",block:{type:"Block",loc:null,children:x}});t.children.append(H)}if(n){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.left.unit,value:n.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.right.unit,value:n.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.top.unit,value:n.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.bottom.unit,value:n.bottom.value}),q.appendData({type:"Function",name:"calc",children:O}),q.appendData({type:"WhiteSpace",value:" "}),q.appendData({type:"Function",name:"calc",children:M}),p.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:q}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :right",block:{type:"Block",loc:null,children:p}});t.children.append(H)}}getNth(t){let r=t.indexOf("n"),a=t.indexOf("+"),n=t.split("n"),i=t.split("+"),l=null,c=null;return r>-1?(l=n[0],a>-1&&(c=i[1])):c=t,{type:"Nth",loc:null,selector:null,nth:{type:"AnPlusB",loc:null,a:l,b:c}}}addPageAttributes(t,r,a){let n=[r.dataset.page];if(n&&n.length)for(let i of n)i&&(t.name=i,t.element.classList.add("pagedjs_named_page"),t.element.classList.add("pagedjs_"+i+"_page"),r.dataset.splitFrom||t.element.classList.add("pagedjs_"+i+"_first_page"))}getStartElement(t,r){let a=r&&r.node;if(!t&&!r)return;if(!a)return t.children[0];if(a.nodeType===1&&a.parentNode.nodeType===11||a.nodeType===1&&a.dataset.page)return a;let n=qs(a),i=n.querySelectorAll("[data-page]");return i.length?i[i.length-1]:n.children[0]}beforePageLayout(t,r,a,n){let i=this.getStartElement(r,a);i&&this.addPageAttributes(t,i,n.pages)}finalizePage(t,r,a,n){for(let i in this.marginalia){let l=this.marginalia[i],c=i.split(" "),d;r.element.matches(c[0])&&l.hasContent&&(d=r.element.querySelector(c[1]),d.classList.add("hasContent"))}["top","bottom"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i),c=r.element.querySelector(".pagedjs_margin-"+i+"-center"),d=r.element.querySelector(".pagedjs_margin-"+i+"-left"),h=r.element.querySelector(".pagedjs_margin-"+i+"-right"),k=c.classList.contains("hasContent"),x=d.classList.contains("hasContent"),p=h.classList.contains("hasContent"),g,v,q;if(x&&(v=window.getComputedStyle(d)["max-width"]),p&&(q=window.getComputedStyle(h)["max-width"]),k)if(g=window.getComputedStyle(c)["max-width"],g==="none"||g==="auto")if(!x&&!p)l.style["grid-template-columns"]="0 1fr 0";else if(x)if(p)if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 1fr "+v;else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=h.offsetWidth,H=L+O+M,F=O*100/H;F>40?l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+F+"%) minmax(16.66%, 1fr)":l.style["grid-template-columns"]="repeat(3, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal",h.style["white-space"]="normal"}else if(v!=="none"&&v!=="auto")l.style["grid-template-columns"]=v+" 1fr "+v;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal"}else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",h.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=h.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",h.style["white-space"]="normal",c.style["white-space"]="normal"}else g!=="none"&&g!=="auto"&&(x&&v!=="none"&&v!=="auto"?l.style["grid-template-columns"]=v+" "+g+" 1fr":p&&q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr "+g+" "+q:l.style["grid-template-columns"]="1fr "+g+" 1fr");else if(x)if(!p)l.style["grid-template-columns"]="1fr 0 0";else if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 0 1fr";else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]="1fr 0 "+q;else{l.style["grid-template-columns"]="auto 1fr auto",d.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=h.offsetWidth,M=L+O,H=L*100/M;l.style["grid-template-columns"]="minmax(16.66%, "+H+"%) 0 1fr",d.style["white-space"]="normal",h.style["white-space"]="normal"}else q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr 0 "+q:l.style["grid-template-columns"]="0 0 1fr"}),["left","right"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i+"-middle.hasContent"),c=r.element.querySelector(".pagedjs_margin-"+i),d=r.element.querySelector(".pagedjs_margin-"+i+"-top"),h=r.element.querySelector(".pagedjs_margin-"+i+"-bottom"),k=d.classList.contains("hasContent"),x=h.classList.contains("hasContent"),p,g,v;k&&(g=window.getComputedStyle(d)["max-height"]),x&&(v=window.getComputedStyle(h)["max-height"]),l?(p=window.getComputedStyle(l)["max-height"],p==="none"||p==="auto"?!k&&!x?c.style["grid-template-rows"]="0 1fr 0":k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" calc(100% - "+g+" - "+v+") "+v:c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g:v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):g!=="none"&&g!=="auto"&&(c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g):v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):k&&g!=="none"&&g!=="auto"?c.style["grid-template-rows"]=g+" "+p+" calc(100% - ("+g+" + "+p+"))":x&&v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr "+p+" "+v:c.style["grid-template-rows"]="calc((100% - "+p+")/2) "+p+" calc((100% - "+p+")/2)"):k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" 1fr "+v:c.style["grid-template-rows"]=g+" 0 1fr":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="1fr 0 1fr":c.style["grid-template-rows"]="1fr 0 0":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="0 0 1fr"})}selectorsForPage(t){let r,a,n=new ce.default.List;return n.insertData({type:"ClassSelector",name:"pagedjs_page"}),t.name&&(n.insertData({type:"ClassSelector",name:"pagedjs_named_page"}),n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_page"})),t.psuedo&&!(t.name&&t.psuedo==="first")&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.psuedo+"_page"}),t.name&&t.psuedo==="first"&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_"+t.psuedo+"_page"}),t.nth&&(r=new ce.default.List,a=this.getNth(t.nth),r.insertData(a),n.insertData({type:"PseudoClassSelector",name:"nth-of-type",children:r})),n}selectorsForPageMargin(t,r){let a=this.selectorsForPage(t);return a.insertData({type:"Combinator",name:" "}),a.insertData({type:"ClassSelector",name:"pagedjs_margin-"+r}),a}createDeclaration(t,r,a){let n=new ce.default.List;return n.insertData({type:"Identifier",loc:null,name:r}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createVariable(t,r){return{type:"Declaration",loc:null,property:t,value:{type:"Raw",value:r}}}createCalculatedDimension(t,r,a,n="+"){let i=new ce.default.List,l=new ce.default.List;return r.forEach((c,d)=>{l.appendData({type:"Dimension",unit:c.unit,value:c.value}),l.appendData({type:"WhiteSpace",value:" "}),d+1<r.length&&(l.appendData({type:"Operator",value:n}),l.appendData({type:"WhiteSpace",value:" "}))}),i.insertData({type:"Function",loc:null,name:"calc",children:l}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:i}}}createDimension(t,r,a){let n=new ce.default.List;return n.insertData({type:"Dimension",loc:null,value:r.value,unit:r.unit}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createBlock(t){let r=new ce.default.List;return t.forEach(a=>{r.insertData(a)}),{type:"Block",loc:null,children:r}}createRule(t,r){let a=new ce.default.List;return a.insertData({type:"Selector",children:t}),Array.isArray(r)&&(r=this.createBlock(r)),{type:"Rule",prelude:{type:"SelectorList",children:a},block:r}}},a3=Ad;b();var Td=He(bt(),1);var Ed=class extends xe{constructor(t,r,a){super(t,r,a),this.breaks={}}onDeclaration(t,r,a,n){let i=t.property;if(i==="page"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude),k={property:i,value:c,selector:d,name:c};d.split(",").forEach(x=>{this.breaks[x]?this.breaks[x].push(k):this.breaks[x]=[k]}),a.remove(r)}if(i==="break-before"||i==="break-after"||i==="page-break-before"||i==="page-break-after"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude);i==="page-break-before"?i="break-before":i==="page-break-after"&&(i="break-after");let h={property:i,value:c,selector:d};d.split(",").forEach(k=>{this.breaks[k]?this.breaks[k].push(h):this.breaks[k]=[h]}),a.remove(r)}}afterParsed(t){this.processBreaks(t,this.breaks)}processBreaks(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++)for(let l of r[n])if(l.property==="break-after"){let c=jc(i[a],t);i[a].setAttribute("data-break-after",l.value),c&&c.setAttribute("data-previous-break-after",l.value)}else if(l.property==="break-before"){let c=cg(i[a],t);if(c){if(l.value==="page"&&Ds(i[a],c))continue;i[a].setAttribute("data-break-before",l.value),c.setAttribute("data-next-break-before",l.value)}}else if(l.property==="page"){i[a].setAttribute("data-page",l.value);let c=jc(i[a],t);c&&c.setAttribute("data-after-page",l.value)}else i[a].setAttribute("data-"+l.property,l.value)}}mergeBreaks(t,r){for(let a in r)a in t?t[a]=t[a].concat(r[a]):t[a]=r[a];return t}addBreakAttributes(t,r){let a=t.querySelector("[data-break-before]"),n=t.querySelector("[data-break-after]"),i=t.querySelector("[data-previous-break-after]");a&&(a.dataset.splitFrom?(r.splitFrom=a.dataset.splitFrom,t.setAttribute("data-split-from",a.dataset.splitFrom)):a.dataset.breakBefore&&a.dataset.breakBefore!=="avoid"&&(r.breakBefore=a.dataset.breakBefore,t.setAttribute("data-break-before",a.dataset.breakBefore))),n&&n.dataset&&(n.dataset.splitTo?(r.splitTo=n.dataset.splitTo,t.setAttribute("data-split-to",n.dataset.splitTo)):n.dataset.breakAfter&&n.dataset.breakAfter!=="avoid"&&(r.breakAfter=n.dataset.breakAfter,t.setAttribute("data-break-after",n.dataset.breakAfter))),i&&i.dataset&&i.dataset.previousBreakAfter&&i.dataset.previousBreakAfter!=="avoid"&&(r.previousBreakAfter=i.dataset.previousBreakAfter)}afterPageLayout(t,r){this.addBreakAttributes(t,r)}},n3=Ed;b();var i3=He(bt(),1),qd=class extends xe{constructor(t,r,a){super(t,r,a)}onAtMedia(t,r,a){let n=this.getMediaName(t),i;n.includes("print")?(i=t.block.children,a.appendList(i),a.remove(r)):!n.includes("all")&&!n.includes("pagedjs-ignore")&&a.remove(r)}getMediaName(t){let r=[];if(!(typeof t.prelude>"u"||t.prelude.type!=="AtrulePrelude"))return i3.default.walk(t.prelude,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),r}},s3=qd;b();var Od=class extends xe{constructor(t,r,a){super(t,r,a)}afterPageLayout(t,r,a,n){let i=Array.from(t.querySelectorAll("[data-split-from]")),l=t.parentNode,c=Array.prototype.indexOf.call(l.children,t),d;if(c===0)return;d=l.children[c-1];let h;i.forEach(k=>{let x=k.dataset.ref;h=d.querySelector("[data-ref='"+x+"']:not([data-split-to])"),h&&(h.dataset.splitTo=x,h.dataset.splitFrom||(h.dataset.splitOriginal=!0))}),h&&this.handleAlignment(h)}handleAlignment(t){let r=window.getComputedStyle(t),a=r["text-align"],n=r["text-align-last"];t.dataset.lastSplitElement="true",a==="justify"&&n==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=n}},o3=Od;b();var Io=He(bt(),1),Dd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counters={},this.resetCountersMap=new Map}onDeclaration(t,r,a,n){let i=t.property;if(i==="counter-increment"){this.handleIncrement(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}else if(i==="counter-reset"){this.handleReset(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}}afterParsed(t){this.processCounters(t,this.counters),this.scopeCounters(this.counters)}addCounter(t){return t in this.counters?this.counters[t]:(this.counters[t]={name:t,increments:{},resets:{}},this.counters[t])}handleIncrement(t,r){let a=[],n=t.value.children;return n.forEach((i,l)=>{if(i.type&&i.type==="Identifier"){let c=i.name;if(c==="page"||c.indexOf("target-counter-")===0)return;let d,h,k;l.next&&l.next.data.type==="WhiteSpace"&&(d=l.next),d&&d.next&&d.next.data.type==="Number"&&(h=d.next,k=parseInt(h.data.value));let x=Io.default.generate(r.ruleNode.prelude),p;c in this.counters?p=this.counters[c]:p=this.addCounter(c);let g={selector:x,number:k||1};p.increments[x]=g,a.push(g),n.remove(l),d&&n.remove(d),h&&n.remove(h)}}),a}handleReset(t,r){let a=t.value.children;a.forEach((n,i)=>{if(n.type&&n.type==="Identifier"){let l=n.name,c,d,h;i.next&&i.next.data.type==="WhiteSpace"&&(c=i.next),c&&c.next&&(c.next.data.type==="Number"?(d=c.next,h=parseInt(d.data.value)):c.next.data.type==="Function"&&c.next.data.name==="var"&&(d=c.next,h=c.next.data.children.head.data.name));let k,x,p=r.ruleNode.prelude;r.ruleNode.type==="Atrule"&&r.ruleNode.name==="page"?x=".pagedjs_page":x=Io.default.generate(p||r.ruleNode),l==="footnote"&&this.addFootnoteMarkerCounter(t.value.children),l in this.counters?k=this.counters[l]:k=this.addCounter(l);let g={selector:x,number:h||0};k.resets[x]=g,x!==".pagedjs_page"&&(a.remove(i),c&&a.remove(c),d&&a.remove(d))}})}processCounters(t,r){let a;for(let n in r)a=this.counters[n],this.processCounterIncrements(t,a),this.processCounterResets(t,a),n!=="page"&&this.addCounterValues(t,a)}scopeCounters(t){let r=[];for(let a in t)a!=="page"&&r.push(`${t[a].name} 0`);this.insertRule(`.pagedjs_pages { counter-reset: ${r.join(" ")} page 0 pages var(--pagedjs-page-count) footnote var(--pagedjs-footnotes-count) footnote-marker var(--pagedjs-footnotes-count)}`)}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}processCounterIncrements(t,r){let a;for(let n in r.increments){a=r.increments[n];let i=t.querySelectorAll(a.selector);for(let l=0;l<i.length;l++)i[l].setAttribute("data-counter-"+r.name+"-increment",a.number),i[l].getAttribute("data-counter-increment")?i[l].setAttribute("data-counter-increment",i[l].getAttribute("data-counter-increment")+" "+r.name):i[l].setAttribute("data-counter-increment",r.name)}}processCounterResets(t,r){let a;for(let i in r.resets){a=r.resets[i];let l=t.querySelectorAll(a.selector);for(var n=0;n<l.length;n++){let c=a.number;typeof c=="string"&&c.startsWith("--")&&(c=l[n].style.getPropertyValue(c)||0),l[n].setAttribute("data-counter-"+r.name+"-reset",c),l[n].getAttribute("data-counter-reset")?l[n].setAttribute("data-counter-reset",l[n].getAttribute("data-counter-reset")+" "+r.name):l[n].setAttribute("data-counter-reset",r.name)}}}addCounterValues(t,r){let a=r.name;if(a==="page"||a==="footnote")return;let n=t.querySelectorAll("[data-counter-"+a+"-reset], [data-counter-"+a+"-increment]"),i=0,l,c,d,h,k,x,p;for(let g=0;g<n.length;g++)l=n[g],x=0,p=[],l.hasAttribute("data-counter-"+a+"-reset")&&(d=l.getAttribute("data-counter-"+a+"-reset"),h=parseInt(d),x=h-i,p.push(`${a} ${x}`),i=h),l.hasAttribute("data-counter-"+a+"-increment")&&(c=l.getAttribute("data-counter-"+a+"-increment"),k=parseInt(c),i+=k,l.setAttribute("data-counter-"+a+"-value",i),p.push(`${a} ${k}`)),p.length>0&&this.incrementCounterForElement(l,p)}addFootnoteMarkerCounter(t){let r=[];Io.default.walk(t,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),!r.includes("footnote-maker")&&(t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Identifier",name:"footnote-marker"}),t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Number",value:0}))}incrementCounterForElement(t,r){if(!t||!r||r.length===0)return;let a=t.dataset.ref,n=Array.from(this.styleSheet.cssRules).filter(l=>l.selectorText===`[data-ref="${t.dataset.ref}"]:not([data-split-from])`&&l.style[0]==="counter-increment").map(l=>l.style.counterIncrement);n.push(this.mergeIncrements(r,(l,c)=>(parseInt(l)||0)+(parseInt(c)||0)));let i=this.mergeIncrements(n,(l,c)=>c);this.insertRule(`[data-ref="${a}"]:not([data-split-from]) { counter-increment: ${i} }`)}mergeIncrements(t,r){let a={};return t.forEach(n=>{let i=n.split(" ");for(let l=0;l<i.length;l+=2)a[i[l]]=r(a[i[l]],i[l+1])}),Object.entries(a).map(([n,i])=>`${n} ${i}`).join(" ")}afterPageLayout(t,r){let a=[];t.querySelectorAll("[data-counter-page-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset&&l.dataset.ref;if(!(c&&this.resetCountersMap.has(c))){c&&this.resetCountersMap.set(c,"");let d=l.dataset.counterPageReset;a.push(`page ${d}`)}}),t.querySelectorAll("[data-counter-footnote-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset.counterFootnoteReset;a.push(`footnote ${c}`),a.push(`footnote-marker ${c}`)}),a.length&&this.styleSheet.insertRule(`[data-page-number="${t.dataset.pageNumber}"] { counter-increment: none; counter-reset: ${a.join(" ")} }`,this.styleSheet.cssRules.length)}},l3=Dd;b();var Md=class extends xe{constructor(t,r,a){super(t,r,a)}afterParsed(t){let r=t.querySelectorAll("ol");for(var a of r)this.addDataNumbers(a)}afterPageLayout(t,r,a,n){var i=t.getElementsByTagName("ol");for(var l of i)l.firstElementChild&&(l.start=l.firstElementChild.dataset.itemNum)}addDataNumbers(t){let r=1;t.hasAttribute("start")&&(r=parseInt(t.getAttribute("start"),10),isNaN(r)&&(r=1));let a=t.children;for(var n=0;n<a.length;n++)a[n].setAttribute("data-item-num",n+r)}},c3=Md;b();var u3=He(bt(),1),jd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.fixedElementsSelector=[],this.fixedElements=[]}onDeclaration(t,r,a,n){if(t.property==="position"&&t.value.children.first().name==="fixed"){let i=u3.default.generate(n.ruleNode.prelude);this.fixedElementsSelector.push(i),a.remove(r)}}afterParsed(t){this.fixedElementsSelector.forEach(r=>{t.querySelectorAll(`${r}`).forEach(a=>{a.style.setProperty("position","absolute"),this.fixedElements.push(a),a.remove()})})}afterPageLayout(t,r,a){this.fixedElements.forEach(n=>{let i=n.cloneNode(!0);t.querySelector(".pagedjs_pagebox").insertAdjacentElement("afterbegin",i)})}},d3=jd;b();var p3=He(bt(),1),Bd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.pageCounter={name:"page",increments:{},resets:{}}}onDeclaration(t,r,a,n){t.property==="counter-increment"&&this.handleIncrement(t,n)&&a.remove(r)}afterParsed(t){for(let r in this.pageCounter.increments){let a=this.pageCounter.increments[r];this.insertRule(`${a.selector} { --pagedjs-page-counter-increment: ${a.number} }`)}}handleIncrement(t,r){let a=t.value.children.first(),n=t.value.children.getSize()>1?t.value.children.last().value:1,i=a&&a.name;if(i&&i.indexOf("target-counter-")===0||i!=="page"||r.ruleNode.name==="page"&&r.ruleNode.type==="Atrule")return;let l=p3.default.generate(r.ruleNode.prelude);return this.pageCounter.increments[l]={selector:l,number:n}}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}},f3=Bd;b();var Ld=He(bt(),1);var Pd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Ld.default.generate(t.prelude);if(n.match(/:(first|last|nth)-of-type/)){let i=Ld.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="nth-of-type-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-nth-of-type");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-nth-of-type",c)):i[a].setAttribute("data-nth-of-type",r[n][0])}let l=`*[data-nth-of-type*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},h3=Pd;b();var Id=He(bt(),1);var Rd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Id.default.generate(t.prelude);if(n.match(/\+/)){let i=Id.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="following-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-following");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-following",c)):i[a].setAttribute("data-following",r[n][0])}let l=`*[data-following*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},m3=Rd;b();var gn=He(bt(),1),Nd=class extends xe{constructor(t,r,a){super(t,r,a),this.footnotes={},this.needsLayout=[]}onDeclaration(t,r,a,n){let i=t.property;if(i==="float"){let l=t.value.children&&t.value.children.first();if((l&&l.name)==="footnote"){let d=gn.default.generate(n.ruleNode.prelude);this.footnotes[d]={selector:d,policy:"auto",display:"block"},a.remove(r)}}if(i==="footnote-policy"){let l=t.value.children&&t.value.children.first(),c=l&&l.name;if(c){let d=gn.default.generate(n.ruleNode.prelude),h=this.footnotes[d];h&&(h.policy=c)}}if(i==="footnote-display"){let l=t.value.children&&t.value.children.first(),c=l&&l.name,d=gn.default.generate(n.ruleNode.prelude);if(c&&this.footnotes[d]){let h=this.footnotes[d];h&&(h.display=c)}}}onPseudoSelector(t,r,a,n,i){let l=t.name;if(l==="footnote-marker"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-marker"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"marker",loc:null,children:null}),c.children.first().children=d}if(l==="footnote-call"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-call"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"after",loc:null,children:null}),c.children.first().children=d}}afterParsed(t){this.processFootnotes(t,this.footnotes)}processFootnotes(t,r){for(let n in r){let i=t.querySelectorAll(n),l,c=r[n];for(var a=0;a<i.length;a++)l=i[a],l.setAttribute("data-note","footnote"),l.setAttribute("data-break-before","avoid"),l.setAttribute("data-note-policy",c.policy||"auto"),l.setAttribute("data-note-display",c.display||"block"),this.processFootnoteContainer(l)}}processFootnoteContainer(t){let r=t.parentElement,a=r;for(;r;){if(Ms(r)){a.setAttribute("data-has-notes","true");break}a=r,r=r.parentElement,r||a.setAttribute("data-has-notes","true")}}renderNode(t){if(t.nodeType==1){let r;if(!t.dataset)return;t.dataset.note==="footnote"?r=[t]:(t.dataset.hasNotes||t.querySelectorAll("[data-note='footnote']"))&&(r=t.querySelectorAll("[data-note='footnote']")),r&&r.length&&this.findVisibleFootnotes(r,t)}}findVisibleFootnotes(t,r){let a,n,i;a=r.closest(".pagedjs_page_content"),n=a.getBoundingClientRect(),i=n.left+n.width;for(let l=0;l<t.length;++l){let c=t[l];c.getBoundingClientRect().left<i&&this.moveFootnote(c,r.closest(".pagedjs_area"),!0)}}moveFootnote(t,r,a){let n=r.querySelector(".pagedjs_footnote_area"),i=n.querySelector(".pagedjs_footnote_content"),l=i.querySelector(".pagedjs_footnote_inner_content");if(!ft(t))return;let c;if(a&&(c=this.createFootnoteCall(t)),t.removeAttribute("data-break-before"),l.querySelector(`[data-ref="${t.dataset.ref}"]`)){t.remove();return}l.appendChild(t),i.classList.contains("pagedjs_footnote_empty")&&i.classList.remove("pagedjs_footnote_empty"),t.dataset.footnoteMarker=t.dataset.ref,t.id=`note-${t.dataset.ref}`;let h=i.scrollHeight,x=r.querySelector(".pagedjs_page_content").getBoundingClientRect(),p=x.left+x.width,g=c&&c.getBoundingClientRect(),v=n.getBoundingClientRect(),q=this.marginsHeight(i),L=this.paddingHeight(i),O=this.borderHeight(i),M=q+L+O,H=Math.floor(v.top);v.height===0&&(H-=this.marginsHeight(i,!1),H-=this.paddingHeight(i,!1),H-=this.borderHeight(i,!1));let F=t.dataset.notePolicy,U=0,G=0;if(c){let be=c.previousSibling,Le=new Range;be?Le.setStartBefore(be):Le.setStartBefore(c),Le.setEndAfter(c);let Ne=Le.getBoundingClientRect();if(U=Ne.bottom,!F||F==="auto")G=Math.ceil(Ne.bottom);else if(F==="line")G=Math.ceil(Ne.top);else if(F==="block"){let Ae=c.closest("p").previousElementSibling;Ae?G=Math.ceil(Ae.getBoundingClientRect().bottom):G=Math.ceil(Ne.bottom)}}let Y=h+M-v.height,X=U?H-U:0,ne=U?Math.floor(v.top)-G:0,ve=n.querySelector("[data-note='footnote']");if(a&&g.left>p)t.remove();else if(!ve&&a&&M>X){r.style.setProperty("--pagedjs-footnotes-height","0px");let be=document.createElement("div");be.appendChild(t),this.needsLayout.push(be)}else a?U<v.top-Y?r.style.setProperty("--pagedjs-footnotes-height",`${h+q+O}px`):(r.style.setProperty("--pagedjs-footnotes-height",`${v.height+ne}px`),l.style.height=v.height+ne-M+"px"):r.style.setProperty("--pagedjs-footnotes-height",`${h+M}px`)}createFootnoteCall(t){let r=t.parentElement,a=document.createElement("a");for(let n of t.classList)a.classList.add(`${n}`);return a.dataset.footnoteCall=t.dataset.ref,a.dataset.ref=t.dataset.ref,a.dataset.dataCounterFootnoteIncrement=1,a.href=`#note-${t.dataset.ref}`,r.insertBefore(a,t),a}afterPageLayout(t,r,a,n){let i=t.querySelector(".pagedjs_area"),l=r.footnotesArea,c=l.querySelector(".pagedjs_footnote_content"),d=l.querySelector(".pagedjs_footnote_inner_content"),h=c.getBoundingClientRect(),{width:k}=h;d.style.columnWidth=Math.round(k)+"px",d.style.columnGap="calc(var(--pagedjs-margin-right) + var(--pagedjs-margin-left))";let p=new $s(l,void 0,n.settings).findOverflow(d,h);if(p){let{startContainer:g,startOffset:v}=p,q;if(ft(g)){let G=g.childNodes[v];q=ft(G)&&G.hasAttribute("data-footnote-marker")}let L=p.extractContents();if(!q){let G=L.firstElementChild;G.dataset.splitFrom=G.dataset.ref,this.handleAlignment(d.lastElementChild)}this.needsLayout.push(L),c.style.removeProperty("height"),d.style.removeProperty("height");let O=d.getBoundingClientRect(),{height:M}=O,H=this.marginsHeight(c),F=this.paddingHeight(c),U=this.borderHeight(c);if(i.style.setProperty("--pagedjs-footnotes-height",`${M+H+U+F}px`),d.childNodes.length===0&&c.classList.add("pagedjs_footnote_empty"),!a)n.clonePage(r);else{let G,Y;a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.previousBreakAfter<"u"&&(Y=a.node.dataset.previousBreakAfter),a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.breakBefore<"u"&&(G=a.node.dataset.breakBefore),(G||Y)&&n.clonePage(r)}}d.style.height="auto"}handleAlignment(t){let a=window.getComputedStyle(t)["text-align-last"];t.dataset.lastSplitElement="true",a==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=a}beforePageLayout(t){for(;this.needsLayout.length;){let r=this.needsLayout.shift();Array.from(r.childNodes).forEach(a=>{this.moveFootnote(a,t.element.querySelector(".pagedjs_area"),!1)})}}afterOverflowRemoved(t,r){let a=r.closest(".pagedjs_area"),n=a.querySelectorAll(".pagedjs_footnote_area [data-note='footnote']");for(let l=0;l<n.length;l++){let c=n[l];t.querySelector(`[data-footnote-call="${c.dataset.ref}"]`)&&c.remove()}let i=a.querySelector(".pagedjs_footnote_inner_content");i&&i.childNodes.length===0&&i.parentElement.classList.add("pagedjs_footnote_empty")}marginsHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.marginTop),i=parseInt(a.marginBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}paddingHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.paddingTop),i=parseInt(a.paddingBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}borderHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.borderTop),i=parseInt(a.borderBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}},g3=Nd;var y3=[s3,a3,n3,o3,l3,c3,d3,f3,h3,m3,g3];b();b();var ki=He(bt(),1),Fd=class extends xe{constructor(t,r,a){super(t,r,a),this.runningSelectors={},this.elements={}}onDeclaration(t,r,a,n){if(t.property==="position"){let i=ki.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;if(l==="running"){let c;ki.default.walk(t,{visit:"Function",enter:(d,h,k)=>{c=d.children.first().name}}),this.runningSelectors[c]={identifier:l,value:c,selector:i}}}t.property==="content"&&ki.default.walk(t,{visit:"Function",enter:(i,l,c)=>{if(i.name.indexOf("element")>-1){let d=ki.default.generate(n.ruleNode.prelude),h=i.name,k=i.children.first().name,x=[k],p="first";d.split(",").forEach(g=>{g=g.replace(/::after|::before/,""),this.elements[g]={func:h,args:x,value:k,style:p||"first",selector:g,fullSelector:d}})}}})}afterParsed(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=Array.from(t.querySelectorAll(a.selector));if(a.identifier==="running")for(let i of n)i.style.display="none"}}afterPageLayout(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=t.querySelector(a.selector);n&&(a.identifier==="running"?a.first=n:console.warn(a.value+"needs css replacement"))}this.orderedSelectors||(this.orderedSelectors=this.orderSelectors(this.elements));for(let r of this.orderedSelectors)if(r){let a=this.elements[r],n=t.querySelector(r);if(n){let i=this.runningSelectors[a.args[0]];if(i&&i.first){n.innerHTML="";let l=i.first.cloneNode(!0);l.style.display=null,n.appendChild(l)}}}}pageWeight(t){let r=1,a=t.split(" "),n=a.length&&a[0].split(".");switch(n.shift(),n.length){case 4:/^pagedjs_[\w-]+_first_page$/.test(n[3])?r=7:(n[3]==="pagedjs_left_page"||n[3]==="pagedjs_right_page")&&(r=6);break;case 3:n[1]==="pagedjs_named_page"&&(n[2].indexOf(":nth-of-type")>-1?r=7:r=5);break;case 2:n[1]==="pagedjs_first_page"?r=4:n[1]==="pagedjs_blank_page"?r=3:(n[1]==="pagedjs_left_page"||n[1]==="pagedjs_right_page")&&(r=2);break;default:n[0].indexOf(":nth-of-type")>-1?r=4:r=1}return r}orderSelectors(t){let r=Object.keys(t),a={1:[],2:[],3:[],4:[],5:[],6:[],7:[]},n=[];for(let l of r){let c=this.pageWeight(l);a[c].unshift(l)}for(var i=1;i<=7;i++)n=n.concat(a[i]);return n}beforeTreeParse(t,r){r.text=t.replace(/element[\s]*\(([^|^#)]*)\)/g,"element-ident($1)")}},b3=Fd;b();var Wd=He(bt(),1);b();function ua(e,t=`"' `){if(e!=null)return e.replace(new RegExp(`^[${t}]+`),"").replace(new RegExp(`[${t}]+$`),"").replace(/["']/g,r=>"\\"+r).replace(/[\n]/g,r=>"\\00000A")}function k3(e){if(e!=null)return e.replace(new RegExp("::footnote-call","g"),"").replace(new RegExp("::footnote-marker","g"),"")}var Hd=class extends xe{constructor(t,r,a){super(t,r,a),this.stringSetSelectors={},this.type,this.pageLastString}onDeclaration(t,r,a,n){if(t.property==="string-set"){let i=Wd.default.generate(n.ruleNode.prelude),l=[],c=[],d=[];t.value.children.forEach(h=>{h.type==="Identifier"&&l.push(h.name),h.type==="Function"&&(c.push(h.name),h.children.forEach(k=>{k.type==="Identifier"&&d.push(k.name)}))}),l.forEach((h,k)=>{let x=c[k],p=d[k];this.stringSetSelectors[h]={identifier:h,func:x,value:p,selector:i}})}}onContent(t,r,a,n,i){if(t.name==="string"){let l=t.children&&t.children.first().name;this.type=t.children.last().name,t.name="var",t.children=new Wd.default.List,this.type==="first"||this.type==="last"||this.type==="start"||this.type==="first-except"?t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-"+this.type+"-"+l})):t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-first-"+l}))}}afterPageLayout(t){this.pageLastString===void 0&&(this.pageLastString={});for(let r of Object.keys(this.stringSetSelectors)){let a=this.stringSetSelectors[r],n=a.value,i=a.func,l=t.querySelectorAll(a.selector),c=r in this.pageLastString?this.pageLastString[r]:"",d,h,k,x;if(l.length==0)d=c,h=c,k=c,x=c;else{l.forEach(q=>{i==="content"&&(this.pageLastString[r]=l[l.length-1].textContent),i==="attr"&&(this.pageLastString[r]=l[l.length-1].getAttribute(n)||"")}),i==="content"&&(d=l[0].textContent),i==="attr"&&(d=l[0].getAttribute(n)||""),i==="content"&&(h=l[l.length-1].textContent),i==="attr"&&(h=l[l.length-1].getAttribute(n)||"");let p=l[0].getBoundingClientRect().top,v=l[0].closest(".pagedjs_page_content").getBoundingClientRect().top;p==v?k=d:k=c,x=""}t.style.setProperty(`--pagedjs-string-first-${r}`,`"${ua(d)}`),t.style.setProperty(`--pagedjs-string-last-${r}`,`"${ua(h)}`),t.style.setProperty(`--pagedjs-string-start-${r}`,`"${ua(k)}`),t.style.setProperty(`--pagedjs-string-first-except-${r}`,`"${ua(x)}`)}}},_3=Hd;b();var _i=He(bt(),1),$d=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counterTargets={}}onContent(t,r,a,n,i){if(t.name==="target-counter"){let l=_i.default.generate(i.ruleNode.prelude),c=t.children.first(),d=c.name,h=_i.default.generate(t),k=[];c.children.forEach(q=>{q.type==="Identifier"&&k.push(q.name)});let x,p,g;t.children.forEach(q=>{q.type==="Identifier"&&(x?p||(g=_i.default.clone(q),p=q.name):x=q.name)});let v="target-counter-"+xt();l.split(",").forEach(q=>{this.counterTargets[q]={func:d,args:k,value:h,counter:x,style:p,selector:q,fullSelector:l,variable:v}}),t.name="counter",t.children=new _i.default.List,t.children.appendData({type:"Identifier",loc:0,name:v}),g&&(t.children.appendData({type:"Operator",loc:null,value:","}),t.children.appendData(g))}}afterPageLayout(t,r,a,n){Object.keys(this.counterTargets).forEach(i=>{let l=this.counterTargets[i],c=l.selector.split(/::?/g),d=c[0];n.pagesArea.querySelectorAll(d+":not([data-"+l.variable+"])").forEach((k,x)=>{if(l.func!=="attr")return;let p=zs(k,l.args),g=n.pagesArea.querySelector(Cs(p));if(g){let v=xt();k.setAttribute("data-"+l.variable,v);let q="";if(c.length>1&&(q+="::"+c[1]),l.counter==="page"){let O=n.pagesArea.querySelectorAll(".pagedjs_page"),M=0;for(let H=0;H<O.length;H++){let F=O[H],U=window.getComputedStyle(F),G=U["counter-reset"].replace("page","").trim(),Y=U["counter-increment"].replace("page","").trim();if(G!=="none"&&(M=parseInt(G)),Y!=="none"&&(M+=parseInt(Y)),F.contains(g))break}this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${M}; }`,this.styleSheet.cssRules.length)}else{let O=g.getAttribute(`data-counter-${l.counter}-value`);O&&this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${l.variable} ${parseInt(O)}; }`,this.styleSheet.cssRules.length)}let L=document.querySelector(`[data-${l.variable}="${v}"]`);L&&(L.style.display="none",L.clientHeight,L.style.removeProperty("display"))}})})}},w3=$d;b();var Ro=He(bt(),1),Gd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.textTargets={},this.beforeContent="",this.afterContent="",this.selector={}}onContent(t,r,a,n,i){if(t.name==="target-text"){this.selector=Ro.default.generate(i.ruleNode.prelude);let l=t.children.first(),c=t.children.last(),d=l.name,h=Ro.default.generate(t),k=[];l.children.forEach(g=>{g.type==="Identifier"&&k.push(g.name)});let x;c!==l&&(x=c.name);let p="--pagedjs-"+xt();this.selector.split(",").forEach(g=>{this.textTargets[g]={func:d,args:k,value:h,style:x||"content",selector:g,fullSelector:this.selector,variable:p}}),t.name="var",t.children=new Ro.default.List,t.children.appendData({type:"Identifier",loc:0,name:p})}}onPseudoSelector(t,r,a,n,i){i.ruleNode.block.children.forEach(l=>{t.name==="before"&&l.property==="content"?l.value.children.forEach(d=>{d.type==="String"&&(this.beforeContent=d.value)}):t.name==="after"&&l.property==="content"&&l.value.children.forEach(c=>{c.type==="String"&&(this.afterContent=c.value)})})}afterParsed(t){Object.keys(this.textTargets).forEach(r=>{let a=this.textTargets[r],n=a.selector.split("::"),i=n[0],l=t.querySelectorAll(i),c;l.forEach((d,h)=>{let k=zs(d,a.args),x=t.querySelector(Cs(k));if(x)if(a.style){this.selector=xt(),d.setAttribute("data-target-text",this.selector);let p="";if(n.length>1&&(p+="::"+n[1]),a.style==="before"||a.style==="after"){let g=`${a.style}Content`;c=ua(this[g])}else c=ua(x.textContent," ");c=a.style==="first-letter"?c.charAt(0):c,this.styleSheet.insertRule(`[data-target-text="${this.selector}"]${p} { ${a.variable}: "${c}" }`)}else console.warn("missed target",k)})})}},v3=Gd;var x3=[b3,_3,w3,v3];b();b();var Ud=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,r=>this.filterEmpty(r),NodeFilter.SHOW_TEXT)}filterEmpty(t){if(t.textContent.length>1&&Un(t)){let r=t.parentNode;if(ft(r)&&r.closest("pre"))return NodeFilter.FILTER_REJECT;let n=Ts(t),i=Es(t);return i===null&&n===null?(t.textContent=" ",NodeFilter.FILTER_REJECT):i===null||n===null?NodeFilter.FILTER_ACCEPT:(t.textContent=" ",NodeFilter.FILTER_REJECT)}else return NodeFilter.FILTER_REJECT}},S3=Ud;b();var Vd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,null,NodeFilter.SHOW_COMMENT)}},z3=Vd;b();var Yd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){t.querySelectorAll("script").forEach(r=>{r.remove()})}},C3=Yd;b();var q3=He(bt(),1),O3=He(E3(),1);var Kd=class extends xe{constructor(t,r,a){super(t,r,a),this.displayRules={}}onDeclaration(t,r,a,n){if(t.property==="display"){let i=q3.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;i.split(",").forEach(c=>{this.displayRules[c]={value:l,selector:c,specificity:(0,O3.calculateSpecificity)(c),important:t.important}})}}filter(t){let{matches:r,selectors:a}=this.sortDisplayedSelectors(t,this.displayRules);for(let i=0;i<r.length;i++){let l=r[i],c=a[i],d=c[c.length-1].value;this.removable(l)&&d==="none"&&(l.dataset.undisplayed="undisplayed")}let n=t.querySelectorAll("[style]");for(let i=0;i<n.length;i++){let l=n[i];this.removable(l)&&(l.dataset.undisplayed="undisplayed")}}sorter(t,r){return t.important&&!r.important?1:r.important&&!t.important?-1:t.specificity-r.specificity}sortDisplayedSelectors(t,r=[]){let a=[],n=[];for(let i in r){let l=r[i],c=l.selector,d=[];try{try{d=t.querySelectorAll(c)}catch{d=t.querySelectorAll(k3(c))}}catch{d=[]}let h=Array.from(d);for(let k of h)if(a.includes(k)){let x=a.indexOf(k);n[x].push(l),n[x]=n[x].sort(this.sorter)}else a.push(k),n.push([l])}return{matches:a,selectors:n}}removable(t){return!(t.style&&t.style.display!==""&&t.style.display!=="none")}},D3=Kd;var M3=[S3,z3,C3,D3];var e6=He(aa(),1),t6=He(Jw(),1),n0=[...y3,...x3,...M3],Wo=class{constructor(t,r,a){let n=[];n0.forEach(i=>{let l=new i(t,r,a);n.push(l),(0,t6.default)(l,this)})}};(0,e6.default)(Wo.prototype);function Ho(){for(var e=0;e<arguments.length;e++)n0.push(arguments[e])}function i0(e,t,r){return new Wo(e,t,r)}var $o=class{constructor(t){this.settings=t||{},this.polisher=new zd(!1),this.chunker=new eu(void 0,void 0,this.settings),this.hooks={},this.hooks.beforePreview=new ue(this),this.hooks.afterPreview=new ue(this),this.size={width:{value:8.5,unit:"in"},height:{value:11,unit:"in"},format:void 0,orientation:void 0},this.chunker.on("page",r=>{this.emit("page",r)}),this.chunker.on("rendering",()=>{this.emit("rendering",this.chunker)})}initializeHandlers(){let t=i0(this.chunker,this.polisher,this);return t.on("size",r=>{this.size=r,this.emit("size",r)}),t.on("atpages",r=>{this.atpages=r,this.emit("atpages",r)}),t}registerHandlers(){return Ho.apply(Ho,arguments)}getParams(t){let r,a=new URL(window.location),n=new URLSearchParams(a.search);for(var i of n.entries())i[0]===t&&(r=i[1]);return r}wrapContent(){let t=document.querySelector("body"),r;return r=t.querySelector(":scope > template[data-ref='pagedjs-content']"),r||(r=document.createElement("template"),r.dataset.ref="pagedjs-content",r.innerHTML=t.innerHTML,t.innerHTML="",t.appendChild(r)),r.content}removeStyles(t=document){let r=Array.from(t.querySelectorAll("link[rel='stylesheet']:not([data-pagedjs-ignore], [media~='screen'])")),a=Array.from(t.querySelectorAll("style:not([data-pagedjs-inserted-styles], [data-pagedjs-ignore], [media~='screen'])"));return[...r,...a].sort(function(i,l){let c=i.compareDocumentPosition(l);return c===Node.DOCUMENT_POSITION_PRECEDING?1:c===Node.DOCUMENT_POSITION_FOLLOWING?-1:0}).map(i=>{if(i.nodeName==="STYLE"){let l={};return l[window.location.href]=i.textContent,i.remove(),l}if(i.nodeName==="LINK")return i.remove(),i.href;console.warn(`Unable to process: ${i}, ignoring.`)})}async preview(t,r,a){await this.hooks.beforePreview.trigger(t,a),t||(t=this.wrapContent()),r||(r=this.removeStyles()),this.polisher.setup(),this.handlers=this.initializeHandlers(),await this.polisher.add(...r);let n=performance.now(),i=await this.chunker.flow(t,a),l=performance.now();return i.performance=l-n,i.size=this.size,this.emit("rendered",i),await this.hooks.afterPreview.trigger(i.pages),i}};(0,r6.default)($o.prototype);var s0=$o;async function a6(e,t,r){r.innerHTML="",document.querySelectorAll("style[data-pagedjs-inserted-styles]").forEach(n=>n.remove()),await new s0().preview(e,t,r)}function n6(){window.print()}b();var i6={none:{body:"system-serif",heading:"system-serif"},"light-neat-1":{body:"inter",heading:"inter"},"light-neat-2":{body:"ibm-plex-sans",heading:"ibm-plex-sans"},"light-neat-3":{body:"raleway",heading:"raleway"},"light-academic-1":{body:"source-serif-4",heading:"source-serif-4"},"light-academic-2":{body:"crimson-pro",heading:"inter"},"beige-decent-1":{body:"lora",heading:"lora"},"beige-decent-2":{body:"noto-serif",heading:"noto-serif"}};b();function s6(e){return e.trim().toLowerCase().replace(/-/g,"_")}function o0(e){let t=e.indexOf("=");return t<0?{key:s6(e),value:""}:{key:s6(e.slice(0,t)),value:e.slice(t+1).trim()}}function o6(e,t){Array.prototype.forEach.call(e.querySelectorAll("[data-show-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-show-when")||"");t[a]===n?r.removeAttribute("data-show-when"):r.remove()}),Array.prototype.forEach.call(e.querySelectorAll("[data-hide-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-hide-when")||"");t[a]===n?r.remove():r.removeAttribute("data-hide-when")})}function l6(e){let t={};for(let a of["data-show-when","data-hide-when"])Array.prototype.forEach.call(e.querySelectorAll("["+a+"]"),n=>{let{key:i,value:l}=o0(n.getAttribute(a)||"");(t[i]=t[i]||new Set).add(l)});let r={};for(let a of Object.keys(t))r[a]=Array.from(t[a]).sort();return r}var xM="0.3.0";function kn(){return window.__ORZ_PAGED__||{}}function Uo(){let e=document.getElementById("orz-src");return(e&&e.textContent||"").replace(/^\n/,"").replace(/\n\s*$/,"")}function u6(){let e=document.getElementById("orz-pages");return e||(e=document.createElement("div"),e.id="orz-pages",e.setAttribute("data-orz-copy",""),document.body.appendChild(e)),e}function Go(e){return new Promise((t,r)=>{if(!e||document.querySelector(`script[data-lib="${e}"]`))return t();let a=document.createElement("script");a.src=e,a.async=!0,a.setAttribute("data-lib",e),a.setAttribute("data-orz-runtime","1"),a.onload=()=>t(),a.onerror=()=>r(new Error("failed to load "+e)),document.head.appendChild(a)})}function Si(e,t){if(!e||t&&document.getElementById(t)||!t&&document.querySelector(`link[href="${e}"]`))return;let r=document.createElement("link");r.rel="stylesheet",r.href=e,t&&(r.id=t),r.setAttribute("data-orz-runtime","1"),document.head.appendChild(r)}function SM(e){try{let t=document.createElement("img");t.src=e.toDataURL("image/png"),t.className=e.className,t.style.maxWidth="100%";let r=e.getAttribute("data-md");r!=null&&t.setAttribute("data-md",r),e.replaceWith(t)}catch{}}async function zM(e){let t=kn().enhancers||{},r=window,a=[];t.hljsJs&&e.querySelector("pre code")&&(await Go(t.hljsJs),r.hljs&&e.querySelectorAll("pre code:not(.hljs)").forEach(n=>{try{r.hljs.highlightElement(n)}catch{}})),t.mermaidJs&&e.querySelector(".mermaid")&&(await Go(t.mermaidJs),r.mermaid&&(r.mermaid.initialize({startOnLoad:!1}),a.push(Promise.resolve(r.mermaid.run({nodes:e.querySelectorAll(".mermaid")})).catch(()=>{})))),t.smilesJs&&e.querySelector("canvas[data-smiles]")&&(await Go(t.smilesJs),r.SmilesDrawer&&e.querySelectorAll("canvas[data-smiles]").forEach(n=>{let i=new r.SmilesDrawer.Drawer({width:n.width,height:n.height});a.push(new Promise(l=>{r.SmilesDrawer.parse(n.getAttribute("data-smiles"),c=>{try{i.draw(c,n,"light",!1)}catch{}l()},()=>l())}))})),t.chartJs&&e.querySelector("canvas.orz-chart[data-chart]")&&(await Go(t.chartJs),r.Chart&&e.querySelectorAll("canvas.orz-chart[data-chart]").forEach(n=>{try{let i=JSON.parse(n.getAttribute("data-chart")||"{}");i.options={...i.options||{},responsive:!1,animation:!1},new r.Chart(n,i)}catch{}})),await Promise.all(a),e.querySelectorAll("canvas").forEach(n=>SM(n))}var Vo=null,Zo=null,l0={},d6={};function CM(e){let t=kn(),r=Zo||e.theme,a=[];return t.mode==="cdn"?(t.baseUrl&&a.push(t.baseUrl),r!=="none"&&t.themeUrls&&t.themeUrls[r]&&a.push(t.themeUrls[r])):(t.baseCss&&a.push({"orz-base.css":t.baseCss}),r!=="none"&&t.themes&&t.themes[r]&&a.push({"orz-theme.css":t.themes[r]})),a.push({"orz-page.css":e.css}),a}async function Yo(e){let t=Mc(e);Vo=t;let r=Zo||t.theme,a=i6[r];a&&(Si(Or(a.body).cssUrl),Si(Or(a.heading).cssUrl)),t.fontCssUrls.forEach(l=>Si(l)),kn().katexCss&&Si(kn().katexCss,"orz-katex"),kn().hljsCss&&Si(kn().hljsCss,"orz-hljs");let n=document.createElement("div");n.className="orz-stage",n.style.cssText="position:absolute;left:-99999px;top:0;width:680px;",n.innerHTML=t.bodyHtml,document.body.appendChild(n),d6=l6(n),l0={...t.settings.dynamicChoices},o6(n,l0);let i=document.createElement("div");i.style.cssText="position:absolute;left:-99999px;top:0;width:900px;",document.body.appendChild(i);try{if(await zM(n.querySelector(".orz-doc")||n),document.fonts&&document.fonts.ready)try{await document.fonts.ready}catch{}await a6(n.innerHTML,CM(t),i);let l=u6(),c=l.scrollTop;if(l.replaceChildren(...Array.prototype.slice.call(i.childNodes)),l.scrollTop=c,t.settings.frontMatterClean){let k=Array.prototype.slice.call(l.querySelectorAll(".pagedjs_page")).filter(x=>!x.classList.contains("pagedjs_orz-front_page"));document.documentElement.style.setProperty("--orz-body-pages",`"${k.length}"`),k.forEach((x,p)=>x.style.setProperty("--orz-pageno",`"${p+1}"`))}AM();let d=window.__orzPagedAfterRender;if(d)try{d()}catch{}}finally{n.remove(),i.remove()}}function AM(){let e=u6(),t=e.querySelector(".orz-toc");if(!t)return;let r=Number(t.getAttribute("data-max-level")||"3"),a=[];e.querySelectorAll(".pagedjs_page h1, .pagedjs_page h2, .pagedjs_page h3, .pagedjs_page h4").forEach(n=>{let i=Number(n.tagName.slice(1));if(i>r)return;let l=n.closest(".pagedjs_page"),c=l&&l.getAttribute("data-page-number")||"";a.push(`<li class="orz-toc-item orz-toc-l${i}"><span class="orz-toc-text">${n.textContent||""}</span><span class="orz-toc-page">${c}</span></li>`)}),a.length&&(t.innerHTML=`<ol class="orz-toc-list">${a.join("")}</ol>`)}var TM={version:xM,assemble:Mc,render:e=>Yo(e),refresh:()=>Yo(Uo()),exportPdf:()=>n6(),setTheme:e=>(Zo=e&&e!=="none"?e:null,Yo(Uo())),getTheme:()=>Zo||(Vo?Vo.theme:null),getDynamicState:()=>({options:d6,choices:l0}),get assembly(){return Vo},source:Uo};window.orzpaged=TM;function c6(){Yo(Uo()).catch(e=>console.error("[orz-paged]",e))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",c6):c6();})();
|
package/dist/paged.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A stylesheet for paged.js: a URL (fetched) or inline CSS as `{ name: cssText }`. */
|
|
2
|
+
export type PagedStylesheet = string | Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Flow `content` (body HTML) into `target` as `.pagedjs_page` boxes, applying
|
|
5
|
+
* `stylesheets` (the `@page` rules + content/theme CSS). Clears `target` first.
|
|
6
|
+
*/
|
|
7
|
+
export declare function paginate(content: string, stylesheets: PagedStylesheet[], target: HTMLElement): Promise<void>;
|
|
8
|
+
/** Export to PDF via the browser's own print engine (no Puppeteer). */
|
|
9
|
+
export declare function printDocument(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assembler — A1.
|
|
3
|
+
*
|
|
4
|
+
* `assemble(source)` turns a Markdown source into a {@link PagedAssembly}: pure
|
|
5
|
+
* data (CSS, font URLs, theme, body HTML, resolved settings) that the browser
|
|
6
|
+
* engine then hands to paged.js for pagination. No DOM here.
|
|
7
|
+
*
|
|
8
|
+
* Pipeline (DESIGN §3/§6):
|
|
9
|
+
* 1. `parseDocSettings` extracts + strips the `{{nyml kind: document}}` block.
|
|
10
|
+
* 2. Merge DEFAULTS ← template layer ← user overrides → resolved settings.
|
|
11
|
+
* 3. Scan the remaining body for `{{nyml kind: element}}` blocks, render each
|
|
12
|
+
* via `renderElement`, and replace it with a placeholder token.
|
|
13
|
+
* 4. Render the placeholdered body Markdown, then swap each placeholder for
|
|
14
|
+
* its element's HTML (so element HTML is never re-parsed as Markdown).
|
|
15
|
+
* 5. Compose page CSS + deduped element CSS + custom CSS; collect font URLs.
|
|
16
|
+
*/
|
|
17
|
+
import type { PagedAssembly } from './types.js';
|
|
18
|
+
/**
|
|
19
|
+
* Assemble a Markdown source into a {@link PagedAssembly}.
|
|
20
|
+
*/
|
|
21
|
+
export declare function assemble(source: string): PagedAssembly;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the self-contained `.paged.html` shell (A3):
|
|
3
|
+
* <head> editor-chrome CSS (the document/page CSS is applied by the engine via
|
|
4
|
+
* paged.js' polisher, not here)
|
|
5
|
+
* <body> an empty #orz-pages render target, the editor chrome (edit FAB +
|
|
6
|
+
* docked CodeMirror panel + brand header + banners), the embedded
|
|
7
|
+
* Markdown source in <script id="orz-src">, the engine bundle (inline or
|
|
8
|
+
* CDN), the __ORZ_PAGED__ config, the boot call, and the in-file app.
|
|
9
|
+
*
|
|
10
|
+
* The source in #orz-src is the single source of truth: the engine renders it on
|
|
11
|
+
* load and the editor re-serialises it on save (self-reproducing). Mirrors
|
|
12
|
+
* orz-slides' template (live preview = the real rendered pages).
|
|
13
|
+
*/
|
|
14
|
+
export type RendererSpec = {
|
|
15
|
+
mode: 'inline';
|
|
16
|
+
js: string;
|
|
17
|
+
} | {
|
|
18
|
+
mode: 'cdn';
|
|
19
|
+
src: string;
|
|
20
|
+
};
|
|
21
|
+
export interface ThemeAsset {
|
|
22
|
+
id: string;
|
|
23
|
+
css: string;
|
|
24
|
+
}
|
|
25
|
+
/** A template + its starter skeleton, for the in-editor template picker. */
|
|
26
|
+
export interface TemplateAsset {
|
|
27
|
+
id: string;
|
|
28
|
+
label: string;
|
|
29
|
+
description: string;
|
|
30
|
+
group: string;
|
|
31
|
+
skeleton: string;
|
|
32
|
+
}
|
|
33
|
+
export interface BuildOptions {
|
|
34
|
+
source: string;
|
|
35
|
+
title: string;
|
|
36
|
+
rendererVersion: string;
|
|
37
|
+
renderer: RendererSpec;
|
|
38
|
+
/** assets/themes/base.css text. */
|
|
39
|
+
baseCss: string;
|
|
40
|
+
/** all curated themes, inlined so the editor can switch with no network. */
|
|
41
|
+
themes: ThemeAsset[];
|
|
42
|
+
/** default theme id (informational; the document's settings decide). */
|
|
43
|
+
defaultTheme: string;
|
|
44
|
+
/** CDN URLs needed at view time. */
|
|
45
|
+
cdn: {
|
|
46
|
+
katexCss: string;
|
|
47
|
+
mermaidJs: string;
|
|
48
|
+
smilesJs: string;
|
|
49
|
+
chartJs: string;
|
|
50
|
+
hljsJs: string;
|
|
51
|
+
hljsCss: string;
|
|
52
|
+
};
|
|
53
|
+
/** the in-file editor app (assets/app.js text). */
|
|
54
|
+
appJs: string;
|
|
55
|
+
/** orz-markdown browser runtime (copy-as-Markdown + qr). */
|
|
56
|
+
runtime: string;
|
|
57
|
+
/** template catalog for the in-editor picker (id/label/description/group/skeleton). */
|
|
58
|
+
templates?: TemplateAsset[];
|
|
59
|
+
}
|
|
60
|
+
export declare function buildHtml(o: BuildOptions): string;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orz-paged — LOCKED INTERFACE.
|
|
3
|
+
*
|
|
4
|
+
* Every module codes against these types and nothing else. Changing a type here
|
|
5
|
+
* ripples across the document layer, the assembler, and the engine — treat edits
|
|
6
|
+
* as a coordinated change. (Mirrors orz-slides' `src/types.ts` role.)
|
|
7
|
+
*
|
|
8
|
+
* Vocabulary follows DESIGN.md §6–§9 and docs/document-model.md (the curated
|
|
9
|
+
* subset). Lengths: margins in **mm**, font size in **pt**, line-height unitless.
|
|
10
|
+
*/
|
|
11
|
+
/** Named page sizes; a custom CSS size string (e.g. `"210mm 297mm"`) is allowed. */
|
|
12
|
+
export type PageSize = 'A3' | 'A4' | 'A5' | 'Letter' | 'Legal' | (string & {});
|
|
13
|
+
/** Where the page number sits in the margin boxes. */
|
|
14
|
+
export type PageNumberPosition = 'header-left' | 'header-center' | 'header-right' | 'footer-left' | 'footer-center' | 'footer-right' | 'none';
|
|
15
|
+
/** How the page number renders (counter formats). */
|
|
16
|
+
export type PageNumberStyle = 'simple' | 'page-n' | 'page-n-of-N' | 'n-of-N' | 'n-slash-N' | 'dash-n-dash' | 'brackets' | 'parentheses';
|
|
17
|
+
/**
|
|
18
|
+
* Curated document templates. `article`/`report`/`exam` come in two variants —
|
|
19
|
+
* `-page` (a dedicated title/cover page) and `-section` (title-on-content) — via
|
|
20
|
+
* the title element's `placement`. Legacy names (`article`/`report`/`exam`) still
|
|
21
|
+
* resolve to the `-section` variant (see resolveTemplate).
|
|
22
|
+
*/
|
|
23
|
+
export type TemplateName = 'article-page' | 'article-section' | 'report-page' | 'report-section' | 'exam-page' | 'exam-section' | 'letter' | 'cover-letter' | 'cv' | 'cv-modern' | 'cv-elegant' | 'note';
|
|
24
|
+
/** Curated, light-only themes (DESIGN §8). `none` = plain. */
|
|
25
|
+
export type ThemeName = 'none' | 'light-academic-1' | 'light-academic-2' | 'light-neat-1' | 'light-neat-2' | 'light-neat-3' | 'beige-decent-1' | 'beige-decent-2';
|
|
26
|
+
/** Curated CDN font presets (DESIGN §4, §8). */
|
|
27
|
+
export type FontPresetName = 'system-serif' | 'source-serif-4' | 'lora' | 'crimson-pro' | 'noto-serif' | 'inter' | 'ibm-plex-sans' | 'roboto' | 'raleway' | 'noto-sans' | 'courier-prime';
|
|
28
|
+
/** Curated document elements (DESIGN §8). */
|
|
29
|
+
export type ElementKind = 'article-title' | 'report-title' | 'exam-title' | 'abstract' | 'letterhead' | 'letter-inside-address' | 'letter-signature' | 'toc' | 'cv-header' | 'question-mc' | 'question-open' | 'timestamp';
|
|
30
|
+
/** A title/cover element renders either as its own page or inline (DESIGN §8). */
|
|
31
|
+
export type Placement = 'page' | 'section';
|
|
32
|
+
/**
|
|
33
|
+
* Raw `{{nyml kind: document}}` payload — snake_case keys, loosely typed, every
|
|
34
|
+
* field optional. M1 (`settings`) parses this from the source.
|
|
35
|
+
*/
|
|
36
|
+
export type RawDocSettings = Record<string, string | number | boolean | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Fully-normalized document settings — every field resolved with defaults
|
|
39
|
+
* applied (after merging template + user layers). M5 (`page-css`) consumes this.
|
|
40
|
+
*/
|
|
41
|
+
export interface DocSettings {
|
|
42
|
+
pageSize: PageSize;
|
|
43
|
+
marginTop: number;
|
|
44
|
+
marginBottom: number;
|
|
45
|
+
marginLeft: number;
|
|
46
|
+
marginRight: number;
|
|
47
|
+
pageBackground?: string;
|
|
48
|
+
fontPreset?: FontPresetName;
|
|
49
|
+
fontFamily?: string;
|
|
50
|
+
fontHeadingPreset?: FontPresetName;
|
|
51
|
+
fontMarginBoxPreset?: FontPresetName;
|
|
52
|
+
fontSize: number;
|
|
53
|
+
lineHeight: number;
|
|
54
|
+
decorationColor?: string;
|
|
55
|
+
pageNumberPosition: PageNumberPosition;
|
|
56
|
+
pageNumberStyle: PageNumberStyle;
|
|
57
|
+
pageNumberStartPage: number;
|
|
58
|
+
firstPageSkipNumber: boolean;
|
|
59
|
+
headerLeft: string;
|
|
60
|
+
headerCenter: string;
|
|
61
|
+
headerRight: string;
|
|
62
|
+
headerRule: boolean;
|
|
63
|
+
headerRuleColor?: string;
|
|
64
|
+
headerFontSize: number;
|
|
65
|
+
footerLeft: string;
|
|
66
|
+
footerCenter: string;
|
|
67
|
+
footerRight: string;
|
|
68
|
+
footerRule: boolean;
|
|
69
|
+
footerRuleColor?: string;
|
|
70
|
+
footerFontSize: number;
|
|
71
|
+
firstPageHideHeader: boolean;
|
|
72
|
+
firstPageHideFooter: boolean;
|
|
73
|
+
/** Strip header/footer/number from every `placement: page` front-matter page
|
|
74
|
+
* (title / abstract / toc on their own pages) and restart the page count so
|
|
75
|
+
* the first main-content page is 1. */
|
|
76
|
+
frontMatterClean: boolean;
|
|
77
|
+
limitImageToPage: boolean;
|
|
78
|
+
keepImageTogether: boolean;
|
|
79
|
+
repeatTableHeader: boolean;
|
|
80
|
+
avoidTableRowBreaks: boolean;
|
|
81
|
+
theme: ThemeName;
|
|
82
|
+
template?: TemplateName;
|
|
83
|
+
customCss?: string;
|
|
84
|
+
/** Dynamic switch — a key→value map driving conditional content. Elements
|
|
85
|
+
* carry `data-show-when="key=value"` / `data-hide-when="key=value"`; at render
|
|
86
|
+
* time non-matching ones are removed. Lets one source print several versions
|
|
87
|
+
* (e.g. `answer-key: hide` for the student copy, `show` for the key). */
|
|
88
|
+
dynamicChoices: Record<string, string>;
|
|
89
|
+
}
|
|
90
|
+
/** A partial settings layer (template defaults / user overrides) for merging. */
|
|
91
|
+
export type DocSettingsLayer = Partial<DocSettings>;
|
|
92
|
+
/** One `{{nyml kind: element}}` block: its kind + raw field map. */
|
|
93
|
+
export interface ElementSpec {
|
|
94
|
+
kind: ElementKind;
|
|
95
|
+
/** snake_case field → raw string value (multiline values preserved). */
|
|
96
|
+
fields: Record<string, string>;
|
|
97
|
+
/** parsed `placement:` if present (title/cover elements). */
|
|
98
|
+
placement?: Placement;
|
|
99
|
+
}
|
|
100
|
+
/** Capabilities an element renderer may use (injected — no hard orz-markdown dep). */
|
|
101
|
+
export interface ElementCtx {
|
|
102
|
+
/** Render inline Markdown (no wrapping `<p>`). */
|
|
103
|
+
renderInline(md: string): string;
|
|
104
|
+
/** Render block Markdown. */
|
|
105
|
+
renderBlock(md: string): string;
|
|
106
|
+
/** The resolved document settings (for accent color, fonts, etc.). */
|
|
107
|
+
settings: DocSettings;
|
|
108
|
+
}
|
|
109
|
+
/** Output of rendering one element. */
|
|
110
|
+
export interface ElementResult {
|
|
111
|
+
/** The element's HTML, placed into the document flow. */
|
|
112
|
+
html: string;
|
|
113
|
+
/** Scoped CSS for this element kind; injected **once** per kind (dedupe by kind). */
|
|
114
|
+
css?: string;
|
|
115
|
+
/** `page` → on its own page; `section` → inline. Defaults to `section`. */
|
|
116
|
+
placement: Placement;
|
|
117
|
+
}
|
|
118
|
+
/** A resolved font preset: a CDN stylesheet to load + the CSS family stack. */
|
|
119
|
+
export interface FontPreset {
|
|
120
|
+
/** `<link rel="stylesheet">` href (e.g. an @fontsource / Google Fonts URL). */
|
|
121
|
+
cssUrl: string;
|
|
122
|
+
/** the `font-family` value to use. */
|
|
123
|
+
family: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Result of assembling a document (A1) — everything the engine/template needs to
|
|
127
|
+
* render the paginated document. Pure data; no DOM.
|
|
128
|
+
*/
|
|
129
|
+
export interface PagedAssembly {
|
|
130
|
+
/** The page CSS (from M5) + element scoped CSS + theme hook + custom CSS. */
|
|
131
|
+
css: string;
|
|
132
|
+
/** Font stylesheet URLs to `<link>` in <head> (from M3, deduped). */
|
|
133
|
+
fontCssUrls: string[];
|
|
134
|
+
/** Theme name to load its stylesheet. */
|
|
135
|
+
theme: ThemeName;
|
|
136
|
+
/** The document body HTML (content + elements), pre-pagination. */
|
|
137
|
+
bodyHtml: string;
|
|
138
|
+
/** The fully-resolved settings (for the editor settings panel + runtime). */
|
|
139
|
+
settings: DocSettings;
|
|
140
|
+
}
|
|
141
|
+
declare global {
|
|
142
|
+
/** Injected by esbuild at bundle time (build/bundle.ts). */
|
|
143
|
+
const __ORZPAGED_VERSION__: string;
|
|
144
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orz-paged",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Self-contained, editable HTML documents (.paged.html) — Markdown shown as print pages via paged.js, edited in-browser, exported to PDF by printing. Sibling of orz-mdhtml and orz-slides.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/lib.js",
|
|
7
|
+
"types": "./dist/lib.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/lib.d.ts",
|
|
11
|
+
"default": "./dist/lib.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
6
14
|
"bin": {
|
|
7
15
|
"orz-paged": "dist/cli.js"
|
|
8
16
|
},
|