revise 2.0.1 → 2.1.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/README.md +4 -1
  3. package/assets/historyMaterializeWorker-C4uxcZEh.js +607 -3
  4. package/backend.js +3 -1
  5. package/chunks/{AgentPageRenderer-BIf_Fza8.js → AgentPageRenderer-BFB0arQL.js} +1 -1
  6. package/chunks/{AgentPageRenderer-DT9sNxEn.js → AgentPageRenderer-Dn6SaRjW.js} +1 -1
  7. package/chunks/AttachmentDocumentImporter-BHDJAdky.js +1 -0
  8. package/chunks/AttachmentDocumentImporter-CxOZqzt1.js +1 -0
  9. package/chunks/BidiText-C8PBPSQY.js +160 -0
  10. package/chunks/ColorParserFull-BKH72fK8.js +446 -1
  11. package/chunks/DocumentMutator-4vBJQ74L.js +31 -0
  12. package/chunks/{DocumentScrubber-DrgzBlx4.js → DocumentScrubber-COPepQKE.js} +1 -1
  13. package/chunks/{DocumentScrubber-W0EfGmL-.js → DocumentScrubber-Cf_QqHhF.js} +1 -1
  14. package/chunks/DocumentScrubber-DS4LFDKS.js +18 -0
  15. package/chunks/DocumentStylesheet-byN5dtC6.js +7 -1
  16. package/chunks/DocxConverter-BCEB7jWY.js +1083 -0
  17. package/chunks/{DocxConverter-CGYMfz-j.js → DocxConverter-C3NflpDr.js} +2 -2
  18. package/chunks/{DocxConverter-DabDLfsu.js → DocxConverter-D9ZNn4nX.js} +2 -2
  19. package/chunks/{DocxGraft-B6W7fbh4.js → DocxGraft-Ba63IRP4.js} +1 -1
  20. package/chunks/DocxGraft-DjERgl-z.js +7 -0
  21. package/chunks/{DocxGraft-Cj7v78BO.js → DocxGraft-cYlmw4Ab.js} +1 -1
  22. package/chunks/{FileImporter-CjUX2S4s.js → FileImporter-CHXj9sNX.js} +1 -1
  23. package/chunks/{FileImporter-DtkbI6rF.js → FileImporter-DetvRoJc.js} +1 -1
  24. package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -1
  25. package/chunks/HtmlConverter-Sd9t49vH.js +267 -0
  26. package/chunks/ListNumbering-Qlu6AuRZ.js +23 -1
  27. package/chunks/MarkdownConverter-BdJgh8xt.js +57 -0
  28. package/chunks/MathRenderer-B0Y1h1JU.js +36 -7
  29. package/chunks/{OdtConverter-Cnda9T0q.js → OdtConverter-BKtyx012.js} +1 -1
  30. package/chunks/{OdtConverter-WdwwXKVM.js → OdtConverter-Ce9j8PRt.js} +1 -1
  31. package/chunks/OdtConverter-D709qfYb.js +31 -0
  32. package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
  33. package/chunks/PdfConverter-BA8XLTAM.js +21 -0
  34. package/chunks/PdfConverter-CkDClffR.js +438 -0
  35. package/chunks/PdfConverter-CxLxd-LJ.js +21 -0
  36. package/chunks/{PdfImportService-Dj1-3L2B.js → PdfImportService-CQCgsRX1.js} +2 -2
  37. package/chunks/{PdfImportService-OE9G383I.js → PdfImportService-xl7fstr-.js} +2 -2
  38. package/chunks/{RtfConverter-D-oqPWNl.js → RtfConverter-BZOnMUGH.js} +1 -1
  39. package/chunks/{RtfConverter-D9zhE07-.js → RtfConverter-Bs81AfXt.js} +1 -1
  40. package/chunks/RtfConverter-DfuE5olb.js +45 -0
  41. package/chunks/TableBorders-Cdkc62cX.js +30 -0
  42. package/chunks/TableGrid-DbroRucl.js +12 -0
  43. package/chunks/TextFileDecoder--rsVs3NR.js +9 -2
  44. package/chunks/{TxtConverter-BYazsp6P.js → TxtConverter-C-oiFUAp.js} +5 -2
  45. package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
  46. package/chunks/XmlConverter-C0FnrVYk.js +70 -0
  47. package/chunks/XmlConverter-CQa8baOF.js +2 -0
  48. package/chunks/XmlConverter-DjEYaIyf.js +2 -0
  49. package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -1
  50. package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -1
  51. package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +1 -1
  52. package/chunks/ar-BdmGnaKI.js +14 -0
  53. package/chunks/backend-BIhAX-Gi.js +484 -0
  54. package/chunks/base64-Qx0OzT4p.js +196 -0
  55. package/chunks/browser-module-CFmqfGkE.js +1791 -3
  56. package/chunks/{browser-module-BbaxnHNK.js → browser-module-CYGCfEyx.js} +1 -1
  57. package/chunks/{browser-module-D2ixluMg.js → browser-module-DgvTMhpA.js} +1 -1
  58. package/chunks/bundle.min-DRpfgV69.js +779 -5
  59. package/chunks/capture-BAJ2in5p.js +9 -0
  60. package/chunks/carrier-C5VZRMxZ.js +6 -0
  61. package/chunks/de-DldIXRFC.js +14 -0
  62. package/chunks/es-CnyKlSPK.js +14 -0
  63. package/chunks/footnoteFlatten-Bekh8ZfM.js +6 -0
  64. package/chunks/graftExport-CRRm1Oe_.js +82 -0
  65. package/chunks/html2canvas.esm-CntiHiYW.js +994 -2
  66. package/chunks/index-B1idHquf.js +1094 -0
  67. package/chunks/index-BWdRWxoH.js +1796 -13
  68. package/chunks/index-C-4H81OE.js +378 -0
  69. package/chunks/index-iZC8xN0t.js +378 -0
  70. package/chunks/{index.es-mTU7Sl3w.js → index.es-Bwt05m_b.js} +1 -1
  71. package/chunks/index.es-CI0QPo8w.js +780 -5
  72. package/chunks/{index.es-B97tjxvW.js → index.es-DAQD57G4.js} +1 -1
  73. package/chunks/{jspdf.es.min-Mykp4BZO.js → jspdf.es.min-CnNRolk9.js} +1 -1
  74. package/chunks/jspdf.es.min-DU74zN8b.js +1747 -32
  75. package/chunks/{jspdf.es.min-DGiD4mlU.js → jspdf.es.min-DlTF8uTw.js} +1 -1
  76. package/chunks/jszip.min-CPW0h1Kx.js +476 -2
  77. package/chunks/katex-DWj8TvwO.js +1209 -8
  78. package/chunks/pdf-BLWDCiFF.js +1826 -10
  79. package/chunks/{pseudoLocale-C90lXrPg.js → pseudoLocale-BoJwIubw.js} +1 -1
  80. package/chunks/{pseudoLocale-UA_TkGrH.js → pseudoLocale-DWAm7Dpa.js} +1 -1
  81. package/chunks/purify.es-BwLardii.js +107 -2
  82. package/chunks/serverDocumentSession-DASrQAbW.js +15 -0
  83. package/chunks/signatures-CBF7NZUy.js +17 -0
  84. package/chunks/tree-sitter-D6zWWUMP.js +1 -1
  85. package/chunks/web-tree-sitter-BXGZGnNj.js +2 -1
  86. package/full.js +1 -1
  87. package/index.d.ts +31 -12
  88. package/index.js +1 -1
  89. package/package.json +1 -1
  90. package/root.js +2 -2
  91. package/serverToolContract.d.ts +21 -3
  92. package/serverToolInputs.generated.d.ts +23 -2
  93. package/style.css +1 -1
  94. package/chunks/AttachmentDocumentImporter-BUavYRxO.js +0 -1
  95. package/chunks/AttachmentDocumentImporter-DGwfDJSH.js +0 -1
  96. package/chunks/BidiText-D7LYTAUL.js +0 -1
  97. package/chunks/DocumentMutator-CjN7Kk-X.js +0 -31
  98. package/chunks/DocumentScrubber-C9ZZEcYW.js +0 -1
  99. package/chunks/DocxConverter-Be3uPNcD.js +0 -11
  100. package/chunks/DocxGraft-Duvo2cpy.js +0 -1
  101. package/chunks/HtmlConverter-ikXImzTY.js +0 -61
  102. package/chunks/MarkdownConverter-CFrcLyO_.js +0 -17
  103. package/chunks/OdtConverter-BFT_P8SI.js +0 -1
  104. package/chunks/PdfConverter-D7UM58vc.js +0 -21
  105. package/chunks/PdfConverter-TB-QPw29.js +0 -21
  106. package/chunks/PdfConverter-wVP63986.js +0 -21
  107. package/chunks/RtfConverter-DZgwU-_R.js +0 -14
  108. package/chunks/TableBorders-BorZS8aZ.js +0 -1
  109. package/chunks/TableGrid-DVWaRZv0.js +0 -1
  110. package/chunks/ar-C8zx2RwP.js +0 -8
  111. package/chunks/backend-MFpDFVrD.js +0 -1
  112. package/chunks/base64-BNMNG-lN.js +0 -1
  113. package/chunks/capture-qC26xmfy.js +0 -1
  114. package/chunks/carrier-BWONvrA7.js +0 -1
  115. package/chunks/de-ByQFqecF.js +0 -8
  116. package/chunks/es-PHpJXv5S.js +0 -8
  117. package/chunks/footnoteFlatten-Bdnn_bz1.js +0 -1
  118. package/chunks/graftExport-CP3h2T88.js +0 -2
  119. package/chunks/index-CjeGoI2g.js +0 -351
  120. package/chunks/index-D7V8zn4w.js +0 -36
  121. package/chunks/index-DyOcu9mD.js +0 -351
  122. package/chunks/serverDocumentSession-CRZSb5SO.js +0 -11
  123. package/chunks/signatures-CsL_TjvW.js +0 -1
