@hidemikimura/receipt-html-to-pdf 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/CHANGELOG.md +50 -0
- package/README.md +33 -9
- package/dist/receipt-html-to-pdf.min.js +15 -14
- package/dist/receipt-html-to-pdf.min.js.map +4 -4
- package/examples/cdn.html +110 -0
- package/package.json +1 -1
- package/skills/receipt-html-to-pdf/SKILL.md +34 -4
- package/skills/receipt-html-to-pdf/references/receipt-format.md +3 -1
- package/skills/receipt-html-to-pdf/references/troubleshooting.md +1 -0
- package/src/font/gsub.js +229 -0
- package/src/index.js +22 -1
- package/src/pacer.js +50 -0
- package/src/page.js +101 -8
- package/src/paginate.js +19 -0
- package/src/pdf/content.js +44 -2
- package/src/pdf/shading.js +113 -0
- package/src/renderer.js +27 -1
- package/src/walker/gradient.js +193 -0
- package/src/walker/image.js +77 -0
- package/src/walker/svg-path.js +342 -0
- package/src/walker/text.js +29 -2
- package/src/walker/walk.js +273 -24
- package/types/font/gsub.d.ts +47 -0
- package/types/index.d.ts +28 -1
- package/types/pacer.d.ts +11 -0
- package/types/page.d.ts +4 -1
- package/types/paginate.d.ts +1 -0
- package/types/pdf/content.d.ts +18 -1
- package/types/pdf/shading.d.ts +44 -0
- package/types/walker/gradient.d.ts +25 -0
- package/types/walker/image.d.ts +36 -0
- package/types/walker/svg-path.d.ts +31 -0
- package/types/walker/text.d.ts +4 -0
- package/types/walker/walk.d.ts +50 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
設計と経緯の詳細は docs/design.md。
|
|
4
4
|
|
|
5
|
+
## 0.3.0 — 描画と大きな文書の強化(2026-09-20)
|
|
6
|
+
|
|
7
|
+
### 追加
|
|
8
|
+
|
|
9
|
+
- **`onProgress` を追加**。`render` → `walk` → `layout`(総ページ数が確定)→ `page`(1 ページずつ)→ `done` の順に進み具合を通知する(docs/design.md 25 章)
|
|
10
|
+
- **長い変換でメインスレッドを占有しなくなった**。12ms ごとにイベントループへ戻す(`scheduler.yield()` があればそれを使う)。3000 行・130 ページの文書で、走査中に描画されるフレーム数が 0 → 5、変換全体の最長フレーム間隔が 934ms → 181ms。所要時間の増加は約 9%
|
|
11
|
+
- **埋め込み後にデコード済み画像データを解放する**。以前はデコード結果(RGB・アルファ)が URL キーのキャッシュに永久に残っていた。600×600 の透過 PNG 12 枚で、変換後に残るメモリが約 17MB → 1.3MB。次の変換では読み直しになる(速度よりメモリを優先)
|
|
12
|
+
- **`background-repeat` に対応**。`repeat` / `no-repeat` / `repeat-x` / `repeat-y` / `space` / `round` と、軸ごとの 2 値指定(`repeat space` など)
|
|
13
|
+
- タイルは同じ画像 XObject を参照するので、繰り返しても画像の埋め込みは 1 回だけ
|
|
14
|
+
- `round` はタイルの大きさを調整して整数個収め、`space` は余りを隙間に等分する(CSS 仕様どおり)
|
|
15
|
+
- タイルが 4000 枚を超える場合のみ、1 枚だけ描いて警告する
|
|
16
|
+
- **GSUB の単一置換に対応**。ブラウザが `font-variant-numeric` / `-caps` / `-east-asian` / `font-feature-settings` で有効にした機能と同じグリフ置換を PDF でも行う(docs/design.md 23 章)
|
|
17
|
+
- `zero`(スラッシュ付きゼロ)、`jp78` / `jp83` / `jp90` / `jp04` / `nlck` / `trad` / `smpl`(旧字体・異体字)、`fwid` / `hwid`、`smcp` など
|
|
18
|
+
- 置換は埋め込み前に解決するので、GSUB テーブル自体は PDF に入らない。抽出テキストは元の文字のまま(ToUnicode は変えない)
|
|
19
|
+
- 合字(`liga` / `dlig`、Lookup タイプ 4)は未対応。既定で有効な機能(`ccmp` / `liga` / `calt`)は適用しない
|
|
20
|
+
- 調査の結果 `tabular-nums` は日本語フォントに `tnum` 機能が無く効かないことが分かったため、数字の桁揃えはフォント選択で解決する旨をドキュメントに明記した
|
|
21
|
+
- **インライン `<svg>` のベクター変換に対応**。ラスタライズせず PDF のパスとして出すので、拡大しても滑らかで、テキスト以外の図形はそのまま印刷品質になる(docs/design.md 22 章)
|
|
22
|
+
- `<path>` の全コマンド(`M L H V C S Q T A Z`、相対・絶対)。円弧と二次ベジェは 3 次ベジェへ変換
|
|
23
|
+
- `<rect>`(`rx` / `ry`)・`<circle>`・`<ellipse>`・`<line>`・`<polyline>`・`<polygon>`・`<g>`・入れ子の `<svg>`
|
|
24
|
+
- `fill` / `fill-rule` / `fill-opacity`、`stroke` と `-width` / `-opacity` / `-linecap` / `-linejoin` / `-miterlimit` / `-dasharray` / `-dashoffset`、`opacity`、`visibility`
|
|
25
|
+
- `viewBox` / `preserveAspectRatio` / `transform` は `getScreenCTM()` の結果をそのまま使う
|
|
26
|
+
- `<svg>` はページ境界で分割しない
|
|
27
|
+
- `<text>` / `<use>` / paint server(`fill="url(#id)"`)は警告して飛ばす。`<img src="x.svg">` は従来どおりラスタライズ
|
|
28
|
+
- **`linear-gradient` に対応**。PDF の軸シェーディング(ShadingType 2)としてベクター出力するので、拡大しても滑らかで、ファイルも軽い(docs/design.md 21 章)
|
|
29
|
+
- 角度(`<n>deg` / `to <side>` / `to <side> <side>`)、色止めの `%` / `px` / 位置省略(等間隔)/ 二重指定、単調化に対応
|
|
30
|
+
- 色止めごとにアルファが変わる場合(`transparent` → `black` など)は輝度ソフトマスクで正確に再現する
|
|
31
|
+
- `background-origin` / `background-clip` / `border-radius` を尊重する
|
|
32
|
+
- `repeating-linear-gradient` / `radial-gradient` / `conic-gradient` / 複数背景は従来どおり警告
|
|
33
|
+
- **`break-before: avoid` / `break-after: avoid`(`page-break-*: avoid`)に対応**。隣の箱との間にページ境界を置かず、置きそうなら前の箱の先頭まで境界を戻す。見出しがページ末尾に取り残されるのを防げる
|
|
34
|
+
- 兄弟が無ければ親をさかのぼるので、`<section>` の最後の見出しに書いても次の `<section>` と結びつく
|
|
35
|
+
- 境界は次の箱の上端ではなく**最初の行**まで判定する(`line-height` の半行分だけ箱の上端より下に来るため)
|
|
36
|
+
- 結んだ範囲が 1 ページに収まらない場合と、戻すとページが空になる場合は諦めて普通に分割する
|
|
37
|
+
|
|
38
|
+
## 0.2.1 — 右端が切れる不具合の修正(2026-09-20)
|
|
39
|
+
|
|
40
|
+
### 追加
|
|
41
|
+
|
|
42
|
+
- 内容が本文領域より横に広いとき、`onWarning` に `other` の警告を出すようにした(はみ出し量つき)。これまでは右端が黙って切れていた
|
|
43
|
+
|
|
44
|
+
### 修正
|
|
45
|
+
|
|
46
|
+
- **親文書の `body` マージンが PDF に持ち込まれ、内容が右へずれて右端が切れていた**。iframe に差し込むリセットは収集したスタイルより前に置かれるため、ページ側の `body { margin: … }` に負けていた。`!important` で確実に打ち消すようにした(用紙の余白は `options.page.margin` が受け持つ)
|
|
47
|
+
- `examples/cdn.html` の `#receipt` に `box-sizing: border-box` が無く、`padding` と `border` の分だけ右端が切れていた
|
|
48
|
+
|
|
49
|
+
### ドキュメント
|
|
50
|
+
|
|
51
|
+
- CDN から読み込む使い方を追加(README / API リファレンス / サイトのクイックスタート / skill)。`dist/` の minify 済みファイルは依存ゼロの単一 ESM なので、jsDelivr や unpkg の URL をそのまま `import` できる
|
|
52
|
+
- `examples/cdn.html` を追加。ファイル 1 つ、ビルドもバンドラーも無しで動く領収証 PDF の例
|
|
53
|
+
- 通常の `<script>` から使う方法(`import * as ReceiptHtmlToPdf` して `window` に載せる)と、モジュールスクリプトの実行順の注意を明記
|
|
54
|
+
|
|
5
55
|
## 0.2.0 — シャドウ DOM 対応(2026-09-20)
|
|
6
56
|
|
|
7
57
|
### 追加
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
**ドキュメント: https://hidemikimura.github.io/receipt-html-to-pdf/** ([デモ](https://hidemikimura.github.io/receipt-html-to-pdf/demo.html) / [API リファレンス](https://hidemikimura.github.io/receipt-html-to-pdf/api.html) / [対応 CSS 一覧](https://hidemikimura.github.io/receipt-html-to-pdf/css.html))
|
|
12
12
|
|
|
13
|
-
> **v0.
|
|
13
|
+
> **v0.3.0** — テキスト・背景・ボーダー・画像・角丸・2D transform・擬似要素・`overflow: hidden`・シャドウ DOM(Web Components)・複数ページに加え、**`linear-gradient`**・**インライン `<svg>` のベクター変換**・**`background-repeat`**・**GSUB の単一置換**・**`break-before/after: avoid`** に対応。長い文書では途中でイベントループへ戻すので画面が固まらず、`onProgress` で進捗を出せる。依存ゼロ、minify バンドルは gzip 26KB。
|
|
14
14
|
> Chromium / Firefox / WebKit の 3 ブラウザで Playwright テスト(テキスト抽出・ページ分割・画素差分)に合格。対応 CSS は [docs/css-support.md](docs/css-support.md)、設計と経緯は [docs/design.md](docs/design.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md)。
|
|
15
15
|
|
|
16
16
|
## 使い方
|
|
@@ -39,9 +39,17 @@ downloadPdf(pdf, 'receipt.pdf');
|
|
|
39
39
|
| `downloadPdf(pdf, filename)` | ブラウザでダウンロードさせる補助 |
|
|
40
40
|
| `listFonts()` / `version` | 登録済みフォントの一覧、ライブラリのバージョン |
|
|
41
41
|
|
|
42
|
-
主なオプション(`ConvertOptions`、型は `types/index.d.ts`): `page: { size, orientation, margin }`、`header` / `footer`(`{{pageNumber}}` `{{totalPages}}`)、`stylesheets: 'inherit' | 'none' | [url または CSS 文字列]`、`mediaPrint`、`fontFallback`、`metadata`、`compress`、`baseUrl`、`onWarning`。
|
|
42
|
+
主なオプション(`ConvertOptions`、型は `types/index.d.ts`): `page: { size, orientation, margin }`、`header` / `footer`(`{{pageNumber}}` `{{totalPages}}`)、`stylesheets: 'inherit' | 'none' | [url または CSS 文字列]`、`mediaPrint`、`fontFallback`、`metadata`、`compress`、`baseUrl`、`onWarning`、`onProgress`。
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
長い文書でも画面が固まらないよう、変換は途中でイベントループへ戻る。進捗表示を出すなら `onProgress` を使う。
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
onProgress: (p) => {
|
|
48
|
+
if (p.phase === 'page') setProgress(p.page / p.totalPages);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
サンプル: [`examples/cdn.html`](examples/cdn.html)(CDN から読むだけ、ビルド不要)、[`examples/vanilla.html`](examples/vanilla.html)(`npm run dev` 後に `/examples/vanilla.html`)、[`examples/react.jsx`](examples/react.jsx)、[`examples/lit.js`](examples/lit.js)(シャドウ DOM はそのまま変換できる)。
|
|
45
53
|
|
|
46
54
|
## インストール
|
|
47
55
|
|
|
@@ -51,6 +59,22 @@ npm install @hidemikimura/receipt-html-to-pdf
|
|
|
51
59
|
|
|
52
60
|
`import ... from '@hidemikimura/receipt-html-to-pdf'` でソース(ESM)、`'@hidemikimura/receipt-html-to-pdf/min'` で minify 済み単一ファイル(`npm run build` で生成)を読み込める。
|
|
53
61
|
|
|
62
|
+
### CDN から読み込む(ビルド不要)
|
|
63
|
+
|
|
64
|
+
`dist/` の minify 済みファイルは依存ゼロの単一 ESM なので、CDN の URL をそのまま `import` できる。npm もバンドラーも要らない。
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<script type="module">
|
|
68
|
+
import { registerFont, htmlToPdf, downloadPdf }
|
|
69
|
+
from 'https://cdn.jsdelivr.net/npm/@hidemikimura/receipt-html-to-pdf@0.3.0/dist/receipt-html-to-pdf.min.js';
|
|
70
|
+
|
|
71
|
+
await registerFont({ family: 'BIZ UDPGothic', src: '/fonts/BIZUDPGothic-Regular.ttf' });
|
|
72
|
+
downloadPdf(await htmlToPdf(document.querySelector('#receipt')), 'receipt.pdf');
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
バージョン(`@0.3.0`)は固定すること。unpkg でも同じ。グローバル変数を配るビルド(IIFE / UMD)は用意していないが、`import * as ReceiptHtmlToPdf` して `window` に載せれば `type="module"` でない普通のスクリプトからも呼べる。ファイル 1 つで動く一式は [`examples/cdn.html`](examples/cdn.html)。
|
|
77
|
+
|
|
54
78
|
## 開発
|
|
55
79
|
|
|
56
80
|
```sh
|
|
@@ -77,15 +101,15 @@ brew install qpdf # 任意: 生成 PDF の構造
|
|
|
77
101
|
|
|
78
102
|
CI(`.github/workflows/ci.yml`)は typecheck → 単体テスト → サイズ検査の後、3 ブラウザ並列でブラウザテストを流し、生成された PDF を `qpdf --check` で検証する。
|
|
79
103
|
|
|
80
|
-
## 対応範囲(v0.
|
|
104
|
+
## 対応範囲(v0.3.0)
|
|
81
105
|
|
|
82
106
|
| 対応 | 未対応(onWarning で通知) |
|
|
83
107
|
|---|---|
|
|
84
|
-
| テキスト(日本語・サブセット埋め込み・ToUnicode)、`color`、`opacity`、`text-decoration` | `box-shadow`、`text-shadow`、`filter`、`clip-path`、`outline
|
|
85
|
-
| `background-color`、`border-*`(solid / dashed / dotted、辺ごと)、`border-collapse`、`border-radius` | 非均一ボーダー +
|
|
86
|
-
| `<img>`(PNG 透過 / JPEG、`object-fit`)、`background-image: url()`(size / position)、`overflow: hidden`
|
|
108
|
+
| テキスト(日本語・サブセット埋め込み・ToUnicode)、`color`、`opacity`、`text-decoration`、GSUB の単一置換(`zero`・`jp90` などの異体字・`fwid` / `hwid`・`smcp`) | `box-shadow`、`text-shadow`、`filter`、`clip-path`、`outline`、縦書き、合字(`liga` / `dlig`) |
|
|
109
|
+
| `background-color`、`background-image: linear-gradient()`(軸シェーディングでベクター出力)、`background-repeat`(`repeat` / `-x` / `-y` / `space` / `round`)、`border-*`(solid / dashed / dotted、辺ごと)、`border-collapse`、`border-radius` | 非均一ボーダー + 角丸(直線で近似)、`repeating-` / `radial-` / `conic-gradient` |
|
|
110
|
+
| `<img>`(PNG 透過 / JPEG、`object-fit`)、`background-image: url()`(size / position)、`overflow: hidden` のクリップ、**インライン `<svg>` のベクター変換**(パス・基本図形・塗り・線・破線・変換行列) | SVG の `<text>` / `<use>` / paint server(警告)、`<img src="x.svg">` はラスタライズ |
|
|
87
111
|
| `transform`(2D、`transform-origin`)、`::before` / `::after`(文字列 content) | 3D transform、`counter()` / `url()` content |
|
|
88
|
-
| 複数ページ: 行・`tr`・`thead`・`tfoot`・`<img>`・`break-inside: avoid` を跨がない分割、`break-before/after: page`、`thead` / `tfoot` の各ページ繰り返し、`header` / `footer` テンプレート(`{{pageNumber}}` `{{totalPages}}`) | `
|
|
112
|
+
| 複数ページ: 行・`tr`・`thead`・`tfoot`・`<img>`・`break-inside: avoid` を跨がない分割、`break-before/after: page`、`break-before/after: avoid`(隣の箱と同じページに保つ)、`thead` / `tfoot` の各ページ繰り返し、`header` / `footer` テンプレート(`{{pageNumber}}` `{{totalPages}}`) | `orphans` / `widows`、ページ番号による高さ変化 |
|
|
89
113
|
| Web Components: シャドウ DOM のホスト要素をそのまま変換(宣言的シャドウ DOM で直列化)、`<slot>` の割り当て、`:host` / `::slotted()`、`adoptedStyleSheets`、`:defined` | `closed` なシャドウルート、`Element.getHTML()` の無いブラウザ(警告して light DOM のみ) |
|
|
90
114
|
| レイアウト全般(Flexbox / Grid / テーブル / 禁則 / letter-spacing)はブラウザ計算をそのまま利用 | |
|
|
91
115
|
|
|
@@ -125,7 +149,7 @@ npm run site:dev # 組み立てて http://localhost:5174 で表示
|
|
|
125
149
|
2. `npm run pack:check` で tarball の内容を確認する(`files` で許可リスト管理。フォント・フィクスチャ・テストは含まれない)
|
|
126
150
|
3. `npm login`(スコープ `@hidemikimura` の所有者アカウント)
|
|
127
151
|
4. `npm publish` — `prepublishOnly` が typecheck → 単体テスト → `.d.ts` 生成 → minify ビルド + サイズ検査を自動で流す。`publishConfig.access` が `public` なのでスコープ付きでも無料で公開される
|
|
128
|
-
5. `git tag v0.
|
|
152
|
+
5. `git tag v0.3.0 && git push --tags`
|
|
129
153
|
|
|
130
154
|
## ライセンス
|
|
131
155
|
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/* @hidemikimura/receipt-html-to-pdf v0.
|
|
2
|
-
function
|
|
1
|
+
/* @hidemikimura/receipt-html-to-pdf v0.3.0 | MIT */
|
|
2
|
+
function Wt(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength),s=n.getUint32(0);if(s===1330926671)throw new Error("CFF outlines (OpenType/CFF) are not supported. Use a TrueType (glyf) font.");if(s===2001684038||s===2001684018)throw new Error("WOFF/WOFF2 are not supported. Use a raw .ttf file.");if(s===1953784678)throw new Error("TrueType collections (.ttc) are not supported. Extract a single face first.");if(s!==65536&&s!==1953658213)throw new Error("Not a TrueType font (bad sfnt version)");let o=n.getUint16(4),r=new Map;for(let w=0;w<o;w++){let S=12+w*16,k=String.fromCharCode(t[S]??0,t[S+1]??0,t[S+2]??0,t[S+3]??0);r.set(k,{offset:n.getUint32(S+8),length:n.getUint32(S+12)})}if(r.has("CFF "))throw new Error("CFF outlines are not supported. Use a TrueType (glyf) font.");let i=r.has("fvar");for(let w of["head","hhea","maxp","hmtx","loca","glyf"])if(!r.has(w))throw new Error(`Font is missing required table: ${w}`);let c=w=>r.get(w),a=c("head"),f=n.getUint16(a.offset+18),m=[n.getInt16(a.offset+36),n.getInt16(a.offset+38),n.getInt16(a.offset+40),n.getInt16(a.offset+42)],l=n.getUint16(a.offset+44),d=n.getInt16(a.offset+50),g=c("hhea"),b=n.getInt16(g.offset+4),p=n.getInt16(g.offset+6),C=n.getInt16(g.offset+8),F=n.getUint16(g.offset+34),T=n.getUint16(c("maxp").offset+4),v=c("hmtx"),I=new Uint16Array(T),W=0;for(let w=0;w<T;w++)w<F&&(W=n.getUint16(v.offset+w*4)),I[w]=W;let q=c("loca"),G=new Uint32Array(T+1);for(let w=0;w<=T;w++)G[w]=d===0?n.getUint16(q.offset+w*2)*2:n.getUint32(q.offset+w*4);let Q=r.get("cmap"),O=Q?Ee(n,Q.offset):new Map,R=Math.round(b*.7),X=!1,Y=b,et=p,ot=b,L=-p,M=(l&1)!==0,P=(l&2)!==0,u=r.get("OS/2");if(u){let w=n.getUint16(u.offset),S=n.getUint16(u.offset+62);if(X=(S&128)!==0,M=M||(S&32)!==0,P=P||(S&1)!==0,Y=n.getInt16(u.offset+68),et=n.getInt16(u.offset+70),ot=n.getUint16(u.offset+74),L=n.getUint16(u.offset+76),w>=2&&u.length>=90){let k=n.getInt16(u.offset+88);k>0&&(R=k)}}let h=0,y=r.get("post");y&&(h=n.getInt32(y.offset+4)/65536);let x=Ae(n,t,r.get("name"))??"Embedded";return{data:t,tables:r,unitsPerEm:f,indexToLocFormat:d,bbox:m,ascender:b,descender:p,lineGap:C,numGlyphs:T,advances:I,loca:G,cmap:O,capHeight:R,italicAngle:h,useTypoMetrics:X,typoAscender:Y,typoDescender:et,winAscent:ot,winDescent:L,postScriptName:x,bold:M,italic:P,variable:i}}function Ee(e,t){let n=e.getUint16(t+2),s=-1,o=-1;for(let c=0;c<n;c++){let a=t+4+c*8,f=e.getUint16(a),m=e.getUint16(a+2),l=e.getUint32(a+4),d=e.getUint16(t+l),g=-1;f===3&&m===10&&d===12?g=4:f===0&&(m===4||m===6)&&d===12?g=3:f===3&&m===1&&d===4?g=2:f===0&&d===4&&(g=1),g>o&&(o=g,s=t+l)}if(s<0)throw new Error("Font has no usable Unicode cmap subtable (format 4 or 12)");let r=new Map,i=e.getUint16(s);if(i===4){let c=e.getUint16(s+6),a=c/2,f=s+14,m=f+c+2,l=m+c,d=l+c;for(let g=0;g<a;g++){let b=e.getUint16(f+g*2),p=e.getUint16(m+g*2),C=e.getInt16(l+g*2),F=e.getUint16(d+g*2);if(p!==65535)for(let T=p;T<=b;T++){let v;if(F===0)v=T+C&65535;else{let I=d+g*2+F+(T-p)*2;if(I+2>e.byteLength)continue;v=e.getUint16(I),v!==0&&(v=v+C&65535)}v!==0&&r.set(T,v)}}}else if(i===12){let c=e.getUint32(s+12),a=s+16;for(let f=0;f<c;f++,a+=12){let m=e.getUint32(a),l=e.getUint32(a+4),d=e.getUint32(a+8);for(let g=m;g<=l&&g-m<65536;g++){let b=d+(g-m);b!==0&&r.set(g,b)}}}return r}function Ae(e,t,n){if(!n)return null;let s=e.getUint16(n.offset+2),o=e.getUint16(n.offset+4),r=null;for(let i=0;i<s;i++){let c=n.offset+6+i*12,a=e.getUint16(c),f=e.getUint16(c+6),m=e.getUint16(c+8),l=e.getUint16(c+10);if(f!==6)continue;let d=n.offset+o+l;if(a===1)return zt(String.fromCharCode(...t.subarray(d,d+m)));if(a===3||a===0){let g="";for(let b=0;b+1<m;b+=2)g+=String.fromCharCode(e.getUint16(d+b));r=zt(g)}}return r}function zt(e){return e.replace(/[^\x21-\x7e]/g,"").replace(/[\[\]\(\)\{\}<>\/%#]/g,"")||"Embedded"}function Pt(e,t){let n=e.tables.get("glyf"),s=e.loca[t]??0,o=e.loca[t+1]??s;return e.data.subarray(n.offset+s,n.offset+o)}function qt(e){if(e.length<10)return[];let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getInt16(0)>=0)return[];let s=[],o=10;for(;;){let r=t.getUint16(o),i=t.getUint16(o+2);if(s.push(i),o+=4,o+=r&1?4:2,r&8?o+=2:r&64?o+=4:r&128&&(o+=8),!(r&32)||o>=e.length)break}return s}var yt=class{constructor(){this.fonts=[]}async register(t){let n=await Ie(t.src),s=Wt(n),o={family:Et(t.family),displayFamily:t.family,weight:t.weight??400,style:t.style??"normal",parsed:s},r=this.fonts.findIndex(i=>i.family===o.family&&i.weight===o.weight&&i.style===o.style);return r>=0?this.fonts[r]=o:this.fonts.push(o),o}hasFamily(t){let n=Et(t);return this.fonts.some(s=>s.family===n)}match(t,n,s,o){for(let r of t){let i=Et(r),c=this.fonts.filter(a=>a.family===i);if(o!==void 0&&(c=c.filter(a=>a.parsed.cmap.has(o))),!!c.length)return Ht(c,n,s)}return null}anyWithGlyph(t,n,s){let o=this.fonts.filter(r=>r.parsed.cmap.has(t));return o.length?Ht(o,n,s):null}};function Ht(e,t,n){let s=e.filter(f=>f.style===n),o=s.length?s:e,r=o.find(f=>f.weight===t);if(r)return r;let i=[...o].sort((f,m)=>f.weight-m.weight),c=i.filter(f=>f.weight>t),a=i.filter(f=>f.weight<t).reverse();if(t>=400&&t<=500){let f=c.find(m=>m.weight<=500);return f||(a.length?a[0]:c[0])}return t<400?a[0]??c[0]:c[0]??a[0]}function Et(e){return e.trim().replace(/^["']|["']$/g,"").trim().toLowerCase()}function Vt(e){let t=[],n="",s="";for(let o of e)s?o===s?s="":n+=o:o==='"'||o==="'"?s=o:o===","?(n.trim()&&t.push(n.trim()),n=""):n+=o;return n.trim()&&t.push(n.trim()),t}function _t(e){if(e==="bold")return 700;if(e==="normal")return 400;let t=parseInt(e,10);return Number.isFinite(t)?t:400}async function Ie(e){if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);let t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch font ${e}: ${t.status} ${t.statusText}`);return new Uint8Array(await t.arrayBuffer())}async function It(e,t){let n=document.createElement("iframe");n.setAttribute("aria-hidden","true"),n.style.cssText=`position:fixed;left:-100000px;top:0;width:${t.widthPx}px;height:1000px;border:0;visibility:hidden;pointer-events:none;`,document.body.appendChild(n);let s=n.contentWindow,o=n.contentDocument;if(!s||!o)throw new Error("Failed to create rendering iframe");let r=Ne(e,t);o.open(),o.write(r),o.close(),je(o,s);let i=()=>{n.style.height=`${Math.max(o.documentElement.scrollHeight,o.body.scrollHeight,100)}px`};return i(),await ze(o),i(),await We(o),await qe(o),He(o,t.warn??(()=>{})),i(),o.body.offsetHeight,Le(o,t.widthPx,t.warn??(()=>{})),{iframe:n,doc:o,win:s,root:o.body,destroy:()=>n.remove()}}function Ne(e,t){let n=t.baseUrl??document.baseURI,s=`<base href="${gt(n)}">`,o="<style data-rhtp-reset>html,body{margin:0 !important;padding:0 !important;background:transparent}html{-webkit-text-size-adjust:100%}</style>";if(typeof e=="string"){if(/<html[\s>]/i.test(e)){let m=e;return m=/<head[^>]*>/i.test(m)?m.replace(/<head[^>]*>/i,l=>`${l}${s}${o}`):m.replace(/<html[^>]*>/i,l=>`${l}<head>${s}${o}</head>`),t.mediaPrint?Ge(m):m}let f=Xt(t.stylesheets,t.mediaPrint);return`<!DOCTYPE html><html><head><meta charset="utf-8">${s}${o}${f}</head><body>${e}</body></html>`}let r=Xt(t.stylesheets,t.mediaPrint)+Re(e,t.stylesheets,t.mediaPrint),i=At(document.documentElement),c=At(document.body),a=Oe(e,t.warn??(()=>{}));return`<!DOCTYPE html><html${i}><head><meta charset="utf-8">${s}${o}${r}</head><body${c}>${a}</body></html>`}function Xt(e,t){if(e==="none")return"";let n=[];if(e==="inherit"){for(let o of document.querySelectorAll('style, link[rel~="stylesheet"]'))if(!o.hasAttribute("data-rhtp-reset"))if(o instanceof HTMLStyleElement){let r=o.textContent??"";n.push(`<style>${t?pt(r):r}</style>`)}else o instanceof HTMLLinkElement&&n.push(`<link rel="stylesheet" href="${gt(o.href)}"${o.media?` media="${gt(o.media)}"`:""}>`);let s=Nt(document.adoptedStyleSheets);return s&&n.push(`<style>${t?pt(s):s}</style>`),n.join("")}for(let s of e)/^(https?:)?\/\/|^\.{0,2}\/|\.css(\?|$)/i.test(s)&&!s.includes("{")?n.push(`<link rel="stylesheet" href="${gt(s)}">`):n.push(`<style>${t?pt(s):s}</style>`);return n.join("")}function Re(e,t,n){if(t!=="inherit")return"";let s=[],o=e.getRootNode();for(;o&&o!==document&&"host"in o;){let r=o,i=[...r.querySelectorAll("style")].map(c=>c.textContent??"").join(`
|
|
3
3
|
`)+`
|
|
4
|
-
`+
|
|
5
|
-
`)}function he(e,t){let n=t.customElements,s=t.HTMLElement;if(!n||!s)return;let o=new Set,r=i=>{for(let a of i.querySelectorAll("*"))a.tagName.includes("-")&&!a.hasAttribute("is")&&o.add(a.tagName.toLowerCase()),a.shadowRoot&&r(a.shadowRoot)};r(e);for(let i of o)if(!n.get(i))try{n.define(i,class extends s{})}catch{}}function de(e){return e.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(t,n,s)=>`<style${n}>${ot(s)}</style>`)}function ot(e){let t="",n=0;for(;n<e.length;){let s=/@media\s*([^{]+)\{/g;s.lastIndex=n;let o=s.exec(e);if(!o){t+=e.slice(n);break}t+=e.slice(n,o.index);let r=1,i=s.lastIndex;for(;i<e.length&&r>0;)e[i]==="{"?r++:e[i]==="}"&&r--,i++;let a=o[1].trim(),c=e.slice(s.lastIndex,i-1);/\bprint\b/.test(a)?t+=c:/^\s*(only\s+)?screen\b/.test(a)&&!/\band\b/.test(a)?t+="":t+=e.slice(o.index,i),n=i}return t}function xt(e){let t="";for(let n of e.attributes)/^on/i.test(n.name)||(t+=` ${n.name}="${it(n.value)}"`);return t}function it(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}async function ue(e){let t=[...e.querySelectorAll('link[rel~="stylesheet"]')];await Promise.all(t.map(n=>new Promise(s=>{let o=n;if(o.sheet)return s(void 0);o.addEventListener("load",()=>s(void 0),{once:!0}),o.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}async function pe(e){if(e.body.offsetHeight,e.fonts){await e.fonts.ready;let t=[...e.fonts].filter(n=>n.status==="loading").map(n=>n.loaded.catch(()=>{}));t.length&&await Promise.all(t),await e.fonts.ready}}async function me(e){let t=[...e.images];await Promise.all(t.map(n=>n.complete?n.decode().catch(()=>{}):new Promise(s=>{n.addEventListener("load",()=>n.decode().catch(()=>{}).then(s),{once:!0}),n.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}function ge(e,t){let n=e.defaultView;if(!n)return;let s=[];for(let i of ye(e.body))for(let a of["before","after"]){let c=n.getComputedStyle(i,`::${a}`),h=c.content;if(!h||h==="none"||h==="normal"||c.display==="none")continue;let p=be(h);if(p===null){t({code:"unsupported-css",message:`::${a} content "${h}" is not supported (only quoted strings are); the pseudo-element is skipped`,element:i,property:"content"});continue}let f=[];for(let d=0;d<c.length;d++){let u=c[d];u==="content"||u.startsWith("-webkit-")||u.startsWith("-moz-")||f.push([u,c.getPropertyValue(u)])}s.push({el:i,pseudo:a,text:p,styles:f})}if(!s.length)return;let o='[data-rhtp-pseudo-host~="before"]::before{content:none!important;display:none!important}[data-rhtp-pseudo-host~="after"]::after{content:none!important;display:none!important}',r=e.createElement("style");r.setAttribute("data-rhtp-pseudo",""),r.textContent=o,e.head.appendChild(r);for(let i of new Set(s.map(a=>a.el.getRootNode()).filter(a=>a!==e))){let a=e.createElement("style");a.setAttribute("data-rhtp-pseudo",""),a.textContent=o,i.appendChild(a)}for(let i of s){let a=e.createElement("span");a.setAttribute("data-rhtp-pseudo",i.pseudo);for(let[h,p]of i.styles)a.style.setProperty(h,p);a.textContent=i.text;let c=(i.el.getAttribute("data-rhtp-pseudo-host")??"").split(" ").filter(Boolean);c.push(i.pseudo),i.el.setAttribute("data-rhtp-pseudo-host",c.join(" ")),i.pseudo==="before"?i.el.insertBefore(a,i.el.firstChild):i.el.appendChild(a)}}function ye(e){let t=[],n=s=>{for(let o of s.querySelectorAll("*"))t.push(o),o.shadowRoot&&n(o.shadowRoot)};return n(e),t}function be(e){let t="",n=0,s=e.trim();for(;n<s.length;){let o=s[n];if(o===" "||o===" "){n++;continue}if(o!=='"'&&o!=="'")return null;let r=o;for(n++;n<s.length&&s[n]!==r;)if(s[n]==="\\"){n++;let i=/^[0-9a-fA-F]{1,6}/.exec(s.slice(n));i?(t+=String.fromCodePoint(parseInt(i[0],16)),n+=i[0].length,s[n]===" "&&n++):(t+=s[n]??"",n++)}else t+=s[n],n++;n++}return t}var _=2.834645669291339,$t={A3:{width:297*_,height:420*_},A4:{width:210*_,height:297*_},A5:{width:148*_,height:210*_},B4:{width:257*_,height:364*_},B5:{width:182*_,height:257*_},Letter:{width:612,height:792},Legal:{width:612,height:1008}};function Y(e){if(typeof e=="number")return e*.75;let t=/^\s*(-?[\d.]+)\s*([a-z%]*)\s*$/i.exec(e);if(!t)throw new Error(`Invalid CSS length: ${e}`);let n=parseFloat(t[1]);switch((t[2]??"").toLowerCase()){case"":case"px":return n*.75;case"pt":return n;case"mm":return n*_;case"cm":return n*_*10;case"in":return n*72;case"pc":return n*12;default:throw new Error(`Unsupported CSS unit: ${e}`)}}function q(e){let t=parseFloat(e);return Number.isFinite(t)?t:0}function st(e){if(!e)return null;let t=e.trim();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=/^rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(t);if(n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:tt(parseFloat(n[1])/255),g:tt(parseFloat(n[2])/255),b:tt(parseFloat(n[3])/255),a:tt(s)}}if(n=/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*(?:\/\s*([\d.]+%?)\s*)?\)$/i.exec(t),n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:tt(parseFloat(n[1])),g:tt(parseFloat(n[2])),b:tt(parseFloat(n[3])),a:tt(s)}}if(n=/^#([0-9a-f]{3,8})$/i.exec(t),n){let s=n[1];(s.length===3||s.length===4)&&(s=s.split("").map(r=>r+r).join(""));let o=parseInt(s.padEnd(8,"f"),16);return{r:(o>>>24&255)/255,g:(o>>>16&255)/255,b:(o>>>8&255)/255,a:(o&255)/255}}return null}function tt(e){return e<0?0:e>1?1:e}function U(e){if(!Number.isFinite(e))return"0";let t=e.toFixed(3),n=t.includes(".")?t.replace(/\.?0+$/,""):t;return n===""||n==="-0"||n==="-"?"0":n}var we=new Set([32,9,10,13,12,160,12288,8194,8195,8201,8202,8239,8287]);function Ot(e,t,n){let s=e.ownerDocument,o=Te(e.data,t.textTransform),r=s.createRange(),i=$e(s,t),a=[],c=null,h=NaN,p=new Set;for(let f=0;f<o.length;){let d=o.codePointAt(f),u=d>65535?2:1,w=f+u;r.setStart(e,f),r.setEnd(e,Math.min(w,e.data.length));let y=xe(r.getClientRects());if(f=w,!y)continue;let C=Se(d,n,p);if(!C)continue;let{font:O,gid:R,cpForUnicode:D}=C,L=y.top;(!c||c.font!==O||Math.abs(L-h)>.5)&&(c={font:O,baseline:L+i,top:L,bottom:y.bottom,glyphs:[]},h=L,a.push(c)),c.top=Math.min(c.top,L),c.bottom=Math.max(c.bottom,y.bottom);let j=(O.parsed.advances[R]??0)*n.size/O.parsed.unitsPerEm;c.glyphs.push({gid:R,cp:D,x:y.left,advance:j})}return a}function xe(e){let t=null;for(let n of e)n.width>.01&&(!t||n.width>t.width)&&(t=n);return t}function Se(e,t,n){let s=(i,a)=>{let c=i?.parsed.cmap.get(a);return i&&c?{font:i,gid:c,cpForUnicode:e}:null};if(we.has(e))return s(t.primary,e)??s(t.primary,32)??s(t.registry.anyWithGlyph(32,t.weight,t.fstyle),32);let o=s(t.primary,e);if(o||(o=s(t.registry.match(t.families,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.match(t.fallback,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.anyWithGlyph(e,t.weight,t.fstyle),e),o))return o;n.has(e)||(n.add(e),t.warn({code:"missing-glyph",message:`No registered font has a glyph for U+${e.toString(16).toUpperCase().padStart(4,"0")} "${String.fromCodePoint(e)}"; substituted with U+25A1`,element:t.element,text:String.fromCodePoint(e)}));let r=s(t.primary,9633)??s(t.registry.anyWithGlyph(9633,t.weight,t.fstyle),9633);return r?{...r,cpForUnicode:e}:null}function Te(e,t){if(!t||t==="none")return e;let n=e;return t.includes("uppercase")?n=e.toUpperCase():t.includes("lowercase")?n=e.toLowerCase():t.includes("capitalize")&&(n=e.replace(new RegExp("(^|\\s)(\\p{L})","gu"),(s,o,r)=>o+r.toUpperCase())),n.length===e.length?n:e}var Dt=new WeakMap;function $e(e,t){let n=[t.fontFamily,t.fontSize,t.fontWeight,t.fontStyle,t.fontStretch,t.fontVariant,t.fontFeatureSettings].join("|"),s=Dt.get(e);s||(s=new Map,Dt.set(e,s));let o=s.get(n);if(o!==void 0)return o;let r=e.createElement("div");r.setAttribute("data-rhtp-probe",""),r.style.cssText="position:absolute;left:0;top:0;visibility:hidden;white-space:pre;line-height:normal;margin:0;padding:0;border:0;letter-spacing:0;text-indent:0;",r.style.fontFamily=t.fontFamily,r.style.fontSize=t.fontSize,r.style.fontWeight=t.fontWeight,r.style.fontStyle=t.fontStyle,r.style.fontStretch=t.fontStretch,r.style.fontVariant=t.fontVariant,r.style.fontFeatureSettings=t.fontFeatureSettings;let i=e.createTextNode("Ag\u3042");r.appendChild(i);let a=e.createElement("span");a.style.cssText="display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0;",r.appendChild(a),e.body.appendChild(r);let c=e.createRange();c.selectNodeContents(i);let h=c.getBoundingClientRect(),f=a.getBoundingClientRect().bottom-h.top;r.remove();let d=Number.isFinite(f)&&f>0?f:parseFloat(t.fontSize)*.8;return s.set(n,d),d}var vt=new Map;function Ct(e,t,n){let s=vt.get(e);return s||(s=Ce(e,t,n).catch(o=>(t({code:"image-failed",message:`Failed to load image ${e}: ${o instanceof Error?o.message:String(o)}`,element:n}),null)),vt.set(e,s)),s}async function Ce(e,t,n){let s=null;try{let y=await fetch(e,{mode:"cors",credentials:"same-origin"});y.ok&&(s=new Uint8Array(await y.arrayBuffer()))}catch{s=null}if(s&&s[0]===255&&s[1]===216){let y=Fe(s);if(y&&y.components===3)return{key:e,width:y.width,height:y.height,jpeg:s,rgb:null,alpha:null}}let o=new Image;o.crossOrigin="anonymous",o.decoding="sync";let r=new Promise((y,C)=>{o.onload=()=>y(void 0),o.onerror=()=>C(new Error("image failed to load"))});if(s){let y=URL.createObjectURL(new Blob([s]));o.src=y;try{await r}finally{URL.revokeObjectURL(y)}}else o.src=e,await r;let i=o.naturalWidth,a=o.naturalHeight;if(!i||!a)throw new Error("image has no intrinsic size");let c=document.createElement("canvas");c.width=i,c.height=a;let h=c.getContext("2d",{willReadFrequently:!0});if(!h)throw new Error("2D canvas unavailable");h.drawImage(o,0,0);let p;try{p=h.getImageData(0,0,i,a)}catch{return t({code:"image-failed",message:`Image ${e} is cross-origin without CORS headers; add crossorigin="anonymous" and Access-Control-Allow-Origin. Skipped.`,element:n}),null}let f=p.data,d=new Uint8Array(i*a*3),u=new Uint8Array(i*a),w=!0;for(let y=0,C=0,O=0;y<f.length;y+=4,C+=3,O++){let R=f[y+3];R===0?d[C]=d[C+1]=d[C+2]=255:(d[C]=f[y],d[C+1]=f[y+1],d[C+2]=f[y+2]),u[O]=R,R!==255&&(w=!1)}return{key:e,width:i,height:a,jpeg:null,rgb:d,alpha:w?null:u}}function Fe(e){let t=2;for(;t+9<e.length;){if(e[t]!==255){t++;continue}let n=e[t+1];if(n===216||n>=208&&n<=215||n===1||n===255){t+=n===255?1:2;continue}let s=e[t+2]<<8|e[t+3];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207)return{height:e[t+5]<<8|e[t+6],width:e[t+7]<<8|e[t+8],components:e[t+9]};if(n===218)break;t+=2+s}return null}function Nt(e){if(!e||e==="none")return null;let t=Ue(e);if(t.length!==1)return null;let n=/^url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)$/.exec(t[0].trim());return n?n[1]??n[2]??n[3]??null:null}function Ue(e){let t=[],n=0,s="";for(let o of e)o==="("?n++:o===")"&&n--,o===","&&n===0?(t.push(s),s=""):s+=o;return s.trim()&&t.push(s),t}function ft(e,t,n,s,o){let r,i,a=s.trim();if(a==="cover"||a==="contain"){let d=a==="cover"?Math.max(e.w/t,e.h/n):Math.min(e.w/t,e.h/n);r=t*d,i=n*d}else{let[d="auto",u="auto"]=a.split(/\s+/),w=Lt(d,e.w),y=Lt(u,e.h);w===null&&y===null?(r=t,i=n):w===null?(i=y,r=t*i/n):y===null?(r=w,i=n*r/t):(r=w,i=y)}let[c="0%",h="0%"]=o.trim().split(/\s+/),p=e.x+jt(c,e.w-r),f=e.y+jt(h,e.h-i);return{x:p,y:f,w:r,h:i}}function Lt(e,t){return e==="auto"?null:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function jt(e,t){return e==="left"||e==="top"?0:e==="center"?t/2:e==="right"||e==="bottom"?t:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function zt(e){switch(e){case"contain":case"scale-down":return"contain";case"cover":return"cover";case"none":return"auto";default:return"100% 100%"}}var ke=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","HEAD","META","LINK","TITLE","BASE","IFRAME","CANVAS","VIDEO","AUDIO","SVG","OBJECT","EMBED"]);function Ee(e){let t=e.shadowRoot;if(t)return[...t.childNodes];if(e.tagName==="SLOT"){let n=e;if(typeof n.assignedNodes=="function")return n.assignedNodes({flatten:!0})}return[...e.childNodes]}var Pe=[["boxShadow",e=>e!=="none"],["textShadow",e=>e!=="none"],["filter",e=>e!=="none"],["backdropFilter",e=>e!=="none"&&e!==""],["writingMode",e=>e.startsWith("vertical")],["outlineStyle",e=>e!=="none"],["clipPath",e=>e!=="none"],["mixBlendMode",e=>e!=="normal"]];async function Ft(e,t){let n=e.ownerDocument.defaultView,s=n.scrollX,o=n.scrollY,r=[],i=r,a=[],c=[],h=[],p=null,f=0,d=new Set,u=new Set;function w(l,m){d.has(l)||(d.add(l),t.warn(m))}async function y(l,m){if(ke.has(l.tagName))return;let g=n.getComputedStyle(l);if(g.display==="none")return;let x=Ae(g.transform);if(x&&"style"in l){let S=l,F=S.getBoundingClientRect(),E=S.style.transform;S.style.transform="none",S.offsetWidth;let k=S.getBoundingClientRect(),[I,A]=Me(g.transformOrigin),N={x:k.left+I+s,y:k.top+A+o},W=r;r=[],await O(l,n.getComputedStyle(l),m);let b=r;r=W,S.style.transform=E,S.offsetWidth,r.push({type:"group",matrix:x,origin:N,items:b,top:F.top+o,bottom:F.bottom+o,z:C(g,m.z),seq:f++});return}await O(l,g,m)}function C(l,m){if(l.position!=="static"&&l.zIndex!=="auto"){let g=parseInt(l.zIndex,10);if(Number.isFinite(g))return g}return m}async function O(l,m,g){let x=C(m,g.z),S=parseFloat(m.opacity),F=g.alpha*(Number.isFinite(S)?S:1),E=m.visibility==="visible"&&F>0;if(m.display!=="contents"&&m.display!=="inline"){let P=l.getBoundingClientRect(),H=P.top+o,K=P.bottom+o;if(P.height>0){let V=m.breakBefore||m.pageBreakBefore,ee=m.breakAfter||m.pageBreakAfter;/^(page|always|left|right|recto|verso)$/.test(V)&&c.push(H),/^(page|always|left|right|recto|verso)$/.test(ee)&&c.push(K);let kt=m.breakInside||m.pageBreakInside;(kt==="avoid"||kt==="avoid-page"||m.display==="table-row"||m.display==="table-header-group"||m.display==="table-footer-group"||l.tagName==="IMG")&&a.push({top:H,bottom:K})}}let k=null;if(m.display==="table"||m.display==="inline-table"){let P=l.getBoundingClientRect();k={top:P.top+o,bottom:P.bottom+o,headTop:0,headBottom:0,headItems:[],footTop:0,footBottom:0,footItems:[]},h.push(k)}let I=p;k&&(p=k);let A=m.display==="table-header-group"&&p&&!p.headItems.length,N=m.display==="table-footer-group"&&p&&!p.footItems.length,W=A||N?r.length:-1,b=m.overflowX!=="visible"||m.overflowY!=="visible",T=null,B=null;if(b&&m.display!=="inline"&&m.display!=="contents"&&l!==e){let P=l.getBoundingClientRect();B=z(P,m,"padding-box",Gt(m,P))}if(E&&m.display!=="contents"){R(l,m);let P=m.display==="inline"?[...l.getClientRects()]:[l.getBoundingClientRect()],H=m.borderCollapse==="collapse"&&/^table/.test(m.display)&&m.display!=="table-caption",K=P.length===1?Gt(m,P[0]):null;for(let V of P)V.width<=0&&V.height<=0||(D(V,m,F,x,K),await L(l,V,m,F,x,K),X(V,m,F,x,H,K));l.tagName==="IMG"&&P[0]&&await j(l,P[0],m,F,x,K)}let v=g.decorations,G=m.textDecorationLine;if(G&&G!=="none"){let P=st(m.textDecorationColor)??st(m.color)??{r:0,g:0,b:0,a:1};v=[...v,{line:G,color:P}]}B&&(T=r,r=[]);let Z={z:x,alpha:F,decorations:v};for(let P of Ee(l))P.nodeType===Node.TEXT_NODE?E&&et(P,l,m,Z):P.nodeType===Node.ELEMENT_NODE&&await y(P,Z);if(B&&T){let P=r.filter(H=>Ie(H,B));r=T,P.length&&r.push({type:"clip",box:B,items:P,top:B.y,bottom:B.y+B.h,z:x,seq:f++})}if((A||N)&&p&&W>=0){let P=l.getBoundingClientRect(),H=r.slice(W);A?(p.headTop=P.top+o,p.headBottom=P.bottom+o,p.headItems=H):(p.footTop=P.top+o,p.footBottom=P.bottom+o,p.footItems=H)}p=I}function R(l,m){for(let[g,x]of Pe){let S=String(m[g]??"");x(S)&&w(`css:${g}`,{code:"unsupported-css",message:`CSS property "${Ht(g)}" is not supported in this version and will be ignored (first seen on <${l.tagName.toLowerCase()}>: ${S})`,element:l,property:Ht(g)})}/^matrix3d/.test(m.transform)&&w("css:transform3d",{code:"unsupported-css",message:"3D transforms are not supported; the element is drawn untransformed",element:l,property:"transform"})}function D(l,m,g,x,S){let F=st(m.backgroundColor);if(!F||F.a<=0)return;let E={type:"rect",x:l.left+s,y:l.top+o,w:l.width,h:l.height,color:at(F,g),z:x,seq:f++};S&&(E.radius=S),r.push(E)}async function L(l,m,g,x,S,F){if(g.backgroundImage==="none")return;let E=Nt(g.backgroundImage);if(!E){w("css:backgroundImage",{code:"unsupported-css",message:`background-image "${g.backgroundImage}" is not supported (only a single url() is); ignored`,element:l,property:"background-image"});return}let k=await Ct(new URL(E,l.ownerDocument.baseURI).href,t.warn,l);if(!k)return;g.backgroundRepeat!=="no-repeat"&&w("css:backgroundRepeat",{code:"unsupported-css",message:`background-repeat "${g.backgroundRepeat}" is not supported; drawn once as no-repeat`,element:l,property:"background-repeat"});let I=z(m,g,g.backgroundClip||"border-box",F),A=z(m,g,g.backgroundOrigin||"padding-box",null),N=ft(A,k.width,k.height,g.backgroundSize,g.backgroundPosition);r.push({type:"image",...N,image:k,clip:I,alpha:x,z:S,seq:f++})}async function j(l,m,g,x,S,F){let E=l.currentSrc||l.src;if(!E)return;let k=await Ct(E,t.warn,l);if(!k)return;let I=z(m,g,"content-box",F),A=ft(I,k.width,k.height,zt(g.objectFit),g.objectPosition);g.objectFit==="scale-down"&&(A.w>k.width||A.h>k.height)&&Object.assign(A,ft(I,k.width,k.height,"auto",g.objectPosition)),r.push({type:"image",...A,image:k,clip:I,alpha:x,z:S,seq:f++})}function z(l,m,g,x){let S=l.left+s,F=l.top+o,E=l.width,k=l.height;if(g==="padding-box"||g==="content-box"){let A=q(m.borderTopWidth),N=q(m.borderRightWidth),W=q(m.borderBottomWidth),b=q(m.borderLeftWidth);S+=b,F+=A,E-=b+N,k-=A+W,x&&(x=x.map(T=>Math.max(0,T-Math.max(A,N,W,b))))}if(g==="content-box"){let A=q(m.paddingTop),N=q(m.paddingRight),W=q(m.paddingBottom),b=q(m.paddingLeft);S+=b,F+=A,E-=b+N,k-=A+W}let I={x:S,y:F,w:Math.max(0,E),h:Math.max(0,k)};return x&&x.some(A=>A>0)&&(I.radius=x),I}function X(l,m,g,x,S,F){let E=l.left+s,k=l.top+o,I=l.width,A=l.height,b=["Top","Right","Bottom","Left"].map(T=>({side:T,width:q(m[`border${T}Width`]),style:m[`border${T}Style`],color:st(m[`border${T}Color`])})).filter(T=>T.width>0&&T.style!=="none"&&T.style!=="hidden"&&T.color&&T.color.a>0);if(b.length){if(F&&F.some(T=>T>0)){let T=b[0];if(b.length===4&&b.every(v=>v.width===T.width&&v.style===T.style&&JSON.stringify(v.color)===JSON.stringify(T.color))){let v=T.width;r.push({type:"stroke-rrect",x:E+v/2,y:k+v/2,w:I-v,h:A-v,radius:F.map(G=>Math.max(0,G-v/2)),width:v,color:at(T.color,g),dash:Wt(T.style,v),z:x,seq:f++});return}w("css:borderRadiusNonUniform",{code:"unsupported-css",message:"border-radius with non-uniform borders is approximated with straight borders",property:"border-radius"})}for(let T of b){let B=T.width,v=at(T.color,g),G=T.side==="Top"||T.side==="Bottom",Z=T.side==="Top"||T.side==="Left"?1:-1,P=T.side==="Top"?k:T.side==="Bottom"?k+A:T.side==="Left"?E:E+I,H=Wt(T.style,B);if(H){let V=S?P:P+B/2*Z;r.push({type:"line",x1:G?E:V,y1:G?V:k,x2:G?E+I:V,y2:G?V:k+A,width:B,color:v,dash:H,z:x,seq:f++});continue}let K=S?P-B/2:Z>0?P:P-B;G?r.push({type:"rect",x:E,y:K,w:I,h:B,color:v,z:x,seq:f++}):r.push({type:"rect",x:K,y:k,w:B,h:A,color:v,z:x,seq:f++})}}}function et(l,m,g,x){let S=l.data;if(!S)return;if(!/\S/.test(S)&&!S.includes("\xA0")){let b=l.ownerDocument.createRange();if(b.selectNodeContents(l),![...b.getClientRects()].some(T=>T.width>0))return}let F=at(st(g.color)??{r:0,g:0,b:0,a:1},x.alpha),E=q(g.fontSize);if(E<=0)return;let k=It(g.fontFamily),I=Rt(g.fontWeight),A=g.fontStyle==="italic"||g.fontStyle==="oblique"?"italic":"normal",N=t.registry.match(k,I,A)??t.registry.match(t.fontFallback,I,A);if(!N){let b=k.join(",");u.has(b)||(u.add(b),t.warn({code:"missing-font",message:`No registered font matches font-family "${g.fontFamily}" and no fallback is available; text will be skipped`,element:m}));return}let W=Ot(l,g,{registry:t.registry,families:k,fallback:t.fontFallback,primary:N,weight:I,fstyle:A,size:E,textMeasure:t.textMeasure,warn:t.warn,element:m});for(let b of W)if(b.glyphs.length){a.push({top:b.top+o,bottom:b.bottom+o}),r.push({type:"text",x:b.glyphs[0]?.x??0,y:b.baseline+o,top:b.top+o,bottom:b.bottom+o,size:E,color:F,font:b.font,glyphs:b.glyphs.map(T=>({...T,x:T.x+s})),z:x.z,seq:f++});for(let T of x.decorations){let B=b.glyphs[0],v=b.glyphs[b.glyphs.length-1];if(!B||!v)continue;let G=B.x+s,Z=v.x+v.advance+s,P=Math.max(1,E/14),H=at(T.color,x.alpha);T.line.includes("underline")&&r.push({type:"rect",x:G,y:b.baseline+o+E*.08,w:Z-G,h:P,color:H,z:x.z,seq:f++}),T.line.includes("line-through")&&r.push({type:"rect",x:G,y:b.baseline+o-E*.3,w:Z-G,h:P,color:H,z:x.z,seq:f++})}}}await y(e,{z:0,alpha:1,decorations:[]}),qt(i);let $=e.getBoundingClientRect().bottom+o;for(let l of i)l.type==="rect"||l.type==="stroke-rrect"||l.type==="image"?$=Math.max($,l.y+l.h):l.type==="line"?$=Math.max($,l.y1,l.y2):(l.type==="text"||l.type==="group"||l.type==="clip")&&($=Math.max($,l.bottom));return{items:i,atoms:a,breaks:c,tables:h,height:$}}function qt(e){e.sort((t,n)=>t.z-n.z||t.seq-n.seq);for(let t of e)(t.type==="group"||t.type==="clip")&&qt(t.items)}function Wt(e,t){return e==="dashed"?[t*3,t*3]:e==="dotted"?[t,t]:null}function Gt(e,t){let n=o=>{let r=o.trim().split(/\s+/)[0]??"0px";return r.endsWith("%")?parseFloat(r)/100*t.width:q(r)},s=[n(e.borderTopLeftRadius),n(e.borderTopRightRadius),n(e.borderBottomRightRadius),n(e.borderBottomLeftRadius)];return s.some(o=>o>0)?s:null}function Ae(e){if(!e||e==="none")return null;let t=/^matrix\(([^)]+)\)$/.exec(e.trim());if(!t)return null;let n=t[1].split(",").map(h=>parseFloat(h));if(n.length!==6||n.some(h=>!Number.isFinite(h)))return null;let[s,o,r,i,a,c]=n;return s===1&&o===0&&r===0&&i===1&&a===0&&c===0?null:[s,o,r,i,a,c]}function Me(e){let t=e.trim().split(/\s+/);return[q(t[0]??"0"),q(t[1]??"0")]}function Ie(e,t){let n,s,o,r;if(e.type==="rect"||e.type==="stroke-rrect"||e.type==="image")n=e.x,s=e.y,o=e.x+e.w,r=e.y+e.h;else if(e.type==="line")n=Math.min(e.x1,e.x2)-e.width,s=Math.min(e.y1,e.y2)-e.width,o=Math.max(e.x1,e.x2)+e.width,r=Math.max(e.y1,e.y2)+e.width;else if(e.type==="text"){let i=e.glyphs[e.glyphs.length-1];n=e.x,s=e.top,o=i?i.x+i.advance:e.x,r=e.bottom}else if(e.type==="clip")n=e.box.x,s=e.box.y,o=e.box.x+e.box.w,r=e.box.y+e.box.h;else return!0;return o>t.x&&n<t.x+t.w&&r>t.y&&s<t.y+t.h}function at(e,t){return t===1?e:{...e,a:e.a*t}}function Ht(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Re(){return typeof CompressionStream=="function"}async function Xt(e){if(!Re())return null;try{let t=new CompressionStream("deflate"),n=t.writable.getWriter();n.write(e),n.close();let s=await new Response(t.readable).arrayBuffer();return new Uint8Array(s)}catch{return null}}var lt=class{constructor(t){this.id=t}toString(){return`${this.id} 0 R`}},J=class{constructor(t){this.name=t}toString(){let t="/";for(let n of this.name){let s=n.charCodeAt(0);if(s<33||s>126||"#/%()<>[]{}".includes(n))for(let o of new TextEncoder().encode(n))t+="#"+o.toString(16).padStart(2,"0");else t+=n}return t}},Q=class{constructor(t){this.text=t}toString(){return this.text}};function nt(e){if(/^[\x20-\x7e]*$/.test(e))return new Q("("+e.replace(/[\\()]/g,n=>"\\"+n)+")");let t="FEFF";for(let n=0;n<e.length;n++)t+=e.charCodeAt(n).toString(16).padStart(4,"0");return new Q("<"+t+">")}function Vt(e){let t=i=>String(i).padStart(2,"0"),n=-e.getTimezoneOffset(),s=n>=0?"+":"-",o=t(Math.floor(Math.abs(n)/60)),r=t(Math.abs(n)%60);return new Q(`(D:${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}${s}${o}'${r}')`)}function ht(e){if(e===null)return"null";if(typeof e=="number")return U(e);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return new J(e).toString();if(e instanceof lt||e instanceof J||e instanceof Q)return e.toString();if(Array.isArray(e))return"["+e.map(ht).join(" ")+"]";let t=[];for(let[n,s]of Object.entries(e))s!==void 0&&t.push(new J(n).toString()+" "+ht(s));return"<< "+t.join(" ")+" >>"}var dt=class{constructor(t={}){this.objects=[null],this.compress=t.compress??!0,this.version=t.version??"1.7"}reserve(){return this.objects.push({value:null}),new lt(this.objects.length-1)}set(t,n,s){this.objects[t.id]={value:n,stream:s}}add(t){let n=this.reserve();return this.set(n,t),n}async addStream(t,n,s={}){let o=this.reserve();return await this.setStream(o,t,n,s),o}async setStream(t,n,s,o={}){let r=s,i={...n};if((o.compress??this.compress)&&!("Filter"in i)){let c=await Xt(s);c&&c.length<s.length&&(r=c,i.Filter="FlateDecode")}i.Length=r.length,this.set(t,i,r)}build(t,n){let s=new TextEncoder,o=[],r=0,i=f=>{let d=typeof f=="string"?s.encode(f):f;o.push(d),r+=d.length};i(ut([s.encode(`%PDF-${this.version}
|
|
4
|
+
`+Nt(r.adoptedStyleSheets);i.trim()&&s.unshift(i),o=r.host.getRootNode()}return s.map(r=>`<style>${n?pt(r):r}</style>`).join("")}function Le(e,t,n){let s=Math.max(e.documentElement.scrollWidth,e.body.scrollWidth),o=s-t;if(o<1)return;let r=i=>Math.round(i/96*25.4*10)/10;n({code:"other",message:`Content is ${Math.round(o)}px (${r(o)}mm) wider than the page content area (${Math.round(s)}px vs ${Math.round(t)}px); the right side will be clipped. Common causes: a fixed width plus padding/border without box-sizing: border-box, or a table that cannot shrink.`})}var ve=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","SOURCE","TRACK","WBR"]);function Oe(e,t){let n=e===document.body||e===document.documentElement,s=De(n?document.body:e);if(!s.length)return n?document.body.innerHTML:e.outerHTML;let o=n?document.body:e;if(typeof o.getHTML!="function")return t({code:"unsupported-css",message:"This browser lacks Element.getHTML(); shadow DOM content cannot be serialized and will be missing from the PDF. Pass an element inside the shadow root instead.",element:e}),n?document.body.innerHTML:e.outerHTML;let r=Be(s);try{let i={serializableShadowRoots:!0,shadowRoots:s},c=o.getHTML(i);if(n)return c;let a=e.tagName.toLowerCase();return ve.has(e.tagName)?e.outerHTML:`<${a}${At(e)}>${c}</${a}>`}finally{r()}}function De(e){let t=[],n=s=>{s instanceof Element&&s.shadowRoot&&(t.push(s.shadowRoot),n(s.shadowRoot));for(let o of s.children)n(o)};return n(e),t}function Be(e){let t=[];for(let n of e){let s=Nt(n.adoptedStyleSheets);if(!s)continue;let o=document.createElement("style");o.setAttribute("data-rhtp-adopted",""),o.textContent=s,n.insertBefore(o,n.firstChild),t.push(o)}return()=>{for(let n of t)n.remove()}}function Nt(e){if(!e||!e.length)return"";let t=[];for(let n of e)try{for(let s of n.cssRules)t.push(s.cssText)}catch{}return t.join(`
|
|
5
|
+
`)}function je(e,t){let n=t.customElements,s=t.HTMLElement;if(!n||!s)return;let o=new Set,r=i=>{for(let c of i.querySelectorAll("*"))c.tagName.includes("-")&&!c.hasAttribute("is")&&o.add(c.tagName.toLowerCase()),c.shadowRoot&&r(c.shadowRoot)};r(e);for(let i of o)if(!n.get(i))try{n.define(i,class extends s{})}catch{}}function Ge(e){return e.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(t,n,s)=>`<style${n}>${pt(s)}</style>`)}function pt(e){let t="",n=0;for(;n<e.length;){let s=/@media\s*([^{]+)\{/g;s.lastIndex=n;let o=s.exec(e);if(!o){t+=e.slice(n);break}t+=e.slice(n,o.index);let r=1,i=s.lastIndex;for(;i<e.length&&r>0;)e[i]==="{"?r++:e[i]==="}"&&r--,i++;let c=o[1].trim(),a=e.slice(s.lastIndex,i-1);/\bprint\b/.test(c)?t+=a:/^\s*(only\s+)?screen\b/.test(c)&&!/\band\b/.test(c)?t+="":t+=e.slice(o.index,i),n=i}return t}function At(e){let t="";for(let n of e.attributes)/^on/i.test(n.name)||(t+=` ${n.name}="${gt(n.value)}"`);return t}function gt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}async function ze(e){let t=[...e.querySelectorAll('link[rel~="stylesheet"]')];await Promise.all(t.map(n=>new Promise(s=>{let o=n;if(o.sheet)return s(void 0);o.addEventListener("load",()=>s(void 0),{once:!0}),o.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}async function We(e){if(e.body.offsetHeight,e.fonts){await e.fonts.ready;let t=[...e.fonts].filter(n=>n.status==="loading").map(n=>n.loaded.catch(()=>{}));t.length&&await Promise.all(t),await e.fonts.ready}}async function qe(e){let t=[...e.images];await Promise.all(t.map(n=>n.complete?n.decode().catch(()=>{}):new Promise(s=>{n.addEventListener("load",()=>n.decode().catch(()=>{}).then(s),{once:!0}),n.addEventListener("error",()=>s(void 0),{once:!0}),setTimeout(()=>s(void 0),1e4)})))}function He(e,t){let n=e.defaultView;if(!n)return;let s=[];for(let i of Ve(e.body))for(let c of["before","after"]){let a=n.getComputedStyle(i,`::${c}`),f=a.content;if(!f||f==="none"||f==="normal"||a.display==="none")continue;let m=_e(f);if(m===null){t({code:"unsupported-css",message:`::${c} content "${f}" is not supported (only quoted strings are); the pseudo-element is skipped`,element:i,property:"content"});continue}let l=[];for(let d=0;d<a.length;d++){let g=a[d];g==="content"||g.startsWith("-webkit-")||g.startsWith("-moz-")||l.push([g,a.getPropertyValue(g)])}s.push({el:i,pseudo:c,text:m,styles:l})}if(!s.length)return;let o='[data-rhtp-pseudo-host~="before"]::before{content:none!important;display:none!important}[data-rhtp-pseudo-host~="after"]::after{content:none!important;display:none!important}',r=e.createElement("style");r.setAttribute("data-rhtp-pseudo",""),r.textContent=o,e.head.appendChild(r);for(let i of new Set(s.map(c=>c.el.getRootNode()).filter(c=>c!==e))){let c=e.createElement("style");c.setAttribute("data-rhtp-pseudo",""),c.textContent=o,i.appendChild(c)}for(let i of s){let c=e.createElement("span");c.setAttribute("data-rhtp-pseudo",i.pseudo);for(let[f,m]of i.styles)c.style.setProperty(f,m);c.textContent=i.text;let a=(i.el.getAttribute("data-rhtp-pseudo-host")??"").split(" ").filter(Boolean);a.push(i.pseudo),i.el.setAttribute("data-rhtp-pseudo-host",a.join(" ")),i.pseudo==="before"?i.el.insertBefore(c,i.el.firstChild):i.el.appendChild(c)}}function Ve(e){let t=[],n=s=>{for(let o of s.querySelectorAll("*"))t.push(o),o.shadowRoot&&n(o.shadowRoot)};return n(e),t}function _e(e){let t="",n=0,s=e.trim();for(;n<s.length;){let o=s[n];if(o===" "||o===" "){n++;continue}if(o!=='"'&&o!=="'")return null;let r=o;for(n++;n<s.length&&s[n]!==r;)if(s[n]==="\\"){n++;let i=/^[0-9a-fA-F]{1,6}/.exec(s.slice(n));i?(t+=String.fromCodePoint(parseInt(i[0],16)),n+=i[0].length,s[n]===" "&&n++):(t+=s[n]??"",n++)}else t+=s[n],n++;n++}return t}var rt=2.834645669291339,Rt={A3:{width:297*rt,height:420*rt},A4:{width:210*rt,height:297*rt},A5:{width:148*rt,height:210*rt},B4:{width:257*rt,height:364*rt},B5:{width:182*rt,height:257*rt},Letter:{width:612,height:792},Legal:{width:612,height:1008}};function it(e){if(typeof e=="number")return e*.75;let t=/^\s*(-?[\d.]+)\s*([a-z%]*)\s*$/i.exec(e);if(!t)throw new Error(`Invalid CSS length: ${e}`);let n=parseFloat(t[1]);switch((t[2]??"").toLowerCase()){case"":case"px":return n*.75;case"pt":return n;case"mm":return n*rt;case"cm":return n*rt*10;case"in":return n*72;case"pc":return n*12;default:throw new Error(`Unsupported CSS unit: ${e}`)}}function J(e){let t=parseFloat(e);return Number.isFinite(t)?t:0}function ct(e){if(!e)return null;let t=e.trim();if(t==="transparent")return{r:0,g:0,b:0,a:0};let n=/^rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i.exec(t);if(n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:ut(parseFloat(n[1])/255),g:ut(parseFloat(n[2])/255),b:ut(parseFloat(n[3])/255),a:ut(s)}}if(n=/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)\s*(?:\/\s*([\d.]+%?)\s*)?\)$/i.exec(t),n){let s=n[4]===void 0?1:n[4].endsWith("%")?parseFloat(n[4])/100:parseFloat(n[4]);return{r:ut(parseFloat(n[1])),g:ut(parseFloat(n[2])),b:ut(parseFloat(n[3])),a:ut(s)}}if(n=/^#([0-9a-f]{3,8})$/i.exec(t),n){let s=n[1];(s.length===3||s.length===4)&&(s=s.split("").map(r=>r+r).join(""));let o=parseInt(s.padEnd(8,"f"),16);return{r:(o>>>24&255)/255,g:(o>>>16&255)/255,b:(o>>>8&255)/255,a:(o&255)/255}}return null}function ut(e){return e<0?0:e>1?1:e}function A(e){if(!Number.isFinite(e))return"0";let t=e.toFixed(3),n=t.includes(".")?t.replace(/\.?0+$/,""):t;return n===""||n==="-0"||n==="-"?"0":n}function Xe(e){let t=e.tables.get("GSUB");if(!t||t.length<10)return null;let n=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),s=t.offset;try{let o=s+n.getUint16(s+6),r=s+n.getUint16(s+8),i=new Map,c=n.getUint16(o);for(let l=0;l<c;l++){let d=o+2+l*6,g=String.fromCharCode(n.getUint8(d),n.getUint8(d+1),n.getUint8(d+2),n.getUint8(d+3)),b=o+n.getUint16(d+4),p=n.getUint16(b+2),C=i.get(g)??[];for(let F=0;F<p;F++)C.push(n.getUint16(b+4+F*2));i.set(g,C)}let a=n.getUint16(r),f=new Map;return{features:i,lookup:l=>{if(f.has(l))return f.get(l)??null;let d=null;if(l>=0&&l<a){let g=r+n.getUint16(r+2+l*2);d=Ye(n,g,n.getUint16(g),n.getUint16(g+4),g+6)}return f.set(l,d),d}}}catch{return null}}function Ye(e,t,n,s,o){if(n!==1&&n!==7)return null;let r=new Map;for(let i=0;i<s;i++){let c=t+e.getUint16(o+i*2);if(n===7){if(e.getUint16(c)!==1||e.getUint16(c+2)!==1)continue;c+=e.getUint32(c+4)}Ze(e,c,r)}return r.size?r:null}function Ze(e,t,n){let s=e.getUint16(t),o=Ke(e,t+e.getUint16(t+2));if(s===1){let r=e.getInt16(t+4);for(let i of o)n.set(i,i+r&65535)}else if(s===2){let r=e.getUint16(t+4);for(let i=0;i<o.length&&i<r;i++)n.set(o[i],e.getUint16(t+6+i*2))}}function Ke(e,t){let n=e.getUint16(t),s=[];if(n===1){let o=e.getUint16(t+2);for(let r=0;r<o;r++)s.push(e.getUint16(t+4+r*2))}else if(n===2){let o=e.getUint16(t+2);for(let r=0;r<o;r++){let i=t+4+r*6,c=e.getUint16(i),a=e.getUint16(i+2),f=e.getUint16(i+4);for(let m=c;m<=a;m++)s[f+(m-c)]=m}}return s}function Yt(e,t){let n=Xe(e);if(!n)return null;let s=[];for(let i of t)for(let c of n.features.get(i)??[])s.includes(c)||s.push(c);if(!s.length)return null;s.sort((i,c)=>i-c);let o=[];for(let i of s){let c=n.lookup(i);c&&o.push(c)}if(!o.length)return null;let r=new Map;return i=>{let c=r.get(i);if(c!==void 0)return c;let a=i;for(let f of o)a=f.get(a)??a;return r.set(i,a),a}}var Qe={"lining-nums":"lnum","oldstyle-nums":"onum","proportional-nums":"pnum","tabular-nums":"tnum","diagonal-fractions":"frac","stacked-fractions":"afrc",ordinal:"ordn","slashed-zero":"zero","small-caps":"smcp","all-small-caps":"c2sc","petite-caps":"pcap","all-petite-caps":"c2pc",unicase:"unic","titling-caps":"titl",jis78:"jp78",jis83:"jp83",jis90:"jp90",jis04:"jp04",simplified:"smpl",traditional:"trad","full-width":"fwid","proportional-width":"pwid",ruby:"ruby"};function Zt(e){let t=new Set,n=`${e.fontVariantNumeric??""} ${e.fontVariantCaps??""} ${e.fontVariantEastAsian??""}`.split(/\s+/);for(let o of n){let r=Qe[o];r&&t.add(r)}let s=e.fontFeatureSettings??"";if(s&&s!=="normal")for(let o of s.split(",")){let r=/^\s*["']([A-Za-z0-9]{4})["']\s*(.*)$/.exec(o);if(!r)continue;let i=r[2].trim();i==="0"||i==="off"||t.add(r[1])}return[...t]}var Je=new Set([32,9,10,13,12,160,12288,8194,8195,8201,8202,8239,8287]);function Jt(e,t,n){let s=e.ownerDocument,o=on(e.data,t.textTransform),r=s.createRange(),i=sn(s,t),c=[],a=null,f=NaN,m=new Set;for(let l=0;l<o.length;){let d=o.codePointAt(l),g=d>65535?2:1,b=l+g;r.setStart(e,l),r.setEnd(e,Math.min(b,e.data.length));let p=en(r.getClientRects());if(l=b,!p)continue;let C=nn(d,n,m);if(!C)continue;let{font:F,gid:T,cpForUnicode:v}=C,I=p.top;(!a||a.font!==F||Math.abs(I-f)>.5)&&(a={font:F,baseline:I+i,top:I,bottom:p.bottom,glyphs:[]},f=I,c.push(a)),a.top=Math.min(a.top,I),a.bottom=Math.max(a.bottom,p.bottom);let W=n.features.length?tn(F.parsed,n.features):null,q=W?W(T):T,G=(F.parsed.advances[q]??0)*n.size/F.parsed.unitsPerEm;a.glyphs.push({gid:q,cp:v,x:p.left,advance:G})}return c}var Kt=new WeakMap;function tn(e,t){let n=Kt.get(e);n||(n=new Map,Kt.set(e,n));let s=[...t].sort().join(",");if(n.has(s))return n.get(s)??null;let o=Yt(e,t);return n.set(s,o),o}function en(e){let t=null;for(let n of e)n.width>.01&&(!t||n.width>t.width)&&(t=n);return t}function nn(e,t,n){let s=(i,c)=>{let a=i?.parsed.cmap.get(c);return i&&a?{font:i,gid:a,cpForUnicode:e}:null};if(Je.has(e))return s(t.primary,e)??s(t.primary,32)??s(t.registry.anyWithGlyph(32,t.weight,t.fstyle),32);let o=s(t.primary,e);if(o||(o=s(t.registry.match(t.families,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.match(t.fallback,t.weight,t.fstyle,e),e),o)||(o=s(t.registry.anyWithGlyph(e,t.weight,t.fstyle),e),o))return o;n.has(e)||(n.add(e),t.warn({code:"missing-glyph",message:`No registered font has a glyph for U+${e.toString(16).toUpperCase().padStart(4,"0")} "${String.fromCodePoint(e)}"; substituted with U+25A1`,element:t.element,text:String.fromCodePoint(e)}));let r=s(t.primary,9633)??s(t.registry.anyWithGlyph(9633,t.weight,t.fstyle),9633);return r?{...r,cpForUnicode:e}:null}function on(e,t){if(!t||t==="none")return e;let n=e;return t.includes("uppercase")?n=e.toUpperCase():t.includes("lowercase")?n=e.toLowerCase():t.includes("capitalize")&&(n=e.replace(new RegExp("(^|\\s)(\\p{L})","gu"),(s,o,r)=>o+r.toUpperCase())),n.length===e.length?n:e}var Qt=new WeakMap;function sn(e,t){let n=[t.fontFamily,t.fontSize,t.fontWeight,t.fontStyle,t.fontStretch,t.fontVariant,t.fontFeatureSettings].join("|"),s=Qt.get(e);s||(s=new Map,Qt.set(e,s));let o=s.get(n);if(o!==void 0)return o;let r=e.createElement("div");r.setAttribute("data-rhtp-probe",""),r.style.cssText="position:absolute;left:0;top:0;visibility:hidden;white-space:pre;line-height:normal;margin:0;padding:0;border:0;letter-spacing:0;text-indent:0;",r.style.fontFamily=t.fontFamily,r.style.fontSize=t.fontSize,r.style.fontWeight=t.fontWeight,r.style.fontStyle=t.fontStyle,r.style.fontStretch=t.fontStretch,r.style.fontVariant=t.fontVariant,r.style.fontFeatureSettings=t.fontFeatureSettings;let i=e.createTextNode("Ag\u3042");r.appendChild(i);let c=e.createElement("span");c.style.cssText="display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0;",r.appendChild(c),e.body.appendChild(r);let a=e.createRange();a.selectNodeContents(i);let f=a.getBoundingClientRect(),l=c.getBoundingClientRect().bottom-f.top;r.remove();let d=Number.isFinite(l)&&l>0?l:parseFloat(t.fontSize)*.8;return s.set(n,d),d}var Lt=new Map;function mt(e,t,n){let s=Lt.get(e);return s||(s=rn(e,t,n).catch(o=>(t({code:"image-failed",message:`Failed to load image ${e}: ${o instanceof Error?o.message:String(o)}`,element:n}),null)),Lt.set(e,s)),s}async function rn(e,t,n){let s=null;try{let p=await fetch(e,{mode:"cors",credentials:"same-origin"});p.ok&&(s=new Uint8Array(await p.arrayBuffer()))}catch{s=null}if(s&&s[0]===255&&s[1]===216){let p=an(s);if(p&&p.components===3)return{key:e,width:p.width,height:p.height,jpeg:s,rgb:null,alpha:null}}let o=new Image;o.crossOrigin="anonymous",o.decoding="sync";let r=new Promise((p,C)=>{o.onload=()=>p(void 0),o.onerror=()=>C(new Error("image failed to load"))});if(s){let p=URL.createObjectURL(new Blob([s]));o.src=p;try{await r}finally{URL.revokeObjectURL(p)}}else o.src=e,await r;let i=o.naturalWidth,c=o.naturalHeight;if(!i||!c)throw new Error("image has no intrinsic size");let a=document.createElement("canvas");a.width=i,a.height=c;let f=a.getContext("2d",{willReadFrequently:!0});if(!f)throw new Error("2D canvas unavailable");f.drawImage(o,0,0);let m;try{m=f.getImageData(0,0,i,c)}catch{return t({code:"image-failed",message:`Image ${e} is cross-origin without CORS headers; add crossorigin="anonymous" and Access-Control-Allow-Origin. Skipped.`,element:n}),null}let l=m.data,d=new Uint8Array(i*c*3),g=new Uint8Array(i*c),b=!0;for(let p=0,C=0,F=0;p<l.length;p+=4,C+=3,F++){let T=l[p+3];T===0?d[C]=d[C+1]=d[C+2]=255:(d[C]=l[p],d[C+1]=l[p+1],d[C+2]=l[p+2]),g[F]=T,T!==255&&(b=!1)}return{key:e,width:i,height:c,jpeg:null,rgb:d,alpha:b?null:g}}function an(e){let t=2;for(;t+9<e.length;){if(e[t]!==255){t++;continue}let n=e[t+1];if(n===216||n>=208&&n<=215||n===1||n===255){t+=n===255?1:2;continue}let s=e[t+2]<<8|e[t+3];if(n>=192&&n<=195||n>=197&&n<=199||n>=201&&n<=203||n>=205&&n<=207)return{height:e[t+5]<<8|e[t+6],width:e[t+7]<<8|e[t+8],components:e[t+9]};if(n===218)break;t+=2+s}return null}function ne(e){if(!e||e==="none")return null;let t=cn(e);if(t.length!==1)return null;let n=/^url\((?:"([^"]*)"|'([^']*)'|([^)]*))\)$/.exec(t[0].trim());return n?n[1]??n[2]??n[3]??null:null}function cn(e){let t=[],n=0,s="";for(let o of e)o==="("?n++:o===")"&&n--,o===","&&n===0?(t.push(s),s=""):s+=o;return s.trim()&&t.push(s),t}function wt(e,t,n,s,o){let r,i,c=s.trim();if(c==="cover"||c==="contain"){let d=c==="cover"?Math.max(e.w/t,e.h/n):Math.min(e.w/t,e.h/n);r=t*d,i=n*d}else{let[d="auto",g="auto"]=c.split(/\s+/),b=te(d,e.w),p=te(g,e.h);b===null&&p===null?(r=t,i=n):b===null?(i=p,r=t*i/n):p===null?(r=b,i=n*r/t):(r=b,i=p)}let[a="0%",f="0%"]=o.trim().split(/\s+/),m=e.x+ee(a,e.w-r),l=e.y+ee(f,e.h-i);return{x:m,y:l,w:r,h:i}}function te(e,t){return e==="auto"?null:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function ee(e,t){return e==="left"||e==="top"?0:e==="center"?t/2:e==="right"||e==="bottom"?t:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function oe(e){switch(e){case"contain":case"scale-down":return"contain";case"cover":return"cover";case"none":return"auto";default:return"100% 100%"}}function se(e){let t=(e||"repeat").trim();if(t==="repeat-x")return["repeat","no-repeat"];if(t==="repeat-y")return["no-repeat","repeat"];let n=t.split(/\s+/),s=i=>i==="repeat"||i==="no-repeat"||i==="space"||i==="round"?i:"repeat",o=s(n[0]??"repeat"),r=s(n[1]??n[0]??"repeat");return[o,r]}function vt(e,t,n,s,o){if(!(n>0))return{positions:[t],size:n};let r=o-s;if(e==="no-repeat")return{positions:[t],size:n};if(e==="round"){let a=Math.max(1,Math.round(r/n)),f=r/a;return{positions:Array.from({length:a},(m,l)=>s+l*f),size:f}}if(e==="space"){let a=Math.floor(r/n);if(a<2)return{positions:[s],size:n};let f=(r-a*n)/(a-1);return{positions:Array.from({length:a},(m,l)=>s+l*(n+f)),size:n}}let i=t-Math.ceil((t-s)/n)*n,c=[];for(let a=i;a<o&&(a+n>s&&c.push(a),!(c.length>1e4));a+=n);return{positions:c.length?c:[t],size:n}}function re(e){e.jpeg=null,e.rgb=null,e.alpha=null,Lt.delete(e.key)}function ae(e,t,n){let s=/^linear-gradient\((.*)\)$/s.exec(e.trim());if(!s)return null;let o=pn(s[1]);if(o.length<2)return null;let r=0,i=180,c=o[0].trim(),a=c.replace(/^in\s+\S+(\s+\S+\s+hue)?\s*/i,"").trim(),f=ln(a);f!==null?(i=f,r=1):/^in\s/i.test(c)&&a===""&&(r=1);let m=o.slice(r).map(I=>I.trim());if(m.length<2)return null;let l=i*Math.PI/180,d=Math.sin(l),g=Math.cos(l),b=Math.abs(t*d)+Math.abs(n*g);if(!(b>0))return null;let p=[];for(let I of m){let W=fn(I);if(!W)return null;let q=ct(W.color);if(!q)return null;if(!W.positions.length){p.push({t:NaN,color:q});continue}for(let G of W.positions){let Q=un(G,b);if(Q===null)return null;p.push({t:Q,color:q})}}if(p.length<2)return null;hn(p);let C=t/2,F=n/2,T=d,v=-g;return{x0:C-T*b/2,y0:F-v*b/2,x1:C+T*b/2,y1:F+v*b/2,stops:p}}function ln(e){let t=/^(-?[\d.]+)deg$/.exec(e);if(t)return(parseFloat(t[1])%360+360)%360;let n=/^to\s+(.+)$/.exec(e);if(!n)return null;let s=n[1].trim().split(/\s+/).sort().join(" ");return{top:0,right:90,bottom:180,left:270,"right top":45,"bottom right":135,"bottom left":225,"left top":315}[s]??null}function fn(e){let t=/^([a-z-]+\([^()]*\))\s*(.*)$/i.exec(e);if(t)return{color:t[1],positions:ie(t[2])};let n=/^(\S+)\s*(.*)$/.exec(e);return n?{color:n[1],positions:ie(n[2])}:null}function ie(e){let t=e.trim();return t?t.split(/\s+/):[]}function un(e,t){let n=/^(-?[\d.]+)%$/.exec(e);if(n)return parseFloat(n[1])/100;let s=/^(-?[\d.]+)px$/.exec(e);return s?parseFloat(s[1])/t:null}function hn(e){let t=e.length-1;Number.isNaN(e[0]?.t)&&(e[0].t=0),Number.isNaN(e[t]?.t)&&(e[t].t=1);for(let n=1;n<t;n++){if(!Number.isNaN(e[n]?.t))continue;let s=n+1;for(;s<t&&Number.isNaN(e[s]?.t);)s++;let o=e[n-1]?.t,r=e[s]?.t;for(let i=n;i<s;i++)e[i].t=o+(r-o)*(i-n+1)/(s-n+1);n=s-1}for(let n=1;n<e.length;n++){let s=e[n-1]?.t;e[n]?.t<s&&(e[n].t=s)}}function pn(e){let t=[],n=0,s="";for(let o of e)o==="("?n++:o===")"&&n--,o===","&&n===0?(t.push(s),s=""):s+=o;return s.trim()&&t.push(s),t}function dn(e){let t=[],n=gn(e),s=0,o=0,r=0,i=0,c=0,a=null,f=null,m="",l=()=>{let g=n[s++];return typeof g=="number"?g:NaN},d=()=>typeof n[s]=="number";for(;s<n.length;){if(typeof n[s]=="string")m=n[s++];else if(!m)break;let g=m===m.toLowerCase(),b=m.toUpperCase(),p=g?o:0,C=g?r:0;if(b==="M"){o=l()+p,r=l()+C,t.push(["M",o,r]),i=o,c=r,a=f=null,m=g?"l":"L";continue}if(b==="Z"){t.push(["Z"]),o=i,r=c,a=f=null;continue}if(b==="L")o=l()+p,r=l()+C,t.push(["L",o,r]),a=f=null;else if(b==="H")o=l()+p,t.push(["L",o,r]),a=f=null;else if(b==="V")r=l()+C,t.push(["L",o,r]),a=f=null;else if(b==="C"){let F=l()+p,T=l()+C,v=l()+p,I=l()+C;o=l()+p,r=l()+C,t.push(["C",F,T,v,I,o,r]),a=[v,I],f=null}else if(b==="S"){let F=a?2*o-a[0]:o,T=a?2*r-a[1]:r,v=l()+p,I=l()+C;o=l()+p,r=l()+C,t.push(["C",F,T,v,I,o,r]),a=[v,I],f=null}else if(b==="Q"||b==="T"){let F,T;b==="Q"?(F=l()+p,T=l()+C):(F=f?2*o-f[0]:o,T=f?2*r-f[1]:r);let v=l()+p,I=l()+C;t.push(["C",o+2/3*(F-o),r+2/3*(T-r),v+2/3*(F-v),I+2/3*(T-I),v,I]),o=v,r=I,f=[F,T],a=null}else if(b==="A"){let F=l(),T=l(),v=l(),I=l(),W=l(),q=l()+p,G=l()+C;for(let Q of mn(o,r,q,G,F,T,v,I!==0,W!==0))t.push(Q);o=q,r=G,a=f=null}else break;if(!d()&&typeof n[s]!="string")break}return t}function gn(e){let t=[],n=/([MmLlHhVvCcSsQqTtAaZz])|(-?(?:\d*\.\d+|\d+)(?:[eE][-+]?\d+)?)/g,s;for(;s=n.exec(e);)s[1]?t.push(s[1]):t.push(parseFloat(s[2]));return t}function mn(e,t,n,s,o,r,i,c,a){if(e===n&&t===s)return[];if(o=Math.abs(o),r=Math.abs(r),o===0||r===0)return[["L",n,s]];let f=i*Math.PI/180,m=Math.cos(f),l=Math.sin(f),d=(e-n)/2,g=(t-s)/2,b=m*d+l*g,p=-l*d+m*g,C=b*b/(o*o)+p*p/(r*r);if(C>1){let P=Math.sqrt(C);o*=P,r*=P}let F=c===a?-1:1,T=o*o*r*r-o*o*p*p-r*r*b*b,v=o*o*p*p+r*r*b*b,I=F*Math.sqrt(Math.max(0,T/v)),W=I*o*p/r,q=-I*r*b/o,G=m*W-l*q+(e+n)/2,Q=l*W+m*q+(t+s)/2,O=(P,u,h,y)=>{let x=P*h+u*y,w=Math.hypot(P,u)*Math.hypot(h,y),S=Math.acos(Math.min(1,Math.max(-1,x/(w||1))));return P*y-u*h<0&&(S=-S),S},R=O(1,0,(b-W)/o,(p-q)/r),X=O((b-W)/o,(p-q)/r,(-b-W)/o,(-p-q)/r);!a&&X>0&&(X-=2*Math.PI),a&&X<0&&(X+=2*Math.PI);let Y=Math.max(1,Math.ceil(Math.abs(X/(Math.PI/2)))),et=X/Y,ot=4/3*Math.tan(et/4),L=[],M=R;for(let P=0;P<Y;P++){let u=M+et,h=Math.cos(M),y=Math.sin(M),x=Math.cos(u),w=Math.sin(u),S=(V,z)=>[m*o*V-l*r*z+G,l*o*V+m*r*z+Q],[k,$]=S(h,y),[j,E]=S(x,w),[H,_]=S(h-ot*y,y+ot*h),[N,U]=S(x+ot*w,w-ot*x);L.push(["C",H,_,N,U,j,E]),M=u}return L}function fe(e,t){let n=(s,o=0)=>{let r=parseFloat(t(s));return Number.isFinite(r)?r:o};switch(e.tagName){case"path":{let s=t("d");return s?dn(s):[]}case"rect":{let s=n("x"),o=n("y"),r=n("width"),i=n("height");if(r<=0||i<=0)return[];let c=t("rx")===""||t("rx")==="auto"?NaN:n("rx"),a=t("ry")===""||t("ry")==="auto"?NaN:n("ry");return Number.isNaN(c)&&Number.isNaN(a)||(Number.isNaN(c)&&(c=a),Number.isNaN(a)&&(a=c),c=Math.min(c,r/2),a=Math.min(a,i/2),c<=0||a<=0)?ce(s,o,r,i):bn(s,o,r,i,c,a)}case"circle":{let s=n("r");return s<=0?[]:le(n("cx"),n("cy"),s,s)}case"ellipse":{let s=n("rx"),o=n("ry");return s<=0||o<=0?[]:le(n("cx"),n("cy"),s,o)}case"line":return[["M",n("x1"),n("y1")],["L",n("x2"),n("y2")]];case"polyline":case"polygon":{let s=t("points").split(/[\s,]+/).map(parseFloat).filter(r=>Number.isFinite(r));if(s.length<4)return[];let o=[["M",s[0],s[1]]];for(let r=2;r+1<s.length;r+=2)o.push(["L",s[r],s[r+1]]);return e.tagName==="polygon"&&o.push(["Z"]),o}default:return null}}function ce(e,t,n,s){return[["M",e,t],["L",e+n,t],["L",e+n,t+s],["L",e,t+s],["Z"]]}var xt=.5522847498307936;function bn(e,t,n,s,o,r){let i=o*xt,c=r*xt,a=e+n,f=t+s;return[["M",e+o,t],["L",a-o,t],["C",a-o+i,t,a,t+r-c,a,t+r],["L",a,f-r],["C",a,f-r+c,a-o+i,f,a-o,f],["L",e+o,f],["C",e+o-i,f,e,f-r+c,e,f-r],["L",e,t+r],["C",e,t+r-c,e+o-i,t,e+o,t],["Z"]]}function le(e,t,n,s){let o=n*xt,r=s*xt;return[["M",e+n,t],["C",e+n,t+r,e+o,t+s,e,t+s],["C",e-o,t+s,e-n,t+r,e-n,t],["C",e-n,t-r,e-o,t-s,e,t-s],["C",e+o,t-s,e+n,t-r,e+n,t],["Z"]]}var ue=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","HEAD","META","LINK","TITLE","BASE","IFRAME","CANVAS","VIDEO","AUDIO","OBJECT","EMBED"]),he=4e3,pe="http://www.w3.org/2000/svg",yn=new Set(["defs","symbol","marker","clipPath","mask","pattern","filter","linearGradient","radialGradient","style","title","desc","metadata","script"]),wn=new Set(["g","a","svg","switch"]);function xn(e){let t=e.shadowRoot;if(t)return[...t.childNodes];if(e.tagName==="SLOT"){let n=e;if(typeof n.assignedNodes=="function")return n.assignedNodes({flatten:!0})}return[...e.childNodes]}var Sn=[["boxShadow",e=>e!=="none"],["textShadow",e=>e!=="none"],["filter",e=>e!=="none"],["backdropFilter",e=>e!=="none"&&e!==""],["writingMode",e=>e.startsWith("vertical")],["outlineStyle",e=>e!=="none"],["clipPath",e=>e!=="none"],["mixBlendMode",e=>e!=="normal"]];async function Ot(e,t){let n=e.ownerDocument.defaultView,s=n.scrollX,o=n.scrollY,r=[],i=r,c=[],a=[],f=[],m=[],l=null,d=0,g=new Set,b=new Set;function p(u,h){g.has(u)||(g.add(u),t.warn(h))}async function C(u,h){if(ue.has(u.tagName))return;t.pacer&&await t.pacer();let y=n.getComputedStyle(u);if(y.display==="none")return;let x=Tn(y.transform);if(x&&"style"in u){let w=u,S=w.getBoundingClientRect(),k=w.style.transform;w.style.transform="none",w.offsetWidth;let $=w.getBoundingClientRect(),[j,E]=Cn(y.transformOrigin),H={x:$.left+j+s,y:$.top+E+o},_=r;r=[],await T(u,n.getComputedStyle(u),h);let N=r;r=_,w.style.transform=k,w.offsetWidth,r.push({type:"group",matrix:x,origin:H,items:N,top:S.top+o,bottom:S.bottom+o,z:F(y,h.z),seq:d++});return}await T(u,y,h)}function F(u,h){if(u.position!=="static"&&u.zIndex!=="auto"){let y=parseInt(u.zIndex,10);if(Number.isFinite(y))return y}return h}async function T(u,h,y){let x=F(h,y.z),w=parseFloat(h.opacity),S=y.alpha*(Number.isFinite(w)?w:1),k=h.visibility==="visible"&&S>0;if(h.display!=="contents"&&h.display!=="inline"){let D=u.getBoundingClientRect(),tt=D.top+o,st=D.bottom+o;if(D.height>0){let nt=h.breakBefore||h.pageBreakBefore,jt=h.breakAfter||h.pageBreakAfter;/^(page|always|left|right|recto|verso)$/.test(nt)&&a.push(tt),/^(page|always|left|right|recto|verso)$/.test(jt)&&a.push(st);let Gt=h.breakInside||h.pageBreakInside;if((Gt==="avoid"||Gt==="avoid-page"||h.display==="table-row"||h.display==="table-header-group"||h.display==="table-footer-group"||u.tagName==="IMG"||u.tagName==="svg")&&c.push({top:tt,bottom:st}),/^avoid(-page)?$/.test(jt)){let ft=L(u);ft&&f.push({start:Math.min(st,ft.top),end:Math.max(st,ft.top),pullTo:tt})}if(/^avoid(-page)?$/.test(nt)){let ft=M(u);ft&&f.push({start:Math.min(ft.bottom,tt),end:Math.max(ft.bottom,tt),pullTo:ft.top})}}}let $=null;if(h.display==="table"||h.display==="inline-table"){let D=u.getBoundingClientRect();$={top:D.top+o,bottom:D.bottom+o,headTop:0,headBottom:0,headItems:[],footTop:0,footBottom:0,footItems:[]},m.push($)}let j=l;$&&(l=$);let E=h.display==="table-header-group"&&l&&!l.headItems.length,H=h.display==="table-footer-group"&&l&&!l.footItems.length,_=E||H?r.length:-1,N=h.overflowX!=="visible"||h.overflowY!=="visible",U=null,V=null;if(N&&h.display!=="inline"&&h.display!=="contents"&&u!==e){let D=u.getBoundingClientRect();V=G(D,h,"padding-box",ge(h,D))}if(k&&h.display!=="contents"){v(u,h);let D=h.display==="inline"?[...u.getClientRects()]:[u.getBoundingClientRect()],tt=h.borderCollapse==="collapse"&&/^table/.test(h.display)&&h.display!=="table-caption",st=D.length===1?ge(h,D[0]):null;for(let nt of D)nt.width<=0&&nt.height<=0||(I(nt,h,S,x,st),await W(u,nt,h,S,x,st),Q(nt,h,S,x,tt,st));u.tagName==="IMG"&&D[0]&&await q(u,D[0],h,S,x,st)}let z=y.decorations,Z=h.textDecorationLine;if(Z&&Z!=="none"){let D=ct(h.textDecorationColor)??ct(h.color)??{r:0,g:0,b:0,a:1};z=[...z,{line:Z,color:D}]}V&&(U=r,r=[]);let at={z:x,alpha:S,decorations:z};if(u.tagName==="svg"&&u.namespaceURI===pe){X(u,S,x),V&&U&&ot(V,U,x);return}for(let D of xn(u))D.nodeType===Node.TEXT_NODE?k&&O(D,u,h,at):D.nodeType===Node.ELEMENT_NODE&&await C(D,at);if(V&&U&&ot(V,U,x),(E||H)&&l&&_>=0){let D=u.getBoundingClientRect(),tt=r.slice(_);E?(l.headTop=D.top+o,l.headBottom=D.bottom+o,l.headItems=tt):(l.footTop=D.top+o,l.footBottom=D.bottom+o,l.footItems=tt)}l=j}function v(u,h){for(let[y,x]of Sn){let w=String(h[y]??"");x(w)&&p(`css:${y}`,{code:"unsupported-css",message:`CSS property "${me(y)}" is not supported in this version and will be ignored (first seen on <${u.tagName.toLowerCase()}>: ${w})`,element:u,property:me(y)})}/^matrix3d/.test(h.transform)&&p("css:transform3d",{code:"unsupported-css",message:"3D transforms are not supported; the element is drawn untransformed",element:u,property:"transform"})}function I(u,h,y,x,w){let S=ct(h.backgroundColor);if(!S||S.a<=0)return;let k={type:"rect",x:u.left+s,y:u.top+o,w:u.width,h:u.height,color:bt(S,y),z:x,seq:d++};w&&(k.radius=w),r.push(k)}async function W(u,h,y,x,w,S){if(y.backgroundImage==="none")return;let k=G(h,y,y.backgroundClip||"border-box",S),$=G(h,y,y.backgroundOrigin||"padding-box",null),j=ae(y.backgroundImage,$.w,$.h);if(j){r.push({type:"gradient",box:$,clip:k,gradient:j,alpha:x,z:w,seq:d++});return}let E=ne(y.backgroundImage);if(!E){p("css:backgroundImage",{code:"unsupported-css",message:`background-image "${y.backgroundImage}" is not supported (a single url() or linear-gradient() is); ignored`,element:u,property:"background-image"});return}let H=await mt(new URL(E,u.ownerDocument.baseURI).href,t.warn,u);if(!H)return;let _=wt($,H.width,H.height,y.backgroundSize,y.backgroundPosition),[N,U]=se(y.backgroundRepeat),V=vt(N,_.x,_.w,k.x,k.x+k.w),z=vt(U,_.y,_.h,k.y,k.y+k.h),Z=V.positions.length*z.positions.length;if(Z>he){p("css:backgroundRepeat",{code:"unsupported-css",message:`background-repeat would need ${Z} tiles (limit ${he}); drawn once instead. Use a larger background-size or a pre-tiled image.`,element:u,property:"background-repeat"}),r.push({type:"image",..._,image:H,clip:k,alpha:x,z:w,seq:d++});return}for(let at of z.positions)for(let D of V.positions)r.push({type:"image",x:D,y:at,w:V.size,h:z.size,image:H,clip:k,alpha:x,z:w,seq:d++})}async function q(u,h,y,x,w,S){let k=u.currentSrc||u.src;if(!k)return;let $=await mt(k,t.warn,u);if(!$)return;let j=G(h,y,"content-box",S),E=wt(j,$.width,$.height,oe(y.objectFit),y.objectPosition);y.objectFit==="scale-down"&&(E.w>$.width||E.h>$.height)&&Object.assign(E,wt(j,$.width,$.height,"auto",y.objectPosition)),r.push({type:"image",...E,image:$,clip:j,alpha:x,z:w,seq:d++})}function G(u,h,y,x){let w=u.left+s,S=u.top+o,k=u.width,$=u.height;if(y==="padding-box"||y==="content-box"){let E=J(h.borderTopWidth),H=J(h.borderRightWidth),_=J(h.borderBottomWidth),N=J(h.borderLeftWidth);w+=N,S+=E,k-=N+H,$-=E+_,x&&(x=x.map(U=>Math.max(0,U-Math.max(E,H,_,N))))}if(y==="content-box"){let E=J(h.paddingTop),H=J(h.paddingRight),_=J(h.paddingBottom),N=J(h.paddingLeft);w+=N,S+=E,k-=N+H,$-=E+_}let j={x:w,y:S,w:Math.max(0,k),h:Math.max(0,$)};return x&&x.some(E=>E>0)&&(j.radius=x),j}function Q(u,h,y,x,w,S){let k=u.left+s,$=u.top+o,j=u.width,E=u.height,N=["Top","Right","Bottom","Left"].map(U=>({side:U,width:J(h[`border${U}Width`]),style:h[`border${U}Style`],color:ct(h[`border${U}Color`])})).filter(U=>U.width>0&&U.style!=="none"&&U.style!=="hidden"&&U.color&&U.color.a>0);if(N.length){if(S&&S.some(U=>U>0)){let U=N[0];if(N.length===4&&N.every(z=>z.width===U.width&&z.style===U.style&&JSON.stringify(z.color)===JSON.stringify(U.color))){let z=U.width;r.push({type:"stroke-rrect",x:k+z/2,y:$+z/2,w:j-z,h:E-z,radius:S.map(Z=>Math.max(0,Z-z/2)),width:z,color:bt(U.color,y),dash:de(U.style,z),z:x,seq:d++});return}p("css:borderRadiusNonUniform",{code:"unsupported-css",message:"border-radius with non-uniform borders is approximated with straight borders",property:"border-radius"})}for(let U of N){let V=U.width,z=bt(U.color,y),Z=U.side==="Top"||U.side==="Bottom",at=U.side==="Top"||U.side==="Left"?1:-1,D=U.side==="Top"?$:U.side==="Bottom"?$+E:U.side==="Left"?k:k+j,tt=de(U.style,V);if(tt){let nt=w?D:D+V/2*at;r.push({type:"line",x1:Z?k:nt,y1:Z?nt:$,x2:Z?k+j:nt,y2:Z?nt:$+E,width:V,color:z,dash:tt,z:x,seq:d++});continue}let st=w?D-V/2:at>0?D:D-V;Z?r.push({type:"rect",x:k,y:st,w:j,h:V,color:z,z:x,seq:d++}):r.push({type:"rect",x:st,y:$,w:V,h:E,color:z,z:x,seq:d++})}}}function O(u,h,y,x){let w=u.data;if(!w)return;if(!/\S/.test(w)&&!w.includes("\xA0")){let N=u.ownerDocument.createRange();if(N.selectNodeContents(u),![...N.getClientRects()].some(U=>U.width>0))return}let S=bt(ct(y.color)??{r:0,g:0,b:0,a:1},x.alpha),k=J(y.fontSize);if(k<=0)return;let $=Vt(y.fontFamily),j=_t(y.fontWeight),E=y.fontStyle==="italic"||y.fontStyle==="oblique"?"italic":"normal",H=t.registry.match($,j,E)??t.registry.match(t.fontFallback,j,E);if(!H){let N=$.join(",");b.has(N)||(b.add(N),t.warn({code:"missing-font",message:`No registered font matches font-family "${y.fontFamily}" and no fallback is available; text will be skipped`,element:h}));return}let _=Jt(u,y,{registry:t.registry,families:$,fallback:t.fontFallback,primary:H,weight:j,fstyle:E,size:k,textMeasure:t.textMeasure,features:Zt(y),warn:t.warn,element:h});for(let N of _)if(N.glyphs.length){c.push({top:N.top+o,bottom:N.bottom+o}),r.push({type:"text",x:N.glyphs[0]?.x??0,y:N.baseline+o,top:N.top+o,bottom:N.bottom+o,size:k,color:S,font:N.font,glyphs:N.glyphs.map(U=>({...U,x:U.x+s})),z:x.z,seq:d++});for(let U of x.decorations){let V=N.glyphs[0],z=N.glyphs[N.glyphs.length-1];if(!V||!z)continue;let Z=V.x+s,at=z.x+z.advance+s,D=Math.max(1,k/14),tt=bt(U.color,x.alpha);U.line.includes("underline")&&r.push({type:"rect",x:Z,y:N.baseline+o+k*.08,w:at-Z,h:D,color:tt,z:x.z,seq:d++}),U.line.includes("line-through")&&r.push({type:"rect",x:Z,y:N.baseline+o-k*.3,w:at-Z,h:D,color:tt,z:x.z,seq:d++})}}}await C(e,{z:0,alpha:1,decorations:[]}),be(i);let R=e.getBoundingClientRect().bottom+o;for(let u of i)u.type==="rect"||u.type==="stroke-rrect"||u.type==="image"?R=Math.max(R,u.y+u.h):u.type==="line"?R=Math.max(R,u.y1,u.y2):(u.type==="text"||u.type==="group"||u.type==="clip")&&(R=Math.max(R,u.bottom));function X(u,h,y){for(let x of u.children){if(x.namespaceURI!==pe)continue;let w=x.tagName;if(yn.has(w))continue;let S=n.getComputedStyle(x);if(S.display==="none")continue;let k=parseFloat(S.opacity),$=h*(Number.isFinite(k)?k:1);if($<=0)continue;if(wn.has(w)){X(x,$,y);continue}let E=fe(x,V=>{let z=S.getPropertyValue(V);return z&&/^-?[\d.]+px$/.test(z)?String(parseFloat(z)):x.getAttribute(V)??""});if(E===null){p(`svg:${w}`,{code:"unsupported-css",message:`<${w}> inside an inline <svg> is not supported and was skipped (shapes are: path, rect, circle, ellipse, line, polyline, polygon)`,element:x});continue}if(!E.length||S.visibility!=="visible")continue;let H=x.getScreenCTM?.();if(!H)continue;let _=Y(x,S.fill,S.fillOpacity,$,"fill"),N=et(x,S,$);if(!_&&!N)continue;let U=x.getBoundingClientRect();r.push({type:"path",segs:E,matrix:[H.a,H.b,H.c,H.d,H.e+s,H.f+o],fill:_,evenOdd:S.fillRule==="evenodd",stroke:N,top:U.top+o,bottom:U.bottom+o,z:y,seq:d++})}}function Y(u,h,y,x,w){if(!h||h==="none")return null;if(h.startsWith("url("))return p(`svg:${w}:url`,{code:"unsupported-css",message:`${w} with a paint server (${h}) inside an inline <svg> is not supported; the shape is skipped`,element:u,property:w}),null;let S=ct(h);if(!S)return null;let k=parseFloat(y),$=x*(Number.isFinite(k)?k:1);return $===1?S:{...S,a:S.a*$}}function et(u,h,y){let x=Y(u,h.stroke,h.strokeOpacity,y,"stroke");if(!x)return null;let w=J(h.strokeWidth);if(!(w>0))return null;let S=(h.strokeDasharray||"none").split(/[\s,]+/).map(E=>J(E)).filter(E=>Number.isFinite(E)&&E>=0),k=h.strokeLinecap==="round"?1:h.strokeLinecap==="square"?2:0,$=h.strokeLinejoin==="round"?1:h.strokeLinejoin==="bevel"?2:0,j=parseFloat(h.strokeMiterlimit);return{color:x,width:w,cap:k,join:$,miter:Number.isFinite(j)&&j>=1?j:4,dash:S.length&&S.some(E=>E>0)?S:null,dashOffset:J(h.strokeDashoffset)||0}}function ot(u,h,y){let x=r.filter(w=>$n(w,u));r=h,x.length&&r.push({type:"clip",box:u,items:x,top:u.y,bottom:u.y+u.h,z:y,seq:d++})}function L(u){let h=u;for(;h&&h!==e;){for(let y=h.nextElementSibling;y;y=y.nextElementSibling){let x=P(y,"first");if(x)return x}h=h.parentElement}return null}function M(u){let h=u;for(;h&&h!==e;){for(let y=h.previousElementSibling;y;y=y.previousElementSibling){let x=P(y,"last");if(x)return x}h=h.parentElement}return null}function P(u,h){if(ue.has(u.tagName))return null;let y=n.getComputedStyle(u);if(y.display==="none")return null;if(y.display!=="contents"&&y.display!=="inline"){let w=u.getBoundingClientRect();if(w.height>0)return{top:w.top+o,bottom:w.bottom+o}}let x=[...u.children];h==="last"&&x.reverse();for(let w of x){let S=P(w,h);if(S)return S}return null}return{items:i,atoms:c,breaks:a,joins:f,tables:m,height:R}}function be(e){e.sort((t,n)=>t.z-n.z||t.seq-n.seq);for(let t of e)(t.type==="group"||t.type==="clip")&&be(t.items)}function de(e,t){return e==="dashed"?[t*3,t*3]:e==="dotted"?[t,t]:null}function ge(e,t){let n=o=>{let r=o.trim().split(/\s+/)[0]??"0px";return r.endsWith("%")?parseFloat(r)/100*t.width:J(r)},s=[n(e.borderTopLeftRadius),n(e.borderTopRightRadius),n(e.borderBottomRightRadius),n(e.borderBottomLeftRadius)];return s.some(o=>o>0)?s:null}function Tn(e){if(!e||e==="none")return null;let t=/^matrix\(([^)]+)\)$/.exec(e.trim());if(!t)return null;let n=t[1].split(",").map(f=>parseFloat(f));if(n.length!==6||n.some(f=>!Number.isFinite(f)))return null;let[s,o,r,i,c,a]=n;return s===1&&o===0&&r===0&&i===1&&c===0&&a===0?null:[s,o,r,i,c,a]}function Cn(e){let t=e.trim().split(/\s+/);return[J(t[0]??"0"),J(t[1]??"0")]}function $n(e,t){let n,s,o,r;if(e.type==="rect"||e.type==="stroke-rrect"||e.type==="image")n=e.x,s=e.y,o=e.x+e.w,r=e.y+e.h;else if(e.type==="line")n=Math.min(e.x1,e.x2)-e.width,s=Math.min(e.y1,e.y2)-e.width,o=Math.max(e.x1,e.x2)+e.width,r=Math.max(e.y1,e.y2)+e.width;else if(e.type==="text"){let i=e.glyphs[e.glyphs.length-1];n=e.x,s=e.top,o=i?i.x+i.advance:e.x,r=e.bottom}else{if(e.type==="path")return!0;if(e.type==="clip"||e.type==="gradient"){let i=e.type==="clip"?e.box:e.clip;n=i.x,s=i.y,o=i.x+i.w,r=i.y+i.h}else return!0}return o>t.x&&n<t.x+t.w&&r>t.y&&s<t.y+t.h}function bt(e,t){return t===1?e:{...e,a:e.a*t}}function me(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function Mn(){return typeof CompressionStream=="function"}async function ye(e){if(!Mn())return null;try{let t=new CompressionStream("deflate"),n=t.writable.getWriter();n.write(e),n.close();let s=await new Response(t.readable).arrayBuffer();return new Uint8Array(s)}catch{return null}}var St=class{constructor(t){this.id=t}toString(){return`${this.id} 0 R`}},K=class{constructor(t){this.name=t}toString(){let t="/";for(let n of this.name){let s=n.charCodeAt(0);if(s<33||s>126||"#/%()<>[]{}".includes(n))for(let o of new TextEncoder().encode(n))t+="#"+o.toString(16).padStart(2,"0");else t+=n}return t}},lt=class{constructor(t){this.text=t}toString(){return this.text}};function ht(e){if(/^[\x20-\x7e]*$/.test(e))return new lt("("+e.replace(/[\\()]/g,n=>"\\"+n)+")");let t="FEFF";for(let n=0;n<e.length;n++)t+=e.charCodeAt(n).toString(16).padStart(4,"0");return new lt("<"+t+">")}function we(e){let t=i=>String(i).padStart(2,"0"),n=-e.getTimezoneOffset(),s=n>=0?"+":"-",o=t(Math.floor(Math.abs(n)/60)),r=t(Math.abs(n)%60);return new lt(`(D:${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}${s}${o}'${r}')`)}function Tt(e){if(e===null)return"null";if(typeof e=="number")return A(e);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return new K(e).toString();if(e instanceof St||e instanceof K||e instanceof lt)return e.toString();if(Array.isArray(e))return"["+e.map(Tt).join(" ")+"]";let t=[];for(let[n,s]of Object.entries(e))s!==void 0&&t.push(new K(n).toString()+" "+Tt(s));return"<< "+t.join(" ")+" >>"}var Ct=class{constructor(t={}){this.objects=[null],this.compress=t.compress??!0,this.version=t.version??"1.7"}reserve(){return this.objects.push({value:null}),new St(this.objects.length-1)}set(t,n,s){this.objects[t.id]={value:n,stream:s}}add(t){let n=this.reserve();return this.set(n,t),n}async addStream(t,n,s={}){let o=this.reserve();return await this.setStream(o,t,n,s),o}async setStream(t,n,s,o={}){let r=s,i={...n};if((o.compress??this.compress)&&!("Filter"in i)){let a=await ye(s);a&&a.length<s.length&&(r=a,i.Filter="FlateDecode")}i.Length=r.length,this.set(t,i,r)}build(t,n){let s=new TextEncoder,o=[],r=0,i=l=>{let d=typeof l=="string"?s.encode(l):l;o.push(d),r+=d.length};i($t([s.encode(`%PDF-${this.version}
|
|
6
6
|
%`),new Uint8Array([226,227,207,211]),s.encode(`
|
|
7
|
-
`)]));let
|
|
8
|
-
${
|
|
7
|
+
`)]));let c=[];for(let l=1;l<this.objects.length;l++){let d=this.objects[l];if(!d)throw new Error(`PDF object ${l} was reserved but never set`);c[l]=r,i(`${l} 0 obj
|
|
8
|
+
${Tt(d.value)}
|
|
9
9
|
`),d.stream&&(i(`stream
|
|
10
10
|
`),i(d.stream),i(`
|
|
11
11
|
endstream
|
|
12
12
|
`)),i(`endobj
|
|
13
|
-
`)}let
|
|
13
|
+
`)}let a=r,f=`xref
|
|
14
14
|
0 ${this.objects.length}
|
|
15
15
|
0000000000 65535 f
|
|
16
|
-
`;for(let
|
|
17
|
-
`;i(
|
|
18
|
-
${
|
|
16
|
+
`;for(let l=1;l<this.objects.length;l++)f+=String(c[l]).padStart(10,"0")+` 00000 n
|
|
17
|
+
`;i(f);let m={Size:this.objects.length,Root:t};return n&&(m.Info=n),i(`trailer
|
|
18
|
+
${Tt(m)}
|
|
19
19
|
startxref
|
|
20
|
-
${
|
|
20
|
+
${a}
|
|
21
21
|
%%EOF
|
|
22
|
-
`)
|
|
22
|
+
`),$t(o)}};function $t(e){let t=0;for(let o of e)t+=o.length;let n=new Uint8Array(t),s=0;for(let o of e)n.set(o,s),s+=o.length;return n}var Mt=class{constructor(){this.ops=[],this.depth=0}save(){return this.ops.push("q"),this.depth++,this}restore(){if(this.depth<=0)throw new Error("ContentStream: unbalanced Q");return this.ops.push("Q"),this.depth--,this}transform(t,n,s,o,r,i){return this.ops.push(`${A(t)} ${A(n)} ${A(s)} ${A(o)} ${A(r)} ${A(i)} cm`),this}setGState(t){return this.ops.push(`/${t} gs`),this}fillColor(t,n,s){return this.ops.push(`${A(t)} ${A(n)} ${A(s)} rg`),this}strokeColor(t,n,s){return this.ops.push(`${A(t)} ${A(n)} ${A(s)} RG`),this}lineWidth(t){return this.ops.push(`${A(t)} w`),this}dash(t,n=0){return this.ops.push(`[${t.map(A).join(" ")}] ${A(n)} d`),this}lineCap(t){return this.ops.push(`${t} J`),this}rect(t,n,s,o){return this.ops.push(`${A(t)} ${A(n)} ${A(s)} ${A(o)} re`),this}moveTo(t,n){return this.ops.push(`${A(t)} ${A(n)} m`),this}lineTo(t,n){return this.ops.push(`${A(t)} ${A(n)} l`),this}curveTo(t,n,s,o,r,i){return this.ops.push(`${A(t)} ${A(n)} ${A(s)} ${A(o)} ${A(r)} ${A(i)} c`),this}closePath(){return this.ops.push("h"),this}roundedRect(t,n,s,o,r){let c=Math.min(s,o)/2,a=p=>Math.max(0,Math.min(p,c)),f=a(r[0]),m=a(r[1]),l=a(r[2]),d=a(r[3]),g=n+o,b=t+s;return this.moveTo(t+f,g),this.lineTo(b-m,g),m&&this.curveTo(b-m+m*.5523,g,b,g-m+m*.5523,b,g-m),this.lineTo(b,n+l),l&&this.curveTo(b,n+l-l*.5523,b-l+l*.5523,n,b-l,n),this.lineTo(t+d,n),d&&this.curveTo(t+d-d*.5523,n,t,n+d-d*.5523,t,n+d),this.lineTo(t,g-f),f&&this.curveTo(t,g-f+f*.5523,t+f-f*.5523,g,t+f,g),this.closePath()}image(t,n,s,o,r){return this.ops.push(`q ${A(o)} 0 0 ${A(r)} ${A(n)} ${A(s)} cm /${t} Do Q`),this}lineJoin(t){return this.ops.push(`${t} j`),this}miterLimit(t){return this.ops.push(`${A(t)} M`),this}fill(t=!1){return this.ops.push(t?"f*":"f"),this}fillAndStroke(t=!1){return this.ops.push(t?"B*":"B"),this}path(t){for(let n of t)n[0]==="M"?this.moveTo(n[1],n[2]):n[0]==="L"?this.lineTo(n[1],n[2]):n[0]==="C"?this.curveTo(n[1],n[2],n[3],n[4],n[5],n[6]):this.closePath();return this}stroke(){return this.ops.push("S"),this}shading(t){return this.ops.push(`/${t} sh`),this}clip(){return this.ops.push("W n"),this}fillRect(t,n,s,o){return this.rect(t,n,s,o).fill()}text(t,n,s,o,r,i={}){let c=[];for(let a of r)typeof a=="string"?a.length&&c.push(`<${a}>`):a!==0&&c.push(A(a));return c.length?(this.ops.push("BT"),this.ops.push(`/${t} ${A(n)} Tf`),i.charSpacing&&this.ops.push(`${A(i.charSpacing)} Tc`),i.rise&&this.ops.push(`${A(i.rise)} Ts`),this.ops.push(`1 0 0 1 ${A(s)} ${A(o)} Tm`),this.ops.push(`[${c.join(" ")}] TJ`),this.ops.push("ET"),this):this}toBytes(){if(this.depth!==0)throw new Error(`ContentStream: ${this.depth} unclosed q`);return new TextEncoder().encode(this.ops.join(`
|
|
23
23
|
`)+`
|
|
24
|
-
`)}};function
|
|
24
|
+
`)}};function Se(e,t){let n=new Set([0]),s=[...t];for(;s.length;){let O=s.pop();if(!(O<0||O>=e.numGlyphs||n.has(O))){n.add(O);for(let R of qt(Pt(e,O)))n.has(R)||s.push(R)}}let o=[...n].sort((O,R)=>O-R),r=new Map;o.forEach((O,R)=>r.set(O,R));let i=o.length,c=[],a=new Uint32Array(i+1),f=0;for(let O=0;O<i;O++){let R=Pt(e,o[O]);R.length&&new DataView(R.buffer,R.byteOffset,R.byteLength).getInt16(0)<0&&(R=kn(R,r)),a[O]=f,c.push(R),f+=R.length;let X=(4-f%4)%4;X&&(c.push(new Uint8Array(X)),f+=X)}a[i]=f;let m=$t(c),l=new Uint8Array(a.length*4),d=new DataView(l.buffer);a.forEach((O,R)=>d.setUint32(R*4,O));let g=e.tables.get("hmtx"),b=e.tables.get("hhea"),p=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),C=p.getUint16(b.offset+34),F=new Uint8Array(i*4),T=new DataView(F.buffer);for(let O=0;O<i;O++){let R=o[O],X=R<C?g.offset+R*4+2:g.offset+C*4+(R-C)*2;T.setUint16(O*4,e.advances[R]??0),T.setInt16(O*4+2,X+2<=e.data.byteLength?p.getInt16(X):0)}let v=kt(e,"head"),I=new DataView(v.buffer);I.setUint32(8,0),I.setInt16(50,1);let W=kt(e,"hhea");new DataView(W.buffer).setUint16(34,i);let q=kt(e,"maxp");new DataView(q.buffer).setUint16(4,i);let G=[["glyf",m],["head",v],["hhea",W],["hmtx",F],["loca",l],["maxp",q]];for(let O of["cvt ","fpgm","prep"])e.tables.has(O)&&G.push([O,kt(e,O)]);return G.sort((O,R)=>O[0]<R[0]?-1:1),{data:Un(G),gidMap:r,oldGids:o}}function kt(e,t){let n=e.tables.get(t);if(!n)throw new Error(`missing table ${t}`);return new Uint8Array(e.data.subarray(n.offset,n.offset+n.length))}function kn(e,t){let n=new Uint8Array(e),s=new DataView(n.buffer),o=10;for(;;){let r=s.getUint16(o),i=s.getUint16(o+2);if(s.setUint16(o+2,t.get(i)??0),o+=4,o+=r&1?4:2,r&8?o+=2:r&64?o+=4:r&128&&(o+=8),!(r&32)||o>=n.length)break}return n}function Un(e){let t=e.length,n=0;for(;1<<n+1<=t;)n++;let s=(1<<n)*16,o=t*16-s,i=12+t*16,c=[];for(let[l,d]of e)c.push({tag:l,data:d,offset:i,checksum:xe(d)}),i+=d.length+3&-4;let a=new Uint8Array(i),f=new DataView(a.buffer);f.setUint32(0,65536),f.setUint16(4,t),f.setUint16(6,s),f.setUint16(8,n),f.setUint16(10,o),c.forEach((l,d)=>{let g=12+d*16;for(let b=0;b<4;b++)a[g+b]=l.tag.charCodeAt(b);f.setUint32(g+4,l.checksum),f.setUint32(g+8,l.offset),f.setUint32(g+12,l.data.length),a.set(l.data,l.offset)});let m=c.find(l=>l.tag==="head");if(m){let l=xe(a);f.setUint32(m.offset+8,2981146554-l>>>0)}return a}function xe(e){let t=0,n=e.length;for(let s=0;s<n;s+=4){let o=e[s]??0,r=e[s+1]??0,i=e[s+2]??0,c=e[s+3]??0;t=t+((o<<24|r<<16|i<<8|c)>>>0)>>>0}return t}var Ut=class{constructor(t,n){this.font=t,this.resourceName=n,this.usedGids=new Map,this.subset=null}addGlyph(t,n){this.usedGids.has(t)||this.usedGids.set(t,n)}cid(t){if(!this.subset)throw new Error("EmbeddedFont: embed() must be called before cid()");return this.subset.gidMap.get(t)??0}finalize(){return this.subset||(this.subset=Se(this.font,this.usedGids.keys())),this.subset}async embed(t){let n=this.finalize(),s=this.font,o=1e3/s.unitsPerEm,i=`${Fn(this.usedGids)}+${s.postScriptName}`,c=await t.addStream({Length1:n.data.length},n.data),a=4;s.italic&&(a|=64),s.bold&&(a|=1<<18);let f=t.add({Type:"FontDescriptor",FontName:i,Flags:a,FontBBox:s.bbox.map(p=>Math.round(p*o)),ItalicAngle:s.italicAngle,Ascent:Math.round(s.ascender*o),Descent:Math.round(s.descender*o),CapHeight:Math.round(s.capHeight*o),StemV:s.bold?120:80,FontFile2:c}),m=[],l=n.oldGids.map(p=>Math.round((s.advances[p]??0)*o)),d=0;for(;d<l.length;){let p=d;for(;p+1<l.length&&p-d<100;)p++;m.push(d,l.slice(d,p+1)),d=p+1}let g=t.add({Type:"Font",Subtype:"CIDFontType2",BaseFont:i,CIDSystemInfo:{Registry:new lt("(Adobe)"),Ordering:new lt("(Identity)"),Supplement:0},FontDescriptor:f,DW:1e3,W:m,CIDToGIDMap:"Identity"}),b=await t.addStream({},Pn(n,this.usedGids));return t.add({Type:"Font",Subtype:"Type0",BaseFont:i,Encoding:"Identity-H",DescendantFonts:[g],ToUnicode:b})}};function Fn(e){let t=2166136261;for(let s of e.keys())t^=s,t=Math.imul(t,16777619)>>>0;let n="";for(let s=0;s<6;s++)n+=String.fromCharCode(65+t%26),t=Math.floor(t/26);return n}function Pn(e,t){let n=[];e.oldGids.forEach((r,i)=>{let c=t.get(r);c!==void 0&&n.push(`<${dt(i)}> <${En(c)}>`)});let s="";for(let r=0;r<n.length;r+=100){let i=n.slice(r,r+100);s+=`${i.length} beginbfchar
|
|
25
25
|
${i.join(`
|
|
26
26
|
`)}
|
|
27
27
|
endbfchar
|
|
@@ -38,5 +38,6 @@ endcodespacerange
|
|
|
38
38
|
CMapName currentdict /CMap defineresource pop
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
`;return new TextEncoder().encode(o)}function rt(e){return e.toString(16).toUpperCase().padStart(4,"0")}function Le(e){if(e<=65535)return rt(e);let t=e-65536;return rt(55296+(t>>10))+rt(56320+(t&1023))}async function Kt(e,t){let n={Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceRGB",BitsPerComponent:8};if(t.jpeg)return n.Filter="DCTDecode",e.addStream(n,t.jpeg,{compress:!1});if(!t.rgb)throw new Error("embedImage: image has no pixel data");return t.alpha&&(n.SMask=await e.addStream({Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceGray",BitsPerComponent:8},t.alpha)),e.addStream(n,t.rgb)}function Jt(e,t){let n=t,s=e.height,o=[...e.atoms].sort((f,d)=>f.top-d.top),r=[...new Set(e.breaks)].sort((f,d)=>f-d),i=.01,a=[],c=0,h=0;for(;c<s-i&&h++<1e4;){let f=[],d=0;for(let C of e.tables)C.headItems.length&&C.headBottom<=c+i&&c<C.bottom-i&&(f.push({table:C,shift:d}),d+=C.headBottom-C.headTop);let u=[],w=0,y=c;for(let C=0;C<4;C++){let O=Math.max(n-d-w,n*.25);y=p(c,O);let R=[],D=0;for(let j of e.tables)j.footItems.length&&j.top<y-i&&j.footTop>=y-i&&j.bottom>y+i&&(R.push({table:j,shift:D}),D+=j.footBottom-j.footTop);let L=R.length===u.length&&R.every((j,z)=>j.table===u[z]?.table);if(u=R,w=D,L)break}a.push({start:c,end:y,heads:f,headShift:d,feet:u,footShift:w}),c=y}return a.length||a.push({start:0,end:Math.max(s,1),heads:[],headShift:0,feet:[],footShift:0}),a;function p(f,d){let u=Math.min(f+d,s);for(let w of r)if(w>f+i&&w<u-i){u=w;break}if(u<s-i){let w=!0,y=0;for(;w&&y++<1e3;){w=!1;for(let C of o){if(C.top>=u)break;C.bottom-C.top>d||C.top<u-i&&C.bottom>u+i&&C.top>f+i&&(u=C.top,w=!0)}}u<=f+i&&(u=Math.min(f+d,s))}return u}}function Qt(e={}){let t=e.size??"A4",n,s;if(typeof t=="string"){let i=$t[t];if(!i)throw new Error(`Unknown page size "${t}". Use one of ${Object.keys($t).join(", ")} or {width, height}.`);n=i.width,s=i.height}else n=Y(t.width),s=Y(t.height);(e.orientation??"portrait")==="landscape"&&n<s&&([n,s]=[s,n]);let o=e.margin??"15mm",r=typeof o=="string"?{top:Y(o),right:Y(o),bottom:Y(o),left:Y(o)}:{top:Y(o.top),right:Y(o.right),bottom:Y(o.bottom),left:Y(o.left)};return{width:n,height:s,...r}}async function Zt(e,t,n){let s=new dt({compress:n.compress}),o=(n.header?.heightPx??0)*.75,r=(n.footer?.heightPx??0)*.75,i=t.width-t.left-t.right,a=t.height-t.top-o,c=t.height-t.top-t.bottom-o-r;if(c<=0)throw new Error("Page content area is empty: margins + header + footer exceed the page height");let h=c/.75,p=Jt(e,h),f=p.length,d=[],u=[];for(let g=0;g<f;g++)d.push(n.header?await n.header.render(g+1,f):null),u.push(n.footer?await n.footer.render(g+1,f):null);let w=new Map,y=new Map,C=g=>{for(let x of g)if(x.type==="text"){let S=w.get(x.font);S||(S=new gt(x.font.parsed,`F${w.size+1}`),w.set(x.font,S));for(let F of x.glyphs)S.addGlyph(F.gid,F.cp)}else x.type==="image"?y.has(x.image.key)||y.set(x.image.key,{name:`Im${y.size+1}`,image:x.image}):(x.type==="group"||x.type==="clip")&&C(x.items)};C(e.items);for(let g of[...d,...u])g&&C(g.items);for(let g of w.values())g.finalize();let O={};for(let g of w.values())O[g.resourceName]=await g.embed(s);let R={};for(let g of y.values())R[g.name]=await Kt(s,g.image);let D=new Map,L={},j=g=>{let x=U(g),S=D.get(x);return S||(S=`GS${D.size+1}`,D.set(x,S),L[S]=s.add({Type:"ExtGState",ca:g,CA:g})),S},z=s.reserve(),X=[];for(let g=0;g<f;g++){let x=p[g],S=new pt,F=new Ut(S,t,w,y,j),E=x.headShift*.75,k=x.footShift*.75;S.save(),S.rect(t.left,a-c+k,i,c-E-k).clip(),F.setOrigin(a-E,x.start),F.render(e.items,x),S.restore();let I=a-E-(x.end-x.start)*.75;for(let b of x.feet){let T=(b.table.footBottom-b.table.footTop)*.75,B=I-b.shift*.75-T;S.save(),S.rect(t.left,B,i,T).clip(),F.setOrigin(B+T,b.table.footTop),F.render(b.table.footItems),S.restore()}for(let b of x.heads){S.save();let T=(b.table.headBottom-b.table.headTop)*.75;S.rect(t.left,a-b.shift*.75-T,i,T).clip(),F.setOrigin(a-b.shift*.75,b.table.headTop),F.render(b.table.headItems),S.restore()}let A=d[g];A&&(S.save(),S.rect(t.left,t.height-t.top-o,i,o).clip(),F.setOrigin(t.height-t.top,0),F.render(A.items),S.restore());let N=u[g];N&&(S.save(),S.rect(t.left,t.bottom,i,r).clip(),F.setOrigin(t.bottom+r,0),F.render(N.items),S.restore());let W=await s.addStream({},S.toBytes());X.push(s.add({Type:"Page",Parent:z,MediaBox:[0,0,t.width,t.height],Resources:{Font:O,XObject:R,ExtGState:L,ProcSet:[new J("PDF"),new J("Text"),new J("ImageC")]},Contents:W}))}s.set(z,{Type:"Pages",Kids:X,Count:X.length});let et=s.add({Type:"Catalog",Pages:z}),$=n.metadata??{},l={Producer:nt("receipt-html-to-pdf"),Creator:nt($.creator??"receipt-html-to-pdf"),CreationDate:Vt($.creationDate??new Date)};$.title&&(l.Title=nt($.title)),$.author&&(l.Author=nt($.author)),$.subject&&(l.Subject=nt($.subject)),$.keywords&&(l.Keywords=nt($.keywords));let m=s.add(l);return s.build(et,m)}function je(e,t){if(e.type==="text"){let s=(e.top+e.bottom)/2;return s>=t.start-.01&&s<t.end-.01}return We(e)>t.start+.01&&ze(e)<t.end-.01}var Ut=class{constructor(t,n,s,o,r){this.cs=t,this.geo=n,this.fonts=s,this.images=o,this.gsName=r,this.pdfTop=n.height-n.top,this.docTop=0,this.curAlpha=1}setOrigin(t,n){this.pdfTop=t,this.docTop=n}X(t){return this.geo.left+t*.75}Y(t){return this.pdfTop-(t-this.docTop)*.75}setAlpha(t){Math.abs(t-this.curAlpha)<.001||(this.cs.setGState(this.gsName(t)),this.curAlpha=t)}radiusPt(t){return(t??[0,0,0,0]).map(n=>n*.75)}clipBox(t){let n=this.cs;t.radius?n.roundedRect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75,this.radiusPt(t.radius)):n.rect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75),n.clip()}render(t,n){let s=this.cs;for(let o of t)if(!(n&&!je(o,n)))if(o.type==="rect"){if(o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),o.radius?s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).fill():s.fillRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="line")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.moveTo(this.X(o.x1),this.Y(o.y1)).lineTo(this.X(o.x2),this.Y(o.y2)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="stroke-rrect")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="image"){let r=this.images.get(o.image.key);if(!r||o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.alpha),o.clip&&this.clipBox(o.clip),s.image(r.name,this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="text"){let r=this.fonts.get(o.font),i=Ne(o,r);s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),s.text(r.resourceName,o.size*.75,this.X(o.x),this.Y(o.y),i),s.restore(),this.curAlpha=1}else if(o.type==="group"){let[r,i,a,c]=o.matrix,h=this.X(o.origin.x),p=this.Y(o.origin.y),f=r,d=-i,u=-a,w=c,y=h-(f*h+u*p)+o.matrix[4]*.75,C=p-(d*h+w*p)-o.matrix[5]*.75;s.save(),s.transform(f,d,u,w,y,C),this.render(o.items,n),s.restore()}else o.type==="clip"&&(s.save(),this.clipBox(o.box),this.render(o.items,n),s.restore())}};function Ne(e,t){let n=[],s="";for(let o=0;o<e.glyphs.length;o++){let r=e.glyphs[o];s+=rt(t.cid(r.gid));let i=e.glyphs[o+1];if(!i)break;let a=r.x+r.advance,h=-(i.x-a)/e.size*1e3;Math.abs(h)>=.5&&(n.push(s,Math.round(h*10)/10),s="")}return s&&n.push(s),n}function ze(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y:e.type==="line"?Math.min(e.y1,e.y2)-e.width/2:(e.type==="group"||e.type==="clip",e.top)}function We(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y+e.h:e.type==="line"?Math.max(e.y1,e.y2)+e.width/2:(e.type==="group"||e.type==="clip",e.bottom)}var Pn="0.2.0",yt=new ct;async function An(e){if(!e||!e.family||!e.src)throw new TypeError("registerFont: { family, src } are required");(await yt.register(e)).parsed.variable&&console.warn(`[receipt-html-to-pdf] "${e.family}" is a variable font; only the default instance outlines are embedded. Use static TTF instances for other weights.`)}function Mn(){return yt.fonts.map(e=>({family:e.displayFamily,weight:e.weight,style:e.style,glyphs:e.parsed.numGlyphs}))}async function In(e,t={}){if(typeof document>"u")throw new Error("htmlToPdf must run in a browser (needs DOM layout)");if(yt.fonts.length===0)throw new Error("htmlToPdf: no fonts registered. Call registerFont() with at least one TrueType font first.");let n=t.onWarning??(()=>{}),s=Qt(t.page),o=(s.width-s.left-s.right)/.75,r=await St(e,{widthPx:o,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n}),i={registry:yt,fontFallback:t.fontFallback??[],warn:n,textMeasure:t.textMeasure??"auto"},a={widthPx:o,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n};try{let c=await Ft(r.root,i),h=t.header?await te(t.header,a,i):null,p=t.footer?await te(t.footer,a,i):null,f=await Zt(c,s,{compress:t.compress??!0,metadata:t.metadata,header:h,footer:p});return Ge(f,t.output??"blob")}finally{r.destroy()}}async function te(e,t,n){let s=async(i,a)=>{let c=e.replace(/\{\{\s*pageNumber\s*\}\}/g,String(i)).replace(/\{\{\s*totalPages\s*\}\}/g,String(a)),h=await St(c,t);try{return await Ft(h.root,n)}finally{h.destroy()}},o=await s(1,1),r=new Map([["1/1",o]]);return{heightPx:o.height,render:async(i,a)=>{let c=`${i}/${a}`,h=r.get(c);return h||(h=await s(i,a),r.set(c,h)),h}}}function Ge(e,t){if(t==="uint8array")return e;if(t==="dataurl"){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,s+32768));return"data:application/pdf;base64,"+btoa(n)}return new Blob([e],{type:"application/pdf"})}function Rn(e,t){let n=e instanceof Blob?e:new Blob([e],{type:"application/pdf"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}export{Rn as downloadPdf,ot as expandPrintMediaCss,In as htmlToPdf,Mn as listFonts,An as registerFont,Pn as version};
|
|
41
|
+
`;return new TextEncoder().encode(o)}function dt(e){return e.toString(16).toUpperCase().padStart(4,"0")}function En(e){if(e<=65535)return dt(e);let t=e-65536;return dt(55296+(t>>10))+dt(56320+(t&1023))}async function Te(e,t){let n={Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceRGB",BitsPerComponent:8};if(t.jpeg)return n.Filter="DCTDecode",e.addStream(n,t.jpeg,{compress:!1});if(!t.rgb)throw new Error("embedImage: image has no pixel data");return t.alpha&&(n.SMask=await e.addStream({Type:"XObject",Subtype:"Image",Width:t.width,Height:t.height,ColorSpace:"DeviceGray",BitsPerComponent:8},t.alpha)),e.addStream(n,t.rgb)}function Ce(e,t){let s=t,o=e.height,r=[...e.atoms].sort((g,b)=>g.top-b.top),i=[...new Set(e.breaks)].sort((g,b)=>g-b),c=(e.joins??[]).map(g=>{let b=r.find(p=>p.top>=g.end-.01);return{start:g.start,limit:b?Math.max(b.top,g.end):g.end,pullTo:g.pullTo}}),a=.01,f=[],m=0,l=0;for(;m<o-a&&l++<1e4;){let g=[],b=0;for(let T of e.tables)T.headItems.length&&T.headBottom<=m+a&&m<T.bottom-a&&(g.push({table:T,shift:b}),b+=T.headBottom-T.headTop);let p=[],C=0,F=m;for(let T=0;T<4;T++){let v=Math.max(s-b-C,s*.25);F=d(m,v);let I=[],W=0;for(let G of e.tables)G.footItems.length&&G.top<F-a&&G.footTop>=F-a&&G.bottom>F+a&&(I.push({table:G,shift:W}),W+=G.footBottom-G.footTop);let q=I.length===p.length&&I.every((G,Q)=>G.table===p[Q]?.table);if(p=I,C=W,q)break}f.push({start:m,end:F,heads:g,headShift:b,feet:p,footShift:C}),m=F}return f.length||f.push({start:0,end:Math.max(o,1),heads:[],headShift:0,feet:[],footShift:0}),f;function d(g,b){let p=Math.min(g+b,o);for(let C of i)if(C>g+a&&C<p-a){p=C;break}if(p<o-a){let C=!0,F=0;for(;C&&F++<1e3;){C=!1;for(let T of r){if(T.top>=p)break;T.bottom-T.top>b||T.top<p-a&&T.bottom>p+a&&T.top>g+a&&(p=T.top,C=!0)}for(let T of c)T.limit-T.pullTo>b||T.pullTo<=g+a||p>=T.start-a&&p<=T.limit+a&&p>T.pullTo+a&&(p=T.pullTo,C=!0)}p<=g+a&&(p=Math.min(g+b,o))}return p}}function An(e,t,n){let s=t[0],o=t[t.length-1],r=o.t-s.t;if(!(r>0))return e.add({FunctionType:2,Domain:[0,1],C0:n(s.color),C1:n(o.color),N:1});if(t.length===2)return e.add({FunctionType:2,Domain:[0,1],C0:n(s.color),C1:n(o.color),N:1});let i=[],c=[],a=[];for(let f=0;f<t.length-1;f++){let m=t[f],l=t[f+1];i.push(e.add({FunctionType:2,Domain:[0,1],C0:n(m.color),C1:n(l.color),N:1})),a.push(0,1),f>0&&c.push((m.t-s.t)/r)}return e.add({FunctionType:3,Domain:[0,1],Functions:i,Bounds:c,Encode:a})}function Dt(e,t,n,s){let o=s==="rgb"?r=>[r.r,r.g,r.b]:r=>[r.a];return e.add({ShadingType:2,ColorSpace:new K(s==="rgb"?"DeviceRGB":"DeviceGray"),Coords:[t.x0,t.y0,t.x1,t.y1],Function:An(e,n,o),Extend:[!0,!0]})}function $e(e){let t=e[0].color.a;return e.every(n=>Math.abs(n.color.a-t)<.002)?t:null}async function Me(e,t,n,s,o){let r=o===1?n:n.map(f=>({t:f.t,color:{...f.color,a:f.color.a*o}})),i=Dt(e,t,r,"gray"),c=new TextEncoder().encode(`q ${s.x} ${s.y} ${s.w} ${s.h} re W n /Sh0 sh Q
|
|
42
|
+
`),a=await e.addStream({Type:new K("XObject"),Subtype:new K("Form"),BBox:[s.x,s.y,s.x+s.w,s.y+s.h],Group:{Type:new K("Group"),S:new K("Transparency"),CS:new K("DeviceGray")},Resources:{Shading:{Sh0:i}}},c);return e.add({Type:new K("ExtGState"),SMask:{Type:new K("Mask"),S:new K("Luminosity"),G:a,BC:[0]},ca:1,CA:1})}function ke(e={}){let t=e.size??"A4",n,s;if(typeof t=="string"){let i=Rt[t];if(!i)throw new Error(`Unknown page size "${t}". Use one of ${Object.keys(Rt).join(", ")} or {width, height}.`);n=i.width,s=i.height}else n=it(t.width),s=it(t.height);(e.orientation??"portrait")==="landscape"&&n<s&&([n,s]=[s,n]);let o=e.margin??"15mm",r=typeof o=="string"?{top:it(o),right:it(o),bottom:it(o),left:it(o)}:{top:it(o.top),right:it(o.right),bottom:it(o.bottom),left:it(o.left)};return{width:n,height:s,...r}}async function Ue(e,t,n){let s=new Ct({compress:n.compress}),o=(n.header?.heightPx??0)*.75,r=(n.footer?.heightPx??0)*.75,i=t.width-t.left-t.right,c=t.height-t.top-o,a=t.height-t.top-t.bottom-o-r;if(a<=0)throw new Error("Page content area is empty: margins + header + footer exceed the page height");let f=a/.75,m=Ce(e,f),l=m.length,d=[],g=[];for(let L=0;L<l;L++)d.push(n.header?await n.header.render(L+1,l):null),g.push(n.footer?await n.footer.render(L+1,l):null);let b=new Map,p=new Map,C=L=>{for(let M of L)if(M.type==="text"){let P=b.get(M.font);P||(P=new Ut(M.font.parsed,`F${b.size+1}`),b.set(M.font,P));for(let u of M.glyphs)P.addGlyph(u.gid,u.cp)}else M.type==="image"?p.has(M.image.key)||p.set(M.image.key,{name:`Im${p.size+1}`,image:M.image}):(M.type==="group"||M.type==="clip")&&C(M.items)};C(e.items);for(let L of[...d,...g])L&&C(L.items);for(let L of b.values())L.finalize();let F={};for(let L of b.values())F[L.resourceName]=await L.embed(s);let T={};for(let L of p.values()){let M=L.image;if(!M.jpeg&&!M.rgb){let P=await mt(M.key,n.warn??(()=>{}));if(!P)continue;M=P}T[L.name]=await Te(s,M),re(M),n.pacer&&await n.pacer()}let v=new Map,I={},W=(L,M=L)=>{let P=`${A(L)}/${A(M)}`,u=v.get(P);return u||(u=`GS${v.size+1}`,v.set(P,u),I[u]=s.add({Type:"ExtGState",ca:L,CA:M})),u},q={},G=new Map,Q=async L=>{for(let M of L)if(M.type==="gradient"){let P=`Sh${Object.keys(q).length+1}`;q[P]=Dt(s,M.gradient,M.gradient.stops,"rgb");let u=$e(M.gradient.stops),h=null;if(u===null){let y=await Me(s,M.gradient,M.gradient.stops,{x:0,y:0,w:M.box.w,h:M.box.h},M.alpha);h=`GM${G.size+1}`,I[h]=y}G.set(M,{sh:P,gs:h})}else(M.type==="group"||M.type==="clip")&&await Q(M.items)};await Q(e.items);for(let L of[...d,...g])L&&await Q(L.items);let O=s.reserve(),R=[];n.progress?.({phase:"layout",totalPages:l});for(let L=0;L<l;L++){n.pacer&&await n.pacer(),n.progress?.({phase:"page",page:L+1,totalPages:l});let M=m[L],P=new Mt,u=new Bt(P,t,b,p,W,G),h=M.headShift*.75,y=M.footShift*.75;P.save(),P.rect(t.left,c-a+y,i,a-h-y).clip(),u.setOrigin(c-h,M.start),u.render(e.items,M),P.restore();let x=c-h-(M.end-M.start)*.75;for(let $ of M.feet){let j=($.table.footBottom-$.table.footTop)*.75,E=x-$.shift*.75-j;P.save(),P.rect(t.left,E,i,j).clip(),u.setOrigin(E+j,$.table.footTop),u.render($.table.footItems),P.restore()}for(let $ of M.heads){P.save();let j=($.table.headBottom-$.table.headTop)*.75;P.rect(t.left,c-$.shift*.75-j,i,j).clip(),u.setOrigin(c-$.shift*.75,$.table.headTop),u.render($.table.headItems),P.restore()}let w=d[L];w&&(P.save(),P.rect(t.left,t.height-t.top-o,i,o).clip(),u.setOrigin(t.height-t.top,0),u.render(w.items),P.restore());let S=g[L];S&&(P.save(),P.rect(t.left,t.bottom,i,r).clip(),u.setOrigin(t.bottom+r,0),u.render(S.items),P.restore());let k=await s.addStream({},P.toBytes());R.push(s.add({Type:"Page",Parent:O,MediaBox:[0,0,t.width,t.height],Resources:{Font:F,XObject:T,ExtGState:I,Shading:q,ProcSet:[new K("PDF"),new K("Text"),new K("ImageC")]},Contents:k}))}s.set(O,{Type:"Pages",Kids:R,Count:R.length});let X=s.add({Type:"Catalog",Pages:O}),Y=n.metadata??{},et={Producer:ht("receipt-html-to-pdf"),Creator:ht(Y.creator??"receipt-html-to-pdf"),CreationDate:we(Y.creationDate??new Date)};Y.title&&(et.Title=ht(Y.title)),Y.author&&(et.Author=ht(Y.author)),Y.subject&&(et.Subject=ht(Y.subject)),Y.keywords&&(et.Keywords=ht(Y.keywords));let ot=s.add(et);return s.build(X,ot)}function In(e,t){if(e.type==="text"){let s=(e.top+e.bottom)/2;return s>=t.start-.01&&s<t.end-.01}return Ln(e)>t.start+.01&&Rn(e)<t.end-.01}var Bt=class{constructor(t,n,s,o,r,i){this.cs=t,this.geo=n,this.fonts=s,this.images=o,this.gsName=r,this.gradients=i,this.pdfTop=n.height-n.top,this.docTop=0,this.curAlpha=1}setOrigin(t,n){this.pdfTop=t,this.docTop=n}X(t){return this.geo.left+t*.75}Y(t){return this.pdfTop-(t-this.docTop)*.75}setAlpha(t){Math.abs(t-this.curAlpha)<.001||(this.cs.setGState(this.gsName(t)),this.curAlpha=t)}radiusPt(t){return(t??[0,0,0,0]).map(n=>n*.75)}clipBox(t){let n=this.cs;t.radius?n.roundedRect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75,this.radiusPt(t.radius)):n.rect(this.X(t.x),this.Y(t.y+t.h),t.w*.75,t.h*.75),n.clip()}render(t,n){let s=this.cs;for(let o of t)if(!(n&&!In(o,n)))if(o.type==="rect"){if(o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),o.radius?s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).fill():s.fillRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="line")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.moveTo(this.X(o.x1),this.Y(o.y1)).lineTo(this.X(o.x2),this.Y(o.y2)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="stroke-rrect")s.save(),this.setAlpha(o.color.a),s.strokeColor(o.color.r,o.color.g,o.color.b),s.lineWidth(o.width*.75),o.dash&&s.dash(o.dash.map(r=>r*.75)),s.roundedRect(this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75,this.radiusPt(o.radius)).stroke(),s.restore(),this.curAlpha=1;else if(o.type==="path"){if(!o.segs.length)continue;let[r,i,c,a,f,m]=o.matrix,l=.75,d=this.geo.left,g=this.pdfTop+this.docTop*l;s.save(),s.transform(l*r,-l*i,l*c,-l*a,l*f+d,-l*m+g),o.fill&&s.fillColor(o.fill.r,o.fill.g,o.fill.b),o.stroke&&(s.strokeColor(o.stroke.color.r,o.stroke.color.g,o.stroke.color.b),s.lineWidth(o.stroke.width),s.lineCap(o.stroke.cap),s.lineJoin(o.stroke.join),o.stroke.join===0&&s.miterLimit(o.stroke.miter),o.stroke.dash&&s.dash(o.stroke.dash,o.stroke.dashOffset));let b=o.fill?o.fill.a:1,p=o.stroke?o.stroke.color.a:1;(b!==1||p!==1)&&s.setGState(this.gsName(b,p)),s.path(o.segs),o.fill&&o.stroke?s.fillAndStroke(o.evenOdd):o.fill?s.fill(o.evenOdd):s.stroke(),s.restore(),this.curAlpha=1}else if(o.type==="gradient"){let r=this.gradients.get(o);if(!r||o.box.w<=0||o.box.h<=0)continue;s.save(),this.clipBox(o.clip),s.transform(.75,0,0,-.75,this.X(o.box.x),this.Y(o.box.y)),r.gs?s.setGState(r.gs):this.setAlpha(o.alpha),s.shading(r.sh),s.restore(),this.curAlpha=1}else if(o.type==="image"){let r=this.images.get(o.image.key);if(!r||o.w<=0||o.h<=0)continue;s.save(),this.setAlpha(o.alpha),o.clip&&this.clipBox(o.clip),s.image(r.name,this.X(o.x),this.Y(o.y+o.h),o.w*.75,o.h*.75),s.restore(),this.curAlpha=1}else if(o.type==="text"){let r=this.fonts.get(o.font),i=Nn(o,r);s.save(),this.setAlpha(o.color.a),s.fillColor(o.color.r,o.color.g,o.color.b),s.text(r.resourceName,o.size*.75,this.X(o.x),this.Y(o.y),i),s.restore(),this.curAlpha=1}else if(o.type==="group"){let[r,i,c,a]=o.matrix,f=this.X(o.origin.x),m=this.Y(o.origin.y),l=r,d=-i,g=-c,b=a,p=f-(l*f+g*m)+o.matrix[4]*.75,C=m-(d*f+b*m)-o.matrix[5]*.75;s.save(),s.transform(l,d,g,b,p,C),this.render(o.items,n),s.restore()}else o.type==="clip"&&(s.save(),this.clipBox(o.box),this.render(o.items,n),s.restore())}};function Nn(e,t){let n=[],s="";for(let o=0;o<e.glyphs.length;o++){let r=e.glyphs[o];s+=dt(t.cid(r.gid));let i=e.glyphs[o+1];if(!i)break;let c=r.x+r.advance,f=-(i.x-c)/e.size*1e3;Math.abs(f)>=.5&&(n.push(s,Math.round(f*10)/10),s="")}return s&&n.push(s),n}function Rn(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y:e.type==="gradient"?e.clip.y:e.type==="path"?e.top:e.type==="line"?Math.min(e.y1,e.y2)-e.width/2:(e.type==="group"||e.type==="clip",e.top)}function Ln(e){return e.type==="rect"||e.type==="stroke-rrect"||e.type==="image"?e.y+e.h:e.type==="gradient"?e.clip.y+e.clip.h:e.type==="path"?e.bottom:e.type==="line"?Math.max(e.y1,e.y2)+e.width/2:(e.type==="group"||e.type==="clip",e.bottom)}function vn(){let e=globalThis.scheduler;return e&&typeof e.yield=="function"?e.yield():new Promise(t=>{if(typeof MessageChannel=="function"){let n=new MessageChannel;n.port1.onmessage=()=>{n.port1.close(),t()},n.port2.postMessage(0)}else setTimeout(t,0)})}function Fe(e=12){let t=()=>typeof performance<"u"?performance.now():Date.now(),n=t();return async()=>{t()-n<e||(await vn(),n=t())}}var Oo="0.3.0",Ft=new yt;async function Do(e){if(!e||!e.family||!e.src)throw new TypeError("registerFont: { family, src } are required");(await Ft.register(e)).parsed.variable&&console.warn(`[receipt-html-to-pdf] "${e.family}" is a variable font; only the default instance outlines are embedded. Use static TTF instances for other weights.`)}function Bo(){return Ft.fonts.map(e=>({family:e.displayFamily,weight:e.weight,style:e.style,glyphs:e.parsed.numGlyphs}))}async function jo(e,t={}){if(typeof document>"u")throw new Error("htmlToPdf must run in a browser (needs DOM layout)");if(Ft.fonts.length===0)throw new Error("htmlToPdf: no fonts registered. Call registerFont() with at least one TrueType font first.");let n=t.onWarning??(()=>{}),s=t.onProgress??(()=>{}),o=Fe(),r=ke(t.page),i=(r.width-r.left-r.right)/.75;s({phase:"render"});let c=await It(e,{widthPx:i,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n}),a={registry:Ft,fontFallback:t.fontFallback??[],warn:n,textMeasure:t.textMeasure??"auto",pacer:o},f={widthPx:i,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n};try{s({phase:"walk"});let m=await Ot(c.root,a),l=t.header?await Pe(t.header,f,a):null,d=t.footer?await Pe(t.footer,f,a):null,g=await Ue(m,r,{compress:t.compress??!0,metadata:t.metadata,header:l,footer:d,pacer:o,progress:s,warn:n});return s({phase:"done"}),On(g,t.output??"blob")}finally{c.destroy()}}async function Pe(e,t,n){let s=async(i,c)=>{let a=e.replace(/\{\{\s*pageNumber\s*\}\}/g,String(i)).replace(/\{\{\s*totalPages\s*\}\}/g,String(c)),f=await It(a,t);try{return await Ot(f.root,n)}finally{f.destroy()}},o=await s(1,1),r=new Map([["1/1",o]]);return{heightPx:o.height,render:async(i,c)=>{let a=`${i}/${c}`,f=r.get(a);return f||(f=await s(i,c),r.set(a,f)),f}}}function On(e,t){if(t==="uint8array")return e;if(t==="dataurl"){let n="";for(let s=0;s<e.length;s+=32768)n+=String.fromCharCode(...e.subarray(s,s+32768));return"data:application/pdf;base64,"+btoa(n)}return new Blob([e],{type:"application/pdf"})}function Go(e,t){let n=e instanceof Blob?e:new Blob([e],{type:"application/pdf"}),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e3)}export{Go as downloadPdf,pt as expandPrintMediaCss,jo as htmlToPdf,Bo as listFonts,Do as registerFont,Oo as version};
|
|
42
43
|
//# sourceMappingURL=receipt-html-to-pdf.min.js.map
|