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
package/backend.js CHANGED
@@ -1 +1,3 @@
1
- import{bW as s,R as a,bV as e,bU as o,bS as c,bR as r,bI as b,bQ as t,bN as D,bJ as m,bP as i,b as d,bH as n,bT as S,bK as u,bO as l,bL as R,bM as T}from"./chunks/backend-MFpDFVrD.js";import"yjs";export{s as RESERVED_DOCUMENT_KEYS,a as ReviseToolError,e as assertUsableSharedDocument,o as createReviseYDoc,c as createServerDocumentSession,r as decodeYDoc,b as documentToDocx,t as encodeYDoc,D as exportDocument,m as fileToYDoc,i as hasDocument,d as installDomShims,n as parseDocument,S as repairSeedRace,u as seedYDocFromFile,l as ydocSourceFidelity,R as ydocToDocument,T as ydocToDocx};
1
+ import{bW as s,R as a,bV as e,bU as o,bS as c,bR as r,bI as b,bQ as t,bN as D,bJ as m,bP as i,b as d,bH as n,bT as S,bK as u,bO as l,bL as R,bM as T}from"./chunks/backend-BIhAX-Gi.js";import"yjs";export{
2
+ s as RESERVED_DOCUMENT_KEYS,a as ReviseToolError,e as assertUsableSharedDocument,o as createReviseYDoc,c as createServerDocumentSession,r as decodeYDoc,b as documentToDocx,t as encodeYDoc,D as exportDocument,
3
+ m as fileToYDoc,i as hasDocument,d as installDomShims,n as parseDocument,S as repairSeedRace,u as seedYDocFromFile,l as ydocSourceFidelity,R as ydocToDocument,T as ydocToDocx};
@@ -1 +1 @@
1
- import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-DyOcu9mD.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
1
+ import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-C-4H81OE.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
@@ -1 +1 @@
1
- import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-CjeGoI2g.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
1
+ import{A as P,B as I,E,F as L,S as R,H as q,I as D,J as $,K as H,L as N,M as F,N as B,O as j,P as W}from"./index-iZC8xN0t.js";function w(t,r,o,n){if(Array.isArray(t)){for(const s of t)w(s,r,o,n);return}if(!t||typeof t!="object")return;const a=t,e=typeof a.id=="string"?a.id:r;a.type==="math"&&typeof a.content=="string"&&o.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:e}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&o.push({content:a.text,displayMode:!1,blockId:e}),a.type==="image"&&typeof a.src=="string"&&n.push({src:a.src,blockId:e,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const s of Object.values(a))if(Array.isArray(s))for(const l of s)w(l,e,o,n);else s&&typeof s=="object"&&w(s,e,o,n)}function S(){return new Promise(t=>{let r=!1;const o=()=>{r||(r=!0,clearTimeout(n),t())},n=setTimeout(o,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(o)})}async function G(t,r){if(t.length===0)return;const o=Promise.allSettled(t.map(n=>D(n.content,n.displayMode,r)));await Promise.race([o,new Promise(n=>setTimeout(n,2500))]),await S(),await S()}function v(t,r){if(typeof t.pageNumber=="number")return t.pageNumber-1;const o=t.bounds.y;return r.pageGeometries?.find(n=>o>=n.pageTop&&o<n.pageTop+n.pageHeight)?.pageIndex??0}function O(t,r){return new Set(t.fragments.filter(o=>r.has(v(o,t))).map(o=>o.blockId))}function Y(t){return t==="table"?"#7c3aed":t==="table-cell"||t==="table-row"?"#db2777":t==="image"?"#ea580c":t==="container"?"#2563eb":t==="math"?"#ca8a04":"#0891b2"}function A(t,r,o){t.save(),t.lineWidth=.75,t.setLineDash([4,3]),t.strokeStyle="rgba(22, 163, 74, 0.9)",t.strokeRect(o.marginLeft,o.marginTop,o.pageWidth-o.marginLeft-o.marginRight,o.pageHeight-o.marginTop-o.marginBottom),t.setLineDash([]);const n=new Set;for(const a of r.fragments){if(v(a,r)!==o.pageIndex)continue;const{bounds:e}=a,s=e.relativeToPage?e.y:e.y-o.pageTop,l=`${a.blockId}:${Math.round(e.x)}:${Math.round(s)}:${Math.round(e.width)}:${Math.round(e.height)}`;if(n.has(l)||e.width<=0||e.height<=0)continue;n.add(l);const m=Y(a.block.type);if(t.strokeStyle=m,t.globalAlpha=.82,t.strokeRect(e.x,s,e.width,e.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&e.width>=42&&e.height>=12){const p=`${a.block.type} #${a.blockId}`;t.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",t.textAlign="left",t.textBaseline="top";const f=Math.min(e.width,t.measureText(p).width+5);t.globalAlpha=.88,t.fillStyle=m,t.fillRect(e.x,Math.max(0,s),f,13),t.globalAlpha=1,t.fillStyle="#ffffff",t.fillText(p,e.x+2,Math.max(0,s)+1,Math.max(1,f-4))}}t.restore()}function _(t,r){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:t.pageWidth,pageHeight:Math.min(4096,Math.max(t.pageHeight,r.totalHeight)),marginTop:t.pageMarginTop??t.pageMargin,marginRight:t.pageMarginRight??t.pageMargin,marginBottom:t.pageMarginBottom??t.pageMargin,marginLeft:t.pageMarginLeft??t.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}function U(t){const r=document.createElement("canvas");r.width=Math.ceil(t.geometry.pageWidth),r.height=Math.ceil(t.geometry.pageHeight);const o=r.getContext("2d");if(!o)throw new Error("The browser could not create a page canvas.");const n=P(t.themeElement);o.fillStyle=n.pageBackground,o.fillRect(0,0,r.width,r.height);const a=I(o);t.editor.setTextMeasurementContext(a,t.layout);const e=$(o,r,t.layout,a);e.theme=n,e.currentPage=t.geometry.pageIndex,e.pageGeometry=t.geometry,e.yOffset=t.geometry.pageTop,e.startY=t.geometry.pageTop,e.endY=t.geometry.pageTop+t.geometry.pageHeight,e.pageLayoutSettings=t.pageLayoutSettings,e.headersContent=t.editor.getDocument().headers,e.footersContent=t.editor.getDocument().footers,e.watermark=H(t.editor.getDocument().watermark),e.totalPages=t.computed.pageCount,e.lineNumberMarks=t.computed.lineNumberMarks,e.headingPageNumbers=N(t.computed),e.syntaxTheme=F(t.codeTheme||"solarized",n.isDark),B(e,1);const s={showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:t.forceImagePlaceholders};if(t.pageless){const l={startY:0,endY:t.geometry.pageHeight};j(e,t.editor,l,s)}else W(e,t.editor,t.geometry.pageIndex,s);return t.mode==="layout"&&A(o,t.computed,t.geometry),r}function K(t,r,o){const n=o==="compact"?360:720,a=o==="compact"?Math.min(2,t.length):t.length,e=Math.ceil(t.length/a),s=16,l=16,m=26,p=t.map(c=>({width:n,height:Math.round(c.height/c.width*n)})),f=Array.from({length:e},(c,u)=>Math.max(...p.slice(u*a,(u+1)*a).map(h=>h.height+m))),d=document.createElement("canvas");d.width=l*2+a*n+Math.max(0,a-1)*s,d.height=l*2+f.reduce((c,u)=>c+u,0)+Math.max(0,e-1)*s;const g=d.getContext("2d");if(!g)throw new Error("The browser could not create a page contact sheet.");g.fillStyle="#e5e7eb",g.fillRect(0,0,d.width,d.height),g.fillStyle="#111827",g.font="600 14px ui-sans-serif, system-ui, sans-serif",g.textBaseline="top";let y=l;for(let c=0;c<e;c+=1){for(let u=0;u<a;u+=1){const h=c*a+u;if(h>=t.length)break;const b=l+u*(n+s);g.fillText(`Page ${r[h]}`,b,y+4),g.drawImage(t[h],b,y+m,p[h].width,p[h].height),g.strokeStyle="#9ca3af",g.strokeRect(b,y+m,p[h].width,p[h].height)}y+=f[c]+s}return d}async function z(t){const r=t.editor.getDocument(),o=P(t.themeElement),n=[],a=[];w(r,null,n,a),await G(n,o.text);const e=document.createElement("canvas");e.width=8,e.height=8;const s=e.getContext("2d");if(!s)throw new Error("The browser could not measure document pages.");const l=I(s);t.editor.setTextMeasurementContext(l,t.layout);const m=E(r,l,t.layout),p=m.pageGeometries?.length?m.pageGeometries:[_(t.layout,m)],f=p.length,d=t.request.startPage-1;if(d<0||d>=f)throw new Error(`start_page ${t.request.startPage} is outside this ${f}-page document.`);const g=p.slice(d,Math.min(f,d+t.request.pageCount)),y=new Set(g.map(i=>i.pageIndex)),c=O(m,y),u=a.filter(i=>i.blockId===null||c.has(i.blockId)),h=await Promise.all(u.map(i=>i.permanentlyPlaceholder?Promise.resolve("placeholder"):L(i.src))),b=g.map(i=>U({editor:t.editor,layout:t.layout,computed:m,geometry:i,pageLayoutSettings:t.pageLayoutSettings,mode:t.request.mode,codeTheme:t.codeTheme,themeElement:t.themeElement,pageless:!!r.pageless})),M=g.map(i=>i.pageIndex+1),x=K(b,M,t.request.quality);let k;try{k=x.toDataURL("image/jpeg",t.request.quality==="compact"?.78:.9)}catch(i){throw typeof i=="object"&&i!==null&&"name"in i&&i.name==="SecurityError"?new R("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):i}const C=n.filter(i=>i.blockId===null||c.has(i.blockId)).filter(i=>{const T=q(i.content,i.displayMode,o.text);return T.loading||!T.image}).length;return{dataUrl:k,width:x.width,height:x.height,pages:M,totalPages:f,placeholderImageCount:h.filter(i=>i==="placeholder").length,failedImageCount:h.filter(i=>i==="failed").length,mathPlaceholderCount:C}}export{A as paintPageLayoutDiagnostics,z as renderDocumentPagesForAgent};
@@ -0,0 +1 @@
1
+ import{Q as l,R as y,T as D}from"./index-iZC8xN0t.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function k(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function b(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const s=e.getWorkingDocument(),f=s.children.length,p=l(s);if(!p&&!t&&l(e.getDocumentWithPendingSuggestionsApplied())&&(t=s.children.at(-1)?.id),!p&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!s.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await k(o);let g;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-CHXj9sNX.js"),h=await a.parseFile(m),i=e.getYDoc();if(t)g=y(i,h,t);else{if(!l(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const d=h.pendingDocxCarrier;if(delete h.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),D(i,h)}),d){const{storeDocxCarrier:c}=await import("./DocxGraft-cYlmw4Ab.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-CQCgsRX1.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:g??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{b as importAttachmentIntoDocument,l as isEmptyDocumentForAttachmentImport};
@@ -0,0 +1 @@
1
+ import{Q as l,R as y,T as D}from"./index-C-4H81OE.js";const w="This attachment was stored in an older per-page image format that cannot be imported. Ask the user to re-attach the original file.";async function k(n){if(n.type==="pdf"&&(n.urls?.length??0)>1)throw new Error(w);const o=n.urls?.[0];if(!o)throw new Error("The attachment no longer has an importable file URL.");const r=await fetch(o);if(!r.ok)throw new Error(`Could not download the attachment (${r.status}).`);const e=await r.blob();if(e.type.startsWith("image/"))throw new Error(w);const t=n.type==="pdf"?"attachment.pdf":"attachment.docx";return new File([e],n.fileName||t,{type:n.mimeType||e.type})}async function b(n){const{attachment:o,documentId:r,documentSession:e}=n;let t=n.afterBlockId?.trim()||void 0;if(o.type!=="docx"&&o.type!=="pdf")throw new Error("Only DOCX and PDF attachments can be imported into the document.");const s=e.getWorkingDocument(),f=s.children.length,p=l(s);if(!p&&!t&&l(e.getDocumentWithPendingSuggestionsApplied())&&(t=s.children.at(-1)?.id),!p&&!t)throw new Error("The current document has content. Provide after_block_id to insert the attachment after a current top-level block without replacing existing content.");if(t&&!s.children.some(a=>a.id===t))throw new Error(`Block "${t}" was not found as a top-level insertion anchor. Read the document and use a current top-level block ID.`);const m=await k(o);let g;if(o.type==="docx"){const{FileImporter:a}=await import("./FileImporter-DetvRoJc.js"),h=await a.parseFile(m),i=e.getYDoc();if(t)g=y(i,h,t);else{if(!l(e.getWorkingDocument()))throw new Error("The current document is no longer empty; import was cancelled. Read the document and provide after_block_id to insert the attachment without replacing existing content.");const d=h.pendingDocxCarrier;if(delete h.pendingDocxCarrier,i.transact(()=>{const c=i.getXmlFragment("content");c.length>0&&c.delete(0,c.length),D(i,h)}),d){const{storeDocxCarrier:c}=await import("./DocxGraft-Ba63IRP4.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-xl7fstr-.js");await a(m,r,e.getYDoc(),void 0,t)}const u=e.getWorkingDocument();return{blockCount:g??(t?Math.max(0,u.children.length-f):u.children.length),fileName:o.fileName||m.name}}export{b as importAttachmentIntoDocument,l as isEmptyDocumentForAttachmentImport};
@@ -0,0 +1,160 @@
1
+ import{r as Ir,e as wn,c as xn}from"./MathRenderer-B0Y1h1JU.js";import{bG as Lr}from"./backend-BIhAX-Gi.js";const Fr={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",
2
+ tsx:"tsx",mts:"typescript",cts:"typescript",py:"python",python3:"python",py3:"python","c++":"cpp",cxx:"cpp",cc:"cpp",hpp:"cpp",h:"c",cs:"c_sharp",csharp:"c_sharp","c#":"c_sharp",golang:"go",rs:"rust",
3
+ rb:"ruby",sh:"bash",shell:"bash",zsh:"bash",htm:"html",yml:"yaml",kt:"kotlin",kts:"kotlin",ex:"elixir",exs:"elixir",sol:"solidity",ml:"ocaml",mli:"ocaml",plaintext:"text",plain:"text",txt:"text"},_n=new Set(
4
+ ["javascript","typescript","tsx","python","java","c","cpp","c_sharp","go","rust","ruby","php","swift","kotlin","scala","bash","css","html","json","yaml","toml","lua","elixir","dart","vue","zig","elm",
5
+ "solidity","ocaml"]);function Jt(t){const e=t.toLowerCase().trim();if(Fr[e]){const n=Fr[e];return n==="text"?null:n}return _n.has(e)?e:null}const $e={keyword:"#0000FF",string:"#A31515",number:"#098658",
6
+ comment:"#008000",function:"#795E26",variable:"#001080",operator:"#000000",punctuation:"#000000",type:"#267F99",property:"#001080",constant:"#0070C1",default:"#000000",background:"#ffffff",text:"#0000\
7
+ 00"};let kt=null,Vt=new Map,Qt=new Map,wt=new Set,Er=!1;function Bn(t){return typeof t=="object"&&t!==null&&"status"in t&&t.status===404?!0:(t instanceof Error?t.message:typeof t=="string"?t:"").includes(
8
+ "status 404")}function jn(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e^t.charCodeAt(n);return(e>>>0).toString(36)}function Cn(t,e){return["const","let","var","function","return","if","else","fo\
9
+ r","while","do","switch","case","break","continue","try","catch","finally","throw","new","delete","typeof","instanceof","void","in","of","class","extends","static","get","set","async","await","yield",
10
+ "import","export","from","as","default","this","super"].includes(t)?"keyword":["string","template_string","string_fragment","template_literal"].includes(t)?"string":["number","integer","float"].includes(
11
+ t)?"number":["comment","line_comment","block_comment"].includes(t)?"comment":t==="identifier"&&(e==="function_declaration"||e==="call_expression"||e==="method_definition")?"function":["type_identifier",
12
+ "predefined_type","type_annotation"].includes(t)?"type":t==="property_identifier"||e==="member_expression"?"property":["true","false","null","undefined"].includes(t)?"constant":["+","-","*","/","%","=",
13
+ "==","===","!=","!==","<",">","<=",">=","&&","||","!","&","|","^","~","<<",">>",">>>","++","--","+=","-=","*=","/=","?",":","=>"].includes(t)?"operator":["(",")","{","}","[","]",";",",",".","..."].includes(
14
+ t)?"punctuation":t==="identifier"?"variable":"default"}function Pe(){return typeof window>"u"||globalThis.__reviseServerRuntime===!0}async function qr(){if(kt)return kt;const t=(async()=>{const e=(await import("./web-tree-sitter-BXGZGnNj.js")).
15
+ Parser;await e.init({locateFile:r=>Ir(`tree-sitter/${r}`)});const n=new e;return Er=!0,n})();return t.catch(()=>{kt===t&&(kt=null)}),kt=t,t}async function Nr(t){if(Vt.has(t))return Vt.get(t);if(wt.has(
16
+ t))return null;if(Qt.has(t))return Qt.get(t);const e=(async()=>{try{const n=await(await import("./web-tree-sitter-BXGZGnNj.js")).Language.load(Ir(`tree-sitter/tree-sitter-${t}.wasm`));return Vt.set(t,
17
+ n),n}catch(n){return Bn(n)?(wt.add(t),console.warn(`Tree-sitter grammar not found for ${t} (404). Disabling syntax highlighting for this language.`),null):(console.warn(`Failed to load tree-sitter gra\
18
+ mmar for ${t}:`,n),null)}finally{Qt.delete(t)}})();return Qt.set(t,e),e}function Dr(t,e){if(t.childCount===0)e.push({start:t.startIndex,end:t.endIndex,type:t.type,parentType:t.parent?.type});else for(let n=0;n<
19
+ t.childCount;n++)Dr(t.child(n),e)}function Mn(t="javascript"){const e=Jt(t);return e?Er&&Vt.has(e):!0}async function Sn(t="javascript"){if(Pe())return!1;const e=Jt(t);if(!e)return!0;if(wt.has(e))return!1;
20
+ try{const n=await qr(),r=await Nr(e);return r?(n.setLanguage(r),!0):!1}catch(n){return console.warn("Failed to preload syntax highlighter:",n),!1}}async function Re(t,e="javascript",n=$e){if(Pe())return null;
21
+ const r=Jt(e);if(!r||wt.has(r))return null;try{const a=await qr(),o=await Nr(r);if(!o)return null;a.setLanguage(o);const l=a.parse(t),s=[];Dr(l.rootNode,s),s.sort((h,N)=>h.start-N.start);const f=[];let m=0;
22
+ for(const h of s){if(h.start>m){const w=t.slice(m,h.start);w&&f.push({text:w,color:n.default})}const N=t.slice(h.start,h.end);if(N){const w=Cn(h.type,h.parentType);f.push({text:N,color:n[w]})}m=h.end}
23
+ return m<t.length&&f.push({text:t.slice(m),color:n.default}),f}catch(a){return console.warn("Syntax highlighting failed:",a),null}}let lt=new Map;const In=100;function Ln(t,e="javascript",n){if(Pe())return null;
24
+ const r=Jt(e);if(!r||wt.has(r))return null;const a=n||$e,o=a.keyword+a.string,l=`${r}:${o}:${jn(t)}`;if(lt.has(l))return lt.get(l);const s=(f,m)=>{if(lt.size>=In){const h=lt.keys().next().value;h&&lt.
25
+ delete(h)}lt.set(f,m)};return Mn(r)?(Re(t,r,a).then(f=>{f&&s(l,f)}),null):(Re(t,r,a).then(f=>{f&&(s(l,f),typeof window<"u"&&window.dispatchEvent(new CustomEvent("syntax-highlight-ready")))}),null)}const xt=180,
26
+ ze=new Map,Gt=new Map,Tr=new Map,$r=new Map,Fn=new Set,J=new Map;let Ae=null,Pr=0;function G(t){return t.trim().toLowerCase()}function Rr(t){return[t.background,t.text,t.selection,t.pageBorder,t.pageBackground,
27
+ t.codeBackground,t.codeBorder,t.codeText,t.diffInsert,t.diffDelete].join("|")}function Oe(t){const e=G(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}:${t.source}`}function Kt(t){
28
+ const e=G(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}`}function zr(t){const e=Kt(t);return Tr.get(e)||{width:Math.max(120,Math.round(t.maxWidth)),height:xt}}function We(t){
29
+ return t.replace(/\s+/g," ").trim()}function En(t){if(t instanceof Error&&t.message)return We(t.message);if(typeof t=="string"&&t.trim())return We(t);if(t&&typeof t=="object"){const e=t,n=typeof e.message==
30
+ "string"&&e.message||typeof e.str=="string"&&e.str||"",r=typeof e.hash=="object"&&e.hash?e.hash:null,a=r&&typeof r.line=="number"&&Number.isFinite(r.line)?r.line+1:null,o=r&&typeof r.loc=="object"&&r.
31
+ loc?r.loc:null,l=o&&typeof o.first_column=="number"&&Number.isFinite(o.first_column)?o.first_column+1:null,s=a!==null?`Line ${a}${l!==null?`, col ${l}`:""}: `:"";if(n.trim())return`${s}${We(n)}`}return"\
32
+ Diagram render failed"}function qn(t,e,n){if(e<=0||n<=0||!Number.isFinite(e)||!Number.isFinite(n))return;const r=Kt(t);Tr.set(r,{width:Math.max(1,Math.round(e)),height:Math.max(1,Math.round(n))})}function Nn(t,e){
33
+ if(!e.image||e.width<=0||e.height<=0)return;const n=Kt(t);$r.set(n,{image:e.image,svg:e.svg,width:Math.max(1,Math.round(e.width)),height:Math.max(1,Math.round(e.height))})}function Dn(){typeof window<
34
+ "u"&&window.dispatchEvent(new CustomEvent("diagram-render-ready"));for(const t of Fn)try{t()}catch(e){console.error("diagram render callback failed:",e)}}function Tn(t){if(typeof DOMParser<"u")try{const n=new DOMParser().
35
+ parseFromString(t,"image/svg+xml").documentElement,r=n.getAttribute("viewBox");if(r){const l=r.split(/\s+/).map(s=>Number.parseFloat(s)).filter(s=>Number.isFinite(s));if(l.length===4&&l[2]>0&&l[3]>0)return{
36
+ width:l[2],height:l[3]}}const a=n.getAttribute("width"),o=n.getAttribute("height");if(a&&o){const l=Number.parseFloat(a),s=Number.parseFloat(o);if(Number.isFinite(l)&&Number.isFinite(s))return{width:l,
37
+ height:s}}}catch{}const e=t.match(/viewBox="([^"]+)"/i);if(e){const n=e[1].split(/\s+/).map(r=>Number.parseFloat(r)).filter(r=>Number.isFinite(r));if(n.length===4&&n[2]>0&&n[3]>0)return{width:n[2],height:n[3]}}
38
+ return{width:800,height:xt}}function $n(t,e,n){if(t<=0||e<=0)return{width:n,height:xt};if(t<=n)return{width:t,height:e};const r=n/t;return{width:n,height:Math.max(40,Math.round(e*r))}}async function Pn(t,e,n){
39
+ const r="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(t),a=new Image;return new Promise((o,l)=>{a.onload=()=>{o(a)},a.onerror=()=>{l(new Error("Failed to load rendered diagram SVG"))},a.src=r,
40
+ a.width=Math.max(1,Math.round(e)),a.height=Math.max(1,Math.round(n))})}function Rn(t){const e=Math.max(1,t.naturalWidth||t.width||1),n=Math.max(1,t.naturalHeight||t.height||1),r=document.createElement(
41
+ "canvas");r.width=e,r.height=n;const a=r.getContext("2d");if(!a)throw new Error("Unable to create PNG export canvas");return a.drawImage(t,0,0,e,n),r.toDataURL("image/png")}async function zn(){if(typeof window>
42
+ "u")throw new Error("Mermaid runtime requires a browser environment");return window.mermaid?window.mermaid:(Ae||(Ae=new Promise((t,e)=>{const n=document.querySelector('script[data-revise-mermaid="true\
43
+ "]');if(n){n.addEventListener("load",()=>t(window.mermaid)),n.addEventListener("error",()=>e(new Error("Failed to load Mermaid script")));return}const r=document.createElement("script");r.src="https:/\
44
+ /cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js",r.async=!0,r.defer=!0,r.setAttribute("data-revise-mermaid","true"),r.onload=()=>t(window.mermaid),r.onerror=()=>e(new Error("Failed to load Mermai\
45
+ d script")),document.head.appendChild(r)})),Ae)}function An(t){return{background:t.pageBackground,primaryColor:t.codeBackground,primaryBorderColor:t.codeBorder,primaryTextColor:t.codeText,secondaryColor:t.
46
+ background,secondaryBorderColor:t.pageBorder,tertiaryColor:t.background,tertiaryBorderColor:t.pageBorder,lineColor:t.text,arrowheadColor:t.text,defaultLinkColor:t.text,textColor:t.text,edgeLabelBackground:t.
47
+ pageBackground,clusterBkg:t.codeBackground,clusterBorder:t.pageBorder,nodeBorder:t.codeBorder,fontFamily:"Arial, sans-serif",cScale0:t.codeBackground,cScale1:t.background,cScale2:t.pageBackground,cScaleLabel0:t.
48
+ text,cScaleLabel1:t.text,cScaleLabel2:t.text}}function Ar(t){if(typeof document>"u")return;const e=document.getElementById(t);e?.parentElement&&e.parentElement.removeChild(e)}const On={protocol:"merma\
49
+ id",renderToSvg:async(t,e)=>{const n=await zn();if(!n)throw new Error("Mermaid runtime unavailable");n.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"base",themeVariables:An(
50
+ e)}),Pr+=1;const r=`revise-mermaid-${Pr}`;Ar(r);let a;try{a=await n.render(r,t)}finally{Ar(r)}const o=typeof a=="string"?a:a?.svg;if(!o||typeof o!="string")throw new Error("Mermaid returned invalid SV\
51
+ G output");const l=Tn(o);return{svg:o,width:l.width,height:l.height}}};function Or(t,e){return{protocol:t,renderToSvg:async(n,r)=>{const a=n.trim();if(!a)throw new Error("LaTeX source is empty");await wn(
52
+ a,e,r.text);const o=xn(a,e,r.text);if(!o?.svg)throw new Error("LaTeX render unavailable");return{svg:o.svg,width:o.width,height:o.height}}}}function Wr(){J.has("mermaid")||J.set("mermaid",On),J.has("l\
53
+ atex")||J.set("latex",Or("latex",!0)),J.has("latex-inline")||J.set("latex-inline",Or("latex-inline",!1))}async function Wn(t){Wr();const e=G(t.protocol),n=J.get(e);if(!n)return{image:null,width:t.maxWidth,
54
+ height:xt,loading:!1,error:`Unsupported diagram protocol: ${t.protocol}`};try{const{svg:r,width:a,height:o}=await n.renderToSvg(t.source,t.theme),l=$n(a,o,t.maxWidth);qn(t,l.width,l.height);const s={image:await Pn(
55
+ r,l.width,l.height),svg:r,width:l.width,height:l.height,loading:!1};return Nn(t,s),s}catch(r){const a=zr(t);return{image:null,width:a.width,height:a.height,loading:!1,error:En(r)}}}function Xr(t){if(!t)
56
+ return null;Wr();const e=G(t);return J.has(e)?e:null}function Xe(t){const e=G(t.protocol);if(!e||!t.source.trim())return{image:null,width:t.maxWidth,height:xt,loading:!1,error:"Diagram source is empty"};
57
+ const n={...t,protocol:e,source:t.source},r=Oe(n),a=ze.get(r);if(a)return a;if(!Gt.has(r)){const f=Wn(n).then(m=>(ze.set(r,m),Gt.delete(r),Dn(),m));Gt.set(r,f)}const o=Kt(n),l=$r.get(o);if(l)return{image:l.
58
+ image,svg:l.svg,width:l.width,height:l.height,loading:!0};const s=zr(n);return{image:null,width:s.width,height:s.height,loading:!0}}async function Zr(t){const e=Xe(t);if(!e.loading)return e;const n=Oe(
59
+ {...t,protocol:G(t.protocol)});return Gt.get(n)||Xe(t)}function Hr(t){const e=Oe({...t,protocol:G(t.protocol)}),n=ze.get(e);return!n||n.loading?null:n}function Xn(t){const e=Hr(t);return!e||!e.svg?null:
60
+ {svg:e.svg,width:e.width,height:e.height}}function Zn(t){if(typeof document>"u")return null;const e=Hr(t);if(!e||!e.image)return null;try{return{dataUrl:Rn(e.image),width:e.width,height:e.height}}catch{
61
+ return null}}async function Hn(t,e,n){const r=[],a=o=>{if(!(!o||typeof o!="object")){if(o.type==="code"){const l=Xr(o.language);l&&o.renderDiagram!==!1&&o.content?.trim()&&r.push({protocol:l,source:o.
62
+ content,theme:e,maxWidth:n});return}if(o.type==="container"||o.type==="table-cell"){for(const l of o.children||[])a(l);return}if(o.type==="table")for(const l of o.children||[])for(const s of l.children||
63
+ [])for(const f of s.children||[])a(f)}};for(const o of t.children)a(o);r.length!==0&&await Promise.all(r.map(o=>Zr(o)))}const Ur={isDark:!1,background:"#f5f5f5",text:"#000000",linkText:"#007bff",selection:"\
64
+ #3390ff",selectionOpacity:.4,inactiveSelection:"#9ac0e8",inactiveSelectionOpacity:.35,agentReadHighlight:"#7aaee6",searchHighlight:"#cc8f00",cursor:"#000000",pageBorder:"#dee2e6",pageBackground:"#ffff\
65
+ ff",pageShadow:"rgba(0, 0, 0, 0.1)",diffInsert:"#22c55e",diffDelete:"#CF2A2A",diffEqual:"#000000",diffFormatChange:"#f59e0b",diffInsertText:"#0B8237",diffDeleteText:"#CF2A2A",diffFormatChangeText:"#78\
66
+ 350f",debugText:"#ff0000",todoCheckboxBorder:"#c8ccd5",todoCheckboxBackground:"#ffffff",todoCheckboxChecked:"#46b35e",todoCheckboxCheckmark:"#46b35e",todoCheckedText:"#6c757d",codeBackground:"#f5f5f5",
67
+ codeBorder:"#e0e0e0",codeText:"#333333"},Un={isDark:!0,background:"#080a0e",text:"#c9c9c9",linkText:"#4099ff",selection:"#4099ff",selectionOpacity:.4,inactiveSelection:"#5a7a9e",inactiveSelectionOpacity:.35,
68
+ agentReadHighlight:"#24568f",searchHighlight:"#fbbf24",cursor:"#ffffff",pageBorder:"#1e2430",pageBackground:"#05060a",pageShadow:"rgba(0, 0, 0, 0.5)",diffInsert:"#50B173",diffDelete:"#f87171",diffEqual:"\
69
+ #c9c9c9",diffFormatChange:"#fbbf24",diffInsertText:"#50B173",diffDeleteText:"#f87171",diffFormatChangeText:"#f5a91d",debugText:"#ff6b6b",todoCheckboxBorder:"#2f3747",todoCheckboxBackground:"#05060a",todoCheckboxChecked:"\
70
+ #0e6b30",todoCheckboxCheckmark:"#f3f7ff",todoCheckedText:"#6f7689",codeBackground:"#0c0f15",codeBorder:"#2a2f3a",codeText:"#c9c9c9"};function Jn(t){if(typeof window>"u")return!1;const e=t?.closest?.("\
71
+ [data-theme]")?.getAttribute("data-theme");return e==="dark"?!0:e==="light"?!1:document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("dark-theme")}function Jr(t){
72
+ const e=Jn(t)?Un:Ur,n=t?.closest?.("[data-page-background]")?.getAttribute("data-page-background");return n?{...e,pageBackground:n}:e}function Vn(t,e){const n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(
73
+ 3,5),16),a=parseInt(t.slice(5,7),16);return`rgba(${n}, ${r}, ${a}, ${e})`}const Vr=["bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","letterSpacing","code","late\
74
+ x","superscript","subscript","backgroundColor","link"],Qn=Vr.reduce((t,e)=>(t[e]=null,t),{}),Gn=[],Ze={yellow:"#FDE68A",orange:"#FED7AA",green:"#BBF7D0",blue:"#BFDBFE",purple:"#E9D5FF",pink:"#FBCFE8",
75
+ gray:"#E5E7EB"},Kn={yellow:"#7C5E10",orange:"#7C3F16",green:"#1F5F3A",blue:"#1E4E8C",purple:"#5B3A7A",pink:"#7A3F66",gray:"#4B5563"},Qr=Ze,Gr=["yellow","orange","green","blue","purple","pink","gray"],
76
+ Yn={yellow:"yellow",gold:"yellow",orange:"orange",darkorange:"orange",darkyellow:"orange",green:"green",darkgreen:"green",blue:"blue",cyan:"blue",darkblue:"blue",darkcyan:"blue",purple:"purple",violet:"\
77
+ purple",darkviolet:"purple",darkmagenta:"purple",pink:"pink",magenta:"pink",red:"pink",darkred:"pink",gray:"gray",grey:"gray",lightgray:"gray",lightgrey:"gray",darkgray:"gray",darkgrey:"gray",black:"g\
78
+ ray",white:"gray"},ta={yellow:"yellow",gold:"yellow",orange:"orange",green:"green",blue:"blue",cyan:"blue",purple:"purple",violet:"purple",pink:"pink",magenta:"pink",red:"pink",gray:"gray",grey:"gray",
79
+ lightgray:"gray",lightgrey:"gray"},ea="yellow";function ra(t){if(!t)return;const e=t.trim().toLowerCase().replace(/[\s_-]+/g,"");return Yn[e]}function na(t){return Yt(t)}function aa(t){const e=Yt(t);return e?
80
+ Qr[e]:void 0}function oa(t,e=Jr().isDark){const n=Yt(t);return n?(e?Kn:Ze)[n]:void 0}function Kr(t){const e=Lr(t);return e?[e.r,e.g,e.b]:null}function ia(t){const e=Lr(t);return e?{rgb:[e.r,e.g,e.b],alpha:e.
81
+ a}:null}function Yr(t,e=!1,n=Gr){let r=null,a=Number.POSITIVE_INFINITY;for(const o of n){const l=[Qr[o],...e?[Ze[o]]:[]];for(const s of l){const f=Kr(s);if(!f)continue;const m=(t[0]-f[0])**2+(t[1]-f[1])**
82
+ 2+(t[2]-f[2])**2;m<a&&(a=m,r=o)}}return r?{name:r,distance:a}:null}function la(t){const[e,n,r]=t.map(h=>h/255),a=Math.max(e,n,r),o=Math.min(e,n,r),l=a-o,s=(a+o)/2,f=l===0?0:l/(1-Math.abs(2*s-1));let m=null;
83
+ return l!==0&&(a===e?m=60*((n-r)/l%6):a===n?m=60*((r-e)/l+2):m=60*((e-n)/l+4),m<0&&(m+=360)),{hue:m,lightness:s,saturation:f,maxChannel:Math.max(...t)}}function sa(t){return t>=20&&t<42?"orange":t>=42&&
84
+ t<85?"yellow":t>=85&&t<170?"green":t>=170&&t<255?"blue":t>=255&&t<320?"purple":"pink"}function ca(t){if(!t)return;const e=t.trim().toLowerCase().replace(/[\s_-]+/g,"");return ta[e]}function Yt(t){if(!t)
85
+ return;const e=ra(t);if(e)return e;if(/^[a-z]+$/i.test(t.trim()))return;const n=Kr(t);if(n)return Yr(n)?.name}function fa(t){if(!t)return;const e=ca(t);if(e)return e;const n=ia(t);if(!n||n.alpha<.35)return;
86
+ const{hue:r,lightness:a,saturation:o,maxChannel:l}=la(n.rgb),s=o>.18&&r!==null?[sa(r)]:["gray"],f=Yr(n.rgb,!0,s);if(!f)return;if(f.distance===0)return f.name;if(f.name==="gray")return f.distance>70**2||
87
+ o>.12||a<.68||a>.92?void 0:f.name;const m=o>=.8&&l>=220&&a>=.45;if(!(f.distance>95**2&&!m)&&!(a>.92)&&!(l<150)&&!(o<.22)&&!(a<.55&&l<220))return f.name}const O={paragraph:16,h1:32,h2:24,h3:20,h4:18,h5:16,
88
+ h6:14,code:14},te={paragraph:1.4,heading:1.2,code:1.5};function tn(t){if(!t.hasOwnProperty("heading"))return O.paragraph;switch(t.heading){case 1:return O.h1;case 2:return O.h2;case 3:return O.h3;case 4:
89
+ return O.h4;case 5:return O.h5;case 6:return O.h6;default:return O.paragraph}}function en(t){return t.lineSpacing!==void 0?t.lineSpacing:t.heading?te.heading:te.paragraph}function ua(t){const e=tn(t),
90
+ n=en(t);return e*n}function da(t){return t.lineSpacing!==void 0?t.lineSpacing:te.paragraph}function ha(){var t=function(e){var n={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+\
91
+ 9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,a\
92
+ v,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,\
93
+ 2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9\
94
+ ,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2\
95
+ +2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4\
96
+ ,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2\
97
+ +3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1e\
98
+ kf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1\
99
+ ,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,\
100
+ 2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c\
101
+ ,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1a\
102
+ f+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,\
103
+ 2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,\
104
+ f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"\
105
+ 6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},r={},a={};r.L=1,a[1]="L",Object.keys(n).forEach(function(u,k){r[u]=1<<k+1,a[r[u]]=u}),Object.freeze(r);var o=r.LRI|
106
+ r.RLI|r.FSI,l=r.L|r.R|r.AL,s=r.B|r.S|r.WS|r.ON|r.FSI|r.LRI|r.RLI|r.PDI,f=r.BN|r.RLE|r.LRE|r.RLO|r.LRO|r.PDF,m=r.S|r.WS|r.B|o|r.PDI|f,h=null;function N(){if(!h){h=new Map;var u=function(y){if(n.hasOwnProperty(
107
+ y)){var i=0;n[y].split(",").forEach(function(_){var d=_.split("+"),p=d[0],g=d[1];p=parseInt(p,36),g=g?parseInt(g,36):0,h.set(i+=p,r[y]);for(var j=0;j<g;j++)h.set(++i,r[y])})}};for(var k in n)u(k)}}function w(u){
108
+ return N(),h.get(u.codePointAt(0))||r.L}function K(u){return a[w(u)]}var jt={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,\
109
+ +2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>\
110
+ -14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function re(u,k){var y=36,i=0,_=new Map,d=k&&new Map,p;return u.split("\
111
+ ,").forEach(function g(j){if(j.indexOf("+")!==-1)for(var C=+j;C--;)g(p);else{p=j;var v=j.split(">"),B=v[0],P=v[1];B=String.fromCodePoint(i+=parseInt(B,y)),P=String.fromCodePoint(i+=parseInt(P,y)),_.set(
112
+ B,P),k&&d.set(P,B)}}),{map:_,reverseMap:d}}var ne,Ue,Je;function ae(){if(!ne){var u=re(jt.pairs,!0),k=u.map,y=u.reverseMap;ne=k,Ue=y,Je=re(jt.canonical,!1).map}}function oe(u){return ae(),ne.get(u)||null}
113
+ function ie(u){return ae(),Ue.get(u)||null}function le(u){return ae(),Je.get(u)||null}var E=r.L,D=r.R,I=r.EN,st=r.ES,Ct=r.ET,ct=r.AN,Mt=r.CS,Y=r.B,an=r.S,St=r.ON,on=r.BN,It=r.NSM,Lt=r.AL,Ve=r.LRO,Ft=r.
114
+ RLO,Qe=r.LRE,se=r.RLE,Ge=r.PDF,ln=r.LRI,Ke=r.RLI,sn=r.FSI,tt=r.PDI;function cn(u,k){for(var y=125,i=new Uint32Array(u.length),_=0;_<u.length;_++)i[_]=w(u[_]);var d=new Map;function p(L,$){var F=i[L];i[L]=
115
+ $,d.set(F,d.get(F)-1),F&s&&d.set(s,d.get(s)-1),d.set($,(d.get($)||0)+1),$&s&&d.set(s,(d.get(s)||0)+1)}for(var g=new Uint8Array(u.length),j=new Map,C=[],v=null,B=0;B<u.length;B++)v||C.push(v={start:B,end:u.
116
+ length-1,level:k==="rtl"?1:k==="ltr"?0:Mr(B,!1)}),i[B]&Y&&(v.end=B,v=null);for(var P=se|Qe|Ft|Ve|o|tt|Ge|Y,V=function(L){return L+(L&1?1:2)},W=function(L){return L+(L&1?2:1)},X=0;X<C.length;X++){v=C[X];
117
+ var b=[{_level:v.level,_override:0,_isolate:0}],x=void 0,A=0,Z=0,ue=0;d.clear();for(var M=v.start;M<=v.end;M++){var S=i[M];if(x=b[b.length-1],d.set(S,(d.get(S)||0)+1),S&s&&d.set(s,(d.get(s)||0)+1),S&P)
118
+ if(S&(se|Qe)){g[M]=x._level;var er=(S===se?W:V)(x._level);er<=y&&!A&&!Z?b.push({_level:er,_override:0,_isolate:0}):A||Z++}else if(S&(Ft|Ve)){g[M]=x._level;var rr=(S===Ft?W:V)(x._level);rr<=y&&!A&&!Z?b.
119
+ push({_level:rr,_override:S&Ft?D:E,_isolate:0}):A||Z++}else if(S&o){S&sn&&(S=Mr(M+1,!0)===1?Ke:ln),g[M]=x._level,x._override&&p(M,x._override);var nr=(S===Ke?W:V)(x._level);nr<=y&&A===0&&Z===0?(ue++,b.
120
+ push({_level:nr,_override:0,_isolate:1,_isolInitIndex:M})):A++}else if(S&tt){if(A>0)A--;else if(ue>0){for(Z=0;!b[b.length-1]._isolate;)b.pop();var de=b[b.length-1]._isolInitIndex;de!=null&&(j.set(de,M),
121
+ j.set(M,de)),b.pop(),ue--}x=b[b.length-1],g[M]=x._level,x._override&&p(M,x._override)}else S&Ge?(A===0&&(Z>0?Z--:!x._isolate&&b.length>1&&(b.pop(),x=b[b.length-1])),g[M]=x._level):S&Y&&(g[M]=v.level);else
122
+ g[M]=x._level,x._override&&S!==on&&p(M,x._override)}for(var et=[],R=null,Q=v.start;Q<=v.end;Q++){var he=i[Q];if(!(he&f)){var ar=g[Q],or=he&o,gn=he===tt;R&&ar===R._level?(R._end=Q,R._endsWithIsolInit=or):
123
+ et.push(R={_start:Q,_end:Q,_level:ar,_startsWithPDI:gn,_endsWithIsolInit:or})}}for(var ge=[],Et=0;Et<et.length;Et++){var qt=et[Et];if(!qt._startsWithPDI||qt._startsWithPDI&&!j.has(qt._start)){for(var pe=[
124
+ R=qt],ir=void 0;R&&R._endsWithIsolInit&&(ir=j.get(R._end))!=null;)for(var Nt=Et+1;Nt<et.length;Nt++)if(et[Nt]._start===ir){pe.push(R=et[Nt]);break}for(var rt=[],me=0;me<pe.length;me++)for(var lr=pe[me],
125
+ ve=lr._start;ve<=lr._end;ve++)rt.push(ve);for(var pn=g[rt[0]],sr=v.level,Dt=rt[0]-1;Dt>=0;Dt--)if(!(i[Dt]&f)){sr=g[Dt];break}var ye=rt[rt.length-1],mn=g[ye],cr=v.level;if(!(i[ye]&o)){for(var Tt=ye+1;Tt<=
126
+ v.end;Tt++)if(!(i[Tt]&f)){cr=g[Tt];break}}ge.push({_seqIndices:rt,_sosType:Math.max(sr,pn)%2?D:E,_eosType:Math.max(cr,mn)%2?D:E})}}for(var be=0;be<ge.length;be++){var ke=ge[be],c=ke._seqIndices,ft=ke.
127
+ _sosType,vn=ke._eosType,nt=g[c[0]]&1?D:E;if(d.get(It))for(var $t=0;$t<c.length;$t++){var fr=c[$t];if(i[fr]&It){for(var we=ft,Pt=$t-1;Pt>=0;Pt--)if(!(i[c[Pt]]&f)){we=i[c[Pt]];break}p(fr,we&(o|tt)?St:we)}}
128
+ if(d.get(I))for(var Rt=0;Rt<c.length;Rt++){var ur=c[Rt];if(i[ur]&I)for(var zt=Rt-1;zt>=-1;zt--){var dr=zt===-1?ft:i[c[zt]];if(dr&l){dr===Lt&&p(ur,ct);break}}}if(d.get(Lt))for(var xe=0;xe<c.length;xe++){
129
+ var hr=c[xe];i[hr]&Lt&&p(hr,D)}if(d.get(st)||d.get(Mt))for(var ut=1;ut<c.length-1;ut++){var _e=c[ut];if(i[_e]&(st|Mt)){for(var at=0,Be=0,je=ut-1;je>=0&&(at=i[c[je]],!!(at&f));je--);for(var Ce=ut+1;Ce<
130
+ c.length&&(Be=i[c[Ce]],!!(Be&f));Ce++);at===Be&&(i[_e]===st?at===I:at&(I|ct))&&p(_e,at)}}if(d.get(I))for(var z=0;z<c.length;z++){var yn=c[z];if(i[yn]&I){for(var At=z-1;At>=0&&i[c[At]]&(Ct|f);At--)p(c[At],
131
+ I);for(z++;z<c.length&&i[c[z]]&(Ct|f|I);z++)i[c[z]]!==I&&p(c[z],I)}}if(d.get(Ct)||d.get(st)||d.get(Mt))for(var dt=0;dt<c.length;dt++){var gr=c[dt];if(i[gr]&(Ct|st|Mt)){p(gr,St);for(var Ot=dt-1;Ot>=0&&
132
+ i[c[Ot]]&f;Ot--)p(c[Ot],St);for(var Wt=dt+1;Wt<c.length&&i[c[Wt]]&f;Wt++)p(c[Wt],St)}}if(d.get(I))for(var Me=0,pr=ft;Me<c.length;Me++){var mr=c[Me],Se=i[mr];Se&I?pr===E&&p(mr,E):Se&l&&(pr=Se)}if(d.get(
133
+ s)){var ht=D|I|ct,vr=ht|E,Xt=[];{for(var ot=[],it=0;it<c.length;it++)if(i[c[it]]&s){var gt=u[c[it]],yr=void 0;if(oe(gt)!==null)if(ot.length<63)ot.push({char:gt,seqIndex:it});else break;else if((yr=ie(
134
+ gt))!==null)for(var pt=ot.length-1;pt>=0;pt--){var Ie=ot[pt].char;if(Ie===yr||Ie===ie(le(gt))||oe(le(Ie))===gt){Xt.push([ot[pt].seqIndex,it]),ot.length=pt;break}}}Xt.sort(function(L,$){return L[0]-$[0]})}
135
+ for(var Le=0;Le<Xt.length;Le++){for(var br=Xt[Le],Zt=br[0],Fe=br[1],kr=!1,T=0,Ee=Zt+1;Ee<Fe;Ee++){var wr=c[Ee];if(i[wr]&vr){kr=!0;var xr=i[wr]&ht?D:E;if(xr===nt){T=xr;break}}}if(kr&&!T){T=ft;for(var qe=Zt-
136
+ 1;qe>=0;qe--){var _r=c[qe];if(i[_r]&vr){var Br=i[_r]&ht?D:E;Br!==nt?T=Br:T=nt;break}}}if(T){if(i[c[Zt]]=i[c[Fe]]=T,T!==nt){for(var mt=Zt+1;mt<c.length;mt++)if(!(i[c[mt]]&f)){w(u[c[mt]])&It&&(i[c[mt]]=
137
+ T);break}}if(T!==nt){for(var vt=Fe+1;vt<c.length;vt++)if(!(i[c[vt]]&f)){w(u[c[vt]])&It&&(i[c[vt]]=T);break}}}}for(var H=0;H<c.length;H++)if(i[c[H]]&s){for(var jr=H,Ne=H,De=ft,yt=H-1;yt>=0;yt--)if(i[c[yt]]&
138
+ f)jr=yt;else{De=i[c[yt]]&ht?D:E;break}for(var Cr=vn,bt=H+1;bt<c.length;bt++)if(i[c[bt]]&(s|f))Ne=bt;else{Cr=i[c[bt]]&ht?D:E;break}for(var Te=jr;Te<=Ne;Te++)i[c[Te]]=De===Cr?De:nt;H=Ne}}}for(var q=v.start;q<=
139
+ v.end;q++){var bn=g[q],Ht=i[q];if(bn&1?Ht&(E|I|ct)&&g[q]++:Ht&D?g[q]++:Ht&(ct|I)&&(g[q]+=2),Ht&f&&(g[q]=q===0?v.level:g[q-1]),q===v.end||w(u[q])&(an|Y))for(var Ut=q;Ut>=0&&w(u[Ut])&m;Ut--)g[Ut]=v.level}}
140
+ return{levels:g,paragraphs:C};function Mr(L,$){for(var F=L;F<u.length;F++){var U=i[F];if(U&(D|Lt))return 1;if(U&(Y|E)||$&&U===tt)return 0;if(U&o){var Sr=kn(F);F=Sr===-1?u.length:Sr}}return 0}function kn(L){
141
+ for(var $=1,F=L+1;F<u.length;F++){var U=i[F];if(U&Y)break;if(U&tt){if(--$===0)return F}else U&o&&$++}return-1}}var fn="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>\
142
+ 1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7\
143
+ >8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1\
144
+ >1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",ce;function un(){if(!ce){var u=re(fn,!0),k=u.map,y=u.reverseMap;y.forEach(
145
+ function(i,_){k.set(_,i)}),ce=k}}function fe(u){return un(),ce.get(u)||null}function dn(u,k,y,i){var _=u.length;y=Math.max(0,y==null?0:+y),i=Math.min(_-1,i==null?_-1:+i);for(var d=new Map,p=y;p<=i;p++)
146
+ if(k[p]&1){var g=fe(u[p]);g!==null&&d.set(p,g)}return d}function Ye(u,k,y,i){var _=u.length;y=Math.max(0,y==null?0:+y),i=Math.min(_-1,i==null?_-1:+i);var d=[];return k.paragraphs.forEach(function(p){var g=Math.
147
+ max(y,p.start),j=Math.min(i,p.end);if(g<j){for(var C=k.levels.slice(g,j+1),v=j;v>=g&&w(u[v])&m;v--)C[v]=p.level;for(var B=p.level,P=1/0,V=0;V<C.length;V++){var W=C[V];W>B&&(B=W),W<P&&(P=W|1)}for(var X=B;X>=
148
+ P;X--)for(var b=0;b<C.length;b++)if(C[b]>=X){for(var x=b;b+1<C.length&&C[b+1]>=X;)b++;b>x&&d.push([x+g,b+g])}}}),d}function hn(u,k,y,i){var _=tr(u,k,y,i),d=[].concat(u);return _.forEach(function(p,g){
149
+ d[g]=(k.levels[p]&1?fe(u[p]):null)||u[p]}),d.join("")}function tr(u,k,y,i){for(var _=Ye(u,k,y,i),d=[],p=0;p<u.length;p++)d[p]=p;return _.forEach(function(g){for(var j=g[0],C=g[1],v=d.slice(j,C+1),B=v.
150
+ length;B--;)d[C-B]=v[B]}),d}return e.closingToOpeningBracket=ie,e.getBidiCharType=w,e.getBidiCharTypeName=K,e.getCanonicalBracket=le,e.getEmbeddingLevels=cn,e.getMirroredCharacter=fe,e.getMirroredCharactersMap=
151
+ dn,e.getReorderSegments=Ye,e.getReorderedIndices=tr,e.getReorderedString=hn,e.openingToClosingBracket=oe,Object.defineProperty(e,"__esModule",{value:!0}),e}({});return t}const ga=new Set(["R","AL","AN",
152
+ "RLE","RLO","RLI","LRE","LRO","LRI","FSI","PDI","PDF"]),_t=new Map,pa=500;function rn(t){const e=_t.get(t);if(e!==void 0)return e;let n=!1;for(const r of t)if(ga.has(ee().getBidiCharTypeName(r))){n=!0;
153
+ break}if(_t.size>=pa){const r=_t.keys().next().value;r!==void 0&&_t.delete(r)}return _t.set(t,n),n}function nn(t){for(let e=0;e<t.length;){const n=t.codePointAt(e);if(n===void 0)break;const r=String.fromCodePoint(
154
+ n),a=ee().getBidiCharTypeName(r);if(a==="R"||a==="AL")return"rtl";if(a==="L")return"ltr";e+=r.length}return null}function ma(t,e){return t==="rtl"||t==="ltr"?t:nn(e)??"ltr"}let He=null;function ee(){return He||
155
+ (He=ha()),He}const Bt=new Map,va=300;function ya(t,e){const n=e+"\0"+t,r=Bt.get(n);if(r)return r;const a=ee().getEmbeddingLevels(t,e);if(Bt.size>=va){const o=Bt.keys().next().value;o!==void 0&&Bt.delete(
156
+ o)}return Bt.set(n,a),a}function ba(t,e,n,r){if(r<=n)return[];if(e==="ltr"&&!rn(t.slice(n,r)))return[{start:n,end:r,rtl:!1}];const a=ya(t,e),o=ee().getReorderSegments(t,a,n,r-1),l=r-n,s=new Array(l);for(let h=0;h<
157
+ l;h++)s[h]=n+h;for(const[h,N]of o){let w=h-n,K=N-n;for(;w<K;){const jt=s[w];s[w]=s[K],s[K]=jt,w++,K--}}const f=[];let m=0;for(let h=1;h<=l;h++){if(!(h===l||Math.abs(s[h]-s[h-1])!==1||s[h]-s[h-1]!==s[m+
158
+ 1]-s[m]))continue;const N=s[m],w=s[h-1];N<=w?f.push({start:N,end:w+1,rtl:!1}):f.push({start:w,end:N+1,rtl:!0}),m=h}for(const h of f)h.end-h.start===1&&(h.rtl=(a.levels[h.start]&1)===1);return f}export{
159
+ Xe as A,Sn as B,Gn as C,ea as D,O as F,Gr as H,te as L,Qn as a,Vr as b,nn as c,fa as d,Jr as e,Hn as f,Xr as g,Yt as h,aa as i,Xn as j,Ln as k,$e as l,Zn as m,na as n,Ur as o,en as p,Re as q,ma as r,Zr as s,
160
+ rn as t,tn as u,ua as v,da as w,Vn as x,ba as y,oa as z};