revise 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +195 -0
- package/README.md +4 -1
- package/assets/historyMaterializeWorker-B51R08XN.js +612 -0
- package/backend.d.ts +8 -2
- package/backend.js +3 -1
- package/chunks/AgentPageRenderer-CH8kSTJn.js +1 -0
- package/chunks/AgentPageRenderer-P23XVguo.js +1 -0
- package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +1 -0
- package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +1 -0
- package/chunks/BidiText-Swm5fl9J.js +160 -0
- package/chunks/ColorParserFull-BKH72fK8.js +446 -1
- package/chunks/DocumentMutator-btiDK57e.js +31 -0
- package/chunks/DocumentScrubber-CMPfm_HF.js +18 -0
- package/chunks/{DocumentScrubber-DrgzBlx4.js → DocumentScrubber-Cm2kH8op.js} +1 -1
- package/chunks/{DocumentScrubber-W0EfGmL-.js → DocumentScrubber-bJoKijol.js} +1 -1
- package/chunks/DocumentStylesheet-DreoD7sD.js +7 -0
- package/chunks/DocxConverter-BcVG-p5K.js +13 -0
- package/chunks/DocxConverter-D2bO5RE-.js +1125 -0
- package/chunks/DocxConverter-haCfRuWb.js +13 -0
- package/chunks/{DocxGraft-B6W7fbh4.js → DocxGraft-BRKh4mHQ.js} +1 -1
- package/chunks/DocxGraft-BxSQtl12.js +7 -0
- package/chunks/{DocxGraft-Cj7v78BO.js → DocxGraft-C9MBQCnf.js} +1 -1
- package/chunks/FileImporter-CszqRfVU.js +1 -0
- package/chunks/FileImporter-DObFoCCn.js +1 -0
- package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -1
- package/chunks/HtmlConverter-DwXB4IDh.js +267 -0
- package/chunks/ListNumbering-Qlu6AuRZ.js +23 -1
- package/chunks/MarkdownConverter-CUC8GgsS.js +57 -0
- package/chunks/MathRenderer-DT6GyJXb.js +68 -0
- package/chunks/OdtConverter-7h9HHMpL.js +125 -0
- package/chunks/OdtConverter-Ct4qypJk.js +6 -0
- package/chunks/OdtConverter-DFl__sJc.js +6 -0
- package/chunks/OfficeImportShared-BY6FdZ8d.js +1 -0
- package/chunks/OfficeImportShared-BrZoDM0j.js +30 -0
- package/chunks/OfficeImportShared-Bvm-mOyj.js +1 -0
- package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
- package/chunks/PdfConverter-1wyvoT7X.js +21 -0
- package/chunks/PdfConverter-BAoEHILo.js +21 -0
- package/chunks/PdfConverter-CKEvFj11.js +448 -0
- package/chunks/{PdfImportService-Dj1-3L2B.js → PdfImportService-BhLPp5uG.js} +2 -2
- package/chunks/{PdfImportService-OE9G383I.js → PdfImportService-xbzrN__L.js} +2 -2
- package/chunks/RtfConverter-Bxn-enp8.js +15 -0
- package/chunks/RtfConverter-LZPzBDSr.js +15 -0
- package/chunks/RtfConverter-_bacXqr1.js +186 -0
- package/chunks/TableBorders-CwnF3jvH.js +30 -0
- package/chunks/TableGrid-DbroRucl.js +12 -0
- package/chunks/TextFileDecoder--rsVs3NR.js +9 -2
- package/chunks/{TxtConverter-BYazsp6P.js → TxtConverter-C7FOwHpH.js} +5 -2
- package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
- package/chunks/XmlConverter-7oo8oeQB.js +2 -0
- package/chunks/XmlConverter-DGORHJcZ.js +96 -0
- package/chunks/XmlConverter-DeLHReK_.js +2 -0
- package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -1
- package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -1
- package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -1
- package/chunks/ar-ComXvtmh.js +13 -0
- package/chunks/backend-DecaBz-I.js +490 -0
- package/chunks/base64-sSPOzq-u.js +198 -0
- package/chunks/browser-module-CFmqfGkE.js +1791 -3
- package/chunks/{browser-module-BbaxnHNK.js → browser-module-Dj5o3kuL.js} +1 -1
- package/chunks/{browser-module-D2ixluMg.js → browser-module-UuM_O36W.js} +1 -1
- package/chunks/bundle.min-DRpfgV69.js +779 -5
- package/chunks/capture-1btcWcPF.js +9 -0
- package/chunks/carrier-DQeng6yq.js +6 -0
- package/chunks/de-BkbpIKxx.js +13 -0
- package/chunks/es-CKkXujOF.js +13 -0
- package/chunks/fil-piIHMc8F.js +13 -0
- package/chunks/footnoteFlatten-DUQticYy.js +6 -0
- package/chunks/fr-DuA8qLje.js +13 -0
- package/chunks/graftExport-CYnStOdU.js +82 -0
- package/chunks/html2canvas.esm-CntiHiYW.js +994 -2
- package/chunks/index-2TBhRkX7.js +387 -0
- package/chunks/index-BWdRWxoH.js +1796 -13
- package/chunks/index-Bf14eTEW.js +1096 -0
- package/chunks/index-BwcX_r62.js +387 -0
- package/chunks/index.es-CI0QPo8w.js +780 -5
- package/chunks/{index.es-B97tjxvW.js → index.es-CI7cDExj.js} +1 -1
- package/chunks/{index.es-mTU7Sl3w.js → index.es-DHpGt6Y5.js} +1 -1
- package/chunks/ja-DgrSs555.js +13 -0
- package/chunks/{jspdf.es.min-Mykp4BZO.js → jspdf.es.min--GshOuIm.js} +1 -1
- package/chunks/jspdf.es.min-DU74zN8b.js +1747 -32
- package/chunks/{jspdf.es.min-DGiD4mlU.js → jspdf.es.min-DurJZ1zW.js} +1 -1
- package/chunks/jszip.min-CPW0h1Kx.js +476 -2
- package/chunks/katex-DWj8TvwO.js +1209 -8
- package/chunks/pdf-BLWDCiFF.js +1826 -10
- package/chunks/pseudoLocale-BoYTjmiK.js +1 -0
- package/chunks/pseudoLocale-DG2NnZmz.js +1 -0
- package/chunks/purify.es-BwLardii.js +107 -2
- package/chunks/serverDocumentSession-CJ1EH3Tp.js +15 -0
- package/chunks/signatures-Bwt_OGik.js +17 -0
- package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
- package/chunks/tree-sitter-D6zWWUMP.js +1 -1
- package/chunks/web-tree-sitter-BXGZGnNj.js +2 -1
- package/chunks/zh-9OF3SWWO.js +13 -0
- package/full.js +1 -1
- package/index.d.ts +42 -15
- package/index.js +1 -1
- package/package.json +1 -1
- package/root.js +2 -2
- package/serverToolContract.d.ts +21 -3
- package/serverToolInputs.generated.d.ts +23 -2
- package/style.css +1 -1
- package/assets/historyMaterializeWorker-C4uxcZEh.js +0 -3
- package/chunks/AgentPageRenderer-BIf_Fza8.js +0 -1
- package/chunks/AgentPageRenderer-DT9sNxEn.js +0 -1
- package/chunks/AttachmentDocumentImporter-BUavYRxO.js +0 -1
- package/chunks/AttachmentDocumentImporter-DGwfDJSH.js +0 -1
- package/chunks/BidiText-D7LYTAUL.js +0 -1
- package/chunks/DocumentMutator-CjN7Kk-X.js +0 -31
- package/chunks/DocumentScrubber-C9ZZEcYW.js +0 -1
- package/chunks/DocumentStylesheet-byN5dtC6.js +0 -1
- package/chunks/DocxConverter-Be3uPNcD.js +0 -11
- package/chunks/DocxConverter-CGYMfz-j.js +0 -11
- package/chunks/DocxConverter-DabDLfsu.js +0 -11
- package/chunks/DocxGraft-Duvo2cpy.js +0 -1
- package/chunks/FileImporter-CjUX2S4s.js +0 -1
- package/chunks/FileImporter-DtkbI6rF.js +0 -1
- package/chunks/HtmlConverter-ikXImzTY.js +0 -61
- package/chunks/MarkdownConverter-CFrcLyO_.js +0 -17
- package/chunks/MathRenderer-B0Y1h1JU.js +0 -33
- package/chunks/OdtConverter-BFT_P8SI.js +0 -1
- package/chunks/OdtConverter-Cnda9T0q.js +0 -1
- package/chunks/OdtConverter-WdwwXKVM.js +0 -1
- package/chunks/PdfConverter-D7UM58vc.js +0 -21
- package/chunks/PdfConverter-TB-QPw29.js +0 -21
- package/chunks/PdfConverter-wVP63986.js +0 -21
- package/chunks/RtfConverter-D-oqPWNl.js +0 -14
- package/chunks/RtfConverter-D9zhE07-.js +0 -14
- package/chunks/RtfConverter-DZgwU-_R.js +0 -14
- package/chunks/TableBorders-BorZS8aZ.js +0 -1
- package/chunks/TableGrid-DVWaRZv0.js +0 -1
- package/chunks/ar-C8zx2RwP.js +0 -8
- package/chunks/backend-MFpDFVrD.js +0 -1
- package/chunks/base64-BNMNG-lN.js +0 -1
- package/chunks/capture-qC26xmfy.js +0 -1
- package/chunks/carrier-BWONvrA7.js +0 -1
- package/chunks/de-ByQFqecF.js +0 -8
- package/chunks/es-PHpJXv5S.js +0 -8
- package/chunks/footnoteFlatten-Bdnn_bz1.js +0 -1
- package/chunks/graftExport-CP3h2T88.js +0 -2
- package/chunks/index-CjeGoI2g.js +0 -351
- package/chunks/index-D7V8zn4w.js +0 -36
- package/chunks/index-DyOcu9mD.js +0 -351
- package/chunks/pseudoLocale-C90lXrPg.js +0 -1
- package/chunks/pseudoLocale-UA_TkGrH.js +0 -1
- package/chunks/serverDocumentSession-CRZSb5SO.js +0 -11
- package/chunks/signatures-CsL_TjvW.js +0 -1
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
import{bb as re,bc as Pt,bd as Ht,be as Nt,r as Gt,bf as Rt,Z as zt,a as Ut,t as se,bg as le,bh as ce,bi as he,bj as ge,ai as Kt,bk as et,aj as jt,aR as de,f as fe,bl as Yt,bm as me,bn as Et,bo as Bt,
|
|
2
|
+
bp as dt,bq as Pe,br as pe,bs as ue,bt as Te,C as Ft,bu as xe,ad as _e,b0 as ye,aa as vt}from"./backend-DecaBz-I.js";import{b as be,s as Fe,o as Se,p as Le,n as we}from"./ListNumbering-Qlu6AuRZ.js";import{
|
|
3
|
+
w as $t,x as qt,g as Oe,b as ke,c as Ce,y as Me,z as Ne,A as Re,B as Ee,D as St,C as Be,E as ve,F as Ie,G as Vt,H as Qt,I as De,J as Jt,K as Zt,L as Xe,S as te}from"./index-Bf14eTEW.js";import{m as Ae,
|
|
4
|
+
k as We,a as He,r as Ge,o as ze,b as Ue,q as Ke}from"./TableBorders-CwnF3jvH.js";import{b as je,n as Ye}from"./TableGrid-DbroRucl.js";import{i as $e,l as qe,s as Ve,d as Qe}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";
|
|
5
|
+
import{b as ee,c as Je,p as It,K as ae,d as Ze}from"./base64-sSPOzq-u.js";import{l as Dt}from"./UnicodeUtils-CXtusU4g.js";import{L as ta,F as _t,l as Xt,o as Lt,r as ea,p as ie,c as aa,g as ia,q as na,
|
|
6
|
+
e as ne,s as oa,i as ra,u as sa}from"./BidiText-Swm5fl9J.js";import{r as wt,o as la,e as ca,c as ha,a as ga}from"./MathRenderer-DT6GyJXb.js";const oe=new WeakMap;function da(Q,t){if(!Q)return;const e=oe.
|
|
7
|
+
get(Q);if(e&&e.defaultFont===t)return e.fonts;const a=Q.lineNumberMarks!==void 0||(Q.pageGeometries??[]).some(i=>i.lineNumbering||i.pleadingGrid)?fa(Q.fragments,t):void 0;return oe.set(Q,{defaultFont:t,
|
|
8
|
+
fonts:a}),a}function fa(Q,t){const e=new Map;for(const i of Q){if(i.isChrome||i.repeatedHeader)continue;const r=i.pageNumber;if(r===void 0)continue;const n=i.block.children;if(!Array.isArray(n))continue;
|
|
9
|
+
const l=i.charRange;let o=0;for(const h of n){const s=h;if(s.type!=="text"||typeof s.text!="string")continue;const g=o;o+=s.text.length;const P=l?Math.max(g,l.start):g,c=l?Math.min(o,l.end):o;if(c<=P)
|
|
10
|
+
continue;const d=s.text.slice(P-g,c-g).replace(/\s+/g,"").length;if(d===0)continue;const f=s.marks?.fontFamily||t;let T=e.get(r);T||(T=new Map,e.set(r,T)),T.set(f,(T.get(f)??0)+d)}}const a=new Map;for(const[
|
|
11
|
+
i,r]of e){let n="",l=0;for(const[o,h]of r)h>l&&(n=o,l=h);n&&a.set(i,n)}return a}const Mt=new Map;la(()=>Mt.clear());function ma(Q){const t=String.fromCharCode(...Q.subarray(0,4));return Q[0]===0&&Q[1]===
|
|
12
|
+
1&&Q[2]===0&&Q[3]===0||t==="true"||t==="OTTO"}function Pa(Q){let t="";for(let e=0;e<Q.length;e+=32768)t+=String.fromCharCode(...Q.subarray(e,e+32768));return btoa(t)}async function pa(Q){try{const t=await fetch(
|
|
13
|
+
wt(`fonts/${encodeURIComponent(Q)}`),{credentials:"omit"});if(!t.ok)return null;const e=new Uint8Array(await t.arrayBuffer());return ma(e)?Pa(e):null}catch{return null}}async function ua(Q){let t=Mt.get(
|
|
14
|
+
Q);return t||(t=pa(Q),Mt.set(Q,t),t.then(e=>{e===null&&Mt.delete(Q)})),t}const J=Q=>({normal:Q,bold:Q}),Ta={japanese:{family:"NotoSansJP",probeCodePoint:12354,charRegex:/[\p{Script=Hiragana}\p{Script=Katakana}]/u,
|
|
15
|
+
files:J("NotoSansJP-Regular.ttf")},korean:{family:"NotoSansKR",probeCodePoint:54620,charRegex:/\p{Script=Hangul}/u,files:J("NotoSansKR-Regular.ttf")},devanagari:{family:"NotoSansDevanagari",probeCodePoint:2309,
|
|
16
|
+
charRegex:/\p{Script=Devanagari}/u,files:J("NotoSansDevanagari-Regular.ttf"),shape:!0},bengali:{family:"NotoSansBengali",probeCodePoint:2437,charRegex:/\p{Script=Bengali}/u,files:J("NotoSansBengali-Re\
|
|
17
|
+
gular.ttf"),shape:!0},gurmukhi:{family:"NotoSansGurmukhi",probeCodePoint:2565,charRegex:/\p{Script=Gurmukhi}/u,files:J("NotoSansGurmukhi-Regular.ttf"),shape:!0},gujarati:{family:"NotoSansGujarati",probeCodePoint:2693,
|
|
18
|
+
charRegex:/\p{Script=Gujarati}/u,files:J("NotoSansGujarati-Regular.ttf"),shape:!0},oriya:{family:"NotoSansOriya",probeCodePoint:2821,charRegex:/\p{Script=Oriya}/u,files:J("NotoSansOriya-Regular.ttf"),
|
|
19
|
+
shape:!0},tamil:{family:"NotoSansTamil",probeCodePoint:2949,charRegex:/\p{Script=Tamil}/u,files:J("NotoSansTamil-Regular.ttf"),shape:!0},telugu:{family:"NotoSansTelugu",probeCodePoint:3077,charRegex:/\p{Script=Telugu}/u,
|
|
20
|
+
files:J("NotoSansTelugu-Regular.ttf"),shape:!0},kannada:{family:"NotoSansKannada",probeCodePoint:3205,charRegex:/\p{Script=Kannada}/u,files:J("NotoSansKannada-Regular.ttf"),shape:!0},malayalam:{family:"\
|
|
21
|
+
NotoSansMalayalam",probeCodePoint:3333,charRegex:/\p{Script=Malayalam}/u,files:J("NotoSansMalayalam-Regular.ttf"),shape:!0},sinhala:{family:"NotoSansSinhala",probeCodePoint:3461,charRegex:/\p{Script=Sinhala}/u,
|
|
22
|
+
files:J("NotoSansSinhala-Regular.ttf"),shape:!0},thai:{family:"NotoSansThai",probeCodePoint:3585,charRegex:/\p{Script=Thai}/u,files:J("NotoSansThai-Regular.ttf"),shape:!0},lao:{family:"NotoSansLao",probeCodePoint:3713,
|
|
23
|
+
charRegex:/\p{Script=Lao}/u,files:J("NotoSansLao-Regular.ttf"),shape:!0},khmer:{family:"NotoSansKhmer",probeCodePoint:6016,charRegex:/\p{Script=Khmer}/u,files:J("NotoSansKhmer-Regular.ttf"),shape:!0},
|
|
24
|
+
myanmar:{family:"NotoSansMyanmar",probeCodePoint:4096,charRegex:/\p{Script=Myanmar}/u,files:J("NotoSansMyanmar-Regular.ttf"),shape:!0},tibetan:{family:"NotoSerifTibetan",probeCodePoint:3904,charRegex:/\p{Script=Tibetan}/u,
|
|
25
|
+
files:J("NotoSerifTibetan-Regular.ttf"),shape:!0},ethiopic:{family:"NotoSansEthiopic",probeCodePoint:4608,charRegex:/\p{Script=Ethiopic}/u,files:J("NotoSansEthiopic-Regular.ttf")},armenian:{family:"No\
|
|
26
|
+
toSansArmenian",probeCodePoint:1329,charRegex:/\p{Script=Armenian}/u,files:J("NotoSansArmenian-Regular.ttf")},georgian:{family:"NotoSansGeorgian",probeCodePoint:4304,charRegex:/\p{Script=Georgian}/u,files:J(
|
|
27
|
+
"NotoSansGeorgian-Regular.ttf")},syriac:{family:"NotoSansSyriac",probeCodePoint:1808,charRegex:/\p{Script=Syriac}/u,files:J("NotoSansSyriac-Regular.ttf"),shape:!0},thaana:{family:"NotoSansThaana",probeCodePoint:1920,
|
|
28
|
+
charRegex:/\p{Script=Thaana}/u,files:J("NotoSansThaana-Regular.ttf"),shape:!0},arabic:{family:"NotoNaskhArabic",probeCodePoint:1575,charRegex:/[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/,
|
|
29
|
+
files:{normal:"NotoNaskhArabic-Regular.ttf",bold:"NotoNaskhArabic-Bold.ttf"}},hebrew:{family:"NotoSansHebrew",probeCodePoint:1488,charRegex:/[\u0590-\u05FF\uFB1D-\uFB4F]/,files:{normal:"NotoSansHebrew\
|
|
30
|
+
-Regular.ttf",bold:"NotoSansHebrew-Bold.ttf"}},cjkExtensionB:{family:"HanExtBSubset",probeCodePoint:131079,charRegex:/[\u{20000}-\u{207FF}]/u,files:J("HanExtBSubset-Regular.ttf"),shape:!0},han:{family:"\
|
|
31
|
+
NotoSansSC",probeCodePoint:20013,charRegex:/[\p{Script=Han}\p{Script=Bopomofo}\u3000-\u303F\uFE30-\uFE4F\uFF00-\uFFEF]/u,files:J("NotoSansSC-Regular.ttf")},emoji:{family:"NotoEmoji",probeCodePoint:128512,
|
|
32
|
+
charRegex:/[\p{Extended_Pictographic}\p{Regional_Indicator}]/u,files:J("NotoEmoji-Regular.ttf"),shape:!0},arrows:{family:"NotoSansSymbols",probeCodePoint:8592,charRegex:/[\u2190-\u21FF]/u,files:J("Not\
|
|
33
|
+
oSansSymbols-Regular.ttf")},symbols:{family:"NotoSansSymbols2",probeCodePoint:9728,charRegex:/[\u2300-\u23FF\u2460-\u24FF\u25A0-\u27BF\u2B00-\u2BFF\u{1F000}-\u{1F2FF}]/u,files:J("NotoSansSymbols2-Regu\
|
|
34
|
+
lar.ttf"),shape:!0}},E=class st{static async ensureAllLatexRendered(t){const e=[],a=new Set,i=(n,l)=>{const o=`${l}:${n}`;!a.has(o)&&n.trim()&&(a.add(o),e.push({content:n,displayMode:l}))},r=n=>{if(!n||
|
|
35
|
+
typeof n!="object")return;if(Array.isArray(n)){n.forEach(r);return}const l=n;l.type==="math"&&l.content?i(l.content,l.displayMode!=="inline"):l.type==="text"&&l.marks?.latex&&l.text&&i(l.text,!1),r(l.
|
|
36
|
+
children)};r(t.children),r(t.chrome),r(t.notes),await Promise.all(e.map(n=>ca(n.content,n.displayMode)))}static getLatexSvgFromCache(t,e){return ha(t,e)}static async svgToPng(t,e,a,i=3){return new Promise(
|
|
37
|
+
r=>{const n=new Image,l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(t);n.onload=()=>{try{const o=document.createElement("canvas");o.width=e*i,o.height=a*i;const h=o.getContext("2d");if(!h){
|
|
38
|
+
r(null);return}h.scale(i,i),h.drawImage(n,0,0,e,a),r(o.toDataURL("image/png"))}catch(o){console.error("Failed to convert SVG to PNG:",o),r(null)}},n.onerror=()=>{r(null)},n.src=l})}static async loadFontFile(t,e=!0){
|
|
39
|
+
const a=wt(`fonts/${t}`),i=this.fontFileData.get(a);if(i!==void 0)return i;const r=await ua(t);let n=r??null;try{if(r===void 0){const l=await fetch(wt(`fonts/${t}`));if(l.ok){const o=await l.arrayBuffer();
|
|
40
|
+
Ht(new Uint8Array(o))==="ttf"&&(n=this.arrayBufferToBase64(o))}}}catch{}return n||(n=await this.readFontFromDisk(t)),!n&&e&&console.warn(`Failed to load font ${t}; PDF export used a fallback font. Emb\
|
|
41
|
+
edded editors: if revise.io is unreachable, mirror the fonts and call setAssetBaseUrl().`),this.fontFileData.set(a,n),n}static async readFontFromDisk(t){try{const{readFile:e}=await import("fs/promises"),
|
|
42
|
+
{join:a}=await import("path"),i=[a(process.cwd(),"public","fonts",t),a(process.cwd(),"frontend","public","fonts",t),a(process.cwd(),"..","frontend","public","fonts",t),a(process.cwd(),"..","..","front\
|
|
43
|
+
end","public","fonts",t)];for(const r of i)try{return(await e(r)).toString("base64")}catch{}}catch{}return null}static async loadSourceCodePro(t){const e=await this.loadFontFile("SourceCodePro-Regular\
|
|
44
|
+
.ttf",!1);return e?(t.addFileToVFS("SourceCodePro-Regular.ttf",e),t.addFont("SourceCodePro-Regular.ttf","SourceCodePro","normal"),!0):!1}static async loadKaTeXMain(t){const e=[{file:"KaTeX_Main-Regula\
|
|
45
|
+
r.ttf",style:"normal"},{file:"KaTeX_Main-Bold.ttf",style:"bold"},{file:"KaTeX_Main-Italic.ttf",style:"italic"},{file:"KaTeX_Main-BoldItalic.ttf",style:"bolditalic"}],a=await Promise.all(e.map(async i=>{
|
|
46
|
+
const r=await this.loadFontFile(i.file);return r?{...i,base64:r}:null}));for(const i of a)i&&(t.addFileToVFS(i.file,i.base64),t.addFont(i.file,"KaTeX_Main",i.style));return a[0]!==null}static async embedBundledGenreFonts(t,e,a){
|
|
47
|
+
this.bundledGenreFamilies.clear();const i=new Set,r=n=>{const l=this.mapFontFamilyToStandard(n);this.BUNDLED_GENRE_FONTS[l]&&i.add(l)};r(a);for(const n of Nt(e))r(n.value);for(const n of i){const l=this.
|
|
48
|
+
BUNDLED_GENRE_FONTS[n],o=await Promise.all(Object.entries(l.files).map(async([h,s])=>({style:h,file:s,base64:await this.loadFontFile(s)})));if(!o.some(h=>!h.base64)){for(const{style:h,file:s,base64:g}of o)
|
|
49
|
+
t.addFileToVFS(s,g),t.addFont(s,l.family,h);this.bundledGenreFamilies.set(n,l.family)}}}static documentFallbackScripts(t){const e=new Set,a=Object.keys(this.SCRIPT_FALLBACK_FONTS),i=r=>{if(e.size===a.
|
|
50
|
+
length||!r||typeof r!="object")return;if(Array.isArray(r)){r.forEach(i);return}const n=r;if(typeof n.text=="string"&&n.text)for(const l of a)!e.has(l)&&this.SCRIPT_FALLBACK_FONTS[l].charRegex.test(n.text)&&
|
|
51
|
+
e.add(l);i(n.children)};return i(t.children),i(t.chrome),i(t.notes),e}static splitDocumentFallbackRuns(t,e){const a=Object.entries(this.SCRIPT_FALLBACK_FONTS),i=s=>{const g=a.filter(([,P])=>P.charRegex.
|
|
52
|
+
test(s)).map(([P])=>P);if(g.length>1&&e){const P=s.codePointAt(0)??0,c=g.find(d=>e(d,P));if(c)return c}return g[0]},r=/[\p{Letter}\p{Number}]/u,n=this.SCRIPT_FALLBACK_FONTS.japanese.charRegex,l=this.SCRIPT_FALLBACK_FONTS.
|
|
53
|
+
korean.charRegex,o=s=>{const g=s.text??"";if(!g)return[{...s}];const P=[];let c="",d=null;for(const f of g.split(/(\s+)/)){const T=n.test(f)?"japanese":l.test(f)?"korean":null;for(const m of f){let x=i(
|
|
54
|
+
m);if(x==="han"&&T&&(x=T),!x&&r.test(m)&&(x="base"),!x){d?d.text+=m:c+=m;continue}!d||d.key!==x?(d&&P.push(d),d={key:x,text:c+m},c=""):d.text+=m}}return d?(d.text+=c,P.push(d)):P.push({key:"base",text:c}),
|
|
55
|
+
P.map(f=>{if(f.key==="base")return{...s,text:f.text};const T=this.SCRIPT_FALLBACK_FONTS[f.key];return{...s,text:f.text,marks:{...s.marks,fontFamily:T.family}}})},h=s=>Array.isArray(s)?s.flatMap(g=>g&&
|
|
56
|
+
typeof g=="object"&&g.type==="text"?o(g):[h(g)]):!s||typeof s!="object"?s:Object.fromEntries(Object.entries(s).map(([g,P])=>[g,h(P)]));return h(t)}static async loadFallbackCoverage(t){const e=Object.entries(
|
|
57
|
+
this.SCRIPT_FALLBACK_FONTS),a=new Set,i=new Set,r=l=>{if(!l||typeof l!="object")return;if(Array.isArray(l)){l.forEach(r);return}const o=l;if(typeof o.text=="string")for(const h of o.text){if(i.has(h)||
|
|
58
|
+
h.charCodeAt(0)<128)continue;i.add(h);const s=e.filter(([,g])=>g.charRegex.test(h));s.length>1&&s.forEach(([g])=>a.add(g))}r(o.children)};r(t.children),r(t.chrome),r(t.notes);const n=new Map;for(const l of a){
|
|
59
|
+
const o=this.SCRIPT_FALLBACK_FONTS[l].files.normal;let h=this.fallbackCharsetCache.get(o);if(h===void 0){h=null;const s=await this.loadFontFile(o,!1);if(s)try{const g=(await import("./browser-module-CFmqfGkE.js")).
|
|
60
|
+
create(ee(s));h=new Set(g.characterSet??[])}catch{h=null}this.fallbackCharsetCache.set(o,h)}h&&n.set(l,h)}return(l,o)=>{const h=n.get(l);return h?h.has(o):!0}}static async embedScriptFallbackFonts(t,e){
|
|
61
|
+
this.scriptFallbackFamilies.clear(),this.shapingFonts.clear();for(const a of this.documentFallbackScripts(e)){const i=await this.registerScriptFallbackFace(t,a);i&&this.scriptFallbackFamilies.set(a,i)}}static async registerScriptFallbackFace(t,e){
|
|
62
|
+
const a=this.SCRIPT_FALLBACK_FONTS[e];if(!a)return null;const i=await this.loadFontFile(a.files.normal);if(!i)return null;const r=await this.loadFontFile(a.files.bold,!1);t.addFileToVFS(a.files.normal,
|
|
63
|
+
i),r&&a.files.bold!==a.files.normal&&t.addFileToVFS(a.files.bold,r);const n=r?a.files.bold:a.files.normal;if(t.addFont(a.files.normal,a.family,"normal"),t.addFont(n,a.family,"bold"),t.addFont(a.files.
|
|
64
|
+
normal,a.family,"italic"),t.addFont(n,a.family,"bolditalic"),a.shape&&!this.shapingFonts.has(a.family))try{const[l,o]=await Promise.all([import("./browser-module-CFmqfGkE.js"),import("./_revise-sdk-lazy-harfbuzz-CDWdjF9f.js")]),
|
|
65
|
+
h=o,s=h.loadHarfBuzz?await h.loadHarfBuzz():o,g=ee(i),P=l.create(g),c=new s.Blob(g),d=new s.Face(c),f=new s.Font(d);this.shapingFonts.set(a.family,{unitsPerEm:d.upem,notdefPathCommands:P.getGlyph(0).path.
|
|
66
|
+
commands,layout:T=>{const m=new s.Buffer;m.addText(T),m.guessSegmentProperties(),s.shape(f,m);const x=m.getGlyphInfosAndPositions(),F=x.map(_=>({xAdvance:_.xAdvance??0,yAdvance:_.yAdvance??0,xOffset:_.
|
|
67
|
+
xOffset??0,yOffset:_.yOffset??0}));return{glyphs:x.map(_=>P.getGlyph(_.codepoint)),positions:F,advanceWidth:F.reduce((_,I)=>_+I.xAdvance,0)}}})}catch(l){console.warn(`Failed to initialize PDF shaping \
|
|
68
|
+
for ${a.family}:`,l)}return a.family}static fontCoversCodePoint(t,e,a){const i=`${e}:${a}`;let r=this.scriptFontCoverageCache.get(i);if(r===void 0){let n;try{n=t.getFont(e,"normal")}catch{n=void 0}r=!!n?.
|
|
69
|
+
metadata?.cmap?.unicode?.codeMap?.[a],this.scriptFontCoverageCache.set(i,r)}return r}static fontCoversMatchedChars(t,e,a,i){let r=!1;for(const n of a)if(i.test(n)&&(r=!0,!this.fontCoversCodePoint(t,e,
|
|
70
|
+
n.codePointAt(0)??0)))return!1;return r}static scriptFallbackFor(t,e,a){if(!e||this.scriptFallbackFamilies.size===0)return null;let i=null;for(const[r,n]of Object.entries(this.SCRIPT_FALLBACK_FONTS)){
|
|
71
|
+
const l=this.scriptFallbackFamilies.get(r);if(l&&n.charRegex.test(e)&&!this.fontCoversCodePoint(t,a,n.probeCodePoint)&&!this.fontCoversMatchedChars(t,a,e,n.charRegex)){if(this.fontCoversMatchedChars(t,
|
|
72
|
+
l,e,n.charRegex))return l;i??(i=l)}}return i}static async registerDocumentFonts(t,e,a){await this.embedLocalFonts(t,e),await this.embedBundledGenreFonts(t,e,a),await this.embedScriptFallbackFonts(t,e);
|
|
73
|
+
const i=this.documentUsesSourceCodePro(e)?await this.loadSourceCodePro(t):!1;return this.inlineCodeFontFamily=i?"SourceCodePro":"courier",this.documentUsesKaTeXMain(e)&&await this.loadKaTeXMain(t),{hasSourceCodePro:i}}static async registerCurrentPdfFonts(t,e){
|
|
74
|
+
for(const[a,i]of this.bundledGenreFamilies){const r=this.BUNDLED_GENRE_FONTS[a];if(!r||r.family!==i)continue;const n=await Promise.all(Object.entries(r.files).map(async([l,o])=>({style:l,file:o,base64:await this.
|
|
75
|
+
loadFontFile(o)})));for(const{style:l,file:o,base64:h}of n)h&&(t.addFileToVFS(o,h),t.addFont(o,i,l))}for(const a of this.scriptFallbackFamilies.keys())await this.registerScriptFallbackFace(t,a);e&&await this.
|
|
76
|
+
loadSourceCodePro(t)}static documentUsesKaTeXMain(t){return Nt(t).some(e=>{const a=e.family.toLowerCase();return a.includes("katex")||a.includes("computer modern")||a.includes("computermodern")})}static documentUsesSourceCodePro(t){
|
|
77
|
+
const e=[...t.children];for(;e.length>0;){const a=e.pop();if(!a||typeof a!="object")continue;const i=a;if(i.type==="code"||i.type==="text"&&typeof i.marks=="object"&&i.marks!==null&&i.marks.code===!0)
|
|
78
|
+
return!0;Array.isArray(i.children)&&e.push(...i.children)}return!1}static createCanvasTextContext(){if(typeof document>"u")return null;const t=document.createElement("canvas").getContext("2d");if(!t)return null;
|
|
79
|
+
let e=null;return{measureText:a=>({width:$t(a,e,i=>t.measureText(i).width)}),setFont:a=>{t.font=a,e=null},setMarkAdjustments:a=>{e=a}}}static resolveIndentStepPx(t){return this.resolvePdfLayoutMetrics(
|
|
80
|
+
t).indentStepPx}static getDefaultPdfLayoutMetrics(){const t=Gt(void 0),e=Math.max(1,this.PAGE_WIDTH-this.MARGIN_LEFT-this.MARGIN_RIGHT);return{orientation:"portrait",pageWidthPt:this.PAGE_WIDTH,pageHeightPt:this.
|
|
81
|
+
PAGE_HEIGHT,marginTopPt:this.MARGIN_TOP,marginRightPt:this.MARGIN_RIGHT,marginBottomPt:this.MARGIN_BOTTOM,marginLeftPt:this.MARGIN_LEFT,contentWidthPt:e,fullContentWidthPt:e,pageMarginLeftPt:this.MARGIN_LEFT,
|
|
82
|
+
columnCount:1,columnGapPt:Rt(t.columnGapTwips),columnStridePt:qt(e,Rt(t.columnGapTwips)),blockSpacingPt:t.blockSpacingPx*this.PX_TO_PT,indentStepPx:t.indentStepPx,showPageNumbers:t.showPageNumbers,pageBorders:t.
|
|
83
|
+
pageBorders,pageNumberPosition:t.pageNumberPosition,pageNumberStart:t.pageNumberStart,pageNumberFormat:t.pageNumberFormat,hyphenationEnabled:t.hyphenationEnabled,lineNumbering:t.lineNumbering,pleadingGrid:t.
|
|
84
|
+
pleadingGrid}}static resolvePdfLayoutMetrics(t){return this.resolvePdfMetricsFromSettings(t?.pageLayout,t?.pageLayout,!1)}static resolvePdfMetricsFromSettings(t,e,a=!1){const i=zt(e,t),r=t,{pageWidth:n,
|
|
85
|
+
pageHeight:l}=Ut(i),o=n*this.PX_TO_PT,h=l*this.PX_TO_PT,s=i.marginTopPx*this.PX_TO_PT,g=i.marginRightPx*this.PX_TO_PT,P=i.marginBottomPx*this.PX_TO_PT,c=i.marginLeftPx*this.PX_TO_PT,d=Math.max(1,o-c-g),
|
|
86
|
+
f=Math.max(1,i.columnCount),T=Rt(i.columnGapTwips),m=Oe(d,f,T);return{orientation:i.orientation,pageWidthPt:o,pageHeightPt:h,marginTopPt:s,marginRightPt:g,marginBottomPt:P,marginLeftPt:c,contentWidthPt:m,
|
|
87
|
+
fullContentWidthPt:d,pageMarginLeftPt:c,columnCount:f,columnGapPt:T,columnStridePt:qt(m,T),...f>1?{columnFlow:{index:0,topPt:s,pageOffset:0}}:{},blockSpacingPt:i.blockSpacingPx*this.PX_TO_PT,indentStepPx:i.
|
|
88
|
+
indentStepPx,showPageNumbers:i.showPageNumbers,pageBorders:i.pageBorders,pageNumberPosition:i.pageNumberPosition,pageNumberStart:i.pageNumberStart,pageNumberStartExplicit:a&&r?.pageNumberStart!==void 0,
|
|
89
|
+
pageNumberFormat:i.pageNumberFormat,hyphenationEnabled:i.hyphenationEnabled,lineNumbering:i.lineNumbering,pleadingGrid:i.pleadingGrid}}static physicalPageMetrics(t){return{...t,marginLeftPt:t.pageMarginLeftPt,
|
|
90
|
+
contentWidthPt:t.fullContentWidthPt,columnFlow:void 0,reservedInsetForPage:void 0}}static computeEngineLayout(t){if(typeof document>"u")return null;const e=document.createElement("canvas").getContext(
|
|
91
|
+
"2d");if(!e)return null;const a=Gt(t.pageLayout),i=Ut(a),r=ke({pageWidth:i.pageWidth,pageHeight:i.pageHeight,pageMargin:a.marginLeftPx,pageMarginTop:a.marginTopPx,pageMarginRight:a.marginRightPx,pageMarginBottom:a.
|
|
92
|
+
marginBottomPx,pageMarginLeft:a.marginLeftPx,availableWidth:Math.max(1,i.pageWidth-a.marginLeftPx-a.marginRightPx),textStartY:a.marginTopPx,indentStepPx:a.indentStepPx,blockSpacingPx:a.blockSpacingPx,
|
|
93
|
+
hyphenationEnabled:a.hyphenationEnabled,lineNumbering:a.lineNumbering,columnCount:a.columnCount,columnGapPx:se(a.columnGapTwips),pageless:!1});try{return Je(t,Ce(e),r)}catch{return null}}static computeColumnBalanceTargets(t,e){
|
|
94
|
+
const a=new Map,i=e.filter(g=>g.type==="section-break"),r=new Set;if(i.forEach((g,P)=>{const c=zt(t.pageLayout,g.layout);Me(Math.max(1,c.columnCount),g.breakType==="continuous")&&r.add(P)}),r.size===0)
|
|
95
|
+
return a;const n=this.computeEngineLayout(t);if(!n?.pageGeometries||n.pageGeometries.length===0)return a;const l=new Map(n.pageGeometries.map(g=>[g.pageIndex+1,g.pageTop])),o=(g,P)=>{if(!g||typeof g!=
|
|
96
|
+
"object")return;if(Array.isArray(g)){g.forEach(d=>o(d,P));return}const c=g;typeof c.id=="string"&&c.id&&P.add(c.id),o(c.children,P)},h=new Map;let s=0;for(const g of e){if(g.type==="section-break"){s+=
|
|
97
|
+
1;continue}let P=h.get(s);P||(P=new Set,h.set(s,P)),o(g,P)}for(const g of r){const P=h.get(g);if(!P||P.size===0)continue;const c=n.fragments.filter(x=>!x.isChrome&&typeof x.pageNumber=="number"&&P.has(
|
|
98
|
+
x.blockId));if(c.length===0)continue;let d=Number.POSITIVE_INFINITY,f=0;for(const x of c)d=Math.min(d,x.pageNumber),f=Math.max(f,x.pageNumber);const T=l.get(f);if(T===void 0)continue;let m=0;for(const x of c)
|
|
99
|
+
x.pageNumber===f&&(m=Math.max(m,x.bounds.y+x.bounds.height-T));m<=0||a.set(g,{pageOffset:f-d,bottomPt:m*this.PX_TO_PT+this.COLUMN_BALANCE_SLACK_PT})}return a}static advancePdfColumnOrPage(t,e){const a=e.
|
|
100
|
+
columnFlow;return!a||e.columnCount<=1?(t.addPage(),!0):a.index<e.columnCount-1?(a.index+=1,e.marginLeftPt=e.pageMarginLeftPt+a.index*e.columnStridePt,!1):(a.index=0,e.marginLeftPt=e.pageMarginLeftPt,t.
|
|
101
|
+
addPage([e.pageWidthPt,e.pageHeightPt],e.orientation),a.topPt=e.marginTopPt,a.pageOffset+=1,!0)}static advancePdfFlowRegion(t,e){const a=this.advancePdfColumnOrPage(t,e);return{x:e.marginLeftPt,y:a?e.
|
|
102
|
+
marginTopPt:e.columnFlow?.topPt??e.marginTopPt}}static declaredSpacingPx(t,e){const a=t?.[e];return typeof a=="number"&&Number.isFinite(a)?Math.max(0,a):void 0}static pdfSpaceBeforePt(t,e,a){const i=Ne(
|
|
103
|
+
a,t)??st.declaredSpacingPx(t,"spaceBefore");return i!==void 0?i*st.PX_TO_PT:e.blockSpacingPt}static pdfSpaceAfterPt(t,e){const a=Re(t,e)??st.declaredSpacingPx(t,"spaceAfter");return a!==void 0?a*st.PX_TO_PT:
|
|
104
|
+
0}static syncPdfColumnOffset(t){const e=t.columnFlow;!e||t.columnCount<=1||(t.marginLeftPt=t.pageMarginLeftPt+e.index*t.columnStridePt)}static getPdfReservedInsetPt(t,e){return e.reservedInsetForPage?.
|
|
105
|
+
get(this.getPdfCurrentPage(t))??0}static getPdfWritableBottomPt(t,e){return e.pageHeightPt-e.marginBottomPt-this.getPdfReservedInsetPt(t,e)}static getPdfFlowBottom(t,e){const a=this.getPdfWritableBottomPt(
|
|
106
|
+
t,e),i=e.columnFlow;return!i?.balance||e.columnCount<=1||i.pageOffset!==i.balance.pageOffset?a:Math.min(a,i.balance.bottomPt)}static getPdfPageCount(t){return typeof t.getNumberOfPages=="function"?t.getNumberOfPages():
|
|
107
|
+
typeof t.internal?.getNumberOfPages=="function"?t.internal.getNumberOfPages():1}static getPdfCurrentPage(t){return t.getCurrentPageInfo?.().pageNumber??this.getPdfPageCount(t)}static createPdfPageNumbering(t,e,a){
|
|
108
|
+
const i=[...e?.keys()??[]].sort((o,h)=>o-h),r=o=>{let h=t;for(const s of i){if(s>o)break;h=e.get(s)}return h},n=[],l=o=>{const h=Math.max(1,Math.floor(o));for(let s=n.length+1;s<=h;s++){const g=r(s);n.
|
|
109
|
+
push(s===1||a?.has(s)&&g.pageNumberStartExplicit?g.pageNumberStart:n[s-2]+1)}return n[h-1]};return{metricsForPage:r,numberForPage:l,labelForPage:o=>le(l(o),r(o).pageNumberFormat)}}static async renderHeaderFooterChrome(t,e,a,i,r,n){
|
|
110
|
+
const l=this.getPdfPageCount(t),o=d=>{if(!r)return a;let f=a,T=0;for(const[m,x]of r)m<=d&&m>T&&(f=x,T=m);return f},h=d=>{if(!n)return 0;let f=0,T=0;for(const[m,x]of n)m<=d&&m>T&&(f=x,T=m);return f},s=d=>{
|
|
111
|
+
if(!n)return 1;let f=1;for(const[T]of n)T<=d&&T>f&&(f=T);return f},g=this.createPdfPageNumbering(a,r,n).labelForPage,P=(d,f)=>{if(e.chrome&&e.chrome.length>0)return xe(e.chrome,d,f,h(f));const T=d==="\
|
|
112
|
+
header"?e.headers:e.footers;if(!T)return;const m=f===s(f)&&T.first?"first":f%2===0&&T.even?"even":"default",x=T[m];if(x)return _e(d,m,ye(x),i)},c=async(d,f,T)=>{const m=o(T),x=d.children.slice(0,3).map(
|
|
113
|
+
(M,B)=>{const p=vt[B];return{...M,...p&&!M.align?{align:p}:{},children:M.children.map(u=>u.type!=="text"||!u.marks?.field?u:u.marks.field==="page"?{...u,text:g(T)}:{...u,text:String(l)})}});for(;x.length<
|
|
114
|
+
3;){const M=x.length;x.push({type:"paragraph",id:`${d.id}-pdf-column-${M}`,children:[{type:"text",text:""}],...vt[M]?{align:vt[M]}:{}})}const F=this.createLayoutForWrapping(m.contentWidthPt,m.indentStepPx,
|
|
115
|
+
m),_=this.createCanvasTextContext(),I=_?Ze(d,_,F,e,x).map(M=>M*this.PX_TO_PT):[m.contentWidthPt/3,m.contentWidthPt/3,m.contentWidthPt/3],R=f?Math.max(10*this.PX_TO_PT,m.marginTopPt/2):m.pageHeightPt-Math.
|
|
116
|
+
max(10*this.PX_TO_PT,m.marginBottomPt/2);let v=m.marginLeftPt;for(let M=0;M<3;M++){const B=x[M],p=I[M],u=this.measureParagraphLineAdvances(B,p,m.indentStepPx,m).reduce((k,D)=>k+D,0),S=R-u/2,w={...m,marginTopPt:S,
|
|
117
|
+
marginLeftPt:v,marginRightPt:Math.max(0,m.pageWidthPt-v-p),contentWidthPt:Math.max(1,p)};await this.renderParagraph(t,B,S,p,i,1e9,m.indentStepPx,w),v+=p}};for(let d=0;d<l;d++){const f=d+1;t.setPage(f);
|
|
118
|
+
const T=P("header",f),m=P("footer",f);T&&await c(T,!0,f),m&&await c(m,!1,f)}this.renderPageNumbers(t,a,i,o,g,(d,f)=>!!P(f,d));for(let d=1;d<=l;d++){const f=o(d),T=ce(f.pageBorders,f.pageWidthPt,f.pageHeightPt,
|
|
119
|
+
{top:f.marginTopPt,right:f.marginRightPt,bottom:f.marginBottomPt,left:f.pageMarginLeftPt},d===s(d));if(!T.length)continue;t.setPage(d);const m=t.internal?.pages?.[d],x=m?.length??0;t.saveGraphicsState(),
|
|
120
|
+
t.setLineCap?.("square");for(const F of T){t.setDrawColor(F.color),t.setLineWidth(F.style==="double"?F.widthPt/3:F.widthPt),t.setLineDashPattern(F.style==="dotted"?[F.widthPt,F.widthPt*2]:F.style==="d\
|
|
121
|
+
ashed"?[F.widthPt*4,F.widthPt*2]:[],0);for(const _ of F.style==="double"?[-F.widthPt/3,F.widthPt/3]:[0]){const I=F.x1===F.x2?_:0,R=F.y1===F.y2?_:0;t.line(F.x1+I,F.y1+R,F.x2+I,F.y2+R)}}t.restoreGraphicsState(),
|
|
122
|
+
f.pageBorders?.zOrder==="back"&&m&&m.unshift(...m.splice(x))}}static drawWatermarkOnPage(t,e,a,i){t.setFont("helvetica","normal");const r=Ae(e,a/this.PX_TO_PT,i/this.PX_TO_PT,(x,F)=>{t.setFontSize(F*this.
|
|
123
|
+
PX_TO_PT);const _=t.getTextWidth(x);return typeof _=="number"?_/this.PX_TO_PT:0})*this.PX_TO_PT;t.setFontSize(r);const n=t.getTextWidth(e.text),l=this.hexToRgb(e.color);t.setTextColor(l.r,l.g,l.b);const o=typeof t.
|
|
124
|
+
saveGraphicsState=="function"&&typeof t.setGState=="function"&&typeof t.GState=="function";o&&(t.saveGraphicsState(),t.setGState(new t.GState({opacity:e.opacity})));const h=e.diagonal?Math.atan2(i,a):
|
|
125
|
+
0,s=Math.cos(h),g=Math.sin(h),P=a/2,c=i/2,d=n/2,f=-.35*r,T=P-(d*s+f*g),m=c-(-d*g+f*s);t.text(e.text,T,m,{...h!==0?{angle:h*180/Math.PI}:{}}),o&&t.restoreGraphicsState()}static installWatermarkUnderpaint(t,e){
|
|
126
|
+
const a=()=>{const r=t.internal?.pageSize,n=typeof r?.getWidth=="function"?r.getWidth():r?.width,l=typeof r?.getHeight=="function"?r.getHeight():r?.height;!n||!l||this.drawWatermarkOnPage(t,e,n,l)},i=t.
|
|
127
|
+
addPage.bind(t);t.addPage=(...r)=>{const n=i(...r);return a(),n},a()}static renderBodyLineNumbers(t,e,a,i,r){const n=s=>{let g,P=0;for(const[c,d]of a)c<=s&&c>P&&(g=d,P=c);return g??this.resolvePdfLayoutMetrics(
|
|
128
|
+
i)},l=this.getPdfPageCount(t),o=l;let h=!1;for(let s=1;s<=l;s++){const g=n(s),P=g.pleadingGrid;P&&(t.setPage(s),h=!0,this.renderPleadingGrid(t,P,g,r?.get(s)??P.fontFamily));const c=g.lineNumbering;if(!c||
|
|
129
|
+
e.length===0)continue;let d=c.start;if(c.restart==="continuous")for(const T of e)T.pageNumber<s&&d++;t.setPage(s),h=!0,t.setFont(this.mapFontFamily(r?.get(s)),"normal"),t.setFontSize(10*this.PX_TO_PT),
|
|
130
|
+
t.setTextColor(115,115,115);const f=g.marginLeftPt-(c.distancePx??12)*this.PX_TO_PT;for(const T of e){if(T.pageNumber!==s)continue;const m=d++;if(m%c.countBy!==0)continue;const x=T.baselineOffset??Math.
|
|
131
|
+
min(T.height,12);t.text(String(m),f,T.y+x,{align:"right",baseline:"alphabetic"})}}h&&t.setPage(o)}static renderPleadingGrid(t,e,a,i){t.setFont(this.mapFontFamily(i??"Times New Roman"),"normal");const r=(e.
|
|
132
|
+
fontSizePx??16)*this.PX_TO_PT;t.setFontSize(r),t.setTextColor(0,0,0);const n=e.firstBaselinePx!==void 0?e.firstBaselinePx*this.PX_TO_PT:a.marginTopPt+r,l=(a.pageMarginLeftPt??a.marginLeftPt)-(e.distancePx??
|
|
133
|
+
14)*this.PX_TO_PT;for(let o=0;o<e.rows;o++)t.text(String(o+1),l,n+o*e.pitchPx*this.PX_TO_PT,{align:"right",baseline:"alphabetic"})}static lineBaselineOffsetPt(t,e){let a=0;for(const i of t){if(i.latexImage||
|
|
134
|
+
i.marks?.latex)continue;const r=i.marks?.fontSize?i.marks.fontSize*this.PX_TO_PT:e;r>a&&(a=r)}return a||e}static renderPageNumbers(t,e,a,i,r,n){const l=this.getPdfPageCount(t),o=12,h=o/2+6;t.setFont(this.
|
|
135
|
+
mapFontFamily(a),"normal"),t.setFontSize(o),t.setTextColor(0,0,0);for(let s=0;s<l;s++){const g=i?.(s+1)??e;if(!g.showPageNumbers)continue;const P=s+1,c=g.pageNumberPosition.startsWith("top");if(n?.(P,
|
|
136
|
+
c?"header":"footer"))continue;const d=g.pageNumberPosition.endsWith("right"),f=d?g.pageWidthPt-g.marginRightPt:g.marginLeftPt,T=c?Math.max(h,g.marginTopPt/2):g.pageHeightPt-Math.max(h,g.marginBottomPt/
|
|
137
|
+
2);t.setPage(P),t.text(r?.(P)??he({pageNumberStart:e.pageNumberStart,pageNumberFormat:e.pageNumberFormat??"decimal"},s),f,T,{align:d?"right":"left"})}}static getParagraphLineIndentPt(t,e,a){return ge(
|
|
138
|
+
t,e,a)*this.PX_TO_PT}static createLayoutForWrapping(t,e,a=this.getDefaultPdfLayoutMetrics()){const i=t/this.PX_TO_PT;return{pageWidth:a.pageWidthPt/this.PX_TO_PT,pageHeight:a.pageHeightPt/this.PX_TO_PT,
|
|
139
|
+
pageMargin:a.marginLeftPt/this.PX_TO_PT,pageMarginTop:a.marginTopPt/this.PX_TO_PT,pageMarginRight:a.marginRightPt/this.PX_TO_PT,pageMarginBottom:a.marginBottomPt/this.PX_TO_PT,pageMarginLeft:a.marginLeftPt/
|
|
140
|
+
this.PX_TO_PT,pageSpacing:0,paragraphSpacing:0,availableWidth:i,textStartY:a.marginTopPt/this.PX_TO_PT,fontSize:16,fontFamily:this.DEFAULT_BODY_FONT,lineHeight:16*1.4,indentStepPx:e,pageless:!1,hyphenationEnabled:a.
|
|
141
|
+
hyphenationEnabled}}static buildNumberedNoteEntries(t){const e=new Map,a=s=>{if(!s||typeof s!="object")return;if(Array.isArray(s)){s.forEach(a);return}const g=s;g.type!=="footnote"&&(g.marks?.footnoteRef&&
|
|
142
|
+
!e.has(g.marks.footnoteRef)&&e.set(g.marks.footnoteRef,g.text??""),a(g.children))};a(t.children.filter(s=>s.type!=="footnote"));const i=[...t.notes??[],...t.children.filter(s=>s.type==="footnote")],r={
|
|
143
|
+
footnote:0,endnote:0},n=new Map,l=new Map;for(const s of i)l.set(s.id,s.noteKind==="endnote"?"endnote":"footnote");for(const[s]of e){const g=l.get(s)??"footnote";r[g]+=1,n.set(s,Kt(r[g],g))}const o=i.
|
|
144
|
+
map(s=>{const g=l.get(s.id)??"footnote",P=n.get(s.id)||Kt(r[g]+=1,g);return{footnoteId:s.id,number:P,kind:g,blocks:s.children}}),h=s=>{const g=[...n.keys()],P=g.indexOf(s.footnoteId);return P===-1?g.length:
|
|
145
|
+
P};return o.sort((s,g)=>h(s)-h(g))}static async renderNoteEntry(t,e,a,i,r,n,l,o,h){o&&this.drawNoteNumeral(t,e.number,i.marginLeftPt,a,r);const s=et.verticalPaddingPx*st.PX_TO_PT,g=et.gutterPx*st.PX_TO_PT,
|
|
146
|
+
P=a+s,c={...i,marginTopPt:i.marginTopPt+s,marginLeftPt:i.marginLeftPt+g,contentWidthPt:Math.max(1,i.contentWidthPt-g),blockSpacingPt:et.blockSpacingPx*st.PX_TO_PT};if(h){const d=c.marginTopPt;Object.defineProperty(
|
|
147
|
+
c,"marginTopPt",{get:()=>h.get(this.getPdfCurrentPage(t))??d})}return(await this.renderBodyBlocks(t,e.blocks,c,n,l,r,void 0,void 0,void 0,P)).finalY+s}static drawNoteNumeral(t,e,a,i,r){t.setFont(this.
|
|
148
|
+
mapFontFamily(r),"normal"),t.setFontSize(jt*this.PX_TO_PT),t.setTextColor(0,0,0),t.text(e,a+1.5,i+(6+jt)*st.PX_TO_PT)}static mapFootnoteRefBlocks(t){const e=new Map,a=(i,r)=>{if(!i||typeof i!="object")
|
|
149
|
+
return;if(Array.isArray(i)){i.forEach(l=>a(l,r));return}const n=i;n.marks?.footnoteRef&&!e.has(n.marks.footnoteRef)&&e.set(n.marks.footnoteRef,r),a(n.children,r)};for(const i of t)a(i,i.id??"");return e}static async renderBodyBlocks(t,e,a,i,r,n,l,o,h,s,g){
|
|
150
|
+
const P=new Map,c=new Map([[1,0]]),d=[],f=[],T=be(e);let m=s??a.marginTopPt,x=a.contentWidthPt,F=a.indentStepPx,_=!0;const I=new Map([[1,this.physicalPageMetrics(a)]]),R=()=>t.getCurrentPageInfo?.()?.
|
|
151
|
+
pageNumber??t.getNumberOfPages();let v=0;const M=B=>{if(v=B,!g)return;const p=a.columnFlow;!p||a.columnCount<=1||(p.index=0,p.topPt=m,p.pageOffset=0,p.balance=g.balanceBySection.get(B),a.marginLeftPt=
|
|
152
|
+
a.pageMarginLeftPt)};M(0);for(let B=0;B<e.length;B++){this.syncPdfColumnOffset(a);const p=e[B],u=this.getPdfFlowBottom(t,a);if(p.type==="page-break"){!_&&a.blockSpacingPt>0&&(m+=a.blockSpacingPt),p.id&&
|
|
153
|
+
P.set(p.id,R()),t.addPage([a.pageWidthPt,a.pageHeightPt],a.orientation),a.columnFlow&&(a.columnFlow.index=0,a.columnFlow.topPt=a.marginTopPt,a.columnFlow.pageOffset+=1,a.marginLeftPt=a.pageMarginLeftPt),
|
|
154
|
+
m=a.marginTopPt,_=!0;continue}if(p.type==="docx-raw"){const C=St.heightPx*.75,N=a.pageWidthPt-a.marginLeftPt-a.marginRightPt,G=Ee(p,N/.75)*.75;!_&&a.blockSpacingPt>0&&(m+=a.blockSpacingPt),m+C>u&&(m=this.
|
|
155
|
+
advancePdfFlowRegion(t,a).y),p.id&&P.set(p.id,R());const H=a.marginLeftPt;t.setDrawColor(107,114,128),t.setFillColor(243,244,246),t.setLineWidth(.75),t.roundedRect(H,m,G,C,St.cornerRadiusPx*.75,St.cornerRadiusPx*
|
|
156
|
+
.75,"FD"),t.setFont("courier","normal"),t.setFontSize(St.fontPx*.75),t.setTextColor(107,114,128),t.text(Be(p),H+St.paddingXPx*.75,m+C/2,{baseline:"middle"}),t.setTextColor(0,0,0),m+=C,_=!1;continue}if(p.
|
|
157
|
+
type==="section-break"){p.id&&P.set(p.id,R());const C=l?.get(p.id),N=C?o?.(C)??C:void 0;if(N){const H=ve(p.breakType==="continuous",{width:a.pageWidthPt,height:a.pageHeightPt},{width:N.pageWidthPt,height:N.
|
|
158
|
+
pageHeightPt});a=N,x=N.contentWidthPt,F=N.indentStepPx,H?(m=Ie(m,a.blockSpacingPt,0,a.marginTopPt),m>this.getPdfWritableBottomPt(t,a)&&(t.addPage([a.pageWidthPt,a.pageHeightPt],a.orientation),m=a.marginTopPt)):
|
|
159
|
+
(t.addPage([N.pageWidthPt,N.pageHeightPt],N.orientation),m=a.marginTopPt),I.set(R(),this.physicalPageMetrics(N))}else t.addPage(),m=a.marginTopPt;const G=h?.get(p.id);G!==void 0&&c.set(R(),G),M(v+1),_=
|
|
160
|
+
!0;continue}if(p.type==="toc"){const C=a.blockSpacingPt;!_&&C>0&&(m+=C),_=!1,p.id&&P.set(p.id,R());const N=de({children:e.map(b=>b.type==="paragraph"?this.paragraphForPdfOutput(b):b)},fe(p)),G=(p.fontSize??
|
|
161
|
+
16)*this.PX_TO_PT,H=G*1.4,j=Yt.paddingYPx*this.PX_TO_PT;t.setFont(this.mapFontFamily(p.fontFamily??n),"normal"),t.setFontSize(G);const y=this.hexToRgb(p.color??"#000000");t.setTextColor(y.r,y.g,y.b),m+=
|
|
162
|
+
j,N.length===0&&(m+H>u&&(m=this.advancePdfFlowRegion(t,a).y),m+=H);for(const b of N)m+H>u&&(m=this.advancePdfFlowRegion(t,a).y),f.push({pdfPage:R(),headingBlockId:b.blockId,block:p,entry:b,baseline:m+
|
|
163
|
+
G,left:a.marginLeftPt,width:a.contentWidthPt,fontName:this.mapFontFamily(p.fontFamily??n),fontSizePt:G}),m+=H;m+=j;continue}const S=B>0?e[B-1]:void 0,w=st.pdfSpaceBeforePt(p,a,S)+st.pdfSpaceAfterPt(S,
|
|
164
|
+
p);if(!_&&w>0?m+=w:_&&B===0&&a.keepFirstBlockDeclaredSpaceBefore&&(m+=(st.declaredSpacingPx(p,"spaceBefore")??0)*st.PX_TO_PT),_=!1,p.id&&p.type!=="paragraph"&&P.set(p.id,R()),p.type==="container"){const C=await this.
|
|
165
|
+
renderContainerBlock(t,p,m,x,n,i,r,a);m=C.nextY;for(const[N,G]of C.blockStartPages)P.set(N,G);d.push(...C.lineMarks);continue}if(p.type==="placeholder"){m=this.advancePlaceholderBlock(t,p,m,a);continue}
|
|
166
|
+
if(p.type==="image"){const C=await this.renderImageBlock(t,p,m,x,a);C&&(m=C.nextY);continue}if(p.type==="math"){const C=p;m=(await this.renderMathBlock(t,C,m,x,u,a)).nextY;continue}if(p.type==="list"){
|
|
167
|
+
m=await this.renderListBlock(t,p,m,x,n,a,T.get(p.id),d);continue}if(p.type==="table"){m=await this.renderTableBlock(t,p,m,x,n,i,r,a);continue}if(p.type==="code"){m=await this.renderCodeBlock(t,p,m,x,u,
|
|
168
|
+
a.marginLeftPt,i,r,a,d);continue}if(p.type!=="paragraph")continue;const k=p,{required:D,firstLineAdvance:q}=this.getRequiredParagraphStartHeight(e,B,x,F,a);D>0&&m+D>u&&a.marginTopPt+D<=u&&m!==a.marginTopPt&&
|
|
169
|
+
(m=this.advancePdfFlowRegion(t,a).y),m+q>u&&m!==a.marginTopPt&&(m=this.advancePdfFlowRegion(t,a).y),k.id&&P.set(k.id,R()),m=await this.renderParagraph(t,k,m,x,n,u,F,a,d)}if(f.length>0){const B=R(),p=this.
|
|
170
|
+
createPdfPageNumbering(I.get(1)??a,I,c).labelForPage;for(const u of f){t.setPage(u.pdfPage),t.setFont(u.fontName,"normal"),t.setFontSize(u.fontSizePt);const S=this.hexToRgb(u.block.color??"#000000");t.
|
|
171
|
+
setTextColor(S.r,S.g,S.b);const w=P.get(u.headingBlockId),k=w!==void 0?p(w):"",D=me(u.block,u.entry,u.left,u.width,k,q=>t.getTextWidth(q),this.PX_TO_PT);D.text&&t.text(D.text,D.textX,u.baseline,{align:D.
|
|
172
|
+
align,...D.rtl?{isInputVisual:!1,isOutputVisual:!0,isInputRtl:!0,isOutputRtl:!1}:{}}),k&&D.leaderEnd-D.leaderStart>Yt.minimumLeaderWidthPx*this.PX_TO_PT&&(t.setDrawColor(150),typeof t.setLineDashPattern==
|
|
173
|
+
"function"&&t.setLineDashPattern([.8,2.2],0),t.line(D.leaderStart,u.baseline,D.leaderEnd,u.baseline),typeof t.setLineDashPattern=="function"&&t.setLineDashPattern([],0),t.setDrawColor(0,0,0)),k&&t.text(
|
|
174
|
+
k,D.numberX,u.baseline)}t.setPage(B)}return{blockStartPages:P,pageMetrics:I,pageSections:c,lineMarks:d,finalY:m}}static async renderContainerBlock(t,e,a,i,r,n,l,o){const h=Math.max(0,e.padding??Et.paddingPx)*
|
|
175
|
+
this.PX_TO_PT,s=this.getPdfFlowBottom(t,o);a+h>s&&a!==o.marginTopPt&&(a=this.advancePdfFlowRegion(t,o).y);const g=()=>t.getCurrentPageInfo?.()?.pageNumber??t.getNumberOfPages(),P=g(),c=o.columnFlow?.index??
|
|
176
|
+
0,d=o.columnFlow?.topPt??o.marginTopPt,f={...o,keepFirstBlockDeclaredSpaceBefore:void 0,marginTopPt:o.marginTopPt+h,marginRightPt:o.marginRightPt+h,marginBottomPt:o.marginBottomPt+h,marginLeftPt:o.marginLeftPt+
|
|
177
|
+
h,contentWidthPt:Math.max(1,i-h*2),pageMarginLeftPt:o.pageMarginLeftPt+h},T=await this.renderBodyBlocks(t,e.children,f,n,l,r,void 0,void 0,void 0,a+h);let m=T.finalY+h;this.syncPdfColumnOffset(o),m>s&&
|
|
178
|
+
T.finalY!==f.marginTopPt&&(m=this.advancePdfFlowRegion(t,o).y+h);const x=g(),F=o.columnFlow?.index??0,_=x,I=this.hexToRgb(e.borderColor??Et.borderColor);t.setDrawColor(I.r,I.g,I.b),t.setLineWidth(Et.borderWidthPx*
|
|
179
|
+
this.PX_TO_PT);let R=P,v=c;for(;R<x||R===x&&v<=F;){t.setPage(R);const M=R===P&&v===c,B=R===x&&v===F,p=M?a:R===P?d:o.marginTopPt,u=B?m:s;u>p&&t.rect(o.pageMarginLeftPt+v*o.columnStridePt,p,i,u-p,"S"),v+=
|
|
180
|
+
1,v>=o.columnCount&&(v=0,R+=1)}return t.setPage(_),{nextY:m,blockStartPages:T.blockStartPages,lineMarks:T.lineMarks}}static advancePlaceholderBlock(t,e,a,i){const r=Math.max(0,e.height||100)*this.PX_TO_PT,
|
|
181
|
+
n=this.getPdfFlowBottom(t,i);return a+r>n&&a!==i.marginTopPt&&(a=this.advancePdfFlowRegion(t,i).y),a+r}static async toBlob(t,e,a){class i extends this{}return i.bundledGenreFamilies=new Map,i.scriptFallbackFamilies=
|
|
182
|
+
new Map,i.shapingFonts=new Map,i.embeddedFamilyNames=new Map,i.inlineCodeFontFamily="courier",i.renderDocument(t,e,a)}static async renderDocument(t,e,a){t=this.splitDocumentFallbackRuns(t,await this.loadFallbackCoverage(
|
|
183
|
+
t));const i=a||{...Xt,background:Lt.codeBackground,text:Lt.codeText};await this.ensureAllLatexRendered(t);const r=this.resolvePdfLayoutMetrics(t),n=t.children.filter(S=>S.type==="section-break"),l=new Map,
|
|
184
|
+
o=new Map,h=t.pageLayout?.pageNumberRestart===!0?{...r,pageNumberStartExplicit:!0}:r;n.forEach((S,w)=>{const k=n[w+1];l.set(S.id,k?.layout?this.resolvePdfMetricsFromSettings(k.layout,t.pageLayout,!0):
|
|
185
|
+
k?r:h),o.set(S.id,w+1)});const s=n[0]?.layout?this.resolvePdfMetricsFromSettings(n[0].layout,t.pageLayout,!1):r,g=await import("./jspdf.es.min-DU74zN8b.js").then(S=>S.j),P=g.jsPDF??g.default,c=new P({
|
|
186
|
+
orientation:s.orientation,unit:"pt",format:[s.pageWidthPt,s.pageHeightPt]}),d=this.DEFAULT_BODY_FONT,{hasSourceCodePro:f}=await this.registerDocumentFonts(c,t,d);e&&c.setProperties({title:e});const T=We(
|
|
187
|
+
t.watermark);T&&this.installWatermarkUnderpaint(c,T);const m=[...t.children.filter(S=>S.type==="footnote"),...t.notes??[]],x=t.children.filter(S=>S.type!=="footnote"&&S.type!=="header-footer"),F={balanceBySection:this.
|
|
188
|
+
computeColumnBalanceTargets(t,x)},_=m.length>0?this.buildNumberedNoteEntries(t):[],I=_.filter(S=>S.kind==="footnote"),R=_.filter(S=>S.kind==="endnote");let v=new Map([[1,s]]),M=new Map([[1,0]]),B=s.marginTopPt,
|
|
189
|
+
p=[],u=new Map;if(I.length===0){const S=await this.renderBodyBlocks(c,x,s,i,f,d,l,void 0,o,void 0,F);v=S.pageMetrics,M=S.pageSections,p=S.lineMarks,B=S.finalY}else{const S=I,w=et.separatorSpacePx*this.
|
|
190
|
+
PX_TO_PT,k=this.mapFootnoteRefBlocks(x),D=new P({orientation:s.orientation,unit:"pt",format:[s.pageWidthPt,s.pageHeightPt]});await this.registerDocumentFonts(D,t,d);const q=await this.renderBodyBlocks(
|
|
191
|
+
D,x,s,i,f,d,l,void 0,void 0,void 0,F),C=L=>{let A=s,U=0;for(const[z,Y]of q.pageMetrics)z<=L&&z>U&&(A=Y,U=z);return A},N=new Map,G=D.getNumberOfPages();for(const L of S){const A=k.get(L.footnoteId),U=(A?
|
|
192
|
+
q.blockStartPages.get(A):void 0)??G,z=N.get(U)??[];z.push(L),N.set(U,z)}const H=new P({orientation:r.orientation,unit:"pt",format:[r.pageWidthPt,1e4]});await this.registerDocumentFonts(H,t,d);const j=new Map;
|
|
193
|
+
for(const[L,A]of N){const U=C(L);for(const z of A){const Y={...U,pageHeightPt:1e4,marginTopPt:0,marginBottomPt:0},V=await this.renderNoteEntry(H,z,0,Y,d,i,f,!1);j.set(z.footnoteId,Math.max(0,V))}}const y=new Map;
|
|
194
|
+
for(const[L,A]of N){const U=C(L),z=w+A.reduce((tt,rt)=>tt+(j.get(rt.footnoteId)??0),0),Y=U.pageHeightPt-U.marginTopPt-U.marginBottomPt,V=q.lineMarks.filter(tt=>tt.pageNumber===L).sort((tt,rt)=>tt.y-rt.
|
|
195
|
+
y).slice(0,et.minimumBodyLinesBeforeFootnotes),Z=this.getParagraphLineHeight({type:"paragraph",id:"__pdf_measure__",children:[]}),nt=(V.length>0?Math.max(0,Math.max(...V.map(tt=>tt.y+tt.height))-U.marginTopPt):
|
|
196
|
+
Z*et.minimumBodyLinesBeforeFootnotes)+et.bodyKeepSlackPx*this.PX_TO_PT;y.set(L,Math.min(z,Math.max(0,Y-nt)))}u=y;const b=L=>({...L,reservedInsetForPage:y}),X=b(s),O=await this.renderBodyBlocks(c,x,X,i,
|
|
197
|
+
f,d,l,b,o,void 0,F);v=O.pageMetrics,M=O.pageSections,p=O.lineMarks,B=O.finalY;const K=new Map;for(const L of O.lineMarks)K.set(L.pageNumber,Math.max(K.get(L.pageNumber)??0,L.y+L.height+et.separatorSpacePx*
|
|
198
|
+
this.PX_TO_PT+et.verticalPaddingPx*this.PX_TO_PT));const W=c.getNumberOfPages();for(const[L,A]of[...N.entries()].sort((U,z)=>U[0]-z[0])){const U=Math.min(L,W);c.setPage(U);const z=C(L),Y=y.get(L)??0,V=z.
|
|
199
|
+
pageHeightPt-z.marginBottomPt-Y+w;c.setDrawColor(120),c.setLineWidth(.75),c.line(z.marginLeftPt,V-7,z.marginLeftPt+Math.max(et.separatorWidthMinPx*this.PX_TO_PT,z.contentWidthPt*et.separatorWidthFraction),
|
|
200
|
+
V-7);let Z=V;for(let nt=0;nt<A.length;nt++){nt>0&&(Z+=et.blockSpacingPx*this.PX_TO_PT);const tt=this.getPdfCurrentPage(c),rt=c.addPage.bind(c),lt=[];c.addPage=(...ct)=>{const at=this.getPdfCurrentPage(
|
|
201
|
+
c)+1;return at<=W?c.setPage(at):rt(...ct),lt.push(this.getPdfCurrentPage(c)),c};try{Z=await this.renderNoteEntry(c,A[nt],Z,z,d,i,f,!0,K)}finally{c.addPage=rt}for(const ct of lt){c.setPage(ct),c.setDrawColor(
|
|
202
|
+
120),c.setLineWidth(.75);const at=(K.get(ct)??z.marginTopPt)-et.verticalPaddingPx*this.PX_TO_PT*2;c.line(z.marginLeftPt,at,z.marginLeftPt+z.contentWidthPt,at)}c.setPage(lt[lt.length-1]??tt)}}c.setPage(
|
|
203
|
+
this.getPdfPageCount(c))}if(R.length>0){const S=new P({orientation:r.orientation,unit:"pt",format:[r.pageWidthPt,1e4]});await this.registerDocumentFonts(S,t,d);let w=et.separatorToContentPx*this.PX_TO_PT;
|
|
204
|
+
for(let H=0;H<R.length;H++){H>0&&(w+=et.blockSpacingPx*this.PX_TO_PT);const j={...r,pageHeightPt:1e4,marginTopPt:0,marginBottomPt:0};w+=await this.renderNoteEntry(S,R[H],0,j,d,i,f,!1)}const k=this.getPdfPageCount(
|
|
205
|
+
c);let D=s,q=0;for(const[H,j]of v)H<=k&&H>=q&&(D=j,q=H);const C=B+et.inlineEndnoteGapPx*this.PX_TO_PT,N=C+w<=D.pageHeightPt-D.marginBottomPt-(u.get(k)??0);let G;N?(c.setPage(k),G=C):(c.addPage(),G=D.marginTopPt+
|
|
206
|
+
et.newPageSeparatorOffsetPx*this.PX_TO_PT),c.setDrawColor(120),c.setLineWidth(.75),c.line(D.marginLeftPt,G,D.marginLeftPt+Math.max(et.separatorWidthMinPx*this.PX_TO_PT,D.contentWidthPt*et.separatorWidthFraction),
|
|
207
|
+
G),G+=et.separatorToContentPx*this.PX_TO_PT;for(let H=0;H<R.length;H++)H>0&&(G+=et.blockSpacingPx*this.PX_TO_PT),G=await this.renderNoteEntry(c,R[H],G,D,d,i,f,!0)}return await this.renderHeaderFooterChrome(
|
|
208
|
+
c,t,r,d,v,M),this.renderBodyLineNumbers(c,p,v,t,[...v.values()].some(S=>S.lineNumbering||S.pleadingGrid)?da(this.computeEngineLayout(t),this.DEFAULT_BODY_FONT):void 0),c.output("blob")}static measureLineAdvancePt(t,e,a,i){
|
|
209
|
+
let r=0,n=0;for(const h of t)h.latexImage?n=Math.max(n,h.latexImage.contentHeight*this.PX_TO_PT):r=Math.max(r,h.marks?.fontSize?h.marks.fontSize*this.PX_TO_PT:e);r===0&&(r=e);const l=i??(a?this.LINE_HEIGHT_MULTIPLIERS.
|
|
210
|
+
heading:this.LINE_HEIGHT_MULTIPLIERS.paragraph),o=r*l;return n>o*1.25?n:o}static parseParagraphDecoration(t){const e=t.shading&&t.shading!=="transparent"?t.shading:void 0;if(!e&&!t.borders)return null;
|
|
211
|
+
let a;if(t.borders)try{a=JSON.parse(t.borders)}catch{a=void 0}return!e&&!a?null:{...e?{shading:e}:{},...a?{edges:a}:{}}}static drawParagraphDecorationSlice(t,e,a,i,r,n,l,o){if(e.shading){const f=this.
|
|
212
|
+
hexToRgb(e.shading);t.setFillColor(f.r,f.g,f.b),t.rect(a,i,r,n+(o?0:.5),"F")}const h=e.edges;if(!h)return;const s=(f,T,m,x,F)=>{const _=h[f];if(!_||_.style==="none")return;const I=Math.max(.4,(_.width??
|
|
213
|
+
1)*this.PX_TO_PT),R=m===F,v=this.hexToRgb(_.color??"#000000");if(t.setDrawColor(v.r,v.g,v.b),t.setLineWidth(I),R&&$e(_.style)){const p=qe(T,x,this.PX_TO_PT);for(const u of p.lines)t.line(u.from,m,u.to,
|
|
214
|
+
m);t.setFillColor(v.r,v.g,v.b);for(const u of p.ornaments)if(_.style==="stars")for(const S of Ve(u.cx,m,u.radius))t.line(S.x1,S.y1,S.x2,S.y2);else{const S=Qe(u.cx,m,u.radius);t.lines([[S[1].x-S[0].x,S[1].
|
|
215
|
+
y-S[0].y],[S[2].x-S[1].x,S[2].y-S[1].y],[S[3].x-S[2].x,S[3].y-S[2].y]],S[0].x,S[0].y,[1,1],"F",!0)}return}const M=typeof t.setLineDashPattern=="function";M&&(_.style==="dashed"?t.setLineDashPattern([4.5,
|
|
216
|
+
2.25],0):_.style==="dotted"?t.setLineDashPattern([1.5,1.5],0):t.setLineDashPattern([],0));const B=p=>{t.line(T+(R?0:p),m+(R?p:0),x+(R?0:p),F+(R?p:0))};_.style==="double"?(B(-I),B(I)):B(0),M&&t.setLineDashPattern(
|
|
217
|
+
[],0)},g=o?0:.5,P=f=>Math.max(0,h[f]?.space??0)*this.PX_TO_PT,c=a-P("left"),d=a+r+P("right");if(s("left",c,i,c,i+n+g),s("right",d,i,d,i+n+g),l){const f=i-P("top");s("top",a,f,a+r,f)}if(o){const f=i+n+
|
|
218
|
+
P("bottom");s("bottom",a,f,a+r,f)}}static measureParagraphLineAdvances(t,e,a,i){const r=this.createCanvasTextContext();if(!r)return[this.getParagraphLineHeight(t)];const n=this.createLayoutForWrapping(
|
|
219
|
+
e,a,i),l=Vt(this.paragraphForPdfOutput(t),r,n);if(l.length===0)return[this.getEmptyParagraphLineHeight(t)];const o=this.getParagraphFontSize(t),h=this.getLineSpacingMultiplier(t);return l.map(s=>this.
|
|
220
|
+
measureLineAdvancePt(s.segments.map(g=>({marks:g.marks})),o,!!t.heading,h))}static paragraphForPdfOutput(t){const e=t.children.filter(a=>a.type!=="text"||!a.marks?.hidden||!!a.marks.footnoteRef);return e.
|
|
221
|
+
length===t.children.length?t:{...t,children:e}}static getParagraphDirection(t){let e="";for(const a of t.children)e+=a.text??"";return ea(t.direction,e)}static getEffectiveParagraphAlignment(t,e){return t.
|
|
222
|
+
align||(e==="rtl"?"right":"left")}static getRequiredParagraphStartHeight(t,e,a,i,r){const n=t[e];if(!n||n.type!=="paragraph")return{required:0,firstLineAdvance:0};const l=It(n),o=this.measureParagraphLineAdvances(
|
|
223
|
+
n,a,i,r),h=this.paragraphForPdfOutput(n).children.every(c=>c.type==="text"&&c.text==="")||o.length===0?this.getEmptyParagraphLineHeight(n):o[0],s=c=>c.reduce((d,f)=>d+Math.max(0,f),0);let g=0;if(l.keepLines?
|
|
224
|
+
g=s(o):l.widowControl&&o.length>=2&&(g=o[0]+o[1]),!l.keepNext)return{required:g,firstLineAdvance:h};let P=0;for(let c=0;c<ae;c++){const d=t[e+c+1];if(!d||d.type!=="paragraph")break;const f=this.measureParagraphLineAdvances(
|
|
225
|
+
d,a,i,r);if(f.length===0)break;const T=t[e+c];P+=st.pdfSpaceBeforePt(d,r,T)+st.pdfSpaceAfterPt(T,d);const m=It(d);if(m.keepNext&&c<ae-1){P+=s(f);continue}P+=f[0],m.widowControl&&f.length>=2&&(P+=f[1]);
|
|
226
|
+
break}return{required:Math.max(g,s(o)+P),firstLineAdvance:h}}static async renderParagraph(t,e,a,i,r,n,l=this.resolveIndentStepPx(),o=this.getDefaultPdfLayoutMetrics(),h){let s=a;const g=this.paragraphForPdfOutput(
|
|
227
|
+
e),P=this.getParagraphFontSize(e),c=this.getParagraphLineHeight(e),d=this.getLineSpacingMultiplier(e);let f=Number.isFinite(n)&&n>0?n:this.getPdfFlowBottom(t,o),T=o.marginLeftPt;const m=()=>{const M=this.
|
|
228
|
+
advancePdfFlowRegion(t,o);s=M.y,T=M.x,f=this.getPdfFlowBottom(t,o)},x=(M=c)=>{if(s+M>f){if(s===o.marginTopPt)return;m()}},F=()=>t.getCurrentPageInfo?.()?.pageNumber??t.getNumberOfPages(),_=this.getParagraphDirection(
|
|
229
|
+
g),I=this.getEffectiveParagraphAlignment(e,_),R=this.parseParagraphDecoration(e);if(g.children.length===0||g.children.length===1&&g.children[0].type==="text"&&g.children[0].text===""){const M=this.getEmptyParagraphLineHeight(
|
|
230
|
+
e);return R&&(x(M),this.drawParagraphDecorationSlice(t,R,T,s,i,M,!0,!0)),s+M}const v=this.createCanvasTextContext();if(v){const M=this.createLayoutForWrapping(i,l,o),B=Vt(g,v,M),p=await this.prepareLatexImages(
|
|
231
|
+
g,P),u=B.map(w=>w.segments.map(k=>k.marks?.latex?{text:k.text,marks:k.marks,latexImage:p.get(k.text)}:{text:k.text,marks:k.marks,font:k.marks?.fontFamily})),S=It(e);for(let w=0;w<B.length;w++){const k=B[w],
|
|
232
|
+
D=u[w];if(D.length>0){const q=this.getParagraphLineIndentPt(e,w,l),C=Math.max(1,i-q),N=this.measureLineAdvancePt(D,P,!!e.heading,d),G=u[w+1];if(S.widowControl&&B.length>=3&&w===B.length-2&&G&&s+N<=f){
|
|
233
|
+
const j=this.measureLineAdvancePt(G,P,!!e.heading,d);s+N+j>f&&s!==o.marginTopPt&&m()}x(N);const H=_==="rtl"?T:T+q;R&&this.drawParagraphDecorationSlice(t,R,T,s,i,N,w===0,w===B.length-1),h?.push({pageNumber:F(),
|
|
234
|
+
y:s,height:N,baselineOffset:this.lineBaselineOffsetPt(D,P)}),s=this.renderLine(t,D,s,H,C,I,P,r,!!e.heading,d,w===B.length-1,{direction:_,...k.tabLayout?{tabLayoutPx:k.tabLayout.segments,...k.tabLayout.
|
|
235
|
+
rtl?{tabRtl:!0,tabWidthPx:k.tabLayout.width}:{}}:{},...k.hyphenTrailing?{hyphenTrailing:!0}:{}})}}return s}return this.renderParagraphWithJsPDFWrapping(t,g,a,i,r,n,l,o)}static async prepareLatexImages(t,e){
|
|
236
|
+
const a=new Map;for(const i of t.children)if(i.type==="text"&&i.marks?.latex){const r=await this.renderLatexToImage(i.text,!1,e);r&&a.set(i.text,r)}return a}static async renderParagraphWithJsPDFWrapping(t,e,a,i,r,n,l=this.
|
|
237
|
+
resolveIndentStepPx(),o=this.getDefaultPdfLayoutMetrics()){let h=a;const s=this.getParagraphFontSize(e),g=this.getParagraphLineHeight(e),P=this.getLineSpacingMultiplier(e);let c=Number.isFinite(n)&&n>
|
|
238
|
+
0?n:this.getPdfFlowBottom(t,o),d=o.marginLeftPt;const f=()=>{if(h+g>c){if(h===o.marginTopPt)return;const M=this.advancePdfFlowRegion(t,o);h=M.y,d=M.x,c=this.getPdfFlowBottom(t,o)}},T=this.getParagraphDirection(
|
|
239
|
+
e),m=this.getEffectiveParagraphAlignment(e,T),x=await this.processTextNodesWithLatex(e.children,s);if(x.length===0)return h+this.getEmptyParagraphLineHeight(e);let F=[],_=0,I=0;const R=()=>Math.max(1,
|
|
240
|
+
i-this.getParagraphLineIndentPt(e,I,l)),v=(M=!1)=>{if(F.length===0)return;f();const B=this.getParagraphLineIndentPt(e,I,l);h=this.renderLine(t,F,h,T==="rtl"?d:d+B,Math.max(1,i-B),m,s,r,!!e.heading,P,M,
|
|
241
|
+
{direction:T}),F=[],_=0,I+=1};if(x.length===1&&x[0].text==="")return a+this.getEmptyParagraphLineHeight(e);for(const M of x){if(M.latexImage){const p=M.latexImage.contentWidth*this.PX_TO_PT;_+p>R()&&F.
|
|
242
|
+
length>0&&v(),F.push({text:M.text,marks:M.marks,font:M.font||M.marks?.fontFamily,latexImage:M.latexImage}),_+=p;continue}this.setRunFont(t,M,r),t.setFontSize(this.getRunEffectiveFontSizePt(M.marks,s));
|
|
243
|
+
const B=M.text.split(`
|
|
244
|
+
`);for(let p=0;p<B.length;p++){const u=B[p];p>0&&F.length>0&&v();const S=u.split(/(\s+)/);for(const w of S){const k=this.measureRunDisplayWidthPt(t,w,M.marks);_+k>R()&&F.length>0&&v(),(w.trim()||F.length>
|
|
245
|
+
0)&&(F.push({text:w,marks:M.marks,font:M.font||M.marks?.fontFamily}),_+=k)}}}return F.length>0&&v(!0),h}static getLineSpacingMultiplier(t){return ie(t)}static async renderListBlock(t,e,a,i,r,n=this.getDefaultPdfLayoutMetrics(),l,o){
|
|
246
|
+
if(!e.children.length)return a;let h=a;const s=this.getPdfFlowBottom(t,n),g=l??Fe(e),P={...g.counters};let c;if(e.variant==="ordered"&&e.numberingFormat)try{t.setFont(this.mapFontFamily(r),"normal"),t.
|
|
247
|
+
setFontSize(this.FONT_SIZES.normal);let d=0;for(const T of Se(e,g))d=Math.max(d,t.getTextWidth(T)/this.PX_TO_PT);const f=this.ORDERED_LIST_INDENT_PT/this.PX_TO_PT;c=Math.min(Math.max(f,Math.ceil(d)+10),
|
|
248
|
+
240)*this.PX_TO_PT}catch{c=void 0}for(let d=0;d<e.children.length;d++){const f=e.children[d],T=this.getListIndentLevel(f);let m;e.variant==="ordered"?m={type:"ordered",label:this.computeOrderedMarkerLabel(
|
|
249
|
+
P,T,g.start,Le(e.numberingFormat))}:e.variant==="todo"?m={type:"todo",checked:!!f.checked}:m={type:"bullet",indentLevel:T},h=await this.renderListItem(t,f,e,m,h,i,s,r,n,o,c)}return h}static async renderListItem(t,e,a,i,r,n,l,o,h=this.
|
|
250
|
+
getDefaultPdfLayoutMetrics(),s,g){let P=r+Math.max(0,e.spaceBefore??0)*this.PX_TO_PT;const c=this.getListIndentLevel(e)*this.SUBLIST_INDENT_PT,d=o,f=this.FONT_SIZES.normal,T=this.mapFontFamily(d);t.setFont(
|
|
251
|
+
T,"normal"),t.setFontSize(f);const m=g??this.getListIndentPt(a.variant);let x=h.marginLeftPt,F=x+c+m,_=l;const I=()=>{const b=this.advancePdfFlowRegion(t,h);P=b.y,x=b.x,F=x+c+m,_=this.getPdfFlowBottom(
|
|
252
|
+
t,h)};let R=n-c-m;(!Number.isFinite(R)||R<=0)&&(R=Math.max(n*.3,n*.1));let v="";for(const b of e.children)v+=b.text??"";const M=aa(v)??"ltr",B=M==="rtl",p=()=>B?x:F,u=()=>B?x+R:F,S=e.lineSpacing??a.lineSpacing??
|
|
253
|
+
this.LINE_HEIGHT_MULTIPLIERS.paragraph,w=f*S,k=await this.processTextNodesWithLatex(e.children,f);let D=k.length>0?k:[{text:""}];a.variant==="todo"&&e.checked&&(D=D.map(b=>b.latexImage?b:{...b,marks:{
|
|
254
|
+
...b.marks,strikethrough:!0,color:Lt.todoCheckedText}}));const q=new Set(Object.values(this.SCRIPT_FALLBACK_FONTS).map(b=>b.family)),C=[...k].reverse().find(b=>!b.latexImage&&!b.marks?.latex&&b.text.length>
|
|
255
|
+
0&&!q.has(b.marks?.fontFamily??""))?.marks;let N=[],G=0,H=!1;const j=()=>{H||(P+w>_&&P!==h.marginTopPt&&I(),this.drawListMarker(t,i,u(),P,w,f,d,o,B,C),H=!0)},y=()=>{N.length!==0&&(P+w>_&&P!==h.marginTopPt&&
|
|
256
|
+
I(),j(),s?.push({pageNumber:t.getCurrentPageInfo?.().pageNumber??t.getNumberOfPages(),y:P,height:this.measureLineAdvancePt(N,f,!1,S),baselineOffset:this.lineBaselineOffsetPt(N,f)}),P=this.renderLine(t,
|
|
257
|
+
N,P,p(),R,B?"right":"left",f,d,!1,S,!0,{direction:M}),N=[],G=0)};for(const b of D){if(b.latexImage){const O=b.latexImage.contentWidth*this.PX_TO_PT;G+O>R&&N.length>0&&y(),N.push({text:b.text,marks:b.marks,
|
|
258
|
+
font:b.font,latexImage:b.latexImage}),G+=O;continue}this.setRunFont(t,b,d||o),t.setFontSize(this.getRunEffectiveFontSizePt(b.marks,f));const X=b.text.split(`
|
|
259
|
+
`);for(let O=0;O<X.length;O++){const K=X[O];O>0&&(N.length>0?y():(j(),P+=w));const W=K.split(/(\s+)/);for(const L of W){const A=this.measureRunDisplayWidthPt(t,L,b.marks);G+A>R&&N.length>0&&y(),(L.trim()||
|
|
260
|
+
N.length>0)&&(N.push({text:L,marks:b.marks,font:b.font}),G+=A)}}}return N.length>0&&y(),H||(j(),P+=w),P+Math.max(0,e.spaceAfter??0)*this.PX_TO_PT}static drawListMarker(t,e,a,i,r,n,l,o,h,s){t.setDrawColor(
|
|
261
|
+
0,0,0);const g=(d,f=0)=>h?2*a-d-f:d,P=a-this.BULLET_MARKER_WIDTH_PT,c=i+r/2;switch(e.type){case"bullet":{const d=g(P+this.BULLET_CENTER_OFFSET_PT),f=this.BULLET_RADIUS_PT;if(e.indentLevel<=0)t.circle(
|
|
262
|
+
d,c,f,"F");else if(e.indentLevel===1)t.circle(d,c,f,"S");else{const T=this.BULLET_SQUARE_HALF_PT*2,m=g(P+this.BULLET_SQUARE_INSET_PT,T),x=c-this.BULLET_SQUARE_HALF_PT+this.BULLET_SQUARE_VERTICAL_ADJUST_PT;
|
|
263
|
+
t.rect(m,x,T,T,"S")}break}case"todo":{const d=this.TODO_CHECKBOX_SIZE_PT,f=g(P-this.TODO_CHECKBOX_OFFSET_PT,d),T=c-d/2;t.setLineWidth(.8),typeof t.roundedRect=="function"?t.roundedRect(f,T,d,d,this.TODO_CHECKBOX_RADIUS_PT,
|
|
264
|
+
this.TODO_CHECKBOX_RADIUS_PT,"S"):t.rect(f,T,d,d,"S"),e.checked&&(t.setLineWidth(1.2),t.line(f+d*.15,T+d*.55,f+d*.4,T+d*.75),t.line(f+d*.4,T+d*.75,f+d*.85,T+d*.25));break}case"ordered":{const d=e.label,
|
|
265
|
+
f=s?{fontFamily:s.fontFamily,fontSize:s.fontSize,bold:s.bold,italic:s.italic,code:s.code,superscript:s.superscript,subscript:s.subscript}:void 0;this.setRunFont(t,{text:d,marks:f},l||o);const T=this.getRunEffectiveFontSizePt(
|
|
266
|
+
f,n);t.setFontSize(T);const m=t.getTextWidth(d),x=h?a+this.ORDERED_LABEL_GAP_PT:a-this.ORDERED_LABEL_GAP_PT-m;t.text(d,x,i+T);break}}t.setLineWidth(.5),t.setTextColor(0,0,0)}static async renderTableBlock(t,e,a,i,r,n=Xt,l=!1,o=this.
|
|
267
|
+
getDefaultPdfLayoutMetrics()){if(!e.children||e.children.length===0)return a;const h=this.getPdfFlowBottom(t,o);let s=a;const g=e.borderWidth??Bt.borderWidthPx,P=e.borderColor??Bt.borderColor,c=this.hexToRgb(
|
|
268
|
+
P),d=Number.isFinite(e.cellPadding)?Math.max(0,Math.round(e.cellPadding)):Bt.cellPaddingPx,f=d*this.PX_TO_PT,T=He(e.borders),m=je(e),x=m.cols,F=Math.min(e.tableWidth?e.tableWidth*this.PX_TO_PT:i,i),_=e.
|
|
269
|
+
align==="center"?(i-F)/2:e.align==="right"?i-F:0;let I=o.marginLeftPt+_;const R=Ye(e.columnWidths??[],x).map(y=>y/100*F),v=[0];for(let y=0;y<x;y++)v.push(v[y]+R[y]);const M=y=>v[Math.min(y.col+y.colSpan,
|
|
270
|
+
x)]-v[y.col],B=new Map;for(const y of m.cells){const b=Ge(d,y.cell.padding),X={top:b.top*this.PX_TO_PT,right:b.right*this.PX_TO_PT,bottom:b.bottom*this.PX_TO_PT,left:b.left*this.PX_TO_PT},O=M(y)-X.left-
|
|
271
|
+
X.right,K=this.extractCellBlocks(y.cell);let W=this.FONT_SIZES.normal*this.LINE_HEIGHT_MULTIPLIERS.paragraph;if(K.length>0){const A=await import("./jspdf.es.min-DU74zN8b.js").then(V=>V.j),U=A.jsPDF??A.
|
|
272
|
+
default,z=new U({orientation:"portrait",unit:"pt",format:[Math.max(72,O),this.UNBOUNDED_CELL_FLOW_BOTTOM_PT]});await this.registerCurrentPdfFonts(z,l);const Y={...o,keepFirstBlockDeclaredSpaceBefore:!0,
|
|
273
|
+
pageWidthPt:Math.max(72,O),pageHeightPt:this.UNBOUNDED_CELL_FLOW_BOTTOM_PT,marginTopPt:0,marginRightPt:0,marginBottomPt:0,marginLeftPt:0,contentWidthPt:Math.max(1,O)};W=(await this.renderBodyBlocks(z,
|
|
274
|
+
K,Y,n,l,r,void 0,void 0,void 0,0)).finalY}const L=X.top+W+X.bottom;B.set(y.cell.id,{blocks:K,width:O,flowHeight:W,contentHeight:L,pad:X})}const p=e.children.map((y,b)=>{let X=0;for(const O of y.children){
|
|
275
|
+
const K=m.byId.get(O.id);K&&K.rowSpan>1||(X=Math.max(X,B.get(O.id)?.contentHeight??0))}return X}),u=m.cells.filter(y=>y.rowSpan>1).sort((y,b)=>y.rowSpan-b.rowSpan);for(const y of u){const b=B.get(y.cell.
|
|
276
|
+
id);if(!b)continue;let X=0;for(let O=y.row;O<y.row+y.rowSpan;O++)X+=p[O];b.contentHeight>X&&(p[y.row+y.rowSpan-1]+=b.contentHeight-X)}const S=y=>{let b=0;for(let X=y.row;X<y.row+y.rowSpan;X++)b+=p[X];
|
|
277
|
+
return b},w=[],k=()=>{if(w.length===0)return;const y=this.getPdfCurrentPage(t);for(const{page:b,draw:X}of w)t.setPage(b),X();w.length=0,t.setPage(y)},D=(y,b,X,O,K,W,L)=>{const A=y.backgroundColor?this.
|
|
278
|
+
hexToRgb(y.backgroundColor):L?{r:249,g:250,b:251}:{r:255,g:255,b:255};(y.backgroundColor||L)&&(t.setFillColor(A.r,A.g,A.b),t.rect(X,K,O,W,"F"));const U=this.getPdfCurrentPage(t),z=Ue(y.borders);if(T||
|
|
279
|
+
z){const Y=Ke({tableBorders:T,cellBorders:z,flags:{isTopRow:(b?.row??0)===0,isBottomRow:b?b.row+b.rowSpan===m.rows:!1,isLeftCol:(b?.col??0)===0,isRightCol:b?b.col+b.colSpan===m.cols:!1},fallback:{style:"\
|
|
280
|
+
single",width:g,color:P}}),V=X+O,Z=K+W;w.push({page:U,draw:()=>{this.drawPdfBorderEdge(t,Y.top,X,K,V,K),this.drawPdfBorderEdge(t,Y.bottom,X,Z,V,Z),this.drawPdfBorderEdge(t,Y.left,X,K,X,Z),this.drawPdfBorderEdge(
|
|
281
|
+
t,Y.right,V,K,V,Z)}})}else g>0&&w.push({page:U,draw:()=>{t.setDrawColor(c.r,c.g,c.b),t.setLineWidth(g*this.PX_TO_PT),t.rect(X,K,O,W,"S")}})},q=async(y,b,X,O)=>{const K=!!e.hasHeader&&b===0,W=p[b],L=this.
|
|
282
|
+
getPdfCurrentPage(t);for(const A of y.children){t.setPage(L);const U=m.byId.get(A.id),z=I+(U?v[U.col]:0),Y=U?M(U):F/x,V=O||!U?W:S(U);D(A,U,z,Y,X,V,K);const Z=B.get(A.id),nt=Z?.blocks??this.extractCellBlocks(
|
|
283
|
+
A),tt=Z?.pad.left??f,rt=Z?.pad.right??f,lt=Z?.pad.top??f,ct=Z?.pad.bottom??f,at=Z?.width??Y-tt-rt,ot=Z?.flowHeight??this.FONT_SIZES.normal*this.LINE_HEIGHT_MULTIPLIERS.paragraph,ft=Math.max(0,V-lt-ct-
|
|
284
|
+
ot),pt=A.verticalAlign==="bottom"?ft:A.verticalAlign==="middle"?ft/2:0,Ot=X+lt+pt;if(nt.length>0){const kt={...o,keepFirstBlockDeclaredSpaceBefore:!0,columnCount:1,columnFlow:void 0,marginTopPt:Ot,marginRightPt:Math.
|
|
285
|
+
max(0,o.pageWidthPt-(z+tt+at)),marginBottomPt:o.pageHeightPt-this.UNBOUNDED_CELL_FLOW_BOTTOM_PT,marginLeftPt:z+tt,pageMarginLeftPt:z+tt,contentWidthPt:Math.max(1,at),fullContentWidthPt:Math.max(1,at),
|
|
286
|
+
columnStridePt:Math.max(1,at)};await this.renderBodyBlocks(t,nt,kt,n,l,r,void 0,void 0,void 0,Ot)}}t.setPage(L)},C=(y,b)=>y.idx!==b.idx?y.idx>b.idx?y:b:y.y>=b.y?y:b,N=async(y,b,X,O,K,W)=>{const L=B.get(
|
|
287
|
+
b.id),A=L?.blocks??this.extractCellBlocks(b),U=L?.pad.left??f,z=L?.pad.bottom??f,Y=X?M(X):F/x,V=L?.width??Y-U-(L?.pad.right??f),Z=X?v[X.col]:0;let nt=O.idx;if(A.length===0){const ot=L?.flowHeight??this.
|
|
288
|
+
FONT_SIZES.normal*this.LINE_HEIGHT_MULTIPLIERS.paragraph;return{idx:nt,y:Math.min(W,O.y+ot+z)}}const tt=(ot,ft)=>{const pt=ot.left+Z+U;ft.marginTopPt=ot.top,ft.marginLeftPt=pt,ft.pageMarginLeftPt=pt,ft.
|
|
289
|
+
marginRightPt=Math.max(0,o.pageWidthPt-(pt+V))},rt={...o,keepFirstBlockDeclaredSpaceBefore:!0,columnCount:1,columnFlow:void 0,marginBottomPt:o.pageHeightPt-W,reservedInsetForPage:void 0,contentWidthPt:Math.
|
|
290
|
+
max(1,V),fullContentWidthPt:Math.max(1,V),columnStridePt:Math.max(1,V)},lt=K(nt);tt(lt,rt),y.setPage(lt.page);const ct=y.addPage;y.addPage=()=>{nt+=1;const ot=K(nt);return tt(ot,rt),y.setPage(ot.page),
|
|
291
|
+
y};let at=O.y;try{at=(await this.renderBodyBlocks(y,A,rt,n,l,r,void 0,void 0,void 0,O.y)).finalY}finally{y.addPage=ct}return{idx:nt,y:Math.min(W,at+z)}},G=async(y,b,X)=>{const O=h,K=H&&y>0?p[0]:0,W=o.
|
|
292
|
+
marginTopPt+K,L=await import("./jspdf.es.min-DU74zN8b.js").then($=>$.j),A=L.jsPDF??L.default,U=new A({orientation:o.orientation,unit:"pt",format:[o.pageWidthPt,o.pageHeightPt]});await this.registerCurrentPdfFonts(
|
|
293
|
+
U,l);const z=U.addPage.bind(U),Y=[{page:1,top:o.marginTopPt,left:I}],V=$=>{for(;Y.length<=$;)z(),Y.push({page:Y.length+1,top:W,left:I});return Y[$]},Z=($,it)=>{let{idx:ut,y:ht}=$,gt=it;for(;;){const mt=Math.
|
|
294
|
+
max(0,O-ht);if(gt<=mt+.01)return{idx:ut,y:ht+gt};gt-=mt,ut+=1,ht=W}},nt=[],tt=[],rt=new Map,lt=[];let ct={idx:0,y:X};for(let $=y;$<b;$++){const it=ct;nt[$-y]=it;for(const gt of e.children[$].children){
|
|
295
|
+
const mt=m.byId.get(gt.id),xt=B.get(gt.id)?.pad.top??f,Ct=it.y+xt>O+.01?{idx:it.idx+1,y:W+xt}:{idx:it.idx,y:it.y+xt};rt.set(gt.id,Ct);const Tt=await N(U,gt,mt,Ct,V,O),yt=Math.min(b-1,$+(mt?.rowSpan??1)-
|
|
296
|
+
1),bt=lt[yt-y];lt[yt-y]=bt?C(bt,Tt):Tt}const ut=Z(it,p[$]),ht=lt[$-y];ct=ht?C(ut,ht):ut,tt[$-y]=ct}let at=ct.idx;for(const $ of rt.values())at=Math.max(at,$.idx);at=Math.max(at,Y.length-1);const ot=[{
|
|
297
|
+
page:this.getPdfCurrentPage(t),top:o.marginTopPt,left:I}],ft=t.addPage,pt=()=>{const $=this.advancePdfFlowRegion(t,o);return I=$.x+_,{page:this.getPdfCurrentPage(t),top:$.y+K,left:I}};for(let $=1;$<=at;$++){
|
|
298
|
+
const it=pt();ot.push(it),K>0&&await q(e.children[0],0,it.top-K,!0)}const Ot=$=>{for(;ot.length<=$;){const it=t.addPage;t.addPage=ft;try{ot.push(pt())}finally{t.addPage=it}}return ot[$]};for(let $=y;$<
|
|
299
|
+
b;$++){const it=!!e.hasHeader&&$===0;for(const ut of e.children[$].children){const ht=m.byId.get(ut.id),gt=Math.min(b-1,$+(ht?.rowSpan??1)-1),mt=nt[$-y],xt=tt[gt-y],Ct=ht?M(ht):F/x;for(let Tt=mt.idx;Tt<=
|
|
300
|
+
xt.idx;Tt++){const yt=ot[Tt],bt=Tt===mt.idx?mt.y:yt.top,Wt=Tt===xt.idx?xt.y:O;Wt-bt<=.01||(t.setPage(yt.page),D(ut,ht,yt.left+(ht?v[ht.col]:0),Ct,bt,Wt-bt,it))}}}for(let $=y;$<b;$++)for(const it of e.
|
|
301
|
+
children[$].children)await N(t,it,m.byId.get(it.id),rt.get(it.id),Ot,O);const kt=tt[tt.length-1],At=ot[Math.min(kt.idx,ot.length-1)];return t.setPage(At.page),I=At.left,kt.y},H=e.hasHeader===!0&&e.children.
|
|
302
|
+
length>1&&!m.cells.some(y=>y.row===0&&y.rowSpan>1),j=e.children.map(()=>[]);for(const y of m.cells)j[y.row]?.push(y);for(let y=0;y<e.children.length;){let b=y+1,X=0;for(let L=y;L<b;L++){X+=p[L];for(const A of j[L])
|
|
303
|
+
b=Math.min(e.children.length,Math.max(b,A.row+A.rowSpan))}const O=H&&y>0?p[0]:0,K=h-o.marginTopPt-O,W=X>K;if((W?s>=h-.01:s+X>h)&&s!==o.marginTopPt){const L=this.advancePdfFlowRegion(t,o);s=L.y,I=L.x+_,
|
|
304
|
+
H&&y>0&&(await q(e.children[0],0,s,!0),s+=p[0])}if(W)s=await G(y,b,s);else for(let L=y;L<b;L++)await q(e.children[L],L,s,!1),s+=p[L];y=b}return k(),s}static async renderCodeBlock(t,e,a,i,r,n=this.MARGIN_LEFT,l=Xt,o=!1,h=this.
|
|
305
|
+
getDefaultPdfLayoutMetrics(),s){const g=n-h.marginLeftPt;let P=n;const c=e.language||"",d=ia(c);if(d&&e.renderDiagram!==!1&&d)return this.renderDiagramCodeBlock(t,e,a,i,r,P,d,l,o,h);const f=o?"SourceC\
|
|
306
|
+
odePro":"courier",T=e.content||"",m=c?await na(T,c,l):null,x=dt.fontSizePx*this.PX_TO_PT,F=x*dt.lineHeightMultiplier,_=dt.paddingPx*this.PX_TO_PT,I=dt.borderRadiusPx*this.PX_TO_PT,R=this.hexToRgb(l.background),
|
|
307
|
+
v=this.hexToRgb(l.default);t.setFont(f,"normal"),t.setFontSize(x);const M=Math.max(1,i-_*2),B=Qt(T,C=>t.getTextWidth(C),M),p=[];let u=0;for(const C of m??[])p.push({start:u,end:u+C.text.length,color:C.
|
|
308
|
+
color}),u+=C.text.length;const S=C=>{if(p.length===0)return[{text:C.text,color:l.default}];const N=[];for(const G of p){const H=Math.max(C.startCharOffset,G.start),j=Math.min(C.endCharOffset,G.end);j<=
|
|
309
|
+
H||N.push({text:T.slice(H,j),color:G.color})}return N.length>0?N:[{text:C.text,color:l.default}]};let w=a,k=0,D=r;const q=()=>{const C=this.advancePdfFlowRegion(t,h);w=C.y,P=C.x+g,D=this.getPdfFlowBottom(
|
|
310
|
+
t,h)};for(;k<B.length;){const C=k===0,N=C?_:0,G=N+F+(B.length===k+1?_:0);w+G>D&&w!==h.marginTopPt&&q();let H=k,j=N;for(;H<B.length;){const b=H===B.length-1,X=j+F+(b?_:0);if(w+X>D&&H>k)break;j+=F,H+=1}
|
|
311
|
+
const y=H===B.length;y&&(j+=_),t.setFillColor(R.r,R.g,R.b),C&&y?this.drawRoundedRect(t,P,w,i,j,I):t.rect(P,w,i,j,"F"),t.setFont(f,"normal"),t.setFontSize(x);for(let b=k;b<H;b++){const X=b===0,O=b===B.
|
|
312
|
+
length-1,K=w+N+(b-k)*F;s?.push({pageNumber:t.getCurrentPageInfo?.().pageNumber??t.getNumberOfPages(),y:K-(X?_:0),height:F+(X?_:0)+(O?_:0)});let W=P+_;const L=w+N+(b-k)*F+x;for(const A of S(B[b])){const U=A.
|
|
313
|
+
color?this.hexToRgb(A.color):v;t.setTextColor(U.r,U.g,U.b),A.text&&t.text(A.text,W,L),W+=t.getTextWidth(A.text)}}w+=j,k=H,y||q()}return w}static async renderDiagramCodeBlock(t,e,a,i,r,n,l,o,h,s){const g=n-
|
|
314
|
+
s.marginLeftPt;let P=n;const c=dt.paddingPx*this.PX_TO_PT,d=dt.diagramSourceGapPx*this.PX_TO_PT,f=ne(),T=Math.max(120,Math.round((i-c*2)/this.PX_TO_PT)),m=await oa({protocol:l,source:e.content||"",theme:f,
|
|
315
|
+
maxWidth:T}),x=Math.max(1,m.width*this.PX_TO_PT),F=Math.max(dt.diagramMinHeightPx,m.height)*this.PX_TO_PT,_=F+c*2,I=e.showDiagramSource!==!1,R=h?"SourceCodePro":"courier",v=dt.fontSizePx*this.PX_TO_PT;
|
|
316
|
+
t.setFont(R,"normal"),t.setFontSize(v);const M=Qt(e.content||"",N=>t.getTextWidth(N),Math.max(1,i-c*2)),B=c*2+M.length*v*dt.lineHeightMultiplier,p=(I?B+d:0)+_;let u=a;if(u+p>r&&u!==s.marginTopPt){const N=this.
|
|
317
|
+
advancePdfFlowRegion(t,s);u=N.y,P=N.x+g}I&&(u=await this.renderCodeBlock(t,{...e,renderDiagram:!1},u,i,r,P,o,h,s),u+=d);const S=this.hexToRgb(f.codeBorder||"#e0e0e0"),w=dt.borderRadiusPx*this.PX_TO_PT;
|
|
318
|
+
t.setDrawColor(S.r,S.g,S.b),t.setLineWidth(this.BLOCK_BORDER_WIDTH_PT),this.drawRoundedRect(t,P,u,i,_,w,"S");const k=Math.min(i-c*2,x),D=Math.min(_-c*2,F),q=P+(i-k)/2,C=u+(_-D)/2;if(m.svg){const N=await this.
|
|
319
|
+
svgToPng(m.svg,Math.max(1,Math.round(m.width)),Math.max(1,Math.round(m.height)),2);if(N)return t.addImage(N,"PNG",q,C,k,D),u+_}return t.setTextColor(220,38,38),t.setFont("helvetica","normal"),t.setFontSize(
|
|
320
|
+
10),t.text("Diagram unavailable",P+c,u+c+10),u+_}static renderCellParagraph(t,e,a,i,r,n,l=!1){const o=this.getParagraphFontSize(e),h=this.getParagraphDirection(e),s=this.getEffectiveParagraphAlignment(
|
|
321
|
+
e,h),g=this.getLineSpacingMultiplier(e),P=this.processTextNodes(e.children);let c=i,d=[],f=0;const T=m=>{d.length!==0&&(l?c+=this.measureLineAdvancePt(d,o,!!e.heading,g):c=this.renderLine(t,d,c,a,r,s,
|
|
322
|
+
o,n,!!e.heading,g,m,{direction:h}),d=[],f=0)};for(const m of P){this.setRunFont(t,m,n),t.setFontSize(this.getRunEffectiveFontSizePt(m.marks,o));const x=m.text.split(`
|
|
323
|
+
`);for(let F=0;F<x.length;F++){F>0&&T(!1);const _=x[F].split(/(\s+)/);for(const I of _){const R=this.measureRunDisplayWidthPt(t,I,m.marks);f+R>r&&d.length>0&&T(!1),(I.trim()||d.length>0)&&(d.push({text:I,
|
|
324
|
+
marks:m.marks,font:m.marks?.fontFamily}),f+=R)}}}return T(!0),c===i&&(c+=this.getEmptyParagraphLineHeight(e)),c}static extractCellBlocks(t){return t.children}static drawRoundedRect(t,e,a,i,r,n,l="F"){
|
|
325
|
+
const o=Math.min(n,i/2,r/2);t.roundedRect(e,a,i,r,o,o,l)}static getListIndentPt(t){switch(t){case"todo":return this.TODO_LIST_INDENT_PT;case"ordered":return this.ORDERED_LIST_INDENT_PT;case"unordered":default:
|
|
326
|
+
return this.UNORDERED_LIST_INDENT_PT}}static getListIndentLevel(t){const e=t.indentLevel??0;if(!Number.isFinite(e))return 0;const a=Math.floor(e);return Math.max(0,Math.min(a,this.MAX_LIST_INDENT_LEVEL))}static computeOrderedMarkerLabel(t,e,a,i){
|
|
327
|
+
return we(t,a,e,i)}static getRunLetterSpacingPt(t){return(typeof t?.letterSpacing=="number"&&Number.isFinite(t.letterSpacing)?t.letterSpacing:0)*this.PX_TO_PT}static getRunEffectiveFontSizePt(t,e){const a=t?.
|
|
328
|
+
fontSize?t.fontSize*this.PX_TO_PT:e;return t?.superscript||t?.subscript?Math.round(a/this.PX_TO_PT*.7)*this.PX_TO_PT:a}static setRunFont(t,e,a){if(e.marks?.code){t.setFont(this.inlineCodeFontFamily,"n\
|
|
329
|
+
ormal");return}const i=this.mapFontFamily(e.font||e.marks?.fontFamily||a),r=this.resolveFontStyle(e.marks),n=this.scriptFallbackFor(t,e.text,i);if(n){t.setFont(n,r==="bold"||r==="bolditalic"?"bold":"n\
|
|
330
|
+
ormal");return}t.setFont(i,r)}static measureRunDisplayWidthPt(t,e,a){const i=n=>{const l=t.getFont?.()?.fontName,o=l?this.shapingFonts.get(l):void 0;return o?o.layout(n).advanceWidth*t.getFontSize()/o.
|
|
331
|
+
unitsPerEm:t.getTextWidth(n)},r=De(a);return r?$t(e,{...r,letterSpacingPx:this.getRunLetterSpacingPt(a)},i):i(e)}static drawShapedText(t,e,a,i,r,n,l){const o=t.getFont?.()?.fontName,h=o?this.shapingFonts.
|
|
332
|
+
get(o):void 0;if(!h)return null;const s=h.layout(e);Array.from(e).every(f=>(f.codePointAt(0)??0)<=65535)&&t.text(e,a,i,{renderingMode:"invisible"}),t.setFillColor(l.r,l.g,l.b);const g=r/h.unitsPerEm;let P=0,
|
|
333
|
+
c=0,d=0;for(let f=0;f<s.glyphs.length;f++){const T=s.glyphs[f],m=s.positions[f],x=[];let F=0,_=0;const I=v=>a+d+(P+m.xOffset+v)*g,R=v=>i-(c+m.yOffset+v)*g;for(const v of T.path.commands)if(v.command===
|
|
334
|
+
"moveTo")[F,_]=v.args,x.push({op:"m",c:[I(F),R(_)]});else if(v.command==="lineTo")[F,_]=v.args,x.push({op:"l",c:[I(F),R(_)]});else if(v.command==="bezierCurveTo"){const[M,B,p,u,S,w]=v.args;x.push({op:"\
|
|
335
|
+
c",c:[I(M),R(B),I(p),R(u),I(S),R(w)]}),F=S,_=w}else if(v.command==="quadraticCurveTo"){const[M,B,p,u]=v.args,S=F+(M-F)*2/3,w=_+(B-_)*2/3,k=p+(M-p)*2/3,D=u+(B-u)*2/3;x.push({op:"c",c:[I(S),R(w),I(k),R(
|
|
336
|
+
D),I(p),R(u)]}),F=p,_=u}else v.command==="closePath"&&x.push({op:"h",c:[]});x.length>0&&(t.path(x),t.fill()),P+=m.xAdvance,c+=m.yAdvance,d+=n*Math.max(1,T.codePoints?.length??1)}return s.advanceWidth*
|
|
337
|
+
r/h.unitsPerEm+n*[...e].length}static renderLine(t,e,a,i,r,n,l,o,h,s,g=!0,P){e=e.filter(p=>!p.marks?.hidden||!!p.marks.footnoteRef);let c=P?.tabLayoutPx;const d=p=>p.marks?.fontSize?p.marks.fontSize*this.
|
|
338
|
+
PX_TO_PT:l,f=P?.direction??"ltr";if(!c&&e.length>0&&!e.some(p=>p.latexImage||p.marks?.latex)){const p=e,u={segments:p.map(w=>({text:w.text}))},S=Jt(u,f);if(S){const w=(D,q)=>{let C=0,N=0;for(const G of p){
|
|
339
|
+
const H=Math.max(D,N),j=Math.min(q,N+G.text.length);if(H<j){const y=G.text.slice(H-N,j-N);this.setRunFont(t,{...G,text:y},o),t.setFontSize(this.getRunEffectiveFontSizePt(G.marks,l)),C+=this.measureRunDisplayWidthPt(
|
|
340
|
+
t,y,G.marks)}N+=G.text.length}return C},k=p.map(D=>D.text).join("");e=Zt(u,S,w,n==="justify"&&!g).map(D=>({...p[D.segmentIndex],text:k.slice(D.start,D.end),rtl:D.rtl}))}}if(P?.tabRtl&&c&&c.length>0){const p=e,
|
|
341
|
+
u=c,S=[],w=[];let k=0;for(;k<p.length;){const D=p[k];if(D.text===" "){S.push(D),w.push(u[k]??{startX:0,endX:0}),k++;continue}const q=k;let C=Number.NEGATIVE_INFINITY;for(;k<p.length&&p[k].text!==" ";){
|
|
342
|
+
const O=u[k];O&&(C=Math.max(C,O.endX)),k++}const N=p.slice(q,k),G=N.map(O=>O.text).join("");if(!G)continue;Number.isFinite(C)||(C=0);const H={segments:N.map(O=>({text:O.text}))},j=Jt(H,"rtl");if(!j){for(let O=q;O<
|
|
343
|
+
k;O++)S.push(p[O]),w.push(u[O]??{startX:0,endX:0});continue}const y=Zt(H,j,(O,K)=>{let W=0,L=0;for(const A of N){const U=Math.max(O,L),z=Math.min(K,L+A.text.length);if(U<z){const Y=A.text.slice(U-L,z-
|
|
344
|
+
L);this.setRunFont(t,{...A,text:Y},o),t.setFontSize(this.getRunEffectiveFontSizePt(A.marks,l)),W+=this.measureRunDisplayWidthPt(t,Y,A.marks)}L+=A.text.length}return W}),b=y.reduce((O,K)=>O+K.width,0),
|
|
345
|
+
X=C*this.PX_TO_PT-b;for(const O of y)S.push({...N[O.segmentIndex],text:G.slice(O.start,O.end),rtl:O.rtl}),w.push({startX:(X+O.x)/this.PX_TO_PT,endX:(X+O.x+O.width)/this.PX_TO_PT})}e=S,c=w}let T=0,m=0;
|
|
346
|
+
for(const p of e)if(p.latexImage){const u=p.latexImage.contentHeight*this.PX_TO_PT;u>m&&(m=u)}else{const u=d(p);u>T&&(T=u)}T===0&&(T=l);const x=a+T;let F=0;if(c&&c.length>0)F=P?.tabRtl?(P.tabWidthPx??
|
|
347
|
+
Math.max(...c.map(p=>p.endX)))*this.PX_TO_PT:c[c.length-1].endX*this.PX_TO_PT;else for(const p of e)p.latexImage?F+=p.latexImage.contentWidth*this.PX_TO_PT:(this.setRunFont(t,p,o),t.setFontSize(this.getRunEffectiveFontSizePt(
|
|
348
|
+
p.marks,l)),F+=this.measureRunDisplayWidthPt(t,p.text,p.marks));let _=i;n==="center"?_=i+(r-F)/2:(n==="right"||n==="justify"&&f==="rtl"&&(g||c))&&(_=i+r-F),P?.tabRtl&&c&&(_=i);let I=0;if(n==="justify"&&
|
|
349
|
+
!g&&!c){let p=0;for(const u of e)u.latexImage||u.marks?.latex||(p+=(u.text.match(/ /g)||[]).length);p>0&&(I=Math.max(0,(r-F)/p))}const R=_;for(let p=0;p<e.length;p++){const u=e[p],S=c?.[p];if(S&&(_=R+
|
|
350
|
+
S.startX*this.PX_TO_PT,u.text===" ")){if(S.leader){const W=this.getRunEffectiveFontSizePt(u.marks,l),L=u.marks?.color?this.hexToRgb(u.marks.color):{r:0,g:0,b:0};this.renderTabLeaderPdf(t,R+S.startX*this.
|
|
351
|
+
PX_TO_PT,R+S.endX*this.PX_TO_PT,x,S.leader,W,L)}_=R+S.endX*this.PX_TO_PT;continue}if(u.latexImage){const W=u.latexImage.width*this.PX_TO_PT,L=u.latexImage.height*this.PX_TO_PT,A=u.latexImage.contentWidth*
|
|
352
|
+
this.PX_TO_PT,U=u.latexImage.contentHeight*this.PX_TO_PT,z=(W-A)/2,Y=_-z,V=x-U*.7-z;try{t.addImage(u.latexImage.dataUrl,"PNG",Y,V,W,L)}catch(Z){console.error("Failed to add inline latex image to PDF:",
|
|
353
|
+
Z)}_+=A;continue}this.setRunFont(t,u,o);const w=d(u),k=this.getRunEffectiveFontSizePt(u.marks,l),D=k/this.PX_TO_PT;t.setFontSize(k);const q=!!u.marks?.link;let C={r:0,g:0,b:0};q?C={r:37,g:99,b:235}:u.
|
|
354
|
+
marks?.color?C=this.hexToRgb(u.marks.color):u.marks?.code&&(C=this.hexToRgb(Lt.codeText)),t.setTextColor(C.r,C.g,C.b);const N=!!(u.marks?.smallCaps&&!u.marks?.allCaps),G=this.getRunLetterSpacingPt(u.marks),
|
|
355
|
+
H=u.rtl?{isInputVisual:!1,isOutputVisual:!0,isInputRtl:!0,isOutputRtl:!1}:void 0,j=G!==0||H?{...G!==0?{charSpace:G}:{},...H}:void 0,y=this.measureRunDisplayWidthPt(t,u.text,u.marks),b=I>0?(u.text.match(
|
|
356
|
+
/ /g)||[]).length:0,X=y+b*I;if(u.marks?.backgroundColor){const W=ra(u.marks.backgroundColor)??u.marks.backgroundColor,L=this.hexToRgb(W);t.setFillColor(L.r,L.g,L.b),t.rect(_,x-w*.8,X,w*1.1,"F"),t.setTextColor(
|
|
357
|
+
C.r,C.g,C.b)}else if(u.marks?.code){const W=this.hexToRgb(Lt.codeBackground);t.setFillColor(W.r,W.g,W.b),this.drawRoundedRect(t,_-2*this.PX_TO_PT,x-w*.93,X+4*this.PX_TO_PT,w+4*this.PX_TO_PT,3*this.PX_TO_PT),
|
|
358
|
+
t.setTextColor(C.r,C.g,C.b)}let O=x;u.marks?.superscript?O=x-w*.4:u.marks?.subscript&&(O=x+w*.15),(u.marks?.underline||q)&&!u.marks?.code&&(q?t.setDrawColor(37,99,235):t.setDrawColor(0,0,0),t.setLineWidth(
|
|
359
|
+
.5),t.line(_,O+2,_+X,O+2));const K=(W,L)=>{const A=u.marks?.allCaps?Dt(W,u.marks.lang):W,U=this.drawShapedText(t,A,L,O,k,G,C);if(U!==null)return U;if(N){let z=L;for(const Y of Xe(W,u.marks?.lang)){const V=Y.
|
|
360
|
+
lower?t.getTextWidth(Dt(Y.text,u.marks?.lang))*te:t.getTextWidth(Y.text);Y.lower?(t.setFontSize(k*te),t.text(Dt(Y.text,u.marks?.lang),z,O,j),t.setFontSize(k)):t.text(Y.text,z,O,j),z+=V+G*Y.text.length}
|
|
361
|
+
return z-L}return t.text(A,L,O,j),this.measureRunDisplayWidthPt(t,W,u.marks)};if(I>0){let W=_;for(const L of u.text.split(/( +)/))L&&(W+=K(L,W),L[0]===" "&&(W+=I*L.length))}else K(u.text,_);if(u.marks?.
|
|
362
|
+
strikethrough||u.marks?.doubleStrikethrough){t.setDrawColor(C.r,C.g,C.b),t.setLineWidth(Math.max(1,Math.round(D*.04))*this.PX_TO_PT);const W=L=>{const A=L-k*.3;t.line(_,A,_+X,A)};u.marks?.doubleStrikethrough?
|
|
363
|
+
(W(O+k*.09),W(O-k*.09)):W(O)}if(q&&u.marks?.link){const W=x-w*.8,L=w*1.1;t.link(_,W,X,L,{url:u.marks.link})}_+=X}if(P?.hyphenTrailing){const p=e[e.length-1];if(p&&!p.marks?.latex){this.setRunFont(t,p,
|
|
364
|
+
o),t.setFontSize(this.getRunEffectiveFontSizePt(p.marks,l));const u=p.marks?.color?this.hexToRgb(p.marks.color):{r:0,g:0,b:0};t.setTextColor(u.r,u.g,u.b),t.text("-",_,x)}}const v=s??(h?this.LINE_HEIGHT_MULTIPLIERS.
|
|
365
|
+
heading:this.LINE_HEIGHT_MULTIPLIERS.paragraph),M=T*v,B=m>M*1.25?m:M;return a+B}static renderTabLeaderPdf(t,e,a,i,r,n,l){const o=Math.max(1.5,n*.12),h=e+o,s=a-o;if(s-h<1)return;if(t.setFillColor(l.r,l.
|
|
366
|
+
g,l.b),r==="underscore"){const P=i+Math.max(1,n*.08),c=Math.max(.75,n*.055);t.rect(h,P,s-h,c,"F");return}const g=Math.max(2.25,n*.33);if(r==="dot"){const P=Math.max(.45,n*.045),c=i-P;for(let d=Math.ceil(
|
|
367
|
+
h/g)*g;d<=s;d+=g)t.circle(d,c,P,"F")}else{const P=Math.max(1.5,n*.18),c=i-n*.28,d=Math.max(.75,n*.055);for(let f=Math.ceil(h/g)*g;f+P<=s;f+=g)t.rect(f,c,P,d,"F")}}static processTextNodes(t){const e=[];
|
|
368
|
+
for(const a of t)if(a.type==="text"){const i=a;if(i.marks?.hidden&&!i.marks.footnoteRef)continue;e.push({text:i.text,marks:i.marks,font:i.marks?.fontFamily})}return e}static async processTextNodesWithLatex(t,e){
|
|
369
|
+
const a=[];for(let n=0;n<t.length;n++){const l=t[n];if(l.type==="text"){const o=l;if(o.marks?.hidden&&!o.marks.footnoteRef)continue;o.marks?.latex?a.push({index:n,node:o,latexPromise:this.renderLatexToImage(
|
|
370
|
+
o.text,!1,e)}):a.push({index:n,node:o})}}const i=await Promise.all(a.map(n=>n.latexPromise||Promise.resolve(null))),r=[];for(let n=0;n<a.length;n++){const{node:l}=a[n],o=i[n];r.push({text:l.text,marks:l.
|
|
371
|
+
marks,font:l.marks?.fontFamily,latexImage:o||void 0})}return r}static getParagraphFontSize(t){return sa(t)*this.PX_TO_PT}static getParagraphLineHeight(t){return this.getParagraphFontSize(t)*ie(t)}static getEmptyParagraphLineHeight(t){
|
|
372
|
+
return this.measureLineAdvancePt(this.paragraphForPdfOutput(t).children.map(e=>({marks:e.type==="text"?e.marks:void 0})),this.getParagraphFontSize(t),!!t.heading,this.getLineSpacingMultiplier(t))}static async embedLocalFonts(t,e){
|
|
373
|
+
if(this.embeddedFamilyNames.clear(),typeof window>"u")return;const a=new Set(["sans-serif","sans","serif","monospace","system-ui","system ui","ui-sans-serif","ui-serif","ui-monospace"]),i=Nt(e).map(n=>n.
|
|
374
|
+
family).filter(n=>{const l=n.toLowerCase();return!a.has(l)&&this.FONT_MAP[l]!=="KaTeX_Main"});if(i.length===0)return;let r;for(const n of i){const l=n.toLowerCase();let o=this.localFontFiles.get(l);if(o===
|
|
375
|
+
void 0){if(r===void 0&&(r=await Pe().catch(()=>null)),!r)return;try{o=await this.buildLocalFontFiles(n,r)}catch{o=null}this.localFontFiles.set(l,o)}if(o)try{for(const h of o)t.addFileToVFS(h.vfsName,h.
|
|
376
|
+
base64),t.addFont(h.vfsName,n,h.style);this.embeddedFamilyNames.set(l,n)}catch(h){console.warn(`Failed to embed font "${n}" in PDF:`,h),this.localFontFiles.set(l,null)}}}static async buildLocalFontFiles(t,e){
|
|
377
|
+
const a=t.toLowerCase(),i=e.filter(c=>c.family?.trim().toLowerCase()===a&&c.blob);if(i.length===0)return null;const r=i.map(c=>({entry:c,...pe(c.style),specificity:(c.style??"").length})),n=(c,d)=>r.filter(
|
|
378
|
+
f=>f.bold===c&&f.italic===d).sort((f,T)=>f.specificity-T.specificity)[0]?.entry,l=n(!1,!1)??r[0].entry,o=[{style:"normal",entry:l},{style:"bold",entry:n(!0,!1)??l},{style:"italic",entry:n(!1,!0)??l},{
|
|
379
|
+
style:"bolditalic",entry:n(!0,!0)??n(!0,!1)??l}],h=new Map;for(const{entry:c}of o){if(h.has(c))continue;const d=await(await c.blob()).arrayBuffer(),f=Ht(new Uint8Array(d));h.set(c,f==="ttf"?this.arrayBufferToBase64(
|
|
380
|
+
d):null)}if(!h.get(l))return null;const s=a.replace(/[^a-z0-9]+/g,"-"),g=new Map;let P=0;return o.map(({style:c,entry:d})=>{const f=h.get(d)?d:l;let T=g.get(f);return T||(T=`${s}-${P++}.ttf`,g.set(f,T)),
|
|
381
|
+
{vfsName:T,base64:h.get(f),style:c}})}static mapFontFamily(t){const e=this.mapFontFamilyToStandard(t);return this.bundledGenreFamilies.get(e)??(e==="SourceSerif4"?"times":e)}static mapFontFamilyToStandard(t){
|
|
382
|
+
if(!t)return"helvetica";const e=new Set(["helvetica","times","courier"]),a=t.split(",").map(r=>r.trim().replace(/^['"]|['"]$/g,"")).filter(r=>r.length>0);a.length===0&&a.push(t);for(const r of a){const n=r.
|
|
383
|
+
toLowerCase(),l=this.embeddedFamilyNames.get(n);if(l)return l;if(e.has(n))return n;const o=this.FONT_MAP[n];if(o)return o}const i=ue(a[0]);return i==="serif"?"times":i==="monospace"?"courier":"helveti\
|
|
384
|
+
ca"}static resolveFontStyle(t){const e=!!t?.bold,a=!!t?.italic;return e&&a?"bolditalic":e?"bold":a?"italic":"normal"}static drawPdfBorderEdge(t,e,a,i,r,n){if(e.style==="none"||e.width<=0)return;const l=this.
|
|
385
|
+
hexToRgb(e.color);t.setDrawColor(l.r,l.g,l.b);const o=ze(e).map(h=>h*this.PX_TO_PT);if(o.length>0&&typeof t.setLineDashPattern=="function"&&t.setLineDashPattern(o,0),e.style==="double"){const h=Math.max(
|
|
386
|
+
e.width/3,.5)*this.PX_TO_PT,s=e.width*2/3/2*this.PX_TO_PT;t.setLineWidth(h);const g=i===n,P=g?0:s,c=g?s:0;t.line(a-P,i-c,r-P,n-c),t.line(a+P,i+c,r+P,n+c)}else t.setLineWidth(e.width*this.PX_TO_PT),t.line(
|
|
387
|
+
a,i,r,n);o.length>0&&typeof t.setLineDashPattern=="function"&&t.setLineDashPattern([],0)}static hexToRgb(t){return Te(t)??{r:0,g:0,b:0}}static async renderImageBlock(t,e,a,i,r=this.getDefaultPdfLayoutMetrics()){
|
|
388
|
+
if(!e.src)return{nextY:a};const n=this.getPdfFlowBottom(t,r);let l=Math.max(e.width||1,1)*this.PX_TO_PT,o=Math.max(e.height||1,1)*this.PX_TO_PT;if(l>i){const c=i/l;l=i,o*=c}(o<=0||!Number.isFinite(o))&&
|
|
389
|
+
(o=72);let h=r.marginLeftPt;if(a+o>n&&a!==r.marginTopPt){const c=this.advancePdfFlowRegion(t,r);a=c.y,h=c.x}const s=e.align||"left";let g=h;if(s==="center"?g=h+(i-l)/2:s==="right"&&(g=h+i-l),e.originalFormat)
|
|
390
|
+
return t.setFillColor(243,244,246),t.setDrawColor(209,213,219),t.setLineWidth(.75),t.rect(g,a,l,o,"FD"),t.setFont(this.mapFontFamily(void 0),"normal"),t.setFontSize(14*this.PX_TO_PT),t.setTextColor(107,
|
|
391
|
+
114,128),t.text(`${e.originalFormat.toUpperCase()} image`,g+l/2,a+o/2,{align:"center",baseline:"middle"}),{nextY:a+o};const P=await this.resolveImageData(e.src);if(!P)return{nextY:a+o};try{t.addImage(
|
|
392
|
+
P.data,P.format,g,a,l,o)}catch(c){return console.error("Failed to add image to PDF",c),{nextY:a+o}}return{nextY:a+o}}static async resolveImageData(t){const e=t.match(/^data:image\/([a-zA-Z0-9+.-]+);base64,/);
|
|
393
|
+
if(e){const n=this.normalizeImageFormat(e[1]);return{data:t,format:n}}const a=await this.fetchImageAsBlob(t);if(!a)return null;const{blob:i,format:r}=a;return{data:await this.blobToDataUrl(i,r),format:r}}static async fetchImageAsBlob(t){
|
|
394
|
+
try{const e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch image: ${e.status}`);const a=await e.blob(),i=this.extractImageFormat(a.type);return{blob:a,format:i}}catch(e){return console.error(
|
|
395
|
+
"Failed to load image for PDF export",e),null}}static async blobToDataUrl(t,e){const a=await t.arrayBuffer(),i=this.arrayBufferToBase64(a);return`data:${this.formatToMime(e)};base64,${i}`}static arrayBufferToBase64(t){
|
|
396
|
+
const e=globalThis?.Buffer;if(e)return e.from(t).toString("base64");let a="";const i=new Uint8Array(t),r=32768;for(let n=0;n<i.length;n+=r){const l=i.subarray(n,n+r);a+=String.fromCharCode.apply(null,
|
|
397
|
+
Array.from(l))}return btoa(a)}static formatToMime(t){const e=t.toLowerCase();return e==="jpeg"||e==="jpg"?"image/jpeg":e==="png"?"image/png":e==="webp"?"image/webp":`image/${e}`}static extractImageFormat(t){
|
|
398
|
+
if(!t)return"PNG";const e=t.match(/^image\/([a-zA-Z0-9+.-]+)/);return e?this.normalizeImageFormat(e[1]):"PNG"}static normalizeImageFormat(t){const e=t.toLowerCase();return e==="jpg"||e==="jpeg"?"JPEG":
|
|
399
|
+
e==="png"?"PNG":e==="webp"?"WEBP":e.toUpperCase()}static async renderMathBlock(t,e,a,i,r,n=this.getDefaultPdfLayoutMetrics()){if(!e.content||e.content.trim()==="")return{nextY:a};const l=e.displayMode!==
|
|
400
|
+
"inline",o=await this.renderLatexToImage(e.content,l);if(!o)return{nextY:a+20};let h=o.width*this.PX_TO_PT,s=o.height*this.PX_TO_PT;const g=i-this.MATH_BLOCK_PADDING*2;if(h>g){const x=g/h;h=g,s*=x}const P=Math.
|
|
401
|
+
max(this.MATH_BLOCK_MIN_HEIGHT,s)+this.MATH_BLOCK_PADDING*2;let c=n.marginLeftPt;if(a+P>r&&a!==n.marginTopPt){const x=this.advancePdfFlowRegion(t,n);a=x.y,c=x.x}const d=this.hexToRgb(ne().codeBorder||
|
|
402
|
+
"#e0e0e0");t.setDrawColor(d.r,d.g,d.b),t.setLineWidth(this.BLOCK_BORDER_WIDTH_PT),typeof t.roundedRect=="function"?t.roundedRect(c,a,i,P,this.MATH_BLOCK_BORDER_RADIUS,this.MATH_BLOCK_BORDER_RADIUS,"S"):
|
|
403
|
+
t.rect(c,a,i,P,"S");const f=e.align||"center";let T=c+this.MATH_BLOCK_PADDING;f==="center"?T=c+(i-h)/2:f==="right"&&(T=c+i-h-this.MATH_BLOCK_PADDING);const m=a+(P-s)/2;try{t.addImage(o.dataUrl,"PNG",T,
|
|
404
|
+
m,h,s)}catch(x){console.error("Failed to add math image to PDF:",x)}return{nextY:a+P}}static async getHtml2Canvas(){return this.html2canvasModule?this.html2canvasModule:this.html2canvasLoading?this.html2canvasLoading:
|
|
405
|
+
(this.html2canvasLoading=import("./html2canvas.esm-CntiHiYW.js").then(t=>(this.html2canvasModule=t.default,t.default)),this.html2canvasLoading)}static async renderLatexToImage(t,e,a=12){const i=this.getLatexSvgFromCache(
|
|
406
|
+
t,e);if(i){const r=await this.svgToPng(i.svg,i.width,i.height,3);if(r){const n=e?1:this.INLINE_MATH_SCALE;return{dataUrl:r,width:i.width*n,height:i.height*n,contentWidth:i.contentWidth*n,contentHeight:i.
|
|
407
|
+
contentHeight*n}}}try{const r=await this.getHtml2Canvas(),n=this.preprocessLaTeX(t),l=(await ga()).renderToString(n,{displayMode:e,throwOnError:!1,errorColor:"#ef4444",trust:!1,strict:!1});this.ensureKaTeXStyles();
|
|
408
|
+
const o=a/this.PX_TO_PT,h=e?20:o*this.INLINE_MATH_SCALE,s=4,g=document.createElement("div");g.style.cssText=`
|
|
409
|
+
position: fixed;
|
|
410
|
+
top: -9999px;
|
|
411
|
+
left: -9999px;
|
|
412
|
+
font-size: ${h}px;
|
|
413
|
+
line-height: 1.2;
|
|
414
|
+
background: transparent;
|
|
415
|
+
padding: ${s}px;
|
|
416
|
+
z-index: -9999;
|
|
417
|
+
`,g.innerHTML=l,document.body.appendChild(g),document.fonts?.ready&&await document.fonts.ready;const P=4,c=await r(g,{backgroundColor:null,scale:P,logging:!1,useCORS:!0,allowTaint:!1});document.
|
|
418
|
+
body.removeChild(g);const d=c.toDataURL("image/png"),f=c.width/P,T=c.height/P,m=f-s*2,x=T-s*2;return{dataUrl:d,width:f,height:T,contentWidth:m,contentHeight:x}}catch(r){return console.error("Failed to\
|
|
419
|
+
render LaTeX for PDF:",r),null}}static preprocessLaTeX(t){if(!t.includes(`
|
|
420
|
+
`)||["align","aligned","gather","gathered","split","cases","matrix","pmatrix","bmatrix","array"].some(a=>t.includes(`\\begin{${a}}`)||t.includes(`\\begin{${a}*}`)))return t;const e=t.split(`
|
|
421
|
+
`).map(a=>a.trim()).filter(a=>a.length>0);return e.length<=1?t:`\\begin{gathered}
|
|
422
|
+
${e.join(` \\\\
|
|
423
|
+
`)}
|
|
424
|
+
\\end{gathered}`}static ensureKaTeXStyles(){if(this.katexStylesLoaded)return;if(document.querySelector('link[href*="katex"]')){this.katexStylesLoaded=!0;return}const t=document.createElement("link");t.
|
|
425
|
+
rel="stylesheet",t.href=wt("katex.min.css"),document.head.appendChild(t),this.katexStylesLoaded=!0}static async parseFile(t){const e=await import("./pdf-BLWDCiFF.js");e.GlobalWorkerOptions.workerSrc=wt(
|
|
426
|
+
"pdfjs/worker.js");const a=await t.arrayBuffer();try{const i=await e.getDocument(a).promise;let r="";for(let h=1;h<=i.numPages;h++){const s=(await(await i.getPage(h)).getTextContent()).items.map(g=>g.
|
|
427
|
+
str).join(" ");r+=s+`
|
|
428
|
+
|
|
429
|
+
`}const n=r.trim().split(`
|
|
430
|
+
`),l=[];let o=[];for(let h=0;h<n.length;h++){const s=n[h].trim();if(s===""){if(o.length>0){const g=o.join(" ").trim();g&&l.push(Ft([{type:"text",text:g}])),o=[]}}else{const g=s.length<60,P=s===s.toUpperCase()&&
|
|
431
|
+
/[A-Z]/.test(s),c=/[.!?]$/.test(s),d=h+1<n.length&&n[h+1].trim()==="";if(g&&(P||d&&!c)){if(o.length>0){const f=o.join(" ").trim();f&&l.push(Ft([{type:"text",text:f}])),o=[]}l.push(Ft([{type:"text",text:s}]))}else
|
|
432
|
+
o.push(s)}}if(o.length>0){const h=o.join(" ").trim();h&&l.push(Ft([{type:"text",text:h}]))}return l.length===0&&l.push(Ft()),{type:"doc",children:l}}catch(i){throw console.error("Failed to parse PDF:",
|
|
433
|
+
i),new Error(`Failed to parse PDF: ${i instanceof Error?i.message:"Unknown error"}`)}}};E.PAGE_WIDTH=612,E.PAGE_HEIGHT=792,E.MARGIN_LEFT=72,E.MARGIN_RIGHT=72,E.MARGIN_TOP=72,E.MARGIN_BOTTOM=72,E.PX_TO_PT=
|
|
434
|
+
re,E.UNBOUNDED_CELL_FLOW_BOTTOM_PT=1e4,E.DEFAULT_BODY_FONT="Arial, sans-serif",E.LINE_HEIGHT_MULTIPLIERS=ta,E.FONT_SIZES={h1:_t.h1*E.PX_TO_PT,h2:_t.h2*E.PX_TO_PT,h3:_t.h3*E.PX_TO_PT,h4:_t.h4*E.PX_TO_PT,
|
|
435
|
+
h5:_t.h5*E.PX_TO_PT,h6:_t.h6*E.PX_TO_PT,normal:_t.paragraph*E.PX_TO_PT},E.FONT_MAP={arial:"helvetica",helvetica:"helvetica","helvetica neue":"helvetica","times new roman":"times",georgia:"times","sour\
|
|
436
|
+
ce serif 4":"SourceSerif4",times:"times",courier:"courier","courier new":"courier",monospace:"courier",verdana:"helvetica",tahoma:"helvetica",inter:"helvetica","system-ui":"helvetica","system ui":"hel\
|
|
437
|
+
vetica","ui-sans-serif":"helvetica","ui-serif":"times","ui-monospace":"courier","sans-serif":"helvetica",sans:"helvetica",serif:"times",katex_main:"KaTeX_Main",computermodern:"KaTeX_Main","computer mo\
|
|
438
|
+
dern":"KaTeX_Main"},E.TODO_LIST_INDENT_PT=Pt.variantIndentPx.todo*E.PX_TO_PT,E.ORDERED_LIST_INDENT_PT=Pt.variantIndentPx.ordered*E.PX_TO_PT,E.UNORDERED_LIST_INDENT_PT=Pt.variantIndentPx.unordered*E.PX_TO_PT,
|
|
439
|
+
E.SUBLIST_INDENT_PT=Pt.sublistIndentPx*E.PX_TO_PT,E.BULLET_MARKER_WIDTH_PT=Pt.markerWidthPx*E.PX_TO_PT,E.BULLET_CENTER_OFFSET_PT=8*E.PX_TO_PT,E.BULLET_RADIUS_PT=2.5*E.PX_TO_PT,E.BULLET_SQUARE_INSET_PT=
|
|
440
|
+
5*E.PX_TO_PT,E.BULLET_SQUARE_HALF_PT=5*E.PX_TO_PT,E.BULLET_SQUARE_VERTICAL_ADJUST_PT=1*E.PX_TO_PT,E.ORDERED_LABEL_GAP_PT=6*E.PX_TO_PT,E.TODO_CHECKBOX_SIZE_PT=Pt.todoCheckboxSizePx*E.PX_TO_PT,E.TODO_CHECKBOX_RADIUS_PT=
|
|
441
|
+
Pt.todoCheckboxRadiusPx*E.PX_TO_PT,E.TODO_CHECKBOX_OFFSET_PT=Pt.todoCheckboxOffsetPx*E.PX_TO_PT,E.MAX_LIST_INDENT_LEVEL=Pt.maxIndentLevel,E.MATH_BLOCK_PADDING=16*E.PX_TO_PT,E.MATH_BLOCK_MIN_HEIGHT=40*
|
|
442
|
+
E.PX_TO_PT,E.MATH_BLOCK_BORDER_RADIUS=4*E.PX_TO_PT,E.BLOCK_BORDER_WIDTH_PT=1*E.PX_TO_PT,E.INLINE_MATH_SCALE=.85,E.BUNDLED_GENRE_FONTS={SourceSerif4:{family:"SourceSerif4",files:{normal:"SourceSerif4-R\
|
|
443
|
+
egular.ttf",bold:"SourceSerif4-Bold.ttf",italic:"SourceSerif4-It.ttf",bolditalic:"SourceSerif4-BoldIt.ttf"}},helvetica:{family:"LiberationSans",files:{normal:"LiberationSans-Regular.ttf",bold:"Liberat\
|
|
444
|
+
ionSans-Bold.ttf",italic:"LiberationSans-Italic.ttf",bolditalic:"LiberationSans-BoldItalic.ttf"}},times:{family:"LiberationSerif",files:{normal:"LiberationSerif-Regular.ttf",bold:"LiberationSerif-Bold\
|
|
445
|
+
.ttf",italic:"LiberationSerif-Italic.ttf",bolditalic:"LiberationSerif-BoldItalic.ttf"}},courier:{family:"LiberationMono",files:{normal:"LiberationMono-Regular.ttf",bold:"LiberationMono-Bold.ttf",italic:"\
|
|
446
|
+
LiberationMono-Italic.ttf",bolditalic:"LiberationMono-BoldItalic.ttf"}}},E.bundledGenreFamilies=new Map,E.SCRIPT_FALLBACK_FONTS=Ta,E.scriptFallbackFamilies=new Map,E.scriptFontCoverageCache=new Map,E.
|
|
447
|
+
fallbackCharsetCache=new Map,E.shapingFonts=new Map,E.inlineCodeFontFamily="courier",E.fontFileData=new Map,E.localFontFiles=new Map,E.embeddedFamilyNames=new Map,E.COLUMN_BALANCE_SLACK_PT=1.5,E.html2canvasModule=
|
|
448
|
+
null,E.html2canvasLoading=null,E.katexStylesLoaded=!1;let xa=E;export{xa as PdfConverter};
|