@reviseio/engine 0.0.0-stage → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
  3. package/FONT-LICENSE-KATEX.txt +95 -0
  4. package/FONT-LICENSE-LIBERATION.txt +102 -0
  5. package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
  6. package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
  7. package/FONT-LICENSE-NOTO.txt +94 -0
  8. package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
  9. package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
  10. package/LICENSE +141 -0
  11. package/README.md +11 -2
  12. package/THIRD-PARTY-NOTICES.md +3376 -0
  13. package/assets/historyMaterializeWorker-Kl0syEbc.js +618 -0
  14. package/chunks/AgentHtmlConverter-CnnB8-WI.js +379 -0
  15. package/chunks/AgentPageRenderViews-BTLjPZJQ.js +2 -0
  16. package/chunks/AgentPageRenderer-DLgUGrGy.js +180 -0
  17. package/chunks/BidiText-Bkp4Y90s.js +160 -0
  18. package/chunks/BlockDiff-B6-aJxHo.js +42 -0
  19. package/chunks/CanvasRenderer-C1Vegx9Y.js +110 -0
  20. package/chunks/ColorParserFull-BKH72fK8.js +446 -0
  21. package/chunks/DocumentCompare-C8295s35.js +6 -0
  22. package/chunks/DocumentLayout-CsU5MR-3.js +12 -0
  23. package/chunks/DocumentLayoutEngine-C62pyGVf.js +218 -0
  24. package/chunks/DocumentMutator-Bat_oLBQ.js +13 -0
  25. package/chunks/DocumentScrubber-BZQn_z92.js +21 -0
  26. package/chunks/DocumentSession-BDcazSEv.js +1 -0
  27. package/chunks/DocumentStylesheet-CEEt18sr.js +7 -0
  28. package/chunks/DocxConverter-BC31uYIL.js +1236 -0
  29. package/chunks/DocxGraft-L10HXM3U.js +8 -0
  30. package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -0
  31. package/chunks/HtmlConverter-C5ihhZ6G.js +267 -0
  32. package/chunks/ListNumbering-Qlu6AuRZ.js +23 -0
  33. package/chunks/MarkdownConverter-DofaSeC4.js +57 -0
  34. package/chunks/MathRenderer-Bz9WEVvF.js +68 -0
  35. package/chunks/OdtConverter-c1fTWoAt.js +125 -0
  36. package/chunks/OfficeImportShared-CrOpHpJ-.js +30 -0
  37. package/chunks/PageNumeralFonts-BWzI061X.js +5 -0
  38. package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
  39. package/chunks/PdfConverter-DX7fsRH5.js +457 -0
  40. package/chunks/RtfConverter-hbJ2529G.js +186 -0
  41. package/chunks/TableBorders-DVhdvo6f.js +32 -0
  42. package/chunks/TableGrid-DbroRucl.js +12 -0
  43. package/chunks/TextDecoding-IPbuUqcC.js +2 -0
  44. package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
  45. package/chunks/TxtConverter-YHv5FXWb.js +14 -0
  46. package/chunks/Typography-B4gndEdB.js +28 -0
  47. package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
  48. package/chunks/XmlConverter-BRRluy9k.js +55 -0
  49. package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -0
  50. package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
  51. package/chunks/base64-Di1bxoXD.js +1 -0
  52. package/chunks/browser-module-CFmqfGkE.js +1791 -0
  53. package/chunks/bundle.min-DRpfgV69.js +782 -0
  54. package/chunks/capture-i_dPkQIS.js +11 -0
  55. package/chunks/carrier-pYM9xf6x.js +6 -0
  56. package/chunks/chromeImageLayout-BiQ3Iz1-.js +18 -0
  57. package/chunks/engine-LMUnxdm2.js +520 -0
  58. package/chunks/footnoteFlatten-EE85Hjre.js +6 -0
  59. package/chunks/graftExport-G-dG7Vcc.js +104 -0
  60. package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
  61. package/chunks/index-BLb10wQt.js +1002 -0
  62. package/chunks/index-BWdRWxoH.js +1807 -0
  63. package/chunks/index.es-CI0QPo8w.js +780 -0
  64. package/chunks/jspdf.es.min-DU74zN8b.js +1792 -0
  65. package/chunks/jszip.min-CPW0h1Kx.js +476 -0
  66. package/chunks/katex-DWj8TvwO.js +1462 -0
  67. package/chunks/pdf-BLWDCiFF.js +1828 -0
  68. package/chunks/purify.es-BwLardii.js +107 -0
  69. package/chunks/serverDocumentSession-DGDU5Lh3.js +1011 -0
  70. package/chunks/signatures-DTNDS2PH.js +21 -0
  71. package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
  72. package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
  73. package/chunks/xmlScan-DXjt2cTS.js +8 -0
  74. package/engine.d.ts +179 -0
  75. package/engine.js +3 -0
  76. package/package.json +64 -4
  77. package/serverToolContract.d.ts +420 -0
  78. package/serverToolInputs.generated.d.ts +264 -0