@@ -0,0 +1,196 @@
1
+ import{M as $e,m as Ve,N as mt,O as xt,P as Et,E as Xe,F as Ge,Q as Ue,g as fe,R as be,y as ze,T as rt,U as Qe,V as Ze,W as me,X as qe,x as Je,Y as xe,Z as je,_ as ke,$ as Ke,A as ye,z as to}from"./index-B1idHquf.js";
2
+ import{ai as Me,bh as Nt,bs as eo,Z as we,br as oo,a as no,t as ao,r as ro,bd as so,bf as io,aa as lo,bk as co,bl as ee}from"./backend-BIhAX-Gi.js";import{L as go,v as uo,w as ho}from"./BidiText-C8PBPSQY.js";
3
+ import{b as po,c as fo}from"./TableGrid-DbroRucl.js";import{r as bo,t as mo}from"./TableBorders-Cdkc62cX.js";const Ye=48,xo=10;function Ie(o,t,e,a,c){const u=e.availableWidth,s=u/3,p=c??o.children,h=[
4
+ 0,1,2].map(M=>{const w=p[M];if(!w)return Ye;const L=$e(w,t,e,a)+xo;return Math.max(Ye,Math.min(L,u))}),y=[s,s,s],H=h.map((M,w)=>Math.max(0,M-y[w])),b=h.map((M,w)=>Math.max(0,y[w]-M)),f=H.reduce((M,w)=>M+
5
+ w,0),N=b.reduce((M,w)=>M+w,0);if(f>0&&N>0){const M=Math.min(f,N);for(let w=0;w<3;w++)H[w]>0?y[w]+=H[w]/f*M:b[w]>0&&(y[w]-=b[w]/N*M)}return[y[0],y[1],y[2]]}function oe(o){if(o.type!=="paragraph")return{
6
+ keepNext:!1,keepLines:!1,widowControl:!1};const t=o;return{keepNext:t.keepNext??!!t.heading,keepLines:!!t.keepLines,widowControl:t.widowControl!==!1}}const ne=3;function ko(o,t){const e=[];let a=[];for(const c of o)
7
+ a.push(c),c.type==="section-break"&&(e.push({blocks:a,rawSettings:c.layout}),a=[]);return e.push({blocks:a,rawSettings:t}),e}function Be(o,t,e){if(!e)return{...o};const a=we(t,e),{pageWidth:c,pageHeight:u}=no(
8
+ a),s=a.columnCount,p=ao(a.columnGapTwips),h=Math.max(1,c-a.marginLeftPx-a.marginRightPx);return{...o,pageWidth:c,pageHeight:u,pageMargin:a.marginLeftPx,pageMarginTop:a.marginTopPx,pageMarginRight:a.marginRightPx,
9
+ pageMarginBottom:a.marginBottomPx,pageMarginLeft:a.marginLeftPx,availableWidth:fe(h,s,p),columnCount:s,columnGapPx:p,textStartY:a.marginTopPx,hyphenationEnabled:a.hyphenationEnabled,lineNumbering:a.lineNumbering}}
10
+ const yo=32,Mo=co.paddingPx;function wo(o,t,e){const a=Ve(),c=(n,r)=>({doc:o,layout:n,textContext:t,registry:a,blocks:[],fragments:[],currentY:r,currentPage:1,totalHeight:r,pageStep:n.pageless?0:n.pageHeight+
11
+ n.pageSpacing,nextBlockIndex:0,pageBreakListeners:[],suppressTopSpacingForNextBlock:!1}),u=(n,r,g=!1)=>{const l=ko(n,o.pageLayout),i=l.map((X,tt)=>tt===l.length-1?Be(r,o.pageLayout,o.pageLayout):Be(r,
12
+ o.pageLayout,X.rawSettings)),d=i.some(X=>(X.columnCount??1)>1);if(l.length===1&&!d||r.pageless){const X=c(r,Et(r));return r.lineNumbering&&!r.pageless&&(X.lineNumberMarks=[]),X.trackLineExtents=g,Wt({
13
+ state:X,blocks:n,x:mt(r),layoutForLevel:r,suppressTopSpacingForFirstBlock:!0}),X.totalHeight=X.currentY,r.pageless||(X.sectionRuntime={runs:[{blocks:n,rawSettings:o.pageLayout}],layouts:[r],startPageIndexes:[
14
+ 0],sectionStartTops:[0]}),X}const x=[],I=[],k=c(i[0],0);k.blocks=[],k.fragments=[],k.currentY=0,k.totalHeight=0,k.currentPage=1,k.trackLineExtents=g,i.some(X=>X.lineNumbering)&&(k.lineNumberMarks=[]);
15
+ let P=-1,V=0,Q=null,B=0,Z=!1;const ht=()=>{Z||(Z=!0,console.warn("Column layout projection clamped a fragment outside its pagination window; a column may render overflowing content."))},D=X=>{const tt=X.
16
+ blocks[X.blocks.length-1];return tt?.type==="section-break"?tt:void 0};return l.forEach((X,tt)=>{const _=i[tt],Mt=tt>0?D(l[tt-1]):void 0,et=tt>0&&Mt?.breakType==="continuous",Bt=Xe(et,Q&&{width:Q.pageWidth,
17
+ height:Q.pageHeight},{width:_.pageWidth,height:_.pageHeight}),F=Bt?P:P+1,ot=Bt?V:Q?V+Q.pageHeight+Q.pageSpacing:0,wt=Bt?Ge(B,Ue(_,0),ot,Et(_)):ot+Et(_);_.sectionStartY=ot,_.sectionFirstPageIndex=F,x.push(
18
+ F),I.push(ot);const Tt=Math.max(1,Math.round(_.columnCount??1)),Ot=Math.max(0,_.columnGapPx??eo),pt=fe(_.pageWidth-mt(_)-be(_),Tt,Ot),Gt=Je(pt,Ot),Rt=_.pageHeight+_.pageSpacing,Vt=Et(_),Yt=S=>{const G=new Map,
19
+ nt=U=>{const E=Math.floor(U/Tt),C=U%Tt,at=F+E,ft=E===0?wt-ot:Vt,Ct=xe(_,at),At=_.pageHeight-xt(_)-Ct,St=S?.pageOffset===E?Math.min(At,ft+S.height):At;return{top:U*Rt+ft,bottom:U*Rt+St,full:S?.pageOffset!==
20
+ E&&ft<=Vt&&Ct<=0,pageIndex:E,columnIndex:C,actualContentTop:ot+E*Rt+ft}},v=U=>{let E=G.get(U);return E||(E=nt(U),G.set(U,E)),E};return{at:v,indexForY:U=>{if(v(0).top>U+rt)return 0;let E=1;for(;v(E).top<=
21
+ U+rt;)E*=2;let C=E>>1,at=C;for(;C<=E;){const ft=C+E>>1;v(ft).top<=U+rt?(at=ft,C=ft+1):E=ft-1}return at}}},Ee=new Map,ie=(S,G)=>{const nt={..._,sectionStartY:0,sectionFirstPageIndex:0,availableWidth:pt,
22
+ columnCount:Tt,columnGapPx:Ot,flowWindows:S},v=c(nt,S.at(0).top);v.nextBlockIndex=k.nextBlockIndex,v.trackLineExtents=g,v.boundsMemo=Ee,_.lineNumbering&&(v.lineNumberMarks=[]);const U=G?.resume;if(U){
23
+ const{snapshot:C,from:at}=U;v.blocks=at.blocks.slice(0,C.blocksLen),v.fragments=at.fragments.slice(0,C.fragmentsLen),v.currentY=C.currentY,v.currentPage=C.currentPage,v.totalHeight=C.totalHeight,v.nextBlockIndex=
24
+ C.nextBlockIndex,v.suppressTopSpacingForNextBlock=C.suppressTopSpacingForNextBlock,v.lastLineTail=C.lastLineTail,v.lineNumberMarks&&at.lineNumberMarks&&(v.lineNumberMarks=at.lineNumberMarks.slice(0,C.
25
+ lineNumberMarksLen))}const E=G?.recordSnapshots;return Wt({state:v,blocks:U?X.blocks.slice(U.snapshot.blockCount):X.blocks,x:mt(_),layoutForLevel:nt,suppressTopSpacingForFirstBlock:!U,onBlockLaidOut:E?
26
+ C=>{E.push({blockCount:C+1,blocksLen:v.blocks.length,fragmentsLen:v.fragments.length,currentY:v.currentY,currentPage:v.currentPage,totalHeight:v.totalHeight,nextBlockIndex:v.nextBlockIndex,suppressTopSpacingForNextBlock:v.
27
+ suppressTopSpacingForNextBlock,lastLineTail:v.lastLineTail,lineNumberMarksLen:v.lineNumberMarks?.length??0})}:void 0}),v.totalHeight=v.currentY,v},jt=(S,G)=>S.indexForY(Math.max(G.currentY-rt,S.at(0).
28
+ top)),Oe=D(X)?.breakType==="continuous",le=ze(Tt,Oe)&&X.blocks.length>0;let Ft=Yt();const ce=[];let Lt=ie(Ft,le?{recordSnapshots:ce}:void 0),Kt=jt(Ft,Lt);if(le){const S=Ft.at(Kt).pageIndex,G=S*Tt,nt=Ft.
29
+ at(G),v=Math.max(1,nt.bottom-nt.top),U=Ft.at(Math.max(0,G-1)).top;let E;for(const St of ce)if(St.currentY<U-rt)E=St;else break;const C=E?{resume:{snapshot:E,from:Lt}}:void 0;let at=1,ft=Math.ceil(v),Ct=Lt,
30
+ At=Ft;for(let St=0;St<11&&at<=ft;St++){const $t=Math.ceil((at+ft)/2),Qt=Yt({pageOffset:S,height:$t}),pe=ie(Qt,C),_e=jt(Qt,pe);Qt.at(_e).pageIndex<=S?(Ct=pe,At=Qt,ft=$t-1):at=$t+1}Lt=Ct,Ft=At,Kt=jt(Ft,
31
+ Lt)}const Ut=S=>{const G=Ft.indexForY(S),nt=Ft.at(G);return{windowIndex:G,window:nt,xOffset:nt.columnIndex*Gt,y:nt.actualContentTop+Math.max(0,S-nt.top),pageNumber:F+nt.pageIndex+1}},zt=[],ge=new Map;
32
+ for(const S of Lt.fragments){const G=S.bounds.y,nt=G+S.bounds.height,v=S.lineExtents;let U=0,E=G,C=!1;for(;E<nt-rt||!C;){const at=Ut(E),ft=Math.min(nt,at.window.bottom),Ct=Math.max(0,ft-E),At=ft>=nt-rt||
33
+ Ct<=0;Ct<=0&&S.bounds.height>rt&&ht();let St;if(v)for(St=[];U<v.length&&(At||v[U].bottom<=ft+rt);)St.push({charEnd:v[U].charEnd,bottom:at.y+(v[U].bottom-E)}),U+=1;const $t=ge.get(S.blockIndex)??0;if(zt.
34
+ push({...S,fragmentIndex:$t,bounds:{...S.bounds,x:S.bounds.x+at.xOffset,y:at.y,height:Ct>0?Ct:S.bounds.height},pageNumber:at.pageNumber,lineExtents:St&&St.length>0?St:void 0}),ge.set(S.blockIndex,$t+1),
35
+ C=!0,At)break;E=Ft.at(at.windowIndex+1).top}}const te=new Map;for(const S of zt){const G=te.get(S.blockIndex)??[];G.push(S),te.set(S.blockIndex,G)}const Ae=Lt.blocks.map(S=>{const G=te.get(S.blockIndex)??
36
+ [];if(G.length===0){const C=Ut(S.bounds.y);return{...S,bounds:{...S.bounds,x:S.bounds.x+C.xOffset,y:C.y},pageNumber:C.pageNumber}}const nt=Math.min(...G.map(C=>C.bounds.x)),v=Math.min(...G.map(C=>C.bounds.
37
+ y)),U=Math.max(...G.map(C=>C.bounds.x+C.bounds.width)),E=Math.max(...G.map(C=>C.bounds.y+C.bounds.height));return{...S,bounds:{...S.bounds,x:nt,y:v,width:U-nt,height:E-v},pageNumber:G[0].pageNumber}});
38
+ if(k.blocks.push(...Ae),k.fragments.push(...zt),k.nextBlockIndex=Lt.nextBlockIndex,k.lineNumberMarks!==void 0&&Lt.lineNumberMarks)for(const S of Lt.lineNumberMarks){const G=Ut(S.y);k.lineNumberMarks.push(
39
+ {...S,y:G.y,pageNumber:G.pageNumber})}const ue=Ft.at(Kt).pageIndex;P=F+ue,V=ot+ue*Rt,Q=_;const De=P+1,de=zt.filter(S=>S.pageNumber===De).map(S=>S.bounds.y+S.bounds.height),he=Ut(Lt.currentY);B=Math.max(
40
+ he.y,...de.length>0?de:[he.y]),k.currentY=B,k.totalHeight=Math.max(k.totalHeight,B),k.currentPage=Math.max(k.currentPage,P+1),k.layout=_,k.pageStep=Rt}),k.sectionRuntime={runs:l,layouts:i,startPageIndexes:x,
41
+ sectionStartTops:I},k},s=(n,r)=>{const g=n.sectionRuntime;if(!g)return e;let l=g.startPageIndexes.length-1;for(;l>0&&r<g.startPageIndexes[l];)l--;return g.layouts[l]},p=(n,r)=>{const g=n.sectionRuntime;
42
+ if(!g)return r*(e.pageHeight+e.pageSpacing);let l=g.startPageIndexes.length-1;for(;l>0&&r<g.startPageIndexes[l];)l--;const i=g.layouts[l],d=i.pageHeight+i.pageSpacing;return g.sectionStartTops[l]+(r-g.
43
+ startPageIndexes[l])*d},h=(n,r)=>{const g=n.sectionRuntime;if(!g)return Math.max(0,Math.floor((r-e.textStartY)/(e.pageHeight+e.pageSpacing)));let l=g.startPageIndexes.length-1;for(;l>0&&r<g.sectionStartTops[l];)
44
+ l--;const i=g.layouts[l],d=i.pageHeight+i.pageSpacing;return g.startPageIndexes[l]+Math.max(0,Math.floor((r-g.sectionStartTops[l]-i.textStartY)/d))},y=(n,r)=>{const g=n.sectionRuntime;if(!g)return;const l=g.
45
+ layouts.length,i=g.layouts.map((k,P)=>{const V=g.runs[P].rawSettings,Q=we(o.pageLayout,V);return{layout:k,raw:V,resolved:Q,step:k.pageHeight+k.pageSpacing,marginTop:Et(k),marginRight:be(k),marginBottom:xt(
46
+ k),marginLeft:mt(k)}}),d=[];let x=0,I=0;for(let k=0;k<r;k++){for(;x<l-1&&k>=g.startPageIndexes[x+1];)x++;const P=i[x];k===0||k===g.startPageIndexes[x]&&(x<l-1?P.raw?.pageNumberStart!==void 0:o.pageLayout?.
47
+ pageNumberRestart===!0)?I=P.resolved.pageNumberStart:I+=1,d.push({pageIndex:k,sectionIndex:x,pageTop:g.sectionStartTops[x]+(k-g.startPageIndexes[x])*P.step,pageWidth:P.layout.pageWidth,pageHeight:P.layout.
48
+ pageHeight,marginTop:P.marginTop,marginRight:P.marginRight,marginBottom:P.marginBottom,marginLeft:P.marginLeft,showPageNumbers:P.resolved.showPageNumbers,pageNumberPosition:P.resolved.pageNumberPosition,
49
+ renderedPageNumber:I,pageNumberFormat:P.resolved.pageNumberFormat,lineNumbering:P.resolved.lineNumbering,pageBorders:P.resolved.pageBorders,sectionFirstPage:k===g.startPageIndexes[x]})}return d},H=[...o.
50
+ notes??[],...o.children.filter(n=>n.type==="footnote")],b=(o.chrome?.length??0)>0;if(H.length===0&&!b){const n=u(o.children,e),r=Math.max(1,n.currentPage,Xt(n));return{blocks:n.blocks,fragments:n.fragments,
51
+ totalHeight:n.totalHeight,pageCount:r,pageGeometries:y(n,r),...n.lineNumberMarks!==void 0?{lineNumberMarks:n.lineNumberMarks}:{}}}const f=o.children.filter(n=>n.type!=="footnote"&&n.type!=="header-foo\
52
+ ter"),N=[],M=n=>{if(!n||typeof n!="object")return;if(Array.isArray(n)){n.forEach(M);return}const r=n;r.type!=="footnote"&&(r.marks?.footnoteRef&&!N.includes(r.marks.footnoteRef)&&N.push(r.marks.footnoteRef),
53
+ M(r.children))};M(f);const w=[...N.map(n=>H.find(r=>r.id===n)).filter(n=>!!n),...H.filter(n=>!N.includes(n.id))],L=w.filter(n=>n.noteKind!=="endnote"),Y=w.filter(n=>n.noteKind==="endnote");L.forEach((n,r)=>{
54
+ n.footnoteNumber=Me(r+1,"footnote")}),Y.forEach((n,r)=>{n.footnoteNumber=Me(r+1,"endnote")});const $=Nt.separatorSpacePx,W=[],R=Math.max(Nt.separatorWidthMinPx,e.availableWidth*Nt.separatorWidthFraction),
55
+ ut=(n,r,g,l)=>{const i=n.layout,d=c(_t(i),g);d.nextBlockIndex=n.nextBlockIndex,Wt({state:d,blocks:r,x:mt(i),layoutForLevel:_t(i),suppressTopSpacingForFirstBlock:!0});for(const x of d.blocks)x.pageNumber=
56
+ l,n.blocks.push(x);for(const x of d.fragments)x.pageNumber=l,n.fragments.push(x);return n.nextBlockIndex=d.nextBlockIndex,d.currentY},q=(n,r,g,l,i,d)=>{const x=s(n,l),I=p(n,l),k=Et(x),P=xt(x),V=12,Q=g?
57
+ I+Math.max(V/2+4,k/2):I+x.pageHeight-Math.max(V/2+4,P/2),B=mt(x),Z=ro(o.pageLayout),ht=d?so(d.renderedPageNumber,d.pageNumberFormat):io(Z,l),D=Mt=>Mt.children.some(et=>et.type==="text"&&et.marks?.field)?
58
+ {...Mt,children:Mt.children.map(et=>{if(et.type!=="text"||!et.marks?.field)return et;const Bt=et.marks.field==="page"?ht:String(i);return{...et,text:Bt}})}:Mt,X=r.children.slice(0,3).map((Mt,et)=>{const Bt=D(
59
+ Mt),F=lo[et];return F&&!Bt.align?{...Bt,align:F}:Bt}),tt=Ie(r,t,x,o,X),_=[0,tt[0],tt[0]+tt[1]];r.children.forEach((Mt,et)=>{if(et>2)return;const Bt=X[et],F=tt[et],ot=B+_[et],wt=c({...x,pageless:!0,availableWidth:F},
60
+ 0);wt.nextBlockIndex=n.nextBlockIndex,Wt({state:wt,blocks:[Bt],x:ot,layoutForLevel:{...x,pageless:!0,availableWidth:F},suppressTopSpacingForFirstBlock:!0});const Tt=wt.currentY,Ot=Q-Tt/2;for(const pt of wt.
61
+ blocks)pt.pageNumber=l+1,pt.bounds={...pt.bounds,y:pt.bounds.y+Ot},n.blocks.push(pt);for(const pt of wt.fragments)pt.pageNumber=l+1,pt.isChrome=!0,pt.bounds={...pt.bounds,y:pt.bounds.y+Ot},n.fragments.
62
+ push(pt);n.nextBlockIndex=wt.nextBlockIndex})},j=(n,r,g)=>{if(e.pageless)return;const l=new Set;for(let i=0;i<r;i++)for(const d of[!0,!1]){const x=oo(o.chrome??[],d?"header":"footer",i+1,g?.[i]?.sectionIndex);
63
+ x&&(q(n,x,d,i,r,g?.[i]),l.add(x.id))}};if(e.pageless){const n=u(f,e),r=[];for(const g of[L,Y]){if(g.length===0)continue;const l=n.currentY+$;W.push({x:mt(e),y:l,width:R}),n.currentY=l+10,Wt({state:n,blocks:g,
64
+ x:mt(e),layoutForLevel:_t(e),suppressTopSpacingForFirstBlock:!0}),r.push({x:mt(e),y:l,width:e.availableWidth,height:Math.max(0,n.currentY-l)})}return n.totalHeight=n.currentY,{blocks:n.blocks,fragments:n.
65
+ fragments,totalHeight:n.totalHeight,pageCount:1,footnoteSeparators:W,footnoteAreas:r}}const it=new Map;(n=>{const r=(g,l,i)=>{if(!g||typeof g!="object")return;if(Array.isArray(g)){g.forEach(x=>r(x,l,i));
66
+ return}const d=g;if(d.marks?.footnoteRef&&!it.has(d.marks.footnoteRef)){const x=i?.value,I=l.type==="paragraph"&&x!==void 0?qe(l).toVisibleOffset(x):void 0;it.set(d.marks.footnoteRef,{blockId:l.id??"",
67
+ charOffset:I})}d.type==="text"&&i&&(i.value+=d.text?.length??0),r(d.children,l,i)};for(const g of n)r(g,g,g.type==="paragraph"?{value:0}:void 0)})(f);const Pt=n=>{const r=new Map,g=Math.max(0,n.currentPage-
68
+ 1);for(const l of L){const i=it.get(l.id),d=i?n.fragments.filter(B=>B.blockId===i.blockId):[],x=i?.charOffset===void 0?d[0]:[...d].reverse().find(B=>B.charRange&&i.charOffset>=B.charRange.start&&i.charOffset<=
69
+ B.charRange.end),I=i?n.blocks.find(B=>B.blockId===i.blockId):void 0,k=x?.pageNumber??I?.pageNumber;if(k===void 0){r.set(l.id,{pageIndex:g});continue}const P=Math.max(0,k-1),V=x??I;let Q;if(V){const B=s(
70
+ n,P),Z=p(n,P)+B.pageHeight-xt(B),ht=x?.lineExtents&&i?.charOffset!==void 0?x.lineExtents.find(D=>D.charEnd>=i.charOffset)?.bottom:void 0;Q=Math.min(ht??V.bounds.y+V.bounds.height,Z)}r.set(l.id,{pageIndex:P,
71
+ keepBottomY:Q})}return r},yt=n=>Math.max($,n.pageHeight-Et(n)-xt(n)),vt=n=>{const r=[];for(const g of n.fragments){const l=g.bounds.y,i=l+g.bounds.height,d=h(n,l),x=h(n,Math.max(l,i-.01));for(let I=d;I<=
72
+ x;I++){const k=s(n,I),P=p(n,I)+k.pageHeight-xt(k);r[I]=Math.max(r[I]??0,Math.min(i,P))}}return r},st=(n,r)=>Math.max(0,yt(s(n,r))-$),J=(n,r,g)=>{const l=vt(n),i=Math.max(n.currentPage,Xt(n)),d=Math.max(
73
+ e.lineHeight,e.fontSize*go.paragraph),x=B=>B.type==="paragraph"?uo(B):B.type==="list"?e.fontSize*ho(B):d,I=[],k=[];for(const B of n.fragments){const Z=h(n,B.bounds.y),ht=I[Z];ht!==void 0&&B.bounds.y>=
74
+ ht||(I[Z]=B.bounds.y,k[Z]=x(B.block))}const P=B=>Math.max(32,Nt.minimumBodyLinesBeforeFootnotes*(k[B]??d)),V=new Map;for(const B of L){const Z=r.get(B.id),ht=g.get(B.id)??Z?.pageIndex??0;!Z||Z.keepBottomY===
75
+ void 0||ht!==Z.pageIndex||V.set(Z.pageIndex,Math.max(V.get(Z.pageIndex)??0,Z.keepBottomY))}const Q=[];for(let B=0;B<i;B++){const Z=s(n,B),ht=p(n,B),D=ht+Et(Z),X=ht+Z.pageHeight-xt(Z),tt=l[B];if(tt===void 0){
76
+ Q[B]=st(n,B);continue}const _=Math.max(V.get(B)??0,Math.min(tt,D+P(B)));Q[B]=Math.max(0,X-$-_-Nt.bodyKeepSlackPx)}return Q},lt=(n,r)=>{const g=Math.max(n.currentPage,Xt(n)),l=[];for(let i=0;i<g;i++)l[i]=
77
+ Math.max(0,Math.min(st(n,i),(r[i]??0)-$));return l};let ct;const K=()=>{if(ct===void 0){const n=c(_t(e),0);Wt({state:n,blocks:L,x:mt(e),layoutForLevel:_t(e),suppressTopSpacingForFirstBlock:!0}),ct=Math.
78
+ max(n.currentY,0)}return ct},dt=(n,r,g,l)=>{const i=F=>F<g.length?Math.max(0,g[F]??0):st(n,F),d=F=>{const ot=s(n,F);return p(n,F)+ot.pageHeight-xt(ot)-i(F)},x=F=>{const ot=s(n,F);return p(n,F)+ot.pageHeight-
79
+ xt(ot)},I=Math.max(48,yt(e)/2),k=Math.max(n.currentPage,Xt(n),g.length)+Math.ceil(K()/I)+4,P=[];for(let F=0;F<k;F++)P.push({top:d(F),bottom:x(F),full:i(F)>=st(n,F)-.01,pageIndex:F});const V=Ze(P),Q=F=>({
80
+ ...s(n,F),pageless:!1,lineHeight:1.25,paragraphSpacing:.25,blockSpacingPx:2,footnotePageInsets:void 0,pageContentTopOffsets:void 0,flowWindows:V}),B=F=>V.at(V.indexForY(F)).pageIndex,Z=L[0],ht=r.get(Z.
81
+ id)??0,D=c(Q(ht),d(ht));D.nextBlockIndex=l,D.currentPage=ht+1;const X=[],tt=new Map,_=new Set,Mt=new Map,et=new Map;for(const F of L){const ot=B(D.currentY),wt=Math.max(r.get(F.id)??0,ot),Tt=wt>ot,Ot=Tt||
82
+ D.blocks.length===0;Tt&&(D.currentY=d(wt),D.currentPage=Math.max(D.currentPage,wt+1)),D.layout=Q(wt),D.pageStep=me(D.layout);const pt=D.blocks.length;Wt({state:D,blocks:[F],x:mt(D.layout),layoutForLevel:D.
83
+ layout,suppressTopSpacingForFirstBlock:Ot});const Gt=D.blocks[pt],Rt=Gt?B(Gt.bounds.y):wt,Vt=B(D.currentY-.01);et.set(F.id,Rt);for(let Yt=Rt;Yt<=Vt;Yt++)tt.has(Yt)||tt.set(Yt,d(Yt)),Yt>Rt&&_.add(Yt),Mt.
84
+ set(Yt,Math.max(Mt.get(Yt)??0,Yt<Vt?x(Yt):D.currentY))}for(const[F,ot]of Mt)X[F]=Math.max(0,ot-d(F));const Bt=Math.max(0,...Mt.keys());return{heights:X,windowTops:tt,continuationPages:_,startPageByNote:et,
85
+ blocks:D.blocks,fragments:D.fragments,endY:D.currentY,lastPageIndex:Bt,nextBlockIndex:D.nextBlockIndex}},Ht=(n,r)=>{const g=[];return r.heights.forEach((l,i)=>{if(!l||l<=0)return;const d=s(n,i);g[i]=Math.
86
+ min($+l,yt(d))}),g},kt=(n,r)=>{const g=Math.max(n.length,r.length);for(let l=0;l<g;l++)if(Math.abs((n[l]??0)-(r[l]??0))>.25)return!1;return!0},O=new Map;let T=[],m=u(f,e,L.length>0),bt=m.currentY;const z=[];
87
+ if(L.length>0){for(let r=0;r<8;r++){const g=Pt(m);for(const[d,x]of g)O.set(d,Math.max(O.get(d)??0,x.pageIndex));const l=dt(m,O,J(m,g,O),0);for(const[d,x]of l.startPageByNote)O.set(d,Math.max(O.get(d)??
88
+ 0,x));const i=Ht(m,l);if(kt(i,T))break;T=i,m=u(f,{...e,footnotePageInsets:T},!0)}bt=m.currentY;const n=dt(m,O,lt(m,T),m.nextBlockIndex);m.blocks.push(...n.blocks),m.fragments.push(...n.fragments),m.nextBlockIndex=
89
+ n.nextBlockIndex,m.currentY=Math.max(m.currentY,n.endY),m.totalHeight=Math.max(m.totalHeight,n.endY),m.currentPage=Math.max(m.currentPage,n.lastPageIndex+1);for(const[r,g]of[...n.windowTops].sort((l,i)=>l[0]-
90
+ i[0])){const l=s(m,r),i=g-8;W.push({pageIndex:r,x:mt(l),y:i,width:n.continuationPages.has(r)?l.availableWidth:Math.max(96,l.availableWidth*.3)}),z.push({pageIndex:r,x:mt(l),y:i,width:l.availableWidth,
91
+ height:p(m,r)+l.pageHeight-xt(l)-i})}}let A=Math.max(1,m.currentPage,Xt(m));if(Y.length>0){const n=A-1,r=p(m,n)+e.pageHeight-xt(e),g=z.filter(B=>B.pageIndex===n).reduce((B,Z)=>Math.min(B,Z.y),Number.POSITIVE_INFINITY),
92
+ l=Math.min(r,g),i=bt+Nt.inlineEndnoteGapPx,d=c(_t(e),i+Nt.separatorToContentPx);d.nextBlockIndex=m.nextBlockIndex,Wt({state:d,blocks:Y,x:mt(e),layoutForLevel:_t(e),suppressTopSpacingForFirstBlock:!0});
93
+ const x=d.currentY<=l,I=x?n:A,k=p(m,I)+e.textStartY,P=x?i:k+Nt.newPageSeparatorOffsetPx;W.push({pageIndex:I,x:mt(e),y:P,width:R});const V=ut(m,Y,P+Nt.separatorToContentPx,I+1);z.push({pageIndex:I,x:mt(
94
+ e),y:P,width:e.availableWidth,height:Math.max(p(m,I)+e.pageHeight-xt(e),V)-P}),m.currentY=Math.max(m.currentY,V),m.totalHeight=Math.max(m.totalHeight,V);const Q=It(m,V)??A;A=Math.max(I+1,Q),m.currentPage=
95
+ Math.max(m.currentPage,A)}const gt=y(m,A);return j(m,A,gt),{blocks:m.blocks,fragments:m.fragments,totalHeight:m.totalHeight,pageCount:A,footnoteSeparators:W,footnoteAreas:z,pageGeometries:gt,...m.lineNumberMarks!==
96
+ void 0?{lineNumberMarks:m.lineNumberMarks}:{}}}function Wt(o){const{state:t,blocks:e,x:a,layoutForLevel:c,onFirstBlockLayout:u,suppressTopSpacingForFirstBlock:s=!1,onBlockLaidOut:p}=o;let h,y,H=!1;for(let b=0;b<
97
+ e.length;b++){const f=e[b],N=t.blocks.length,M=t.suppressTopSpacingForNextBlock,w=s&&b===0||M;M&&(t.suppressTopSpacingForNextBlock=!1);const L=Se(c,{suppressTopSpacingForFirstChild:w,...Qe(e,b)});Yo({
98
+ state:t,block:f,x:a,layout:L,followingBlocks:e.slice(b+1,b+4)});const Y=t.blocks.length>N?t.blocks[t.blocks.length-1]:void 0;if(Y){H||(H=!0,h=Y.bounds.y,u?.(Y));const $=Y.bounds.y+Y.bounds.height;y=y===
99
+ void 0?$:Math.max(y,$)}p?.(b)}return{firstBlockStartY:h,lastBlockEndY:y}}function Se(o,t){return o.suppressTopSpacingForFirstChild===!0===t.suppressTopSpacingForFirstChild&&o.siblingSpaceBeforePx===t.
100
+ siblingSpaceBeforePx&&o.siblingSpaceAfterPx===t.siblingSpaceAfterPx?o:{...o,...t}}function Yo(o){o.state.lastLineTail=Io(o)}function Io(o){const{block:t}=o;if(t.type==="container"){Fe({...o,block:t});
101
+ return}if(t.type==="footnote"){vo({...o,block:t});return}if(t.type==="table"){Wo({...o,block:t});return}if(t.type==="table-cell"){ae({...o,block:t});return}return t.type==="page-break"?No({...o,block:t}):
102
+ t.type==="section-break"?So(o):qt(o)}const Bo=4;function Ne(o,t,e){const a=o.lastLineTail;return a?{x:a.x+Bo,y:a.y,width:t.width,height:Math.max(Math.min(16,a.height),0)}:{x:t.x,y:o.currentY,width:t.width,
103
+ height:Math.max(Math.min(16,e),0)}}function So(o){const{state:t,block:e,x:a,layout:c}=o;if(c.pageless)return qt(o);const u=t.registry.getHandlerForBlock(e);if(!u)return qt(o);const s=t.nextBlockIndex++,
104
+ p=u.getBounds(e,a,t.currentY,t.textContext,c,t.doc),h=Ne(t,p,Jt(t,t.currentY)-t.currentY),y=It(t,h.y);return t.blocks.push({block:e,blockIndex:s,blockId:e.id??"",bounds:h,pageNumber:y,pageBreakBefore:!1}),
105
+ t.fragments.push({block:e,blockIndex:s,blockId:e.id??"",fragmentIndex:0,bounds:h,pageNumber:y,data:{type:"section-break"}}),{x:h.x+h.width,y:h.y,height:Math.max(h.height,t.lastLineTail?.height??0)}}function No(o){
106
+ const{state:t,block:e,x:a,layout:c}=o,u=t.registry.getHandlerForBlock(e);if(!u)return console.warn(`No handler for block type: ${e.type}`),t.lastLineTail;if(c.pageless)return qt(o);const s=t.nextBlockIndex++,
107
+ p=u.getBounds(e,a,t.currentY,t.textContext,c,t.doc),h=Ro(t,t.currentY),y=Ne(t,p,h-t.currentY),H=It(t,y.y),b={block:e,blockIndex:s,blockId:e.id??"",bounds:y,pageNumber:H,pageBreakBefore:!1},f={block:e,
108
+ blockIndex:s,blockId:e.id??"",fragmentIndex:0,bounds:y,pageNumber:H,data:{type:"page-break"}};t.blocks.push(b),t.fragments.push(f),t.currentY=h,t.totalHeight=t.currentY,t.currentPage=Math.max(t.currentPage,
109
+ It(t,h)??t.currentPage),t.suppressTopSpacingForNextBlock=!0,se(t,h)}function Zt(o,t,e){if(e<=0||o.layout.pageless||o.pageStep<=0)return!1;const a=o.layout.flowWindows;return(a&&a.length!==0?Ce(t,e,a):
110
+ ke(t,e,o.layout)).pageChanged}function Pe(o){const t=Jt(o);t>o.currentY&&(o.currentY=t,se(o,t))}function Po(o,t,e,a,c){if(!e||e.length===0)return 0;let u=0,s=t;for(let p=0;p<e.length&&p<ne;p++){const h=e[p];
111
+ if(!h||h.type!=="paragraph")break;const y=o.registry.getHandlerForBlock(h);if(!y)break;const H=Se(c,{suppressTopSpacingForFirstChild:!1,siblingSpaceBeforePx:to(s,h),siblingSpaceAfterPx:ye(h,e[p+1])}),
112
+ b=ye(s,h)??(s.type==="paragraph"&&Number.isFinite(s.spaceAfter)?Math.max(0,s.spaceAfter??0):0);s=h;const f=ve(o,y,h,a,H),N=f.units??[];if(N.length===0)break;const M=b+(f.margins?.top??0),w=oe(h);if(w.
113
+ keepNext&&p<ne-1){u+=M+N.reduce((L,Y)=>L+Math.max(Y.height,0),0);continue}u+=M+Math.max(N[0].height,0),w.widowControl&&N.length>=2&&(u+=Math.max(N[1].height,0));break}return u}function qt(o){const{state:t,
114
+ block:e,x:a,layout:c,followingBlocks:u}=o,s=t.registry.getHandlerForBlock(e);if(!s)return console.warn(`No handler for block type: ${e.type}`),t.lastLineTail;const p=t.nextBlockIndex++,h=ve(t,s,e,a,c),
115
+ y=h.margins?.top??0,H=h.margins?.bottom??0;t.currentY+=y;const b=h.units.length>0?h.units:[];b.length===0&&console.warn(`Block handler for type ${e.type} returned no layout units; layout may be incorr\
116
+ ect.`);let f=!1;const N=oe(e);if(!c.pageless&&t.pageStep>0&&b.length>0){const O=b.reduce((m,bt)=>m+Math.max(bt.height,0),0);let T=0;N.keepLines?T=O:N.widowControl&&b.length>=2&&(T=Math.max(b[0].height,
117
+ 0)+Math.max(b[1].height,0)),N.keepNext&&(T=Math.max(T,O+Po(t,e,u,a,c))),T>0&&Zt(t,t.currentY,T)&&!Zt(t,Jt(t),T)&&(Pe(t),f=!0)}let M=0,w=0,L=t.currentY,Y,$,W,R,ut,q,j,it=Number.POSITIVE_INFINITY,Pt=Number.
118
+ NEGATIVE_INFINITY,yt,vt=0,st,J=f;const lt=[],ct=(O,T)=>{w=O,L=T,Y=void 0,$=void 0,W=void 0,R=void 0,ut=void 0,q=void 0,j=void 0},K=O=>{if(O<=w){ct(O,t.currentY);return}const T=t.currentY-L;if(T<=0){ct(
119
+ O,t.currentY);return}const m=ut??h.x,bt=q!==void 0&&ut!==void 0?q-ut:h.width,z=Math.max(bt,h.width),A={x:m,y:L,width:z,height:T};let gt;!t.layout.pageless&&t.pageStep>0&&(gt=It(t,A.y));const n={block:e,
120
+ blockIndex:p,blockId:e.id??"",fragmentIndex:M,bounds:A,pageNumber:gt,unitRange:{start:w,end:O}};Y!==void 0&&$!==void 0&&$>=Y&&(n.lineRange={start:Y,end:$}),W!==void 0&&R!==void 0&&R>=W&&(n.charRange={
121
+ start:W,end:R}),j&&j.length>0&&(n.lineExtents=j),M===0&&(st=gt),lt.push(n),M+=1,yt=yt??A.y,vt+=A.height,ct(O,t.currentY)};let dt;for(let O=0;O<b.length;O++){const T=b[O],m=Math.max(T.height,0),bt=T.x??
122
+ h.x,z=T.width,A=bt+z,gt=N.widowControl&&b.length>=3&&O===b.length-2&&!Zt(t,t.currentY,m)&&Zt(t,t.currentY+m,Math.max(b[O+1].height,0));gt&&Pe(t),(gt||Dt(t,m))&&(w<O?K(O):M===0&&(J=!0),ct(O,t.currentY)),
123
+ Y===void 0&&T.lineRange&&(Y=T.lineRange.start),T.lineRange&&($=T.lineRange.end),W===void 0&&T.charRange&&(W=T.charRange.start),T.charRange&&(R=T.charRange.end),t.trackLineExtents&&T.charRange&&(j??(j=
124
+ [])).push({charEnd:T.charRange.end,bottom:t.currentY+m}),ut=ut===void 0?bt:Math.min(ut,bt),q=q===void 0?A:Math.max(q,A),it=Math.min(it,bt),Pt=Math.max(Pt,A),t.lineNumberMarks!==void 0&&t.layout.lineNumbering&&
125
+ T.lineRange&&t.lineNumberMarks.push({y:t.currentY,height:m,pageNumber:It(t,t.currentY)}),dt={unit:T,fallbackX:A,y:t.currentY,height:m},t.currentY+=m}K(b.length);const Ht={x:Number.isFinite(it)?it:h.x,
126
+ y:yt??t.currentY,width:Number.isFinite(it)&&Number.isFinite(Pt)?Math.max(Pt-it,h.width):h.width,height:vt,margins:h.margins};t.blocks.push({block:e,blockIndex:p,blockId:e.id??"",bounds:Ht,pageNumber:t.
127
+ layout.pageless?void 0:st,pageBreakBefore:J}),t.fragments.push(...lt),t.currentY+=H,t.totalHeight=t.currentY;const kt=dt;if(!(!s.isTextBased||!kt))return{get x(){return kt.unit.textEndX??kt.fallbackX},
128
+ y:kt.y,height:kt.height}}function ve(o,t,e,a,c){const u=o.boundsMemo;if(!u)return t.getBounds(e,a,o.currentY,o.textContext,c,o.doc);const s=c.suppressTopSpacingForFirstChild===!0,{siblingSpaceBeforePx:p,
129
+ siblingSpaceAfterPx:h}=c;let y=u.get(e);const H=y?.find(f=>f.x===a&&f.availableWidth===c.availableWidth&&f.suppressTopSpacing===s&&f.siblingSpaceBeforePx===p&&f.siblingSpaceAfterPx===h);if(H)return H.
130
+ result;const b=t.getBounds(e,a,o.currentY,o.textContext,c,o.doc);return y||(y=[],u.set(e,y)),y.push({x:a,availableWidth:c.availableWidth,suppressTopSpacing:s,siblingSpaceBeforePx:p,siblingSpaceAfterPx:h,
131
+ result:b}),b}function _t(o){return{...o,pageless:!0,lineHeight:1.25,paragraphSpacing:.25,blockSpacingPx:Nt.blockSpacingPx}}function Fe(o){const{state:t,block:e,x:a,layout:c,paddingOverride:u,fragmentType:s}=o,
132
+ p=t.registry.getHandlerForBlock(e);if(!p){console.warn(`No handler for block type: ${e.type}`);return}const h=t.nextBlockIndex++,y=p.getBounds(e,a,t.currentY,t.textContext,c,t.doc),H=y.margins?.top??0,
133
+ b=y.margins?.bottom??0;t.currentY+=H;let f=t.currentY,N=!1;const M=Math.max(0,e.padding??Mo),w=u?.top??M,L=u?.bottom??M,Y=u?.left??M,$=u?.right??M,W=y.width??c.availableWidth,R={block:e,blockIndex:h,blockId:e.
134
+ id??"",bounds:{x:a,y:f,width:W,height:0,margins:y.margins},pageBreakBefore:!1},ut=t.blocks.length;t.blocks.push(R);const q=t.fragments.length,j=e.children.length>0;let it=!j;const Pt=re(t,Ht=>{it||(f=
135
+ Ht,R.bounds.y=Ht,N=!0)});Dt(t,1e-4)&&(f=t.currentY,R.bounds.y=f,N=!0),Dt(t,w)&&(f=t.currentY,R.bounds.y=f,N=!0),t.currentY+=w;const yt=a+Y,vt=Math.max(c.availableWidth-Y-$,yo),st=Math.abs(vt-c.availableWidth)<
136
+ .5?c:Re(c,vt);let J={};try{J=Wt({state:t,blocks:e.children,x:yt,layoutForLevel:st,onFirstBlockLayout:()=>{it=!0},suppressTopSpacingForFirstBlock:!0})}finally{Pt()}J.firstBlockStartY!==void 0&&J.firstBlockStartY-
137
+ w<f&&(f=J.firstBlockStartY-w,R.bounds.y=f),Dt(t,L)&&(j||(f=t.currentY,R.bounds.y=f,N=!0)),t.currentY+=L;const lt=Math.max(t.currentY-f,w+L);R.bounds={...R.bounds,y:f,height:lt,width:W,margins:y.margins},
138
+ R.pageBreakBefore=N,R.pageNumber=It(t,R.bounds.y);const ct={x:a,y:R.bounds.y,width:W,height:lt},K={block:e,blockIndex:h,blockId:e.id||"",fragmentIndex:0,bounds:ct,pageNumber:R.pageNumber,data:{type:s??
139
+ "container"}};if(t.fragments.splice(q,0,K),J.firstBlockStartY!==void 0){const Ht=Math.max(t.layout.lineHeight*4,64);if(J.firstBlockStartY-f>Ht+w){const kt=J.firstBlockStartY-w;R.bounds.y=kt,R.bounds.height=
140
+ Math.max(t.currentY-kt,w+L),K.bounds={...K.bounds,...R.bounds}}}t.blocks[ut]=R;const dt=It(t,R.bounds.y);R.pageNumber=dt,K.pageNumber=dt,t.currentY+=b,t.totalHeight=t.currentY}function vo(o){Fe({...o,
141
+ block:o.block,paddingOverride:{top:Nt.verticalPaddingPx,bottom:Nt.verticalPaddingPx,left:Nt.gutterPx,right:0},fragmentType:"footnote"})}const He=ee.cellPaddingPx,Fo=ee.borderColor,Ho=ee.borderWidthPx;
142
+ function To(o){if(o.flowWindows)return o.flowWindows;const t=me(o),e=o.sectionStartY??0,a=o.sectionFirstPageIndex??0;return{indexForY:c=>Math.max(0,Math.floor((c-e-o.textStartY+rt)/t)),at:c=>{const u=Ke(
143
+ o,a+c),s=xe(o,a+c),p=e+c*t;return{top:p+u,bottom:p+o.pageHeight-xt(o)-s,full:u<=Et(o)&&s<=0,pageIndex:a+c}}}}function Te(o,t,e){if(o.layout.pageless||e<=0)return t+e;const a=o.layout.flowWindows;let c=a.
144
+ indexForY(t);for(;e>rt;){const u=a.at(c);t=Math.max(t,u.top);const s=Math.max(0,u.bottom-t);if(e<=s+rt)return t+e;if(e-=s,a.length!==void 0&&c+1>=a.length)return u.bottom+e;t=a.at(++c).top}return t}function Lo(o,t,e){
145
+ return We(o,t,e).reduce((a,c)=>a+c.height,0)}function Co(o,t,e,a){const{blockIndex:c,fragmentIndex:u,params:s}=t,p=o.blocks[c].bounds.y,h=s.block.verticalAlign,y=Lo(o,p,e)-(s.measuredHeight??0);if(a&&
146
+ h&&h!=="top"&&y>rt){const N=Y=>{const $={...o,blocks:[],fragments:[],currentY:p,nextBlockIndex:o.blocks[c].blockIndex,pageBreakListeners:[],lineNumberMarks:void 0,lastLineTail:void 0,suppressTopSpacingForNextBlock:!1};
147
+ return ae({...s,state:$,rowHeight:void 0,contentOffset:Y}),$};let M=y*(h==="middle"?.5:1),w=N(M),L;if(w.currentY<=e+rt)L=w;else{let Y=0;for(let $=0;$<16&&M-Y>.01;$++){const W=(Y+M)/2;w=N(W),w.currentY<=
148
+ e+rt?(L=w,Y=W):M=W}}L&&(o.blocks.splice(c,t.blockCount,...L.blocks),o.fragments.splice(u,t.fragmentCount,...L.fragments))}const H=o.blocks[c];H.bounds.height=Math.max(0,e-p);const b=o.fragments[u],f=We(
149
+ o,p,e);f.length&&o.fragments.splice(u,1,...f.map((N,M)=>({...b,fragmentIndex:M,bounds:{...b.bounds,y:N.y,height:N.height},pageNumber:It(o,N.y),data:M>0?structuredClone(b.data):b.data})))}function Wo(o){
150
+ const{state:t,block:e,x:a,layout:c}=o,u=t.registry.getHandlerForBlock(e);if(!u){console.warn(`No handler for block type: ${e.type}`);return}const s=t.nextBlockIndex++,p=u.getBounds(e,a,t.currentY,t.textContext,
151
+ c,t.doc),h=p.margins?.top??0,y=p.margins?.bottom??0;t.currentY+=h;let H=t.currentY,b=!1;const f=p.width,N=Number.isFinite(e.cellPadding)?Math.max(0,Math.round(e.cellPadding)):He,M=e.borderColor??Fo,w=Number.
152
+ isFinite(e.borderWidth)?Math.max(0,Number(e.borderWidth)):Ho,L=p.x,Y={block:e,blockIndex:s,blockId:e.id??"",bounds:{x:L,y:H,width:f,height:0,margins:p.margins},pageBreakBefore:!1},$=t.blocks.length;t.
153
+ blocks.push(Y);const W=t.fragments.length;let R=!(e.children.length>0);const ut=re(t,st=>{R||(H=st,Y.bounds.y=st,b=!0)});Dt(t,1e-4)&&(H=t.currentY,Y.bounds.y=H,b=!0);const q=t.layout,j=To(q);q.pageless||
154
+ (t.layout={...q,flowWindows:j});try{const st=p.units[0]?.data,J=st?.grid??po(e),lt=st?.geometry??fo(J,f,e.columnWidths,(z,A)=>{const gt={...c,availableWidth:A,tableCellPadding:N};return t.registry.getHandlerForBlock(
155
+ z)?.getBounds(z,0,0,t.textContext,gt,t.doc).units.reduce((n,r)=>n+r.height,0)??0}),ct=Array.from({length:J.rows},()=>[]);for(const z of J.cells)ct[z.row].push(z);const K=new Array(J.rows).fill(0),dt=new Array(
156
+ J.rows).fill(0),Ht=q.pageless?1/0:q.pageHeight-q.textStartY-xt(q);let kt=e.hasHeader===!0&&J.rows>1&&!q.pageless&&!ct[0].some(z=>z.rowSpan>1),O=[],T=0,m=0,bt=0;for(let z=0;z<J.rows;){let A=z+1,gt=0;for(let i=z;i<
157
+ A;i++){gt+=lt.rowHeights[i];for(const d of ct[i])A=Math.max(A,d.row+d.rowSpan)}const n=gt>Ht-(z>0?m:0);n?Dt(t,1e-4):Dt(t,gt),R=!0;const r=t.currentY,g=t.fragments.length,l=[];for(let i=z;i<A;i++){const d=t.
158
+ currentY;let x=n?Te(t,d,lt.rowHeights[i]):d+lt.rowHeights[i];for(const I of ct[i]){t.currentY=d;const k={state:t,block:I.cell,x:L+lt.colLefts[I.col],layout:{...c,availableWidth:lt.cellWidth(I),tableCellPadding:N},
159
+ measuredHeight:lt.measuredCellHeight(I),rowHeight:n?void 0:lt.cellHeight(I),cellEdgeInfo:{parentTableId:e.id??"",tableDiffState:e.diffState,rowDiffState:e.children[i].diffState,isTopRow:i===0,isBottomRow:I.
160
+ row+I.rowSpan===J.rows,isLeftCol:I.col===0,isRightCol:I.col+I.colSpan===J.cols,isHeaderCell:e.hasHeader===!0&&i===0,tableBorderColor:M,tableBorderWidth:w,tableBorders:e.borders,tableCellPadding:N,gridRow:I.
161
+ row,gridCol:I.col,rowSpan:I.rowSpan,colSpan:I.colSpan}},P=t.blocks.length,V=t.fragments.length;ae(k);const Q=I.row+I.rowSpan-1;dt[Q]=Math.max(dt[Q],t.currentY),l.push({params:k,gc:I,blockIndex:P,fragmentIndex:V,
162
+ blockCount:t.blocks.length-P,fragmentCount:t.fragments.length-V})}x=Math.max(x,dt[i]),K[i]=x,t.currentY=x}for(let i=l.length-1;i>=0;i--){const d=l[i];Co(t,d,K[d.gc.row+d.gc.rowSpan-1],n)}z===0&&kt&&(T=
163
+ r,m=t.currentY-T,bt=j.indexForY(T),kt=!n&&j.indexForY(t.currentY-rt)===bt&&m<Ht,kt?(O=t.fragments.slice(g),t.layout={...q,flowWindows:{length:j.length,indexForY:j.indexForY,at:i=>{const d=j.at(i);return i>
164
+ bt?{...d,top:d.top+m}:d}}}):m=0),z=A}if(kt&&O.length){const z=j.indexForY(t.currentY-rt);for(let A=bt+1;A<=z;A++){const gt=j.at(A).top-T;for(const n of O){const r={...n.bounds,y:n.bounds.y+gt};t.fragments.
165
+ push({...n,bounds:r,repeatedHeader:!0,pageNumber:It(t,r.y),lineExtents:n.lineExtents?.map(g=>({...g,bottom:g.bottom+gt})),data:{...structuredClone(n.data),repeatedHeader:!0}})}}}}finally{t.layout=q,ut()}
166
+ const it=Math.max(t.currentY-H,0);Y.bounds={...Y.bounds,y:H,height:it,width:f,margins:p.margins},Y.pageBreakBefore=b,Y.pageNumber=It(t,Y.bounds.y);const Pt={x:L,y:Y.bounds.y,width:f,height:it},yt={block:e,
167
+ blockIndex:s,blockId:e.id||"",fragmentIndex:0,bounds:Pt,pageNumber:Y.pageNumber,data:{type:"table"}};t.fragments.splice(W,0,yt),t.blocks[$]=Y;const vt=It(t,Y.bounds.y);Y.pageNumber=vt,yt.pageNumber=vt,
168
+ t.currentY+=y,t.totalHeight=t.currentY}function ae(o){const{state:t,block:e,x:a,layout:c,rowHeight:u,cellEdgeInfo:s}=o,p=t.registry.getHandlerForBlock(e);if(!p){console.warn(`No handler for block type\
169
+ : ${e.type}`);return}const h=t.nextBlockIndex++,y=o.measuredHeight??p.getBounds(e,a,t.currentY,t.textContext,c,t.doc).units.reduce((K,dt)=>K+Math.max(dt.height,0),0),H=c.availableWidth,b=bo(s?.tableCellPadding??
170
+ He,e.padding),f=Math.max(y,b.top+b.bottom),N=u!==void 0?Math.max(u,0):f,M=Math.max(0,N-f),w=e.verticalAlign??"top",L=o.contentOffset??(w==="bottom"?M:w==="middle"?M/2:0);let Y=t.currentY,$=!1;const W={
171
+ block:e,blockIndex:h,blockId:e.id??"",bounds:{x:a,y:Y,width:H,height:0},pageBreakBefore:!1},R=t.blocks.length;t.blocks.push(W);const ut=t.fragments.length;let q=!(e.children.length>0);const j=re(t,K=>{
172
+ !q&&t.fragments.length===ut&&(Y=K,W.bounds.y=K,$=!0)});L>0&&(t.currentY=Te(t,t.currentY,L)),Dt(t,b.top)&&(Y=t.currentY,W.bounds.y=Y,$=!0),t.currentY+=b.top;const it=a+b.left,Pt=mo(H,b),yt=Re(c,Pt);try{
173
+ Wt({state:t,blocks:e.children,x:it,layoutForLevel:yt,onFirstBlockLayout:()=>{q=!0},suppressTopSpacingForFirstBlock:!je(e.children[0])})}finally{j()}if(e.backgroundColor)for(let K=ut;K<t.fragments.length;K++){
174
+ const dt=t.fragments[K];dt.backgroundFill===void 0&&(dt.backgroundFill=e.backgroundColor)}t.currentY+=b.bottom;const vt=Math.max(t.currentY-Y,b.top+b.bottom),st=Math.max(u??0,vt);W.bounds={...W.bounds,
175
+ y:Y,height:st,width:H},W.pageBreakBefore=$,W.pageNumber=It(t,W.bounds.y);const J={x:a,y:W.bounds.y,width:H,height:st},lt={block:e,blockIndex:h,blockId:e.id||"",fragmentIndex:0,bounds:J,pageNumber:W.pageNumber,
176
+ data:{type:"table-cell",...s&&{parentTableId:s.parentTableId,tableDiffState:s.tableDiffState,rowDiffState:s.rowDiffState,isTopRow:s.isTopRow,isBottomRow:s.isBottomRow,isLeftCol:s.isLeftCol,isRightCol:s.
177
+ isRightCol,isHeaderCell:s.isHeaderCell,tableBorderColor:s.tableBorderColor,tableBorderWidth:s.tableBorderWidth,...s.tableBorders?{tableBorders:s.tableBorders}:{},tableCellPadding:s.tableCellPadding,gridRow:s.
178
+ gridRow,gridCol:s.gridCol,rowSpan:s.rowSpan,colSpan:s.colSpan}}};t.fragments.splice(ut,0,lt),t.blocks[R]=W;const ct=It(t,W.bounds.y);W.pageNumber=ct,lt.pageNumber=ct,u!==void 0&&(t.currentY=Y+st),t.totalHeight=
179
+ t.currentY}const Le=1e4;function Ce(o,t,e){const a=e.indexForY(o);if(o+t<=e.at(a).bottom)return{newY:o,pageChanged:!1};const c=e.length!==void 0?e.length-1:a+Le;for(let u=a+1;u<=c;u++){const s=e.at(u);
180
+ if(s.full||s.top+t<=s.bottom||u===c)return u===c&&e.length===void 0&&console.warn("Flow-window scan hit its defensive cap without finding a window that accepts the content; window geometry is broken."),
181
+ {newY:s.top,pageChanged:!0}}return{newY:o,pageChanged:!1}}function Dt(o,t){if(t<=0||o.layout.pageless)return!1;const e=o.layout.flowWindows,a=e&&e.length!==0?Ce(o.currentY,t,e):ke(o.currentY,t,o.layout);
182
+ return a.pageChanged?(o.currentY=a.newY,se(o,a.newY),!0):!1}function We(o,t,e){if(o.layout.pageless||o.pageStep<=0||e<=t)return e>t?[{y:t,height:e-t}]:[];const a=o.layout.flowWindows;if(a&&a.length!==
183
+ 0){const b=[];let f=t,N=a.indexForY(f);for(;f<e-rt;){const M=Math.min(e,a.at(N).bottom);if(M>f&&b.push({y:f,height:M-f}),N+=1,a.length!==void 0&&N>=a.length){e>M&&b.push({y:M,height:e-M});break}f=Math.
184
+ max(M,a.at(N).top)}return b}const{textStartY:c,pageHeight:u}=o.layout,s=o.layout.sectionStartY??0,p=xt(o.layout),h=[];let y=t,H=Math.floor(Math.max(y-s-c,0)/o.pageStep);for(;y<e-rt;){const b=s+H*o.pageStep+
185
+ u-p,f=Math.min(e,b);f>y&&h.push({y,height:f-y}),H+=1,y=Math.max(f,s+H*o.pageStep+c)}return h}function Jt(o,t=o.currentY){if(o.layout.pageless||o.pageStep<=0)return t;const e=o.layout.flowWindows;if(e&&
186
+ e.length!==0){const u=e.indexForY(t);return e.length!==void 0&&u+1>=e.length?t:e.at(u+1).top}const a=o.layout.sectionStartY??0,c=Math.floor(Math.max(t-a-o.layout.textStartY,0)/o.pageStep);return a+(c+
187
+ 1)*o.pageStep+o.layout.textStartY}function Ro(o,t=o.currentY){const e=o.layout.flowWindows;if(!e||e.length===0)return Jt(o,t);const a=e.indexForY(t),c=e.at(a).pageIndex,u=e.length!==void 0?e.length-1:
188
+ a+Le;for(let s=a+1;s<=u;s++){const p=e.at(s);if(p.pageIndex>c)return p.top}return t}function It(o,t){if(o.layout.pageless||o.pageStep<=0)return;const e=o.layout.flowWindows;if(e&&e.length!==0){const s=e.
189
+ at(e.indexForY(t)).pageIndex+1;return o.currentPage=Math.max(o.currentPage,s),s}const a=o.layout.sectionStartY??0,c=Math.floor(Math.max(t-a-o.layout.textStartY,0)/o.pageStep),u=(o.layout.sectionFirstPageIndex??
190
+ 0)+c+1;return o.currentPage=Math.max(o.currentPage,u),u}function Xt(o){if(o.layout.pageless||o.pageStep<=0)return 1;const t=o.layout.sectionStartY??0,e=Math.max(o.totalHeight,o.currentY,t+o.layout.textStartY),
191
+ a=Math.max(e-t-o.layout.textStartY-rt,0);return(o.layout.sectionFirstPageIndex??0)+Math.floor(a/o.pageStep)+1}function Eo(o,t){const e=Math.max(1,o.pageHeight-o.textStartY-xt(o)),a=Math.max(o.textStartY,
192
+ t.totalHeight),c=o.pageHeight+o.pageSpacing;let u;if(o.pageless||c<=0)u=(a-o.textStartY)/e;else{const s=Math.max(1,t.pageCount),p=(t.pageGeometries?.[s-1]?.pageTop??(s-1)*c)+o.textStartY,h=Math.max(0,
193
+ a-p),y=Math.max(.1,Math.min(1,h/e));u=s===1?y:s-1+y}return Math.round(Math.max(.1,u)*10)/10}function Re(o,t){return{...o,availableWidth:t}}function re(o,t){return o.pageBreakListeners.push(t),()=>{const e=o.
194
+ pageBreakListeners.lastIndexOf(t);e>=0&&o.pageBreakListeners.splice(e,1)}}function se(o,t){if(o.pageBreakListeners.length!==0)for(const e of o.pageBreakListeners)try{e(t)}catch(a){console.error("Error\
195
+ in page break listener",a)}}function Oo(o){if(typeof Buffer<"u")return Uint8Array.from(Buffer.from(o,"base64"));const t=atob(o),e=new Uint8Array(t.length);for(let a=0;a<t.length;a++)e[a]=t.charCodeAt(
196
+ a);return e}export{ne as K,Eo as a,Oo as b,wo as c,Ie as d,oe as p};