@hidemikimura/receipt-html-to-pdf 0.3.0 → 0.4.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 +12 -0
- package/README.md +8 -7
- package/dist/receipt-html-to-pdf.min.js +16 -16
- package/dist/receipt-html-to-pdf.min.js.map +4 -4
- package/examples/cdn.html +2 -2
- package/package.json +1 -1
- package/skills/receipt-html-to-pdf/SKILL.md +9 -1
- package/src/index.js +5 -1
- package/src/page.js +96 -16
- package/src/pdf/outline.js +103 -0
- package/src/walker/walk.js +59 -2
- package/types/index.d.ts +11 -1
- package/types/page.d.ts +3 -1
- package/types/pdf/outline.d.ts +41 -0
- package/types/walker/walk.d.ts +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
設計と経緯の詳細は docs/design.md。
|
|
4
4
|
|
|
5
|
+
## 0.4.0 — リンク注釈としおり(2026-09-20)
|
|
6
|
+
|
|
7
|
+
### 追加
|
|
8
|
+
|
|
9
|
+
- **リンク注釈に対応**。`<a href>` を PDF のリンク注釈(`/Annot /Link`)にする。既定で有効、止めるなら `links: false`(docs/design.md 26 章)
|
|
10
|
+
- 外部 URL・`mailto:` / `tel:`・文書内リンク(`href="#id"` → その要素が載るページへ `/Dest [page /XYZ]`)。`<a name>` も飛び先になる
|
|
11
|
+
- 折り返したインラインリンクは行ごとに、ページ境界を跨ぐリンクはページごとに切り取って注釈を作る
|
|
12
|
+
- ヘッダー/フッターの中のリンクも各ページに出る
|
|
13
|
+
- `javascript:` と、飛び先の無い `#id` は注釈にしない。相対 URL は `baseUrl` で解決する
|
|
14
|
+
- `transform` の中のリンクは外接矩形で近似する(PDF の注釈は軸並行の矩形しか持てないため)
|
|
15
|
+
- **`outline: true` でしおり(`/Outlines`)を作る**。`h1`〜`h6` の入れ子から目次の木を組み立て、各項目をその見出しのページへ飛ばす。既定は作らない
|
|
16
|
+
|
|
5
17
|
## 0.3.0 — 描画と大きな文書の強化(2026-09-20)
|
|
6
18
|
|
|
7
19
|
### 追加
|
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
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.
|
|
14
|
-
> Chromium / Firefox / WebKit の 3 ブラウザで Playwright
|
|
13
|
+
> **v0.4.0** — テキスト・背景・ボーダー・画像・角丸・2D transform・擬似要素・`overflow: hidden`・シャドウ DOM(Web Components)・`linear-gradient`・インライン `<svg>` のベクター変換・`background-repeat`・GSUB の単一置換・複数ページに加え、**リンク注釈**(外部 URL・`mailto:`・文書内 `#id`)と**しおり**(`outline: true`)に対応。長い文書では途中でイベントループへ戻すので画面が固まらず、`onProgress` で進捗を出せる。依存ゼロ、minify バンドルは gzip 28KB。
|
|
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
|
## 使い方
|
|
17
17
|
|
|
@@ -39,7 +39,7 @@ 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`、`onProgress`。
|
|
42
|
+
主なオプション(`ConvertOptions`、型は `types/index.d.ts`): `page: { size, orientation, margin }`、`header` / `footer`(`{{pageNumber}}` `{{totalPages}}`)、`stylesheets: 'inherit' | 'none' | [url または CSS 文字列]`、`mediaPrint`、`fontFallback`、`metadata`、`compress`、`baseUrl`、`links`(既定 true、`<a href>` をリンク注釈にする)、`outline`(既定 false、見出しからしおりを作る)、`onWarning`、`onProgress`。
|
|
43
43
|
|
|
44
44
|
長い文書でも画面が固まらないよう、変換は途中でイベントループへ戻る。進捗表示を出すなら `onProgress` を使う。
|
|
45
45
|
|
|
@@ -66,14 +66,14 @@ npm install @hidemikimura/receipt-html-to-pdf
|
|
|
66
66
|
```html
|
|
67
67
|
<script type="module">
|
|
68
68
|
import { registerFont, htmlToPdf, downloadPdf }
|
|
69
|
-
from 'https://cdn.jsdelivr.net/npm/@hidemikimura/receipt-html-to-pdf@0.
|
|
69
|
+
from 'https://cdn.jsdelivr.net/npm/@hidemikimura/receipt-html-to-pdf@0.4.0/dist/receipt-html-to-pdf.min.js';
|
|
70
70
|
|
|
71
71
|
await registerFont({ family: 'BIZ UDPGothic', src: '/fonts/BIZUDPGothic-Regular.ttf' });
|
|
72
72
|
downloadPdf(await htmlToPdf(document.querySelector('#receipt')), 'receipt.pdf');
|
|
73
73
|
</script>
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
バージョン(`@0.
|
|
76
|
+
バージョン(`@0.4.0`)は固定すること。unpkg でも同じ。グローバル変数を配るビルド(IIFE / UMD)は用意していないが、`import * as ReceiptHtmlToPdf` して `window` に載せれば `type="module"` でない普通のスクリプトからも呼べる。ファイル 1 つで動く一式は [`examples/cdn.html`](examples/cdn.html)。
|
|
77
77
|
|
|
78
78
|
## 開発
|
|
79
79
|
|
|
@@ -101,7 +101,7 @@ brew install qpdf # 任意: 生成 PDF の構造
|
|
|
101
101
|
|
|
102
102
|
CI(`.github/workflows/ci.yml`)は typecheck → 単体テスト → サイズ検査の後、3 ブラウザ並列でブラウザテストを流し、生成された PDF を `qpdf --check` で検証する。
|
|
103
103
|
|
|
104
|
-
## 対応範囲(v0.
|
|
104
|
+
## 対応範囲(v0.4.0)
|
|
105
105
|
|
|
106
106
|
| 対応 | 未対応(onWarning で通知) |
|
|
107
107
|
|---|---|
|
|
@@ -110,6 +110,7 @@ CI(`.github/workflows/ci.yml`)は typecheck → 単体テスト → サイ
|
|
|
110
110
|
| `<img>`(PNG 透過 / JPEG、`object-fit`)、`background-image: url()`(size / position)、`overflow: hidden` のクリップ、**インライン `<svg>` のベクター変換**(パス・基本図形・塗り・線・破線・変換行列) | SVG の `<text>` / `<use>` / paint server(警告)、`<img src="x.svg">` はラスタライズ |
|
|
111
111
|
| `transform`(2D、`transform-origin`)、`::before` / `::after`(文字列 content) | 3D transform、`counter()` / `url()` content |
|
|
112
112
|
| 複数ページ: 行・`tr`・`thead`・`tfoot`・`<img>`・`break-inside: avoid` を跨がない分割、`break-before/after: page`、`break-before/after: avoid`(隣の箱と同じページに保つ)、`thead` / `tfoot` の各ページ繰り返し、`header` / `footer` テンプレート(`{{pageNumber}}` `{{totalPages}}`) | `orphans` / `widows`、ページ番号による高さ変化 |
|
|
113
|
+
| リンク注釈(`<a href>` の外部 URL・`mailto:`・文書内 `#id`、ページ跨ぎは分割)、`outline: true` で `h1`〜`h6` からしおり | `transform` 内のリンクは外接矩形で近似、`javascript:` は無視 |
|
|
113
114
|
| Web Components: シャドウ DOM のホスト要素をそのまま変換(宣言的シャドウ DOM で直列化)、`<slot>` の割り当て、`:host` / `::slotted()`、`adoptedStyleSheets`、`:defined` | `closed` なシャドウルート、`Element.getHTML()` の無いブラウザ(警告して light DOM のみ) |
|
|
114
115
|
| レイアウト全般(Flexbox / Grid / テーブル / 禁則 / letter-spacing)はブラウザ計算をそのまま利用 | |
|
|
115
116
|
|
|
@@ -149,7 +150,7 @@ npm run site:dev # 組み立てて http://localhost:5174 で表示
|
|
|
149
150
|
2. `npm run pack:check` で tarball の内容を確認する(`files` で許可リスト管理。フォント・フィクスチャ・テストは含まれない)
|
|
150
151
|
3. `npm login`(スコープ `@hidemikimura` の所有者アカウント)
|
|
151
152
|
4. `npm publish` — `prepublishOnly` が typecheck → 単体テスト → `.d.ts` 生成 → minify ビルド + サイズ検査を自動で流す。`publishConfig.access` が `public` なのでスコープ付きでも無料で公開される
|
|
152
|
-
5. `git tag v0.
|
|
153
|
+
5. `git tag v0.4.0 && git push --tags`
|
|
153
154
|
|
|
154
155
|
## ライセンス
|
|
155
156
|
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/* @hidemikimura/receipt-html-to-pdf v0.
|
|
2
|
-
function
|
|
1
|
+
/* @hidemikimura/receipt-html-to-pdf v0.4.0 | MIT */
|
|
2
|
+
function Xt(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 l=0;l<o;l++){let h=12+l*16,y=String.fromCharCode(t[h]??0,t[h+1]??0,t[h+2]??0,t[h+3]??0);r.set(y,{offset:n.getUint32(h+8),length:n.getUint32(h+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 l of["head","hhea","maxp","hmtx","loca","glyf"])if(!r.has(l))throw new Error(`Font is missing required table: ${l}`);let c=l=>r.get(l),a=c("head"),u=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)],f=n.getUint16(a.offset+44),b=n.getInt16(a.offset+50),g=c("hhea"),d=n.getInt16(g.offset+4),p=n.getInt16(g.offset+6),T=n.getInt16(g.offset+8),P=n.getUint16(g.offset+34),x=n.getUint16(c("maxp").offset+4),L=c("hmtx"),N=new Uint16Array(x),q=0;for(let l=0;l<x;l++)l<P&&(q=n.getUint16(L.offset+l*4)),N[l]=q;let H=c("loca"),W=new Uint32Array(x+1);for(let l=0;l<=x;l++)W[l]=b===0?n.getUint16(H.offset+l*2)*2:n.getUint32(H.offset+l*4);let J=r.get("cmap"),D=J?Le(n,J.offset):new Map,B=Math.round(d*.7),K=!1,ft=d,nt=p,st=d,at=-p,ct=(f&1)!==0,Y=(f&2)!==0,Z=r.get("OS/2");if(Z){let l=n.getUint16(Z.offset),h=n.getUint16(Z.offset+62);if(K=(h&128)!==0,ct=ct||(h&32)!==0,Y=Y||(h&1)!==0,ft=n.getInt16(Z.offset+68),nt=n.getInt16(Z.offset+70),st=n.getUint16(Z.offset+74),at=n.getUint16(Z.offset+76),l>=2&&Z.length>=90){let y=n.getInt16(Z.offset+88);y>0&&(B=y)}}let rt=0,$=r.get("post");$&&(rt=n.getInt32($.offset+4)/65536);let S=Oe(n,t,r.get("name"))??"Embedded";return{data:t,tables:r,unitsPerEm:u,indexToLocFormat:b,bbox:m,ascender:d,descender:p,lineGap:T,numGlyphs:x,advances:N,loca:W,cmap:D,capHeight:B,italicAngle:rt,useTypoMetrics:K,typoAscender:ft,typoDescender:nt,winAscent:st,winDescent:at,postScriptName:S,bold:ct,italic:Y,variable:i}}function Le(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,u=e.getUint16(a),m=e.getUint16(a+2),f=e.getUint32(a+4),b=e.getUint16(t+f),g=-1;u===3&&m===10&&b===12?g=4:u===0&&(m===4||m===6)&&b===12?g=3:u===3&&m===1&&b===4?g=2:u===0&&b===4&&(g=1),g>o&&(o=g,s=t+f)}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,u=s+14,m=u+c+2,f=m+c,b=f+c;for(let g=0;g<a;g++){let d=e.getUint16(u+g*2),p=e.getUint16(m+g*2),T=e.getInt16(f+g*2),P=e.getUint16(b+g*2);if(p!==65535)for(let x=p;x<=d;x++){let L;if(P===0)L=x+T&65535;else{let N=b+g*2+P+(x-p)*2;if(N+2>e.byteLength)continue;L=e.getUint16(N),L!==0&&(L=L+T&65535)}L!==0&&r.set(x,L)}}}else if(i===12){let c=e.getUint32(s+12),a=s+16;for(let u=0;u<c;u++,a+=12){let m=e.getUint32(a),f=e.getUint32(a+4),b=e.getUint32(a+8);for(let g=m;g<=f&&g-m<65536;g++){let d=b+(g-m);d!==0&&r.set(g,d)}}}return r}function Oe(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),u=e.getUint16(c+6),m=e.getUint16(c+8),f=e.getUint16(c+10);if(u!==6)continue;let b=n.offset+o+f;if(a===1)return _t(String.fromCharCode(...t.subarray(b,b+m)));if(a===3||a===0){let g="";for(let d=0;d+1<m;d+=2)g+=String.fromCharCode(e.getUint16(b+d));r=_t(g)}}return r}function _t(e){return e.replace(/[^\x21-\x7e]/g,"").replace(/[\[\]\(\)\{\}<>\/%#]/g,"")||"Embedded"}function It(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 Yt(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 Tt=class{constructor(){this.fonts=[]}async register(t){let n=await De(t.src),s=Xt(n),o={family:Rt(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=Rt(t);return this.fonts.some(s=>s.family===n)}match(t,n,s,o){for(let r of t){let i=Rt(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 Zt(c,n,s)}return null}anyWithGlyph(t,n,s){let o=this.fonts.filter(r=>r.parsed.cmap.has(t));return o.length?Zt(o,n,s):null}};function Zt(e,t,n){let s=e.filter(u=>u.style===n),o=s.length?s:e,r=o.find(u=>u.weight===t);if(r)return r;let i=[...o].sort((u,m)=>u.weight-m.weight),c=i.filter(u=>u.weight>t),a=i.filter(u=>u.weight<t).reverse();if(t>=400&&t<=500){let u=c.find(m=>m.weight<=500);return u||(a.length?a[0]:c[0])}return t<400?a[0]??c[0]:c[0]??a[0]}function Rt(e){return e.trim().replace(/^["']|["']$/g,"").trim().toLowerCase()}function Kt(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 Qt(e){if(e==="bold")return 700;if(e==="normal")return 400;let t=parseInt(e,10);return Number.isFinite(t)?t:400}async function De(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 Lt(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=Be(e,t);o.open(),o.write(r),o.close(),Ve(o,s);let i=()=>{n.style.height=`${Math.max(o.documentElement.scrollHeight,o.body.scrollHeight,100)}px`};return i(),await Xe(o),i(),await Ye(o),await Ze(o),Ke(o,t.warn??(()=>{})),i(),o.body.offsetHeight,Ge(o,t.widthPx,t.warn??(()=>{})),{iframe:n,doc:o,win:s,root:o.body,destroy:()=>n.remove()}}function Be(e,t){let n=t.baseUrl??document.baseURI,s=`<base href="${wt(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,f=>`${f}${s}${o}`):m.replace(/<html[^>]*>/i,f=>`${f}<head>${s}${o}</head>`),t.mediaPrint?_e(m):m}let u=Jt(t.stylesheets,t.mediaPrint);return`<!DOCTYPE html><html><head><meta charset="utf-8">${s}${o}${u}</head><body>${e}</body></html>`}let r=Jt(t.stylesheets,t.mediaPrint)+je(e,t.stylesheets,t.mediaPrint),i=vt(document.documentElement),c=vt(document.body),a=ze(e,t.warn??(()=>{}));return`<!DOCTYPE html><html${i}><head><meta charset="utf-8">${s}${o}${r}</head><body${c}>${a}</body></html>`}function Jt(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?bt(r):r}</style>`)}else o instanceof HTMLLinkElement&&n.push(`<link rel="stylesheet" href="${wt(o.href)}"${o.media?` media="${wt(o.media)}"`:""}>`);let s=Ot(document.adoptedStyleSheets);return s&&n.push(`<style>${t?bt(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="${wt(s)}">`):n.push(`<style>${t?bt(s):s}</style>`);return n.join("")}function je(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 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}
|
|
4
|
+
`+Ot(r.adoptedStyleSheets);i.trim()&&s.unshift(i),o=r.host.getRootNode()}return s.map(r=>`<style>${n?bt(r):r}</style>`).join("")}function Ge(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 We=new Set(["AREA","BASE","BR","COL","EMBED","HR","IMG","INPUT","LINK","META","SOURCE","TRACK","WBR"]);function ze(e,t){let n=e===document.body||e===document.documentElement,s=qe(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=He(s);try{let i={serializableShadowRoots:!0,shadowRoots:s},c=o.getHTML(i);if(n)return c;let a=e.tagName.toLowerCase();return We.has(e.tagName)?e.outerHTML:`<${a}${vt(e)}>${c}</${a}>`}finally{r()}}function qe(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 He(e){let t=[];for(let n of e){let s=Ot(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 Ot(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 Ve(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 _e(e){return e.replace(/<style([^>]*)>([\s\S]*?)<\/style>/gi,(t,n,s)=>`<style${n}>${bt(s)}</style>`)}function bt(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 vt(e){let t="";for(let n of e.attributes)/^on/i.test(n.name)||(t+=` ${n.name}="${wt(n.value)}"`);return t}function wt(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<")}async function Xe(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 Ye(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 Ze(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 Ke(e,t){let n=e.defaultView;if(!n)return;let s=[];for(let i of Qe(e.body))for(let c of["before","after"]){let a=n.getComputedStyle(i,`::${c}`),u=a.content;if(!u||u==="none"||u==="normal"||a.display==="none")continue;let m=Je(u);if(m===null){t({code:"unsupported-css",message:`::${c} content "${u}" is not supported (only quoted strings are); the pseudo-element is skipped`,element:i,property:"content"});continue}let f=[];for(let b=0;b<a.length;b++){let g=a[b];g==="content"||g.startsWith("-webkit-")||g.startsWith("-moz-")||f.push([g,a.getPropertyValue(g)])}s.push({el:i,pseudo:c,text:m,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(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[u,m]of i.styles)c.style.setProperty(u,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 Qe(e){let t=[],n=s=>{for(let o of s.querySelectorAll("*"))t.push(o),o.shadowRoot&&n(o.shadowRoot)};return n(e),t}function Je(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 lt=2.834645669291339,Dt={A3:{width:297*lt,height:420*lt},A4:{width:210*lt,height:297*lt},A5:{width:148*lt,height:210*lt},B4:{width:257*lt,height:364*lt},B5:{width:182*lt,height:257*lt},Letter:{width:612,height:792},Legal:{width:612,height:1008}};function ut(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*lt;case"cm":return n*lt*10;case"in":return n*72;case"pc":return n*12;default:throw new Error(`Unsupported CSS unit: ${e}`)}}function et(e){let t=parseFloat(e);return Number.isFinite(t)?t:0}function pt(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:mt(parseFloat(n[1])/255),g:mt(parseFloat(n[2])/255),b:mt(parseFloat(n[3])/255),a:mt(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:mt(parseFloat(n[1])),g:mt(parseFloat(n[2])),b:mt(parseFloat(n[3])),a:mt(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 mt(e){return e<0?0:e>1?1:e}function I(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 tn(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 f=0;f<c;f++){let b=o+2+f*6,g=String.fromCharCode(n.getUint8(b),n.getUint8(b+1),n.getUint8(b+2),n.getUint8(b+3)),d=o+n.getUint16(b+4),p=n.getUint16(d+2),T=i.get(g)??[];for(let P=0;P<p;P++)T.push(n.getUint16(d+4+P*2));i.set(g,T)}let a=n.getUint16(r),u=new Map;return{features:i,lookup:f=>{if(u.has(f))return u.get(f)??null;let b=null;if(f>=0&&f<a){let g=r+n.getUint16(r+2+f*2);b=en(n,g,n.getUint16(g),n.getUint16(g+4),g+6)}return u.set(f,b),b}}}catch{return null}}function en(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)}nn(e,c,r)}return r.size?r:null}function nn(e,t,n){let s=e.getUint16(t),o=on(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 on(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),u=e.getUint16(i+4);for(let m=c;m<=a;m++)s[u+(m-c)]=m}}return s}function te(e,t){let n=tn(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 u of o)a=u.get(a)??a;return r.set(i,a),a}}var sn={"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 ee(e){let t=new Set,n=`${e.fontVariantNumeric??""} ${e.fontVariantCaps??""} ${e.fontVariantEastAsian??""}`.split(/\s+/);for(let o of n){let r=sn[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 rn=new Set([32,9,10,13,12,160,12288,8194,8195,8201,8202,8239,8287]);function se(e,t,n){let s=e.ownerDocument,o=fn(e.data,t.textTransform),r=s.createRange(),i=un(s,t),c=[],a=null,u=NaN,m=new Set;for(let f=0;f<o.length;){let b=o.codePointAt(f),g=b>65535?2:1,d=f+g;r.setStart(e,f),r.setEnd(e,Math.min(d,e.data.length));let p=cn(r.getClientRects());if(f=d,!p)continue;let T=ln(b,n,m);if(!T)continue;let{font:P,gid:x,cpForUnicode:L}=T,N=p.top;(!a||a.font!==P||Math.abs(N-u)>.5)&&(a={font:P,baseline:N+i,top:N,bottom:p.bottom,glyphs:[]},u=N,c.push(a)),a.top=Math.min(a.top,N),a.bottom=Math.max(a.bottom,p.bottom);let q=n.features.length?an(P.parsed,n.features):null,H=q?q(x):x,W=(P.parsed.advances[H]??0)*n.size/P.parsed.unitsPerEm;a.glyphs.push({gid:H,cp:L,x:p.left,advance:W})}return c}var ne=new WeakMap;function an(e,t){let n=ne.get(e);n||(n=new Map,ne.set(e,n));let s=[...t].sort().join(",");if(n.has(s))return n.get(s)??null;let o=te(e,t);return n.set(s,o),o}function cn(e){let t=null;for(let n of e)n.width>.01&&(!t||n.width>t.width)&&(t=n);return t}function ln(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(rn.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 fn(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 oe=new WeakMap;function un(e,t){let n=[t.fontFamily,t.fontSize,t.fontWeight,t.fontStyle,t.fontStretch,t.fontVariant,t.fontFeatureSettings].join("|"),s=oe.get(e);s||(s=new Map,oe.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 u=a.getBoundingClientRect(),f=c.getBoundingClientRect().bottom-u.top;r.remove();let b=Number.isFinite(f)&&f>0?f:parseFloat(t.fontSize)*.8;return s.set(n,b),b}var Bt=new Map;function xt(e,t,n){let s=Bt.get(e);return s||(s=hn(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)),Bt.set(e,s)),s}async function hn(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=pn(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,T)=>{o.onload=()=>p(void 0),o.onerror=()=>T(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 u=a.getContext("2d",{willReadFrequently:!0});if(!u)throw new Error("2D canvas unavailable");u.drawImage(o,0,0);let m;try{m=u.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 f=m.data,b=new Uint8Array(i*c*3),g=new Uint8Array(i*c),d=!0;for(let p=0,T=0,P=0;p<f.length;p+=4,T+=3,P++){let x=f[p+3];x===0?b[T]=b[T+1]=b[T+2]=255:(b[T]=f[p],b[T+1]=f[p+1],b[T+2]=f[p+2]),g[P]=x,x!==255&&(d=!1)}return{key:e,width:i,height:c,jpeg:null,rgb:b,alpha:d?null:g}}function pn(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 ae(e){if(!e||e==="none")return null;let t=dn(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 dn(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 Ct(e,t,n,s,o){let r,i,c=s.trim();if(c==="cover"||c==="contain"){let b=c==="cover"?Math.max(e.w/t,e.h/n):Math.min(e.w/t,e.h/n);r=t*b,i=n*b}else{let[b="auto",g="auto"]=c.split(/\s+/),d=re(b,e.w),p=re(g,e.h);d===null&&p===null?(r=t,i=n):d===null?(i=p,r=t*i/n):p===null?(r=d,i=n*r/t):(r=d,i=p)}let[a="0%",u="0%"]=o.trim().split(/\s+/),m=e.x+ie(a,e.w-r),f=e.y+ie(u,e.h-i);return{x:m,y:f,w:r,h:i}}function re(e,t){return e==="auto"?null:e.endsWith("%")?parseFloat(e)/100*t:parseFloat(e)||0}function ie(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 ce(e){switch(e){case"contain":case"scale-down":return"contain";case"cover":return"cover";case"none":return"auto";default:return"100% 100%"}}function le(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 jt(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)),u=r/a;return{positions:Array.from({length:a},(m,f)=>s+f*u),size:u}}if(e==="space"){let a=Math.floor(r/n);if(a<2)return{positions:[s],size:n};let u=(r-a*n)/(a-1);return{positions:Array.from({length:a},(m,f)=>s+f*(n+u)),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 fe(e){e.jpeg=null,e.rgb=null,e.alpha=null,Bt.delete(e.key)}function he(e,t,n){let s=/^linear-gradient\((.*)\)$/s.exec(e.trim());if(!s)return null;let o=wn(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(),u=gn(a);u!==null?(i=u,r=1):/^in\s/i.test(c)&&a===""&&(r=1);let m=o.slice(r).map(N=>N.trim());if(m.length<2)return null;let f=i*Math.PI/180,b=Math.sin(f),g=Math.cos(f),d=Math.abs(t*b)+Math.abs(n*g);if(!(d>0))return null;let p=[];for(let N of m){let q=mn(N);if(!q)return null;let H=pt(q.color);if(!H)return null;if(!q.positions.length){p.push({t:NaN,color:H});continue}for(let W of q.positions){let J=bn(W,d);if(J===null)return null;p.push({t:J,color:H})}}if(p.length<2)return null;yn(p);let T=t/2,P=n/2,x=b,L=-g;return{x0:T-x*d/2,y0:P-L*d/2,x1:T+x*d/2,y1:P+L*d/2,stops:p}}function gn(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 mn(e){let t=/^([a-z-]+\([^()]*\))\s*(.*)$/i.exec(e);if(t)return{color:t[1],positions:ue(t[2])};let n=/^(\S+)\s*(.*)$/.exec(e);return n?{color:n[1],positions:ue(n[2])}:null}function ue(e){let t=e.trim();return t?t.split(/\s+/):[]}function bn(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 yn(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 wn(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 xn(e){let t=[],n=Sn(e),s=0,o=0,r=0,i=0,c=0,a=null,u=null,m="",f=()=>{let g=n[s++];return typeof g=="number"?g:NaN},b=()=>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(),d=m.toUpperCase(),p=g?o:0,T=g?r:0;if(d==="M"){o=f()+p,r=f()+T,t.push(["M",o,r]),i=o,c=r,a=u=null,m=g?"l":"L";continue}if(d==="Z"){t.push(["Z"]),o=i,r=c,a=u=null;continue}if(d==="L")o=f()+p,r=f()+T,t.push(["L",o,r]),a=u=null;else if(d==="H")o=f()+p,t.push(["L",o,r]),a=u=null;else if(d==="V")r=f()+T,t.push(["L",o,r]),a=u=null;else if(d==="C"){let P=f()+p,x=f()+T,L=f()+p,N=f()+T;o=f()+p,r=f()+T,t.push(["C",P,x,L,N,o,r]),a=[L,N],u=null}else if(d==="S"){let P=a?2*o-a[0]:o,x=a?2*r-a[1]:r,L=f()+p,N=f()+T;o=f()+p,r=f()+T,t.push(["C",P,x,L,N,o,r]),a=[L,N],u=null}else if(d==="Q"||d==="T"){let P,x;d==="Q"?(P=f()+p,x=f()+T):(P=u?2*o-u[0]:o,x=u?2*r-u[1]:r);let L=f()+p,N=f()+T;t.push(["C",o+2/3*(P-o),r+2/3*(x-r),L+2/3*(P-L),N+2/3*(x-N),L,N]),o=L,r=N,u=[P,x],a=null}else if(d==="A"){let P=f(),x=f(),L=f(),N=f(),q=f(),H=f()+p,W=f()+T;for(let J of Tn(o,r,H,W,P,x,L,N!==0,q!==0))t.push(J);o=H,r=W,a=u=null}else break;if(!b()&&typeof n[s]!="string")break}return t}function Sn(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 Tn(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 u=i*Math.PI/180,m=Math.cos(u),f=Math.sin(u),b=(e-n)/2,g=(t-s)/2,d=m*b+f*g,p=-f*b+m*g,T=d*d/(o*o)+p*p/(r*r);if(T>1){let Y=Math.sqrt(T);o*=Y,r*=Y}let P=c===a?-1:1,x=o*o*r*r-o*o*p*p-r*r*d*d,L=o*o*p*p+r*r*d*d,N=P*Math.sqrt(Math.max(0,x/L)),q=N*o*p/r,H=-N*r*d/o,W=m*q-f*H+(e+n)/2,J=f*q+m*H+(t+s)/2,D=(Y,Z,rt,$)=>{let S=Y*rt+Z*$,l=Math.hypot(Y,Z)*Math.hypot(rt,$),h=Math.acos(Math.min(1,Math.max(-1,S/(l||1))));return Y*$-Z*rt<0&&(h=-h),h},B=D(1,0,(d-q)/o,(p-H)/r),K=D((d-q)/o,(p-H)/r,(-d-q)/o,(-p-H)/r);!a&&K>0&&(K-=2*Math.PI),a&&K<0&&(K+=2*Math.PI);let ft=Math.max(1,Math.ceil(Math.abs(K/(Math.PI/2)))),nt=K/ft,st=4/3*Math.tan(nt/4),at=[],ct=B;for(let Y=0;Y<ft;Y++){let Z=ct+nt,rt=Math.cos(ct),$=Math.sin(ct),S=Math.cos(Z),l=Math.sin(Z),h=(j,O)=>[m*o*j-f*r*O+W,f*o*j+m*r*O+J],[y,w]=h(rt,$),[k,M]=h(S,l),[C,F]=h(rt-st*$,$+st*rt),[z,E]=h(S+st*l,l-st*S);at.push(["C",C,F,z,E,k,M]),ct=Z}return at}function ge(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?xn(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)?pe(s,o,r,i):Cn(s,o,r,i,c,a)}case"circle":{let s=n("r");return s<=0?[]:de(n("cx"),n("cy"),s,s)}case"ellipse":{let s=n("rx"),o=n("ry");return s<=0||o<=0?[]:de(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 pe(e,t,n,s){return[["M",e,t],["L",e+n,t],["L",e+n,t+s],["L",e,t+s],["Z"]]}var kt=.5522847498307936;function Cn(e,t,n,s,o,r){let i=o*kt,c=r*kt,a=e+n,u=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,u-r],["C",a,u-r+c,a-o+i,u,a-o,u],["L",e+o,u],["C",e+o-i,u,e,u-r+c,e,u-r],["L",e,t+r],["C",e,t+r-c,e+o-i,t,e+o,t],["Z"]]}function de(e,t,n,s){let o=n*kt,r=s*kt;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 me=new Set(["SCRIPT","STYLE","NOSCRIPT","TEMPLATE","HEAD","META","LINK","TITLE","BASE","IFRAME","CANVAS","VIDEO","AUDIO","OBJECT","EMBED"]),be=4e3,ye="http://www.w3.org/2000/svg",kn=new Set(["defs","symbol","marker","clipPath","mask","pattern","filter","linearGradient","radialGradient","style","title","desc","metadata","script"]),Mn=new Set(["g","a","svg","switch"]);function $n(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 Un=[["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 Gt(e,t){let n=e.ownerDocument.defaultView,s=n.scrollX,o=n.scrollY,r=[],i=r,c=[],a=[],u=[],m=[],f=new Map,b=[],g=[],d=null,p=0,T=new Set,P=new Set;function x(l,h){T.has(l)||(T.add(l),t.warn(h))}async function L(l,h){if(me.has(l.tagName))return;t.pacer&&await t.pacer();let y=n.getComputedStyle(l);if(y.display==="none")return;let w=Fn(y.transform);if(w&&"style"in l){let k=l,M=k.getBoundingClientRect(),C=k.style.transform;k.style.transform="none",k.offsetWidth;let F=k.getBoundingClientRect(),[z,E]=Pn(y.transformOrigin),j={x:F.left+z+s,y:F.top+E+o},O=r;r=[],await q(l,n.getComputedStyle(l),h);let A=r;r=O,k.style.transform=C,k.offsetWidth,r.push({type:"group",matrix:w,origin:j,items:A,top:M.top+o,bottom:M.bottom+o,z:N(y,h.z),seq:p++});return}await q(l,y,h)}function N(l,h){if(l.position!=="static"&&l.zIndex!=="auto"){let y=parseInt(l.zIndex,10);if(Number.isFinite(y))return y}return h}async function q(l,h,y){let w=N(h,y.z),k=parseFloat(h.opacity),M=y.alpha*(Number.isFinite(k)?k:1),C=h.visibility==="visible"&&M>0;if(h.display!=="contents"&&h.display!=="inline"){let v=l.getBoundingClientRect(),Q=v.top+o,ot=v.bottom+o;if(v.height>0){let tt=h.breakBefore||h.pageBreakBefore,Ht=h.breakAfter||h.pageBreakAfter;/^(page|always|left|right|recto|verso)$/.test(tt)&&a.push(Q),/^(page|always|left|right|recto|verso)$/.test(Ht)&&a.push(ot);let Vt=h.breakInside||h.pageBreakInside;if((Vt==="avoid"||Vt==="avoid-page"||h.display==="table-row"||h.display==="table-header-group"||h.display==="table-footer-group"||l.tagName==="IMG"||l.tagName==="svg")&&c.push({top:Q,bottom:ot}),/^avoid(-page)?$/.test(Ht)){let gt=rt(l);gt&&u.push({start:Math.min(ot,gt.top),end:Math.max(ot,gt.top),pullTo:Q})}if(/^avoid(-page)?$/.test(tt)){let gt=$(l);gt&&u.push({start:Math.min(gt.bottom,Q),end:Math.max(gt.bottom,Q),pullTo:gt.top})}}}Y(l,h);let F=null;if(h.display==="table"||h.display==="inline-table"){let v=l.getBoundingClientRect();F={top:v.top+o,bottom:v.bottom+o,headTop:0,headBottom:0,headItems:[],footTop:0,footBottom:0,footItems:[]},g.push(F)}let z=d;F&&(d=F);let E=h.display==="table-header-group"&&d&&!d.headItems.length,j=h.display==="table-footer-group"&&d&&!d.footItems.length,O=E||j?r.length:-1,A=h.overflowX!=="visible"||h.overflowY!=="visible",U=null,V=null;if(A&&h.display!=="inline"&&h.display!=="contents"&&l!==e){let v=l.getBoundingClientRect();V=B(v,h,"padding-box",xe(h,v))}if(C&&h.display!=="contents"){H(l,h);let v=h.display==="inline"?[...l.getClientRects()]:[l.getBoundingClientRect()],Q=h.borderCollapse==="collapse"&&/^table/.test(h.display)&&h.display!=="table-caption",ot=v.length===1?xe(h,v[0]):null;for(let tt of v)tt.width<=0&&tt.height<=0||(W(tt,h,M,w,ot),await J(l,tt,h,M,w,ot),K(tt,h,M,w,Q,ot));l.tagName==="IMG"&&v[0]&&await D(l,v[0],h,M,w,ot)}let G=y.decorations,_=h.textDecorationLine;if(_&&_!=="none"){let v=pt(h.textDecorationColor)??pt(h.color)??{r:0,g:0,b:0,a:1};G=[...G,{line:_,color:v}]}V&&(U=r,r=[]);let it={z:w,alpha:M,decorations:G};if(l.tagName==="svg"&&l.namespaceURI===ye){st(l,M,w),V&&U&&Z(V,U,w);return}for(let v of $n(l))v.nodeType===Node.TEXT_NODE?C&&ft(v,l,h,it):v.nodeType===Node.ELEMENT_NODE&&await L(v,it);if(V&&U&&Z(V,U,w),(E||j)&&d&&O>=0){let v=l.getBoundingClientRect(),Q=r.slice(O);E?(d.headTop=v.top+o,d.headBottom=v.bottom+o,d.headItems=Q):(d.footTop=v.top+o,d.footBottom=v.bottom+o,d.footItems=Q)}d=z}function H(l,h){for(let[y,w]of Un){let k=String(h[y]??"");w(k)&&x(`css:${y}`,{code:"unsupported-css",message:`CSS property "${Se(y)}" is not supported in this version and will be ignored (first seen on <${l.tagName.toLowerCase()}>: ${k})`,element:l,property:Se(y)})}/^matrix3d/.test(h.transform)&&x("css:transform3d",{code:"unsupported-css",message:"3D transforms are not supported; the element is drawn untransformed",element:l,property:"transform"})}function W(l,h,y,w,k){let M=pt(h.backgroundColor);if(!M||M.a<=0)return;let C={type:"rect",x:l.left+s,y:l.top+o,w:l.width,h:l.height,color:St(M,y),z:w,seq:p++};k&&(C.radius=k),r.push(C)}async function J(l,h,y,w,k,M){if(y.backgroundImage==="none")return;let C=B(h,y,y.backgroundClip||"border-box",M),F=B(h,y,y.backgroundOrigin||"padding-box",null),z=he(y.backgroundImage,F.w,F.h);if(z){r.push({type:"gradient",box:F,clip:C,gradient:z,alpha:w,z:k,seq:p++});return}let E=ae(y.backgroundImage);if(!E){x("css:backgroundImage",{code:"unsupported-css",message:`background-image "${y.backgroundImage}" is not supported (a single url() or linear-gradient() is); ignored`,element:l,property:"background-image"});return}let j=await xt(new URL(E,l.ownerDocument.baseURI).href,t.warn,l);if(!j)return;let O=Ct(F,j.width,j.height,y.backgroundSize,y.backgroundPosition),[A,U]=le(y.backgroundRepeat),V=jt(A,O.x,O.w,C.x,C.x+C.w),G=jt(U,O.y,O.h,C.y,C.y+C.h),_=V.positions.length*G.positions.length;if(_>be){x("css:backgroundRepeat",{code:"unsupported-css",message:`background-repeat would need ${_} tiles (limit ${be}); drawn once instead. Use a larger background-size or a pre-tiled image.`,element:l,property:"background-repeat"}),r.push({type:"image",...O,image:j,clip:C,alpha:w,z:k,seq:p++});return}for(let it of G.positions)for(let v of V.positions)r.push({type:"image",x:v,y:it,w:V.size,h:G.size,image:j,clip:C,alpha:w,z:k,seq:p++})}async function D(l,h,y,w,k,M){let C=l.currentSrc||l.src;if(!C)return;let F=await xt(C,t.warn,l);if(!F)return;let z=B(h,y,"content-box",M),E=Ct(z,F.width,F.height,ce(y.objectFit),y.objectPosition);y.objectFit==="scale-down"&&(E.w>F.width||E.h>F.height)&&Object.assign(E,Ct(z,F.width,F.height,"auto",y.objectPosition)),r.push({type:"image",...E,image:F,clip:z,alpha:w,z:k,seq:p++})}function B(l,h,y,w){let k=l.left+s,M=l.top+o,C=l.width,F=l.height;if(y==="padding-box"||y==="content-box"){let E=et(h.borderTopWidth),j=et(h.borderRightWidth),O=et(h.borderBottomWidth),A=et(h.borderLeftWidth);k+=A,M+=E,C-=A+j,F-=E+O,w&&(w=w.map(U=>Math.max(0,U-Math.max(E,j,O,A))))}if(y==="content-box"){let E=et(h.paddingTop),j=et(h.paddingRight),O=et(h.paddingBottom),A=et(h.paddingLeft);k+=A,M+=E,C-=A+j,F-=E+O}let z={x:k,y:M,w:Math.max(0,C),h:Math.max(0,F)};return w&&w.some(E=>E>0)&&(z.radius=w),z}function K(l,h,y,w,k,M){let C=l.left+s,F=l.top+o,z=l.width,E=l.height,A=["Top","Right","Bottom","Left"].map(U=>({side:U,width:et(h[`border${U}Width`]),style:h[`border${U}Style`],color:pt(h[`border${U}Color`])})).filter(U=>U.width>0&&U.style!=="none"&&U.style!=="hidden"&&U.color&&U.color.a>0);if(A.length){if(M&&M.some(U=>U>0)){let U=A[0];if(A.length===4&&A.every(G=>G.width===U.width&&G.style===U.style&&JSON.stringify(G.color)===JSON.stringify(U.color))){let G=U.width;r.push({type:"stroke-rrect",x:C+G/2,y:F+G/2,w:z-G,h:E-G,radius:M.map(_=>Math.max(0,_-G/2)),width:G,color:St(U.color,y),dash:we(U.style,G),z:w,seq:p++});return}x("css:borderRadiusNonUniform",{code:"unsupported-css",message:"border-radius with non-uniform borders is approximated with straight borders",property:"border-radius"})}for(let U of A){let V=U.width,G=St(U.color,y),_=U.side==="Top"||U.side==="Bottom",it=U.side==="Top"||U.side==="Left"?1:-1,v=U.side==="Top"?F:U.side==="Bottom"?F+E:U.side==="Left"?C:C+z,Q=we(U.style,V);if(Q){let tt=k?v:v+V/2*it;r.push({type:"line",x1:_?C:tt,y1:_?tt:F,x2:_?C+z:tt,y2:_?tt:F+E,width:V,color:G,dash:Q,z:w,seq:p++});continue}let ot=k?v-V/2:it>0?v:v-V;_?r.push({type:"rect",x:C,y:ot,w:z,h:V,color:G,z:w,seq:p++}):r.push({type:"rect",x:ot,y:F,w:V,h:E,color:G,z:w,seq:p++})}}}function ft(l,h,y,w){let k=l.data;if(!k)return;if(!/\S/.test(k)&&!k.includes("\xA0")){let A=l.ownerDocument.createRange();if(A.selectNodeContents(l),![...A.getClientRects()].some(U=>U.width>0))return}let M=St(pt(y.color)??{r:0,g:0,b:0,a:1},w.alpha),C=et(y.fontSize);if(C<=0)return;let F=Kt(y.fontFamily),z=Qt(y.fontWeight),E=y.fontStyle==="italic"||y.fontStyle==="oblique"?"italic":"normal",j=t.registry.match(F,z,E)??t.registry.match(t.fontFallback,z,E);if(!j){let A=F.join(",");P.has(A)||(P.add(A),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 O=se(l,y,{registry:t.registry,families:F,fallback:t.fontFallback,primary:j,weight:z,fstyle:E,size:C,textMeasure:t.textMeasure,features:ee(y),warn:t.warn,element:h});for(let A of O)if(A.glyphs.length){c.push({top:A.top+o,bottom:A.bottom+o}),r.push({type:"text",x:A.glyphs[0]?.x??0,y:A.baseline+o,top:A.top+o,bottom:A.bottom+o,size:C,color:M,font:A.font,glyphs:A.glyphs.map(U=>({...U,x:U.x+s})),z:w.z,seq:p++});for(let U of w.decorations){let V=A.glyphs[0],G=A.glyphs[A.glyphs.length-1];if(!V||!G)continue;let _=V.x+s,it=G.x+G.advance+s,v=Math.max(1,C/14),Q=St(U.color,w.alpha);U.line.includes("underline")&&r.push({type:"rect",x:_,y:A.baseline+o+C*.08,w:it-_,h:v,color:Q,z:w.z,seq:p++}),U.line.includes("line-through")&&r.push({type:"rect",x:_,y:A.baseline+o-C*.3,w:it-_,h:v,color:Q,z:w.z,seq:p++})}}}await L(e,{z:0,alpha:1,decorations:[]}),Te(i);let nt=e.getBoundingClientRect().bottom+o;for(let l of i)l.type==="rect"||l.type==="stroke-rrect"||l.type==="image"?nt=Math.max(nt,l.y+l.h):l.type==="line"?nt=Math.max(nt,l.y1,l.y2):(l.type==="text"||l.type==="group"||l.type==="clip")&&(nt=Math.max(nt,l.bottom));function st(l,h,y){for(let w of l.children){if(w.namespaceURI!==ye)continue;let k=w.tagName;if(kn.has(k))continue;let M=n.getComputedStyle(w);if(M.display==="none")continue;let C=parseFloat(M.opacity),F=h*(Number.isFinite(C)?C:1);if(F<=0)continue;if(Mn.has(k)){st(w,F,y);continue}let E=ge(w,V=>{let G=M.getPropertyValue(V);return G&&/^-?[\d.]+px$/.test(G)?String(parseFloat(G)):w.getAttribute(V)??""});if(E===null){x(`svg:${k}`,{code:"unsupported-css",message:`<${k}> inside an inline <svg> is not supported and was skipped (shapes are: path, rect, circle, ellipse, line, polyline, polygon)`,element:w});continue}if(!E.length||M.visibility!=="visible")continue;let j=w.getScreenCTM?.();if(!j)continue;let O=at(w,M.fill,M.fillOpacity,F,"fill"),A=ct(w,M,F);if(!O&&!A)continue;let U=w.getBoundingClientRect();r.push({type:"path",segs:E,matrix:[j.a,j.b,j.c,j.d,j.e+s,j.f+o],fill:O,evenOdd:M.fillRule==="evenodd",stroke:A,top:U.top+o,bottom:U.bottom+o,z:y,seq:p++})}}function at(l,h,y,w,k){if(!h||h==="none")return null;if(h.startsWith("url("))return x(`svg:${k}:url`,{code:"unsupported-css",message:`${k} with a paint server (${h}) inside an inline <svg> is not supported; the shape is skipped`,element:l,property:k}),null;let M=pt(h);if(!M)return null;let C=parseFloat(y),F=w*(Number.isFinite(C)?C:1);return F===1?M:{...M,a:M.a*F}}function ct(l,h,y){let w=at(l,h.stroke,h.strokeOpacity,y,"stroke");if(!w)return null;let k=et(h.strokeWidth);if(!(k>0))return null;let M=(h.strokeDasharray||"none").split(/[\s,]+/).map(E=>et(E)).filter(E=>Number.isFinite(E)&&E>=0),C=h.strokeLinecap==="round"?1:h.strokeLinecap==="square"?2:0,F=h.strokeLinejoin==="round"?1:h.strokeLinejoin==="bevel"?2:0,z=parseFloat(h.strokeMiterlimit);return{color:w,width:k,cap:C,join:F,miter:Number.isFinite(z)&&z>=1?z:4,dash:M.length&&M.some(E=>E>0)?M:null,dashOffset:et(h.strokeDashoffset)||0}}function Y(l,h){let y=l.id||(l.tagName==="A"?l.getAttribute("name"):null);if(y&&!f.has(y)){let C=l.getBoundingClientRect();f.set(y,C.top+o)}if(/^H[1-6]$/.test(l.tagName)){let C=(l.textContent??"").trim().replace(/\s+/g," ");C&&b.push({level:Number(l.tagName[1]),text:C,y:l.getBoundingClientRect().top+o})}if(l.tagName!=="A")return;let w=l.getAttribute("href");if(!w||h.visibility!=="visible")return;let k=w.startsWith("#")?decodeURIComponent(w.slice(1)):null,M=w;if(!k){try{M=new URL(w,l.ownerDocument.baseURI).href}catch{return}if(!/^(https?|mailto|tel|ftp|file):/i.test(M))return}for(let C of l.getClientRects())C.width<=0||C.height<=0||m.push({x:C.left+s,y:C.top+o,w:C.width,h:C.height,href:M,fragment:k})}function Z(l,h,y){let w=r.filter(k=>An(k,l));r=h,w.length&&r.push({type:"clip",box:l,items:w,top:l.y,bottom:l.y+l.h,z:y,seq:p++})}function rt(l){let h=l;for(;h&&h!==e;){for(let y=h.nextElementSibling;y;y=y.nextElementSibling){let w=S(y,"first");if(w)return w}h=h.parentElement}return null}function $(l){let h=l;for(;h&&h!==e;){for(let y=h.previousElementSibling;y;y=y.previousElementSibling){let w=S(y,"last");if(w)return w}h=h.parentElement}return null}function S(l,h){if(me.has(l.tagName))return null;let y=n.getComputedStyle(l);if(y.display==="none")return null;if(y.display!=="contents"&&y.display!=="inline"){let k=l.getBoundingClientRect();if(k.height>0)return{top:k.top+o,bottom:k.bottom+o}}let w=[...l.children];h==="last"&&w.reverse();for(let k of w){let M=S(k,h);if(M)return M}return null}return{items:i,atoms:c,breaks:a,joins:u,tables:g,links:m,anchors:f,headings:b,height:nt}}function Te(e){e.sort((t,n)=>t.z-n.z||t.seq-n.seq);for(let t of e)(t.type==="group"||t.type==="clip")&&Te(t.items)}function we(e,t){return e==="dashed"?[t*3,t*3]:e==="dotted"?[t,t]:null}function xe(e,t){let n=o=>{let r=o.trim().split(/\s+/)[0]??"0px";return r.endsWith("%")?parseFloat(r)/100*t.width:et(r)},s=[n(e.borderTopLeftRadius),n(e.borderTopRightRadius),n(e.borderBottomRightRadius),n(e.borderBottomLeftRadius)];return s.some(o=>o>0)?s:null}function Fn(e){if(!e||e==="none")return null;let t=/^matrix\(([^)]+)\)$/.exec(e.trim());if(!t)return null;let n=t[1].split(",").map(u=>parseFloat(u));if(n.length!==6||n.some(u=>!Number.isFinite(u)))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 Pn(e){let t=e.trim().split(/\s+/);return[et(t[0]??"0"),et(t[1]??"0")]}function An(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 St(e,t){return t===1?e:{...e,a:e.a*t}}function Se(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function En(){return typeof CompressionStream=="function"}async function Ce(e){if(!En())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 Mt=class{constructor(t){this.id=t}toString(){return`${this.id} 0 R`}},X=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}},dt=class{constructor(t){this.text=t}toString(){return this.text}};function ht(e){if(/^[\x20-\x7e]*$/.test(e))return new dt("("+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 dt("<"+t+">")}function ke(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 dt(`(D:${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}${s}${o}'${r}')`)}function $t(e){if(e===null)return"null";if(typeof e=="number")return I(e);if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return new X(e).toString();if(e instanceof Mt||e instanceof X||e instanceof dt)return e.toString();if(Array.isArray(e))return"["+e.map($t).join(" ")+"]";let t=[];for(let[n,s]of Object.entries(e))s!==void 0&&t.push(new X(n).toString()+" "+$t(s));return"<< "+t.join(" ")+" >>"}var Ut=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 Mt(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 Ce(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=f=>{let b=typeof f=="string"?s.encode(f):f;o.push(b),r+=b.length};i(Ft([s.encode(`%PDF-${this.version}
|
|
6
6
|
%`),new Uint8Array([226,227,207,211]),s.encode(`
|
|
7
|
-
`)]));let c=[];for(let
|
|
8
|
-
${
|
|
9
|
-
`),
|
|
10
|
-
`),i(
|
|
7
|
+
`)]));let c=[];for(let f=1;f<this.objects.length;f++){let b=this.objects[f];if(!b)throw new Error(`PDF object ${f} was reserved but never set`);c[f]=r,i(`${f} 0 obj
|
|
8
|
+
${$t(b.value)}
|
|
9
|
+
`),b.stream&&(i(`stream
|
|
10
|
+
`),i(b.stream),i(`
|
|
11
11
|
endstream
|
|
12
12
|
`)),i(`endobj
|
|
13
|
-
`)}let a=r,
|
|
13
|
+
`)}let a=r,u=`xref
|
|
14
14
|
0 ${this.objects.length}
|
|
15
15
|
0000000000 65535 f
|
|
16
|
-
`;for(let
|
|
17
|
-
`;i(
|
|
18
|
-
${
|
|
16
|
+
`;for(let f=1;f<this.objects.length;f++)u+=String(c[f]).padStart(10,"0")+` 00000 n
|
|
17
|
+
`;i(u);let m={Size:this.objects.length,Root:t};return n&&(m.Info=n),i(`trailer
|
|
18
|
+
${$t(m)}
|
|
19
19
|
startxref
|
|
20
20
|
${a}
|
|
21
21
|
%%EOF
|
|
22
|
-
`)
|
|
22
|
+
`),Ft(o)}};function Ft(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 Pt=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(`${I(t)} ${I(n)} ${I(s)} ${I(o)} ${I(r)} ${I(i)} cm`),this}setGState(t){return this.ops.push(`/${t} gs`),this}fillColor(t,n,s){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} rg`),this}strokeColor(t,n,s){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} RG`),this}lineWidth(t){return this.ops.push(`${I(t)} w`),this}dash(t,n=0){return this.ops.push(`[${t.map(I).join(" ")}] ${I(n)} d`),this}lineCap(t){return this.ops.push(`${t} J`),this}rect(t,n,s,o){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} ${I(o)} re`),this}moveTo(t,n){return this.ops.push(`${I(t)} ${I(n)} m`),this}lineTo(t,n){return this.ops.push(`${I(t)} ${I(n)} l`),this}curveTo(t,n,s,o,r,i){return this.ops.push(`${I(t)} ${I(n)} ${I(s)} ${I(o)} ${I(r)} ${I(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)),u=a(r[0]),m=a(r[1]),f=a(r[2]),b=a(r[3]),g=n+o,d=t+s;return this.moveTo(t+u,g),this.lineTo(d-m,g),m&&this.curveTo(d-m+m*.5523,g,d,g-m+m*.5523,d,g-m),this.lineTo(d,n+f),f&&this.curveTo(d,n+f-f*.5523,d-f+f*.5523,n,d-f,n),this.lineTo(t+b,n),b&&this.curveTo(t+b-b*.5523,n,t,n+b-b*.5523,t,n+b),this.lineTo(t,g-u),u&&this.curveTo(t,g-u+u*.5523,t+u-u*.5523,g,t+u,g),this.closePath()}image(t,n,s,o,r){return this.ops.push(`q ${I(o)} 0 0 ${I(r)} ${I(n)} ${I(s)} cm /${t} Do Q`),this}lineJoin(t){return this.ops.push(`${t} j`),this}miterLimit(t){return this.ops.push(`${I(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(I(a));return c.length?(this.ops.push("BT"),this.ops.push(`/${t} ${I(n)} Tf`),i.charSpacing&&this.ops.push(`${I(i.charSpacing)} Tc`),i.rise&&this.ops.push(`${I(i.rise)} Ts`),this.ops.push(`1 0 0 1 ${I(s)} ${I(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 $e(e,t){let n=new Set([0]),s=[...t];for(;s.length;){let D=s.pop();if(!(D<0||D>=e.numGlyphs||n.has(D))){n.add(D);for(let B of Yt(It(e,D)))n.has(B)||s.push(B)}}let o=[...n].sort((D,B)=>D-B),r=new Map;o.forEach((D,B)=>r.set(D,B));let i=o.length,c=[],a=new Uint32Array(i+1),u=0;for(let D=0;D<i;D++){let B=It(e,o[D]);B.length&&new DataView(B.buffer,B.byteOffset,B.byteLength).getInt16(0)<0&&(B=Nn(B,r)),a[D]=u,c.push(B),u+=B.length;let K=(4-u%4)%4;K&&(c.push(new Uint8Array(K)),u+=K)}a[i]=u;let m=Ft(c),f=new Uint8Array(a.length*4),b=new DataView(f.buffer);a.forEach((D,B)=>b.setUint32(B*4,D));let g=e.tables.get("hmtx"),d=e.tables.get("hhea"),p=new DataView(e.data.buffer,e.data.byteOffset,e.data.byteLength),T=p.getUint16(d.offset+34),P=new Uint8Array(i*4),x=new DataView(P.buffer);for(let D=0;D<i;D++){let B=o[D],K=B<T?g.offset+B*4+2:g.offset+T*4+(B-T)*2;x.setUint16(D*4,e.advances[B]??0),x.setInt16(D*4+2,K+2<=e.data.byteLength?p.getInt16(K):0)}let L=At(e,"head"),N=new DataView(L.buffer);N.setUint32(8,0),N.setInt16(50,1);let q=At(e,"hhea");new DataView(q.buffer).setUint16(34,i);let H=At(e,"maxp");new DataView(H.buffer).setUint16(4,i);let W=[["glyf",m],["head",L],["hhea",q],["hmtx",P],["loca",f],["maxp",H]];for(let D of["cvt ","fpgm","prep"])e.tables.has(D)&&W.push([D,At(e,D)]);return W.sort((D,B)=>D[0]<B[0]?-1:1),{data:In(W),gidMap:r,oldGids:o}}function At(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 Nn(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 In(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[f,b]of e)c.push({tag:f,data:b,offset:i,checksum:Me(b)}),i+=b.length+3&-4;let a=new Uint8Array(i),u=new DataView(a.buffer);u.setUint32(0,65536),u.setUint16(4,t),u.setUint16(6,s),u.setUint16(8,n),u.setUint16(10,o),c.forEach((f,b)=>{let g=12+b*16;for(let d=0;d<4;d++)a[g+d]=f.tag.charCodeAt(d);u.setUint32(g+4,f.checksum),u.setUint32(g+8,f.offset),u.setUint32(g+12,f.data.length),a.set(f.data,f.offset)});let m=c.find(f=>f.tag==="head");if(m){let f=Me(a);u.setUint32(m.offset+8,2981146554-f>>>0)}return a}function Me(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 Et=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=$e(this.font,this.usedGids.keys())),this.subset}async embed(t){let n=this.finalize(),s=this.font,o=1e3/s.unitsPerEm,i=`${Rn(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 u=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=[],f=n.oldGids.map(p=>Math.round((s.advances[p]??0)*o)),b=0;for(;b<f.length;){let p=b;for(;p+1<f.length&&p-b<100;)p++;m.push(b,f.slice(b,p+1)),b=p+1}let g=t.add({Type:"Font",Subtype:"CIDFontType2",BaseFont:i,CIDSystemInfo:{Registry:new dt("(Adobe)"),Ordering:new dt("(Identity)"),Supplement:0},FontDescriptor:u,DW:1e3,W:m,CIDToGIDMap:"Identity"}),d=await t.addStream({},vn(n,this.usedGids));return t.add({Type:"Font",Subtype:"Type0",BaseFont:i,Encoding:"Identity-H",DescendantFonts:[g],ToUnicode:d})}};function Rn(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 vn(e,t){let n=[];e.oldGids.forEach((r,i)=>{let c=t.get(r);c!==void 0&&n.push(`<${yt(i)}> <${Ln(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,6 +38,6 @@ endcodespacerange
|
|
|
38
38
|
CMapName currentdict /CMap defineresource pop
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
`;return new TextEncoder().encode(o)}function
|
|
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};
|
|
41
|
+
`;return new TextEncoder().encode(o)}function yt(e){return e.toString(16).toUpperCase().padStart(4,"0")}function Ln(e){if(e<=65535)return yt(e);let t=e-65536;return yt(55296+(t>>10))+yt(56320+(t&1023))}async function Ue(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 Fe(e,t){let s=t,o=e.height,r=[...e.atoms].sort((g,d)=>g.top-d.top),i=[...new Set(e.breaks)].sort((g,d)=>g-d),c=(e.joins??[]).map(g=>{let d=r.find(p=>p.top>=g.end-.01);return{start:g.start,limit:d?Math.max(d.top,g.end):g.end,pullTo:g.pullTo}}),a=.01,u=[],m=0,f=0;for(;m<o-a&&f++<1e4;){let g=[],d=0;for(let x of e.tables)x.headItems.length&&x.headBottom<=m+a&&m<x.bottom-a&&(g.push({table:x,shift:d}),d+=x.headBottom-x.headTop);let p=[],T=0,P=m;for(let x=0;x<4;x++){let L=Math.max(s-d-T,s*.25);P=b(m,L);let N=[],q=0;for(let W of e.tables)W.footItems.length&&W.top<P-a&&W.footTop>=P-a&&W.bottom>P+a&&(N.push({table:W,shift:q}),q+=W.footBottom-W.footTop);let H=N.length===p.length&&N.every((W,J)=>W.table===p[J]?.table);if(p=N,T=q,H)break}u.push({start:m,end:P,heads:g,headShift:d,feet:p,footShift:T}),m=P}return u.length||u.push({start:0,end:Math.max(o,1),heads:[],headShift:0,feet:[],footShift:0}),u;function b(g,d){let p=Math.min(g+d,o);for(let T of i)if(T>g+a&&T<p-a){p=T;break}if(p<o-a){let T=!0,P=0;for(;T&&P++<1e3;){T=!1;for(let x of r){if(x.top>=p)break;x.bottom-x.top>d||x.top<p-a&&x.bottom>p+a&&x.top>g+a&&(p=x.top,T=!0)}for(let x of c)x.limit-x.pullTo>d||x.pullTo<=g+a||p>=x.start-a&&p<=x.limit+a&&p>x.pullTo+a&&(p=x.pullTo,T=!0)}p<=g+a&&(p=Math.min(g+d,o))}return p}}function On(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 u=0;u<t.length-1;u++){let m=t[u],f=t[u+1];i.push(e.add({FunctionType:2,Domain:[0,1],C0:n(m.color),C1:n(f.color),N:1})),a.push(0,1),u>0&&c.push((m.t-s.t)/r)}return e.add({FunctionType:3,Domain:[0,1],Functions:i,Bounds:c,Encode:a})}function Wt(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 X(s==="rgb"?"DeviceRGB":"DeviceGray"),Coords:[t.x0,t.y0,t.x1,t.y1],Function:On(e,n,o),Extend:[!0,!0]})}function Pe(e){let t=e[0].color.a;return e.every(n=>Math.abs(n.color.a-t)<.002)?t:null}async function Ae(e,t,n,s,o){let r=o===1?n:n.map(u=>({t:u.t,color:{...u.color,a:u.color.a*o}})),i=Wt(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 X("XObject"),Subtype:new X("Form"),BBox:[s.x,s.y,s.x+s.w,s.y+s.h],Group:{Type:new X("Group"),S:new X("Transparency"),CS:new X("DeviceGray")},Resources:{Shading:{Sh0:i}}},c);return e.add({Type:new X("ExtGState"),SMask:{Type:new X("Mask"),S:new X("Luminosity"),G:a,BC:[0]},ca:1,CA:1})}function zt(e,t,n){let s={Type:new X("Annot"),Subtype:new X("Link"),Rect:[t.x,t.y,t.x+t.w,t.y+t.h],Border:[0,0,0],F:4};return"uri"in n?s.A={S:new X("URI"),URI:ht(n.uri)}:s.Dest=n.dest,e.add(s)}function Ee(e,t){let n=t.filter(a=>a.dest!==null);if(!n.length)return null;let s=[],o=[];for(let a of n){let u={level:a.level,text:a.text,dest:a.dest,children:[],ref:e.reserve()};for(;o.length&&o[o.length-1].level>=u.level;)o.pop();let m=o[o.length-1];m?m.children.push(u):s.push(u),o.push(u)}let r=e.reserve(),i=(a,u)=>{let m=0;return a.forEach((f,b)=>{let g=i(f.children,f.ref),d={Title:ht(f.text),Parent:u,Dest:f.dest},p=a[b-1],T=a[b+1];p&&(d.Prev=p.ref),T&&(d.Next=T.ref),f.children.length&&(d.First=f.children[0].ref,d.Last=f.children[f.children.length-1].ref,d.Count=g),e.set(f.ref,d),m+=1+g}),m},c=i(s,r);return e.set(r,{Type:new X("Outlines"),First:s[0].ref,Last:s[s.length-1].ref,Count:c}),r}function Ne(e={}){let t=e.size??"A4",n,s;if(typeof t=="string"){let i=Dt[t];if(!i)throw new Error(`Unknown page size "${t}". Use one of ${Object.keys(Dt).join(", ")} or {width, height}.`);n=i.width,s=i.height}else n=ut(t.width),s=ut(t.height);(e.orientation??"portrait")==="landscape"&&n<s&&([n,s]=[s,n]);let o=e.margin??"15mm",r=typeof o=="string"?{top:ut(o),right:ut(o),bottom:ut(o),left:ut(o)}:{top:ut(o.top),right:ut(o.right),bottom:ut(o.bottom),left:ut(o.left)};return{width:n,height:s,...r}}async function Ie(e,t,n){let s=new Ut({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 u=a/.75,m=Fe(e,u),f=m.length,b=[],g=[];for(let $=0;$<f;$++)b.push(n.header?await n.header.render($+1,f):null),g.push(n.footer?await n.footer.render($+1,f):null);let d=new Map,p=new Map,T=$=>{for(let S of $)if(S.type==="text"){let l=d.get(S.font);l||(l=new Et(S.font.parsed,`F${d.size+1}`),d.set(S.font,l));for(let h of S.glyphs)l.addGlyph(h.gid,h.cp)}else S.type==="image"?p.has(S.image.key)||p.set(S.image.key,{name:`Im${p.size+1}`,image:S.image}):(S.type==="group"||S.type==="clip")&&T(S.items)};T(e.items);for(let $ of[...b,...g])$&&T($.items);for(let $ of d.values())$.finalize();let P={};for(let $ of d.values())P[$.resourceName]=await $.embed(s);let x={};for(let $ of p.values()){let S=$.image;if(!S.jpeg&&!S.rgb){let l=await xt(S.key,n.warn??(()=>{}));if(!l)continue;S=l}x[$.name]=await Ue(s,S),fe(S),n.pacer&&await n.pacer()}let L=new Map,N={},q=($,S=$)=>{let l=`${I($)}/${I(S)}`,h=L.get(l);return h||(h=`GS${L.size+1}`,L.set(l,h),N[h]=s.add({Type:"ExtGState",ca:$,CA:S})),h},H={},W=new Map,J=async $=>{for(let S of $)if(S.type==="gradient"){let l=`Sh${Object.keys(H).length+1}`;H[l]=Wt(s,S.gradient,S.gradient.stops,"rgb");let h=Pe(S.gradient.stops),y=null;if(h===null){let w=await Ae(s,S.gradient,S.gradient.stops,{x:0,y:0,w:S.box.w,h:S.box.h},S.alpha);y=`GM${W.size+1}`,N[y]=w}W.set(S,{sh:l,gs:y})}else(S.type==="group"||S.type==="clip")&&await J(S.items)};await J(e.items);for(let $ of[...b,...g])$&&await J($.items);let D=s.reserve(),B=[],K=Array.from({length:f},()=>s.reserve()),ft=$=>K[$],nt=$=>{for(let S=0;S<f;S++){let l=m[S];if($>=l.start-.01&&($<l.end-.01||S===f-1)){let h=c-l.headShift*.75;return{page:S,x:t.left,y:h-($-l.start)*.75}}}return null};n.progress?.({phase:"layout",totalPages:f});for(let $=0;$<f;$++){n.pacer&&await n.pacer(),n.progress?.({phase:"page",page:$+1,totalPages:f});let S=m[$],l=new Pt,h=new qt(l,t,d,p,q,W),y=S.headShift*.75,w=S.footShift*.75;l.save(),l.rect(t.left,c-a+w,i,a-y-w).clip(),h.setOrigin(c-y,S.start),h.render(e.items,S),l.restore();let k=c-y-(S.end-S.start)*.75;for(let O of S.feet){let A=(O.table.footBottom-O.table.footTop)*.75,U=k-O.shift*.75-A;l.save(),l.rect(t.left,U,i,A).clip(),h.setOrigin(U+A,O.table.footTop),h.render(O.table.footItems),l.restore()}for(let O of S.heads){l.save();let A=(O.table.headBottom-O.table.headTop)*.75;l.rect(t.left,c-O.shift*.75-A,i,A).clip(),h.setOrigin(c-O.shift*.75,O.table.headTop),h.render(O.table.headItems),l.restore()}let M=b[$];M&&(l.save(),l.rect(t.left,t.height-t.top-o,i,o).clip(),h.setOrigin(t.height-t.top,0),h.render(M.items),l.restore());let C=g[$];C&&(l.save(),l.rect(t.left,t.bottom,i,r).clip(),h.setOrigin(t.bottom+r,0),h.render(C.items),l.restore());let F=[];if(n.links!==!1){let O=(A,U,V,G)=>{for(let _ of A){let it=Math.max(_.y,V),v=Math.min(_.y+_.h,G);if(v-it<=.01)continue;let Q={x:t.left+_.x*.75,y:U-(v-V)*.75,w:_.w*.75,h:(v-it)*.75};if(_.fragment===null){F.push(zt(s,Q,{uri:_.href}));continue}let ot=e.anchors?.get(_.fragment);if(ot===void 0)continue;let tt=nt(ot);tt&&F.push(zt(s,Q,{dest:[ft(tt.page),new X("XYZ"),tt.x,tt.y,null]}))}};O(e.links??[],c-y,S.start,S.end),M&&O(M.links??[],t.height-t.top,0,o/.75),C&&O(C.links??[],t.bottom+r,0,r/.75)}let z=await s.addStream({},l.toBytes()),E={Type:"Page",Parent:D,MediaBox:[0,0,t.width,t.height],Resources:{Font:P,XObject:x,ExtGState:N,Shading:H,ProcSet:[new X("PDF"),new X("Text"),new X("ImageC")]},Contents:z};F.length&&(E.Annots=F);let j=ft($);s.set(j,E),B.push(j)}s.set(D,{Type:"Pages",Kids:B,Count:B.length});let st=null;n.outline&&(st=Ee(s,(e.headings??[]).map($=>{let S=nt($.y);return{level:$.level,text:$.text,dest:S?[ft(S.page),new X("XYZ"),S.x,S.y,null]:null}})));let at={Type:"Catalog",Pages:D};st&&(at.Outlines=st,at.PageMode=new X("UseOutlines"));let ct=s.add(at),Y=n.metadata??{},Z={Producer:ht("receipt-html-to-pdf"),Creator:ht(Y.creator??"receipt-html-to-pdf"),CreationDate:ke(Y.creationDate??new Date)};Y.title&&(Z.Title=ht(Y.title)),Y.author&&(Z.Author=ht(Y.author)),Y.subject&&(Z.Subject=ht(Y.subject)),Y.keywords&&(Z.Keywords=ht(Y.keywords));let rt=s.add(Z);return s.build(ct,rt)}function Dn(e,t){if(e.type==="text"){let s=(e.top+e.bottom)/2;return s>=t.start-.01&&s<t.end-.01}return Gn(e)>t.start+.01&&jn(e)<t.end-.01}var qt=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&&!Dn(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,u,m]=o.matrix,f=.75,b=this.geo.left,g=this.pdfTop+this.docTop*f;s.save(),s.transform(f*r,-f*i,f*c,-f*a,f*u+b,-f*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 d=o.fill?o.fill.a:1,p=o.stroke?o.stroke.color.a:1;(d!==1||p!==1)&&s.setGState(this.gsName(d,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=Bn(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,u=this.X(o.origin.x),m=this.Y(o.origin.y),f=r,b=-i,g=-c,d=a,p=u-(f*u+g*m)+o.matrix[4]*.75,T=m-(b*u+d*m)-o.matrix[5]*.75;s.save(),s.transform(f,b,g,d,p,T),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 Bn(e,t){let n=[],s="";for(let o=0;o<e.glyphs.length;o++){let r=e.glyphs[o];s+=yt(t.cid(r.gid));let i=e.glyphs[o+1];if(!i)break;let c=r.x+r.advance,u=-(i.x-c)/e.size*1e3;Math.abs(u)>=.5&&(n.push(s,Math.round(u*10)/10),s="")}return s&&n.push(s),n}function jn(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 Gn(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 Wn(){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 Re(e=12){let t=()=>typeof performance<"u"?performance.now():Date.now(),n=t();return async()=>{t()-n<e||(await Wn(),n=t())}}var Vo="0.4.0",Nt=new Tt;async function _o(e){if(!e||!e.family||!e.src)throw new TypeError("registerFont: { family, src } are required");(await Nt.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 Xo(){return Nt.fonts.map(e=>({family:e.displayFamily,weight:e.weight,style:e.style,glyphs:e.parsed.numGlyphs}))}async function Yo(e,t={}){if(typeof document>"u")throw new Error("htmlToPdf must run in a browser (needs DOM layout)");if(Nt.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=Re(),r=Ne(t.page),i=(r.width-r.left-r.right)/.75;s({phase:"render"});let c=await Lt(e,{widthPx:i,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n}),a={registry:Nt,fontFallback:t.fontFallback??[],warn:n,textMeasure:t.textMeasure??"auto",pacer:o},u={widthPx:i,stylesheets:t.stylesheets??"inherit",mediaPrint:t.mediaPrint??!1,baseUrl:t.baseUrl,warn:n};try{s({phase:"walk"});let m=await Gt(c.root,a),f=t.header?await ve(t.header,u,a):null,b=t.footer?await ve(t.footer,u,a):null,g=await Ie(m,r,{compress:t.compress??!0,metadata:t.metadata,header:f,footer:b,links:t.links??!0,outline:t.outline??!1,pacer:o,progress:s,warn:n});return s({phase:"done"}),zn(g,t.output??"blob")}finally{c.destroy()}}async function ve(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)),u=await Lt(a,t);try{return await Gt(u.root,n)}finally{u.destroy()}},o=await s(1,1),r=new Map([["1/1",o]]);return{heightPx:o.height,render:async(i,c)=>{let a=`${i}/${c}`,u=r.get(a);return u||(u=await s(i,c),r.set(a,u)),u}}}function zn(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 Zo(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{Zo as downloadPdf,bt as expandPrintMediaCss,Yo as htmlToPdf,Xo as listFonts,_o as registerFont,Vo as version};
|
|
43
43
|
//# sourceMappingURL=receipt-html-to-pdf.min.js.map
|