@@ -0,0 +1,8 @@
1
+ import{c,h as u,m as g,r as f}from"./capture-i_dPkQIS.js";import{C as S,a as d,b as m,c as l,i as p,f as h,g as R,h as x,n as C,p as D,l as E,k as y,d as b,s as k,j as _,e as A}from"./signatures-DTNDS2PH.js";
2
+ import{a as i}from"./graftExport-G-dG7Vcc.js";import{G,b as I,g as B,r as T}from"./graftExport-G-dG7Vcc.js";import{C as F,D as H,c as N,g as P,l as U,s as v}from"./carrier-pYM9xf6x.js";function L(a,o){
3
+ const r=a.docxSource;if(!r)return s("no-capture");if(!o)return s("no-carrier");if(!r.sourceHash)return s("unpaired-capture");if(o.hash!==r.sourceHash)return s("carrier-hash-mismatch");const e=i(a),n=Object.
4
+ entries(e.domains).filter(([,t])=>!t).map(([t])=>t);return{fidelity:e.fullyExact?"exact":"grafted",regeneratedBlockIds:e.regeneratedBlockIds,changedDomains:n}}function s(a){return{fidelity:"converted",
5
+ regeneratedBlockIds:[],changedDomains:[],convertedReason:a}}export{F as CARRIER_MAP_KEY,S as CURRENT_GRAFT_SIGNATURE_VERSION,H as DEFAULT_CARRIER_BYTE_CAP,G as GraftProofError,i as assessGraftability,
6
+ d as blockCanonical,m as blockSignature,l as bodySidecarsSignature,p as canonicalizeForSignature,c as captureDocxSource,h as chromeSignature,N as clearDocxCarrier,R as commentsSignature,L as computeSourceFidelity,
7
+ x as corePropertiesSignature,P as getDocxCarrierMeta,I as getGraftStats,B as graftExport,u as hashBytes,U as loadDocxCarrier,g as markBlockSource,C as notesSignature,D as pageLayoutSignature,E as partHeadSignature,
8
+ y as partSignature,f as refreshDocxSourceSignatures,T as resetGraftStats,b as settingsSignature,k as signatureDigest,_ as stableStringify,v as storeDocxCarrier,A as stylesSignature};
@@ -0,0 +1,3 @@
1
+ const u=new Set(["stars","diamonds"]);function x(s){return s!==void 0&&u.has(s)}function f(s,a,r=1){const t=3.5*r,e=5*r,i=13*r,o=12*r,n=(s+a)/2,c=i+t+o;return a-s<c*2+24*r?{lines:[{from:s,to:a}],ornaments:[]}:
2
+ {lines:[{from:s,to:n-c},{from:n+c,to:a}],ornaments:[{cx:n-i,radius:t},{cx:n,radius:e},{cx:n+i,radius:t}]}}function d(s,a,r){const t=[];for(let e=0;e<4;e++){const i=Math.PI/4*e,o=Math.cos(i)*r,n=Math.sin(
3
+ i)*r;t.push({x1:s-o,y1:a-n,x2:s+o,y2:a+n})}return t}function m(s,a,r){return[{x:s,y:a-r},{x:s+r,y:a},{x:s,y:a+r},{x:s-r,y:a}]}export{m as d,x as i,f as l,d as s};
@@ -0,0 +1,267 @@
1
+ import{a as A,a_ as T,aM as V,b6 as J,b4 as K,W as P,C as U,aV as Z,r as j,Q as B,O as Y,aW as I,N as Q,R as tt,t as et,aS as rt,b7 as nt,aU as it}from"./engine-LMUnxdm2.js";import{i as at,p as D,e as ot,
2
+ r as st,s as lt}from"./ListNumbering-Qlu6AuRZ.js";import{f as O}from"./footnoteFlatten-EE85Hjre.js";import{i as ct}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";import{b as F}from"./TableGrid-DbroRucl.js";
3
+ import{a as ht,l as dt,b as pt,c as z}from"./MathRenderer-Bz9WEVvF.js";import{b as H,a as q,e as mt,g as ut,c as gt,l as ft,h as bt}from"./BidiText-Bkp4Y90s.js";import{c as yt,F as N,g as R,d as xt,L as E}from"./Typography-B4gndEdB.js";
4
+ const $t=[[/[\p{Script=Hiragana}\p{Script=Katakana}]/u,"ja"],[/\p{Script=Hangul}/u,"ko"],[/\p{Script=Han}/u,"und-Hani"],[/\p{Script=Arabic}/u,"und-Arab"],[/\p{Script=Hebrew}/u,"und-Hebr"],[/\p{Script=Devanagari}/u,
5
+ "und-Deva"],[/\p{Script=Bengali}/u,"und-Beng"],[/\p{Script=Gurmukhi}/u,"pa"],[/\p{Script=Gujarati}/u,"gu"],[/\p{Script=Oriya}/u,"or"],[/\p{Script=Tamil}/u,"ta"],[/\p{Script=Telugu}/u,"te"],[/\p{Script=Kannada}/u,
6
+ "kn"],[/\p{Script=Malayalam}/u,"ml"],[/\p{Script=Sinhala}/u,"si"],[/\p{Script=Thai}/u,"th"],[/\p{Script=Lao}/u,"lo"],[/\p{Script=Khmer}/u,"km"],[/\p{Script=Myanmar}/u,"my"],[/\p{Script=Tibetan}/u,"bo"],
7
+ [/\p{Script=Armenian}/u,"hy"],[/\p{Script=Georgian}/u,"ka"],[/\p{Script=Ethiopic}/u,"und-Ethi"],[/\p{Script=Cyrillic}/u,"und-Cyrl"]];function kt(w,t="en"){let e={language:t,count:0};for(const[i,a]of $t){
8
+ const s=new RegExp(i.source,`${i.flags}g`),h=Array.from(w.matchAll(s)).length;h>e.count&&(e={language:a,count:h})}const r=Array.from(w.matchAll(/[\p{Script=Hiragana}\p{Script=Katakana}]/gu)).length,n=Array.
9
+ from(w.matchAll(/\p{Script=Han}/gu)).length;return r>0&&r+n>=e.count?"ja":Array.from(w.matchAll(/\p{Script=Latin}/gu)).length>e.count?t:e.language}function St(w,t="en"){const e=new Map,r=[],n=i=>{if(!i||
10
+ typeof i!="object")return;const a=i;typeof a.text=="string"&&(r.push(a.text),typeof a.marks?.lang=="string"&&e.set(a.marks.lang,(e.get(a.marks.lang)??0)+a.text.length)),typeof a.content=="string"&&r.push(
11
+ a.content),Array.isArray(a.children)&&a.children.forEach(n)};return n(w),[...e.entries()].sort((i,a)=>a[1]-i[1])[0]?.[0]??kt(r.join(`
12
+ `),t)}const M="Arial, sans-serif",_=8.5*96,W=96,vt=11*96,Tt=4,At=20,X={unordered:25,ordered:30,todo:35};class wt{static fromHtml(t){const e=new DOMParser().parseFromString(t,"text/html");this.normalizeWordClipboard(
13
+ e.body);const r=this.extractViewSourceText(e);if(r!==null)return this.convertPlainText(r);if(this.isMinimalHtml(e)){const a=this.extractTextWithLineBreaks(e.body);return this.convertPlainText(a)}const n=Array.
14
+ from(e.body.children).filter(a=>a.tagName.toLowerCase()==="section"&&a.hasAttribute("data-revise-section"));if(n.length>0){const a=[];let s=0;Array.from(e.body.children).forEach(m=>{const l=m.tagName.
15
+ toLowerCase()==="section"&&m.hasAttribute("data-revise-section");if(a.push(...this.extractAllContent(m)),l&&(s+=1,s<n.length)){const c=m.getAttribute("data-revise-break-after"),p={type:"section-break",
16
+ id:A(),breakType:c==="continuous"||c==="evenPage"||c==="oddPage"?c:"nextPage"},d=this.readHtmlSectionLayout(m);d&&(p.layout=d),a.push(p)}});const h=n[n.length-1],o=this.readHtmlSectionLayout(h);return{
17
+ type:"doc",children:a.length>0?a:[T()],...o?{pageLayout:o}:{}}}const i=this.extractAllContent(e.body);return at(A,i),{type:"doc",children:i.length>0?i:[T()]}}static readHtmlSectionLayout(t){const e=t.
18
+ getAttribute("data-revise-section-layout");if(e!==null)try{const o=JSON.parse(e);if(o&&typeof o=="object"&&!Array.isArray(o))return Object.keys(o).length>0?o:void 0}catch{}const r=t.getAttribute("data\
19
+ -revise-column-count")||t.style.columnCount,n=Number.parseInt(r??"",10),i=t.getAttribute("data-revise-column-gap-twips"),a=i?Number.parseFloat(i):Number.NaN,s=Number.parseFloat(t.style.columnGap||""),
20
+ h={...Number.isFinite(n)&&n>=1?{columnCount:n}:{},...Number.isFinite(a)&&a>=0?{columnGapTwips:a}:Number.isFinite(s)&&s>=0?{columnGapTwips:V(s)}:{}};return Object.keys(h).length>0?h:void 0}static convertListElement(t,e=0){
21
+ const r=t.tagName.toLowerCase()==="ol"?"ordered":"unordered",n=[],i=[];let a=r==="ordered";const s=(o,m)=>{for(const l of Array.from(o.children)){const c=l.tagName.toLowerCase();if(c==="ol"||c==="ul"){
22
+ s(l,m+1);continue}if(c!=="li")continue;const p=Number(l.getAttribute("data-aria-level")),d=p>0?p-1:m,g=l.getAttribute("data-clipboard-list-tag")??o.tagName.toLowerCase(),u=l.style.listStyleType||o.style.
23
+ listStyleType,f=g==="ul"||["disc","circle","square"].includes(u);a||(a=!f);const b={"lower-alpha":"lowerLetter","upper-alpha":"upperLetter","lower-latin":"lowerLetter","upper-latin":"upperLetter","low\
24
+ er-roman":"lowerRoman","upper-roman":"upperRoman",a:"lowerLetter",A:"upperLetter",i:"lowerRoman",I:"upperRoman"},y=u||o.getAttribute("type")||"decimal";i[d]=f?{numFmt:"bullet",lvlText:u==="circle"?"◦":
25
+ u==="square"?"▪":"•"}:{numFmt:b[y]??"decimal",lvlText:l.getAttribute("data-leveltext")||`%${d+1}.`};const k=l.cloneNode(!0);k.querySelectorAll("ol, ul").forEach($=>$.remove());const x=this.extractInlineContent(
26
+ k).filter($=>$.type==="text"),S={...this.extractParagraphSpacing(l),type:"list-item",id:A(),children:x.length>0?x:[{type:"text",text:"",marks:{}}]};d>0&&(S.indentLevel=d),n.push(S);for(const $ of Array.
27
+ from(l.children)){const v=$.tagName.toLowerCase();(v==="ol"||v==="ul")&&s($,m+1)}}};if(s(t,e),n.length===0)return null;const h={type:"list",id:A(),variant:a?"ordered":r,children:n};if(a&&(i.length>1||
28
+ i[0]?.numFmt!=="decimal")&&(h.numberingFormat=JSON.stringify(i)),r==="ordered"){const o=t.getAttribute("start"),m=o?parseInt(o,10):NaN;Number.isFinite(m)&&m!==1&&(h.startNumber=m)}return h}static normalizeWordClipboard(t){
29
+ for(const r of Array.from(t.querySelectorAll(".WACImageContainer"))){const n=r.querySelector("svg image"),i=n?.getAttribute("href")??n?.getAttribute("xlink:href");if(!i)continue;const a=t.ownerDocument.
30
+ createElement("img");a.setAttribute("src",i),a.setAttribute("width",r.style.width||n.getAttribute("width")||"200"),a.setAttribute("height",r.style.height||n.getAttribute("height")||"200"),a.setAttribute(
31
+ "alt",r.querySelector("desc")?.textContent||""),r.replaceWith(a)}t.querySelectorAll("span.EOP[data-ccp-props]").forEach(r=>r.remove());for(const r of t.querySelectorAll('p[role="heading"][aria-level]')){
32
+ const n=Number(r.getAttribute("aria-level"));if(n<1||n>6||!Number.isInteger(n))continue;const i=t.ownerDocument.createElement(`h${n}`);for(const a of r.attributes)i.setAttribute(a.name,a.value);i.append(
33
+ ...Array.from(r.childNodes)),r.replaceWith(i)}const e=Array.from(t.querySelectorAll("ol, ul")).filter(r=>r.querySelector(":scope > li[data-listid]"));for(const r of e){for(const i of r.children)i.setAttribute(
34
+ "data-clipboard-list-tag",r.tagName.toLowerCase()),r.classList.contains("NumberListStyle2")&&(i.style.listStyleType="lower-alpha");const n=r.parentElement;n?.classList.contains("ListContainerWrapper")&&
35
+ n.children.length===1&&n.replaceWith(r)}for(const r of e){if(!t.contains(r))continue;const n=r.firstElementChild?.getAttribute("data-listid");let i=r.nextElementSibling;for(;i?.matches("ol, ul")&&i.firstElementChild?.
36
+ getAttribute("data-listid")===n;){const a=i.nextElementSibling;r.append(...Array.from(i.children)),i.remove(),i=a}}}static convertPlainText(t){let e=t.split(/\n\n+/).filter(r=>r.trim());if(e.length===
37
+ 1&&t.includes(`
38
+ `)){const r=t.split(`
39
+ `).filter(n=>n.trim());r.length>1&&(e=r)}return{type:"doc",children:e.length>0?e.map(r=>T([{type:"text",text:r.trim(),marks:{}}])):[T()]}}static extractTextWithLineBreaks(t){let e="";for(const r of Array.
40
+ from(t.childNodes))if(r.nodeType===Node.TEXT_NODE)e+=r.textContent||"";else if(r.nodeType===Node.ELEMENT_NODE){const n=r;n.tagName.toLowerCase()==="br"?e+=`
41
+ `:e+=this.extractTextWithLineBreaks(n)}return e}static extractViewSourceText(t){const e=t.body.getElementsByTagName("table");if(e.length!==1)return null;const r=Array.from(e[0].getElementsByTagName("t\
42
+ r"));if(r.length===0)return null;const n=[];for(const i of r){const a=Array.from(i.getElementsByTagName("td")),s=a.find(o=>o.classList.contains("line-content")),h=a.every(o=>o.classList.contains("line\
43
+ -content")||o.classList.contains("line-number"));if(!s||!h)return null;n.push(s.textContent??"")}return n.join(`
44
+ `)}static isMinimalHtml(t){const e=t.body,r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);let n=!0,i=!1;const a=t.getElementsByTagName("meta");for(const o of Array.from(
45
+ a))if(o.getAttribute("charset")){i=!0;break}let s;for(;s=r.nextNode();)if(s.nodeType===Node.ELEMENT_NODE){const o=s,m=o.tagName.toLowerCase();if(m!=="br"&&m!=="span"&&m!=="div"&&m!=="html"&&m!=="head"&&
46
+ m!=="body"&&m!=="meta"){n=!1;break}if((m==="div"||m==="span")&&(o.getAttribute("style")||o.className)){n=!1;break}}const h=t.getElementsByTagName("br").length>0;return i&&n||h&&n}static extractAllContent(t){
47
+ const e=[];return this.processElement(t,e),e}static convertMathMLToBlock(t){try{const e=t.outerHTML,r=ht();if(!r)return dt(),console.warn("MathML converter not loaded yet; skipping <math>"),null;const n=r.
48
+ convert(e);if(!n||n.trim()==="")return null;const i=t.getAttribute("display")==="block";return J(n.trim(),{displayMode:"block",align:"center"})}catch(e){return console.warn("Failed to convert MathML t\
49
+ o LaTeX:",e),null}}static processElement(t,e,r=new Set(["script","style"])){const n=t.tagName.toLowerCase();if(r.has(n))return;if(n==="img"){const l=t.getAttribute("src");if(!l||!/^(?:https?:|data:image\/|blob:)/i.
50
+ test(l))return;const c=t.style,p=this.parseCssLengthToPx(c.width||t.getAttribute("width")),d=this.parseCssLengthToPx(c.height||t.getAttribute("height"));e.push({type:"image",id:A(),src:l,width:p&&p>0?
51
+ p:300,height:d&&d>0?d:200,...t.getAttribute("alt")?{alt:t.getAttribute("alt")}:{}});return}if(/^(p|h[1-6])$/.test(n)&&t.querySelector("img")){const l=t.ownerDocument.createRange();l.setStart(t,0);const c=()=>{
52
+ const p=l.cloneContents();if(!p.textContent&&!p.querySelector("br"))return;const d=t.cloneNode(!1);d.appendChild(p),this.processElement(d,e,r)};for(const p of Array.from(t.querySelectorAll("img")))l.setEndBefore(
53
+ p),c(),this.processElement(p,e,r),l.setStartAfter(p);l.setEnd(t,t.childNodes.length),c();return}if(n==="math"){const l=this.convertMathMLToBlock(t);l&&e.push(l);return}if(n==="table"){const l=this.convertTableElement(
54
+ t);l&&e.push(l);return}const i=["span","strong","b","em","i","u","s","strike","del","code","sup","sub","a","abbr","mark"];if(n==="p"){const l=this.extractInlineContent(t),c=this.extractElementDirection(
55
+ t),p=c??H(this.inlineNodesText(l))??"ltr",d=this.extractParagraphStyleAttributes(t.getAttribute("style")||"",void 0,p),g=this.splitOnNewlines(l);for(let u=0;u<g.length;u++){const f=g[u],b=T(f.length>0?
56
+ f:[{type:"text",text:"",marks:{}}]);b.align=d.align??this.extractElementAlignment(t);const y=this.resolveImportedDirection(c,this.inlineNodesText(f));y&&(b.direction=y),d.leftIndent!==void 0&&(b.leftIndent=
57
+ d.leftIndent),d.firstLineIndent!==void 0&&(b.firstLineIndent=d.firstLineIndent),d.borders!==void 0&&u===g.length-1&&(b.borders=d.borders),Object.assign(b,this.extractParagraphSpacing(t)),e.push(b)}return}
58
+ if(n.match(/^h[1-6]$/)){const l=this.extractInlineContent(t),c=this.extractElementDirection(t),p=c??H(this.inlineNodesText(l))??"ltr",d=this.extractParagraphStyleAttributes(t.getAttribute("style")||"",
59
+ void 0,p),g=this.splitOnNewlines(l);for(let u=0;u<g.length;u++){const f=g[u],b=T(f.length>0?f:[{type:"text",text:"",marks:{}}]);Object.assign(b,this.extractParagraphSpacing(t)),u===0&&(b.heading=parseInt(
60
+ n.charAt(1))),b.align=d.align??this.extractElementAlignment(t);const y=this.resolveImportedDirection(c,this.inlineNodesText(f));y&&(b.direction=y),d.leftIndent!==void 0&&(b.leftIndent=d.leftIndent),d.
61
+ firstLineIndent!==void 0&&(b.firstLineIndent=d.firstLineIndent),d.borders!==void 0&&u===g.length-1&&(b.borders=d.borders),Object.assign(b,this.extractParagraphSpacing(t)),e.push(b)}return}if(n==="ol"||
62
+ n==="ul"){const l=this.convertListElement(t);l&&l.children.length>0&&e.push(l);return}if(n==="li"){const l=this.extractInlineContent(t),c=this.extractElementDirection(t),p=this.splitOnNewlines(l);for(const d of p){
63
+ const g=T(d.length>0?d:[{type:"text",text:"",marks:{}}]),u=this.resolveImportedDirection(c,this.inlineNodesText(d));u&&(g.direction=u),Object.assign(g,this.extractParagraphSpacing(t)),e.push(g)}return}
64
+ if(n==="hr"){e.push(K());return}if(n==="br"){if(t.className&&t.className.includes("Apple-interchange-newline"))return;e.push(T());return}let a=[];const s=this.extractElementDirection(t),h=(l,c)=>{const p=this.
65
+ resolveImportedDirection(s,this.inlineNodesText(c));p&&(l.direction=p)},o=()=>{if(a.length!==0){for(const l of this.splitOnNewlines(a)){const c=T(l);h(c,l),Object.assign(c,this.extractParagraphSpacing(
66
+ t)),e.push(c)}a=[]}},m=Array.from(t.childNodes);for(const l of m){if(l.nodeType===Node.TEXT_NODE){const d=l.textContent||"";d.trim()&&a.push({type:"text",text:d});continue}if(l.nodeType!==Node.ELEMENT_NODE)
67
+ continue;const c=l,p=c.tagName.toLowerCase();if(c.querySelector(":scope > p"))o(),this.processElement(c,e,r);else if(i.includes(p)){const d=this.extractInlineContent(c);a.push(...d)}else o(),this.processElement(
68
+ c,e,r)}o()}static convertTableElement(t){const e=this.getDirectTableRows(t);if(e.length===0)return null;const r=e.map(l=>this.convertTableRowElement(l)).filter(l=>l!==null&&l.children.length>0);if(r.length===
69
+ 0)return null;const n={children:r,columnWidths:[]};let i=F(n);const a=i.cols;if(a===0)return null;for(let l=0;l<r.length;l++){let c=0;for(let p=0;p<i.cols;p++)i.occupancy[l][p]||c++;if(c>0){for(let p=0;p<
70
+ c;p++)r[l].children.push(this.createEmptyTableCell());i=F(n)}}const s={type:"table",id:A(),children:r,...this.extractTableSizing(t,a)},h=this.extractElementAlignment(t);h&&h!=="justify"&&(s.align=h);const o=this.
71
+ extractTableBorderStyle(t);o.color&&(s.borderColor=o.color),o.width!==void 0&&(s.borderWidth=o.width);const m=this.extractTableCellPadding(t);return m!==void 0&&(s.cellPadding=m),this.tableHasHeaderRow(
72
+ t)&&(s.hasHeader=!0),s}static getDirectTableRows(t){const e=[];for(const r of Array.from(t.children)){const n=r.tagName.toLowerCase();if(n==="tr"){e.push(r);continue}if(n==="thead"||n==="tbody"||n==="\
73
+ tfoot")for(const i of Array.from(r.children))i.tagName.toLowerCase()==="tr"&&e.push(i)}return e}static convertTableRowElement(t){const e=[];for(const r of Array.from(t.children)){const n=r.tagName.toLowerCase();
74
+ if(n!=="td"&&n!=="th")continue;const i=this.convertTableCellElement(r),a=this.parseSpanAttribute(r.getAttribute("colspan")),s=this.parseSpanAttribute(r.getAttribute("rowspan"));a>1&&(i.colSpan=a),s>1&&
75
+ (i.rowSpan=s),e.push(i)}return e.length===0?null:{type:"table-row",id:A(),children:e}}static convertTableCellElement(t){const e=this.extractAllContent(t),r={type:"table-cell",id:A(),children:e.length>
76
+ 0?e:[T()]},n=this.extractTableCellVerticalAlign(t);n&&(r.verticalAlign=n);const i=this.extractElementBackgroundColor(t);return i&&(r.backgroundColor=i),r}static parseSpanAttribute(t){const e=parseInt(
77
+ t||"1",10);return Number.isFinite(e)?Math.min(Math.max(1,e),1e3):1}static createEmptyTableCell(){return{type:"table-cell",id:A(),children:[T()]}}static extractTableSizing(t,e){const r=o=>{for(const m of[
78
+ o.style?.width,o.getAttribute("width")]){const l=this.parseCssLengthToPx(m);if(l!==void 0&&l>0)return l}},n=r(t);let i=[];const a=Array.from(t.querySelectorAll(":scope > colgroup > col"));for(const o of a){
79
+ const m=r(o),l=Math.min(this.parseSpanAttribute(o.getAttribute("span")),e-i.length);for(let c=0;c<l;c++)i.push(m)}if(i.length!==e||i.some(o=>o===void 0)){i=Array(e).fill(void 0);const o=Array(e).fill(
80
+ 0),m=[];this.getDirectTableRows(t).forEach((l,c)=>{let p=0;for(const d of Array.from(l.children).filter(g=>g.matches("td, th"))){for(;p<e&&o[p]>c;)p++;const g=Math.min(this.parseSpanAttribute(d.getAttribute(
81
+ "colspan")),e-p),u=r(d);u&&g>0&&m.push({col:p,span:g,width:u});for(let f=p;f<p+g;f++)o[f]=c+this.parseSpanAttribute(d.getAttribute("rowspan"));p+=g}}),m.sort((l,c)=>l.span-c.span);for(const{col:l,span:c,
82
+ width:p}of m){const d=Array.from({length:c},(u,f)=>l+f).filter(u=>i[u]===void 0),g=i.slice(l,l+c).reduce((u,f)=>u+(f??0),0);if(d.length&&p>g)for(const u of d)i[u]=(p-g)/d.length}}const s=i.every(o=>o!==
83
+ void 0&&o>0)?i.reduce((o,m)=>o+(m??0),0):0,h=n??(s>0?s:void 0);return{columnWidths:s>0?i.map(o=>Number(((o??0)/s*100).toFixed(2))):Array(e).fill(Number((100/e).toFixed(2))),...h!==void 0?{tableWidth:Math.
84
+ round(h)}:{}}}static extractTableBorderStyle(t){const e=t.querySelector("td, th");if(!(e instanceof HTMLElement))return{};const r=[e.style.borderTopWidth,e.style.borderRightWidth,e.style.borderBottomWidth,
85
+ e.style.borderLeftWidth].map(i=>this.parseCssLengthToPx(i)).filter(i=>i!==void 0&&i>=0),n=r.length>0?Math.max(...r.map(i=>Math.round(i))):void 0;return{color:e.style.borderTopColor||e.style.borderRightColor||
86
+ e.style.borderBottomColor||e.style.borderLeftColor||void 0,width:n}}static extractTableCellPadding(t){const e=t.querySelector("td, th");if(!(e instanceof HTMLElement))return;const r=[e.style.paddingTop,
87
+ e.style.paddingRight,e.style.paddingBottom,e.style.paddingLeft].map(n=>this.parseCssLengthToPx(n)).filter(n=>n!==void 0&&n>=0);if(r.length!==0)return Math.round(Math.max(...r))}static tableHasHeaderRow(t){
88
+ const e=this.getDirectTableRows(t)[0];return e?Array.from(e.children).some(r=>r.tagName.toLowerCase()==="th"||r.getAttribute("role")==="columnheader"):!1}static extractTableCellVerticalAlign(t){const e=t instanceof
89
+ HTMLElement?t.style.verticalAlign:"",r=t.getAttribute("valign"),n=(e||r||"").trim().toLowerCase();if(n==="top"||n==="middle"||n==="bottom")return n}static extractElementBackgroundColor(t){const e=t instanceof
90
+ HTMLElement?t.style.backgroundColor:"";if(!(!e||e==="transparent"))return P(e)?e:void 0}static extractElementAlignment(t){const e=this.extractParagraphStyleAttributes(t.getAttribute("style")||"").align;
91
+ if(e)return e;const r=U(t,"align")?.trim().toLowerCase();if(r==="left"||r==="center"||r==="right"||r==="justify")return r}static parseCssLengthToPx(t){if(!t)return;const e=t.trim().toLowerCase();if(!e)
92
+ return;if(e==="0")return 0;const r=e.match(/^(-?\d+(?:\.\d+)?)(px|pt|pc|in|cm|mm|q)?$/);if(!r)return;const n=parseFloat(r[1]);switch(r[2]??"px"){case"px":return n;case"pt":return n*(96/72);case"pc":return n*
93
+ 16;case"in":return n*96;case"cm":return n*(96/2.54);case"mm":return n*(96/25.4);case"q":return n*(96/101.6);default:return}}static extractDirectInlineContent(t){const e=[],r=this.getTextMarks(t),n=["p",
94
+ "h1","h2","h3","h4","h5","h6","div","section","article","aside","main","nav","header","footer","blockquote","pre","ul","ol","li"],i=["span","strong","b","em","i","u","s","strike","del","code","sup","s\
95
+ ub","a","abbr","mark"];if(Array.from(t.childNodes).every(a=>{if(a.nodeType===Node.TEXT_NODE)return!0;if(a.nodeType===Node.ELEMENT_NODE){const s=a.tagName.toLowerCase();return i.includes(s)||s==="br"}return!1}))
96
+ return this.extractInlineContent(t);for(const a of Array.from(t.childNodes))if(a.nodeType===Node.TEXT_NODE){const s=a.textContent||"";s.trim()&&e.push({type:"text",text:s,marks:r})}else if(a.nodeType===
97
+ Node.ELEMENT_NODE){const s=a,h=s.tagName.toLowerCase();if(n.includes(h))continue;if(h==="br"){e.push({type:"text",text:`
98
+ `,marks:r});continue}const o=this.extractInlineContent(s);e.push(...o)}return e}static extractInlineContent(t){const e=[],r=this.getTextMarks(t);for(const n of Array.from(t.childNodes))if(n.nodeType===
99
+ Node.TEXT_NODE){const i=n.textContent||"";i&&e.push({type:"text",text:i,marks:r})}else if(n.nodeType===Node.ELEMENT_NODE){const i=n;if(i.tagName.toLowerCase()==="br"){e.push({type:"text",text:`
100
+ `,marks:r});continue}const a=this.extractInlineContent(i),s=this.getTextMarks(i);for(const h of a)h.type==="text"&&(h.marks={...r,...s,...h.marks}),e.push(h)}return e}static getTextMarks(t){if(!t)return;
101
+ const e={},r=t.closest("[lang]")?.getAttribute("lang")?.trim();r&&/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/u.test(r)&&(e.lang=r);const n=t.tagName.toLowerCase(),i=t instanceof HTMLElement?t.style:null,a=i&&
102
+ i.fontWeight?parseInt(i.fontWeight):null;(n==="strong"||n==="b")&&(!a||a>=700)&&(e.bold=!0),(n==="em"||n==="i")&&(e.italic=!0),n==="u"&&(e.underline=!0),(n==="s"||n==="strike"||n==="del")&&(e.strikethrough=
103
+ !0),n==="code"&&(e.code=!0),(n==="sup"||i?.verticalAlign==="super")&&(e.superscript=!0),(n==="sub"||i?.verticalAlign==="sub")&&(e.subscript=!0);const s=Number(t.getAttribute("data-fontsize"));if((e.superscript||
104
+ e.subscript)&&s>0&&(e.fontSize=s*96/72),n==="a"){const h=t.getAttribute("href");h&&(e.link=h)}if(i){if((i.fontWeight==="bold"||parseInt(i.fontWeight)>=700)&&(e.bold=!0),i.fontStyle==="italic"&&(e.italic=
105
+ !0),i.textDecoration?.includes("underline")&&(e.underline=!0),i.textDecoration?.includes("line-through")&&(i.textDecoration.includes("double")?e.doubleStrikethrough=!0:e.strikethrough=!0),i.fontVariant?.
106
+ includes("small-caps")&&(e.smallCaps=!0),i.textTransform==="uppercase"&&(e.allCaps=!0),i.letterSpacing&&i.letterSpacing!=="normal"){const o=this.parseCssLengthToPx(i.letterSpacing);o!==void 0&&o!==0&&
107
+ (e.letterSpacing=Math.round(o*100)/100)}if(i.backgroundColor&&i.backgroundColor!=="transparent"){const o=yt(i.backgroundColor);o&&(e.backgroundColor=o)}if(i.color){const o=P(i.color);o&&!Z(o)&&(e.color=
108
+ o)}const h=this.parseFontFamily(i.fontFamily);if(h&&(e.fontFamily=h),i.fontSize){const o=this.parseCssLengthToPx(i.fontSize);o!==void 0&&o>0&&(e.fontSize=o)}}return Object.keys(e).length>0?e:void 0}static resolveIndentStepPx(t){
109
+ return j(t?.pageLayout).indentStepPx}static resolveBlockMarginsPx(t,e){const r=n=>typeof n=="number"&&Number.isFinite(n)?Math.max(0,n):void 0;return{top:e.index===0?0:r(t.spaceBefore)??this.resolveBlockSpacingPx(
110
+ e.doc),bottom:r(t.spaceAfter)??0}}static resolveBlockSpacingPx(t){return j(t?.pageLayout).blockSpacingPx}static parseCssParagraphBorder(t){if(!t)return null;const e=t.trim().toLowerCase();if(!e||/\b(none|hidden)\b/.
111
+ test(e))return null;const r=e.match(/\b(solid|dashed|dotted|double)\b/);if(!r)return null;const n=r[1]==="solid"?"single":r[1],i=e.match(/([\d.]+)\s*(pt|px)/);let a=1;if(i){const o=parseFloat(i[1]),m=i[2]===
112
+ "pt"?o*4/3:o;a=Math.min(8,Math.max(1,Math.round(m)))}const s=e.replace(r[0]," ").replace(i?.[0]??""," ").trim(),h=P(s)??"#000000";return{style:n,width:a,color:h}}static extractElementDirection(t){for(let e=t;e;e=
113
+ e.parentElement){const r=(e.getAttribute("style")||"").match(/(?:^|;)\s*direction:\s*(rtl|ltr)\b/i);if(r)return r[1].toLowerCase();const n=e.getAttribute("dir")?.trim().toLowerCase();if(n==="rtl"||n===
114
+ "ltr")return n}}static resolveImportedDirection(t,e){if(t==="rtl")return"rtl";if(t==="ltr"&&H(e)==="rtl")return"ltr"}static inlineNodesText(t){return t.map(e=>e.type==="text"?e.text:"").join("")}static extractParagraphSpacing(t){
115
+ const e=t.style,r={},n=this.parseCssLengthToPx(e.marginTop),i=this.parseCssLengthToPx(e.marginBottom);if(n!==void 0&&n>=0&&(r.spaceBefore=n),i!==void 0&&i>=0&&(r.spaceAfter=i),e.lineHeight&&e.lineHeight!==
116
+ "normal"){const a=Number(e.lineHeight),s=this.parseCssLengthToPx(e.fontSize)??this.parseCssLengthToPx(t.querySelector("span[style]")?.style.fontSize)??N.paragraph,h=a>0?a:e.lineHeight.endsWith("%")?parseFloat(
117
+ e.lineHeight)/100:(this.parseCssLengthToPx(e.lineHeight)??0)/s;h>0&&(r.lineSpacing=h)}return r}static extractParagraphStyleAttributes(t,e=this.resolveIndentStepPx(),r="ltr"){const n={};{const c={},p=this.
118
+ parseCssParagraphBorder(t.match(/(?:^|;)\s*border:\s*([^;]+)/i)?.[1]);for(const d of["top","bottom","left","right"]){const g=t.match(new RegExp(`border-${d}:\\s*([^;]+)`,"i"))?.[1],u=g?this.parseCssParagraphBorder(
119
+ g):p;u&&(c[d]=u)}Object.keys(c).length>0&&(n.borders=JSON.stringify(c))}const i=t.match(/text-align:\s*([^;]+)/i);if(i){const c=i[1].trim().toLowerCase();if(c==="left"||c==="center"||c==="right"||c===
120
+ "justify")n.align=c;else if(c==="start"||c==="end"){const p=c==="start"==(r!=="rtl")?"left":"right";p!==(r==="rtl"?"right":"left")&&(n.align=p)}}const a=t.match(/margin-left:\s*([^;]+)/i),s=t.match(/margin-right:\s*([^;]+)/i),
121
+ h=r==="rtl"?s?.[1]??a?.[1]:a?.[1],o=B(h,{indentStepPx:e});o!==void 0&&(n.leftIndent=o);const m=t.match(/text-indent:\s*([^;]+)/i),l=B(m?.[1],{indentStepPx:e,firstLine:!0});return l!==void 0&&(n.firstLineIndent=
122
+ l),n}static appendParagraphIndentStyles(t,e,r){const n=Y(e.leftIndent);if(n!==void 0){const a=e.children.map(h=>"text"in h?h.text??"":"").join(""),s=q(e.direction,a)==="rtl"?"margin-right":"margin-lef\
123
+ t";t.push(`${s}: ${I(n,r)}px`)}const i=Q(e.firstLineIndent);i!==void 0&&t.push(`text-indent: ${I(i,r)}px`)}static splitOnNewlines(t){const e=[];let r=[];for(const n of t)if(n.type==="text"&&n.text.includes(
124
+ `
125
+ `)){const i=n.text.split(`
126
+ `);for(let a=0;a<i.length;a++){const s=i[a];s&&r.push({type:"text",text:s,marks:n.marks}),a<i.length-1&&(r.length>0?(e.push(r),r=[]):e.push([{type:"text",text:"",marks:{}}]))}}else r.push(n);return r.
127
+ length>0&&e.push(r),e.length>0?e:[[{type:"text",text:"",marks:{}}]]}static toHtml(t,e,r={}){return this.renderDocument(O(t),{mode:"plain",title:e,includeWrapper:!!e,blockSeparator:r.blockSeparator})}static toStyledHtml(t,e={}){
128
+ return this.renderDocument(O(t),{mode:"styled",title:e.title,includeWrapper:e.includeWrapper??!!e.title,syntaxTheme:e.syntaxTheme,defaultFontFamily:e.defaultFontFamily})}static async toStyledHtmlAsync(t,e={}){
129
+ const r=[];if(r.push(pt().then(()=>{})),typeof document<"u"){const n=R();r.push(mt(t,n,e.diagramMaxWidth??680))}return await Promise.all(r),this.toStyledHtml(t,e)}static resolveBaseFontFamily(t){return this.
130
+ normalizeFontFamily(this.inferDocumentFontFamily(t))??M}static inferDocumentFontFamily(t){if(t?.children){for(const e of t.children)if(e.type==="paragraph"){for(const r of e.children)if(r.type==="text"&&
131
+ r.marks?.fontFamily)return r.marks.fontFamily}else if(e.type==="list"){for(const r of e.children)for(const n of r.children)if(n.type==="text"&&n.marks?.fontFamily)return n.marks.fontFamily}}}static renderDocument(t,e){
132
+ if(!t||t.type!=="doc")return"";const r=e.defaultFontFamily??this.inferDocumentFontFamily(t),n=this.normalizeFontFamily(r)??M,i=t.children&&t.children.length>0?t.children:[T()],a=i.length,s=(l,c)=>this.
133
+ blockToHtml(l,{mode:e.mode,doc:t,baseFontFamily:n,index:c,totalBlocks:a,syntaxTheme:e.syntaxTheme}),h=i.some(l=>l.type==="section-break")||(t.pageLayout?.columnCount??1)>1?this.renderSectionedDocument(
134
+ t,i,s,e.blockSeparator??""):i.map(s).join(e.blockSeparator??"");if(!e.includeWrapper)return h;const o=e.title??t.title??"Revise Document",m=this.escapeAttribute(St(t));if(e.mode==="styled"){const l=this.
135
+ getStyledDocumentCss({baseFontFamily:n,pageless:t.pageless??!1});return`<!DOCTYPE html>
136
+ <html lang="${m}">
137
+ <head>
138
+ <meta charset="UTF-8">
139
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
140
+ <title>${this.escapeHtml(o)}</title>
141
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
142
+ <style>
143
+ ${l}
144
+ </style>
145
+ </head>
146
+ <body>
147
+ <main class="revise-document">
148
+ ${h}
149
+ </main>
150
+ </body>
151
+ </html>`}return`<!DOCTYPE html>
152
+ <html lang="${m}">
153
+ <head>
154
+ <meta charset="UTF-8">
155
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
156
+ <title>${this.escapeHtml(o)}</title>
157
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css">
158
+ <style>
159
+ body {
160
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
161
+ line-height: 1.6;
162
+ color: #333;
163
+ max-width: 800px;
164
+ margin: 0 auto;
165
+ padding: 2rem;
166
+ }
167
+ h1 { font-size: 2rem; margin: 1.5rem 0 1rem; }
168
+ h2 { font-size: 1.5rem; margin: 1.3rem 0 0.8rem; }
169
+ h3 { font-size: 1.25rem; margin: 1.2rem 0 0.6rem; }
170
+ h4 { font-size: 1.1rem; margin: 1rem 0 0.5rem; }
171
+ h5 { font-size: 1rem; margin: 1rem 0 0.5rem; }
172
+ h6 { font-size: 0.9rem; margin: 1rem 0 0.5rem; }
173
+ p { margin: 0.5rem 0; }
174
+ code {
175
+ background-color: #f4f4f4;
176
+ padding: 0.2rem 0.4rem;
177
+ border-radius: 3px;
178
+ font-family: 'Courier New', monospace;
179
+ }
180
+ </style>
181
+ </head>
182
+ <body>
183
+ ${h}
184
+ </body>
185
+ </html>`}static renderSectionedDocument(t,e,r,n){const i=[];let a=[];return e.forEach((s,h)=>{s.type==="section-break"?(i.push({blocks:a,layout:s.layout,breakAfter:s.breakType??"nextPage"}),a=[]):a.push(
186
+ {block:s,index:h})}),i.push({blocks:a,layout:t.pageLayout}),i.map((s,h)=>{const o=tt(t.pageLayout,s.layout),m=[`column-count: ${o.columnCount}`,`column-gap: ${this.formatPx(et(o.columnGapTwips))}`,...h>
187
+ 0&&i[h-1].breakAfter!=="continuous"?["break-before: page"]:[]].join("; "),l=s.breakAfter?` data-revise-break-after="${s.breakAfter}"`:"",c=` data-revise-section-layout="${this.escapeAttribute(JSON.stringify(
188
+ s.layout??{}))}"`;return`<section data-revise-section="${h+1}" data-revise-column-count="${o.columnCount}" data-revise-column-gap-twips="${o.columnGapTwips}"${c}${l} style="${m}">${s.blocks.map(({block:p,
189
+ index:d})=>r(p,d)).join(n)}</section>`}).join(n)}static blockToHtml(t,e){return t.type==="placeholder"?this.placeholderToHtml(t,e):t.type==="image"?this.imageBlockToHtml(t,e):t.type==="list"?this.listBlockToHtml(
190
+ t,e):t.type==="paragraph"?this.paragraphToHtml(t,e):t.type==="table"?this.tableBlockToHtml(t,e):t.type==="code"?this.codeBlockToHtml(t,e):t.type==="math"?this.mathBlockToHtml(t,e):""}static placeholderToHtml(t,e){
191
+ const r=Math.max(16,t.height||0);if(e.mode==="styled"){const n=e.index===0?0:this.resolveBlockSpacingPx(e.doc);return`<div style="${["background-color: #e5e7eb","border-radius: 8px",`height: ${this.formatPx(
192
+ r)}`,"width: 100%",`margin: ${this.formatPx(n)} 0 0 0`].join("; ")}" data-block-type="placeholder"></div>`}return`<div style="background-color: #e5e7eb; height: ${r}px; width: 100%;"></div>`}static paragraphToHtml(t,e){
193
+ const r=rt(t);if(r){if(ct(r.style)){const g=r.style==="stars"?"✴":"◆",u=`flex: 1; border-bottom: ${r.width}px solid currentColor`;return`<div role="separator" style="display: flex; align-items: ce\
194
+ nter; gap: 12px; margin: 1em 0; color: ${r.color}"><span style="${u}"></span><span style="font-size: 11px; letter-spacing: 6px; text-indent: 6px; line-height: 1">${g}${g}${g}</span><span style="${u}">\
195
+ </span></div>`}const d=r.style==="single"?"solid":r.style;return`<hr style="${["border: none",`border-bottom: ${r.width}px ${d} ${r.color}`,"margin: 1em 0"].join("; ")}" />`}const n={mode:e.mode,paragraph:t,
196
+ block:t,doc:e.doc,baseFontFamily:e.baseFontFamily};let i=this.inlineNodesToHtml(t.children,n);const a=t.direction?` dir="${t.direction}"`:q(void 0,t.children.map(d=>d.text??"").join(""))==="rtl"?' dir\
197
+ ="auto"':"";if(e.mode==="plain"){const d=[];t.align&&d.push(`text-align: ${t.align}`),this.appendParagraphIndentStyles(d,t,this.resolveIndentStepPx(e.doc));const g=d.length>0?` style="${d.join("; ")}"`:
198
+ "";return t.heading?`<h${t.heading}${a}${g}>${i}</h${t.heading}>`:`<p${a}${g}>${i}</p>`}this.isEmptyInlineContent(t.children)&&(i="<br>");const s=this.getParagraphFontSizePx(t),h=this.getParagraphLineHeightMultiplier(
199
+ t),o=this.resolveBlockMarginsPx(t,e),m=e.baseFontFamily,l=[`margin: ${this.formatPx(o.top)} 0 ${o.bottom>0?this.formatPx(o.bottom):"0"} 0`,`font-size: ${this.formatPx(s)}`,`line-height: ${this.formatNumber(
200
+ h)}`,`font-family: ${this.escapeAttribute(m)}`,"font-weight: 400"];t.align&&l.push(`text-align: ${t.align}`),this.appendParagraphIndentStyles(l,t,this.resolveIndentStepPx(e.doc));const c=t.heading?`h${t.
201
+ heading}`:"p",p=t.heading?` data-block-type="heading" data-heading="${t.heading}"`:' data-block-type="paragraph"';return`<${c}${a} style="${l.join("; ")}"${p}>${i}</${c}>`}static inlineNodesToHtml(t,e){
202
+ return t.map(r=>r.type==="text"?this.textNodeToHtml(r,e):"").join("")}static isEmptyInlineContent(t){return!t.some(e=>e.type==="text"&&e.text.length>0)}static textNodeToHtml(t,e){if(t.marks?.latex){const n=z();
203
+ if(n)try{return`<span data-latex="true">${n.renderToString(t.text,{displayMode:!1,throwOnError:!1,errorColor:"#ef4444",trust:!1,strict:!1})}</span>`}catch(i){const a=i instanceof Error?i.message:"LaTe\
204
+ X render error";return`<span style="color: #ef4444;" data-latex="true">${this.escapeHtml(a)}</span>`}return`<span data-latex="true" data-latex-content="${this.escapeAttribute(t.text)}">${this.escapeHtml(
205
+ t.text)}</span>`}let r=this.escapeHtml(t.text);if(r=r.replace(/\r\n|\r|\n/g,"<br>"),t.marks){const n=[];if(t.marks.bold&&(r=`<strong>${r}</strong>`),t.marks.italic&&(r=`<em>${r}</em>`),t.marks.underline&&
206
+ (r=`<u>${r}</u>`),t.marks.strikethrough&&(r=`<s>${r}</s>`),t.marks.code&&(r=`<code>${r}</code>`),t.marks.superscript&&(r=`<sup>${r}</sup>`),t.marks.subscript&&(r=`<sub>${r}</sub>`),t.marks.link){const i=this.
207
+ sanitizeLinkHref(t.marks.link);i&&(r=`<a href="${this.escapeAttribute(i)}">${r}</a>`)}if(t.marks.doubleStrikethrough&&n.push("text-decoration: line-through double"),t.marks.smallCaps&&n.push("font-var\
208
+ iant: small-caps"),t.marks.allCaps&&n.push("text-transform: uppercase"),typeof t.marks.letterSpacing=="number"&&Number.isFinite(t.marks.letterSpacing)&&t.marks.letterSpacing!==0&&n.push(`letter-spacin\
209
+ g: ${t.marks.letterSpacing}px`),t.marks.color&&n.push(`color: ${t.marks.color}`),t.marks.backgroundColor&&n.push(`background-color: ${xt(t.marks.backgroundColor)??t.marks.backgroundColor}`),t.marks.fontFamily&&
210
+ e.mode==="styled"&&n.push(`font-family: ${this.escapeAttribute(t.marks.fontFamily)}`),t.marks.fontSize&&n.push(`font-size: ${t.marks.fontSize}px`),n.length>0||t.marks.lang){const i=n.length>0?` style=\
211
+ "${n.join("; ")}"`:"";r=`<span${t.marks.lang?` lang="${this.escapeAttribute(t.marks.lang)}"`:""}${i}>${r}</span>`}t.marks.__htmlClassName&&(r=`<span class="${this.escapeAttribute(t.marks.__htmlClassName)}\
212
+ ">${r}</span>`)}return r}static imageBlockToHtml(t,e){const r=t.alt?` alt="${this.escapeAttribute(t.alt)}"`:"",n=t.align?` align="${t.align}" data-align="${t.align}"`:"",i=this.getImageStyle(t),a=Math.
213
+ max(1,Math.round(t.width)),s=Math.max(1,Math.round(t.height));if(e.mode==="plain"){const c=i?` style="${i}"`:"";return`<img src="${this.escapeAttribute(t.src)}" width="${a}" height="${s}"${r}${n}${c}>`}
214
+ const h=i?i.split(";").map(c=>c.trim()).filter(Boolean):[],o=e.index===0?0:this.resolveBlockSpacingPx(e.doc);h.push(`margin-top: ${this.formatPx(o)}`),h.push(`margin-bottom: ${this.formatPx(0)}`);const l=h.
215
+ length>0?` style="${h.join("; ")}"`:"";return`<img src="${this.escapeAttribute(t.src)}" width="${a}" height="${s}"${r}${n}${l} data-block-type="image">`}static listBlockToHtml(t,e){const r=D(t.numberingFormat),
216
+ n=c=>r?.[c]?.numFmt==="bullet"?"ul":t.variant==="ordered"?"ol":"ul",i=n(0),a=(c,p)=>{const d=[];let g=0;for(;g<c.length;){const u=c[g],f=Math.max(0,u.indentLevel??0);if(f<p)break;if(f!==p){g+=1;continue}
217
+ const b={mode:e.mode,block:t,doc:e.doc,baseFontFamily:e.baseFontFamily},y=this.inlineNodesToHtml(u.children,b),k=[];let x=g+1;for(;x<c.length&&!(Math.max(0,c[x].indentLevel??0)<=p);)k.push(c[x]),x+=1;
218
+ let S=y;if(k.length>0){const v=n(p+1),C=e.mode==="styled"?this.getListStyle(t,e,p+1):"",L=C?` style="${C}"`:"",G=a(k,p+1);S+=`<${v}${L}>${G}</${v}>`}if(t.variant==="todo"){const v=u.checked?" checked":
219
+ "",C=e.mode==="styled"?' style="margin-right: 12px; width: 16px; height: 16px; accent-color: #111827; vertical-align: middle;"':"";S=`<input type="checkbox"${v}${C}> ${S}`}let $="";if(e.mode==="styled"){
220
+ const v=u.lineSpacing??this.getListLineHeightMultiplier(t),C=x>=c.length||Math.max(0,c[x].indentLevel??0)<p,L=[`margin: 0 0 ${this.formatPx(u.spaceAfter??(C?0:Tt))} 0`,`margin-top: ${this.formatPx(u.spaceBefore??
221
+ 0)}`,`line-height: ${this.formatNumber(v)}`];t.variant==="todo"&&L.push("list-style-type: none"),$=` style="${L.join("; ")}"`}if(e.mode!=="styled"){const v=[...u.lineSpacing!==void 0?[`line-height: ${u.
222
+ lineSpacing}`]:[],...u.spaceBefore!==void 0?[`margin-top: ${u.spaceBefore}px`]:[],...u.spaceAfter!==void 0?[`margin-bottom: ${u.spaceAfter}px`]:[]];v.length&&($=` style="${v.join("; ")}"`)}d.push(`<li${$}\
223
+ >${S}</li>`),g=x}return d.join("")},s=a(t.children,0),h=t.variant==="ordered"?ot(st(e.doc).get(t.id)??lt(t)):1,o=t.variant==="ordered"&&h!==1?` start="${h}"`:"";if(e.mode==="plain")return`<${i}${o}>${s}\
224
+ </${i}>`;const m=this.getListStyle(t,e,0),l=m?` style="${m}"`:"";return`<${i}${o}${l} data-block-type="list" data-variant="${t.variant}">${s}</${i}>`}static tableBlockToHtml(t,e){const r=t.children;if(!r||
225
+ r.length===0)return"";const n=t.borderColor??"#d1d5db",i=t.borderWidth??1,a=Number.isFinite(t.cellPadding)?Math.max(0,Math.round(t.cellPadding)):8,s=F(t),h=d=>{const g=s.byId.get(d.id);let u="";return g&&
226
+ g.colSpan>1&&(u+=` colspan="${g.colSpan}"`),g&&g.rowSpan>1&&(u+=` rowspan="${g.rowSpan}"`),u};if(e.mode==="plain"){const d=r.map((g,u)=>`<tr>${g.children.map(f=>{const b=this.tableCellContentToHtml(f,
227
+ e),y=t.hasHeader&&u===0?"th":"td";return`<${y}${h(f)}>${b}</${y}>`}).join("")}</tr>`).join("");return`<table border="${i}" cellspacing="0" cellpadding="${a}">${d}</table>`}const o=e.index===0?0:this.resolveBlockSpacingPx(
228
+ e.doc),m=["border-collapse: collapse",t.tableWidth?`width: ${this.formatPx(t.tableWidth)}`:"width: 100%",`margin: ${this.formatPx(o)} 0 ${this.formatPx(0)} 0`],l=r.map((d,g)=>{const u=t.hasHeader&&g===
229
+ 0;return`<tr>${d.children.map(f=>{const b=this.tableCellContentToHtml(f,e),y=u?"th":"td",k=[`border: ${i}px solid ${n}`,`padding: ${a}px`],x=s.byId.get(f.id);if(t.columnWidths&&x){let S=0;for(let $=x.
230
+ col;$<x.col+x.colSpan;$++)S+=t.columnWidths[$]||0;S>0&&k.push(t.tableWidth?`width: ${this.formatPx(t.tableWidth*S/100)}`:`width: ${S}%`)}return f.verticalAlign&&k.push(`vertical-align: ${f.verticalAlign}`),
231
+ f.backgroundColor?k.push(`background-color: ${f.backgroundColor}`):u&&k.push("background-color: #f9fafb"),u&&k.push("font-weight: 600"),`<${y}${h(f)} style="${k.join("; ")}">${b}</${y}>`}).join("")}</\
232
+ tr>`}).join(""),c=t.tableWidth?` width="${Math.round(t.tableWidth)}"`:"",p=t.tableWidth&&t.columnWidths?`<colgroup>${t.columnWidths.map(d=>`<col width="${Math.round(t.tableWidth*d/100)}">`).join("")}<\
233
+ /colgroup>`:"";return`<table${c} style="${m.join("; ")}" data-block-type="table">${p}${l}</table>`}static tableCellContentToHtml(t,e){if(!t.children||t.children.length===0)return"";const r={...e,index:0,
234
+ totalBlocks:t.children.length};return t.children.map((n,i)=>{const a={...r,index:i};return this.blockToHtml(n,a)}).join("")}static codeBlockToHtml(t,e){const r=t.content||"",n=t.language||"",i=ut(n);if(i&&
235
+ t.renderDiagram!==!1&&i){const c=gt({protocol:i,source:r,theme:R(),maxWidth:900}),p=n?` data-language="${n}"`:"",d=e.index===0?0:this.resolveBlockSpacingPx(e.doc),g=["background: #ffffff","border: 1px\
236
+ solid #e0e0e0","border-radius: 4px","padding: 12px",`margin: ${this.formatPx(d)} 0 ${this.formatPx(0)} 0`,"text-align: center","overflow: hidden"].join("; ");return c?.svg?`<figure data-block-type="d\
237
+ iagram"${p} style="${g}">${c.svg}</figure>`:`<figure data-block-type="diagram"${p} data-diagram-source="${this.escapeAttribute(r)}" data-diagram-protocol="${i}" style="${g}"><div style="color: var(--t\
238
+ ext-muted, #999); font-style: italic;">Loading diagram...</div></figure>`}const a=e.syntaxTheme||ft,s=n?bt(r,n,a):null;if(e.mode==="plain"){const c=this.escapeHtml(r);return`<pre${n?` data-language="${n}\
239
+ "`:""}><code>${c}</code></pre>`}const h=e.index===0?0:this.resolveBlockSpacingPx(e.doc),o=[`background-color: var(--revise-code-background, ${a.background})`,`color: var(--revise-code-text, ${a.default}\
240
+ )`,"padding: 12px","border-radius: 4px","overflow-x: hidden","white-space: pre-wrap","overflow-wrap: anywhere","word-break: break-word",`margin: ${this.formatPx(h)} 0 ${this.formatPx(0)} 0`,"font-fami\
241
+ ly: 'Source Code Pro', Monaco, Consolas, 'Courier New', monospace","font-size: 14px","line-height: 1.5"],m=n?` data-language="${n}"`:"",l="font-family: inherit; white-space: inherit; overflow-wrap: in\
242
+ herit; word-break: inherit";if(s&&s.length>0){const c=s.map(p=>{const d=this.escapeHtml(p.text);return`<span style="color: ${p.color}; font-family: inherit">${d}</span>`}).join("");return`<pre style="${o.
243
+ join("; ")}"${m}><code style="${l}">${c}</code></pre>`}else{const c=this.escapeHtml(r);return`<pre style="${o.join("; ")}"${m}><code style="${l}">${c}</code></pre>`}}static mathBlockToHtml(t,e){const r=t.
244
+ content||"",n=t.displayMode!=="inline",i=t.align||"center";let a;const s=z();if(s)try{a=s.renderToString(r,{displayMode:n,throwOnError:!1,errorColor:"#ef4444",trust:!1,strict:!1})}catch(o){const m=o instanceof
245
+ Error?o.message:"LaTeX render error";a=`<span style="color: #ef4444;">${this.escapeHtml(m)}</span>`}else a=`<span data-latex-content="${this.escapeAttribute(r)}">${this.escapeHtml(r)}</span>`;if(e.mode===
246
+ "plain")return`<div style="${i==="center"?"text-align: center;":i==="right"?"text-align: right;":""}" data-math-block="true">${a}</div>`;const h=e.index===0?0:this.resolveBlockSpacingPx(e.doc);return`\
247
+ <div style="${["background: #ffffff","border: 1px solid #e0e0e0","border-radius: 4px","padding: 12px",`margin: ${this.formatPx(h)} 0 ${this.formatPx(0)} 0`,`text-align: ${i}`].join("; ")}" data-block-\
248
+ type="math">${a}</div>`}static getListStyle(t,e,r){if(e.mode!=="styled")return"";const n=(X[t.variant]??X.unordered)+Math.max(0,r)*At,i=[];if(r===0){const s=this.resolveBlockMarginsPx(t,e);i.push(`mar\
249
+ gin: ${this.formatPx(s.top)} 0 ${this.formatPx(s.bottom)} 0`)}else i.push("margin: 0");i.push(`padding-left: ${this.formatPx(n)}`);const a=e.baseFontFamily;if(i.push(`font-size: ${this.formatPx(N.paragraph)}`),
250
+ i.push(`line-height: ${this.formatNumber(this.getListLineHeightMultiplier(t))}`),i.push(`font-family: ${this.escapeAttribute(a)}`),t.variant==="todo")i.push("list-style-type: none");else{const s=D(t.numberingFormat)?.[r],
251
+ h={decimal:"decimal",lowerLetter:"lower-alpha",upperLetter:"upper-alpha",lowerRoman:"lower-roman",upperRoman:"upper-roman",decimalZero:"decimal-leading-zero"},o=s?.numFmt==="bullet"?s.lvlText==="◦"?
252
+ "circle":s.lvlText==="▪"?"square":"disc":s?.numFmt&&h[s.numFmt];o&&i.push(`list-style-type: ${o}`)}return i.join("; ")}static getParagraphFontSizePx(t){if(t.heading){const e=`h${t.heading}`;return N[e]??
253
+ N.paragraph}return N.paragraph}static getParagraphLineHeightMultiplier(t){return typeof t.lineSpacing=="number"&&Number.isFinite(t.lineSpacing)&&t.lineSpacing>0?t.lineSpacing:t.heading?E.heading:E.paragraph}static getListLineHeightMultiplier(t){
254
+ return typeof t.lineSpacing=="number"&&Number.isFinite(t.lineSpacing)&&t.lineSpacing>0?t.lineSpacing:E.paragraph}static normalizeFontFamily(t){if(!t)return;const e=t.trim();if(!e)return;const r=nt(e),
255
+ n=r&&r!=="inherit"?r:e;return/[<>;]/.test(n)?M:n}static formatNumber(t){return Number.isFinite(t)?`${Math.round(t*1e3)/1e3}`.replace(/\.0+$/,"").replace(/(\.\d*[1-9])0+$/,"$1"):"0"}static formatPx(t){
256
+ return`${this.formatNumber(t)}px`}static getStyledDocumentCss(t){const e=t.pageless?"min(100%, 816px)":`${_}px`,r=t.pageless?"48px":`${W}px`,n=t.pageless?"auto":`${Math.max(vt-W*2,0)}px`,i=t.pageless?
257
+ "32px":"48px";return[":root {"," color-scheme: light;","}","body {"," margin: 0;"," background: #f3f4f6;"," color: #111827;",` font-family: ${t.baseFontFamily};`,` font-size: ${this.formatPx(N.paragraph)}\
258
+ ;`,` line-height: ${this.formatNumber(E.paragraph)};`," display: flex;"," justify-content: center;"," padding: 48px 0;","}",".revise-document {"," background: #ffffff;",` width: ${e};`,` min-he\
259
+ ight: ${n};`,` padding: ${r};`," box-sizing: border-box;"," word-wrap: break-word;","}",".revise-document * {"," color: inherit;","}",`@media (max-width: ${_+W*2}px) {`," body {"," padding: 32\
260
+ px 0;"," }"," .revise-document {"," width: calc(100% - 32px);",` padding: ${i};`," }","}"].join(`
261
+ `)}static getImageStyle(t){const e=["display: block","max-width: 100%","height: auto"];switch(t.align){case"center":e.push("margin-left: auto","margin-right: auto");break;case"right":e.push("margin-le\
262
+ ft: auto");break;case"left":e.push("margin-right: auto");break}return e.join("; ")}static escapeHtml(t){const e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return t.replace(/[&<>"']/g,
263
+ r=>e[r])}static escapeAttribute(t){return this.escapeHtml(t)}static sanitizeLinkHref(t){const e=t.trim();if(!e)return null;const r=e.toLowerCase();return r.startsWith("#")||r.startsWith("?")?e:e.startsWith(
264
+ "/")?e.startsWith("//")?null:e:e.startsWith("./")||e.startsWith("../")||r.startsWith("http://")||r.startsWith("https://")||r.startsWith("mailto:")||r.startsWith("tel:")?e:/^[a-z][a-z0-9+.-]*:/i.test(e)?
265
+ null:e}static parseFontFamily(t){if(t)for(const e of t.split(",")){const r=e.replace(/['"]/g,"").trim().toLowerCase(),n=it.find(i=>i.cssValue.split(",")[0].replace(/['"]/g,"").trim().toLowerCase()===r);
266
+ if(n)return n.cssValue.split(",")[0].trim()}}static getConsistentFontFamily(t){if(t.length===0)return;let e,r=!0;for(const n of t)if(n.type==="text"){const i=n.marks?.fontFamily;if(r)e=i,r=!1;else if(e!==
267
+ i)return}return e}}export{wt as HtmlConverter};
@@ -0,0 +1,23 @@
1
+ function c(e){let t=Math.max(1,e),r="";for(;t>0;)t-=1,r=String.fromCharCode(97+t%26)+r,t=Math.floor(t/26);return r}function u(e,t){let r=Math.max(1,e),n="";for(;r>0;)r-=1,n=t[r%t.length]+n,r=Math.floor(
2
+ r/t.length);return n}function f(e,t){return String(e).replace(/\d/g,r=>t[Number(r)])}const g="〇一二三四五六七八九";function h(e){const t=Math.max(1,Math.floor(e));if(t>=1e4){const a=Math.floor(
3
+ t/1e4),l=t%1e4;return`${h(a)}万${l?h(l):""}`}const r=["","十","百","千"];let n="",o=!1;for(let a=3;a>=0;a-=1){const l=10**a,s=Math.floor(t/l)%10;if(s===0){n&&t%l!==0&&(o=!0);continue}o&&(n+="〇"),
4
+ s===1&&a===1&&n===""||(n+=g[s]),n+=r[a],o=!1}return n}const $=["أ","ب","ج","د","ه","و","ز","ح","ط","ي","ك","ل","م","ن","س","ع","ف","ص","ق","ر","ش","ت","ث","خ","ذ","ض","ظ","غ"],
5
+ w=["א","ב","ג","ד","ה","ו","ז","ח","ט","י","כ","ל","מ","נ","ס","ע","פ","צ","ק","ר","ש","ת"],I=Array.from("あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわをん"),
6
+ A=Array.from("いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす"),S=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],
7
+ [100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]];function d(e){let t=Math.max(1,e),r="";for(const[n,o]of S)for(;t>=n;)r+=o,t-=n;return r||"i"}function M(e,t){const r=Math.
8
+ max(1,t);switch((e||"decimal").trim()){case"lowerLetter":return c(r);case"upperLetter":return c(r).toUpperCase();case"lowerRoman":return d(r);case"upperRoman":return d(r).toUpperCase();case"decimalZer\
9
+ o":return r<10?`0${r}`:String(r);case"arabicIndic":return f(r,"٠١٢٣٤٥٦٧٨٩");case"hindiNumbers":return f(r,"०१२३४५६७८९");case"thaiNumbers":return f(r,"๐๑๒๓๔๕๖๗๘๙");case"\
10
+ decimalFullWidth":return f(r,"0123456789");case"arabicAbjad":case"arabicAlpha":return u(r,$);case"hebrew1":case"hebrew2":return u(r,w);case"aiueo":return u(r,I);case"iroha":return u(
11
+ r,A);case"chineseCounting":case"chineseCountingThousand":case"japaneseCounting":return h(r);case"ideographDigital":return String(r).replace(/\d/g,n=>g[Number(n)]);case"none":return"";default:return String(
12
+ r)}}const v=new Map;function x(e){if(!e)return;if(v.has(e))return v.get(e);let t;try{const r=JSON.parse(e);t=Array.isArray(r)?r:void 0}catch{t=void 0}return v.set(e,t),t}function F(e,t,r){return t.replace(
13
+ /%([1-9])/g,(n,o)=>{const a=parseInt(o,10)-1;return M(e[a]?.numFmt,r(a))})}function m(e,t,r,n){const o=r<=0?0:r===1?1:2;o===0?(e.level0=Math.max(e.level0+1,t),e.level1=0,e.level2=0):o===1?(e.level0<t&&
14
+ (e.level0=t),e.level1+=1,e.level2=0):(e.level0<t&&(e.level0=t),e.level1===0&&(e.level1=1),e.level2+=1);const a=n?.[o];if(a?.lvlText){const l=s=>s===0?e.level0:s===1?e.level1:e.level2;return F(n,a.lvlText,
15
+ l)}if(a?.numFmt){const l=o===0?e.level0:o===1?e.level1:e.level2;return`${M(a.numFmt,l)}.`}return o===0?`${e.level0}.`:o===1?`${e.level0} ${c(e.level1)}.`:`${e.level0} ${c(e.level1)} ${d(e.level2)}.`}function L(e,t){
16
+ const r={...t.counters},n=x(e.numberingFormat);return e.children.map(o=>m(r,t.start,o.indentLevel??0,n))}function p(e){const t=e??1;return{counters:{level0:t-1,level1:0,level2:0},start:t}}function N(e){
17
+ return b(e.children)}function b(e){const t=new Map,r=new Map,n=a=>{for(const l of a)if(l.type==="list")o(l);else if(l.type==="container"||l.type==="footnote")n(l.children);else if(l.type==="table")for(const s of l.
18
+ children)for(const i of s.children)n(i.children)},o=a=>{if(a.variant!=="ordered")return;let l;const s=a.numberingChainId;if(s){const i=r.get(s);l=i&&a.startNumber===void 0?i:p(a.startNumber),r.set(s,l)}else
19
+ l=p(a.startNumber);t.set(a.id,{counters:{...l.counters},start:l.start});for(const i of a.children)m(l.counters,l.start,i.indentLevel??0)};return n(e),t}function k(e){return Math.max(e.counters.level0+
20
+ 1,e.start)}const C=new WeakMap;function R(e){let t=C.get(e);return t||(t=N(e),C.set(e,t)),t}function y(e){return p(e.startNumber)}function T(e,t){for(let r=0;r<t.length;r++){const n=t[r];if(!(n.type!==
21
+ "list"||n.variant!=="ordered"||n.numberingChainId||!n.startNumber||n.startNumber<=1))for(let o=r-1;o>=0;o--){const a=t[o];if(a.type!=="list")continue;if(a.variant!=="ordered")break;const l=b(t.slice(0,
22
+ r)).get(a.id)??y(a),s={...l.counters};for(const i of a.children)m(s,l.start,i.indentLevel??0);if(Math.max(s.level0+1,l.start)===n.startNumber){const i=a.numberingChainId??(a.numberingChainId=e());n.numberingChainId=
23
+ i,delete n.startNumber}break}}}export{N as a,b,k as e,T as i,m as n,L as o,x as p,R as r,y as s};
@@ -0,0 +1,57 @@
1
+ import{a_ as k,b0 as y,aR as b,aK as $,b1 as w,b2 as M,b3 as T,b4 as I,a as u,b5 as _}from"./engine-LMUnxdm2.js";import{b as j}from"./TableGrid-DbroRucl.js";import{a as C,e as v,i as N}from"./ListNumbering-Qlu6AuRZ.js";
2
+ class L{static toMarkdown(e){if(!e||e.type!=="doc"||!e.children)return"";this.exportListNumbering=C(e);const n=[];for(const t of e.children){if(t.type==="header-footer"||t.type==="footnote")continue;if(t.
3
+ type==="toc"){const a=this.tocToMarkdown(t,e);a!==null&&n.push(a);continue}const s=this.blockToMarkdown(t);s!==null&&n.push(s)}const i=[...e.notes??[],...e.children.filter(t=>t.type==="footnote")];if(i.
4
+ length>0){const t=new Map,s=c=>{if(!c||typeof c!="object")return;if(Array.isArray(c)){c.forEach(s);return}const o=c;o.type!=="footnote"&&(o.marks?.footnoteRef&&!t.has(o.marks.footnoteRef)&&t.set(o.marks.
5
+ footnoteRef,o.text??""),s(o.children))};s(e.children.filter(c=>c.type!=="footnote"));let a=t.size;for(const c of i){const o=t.get(c.id)||String(a+=1),r=[];c.children.forEach((h,l)=>{const d=this.blockToMarkdown(
6
+ h)??"";l===0?r.push(`[^${o}]: ${d}`):r.push(d.split(`
7
+ `).map(p=>` ${p}`).join(`
8
+ `))}),n.push(r.join(`
9
+
10
+ `))}}return n.join(`
11
+
12
+ `)}static fromInlineMarkdown(e){return k(this.parseInlineContent(e))}static tocToMarkdown(e,n){const i=y(n,b(e));return i.length===0?null:i.map(t=>`${" ".repeat(t.level-1)}${t.text}`).join(`
13
+ `)}static blockToMarkdown(e){switch(e.type){case"paragraph":return $(e)?"---":this.paragraphToMarkdown(e);case"list":return this.listToMarkdown(e);case"table":return this.tableToMarkdown(e);case"image":
14
+ return this.imageToMarkdown(e);case"code":return this.codeBlockToMarkdown(e);case"math":return this.mathBlockToMarkdown(e);case"placeholder":return null;default:return null}}static paragraphToMarkdown(e){
15
+ const n=this.inlineNodesToMarkdown(e.children);return e.heading?`${"#".repeat(e.heading)} ${n}`:n}static inlineNodesToMarkdown(e){return this.coalesceMarkdownRuns(e).map(n=>this.textNodeToMarkdown(n)).
16
+ join("")}static markdownMarksKey(e){const n=e.marks||{};return JSON.stringify([!!n.code,!!n.latex,!!n.bold,!!n.italic,!!n.strikethrough,n.link||null])}static coalesceMarkdownRuns(e){const n=[];let i=null;
17
+ for(const t of e){const s=t.type==="text"&&!t.marks?.footnoteRef?this.markdownMarksKey(t):null,a=n[n.length-1];s!==null&&s===i&&a?n[n.length-1]={...a,text:a.text+t.text}:n.push(t),i=s}return n}static textNodeToMarkdown(e){
18
+ if(e.marks?.footnoteRef)return`[^${e.text}]`;let n=e.text;return n=n.replace(/\\/g,"\\\\"),e.marks&&(e.marks.code?n=`\`${n.replace(/`/g,"\\`")}\``:e.marks.latex?n=`$${n}$`:(e.marks.bold&&(n=`**${n}**`),
19
+ e.marks.italic&&(n=`*${n}*`),e.marks.strikethrough&&(n=`~~${n}~~`)),e.marks.link&&(n=`[${n}](${e.marks.link})`)),n}static listToMarkdown(e){const n=[],i=this.exportListNumbering?.get(e.id);let t=i?v(i):
20
+ e.startNumber??1;for(const s of e.children){if(s.type!=="list-item")continue;const a=" ".repeat(s.indentLevel??0),c=this.inlineNodesToMarkdown(s.children);let o;e.variant==="ordered"?(o=`${t}.`,t++):
21
+ e.variant==="todo"?o=s.checked?"- [x]":"- [ ]":o="-",n.push(`${a}${o} ${c}`)}return n.join(`
22
+ `)}static tableToMarkdown(e){if(!e.children||e.children.length===0)return"";const n=j(e),i=[];for(let t=0;t<n.rows;t++){const s=[];for(let a=0;a<n.cols;a++){const c=n.occupancy[t][a];if(!c||c.row!==t||
23
+ c.col!==a){s.push("");continue}const o=c.cell.children.map(r=>r.type==="paragraph"?this.inlineNodesToMarkdown(r.children):r.type==="code"?`\`${r.content||""}\``:"").join(" ");s.push(o)}if(i.push(`| ${s.
24
+ join(" | ")} |`),t===0){const a=s.map(()=>"---").join(" | ");i.push(`| ${a} |`)}}return i.join(`
25
+ `)}static imageToMarkdown(e){return`![${e.alt||""}](${e.src})`}static codeBlockToMarkdown(e){const n=e.language||"",i=e.content||"";return`\`\`\`${n}
26
+ ${i}
27
+ \`\`\``}static mathBlockToMarkdown(e){return`$$
28
+ ${e.content||""}
29
+ $$`}static fromMarkdown(e){const n=e.split(`
30
+ `),i=[];let t=0;for(;t<n.length;){const s=n[t];if(s.trim()===""){t++;continue}if(s.trim().startsWith("```")){const l=this.parseCodeBlock(n,t);i.push(l.block),t=l.nextIndex;continue}if(s.trim().startsWith(
31
+ "$$")){const l=this.parseMathBlock(n,t);i.push(l.block),t=l.nextIndex;continue}if(s.trim().startsWith("|")&&s.trim().endsWith("|")){const l=this.parseTable(n,t);l.block&&i.push(l.block),t=l.nextIndex;
32
+ continue}const a=s.match(/^\[\^([^\]]+)\]:\s?(.*)$/);if(a){const l=a[1],d=[k(this.parseInlineContent(a[2]??""))];for(t++;t<n.length;){const p=n[t];if(p.trim()===""){const f=n[t+1];if(f!==void 0&&/^ {4}/.
33
+ test(f)){t++;continue}break}if(!/^ {4}/.test(p))break;d.push(k(this.parseInlineContent(p.slice(4)))),t++}w(d),i.push({type:"footnote",id:`mdfn-${l}`,children:d,...M(l)==="endnote"?{noteKind:"endnote"}:
34
+ {}});continue}const c=T(s,"markdown");if(c){i.push(I(_[c])),t++;continue}if(this.isListItem(s)){const l=this.parseList(n,t);i.push(l.block),t=l.nextIndex;continue}const o=s.trim().match(/^!\[([^\]]*)\]\(([^)]+)\)$/);
35
+ if(o){i.push({type:"image",id:u(),src:o[2],alt:o[1],width:400,height:300}),t++;continue}const r=s.match(/^(#{1,6})\s+(.*)$/);if(r){const l=r[1].length,d=r[2],p=k(this.parseInlineContent(d));p.heading=
36
+ l,i.push(p),t++;continue}const h=k(this.parseInlineContent(s));i.push(h),t++}return N(u,i),{type:"doc",children:i.length>0?i:[k()]}}static isListItem(e){const n=e.trimStart();return!!(/^[-*+]\s/.test(
37
+ n)||/^\d+\.\s/.test(n)||/^[-*+]\s\[[x ]\]\s/i.test(n))}static parseList(e,n){const i=[];let t=n,s="unordered",a=1,c=!0;for(;t<e.length;){const o=e[t];if(o.trim()===""||!this.isListItem(o))break;const r=o.
38
+ match(/^(\s*)/),h=r?r[1].length:0,l=h===0?0:Math.max(1,Math.floor(h/2)),d=o.trimStart();let p,f;const m=d.match(/^[-*+]\s\[([x ])\]\s(.*)$/i);if(m)c&&(s="todo"),f=m[1].toLowerCase()==="x",p=m[2];else if(/^\d+\.\s/.
39
+ test(d)){const g=d.match(/^(\d+)\.\s(.*)$/);g?(c&&(s="ordered",a=parseInt(g[1],10)),p=g[2]):p=d}else{const g=d.match(/^[-*+]\s(.*)$/);p=g?g[1]:d}const x={type:"list-item",id:u(),children:this.parseInlineContent(
40
+ p),indentLevel:l};f!==void 0&&(x.checked=f),i.push(x),c=!1,t++}return{block:{type:"list",id:u(),variant:s,children:i,startNumber:s==="ordered"?a:void 0},nextIndex:t}}static parseCodeBlock(e,n){const i=e[n].
41
+ trim().slice(3).trim(),t=[];let s=n+1;for(;s<e.length;){const a=e[s];if(a.trim()==="```"){s++;break}t.push(a),s++}return{block:{type:"code",id:u(),content:t.join(`
42
+ `),language:i||void 0},nextIndex:s}}static parseMathBlock(e,n){const i=[];let t=n+1;for(;t<e.length;){const a=e[t];if(a.trim()==="$$"){t++;break}i.push(a),t++}const s=i.join(`
43
+ `).replace(/\\\\/g,"\\");return{block:{type:"math",id:u(),content:s},nextIndex:t}}static parseTable(e,n){const i=[];let t=n;for(;t<e.length;){const h=e[t].trim();if(!h.startsWith("|")||!h.endsWith("|"))
44
+ break;i.push(h),t++}if(i.length<2)return{block:null,nextIndex:t};const s=i[1];if(!/^\|[\s\-:|]+\|$/.test(s))return{block:null,nextIndex:t};const a=[],c=!0;for(let h=0;h<i.length;h++){if(h===1)continue;
45
+ const l=i[h].slice(1,-1).split("|").map(d=>d.trim()).map(d=>({type:"table-cell",id:u(),children:[k(this.parseInlineContent(d))]}));a.push({type:"table-row",id:u(),children:l})}const o=a[0]?.children.length||
46
+ 1,r=Array(o).fill(100/o);return{block:{type:"table",id:u(),children:a,columnWidths:r,hasHeader:c},nextIndex:t}}static parseInlineContent(e){const n=[],i=[{regex:/\[\^([^\]]+)\]/g,type:"footnoteref"},{
47
+ regex:/!\[([^\]]*)\]\(([^)]+)\)/g,type:"image"},{regex:/\[([^\]]+)\]\(([^)]+)\)/g,type:"link"},{regex:/\*\*\*([^*]+)\*\*\*/g,type:"bolditalic"},{regex:/\*\*([^*]+)\*\*/g,type:"bold"},{regex:/\*([^*]+)\*/g,
48
+ type:"italic"},{regex:/(^|[^A-Za-z0-9_])___([^_]+)___(?![A-Za-z0-9_])/g,type:"bolditalic",underscore:!0},{regex:/(^|[^A-Za-z0-9_])__([^_]+)__(?![A-Za-z0-9_])/g,type:"bold",underscore:!0},{regex:/(^|[^A-Za-z0-9_])_([^_]+)_(?![A-Za-z0-9_])/g,
49
+ type:"italic",underscore:!0},{regex:/~~([^~]+)~~/g,type:"strikethrough"},{regex:/`([^`]+)`/g,type:"code"},{regex:/\$([^$]+)\$/g,type:"latex"}],t=[];for(const o of i){o.regex.lastIndex=0;let r;for(;(r=
50
+ o.regex.exec(e))!==null;)if(o.type==="link")t.push({index:r.index,length:r[0].length,type:o.type,content:r[1],url:r[2]});else if(o.type==="image")t.push({index:r.index,length:r[0].length,type:o.type,content:r[1]||
51
+ "[image]",url:r[2]});else if(o.type==="bolditalic"||o.type==="bold"||o.type==="italic")if("underscore"in o&&o.underscore){const h=r[1];t.push({index:r.index+h.length,length:r[0].length-h.length,type:o.
52
+ type,content:r[2]})}else t.push({index:r.index,length:r[0].length,type:o.type,content:r[1]});else t.push({index:r.index,length:r[0].length,type:o.type,content:r[1]})}t.sort((o,r)=>o.index-r.index);const s=[];
53
+ let a=0;for(const o of t)o.index>=a&&(s.push(o),a=o.index+o.length);let c=0;for(const o of s){if(o.index>c){const h=e.slice(c,o.index);h&&n.push({type:"text",text:h,marks:{}})}const r={type:"text",text:o.
54
+ content,marks:{}};switch(o.type){case"bold":r.marks={bold:!0};break;case"italic":r.marks={italic:!0};break;case"bolditalic":r.marks={bold:!0,italic:!0};break;case"strikethrough":r.marks={strikethrough:!0};
55
+ break;case"code":r.marks={code:!0};break;case"latex":r.text=o.content.replace(/\\\\/g,"\\"),r.marks={latex:!0};break;case"link":r.marks={link:o.url};break;case"image":r.text=o.content||"[image]",r.marks=
56
+ {link:o.url};break;case"footnoteref":r.text=o.content,r.marks={footnoteRef:`mdfn-${o.content}`,superscript:!0};break}n.push(r),c=o.index+o.length}if(c<e.length){const o=e.slice(c);o&&n.push({type:"tex\
57
+ t",text:o,marks:{}})}return n.length===0&&n.push({type:"text",text:e,marks:{}}),n}}export{L as MarkdownConverter};
@@ -0,0 +1,68 @@
1
+ const D="https://revise.io";let U=D;const G=new Set;function l(e){return`${U}/${e.replace(/^\/+/,"")}`}function V(e){G.add(e)}let x=null,K=null;async function X(){return x||(K||(K=import("./katex-DWj8TvwO.js").
2
+ then(e=>(x=e.default,e.default))),K)}function H(){return x}let v=null,S=null;async function P(){return v||(S||(S=import("./bundle.min-DRpfgV69.js").then(e=>e.b).then(e=>(v=e.MathMLToLaTeX,e.MathMLToLaTeX))),
3
+ S)}function L(){return v}function J(e){return/<math[\s>]/i.test(e)}const d=new Map,c=new Map,m=new Map,Q=new Set,b=new Map,k=[0,1e3,5e3,15e3],A=new Map;let $=!1;function C(){$||($=!0,requestAnimationFrame(
4
+ ()=>{$=!1;for(const[e,t]of m)d.set(e,t),c.delete(e),t.provisional?Y(e,t):b.delete(e);m.clear();for(const e of Q)try{e()}catch(t){console.error("Math render callback error:",t)}}))}function R(e,t,n){return`${t?
5
+ "block":"inline"}:${n}:${e}`}const g="#000000";function z(e,t=!0,n=g){if(!e||e.trim()==="")return{image:null,width:100,height:40,contentWidth:80,contentHeight:20,loading:!1,error:void 0};const a=R(e,t,
6
+ n);return d.get(a)||(c.has(a)||F(a,e,t,n),{image:null,width:200,height:t?80:60,contentWidth:180,contentHeight:t?60:40,loading:!0})}function F(e,t,n,a){const i=ee(t,n,a);c.set(e,i),A.set(e,{content:t,displayMode:n,
7
+ color:a}),i.then(r=>{m.set(e,r),C()}).catch(r=>{const o={image:null,width:100,height:40,contentWidth:80,contentHeight:20,loading:!1,error:r instanceof Error?r.message:"Render failed"};m.set(e,o),C()})}
8
+ function Y(e,t){const n=A.get(e),a=b.get(e)??0;if(!n||a>=k.length)return;b.set(e,a+1);const i=k[a];(async()=>(i>0&&await new Promise(r=>setTimeout(r,i)),await O(),!(d.get(e)!==t||c.has(e))&&F(e,n.content,
9
+ n.displayMode,n.color)))()}function W(e,t,n=g){const a=R(e,t,n),i=d.get(a)||m.get(a);return!i||!i.svg?null:{svg:i.svg,width:i.width,height:i.height,contentWidth:i.contentWidth,contentHeight:i.contentHeight}}
10
+ async function I(e,t,n=g){const a=R(e,t,n);if(c.has(a)){await c.get(a);return}if(!(d.has(a)||m.has(a))&&z(e,t,n).loading){const i=c.get(a);i&&await i}}function Z(e){if(!e.includes(`
11
+ `)||["align","aligned","gather","gathered","split","cases","matrix","pmatrix","bmatrix","array"].some(n=>e.includes(`\\begin{${n}}`)||e.includes(`\\begin{${n}*}`)))return e;const t=e.split(`
12
+ `).map(n=>n.trim()).filter(n=>n.length>0);return t.length<=1?e:`\\begin{gathered}
13
+ ${t.join(` \\\\
14
+ `)}
15
+ \\end{gathered}`}async function ee(e,t,n=g){try{const a=Z(e),i=(await X()).renderToString(a,{displayMode:t,throwOnError:!1,errorColor:"#ef4444",trust:!1,strict:!1}),r=await O(),{width:o,height:s,contentWidth:h,
16
+ contentHeight:u}=await ne(i),{css:_,complete:B}=await le(),E=se(i,o,s,_,n);return{image:await ce(E,o,s),width:o,height:s,contentWidth:h,contentHeight:u,loading:!1,svg:E,provisional:T()&&(!r||!B)}}catch(a){
17
+ return console.error("Math render error:",a),{image:null,width:100,height:40,contentWidth:80,contentHeight:20,loading:!1,error:a instanceof Error?a.message:"Unknown error"}}}const p=10,j=.85,q=["16px \
18
+ KaTeX_Main","bold 16px KaTeX_Main","italic 16px KaTeX_Main","italic 16px KaTeX_Math","16px KaTeX_Size1","16px KaTeX_Size2","16px KaTeX_Size3","16px KaTeX_Size4","16px KaTeX_AMS"],te=[...new Set(q.map(
19
+ e=>e.split(" ").pop()))];function T(){const e=typeof document<"u"?document.fonts:void 0;return!!e&&typeof e.forEach=="function"}function N(){if(!T())return!0;const e=document.fonts,t=new Set;return e.
20
+ forEach(n=>{n.status==="loaded"&&t.add(n.family.replace(/^["']|["']$/g,""))}),te.every(n=>t.has(n))}let w=null;function O(){if(w)return w;if(!T())return Promise.resolve(!0);const e=(async()=>{if(!await re())
21
+ return!1;if(N())return!0;try{await Promise.all(q.map(n=>document.fonts.load(n).catch(()=>[]))),await document.fonts.ready,await new Promise(n=>requestAnimationFrame(n))}catch{}return N()})();w=e;const t=()=>{
22
+ w===e&&(w=null)};return e.then(n=>!n&&t(),t),e}async function ne(e){const t=document.createElement("div");return t.style.cssText=`
23
+ position: absolute;
24
+ visibility: hidden;
25
+ pointer-events: none;
26
+ top: -9999px;
27
+ left: -9999px;
28
+ font-size: 16px;
29
+ line-height: 1.2;
30
+ font-family: KaTeX_Main, 'Times New Roman', serif;
31
+ `,t.innerHTML=e,document.body.appendChild(t),T()&&await document.fonts.ready,new Promise(n=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const a=t.querySelector(".katex")||t,i=a.getBoundingClientRect(),
32
+ r=a.scrollWidth,o=a.scrollHeight,s=Math.ceil(Math.max(i.width,r)),h=Math.ceil(Math.max(i.height,o)),u=s+p*2,_=h+p*2;document.body.removeChild(t),n({width:Math.max(u,20),height:Math.max(_,20),contentWidth:Math.
33
+ max(s,10),contentHeight:Math.max(h,10)})})})})}let f=null;const ae=1e4;let y=null;const M=new Map;async function ie(e){if(M.has(e))return M.get(e);const t=(async()=>{try{const n=await fetch(e);if(!n.ok)
34
+ throw new Error(`HTTP ${n.status}`);const a=await n.blob();return new Promise((i,r)=>{const o=new FileReader;o.onload=()=>{i(o.result)},o.onerror=r,o.readAsDataURL(a)})}catch(n){return console.warn(`F\
35
+ ailed to load font: ${e}`,n),M.delete(e),""}})();return M.set(e,t),t}async function oe(){const e=[{family:"KaTeX_Main",weight:"normal",style:"normal",file:l("fonts/KaTeX_Main-Regular.woff2")},{family:"\
36
+ KaTeX_Main",weight:"bold",style:"normal",file:l("fonts/KaTeX_Main-Bold.woff2")},{family:"KaTeX_Main",weight:"normal",style:"italic",file:l("fonts/KaTeX_Main-Italic.woff2")},{family:"KaTeX_Math",weight:"\
37
+ normal",style:"italic",file:l("fonts/KaTeX_Math-Italic.woff2")},{family:"KaTeX_Size1",weight:"normal",style:"normal",file:l("fonts/KaTeX_Size1-Regular.woff2")},{family:"KaTeX_Size2",weight:"normal",style:"\
38
+ normal",file:l("fonts/KaTeX_Size2-Regular.woff2")},{family:"KaTeX_Size3",weight:"normal",style:"normal",file:l("fonts/KaTeX_Size3-Regular.woff2")},{family:"KaTeX_Size4",weight:"normal",style:"normal",
39
+ file:l("fonts/KaTeX_Size4-Regular.woff2")},{family:"KaTeX_AMS",weight:"normal",style:"normal",file:l("fonts/KaTeX_AMS-Regular.woff2")},{family:"KaTeX_Caligraphic",weight:"normal",style:"normal",file:l(
40
+ "fonts/KaTeX_Caligraphic-Regular.woff2")},{family:"KaTeX_Fraktur",weight:"normal",style:"normal",file:l("fonts/KaTeX_Fraktur-Regular.woff2")},{family:"KaTeX_SansSerif",weight:"normal",style:"normal",file:l(
41
+ "fonts/KaTeX_SansSerif-Regular.woff2")},{family:"KaTeX_Script",weight:"normal",style:"normal",file:l("fonts/KaTeX_Script-Regular.woff2")},{family:"KaTeX_Typewriter",weight:"normal",style:"normal",file:l(
42
+ "fonts/KaTeX_Typewriter-Regular.woff2")}];let t=!0;return{css:(await Promise.all(e.map(async n=>{const a=await ie(n.file);return a?`@font-face {
43
+ font-family: '${n.family}';
44
+ font-weight: ${n.weight};
45
+ font-style: ${n.style};
46
+ src: url('${a}') format('woff2');
47
+ }`:(t=!1,"")}))).filter(Boolean).join(`
48
+ `),complete:t}}function re(){if(f)return f;const e=document.querySelector('link[href*="katex"]');if(e?.sheet)return f=Promise.resolve(!0),f;let t=e;t||(t=document.createElement("link"),t.rel="styleshe\
49
+ et",t.href=l("katex.min.css"));const n=t,a=new Promise(i=>{const r=u=>{window.clearTimeout(h),n.removeEventListener("load",o),n.removeEventListener("error",s),!u&&f===a&&(f=null,n!==e&&n.remove()),i(u)},
50
+ o=()=>r(!0),s=()=>r(!1),h=window.setTimeout(()=>r(!!n.sheet),ae);n.addEventListener("load",o),n.addEventListener("error",s)});return f=a,e||document.head.appendChild(t),a}async function le(){if(y)return y;
51
+ const e=(async()=>{try{const[t,n]=await Promise.all([fetch(l("katex.min.css")),oe()]);if(!t.ok)throw new Error(`HTTP ${t.status}`);let a=await t.text();return a=a.replace(/@font-face\s*\{[^}]*\}/g,""),
52
+ {css:n.css+`
53
+ `+a,complete:n.complete}}catch(t){return console.warn("Failed to fetch KaTeX CSS:",t),{css:"",complete:!1}}})();return y=e,e.then(({complete:t})=>{!t&&y===e&&(y=null)}),e}function se(e,t,n,a,i=g){return`\
54
+ <svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${n}" style="overflow: visible;">
55
+ <defs>
56
+ <style type="text/css">
57
+ ${a}
58
+ </style>
59
+ </defs>
60
+ <foreignObject width="100%" height="100%" style="overflow: visible;">
61
+ <div xmlns="http://www.w3.org/1999/xhtml" style="width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1.2; font-family: KaTeX_Main,\
62
+ 'Times New Roman', serif; overflow: visible; box-sizing: border-box; color: ${i};">
63
+ ${e}
64
+ </div>
65
+ </foreignObject>
66
+ </svg>`}function ce(e,t,n){return new Promise((a,i)=>{const r="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(e),o=new Image;o.width=t,o.height=n,o.onload=()=>{a(o)},o.onerror=()=>{i(new Error(
67
+ "Failed to load math SVG as image"))},o.src=r})}const fe=Object.freeze(Object.defineProperty({__proto__:null,INLINE_MATH_SCALE:j,MATH_PADDING:p,ensureMathRendered:I,getCachedMathSvg:W,getKatexSync:H,getMathMlToLatexSync:L,
68
+ getMathRender:z,htmlHasMathMl:J,loadKatex:X,loadMathMlToLatex:P},Symbol.toStringTag,{value:"Module"}));export{j as I,p as M,L as a,X as b,H as c,W as d,I as e,fe as f,z as g,P as l,V as o,l as r};