revise 2.2.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/CHANGELOG.md +56 -1182
  2. package/LICENSE +24 -41
  3. package/README.md +103 -26
  4. package/agent.d.ts +139 -0
  5. package/chunks/chunk-U5X47PZ6.js +135 -0
  6. package/chunks/chunk-U6YKQBKL.js +15 -0
  7. package/chunks/chunk-ZLQVPMBN.js +1650 -0
  8. package/chunks/package-5SHL5FOJ.js +14 -0
  9. package/chunks/render-QD5VWKSV.js +109 -0
  10. package/cli-output.schema.json +1984 -0
  11. package/cli.js +3609 -0
  12. package/document.d.ts +320 -0
  13. package/docx.d.ts +73 -0
  14. package/errors.d.ts +14 -0
  15. package/index.d.ts +13 -975
  16. package/index.js +31 -1
  17. package/legacy/editor.d.ts +19 -0
  18. package/legacy/editor.js +16 -0
  19. package/legacy/server.d.ts +37 -0
  20. package/legacy/server.js +25 -0
  21. package/legacy/style.css +2 -0
  22. package/package.d.ts +23 -0
  23. package/package.json +49 -55
  24. package/render.d.ts +27 -0
  25. package/FONT-LICENSE-HAN-EXT-B.txt +0 -91
  26. package/FONT-LICENSE-KATEX.txt +0 -95
  27. package/FONT-LICENSE-LIBERATION.txt +0 -102
  28. package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +0 -93
  29. package/FONT-LICENSE-NOTO-SANS-SC.txt +0 -93
  30. package/FONT-LICENSE-NOTO.txt +0 -94
  31. package/FONT-LICENSE-SOURCE-CODE-PRO.txt +0 -94
  32. package/FONT-LICENSE-SOURCE-SERIF-4.txt +0 -93
  33. package/THIRD-PARTY-NOTICES.md +0 -3376
  34. package/assets/historyMaterializeWorker-B51R08XN.js +0 -612
  35. package/backend.d.ts +0 -161
  36. package/backend.js +0 -3
  37. package/chunks/AgentPageRenderer-CH8kSTJn.js +0 -1
  38. package/chunks/AgentPageRenderer-P23XVguo.js +0 -1
  39. package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +0 -1
  40. package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +0 -1
  41. package/chunks/BidiText-Swm5fl9J.js +0 -160
  42. package/chunks/ColorParserFull-BKH72fK8.js +0 -446
  43. package/chunks/DocumentMutator-btiDK57e.js +0 -31
  44. package/chunks/DocumentScrubber-CMPfm_HF.js +0 -18
  45. package/chunks/DocumentScrubber-Cm2kH8op.js +0 -1
  46. package/chunks/DocumentScrubber-bJoKijol.js +0 -1
  47. package/chunks/DocumentStylesheet-DreoD7sD.js +0 -7
  48. package/chunks/DocxConverter-BcVG-p5K.js +0 -13
  49. package/chunks/DocxConverter-D2bO5RE-.js +0 -1125
  50. package/chunks/DocxConverter-haCfRuWb.js +0 -13
  51. package/chunks/DocxGraft-BRKh4mHQ.js +0 -1
  52. package/chunks/DocxGraft-BxSQtl12.js +0 -7
  53. package/chunks/DocxGraft-C9MBQCnf.js +0 -1
  54. package/chunks/FileImporter-CszqRfVU.js +0 -1
  55. package/chunks/FileImporter-DObFoCCn.js +0 -1
  56. package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +0 -3
  57. package/chunks/HtmlConverter-DwXB4IDh.js +0 -267
  58. package/chunks/ListNumbering-Qlu6AuRZ.js +0 -23
  59. package/chunks/MarkdownConverter-CUC8GgsS.js +0 -57
  60. package/chunks/MathRenderer-DT6GyJXb.js +0 -68
  61. package/chunks/OdtConverter-7h9HHMpL.js +0 -125
  62. package/chunks/OdtConverter-Ct4qypJk.js +0 -6
  63. package/chunks/OdtConverter-DFl__sJc.js +0 -6
  64. package/chunks/OfficeImportShared-BY6FdZ8d.js +0 -1
  65. package/chunks/OfficeImportShared-BrZoDM0j.js +0 -30
  66. package/chunks/OfficeImportShared-Bvm-mOyj.js +0 -1
  67. package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +0 -36
  68. package/chunks/PdfConverter-1wyvoT7X.js +0 -21
  69. package/chunks/PdfConverter-BAoEHILo.js +0 -21
  70. package/chunks/PdfConverter-CKEvFj11.js +0 -448
  71. package/chunks/PdfImportService-BhLPp5uG.js +0 -2
  72. package/chunks/PdfImportService-xbzrN__L.js +0 -2
  73. package/chunks/RtfConverter-Bxn-enp8.js +0 -15
  74. package/chunks/RtfConverter-LZPzBDSr.js +0 -15
  75. package/chunks/RtfConverter-_bacXqr1.js +0 -186
  76. package/chunks/TableBorders-CwnF3jvH.js +0 -30
  77. package/chunks/TableGrid-DbroRucl.js +0 -12
  78. package/chunks/TextFileDecoder--rsVs3NR.js +0 -9
  79. package/chunks/TxtConverter-C7FOwHpH.js +0 -14
  80. package/chunks/UnicodeUtils-CXtusU4g.js +0 -10
  81. package/chunks/XmlConverter-7oo8oeQB.js +0 -2
  82. package/chunks/XmlConverter-DGORHJcZ.js +0 -96
  83. package/chunks/XmlConverter-DeLHReK_.js +0 -2
  84. package/chunks/__vite-browser-external-l0sNRNKZ.js +0 -0
  85. package/chunks/_commonjsHelpers-DaMA6jEr.js +0 -2
  86. package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +0 -1
  87. package/chunks/_revise-sdk-lazy-harfbuzz-X8gnYTZL.js +0 -1
  88. package/chunks/ar-ComXvtmh.js +0 -13
  89. package/chunks/backend-DecaBz-I.js +0 -490
  90. package/chunks/base64-sSPOzq-u.js +0 -198
  91. package/chunks/browser-module-CFmqfGkE.js +0 -1791
  92. package/chunks/browser-module-Dj5o3kuL.js +0 -3
  93. package/chunks/browser-module-UuM_O36W.js +0 -3
  94. package/chunks/bundle.min-DRpfgV69.js +0 -782
  95. package/chunks/capture-1btcWcPF.js +0 -9
  96. package/chunks/carrier-DQeng6yq.js +0 -6
  97. package/chunks/de-BkbpIKxx.js +0 -13
  98. package/chunks/es-CKkXujOF.js +0 -13
  99. package/chunks/fil-piIHMc8F.js +0 -13
  100. package/chunks/footnoteFlatten-DUQticYy.js +0 -6
  101. package/chunks/fr-DuA8qLje.js +0 -13
  102. package/chunks/graftExport-CYnStOdU.js +0 -82
  103. package/chunks/html2canvas.esm-CntiHiYW.js +0 -997
  104. package/chunks/index-2TBhRkX7.js +0 -387
  105. package/chunks/index-BWdRWxoH.js +0 -1807
  106. package/chunks/index-Bf14eTEW.js +0 -1096
  107. package/chunks/index-BwcX_r62.js +0 -387
  108. package/chunks/index.es-CI0QPo8w.js +0 -780
  109. package/chunks/index.es-CI7cDExj.js +0 -5
  110. package/chunks/index.es-DHpGt6Y5.js +0 -5
  111. package/chunks/ja-DgrSs555.js +0 -13
  112. package/chunks/jspdf.es.min--GshOuIm.js +0 -77
  113. package/chunks/jspdf.es.min-DU74zN8b.js +0 -1792
  114. package/chunks/jspdf.es.min-DurJZ1zW.js +0 -77
  115. package/chunks/jszip.min-CPW0h1Kx.js +0 -476
  116. package/chunks/katex-DWj8TvwO.js +0 -1462
  117. package/chunks/pdf-BLWDCiFF.js +0 -1828
  118. package/chunks/persistInlineDocumentImages-DQj2iaqg.js +0 -1
  119. package/chunks/pseudoLocale-BoYTjmiK.js +0 -1
  120. package/chunks/pseudoLocale-DG2NnZmz.js +0 -1
  121. package/chunks/purify.es-BwLardii.js +0 -107
  122. package/chunks/serverDocumentSession-CJ1EH3Tp.js +0 -15
  123. package/chunks/signatures-Bwt_OGik.js +0 -17
  124. package/chunks/suggestionAuthorship-B-IuLQlE.js +0 -1
  125. package/chunks/tree-sitter-D6zWWUMP.js +0 -4
  126. package/chunks/wasmInline.generated-CBYFkdSM.js +0 -1
  127. package/chunks/web-tree-sitter-BXGZGnNj.js +0 -2
  128. package/chunks/zh-9OF3SWWO.js +0 -13
  129. package/full.js +0 -1
  130. package/root.d.ts +0 -5
  131. package/root.js +0 -2
  132. package/serverToolContract.d.ts +0 -391
  133. package/serverToolInputs.generated.d.ts +0 -250
  134. package/style.css +0 -1
package/backend.d.ts DELETED
@@ -1,161 +0,0 @@
1
- /**
2
- * Server-side primitives. Node only.
3
- *
4
- * Peer dependencies: `yjs` (one copy, shared with anything else that touches
5
- * the document) and `jsdom` (the converters parse XML and HTML with DOM
6
- * APIs).
7
- */
8
- import type { Doc } from "yjs";
9
- import type {
10
- ServerDocumentSession,
11
- ServerDocumentSessionOptions,
12
- } from "./serverToolContract.js";
13
-
14
- /** Revise's document model. Opaque here — convert rather than inspect. */
15
- export interface ReviseDocument {
16
- type: "doc";
17
- children: unknown[];
18
- [key: string]: unknown;
19
- }
20
-
21
- /** Formats readable on the server. PDF and images are browser-only. */
22
- export type ReviseServerFormat =
23
- | "docx"
24
- | "odt"
25
- | "rtf"
26
- | "markdown"
27
- | "txt"
28
- | "html";
29
-
30
- /** Top-level keys the editor owns inside a shared document. */
31
- export declare const RESERVED_DOCUMENT_KEYS: readonly string[];
32
-
33
- /** A document built with the settings the editor requires. */
34
- export declare function createReviseYDoc(): Doc;
35
-
36
- /** Throws if a document already uses the editor's reserved keys for
37
- * something else. */
38
- export declare function assertUsableSharedDocument(ydoc: Doc): void;
39
-
40
- /** Install the DOM globals the converters need. Called for you by everything
41
- * here; exported for hosts importing converters directly. */
42
- export declare function installDomShims(): Promise<void>;
43
-
44
- /** Parse .docx, .odt, .rtf, .md, .txt, or .html into the document model. */
45
- export declare function parseDocument(
46
- bytes: Uint8Array,
47
- filename: string,
48
- ): Promise<ReviseDocument>;
49
-
50
- /** Serialize the document model back to .docx bytes. With `originalDocx`
51
- * (the file this document was imported from), untouched content exports
52
- * byte-for-byte via graft mode; any graft-proof failure falls back to full
53
- * regeneration. */
54
- export declare function documentToDocx(
55
- doc: ReviseDocument,
56
- options?: { originalDocx?: Uint8Array },
57
- ): Promise<Uint8Array>;
58
-
59
- /** Build a room's Yjs document from a file — server-side document creation,
60
- * so every client simply joins. */
61
- export declare function fileToYDoc(
62
- bytes: Uint8Array,
63
- filename: string,
64
- ): Promise<Doc>;
65
-
66
- /** Seed an empty room from a file. Returns false when it already had
67
- * content, so it is safe to call on every connection — including under a
68
- * connect race: every seed records a claim, and a room two peers both
69
- * seeded before syncing is repaired deterministically (on the next call
70
- * here, or by any live editor session the moment the claims merge). */
71
- export declare function seedYDocFromFile(
72
- ydoc: Doc,
73
- bytes: Uint8Array,
74
- filename: string,
75
- ): Promise<boolean>;
76
-
77
- export interface SeedRaceRepairResult {
78
- /** Losing seed claims removed. */
79
- losingClaims: number;
80
- /** Top-level body blocks removed. */
81
- removedBlocks: number;
82
- }
83
-
84
- /** Detect and repair a double-seed connect race: keep the deterministic
85
- * winner and delete everything the losing seeds created. Idempotent and
86
- * convergent — safe on any peer, at any time; null when there is nothing
87
- * to repair. Editor sessions run this automatically. */
88
- export declare function repairSeedRace(
89
- ydoc: Doc,
90
- ): SeedRaceRepairResult | null;
91
-
92
- /** Read a room back as the document model. */
93
- export declare function ydocToDocument(ydoc: Doc): ReviseDocument;
94
-
95
- /** Export a room straight to .docx. A DOCX-imported room carries its
96
- * original file inside the document; untouched content exports
97
- * byte-for-byte. */
98
- export declare function ydocToDocx(ydoc: Doc): Promise<Uint8Array>;
99
-
100
- /** Formats `exportDocument` produces on the server. PDF needs a browser;
101
- * use `tools.export` in the editor. */
102
- export type ReviseServerExportFormat = "docx" | "html" | "markdown" | "txt";
103
-
104
- export interface ReviseServerExportOptions {
105
- format?: ReviseServerExportFormat;
106
- /** "review" (default) keeps pending tracked changes and comments in a
107
- * .docx; other formats show the text with changes accepted. "final"
108
- * accepts every pending change and drops comments first. */
109
- mode?: "review" | "final";
110
- /** Document title, used by the HTML export's <title>. */
111
- title?: string;
112
- }
113
-
114
- /** Export a room or a parsed document as a file. A room in review mode
115
- * keeps DOCX mode (untouched content leaves as the original bytes); a final
116
- * copy is always regenerated. */
117
- export declare function exportDocument(
118
- source: Doc | ReviseDocument,
119
- options?: ReviseServerExportOptions,
120
- ): Promise<Uint8Array>;
121
-
122
- /** DOCX-mode fidelity for a room: "exact" (export reproduces the original
123
- * file byte-for-byte), "grafted" (original + this document's edits), or
124
- * "converted" (no usable original; export regenerates). */
125
- export declare function ydocSourceFidelity(ydoc: Doc): Promise<{
126
- fidelity: "exact" | "grafted" | "converted";
127
- regeneratedBlockIds: string[];
128
- changedDomains: string[];
129
- convertedReason?:
130
- | "no-capture"
131
- | "no-carrier"
132
- | "carrier-hash-mismatch"
133
- | "unpaired-capture";
134
- }>;
135
-
136
- /** Whether a room already holds a Revise document. */
137
- export declare function hasDocument(ydoc: Doc): boolean;
138
-
139
- /** The whole room as one update, for storage. */
140
- export declare function encodeYDoc(ydoc: Doc): Uint8Array;
141
-
142
- /** Restore a room from stored bytes. */
143
- export declare function decodeYDoc(update: Uint8Array): Doc;
144
-
145
- export type * from "./serverToolContract.js";
146
-
147
- export declare class ReviseToolError<Name extends string = string> extends Error {
148
- readonly failure: import("./serverToolContract.js").ReviseToolFailure<Name>;
149
- readonly callId: string;
150
- readonly tool: Name;
151
- readonly code: string;
152
- constructor(failure: import("./serverToolContract.js").ReviseToolFailure<Name>);
153
- }
154
-
155
- /** Bind the canonical deterministic semantic tools to a host-owned Y.Doc.
156
- * Async: the tool session's mutation engine is loaded on first use, so
157
- * conversion-only hosts never pay for it. */
158
- export declare function createServerDocumentSession(
159
- ydoc: Doc,
160
- options: ServerDocumentSessionOptions,
161
- ): Promise<ServerDocumentSession>;
package/backend.js DELETED
@@ -1,3 +0,0 @@
1
- import{bZ as s,R as a,bY as e,bX as o,bV as c,bU as r,bL as b,bT as t,bQ as D,bM as m,bS as i,b as d,bK as n,bW as S,bN as u,bR as l,bO as R,bP as T}from"./chunks/backend-DecaBz-I.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 +0,0 @@
1
- import*as x from"yjs";import{K as P,L as O,S as k,M as C,N as D,O as Y,Q as B,T as G,U as A,z,V as K,W as Q,X as V,Y as X,Z,_ as J,$ as ee,a0 as te,a1 as oe}from"./index-BwcX_r62.js";function $(e,t,n,i){if(Array.isArray(e)){for(const r of e)$(r,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const r of Object.values(a))if(Array.isArray(r))for(const s of r)$(s,o,n,i);else r&&typeof r=="object"&&$(r,o,n,i)}function j(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>K(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await j(),await j()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function E(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,r=o.relativeToPage?o.y:o.y-n.pageTop,s=`${a.blockId}:${Math.round(o.x)}:${Math.round(r)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(s)||o.width<=0||o.height<=0)continue;i.add(s);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,r,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,r),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,r)+1,Math.max(1,d-4))}}e.restore()}function re(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const L=new WeakMap;let q=0;function se(e){let t=L.get(e);return t||(q+=1,t=`session-${q}`,L.set(e,t)),t}const F=new WeakMap;let H=0;function ce(e){let t=F.get(e);return t===void 0&&(H+=1,t=H,F.set(e,t)),t}function W(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,r=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${r} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const s=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${s} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${s} with all ${r} applied ${l}`:`${s} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${r} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${s} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${s} as it stands: its ${r} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${s} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=se(e),o=e.getDocumentMutator().derivedDocumentRevision,r=e.isHistoryOpen(),s=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=s==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${W(n.liveIds)}`,...l>0?[`l${l}.${W(n.legacyIds)}`]:[]],u=s==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:s,historyOpen:r,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(s,t,r,n),key:[i,a,s,...w,t].join(":")}}function N(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const r=ue(n,t,i);if(r.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:r};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:A(g),snapshot:r}}finally{g.destroy()}}const s=new x.Doc;try{if(x.applyUpdate(s,x.encodeStateAsUpdate(n.getYDoc())),r.projectedSuggestionCount===0)return{doc:A(s),snapshot:r};const g=z.createSuggestionProjectionFromYDoc(s,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:r}}finally{g.ydoc.destroy()}}finally{s.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=Q(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=V(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=X(e.computed,o.layout.fontFamily),o.headingPageNumbers=Z(e.computed),o.syntaxTheme=J(e.codeTheme||"solarized",i.isDark),ee(o,1);const r={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const s={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,s,r)}else oe(o,e.editor,e.geometry.pageIndex,r);return e.mode==="layout"&&E(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,r=Math.ceil(e.length/o),s=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:r},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*s,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,r-1)*s;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<r;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+s);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+s}return u}async function fe(e){const t=e.request.view??P;if(!O(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=N(e.editor,t),a=C(e.themeElement),o=[],r=[];$(n,null,o,r),await ne(o,a.text);const s=e.createCanvas?.()??document.createElement("canvas");s.width=8,s.height=8;const g=s.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=Y(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[re(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=r.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):B(c.src))),U=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(U,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const _=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:_,view:t,snapshot:i}}export{N as captureAgentPageRenderSource,E as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
@@ -1 +0,0 @@
1
- import*as x from"yjs";import{K as P,L as O,S as k,M as C,N as D,O as Y,Q as B,T as G,U as A,z,V as K,W as Q,X as V,Y as X,Z,_ as J,$ as ee,a0 as te,a1 as oe}from"./index-2TBhRkX7.js";function $(e,t,n,i){if(Array.isArray(e)){for(const r of e)$(r,t,n,i);return}if(!e||typeof e!="object")return;const a=e,o=typeof a.id=="string"?a.id:t;a.type==="math"&&typeof a.content=="string"&&n.push({content:a.content,displayMode:a.displayMode!=="inline",blockId:o}),a.type==="text"&&typeof a.text=="string"&&a.marks?.latex&&n.push({content:a.text,displayMode:!1,blockId:o}),a.type==="image"&&typeof a.src=="string"&&i.push({src:a.src,blockId:o,permanentlyPlaceholder:a.originalFormat==="emf"||a.originalFormat==="wmf"});for(const r of Object.values(a))if(Array.isArray(r))for(const s of r)$(s,o,n,i);else r&&typeof r=="object"&&$(r,o,n,i)}function j(){return new Promise(e=>{let t=!1;const n=()=>{t||(t=!0,clearTimeout(i),e())},i=setTimeout(n,50);typeof requestAnimationFrame=="function"&&requestAnimationFrame(n)})}async function ne(e,t){if(e.length===0)return;const n=Promise.allSettled(e.map(i=>K(i.content,i.displayMode,t)));await Promise.race([n,new Promise(i=>setTimeout(i,2500))]),await j(),await j()}function R(e,t){if(typeof e.pageNumber=="number")return e.pageNumber-1;const n=e.bounds.y;return t.pageGeometries?.find(i=>n>=i.pageTop&&n<i.pageTop+i.pageHeight)?.pageIndex??0}function ae(e,t){return new Set(e.fragments.filter(n=>t.has(R(n,e))).map(n=>n.blockId))}function ie(e){return e==="table"?"#7c3aed":e==="table-cell"||e==="table-row"?"#db2777":e==="image"?"#ea580c":e==="container"?"#2563eb":e==="math"?"#ca8a04":"#0891b2"}function E(e,t,n){e.save(),e.lineWidth=.75,e.setLineDash([4,3]),e.strokeStyle="rgba(22, 163, 74, 0.9)",e.strokeRect(n.marginLeft,n.marginTop,n.pageWidth-n.marginLeft-n.marginRight,n.pageHeight-n.marginTop-n.marginBottom),e.setLineDash([]);const i=new Set;for(const a of t.fragments){if(R(a,t)!==n.pageIndex)continue;const{bounds:o}=a,r=o.relativeToPage?o.y:o.y-n.pageTop,s=`${a.blockId}:${Math.round(o.x)}:${Math.round(r)}:${Math.round(o.width)}:${Math.round(o.height)}`;if(i.has(s)||o.width<=0||o.height<=0)continue;i.add(s);const g=ie(a.block.type);if(e.strokeStyle=g,e.globalAlpha=.82,e.strokeRect(o.x,r,o.width,o.height),(a.block.type==="table"||a.block.type==="table-cell"||a.block.type==="image"||a.block.type==="container"||a.block.type==="math")&&o.width>=42&&o.height>=12){const l=`${a.block.type} #${a.blockId}`;e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.textAlign="left",e.textBaseline="top";const d=Math.min(o.width,e.measureText(l).width+5);e.globalAlpha=.88,e.fillStyle=g,e.fillRect(o.x,Math.max(0,r),d,13),e.globalAlpha=1,e.fillStyle="#ffffff",e.fillText(l,o.x+2,Math.max(0,r)+1,Math.max(1,d-4))}}e.restore()}function re(e,t){return{pageIndex:0,sectionIndex:0,pageTop:0,pageWidth:e.pageWidth,pageHeight:Math.min(4096,Math.max(e.pageHeight,t.totalHeight)),marginTop:e.pageMarginTop??e.pageMargin,marginRight:e.pageMarginRight??e.pageMargin,marginBottom:e.pageMarginBottom??e.pageMargin,marginLeft:e.pageMarginLeft??e.pageMargin,showPageNumbers:!1,pageNumberPosition:"bottom-right",renderedPageNumber:1}}const L=new WeakMap;let q=0;function se(e){let t=L.get(e);return t||(q+=1,t=`session-${q}`,L.set(e,t)),t}const F=new WeakMap;let H=0;function ce(e){let t=F.get(e);return t===void 0&&(H+=1,t=H,F.set(e,t)),t}function W(e){let t=2166136261;for(const n of e.join("\0"))t^=n.codePointAt(0),t=Math.imul(t,16777619)>>>0;return t.toString(36)}function ge(e){const t=e.getDocumentSession?.();if(!t)throw new k("document_unavailable","Rendered page inspection needs a loaded document. Wait for the document to open, then retry.","verification",!1);return t}function de(e){const t=e.getDetachedSuggestionStore?.();return{liveIds:[...e.getDocumentMutator().getLiveSuggestionIds()].sort(),legacyIds:t?[...t.getPendingSuggestions().keys()].sort():[]}}function le(e,t){return t!==P?"live-pending-suggestion-projection":e.isHistoryOpen()?"displayed-history-revision":"displayed-document"}function v(e,t){return`${e} ${t}${e===1?"":"s"}`}function he(e,t,n,i){const a=i.liveIds.length,o=i.legacyIds.length,r=v(o,"legacy detached suggestion");if(e==="displayed-history-revision")return"The past revision the editor displays while the history view is open, not the live document. The live document's pending suggestions are not part of this image.";if(e==="displayed-document"){const d=`The document as the editor displays it, with ${v(a,"pending suggestion")} drawn as tracked changes.`;return o>0?`${d} ${r} ${o===1?"is":"are"} pending outside the document and not drawn; show-with-tracked-changes-accepted previews them.`:d}const s=n?"The live document, not the past revision the history view displays,":"The live document",g=n?"":"; this view equals show-tracked-changes",l="in a private preview; nothing was resolved in the document.";if(t==="show-with-tracked-changes-accepted")return a>0?`${s} with all ${v(a,"pending suggestion")} accepted ${l}`:o>0?`${s} with all ${r} applied ${l}`:`${s} has no pending suggestions to accept${g}.`;if(a>0){const d=o>0?` ${r} stored outside the document ${o===1?"is":"are"} absent here as well.`:"";return`${s} with all ${v(a,"pending suggestion")} rejected ${l}${d}`}return o>0?`${s} as it stands: its ${r} ${o===1?"is":"are"} stored outside the document, so there is nothing to reject${g}.`:`${s} has no pending suggestions to reject${g}.`}function ue(e,t,n){const i=e.getDocumentId(),a=se(e),o=e.getDocumentMutator().derivedDocumentRevision,r=e.isHistoryOpen(),s=le(e,t),g=n.liveIds.length,l=n.legacyIds.length,d=t==="show-with-tracked-changes-accepted"?g>0?g:l:t==="show-before-tracked-changes"?g:0,w=s==="displayed-history-revision"?[`h${ce(e.getCurrentDocument())}`]:[`r${o}`,`s${g}.${W(n.liveIds)}`,...l>0?[`l${l}.${W(n.legacyIds)}`]:[]],u=s==="displayed-history-revision"?{...e.getSelection(),diffEnabled:e.isDiffEnabled()}:void 0;return{documentId:i,sessionId:a,basis:s,historyOpen:r,revision:o,pendingSuggestionCount:g+l,legacyDetachedSuggestionCount:l,projectedSuggestionCount:d,...u?{historySelection:u}:{},description:he(s,t,r,n),key:[i,a,s,...w,t].join(":")}}function N(e,t){const n=ge(e),i=de(n),a=i.liveIds.length,o=i.legacyIds.length;if(t==="show-with-tracked-changes-accepted"&&a>0&&o>0)throw new k("render_view_unsupported",`This document has ${v(a,"pending suggestion")} plus ${v(o,"legacy detached suggestion")} stored outside it, which cannot be previewed accepted together. Use show-tracked-changes or show-before-tracked-changes, or read the accepted text with a read tool.`,"verification",!1);const r=ue(n,t,i);if(r.basis==="displayed-history-revision")return{doc:{...e.getDocument()},snapshot:r};if(t==="show-with-tracked-changes-accepted"&&a===0&&o>0){const g=n.getDetachedSuggestionStore().materializeWithSuggestions(i.legacyIds);try{return{doc:A(g),snapshot:r}}finally{g.destroy()}}const s=new x.Doc;try{if(x.applyUpdate(s,x.encodeStateAsUpdate(n.getYDoc())),r.projectedSuggestionCount===0)return{doc:A(s),snapshot:r};const g=z.createSuggestionProjectionFromYDoc(s,t==="show-with-tracked-changes-accepted"?"accept":"reject",i.liveIds);try{return{doc:g.doc,snapshot:r}}finally{g.ydoc.destroy()}}finally{s.destroy()}}function pe(e){const t=e.createCanvas?.()??document.createElement("canvas");t.width=Math.ceil(e.geometry.pageWidth),t.height=Math.ceil(e.geometry.pageHeight);const n=t.getContext("2d");if(!n)throw new Error("The browser could not create a page canvas.");const i=C(e.themeElement);n.fillStyle=i.pageBackground,n.fillRect(0,0,t.width,t.height);const a=D(n),o=Q(n,t,e.layout,a);o.theme=i,o.currentPage=e.geometry.pageIndex,o.pageGeometry=e.geometry,o.yOffset=e.geometry.pageTop,o.startY=e.geometry.pageTop,o.endY=e.geometry.pageTop+e.geometry.pageHeight,o.pageLayoutSettings=e.pageLayoutSettings,o.headersContent=e.doc.headers,o.footersContent=e.doc.footers,o.watermark=V(e.doc.watermark),o.totalPages=e.computed.pageCount,o.lineNumberMarks=e.computed.lineNumberMarks,o.pageFontFamilies=X(e.computed,o.layout.fontFamily),o.headingPageNumbers=Z(e.computed),o.syntaxTheme=J(e.codeTheme||"solarized",i.isDark),ee(o,1);const r={diffDocument:e.doc,showCursor:!1,isFocused:!1,readOnly:!0,printPreview:!0,forceImagePlaceholders:e.forceImagePlaceholders};if(e.pageless){const s={startY:0,endY:e.geometry.pageHeight};te(o,e.editor,s,r)}else oe(o,e.editor,e.geometry.pageIndex,r);return e.mode==="layout"&&E(n,e.computed,e.geometry),t}function me(e,t,n,i){const a=n==="compact"?360:720,o=n==="compact"?Math.min(2,e.length):e.length,r=Math.ceil(e.length/o),s=16,g=16,l=26,d=e.map(p=>({width:a,height:Math.round(p.height/p.width*a)})),w=Array.from({length:r},(p,m)=>Math.max(...d.slice(m*o,(m+1)*o).map(f=>f.height+l))),u=i?.()??document.createElement("canvas");u.width=g*2+o*a+Math.max(0,o-1)*s,u.height=g*2+w.reduce((p,m)=>p+m,0)+Math.max(0,r-1)*s;const h=u.getContext("2d");if(!h)throw new Error("The browser could not create a page contact sheet.");h.fillStyle="#e5e7eb",h.fillRect(0,0,u.width,u.height),h.fillStyle="#111827",h.font="600 14px ui-sans-serif, system-ui, sans-serif",h.textBaseline="top";let y=g;for(let p=0;p<r;p+=1){for(let m=0;m<o;m+=1){const f=p*o+m;if(f>=e.length)break;const b=g+m*(a+s);h.fillText(`Page ${t[f]}`,b,y+4),h.drawImage(e[f],b,y+l,d[f].width,d[f].height),h.strokeStyle="#9ca3af",h.strokeRect(b,y+l,d[f].width,d[f].height)}y+=w[p]+s}return u}async function fe(e){const t=e.request.view??P;if(!O(t))throw new k("invalid_view",`Unknown render view "${String(t)}". Use show-tracked-changes, show-with-tracked-changes-accepted, or show-before-tracked-changes.`);const{doc:n,snapshot:i}=N(e.editor,t),a=C(e.themeElement),o=[],r=[];$(n,null,o,r),await ne(o,a.text);const s=e.createCanvas?.()??document.createElement("canvas");s.width=8,s.height=8;const g=s.getContext("2d");if(!g)throw new Error("The browser could not measure document pages.");const l=D(g),d=Y(n,l,e.layout),w=d.pageGeometries?.length?d.pageGeometries:[re(e.layout,d)],u=w.length,h=e.request.startPage-1;if(h<0||h>=u)throw new Error(`start_page ${e.request.startPage} is outside this ${u}-page document in the ${t} view.`);const y=w.slice(h,Math.min(u,h+e.request.pageCount)),p=new Set(y.map(c=>c.pageIndex)),m=ae(d,p),f=r.filter(c=>c.blockId===null||m.has(c.blockId)),b=await Promise.all(f.map(c=>c.permanentlyPlaceholder?Promise.resolve("placeholder"):B(c.src))),U=y.map(c=>pe({editor:e.editor,doc:n,layout:e.layout,computed:d,geometry:c,pageLayoutSettings:e.pageLayoutSettings,mode:e.request.mode,codeTheme:e.codeTheme,themeElement:e.themeElement,pageless:!!n.pageless,createCanvas:e.createCanvas})),I=y.map(c=>c.pageIndex+1),M=me(U,I,e.request.quality,e.createCanvas);let S;try{S=M.toDataURL("image/jpeg",e.request.quality==="compact"?.78:.9)}catch(c){throw typeof c=="object"&&c!==null&&"name"in c&&c.name==="SecurityError"?new k("visual_resource_unavailable","A document resource prevented safe page export. Re-upload external images and retry visual inspection.","verification",!1):c}const _=o.filter(c=>c.blockId===null||m.has(c.blockId)).filter(c=>{const T=G(c.content,c.displayMode,a.text);return T.loading||!T.image}).length;return{dataUrl:S,width:M.width,height:M.height,pages:I,totalPages:u,placeholderImageCount:b.filter(c=>c==="placeholder").length,failedImageCount:b.filter(c=>c==="failed").length,mathPlaceholderCount:_,view:t,snapshot:i}}export{N as captureAgentPageRenderSource,E as paintPageLayoutDiagnostics,fe as renderDocumentPagesForAgent};
@@ -1 +0,0 @@
1
- import{a2 as l,a3 as y,a4 as D}from"./index-2TBhRkX7.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-DObFoCCn.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-BRKh4mHQ.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-BhLPp5uG.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};
@@ -1 +0,0 @@
1
- import{a2 as l,a3 as y,a4 as D}from"./index-BwcX_r62.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-CszqRfVU.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-C9MBQCnf.js");await c(i,d.bytes,{hash:d.hash})}}}else{const{importPdfIntoExistingDocument:a}=await import("./PdfImportService-xbzrN__L.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};
@@ -1,160 +0,0 @@
1
- import{r as jr,e as wn,c as xn}from"./MathRenderer-DT6GyJXb.js";import{bJ as Lr}from"./backend-DecaBz-I.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 Ut(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,Jt=new Map,Vt=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 Cn(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 Mn(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=>jr(`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(Jt.has(t))return Jt.get(t);if(wt.has(
16
- t))return null;if(Vt.has(t))return Vt.get(t);const e=(async()=>{try{const n=await(await import("./web-tree-sitter-BXGZGnNj.js")).Language.load(jr(`tree-sitter/tree-sitter-${t}.wasm`));return Jt.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{Vt.delete(t)}})();return Vt.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 Sn(t="javascript"){const e=Ut(t);return e?Er&&Jt.has(e):!0}async function In(t="javascript"){if(Pe())return!1;const e=Ut(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=Ut(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=Mn(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 jn=100;function Ln(t,e="javascript",n){if(Pe())return null;
24
- const r=Ut(e);if(!r||wt.has(r))return null;const a=n||$e,o=a.keyword+a.string,l=`${r}:${o}:${Cn(t)}`;if(lt.has(l))return lt.get(l);const s=(f,m)=>{if(lt.size>=jn){const h=lt.keys().next().value;h&&lt.
25
- delete(h)}lt.set(f,m)};return Sn(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,Qt=new Map,Tr=new Map,$r=new Map,Fn=new Set,U=new Map;let Ae=null,Pr=0;function Q(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=Q(t.protocol),n=Math.max(120,Math.round(t.maxWidth));return`${e}:${n}:${Rr(t.theme)}:${t.source}`}function Kt(t){
28
- const e=Q(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(){U.has("mermaid")||U.set("mermaid",On),U.has("l\
53
- atex")||U.set("latex",Or("latex",!0)),U.has("latex-inline")||U.set("latex-inline",Or("latex-inline",!1))}async function Wn(t){Wr();const e=Q(t.protocol),n=U.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=Q(t);return U.has(e)?e:null}function Xe(t){const e=Q(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(!Qt.has(r)){const f=Wn(n).then(m=>(ze.set(r,m),Qt.delete(r),Dn(),m));Qt.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 Gr(t){const e=Xe(t);if(!e.loading)return e;const n=Oe(
59
- {...t,protocol:Q(t.protocol)});return Qt.get(n)||Xe(t)}function Zr(t){const e=Oe({...t,protocol:Q(t.protocol)}),n=ze.get(e);return!n||n.loading?null:n}function Xn(t){const e=Zr(t);return!e||!e.svg?null:
60
- {svg:e.svg,width:e.width,height:e.height}}function Gn(t){if(typeof document>"u")return null;const e=Zr(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 Zn(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=>Gr(o)))}const Hr={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"},Hn={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 Un(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 Ur(t){
72
- const e=Un(t)?Hn:Hr,n=t?.closest?.("[data-page-background]")?.getAttribute("data-page-background");return n?{...e,pageBackground:n}:e}function Jn(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 Jr=["bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps","allCaps","letterSpacing","code","late\
74
- x","superscript","subscript","backgroundColor","link"],Vn=Jr.reduce((t,e)=>(t[e]=null,t),{}),Qn=[],Ge={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"},Vr=Ge,Qr=["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
- Vr[e]:void 0}function oa(t,e=Ur().isDark){const n=Yt(t);return n?(e?Kn:Ge)[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=Qr){let r=null,a=Number.POSITIVE_INFINITY;for(const o of n){const l=[Vr[o],...e?[Ge[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 C=0;C<g;C++)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 Ct={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(C){if(C.indexOf("+")!==-1)for(var M=+C;M--;)g(p);else{p=C;var v=C.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,He,Ue;function ae(){if(!ne){var u=re(Ct.pairs,!0),k=u.map,y=u.reverseMap;ne=k,He=y,Ue=re(Ct.canonical,!1).map}}function oe(u){return ae(),ne.get(u)||null}
113
- function ie(u){return ae(),He.get(u)||null}function le(u){return ae(),Ue.get(u)||null}var E=r.L,D=r.R,j=r.EN,st=r.ES,Mt=r.ET,ct=r.AN,St=r.CS,Y=r.B,an=r.S,It=r.ON,on=r.BN,jt=r.NSM,Lt=r.AL,Je=r.LRO,Ft=r.
114
- RLO,Ve=r.LRE,se=r.RLE,Qe=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),C=new Map,M=[],v=null,B=0;B<u.length;B++)v||M.push(v={start:B,end:u.
116
- length-1,level:k==="rtl"?1:k==="ltr"?0:Sr(B,!1)}),i[B]&Y&&(v.end=B,v=null);for(var P=se|Ve|Ft|Je|o|tt|Qe|Y,J=function(L){return L+(L&1?1:2)},W=function(L){return L+(L&1?2:1)},X=0;X<M.length;X++){v=M[X];
117
- var b=[{_level:v.level,_override:0,_isolate:0}],x=void 0,A=0,G=0,ue=0;d.clear();for(var S=v.start;S<=v.end;S++){var I=i[S];if(x=b[b.length-1],d.set(I,(d.get(I)||0)+1),I&s&&d.set(s,(d.get(s)||0)+1),I&P)
118
- if(I&(se|Ve)){g[S]=x._level;var er=(I===se?W:J)(x._level);er<=y&&!A&&!G?b.push({_level:er,_override:0,_isolate:0}):A||G++}else if(I&(Ft|Je)){g[S]=x._level;var rr=(I===Ft?W:J)(x._level);rr<=y&&!A&&!G?b.
119
- push({_level:rr,_override:I&Ft?D:E,_isolate:0}):A||G++}else if(I&o){I&sn&&(I=Sr(S+1,!0)===1?Ke:ln),g[S]=x._level,x._override&&p(S,x._override);var nr=(I===Ke?W:J)(x._level);nr<=y&&A===0&&G===0?(ue++,b.
120
- push({_level:nr,_override:0,_isolate:1,_isolInitIndex:S})):A++}else if(I&tt){if(A>0)A--;else if(ue>0){for(G=0;!b[b.length-1]._isolate;)b.pop();var de=b[b.length-1]._isolInitIndex;de!=null&&(C.set(de,S),
121
- C.set(S,de)),b.pop(),ue--}x=b[b.length-1],g[S]=x._level,x._override&&p(S,x._override)}else I&Qe?(A===0&&(G>0?G--:!x._isolate&&b.length>1&&(b.pop(),x=b[b.length-1])),g[S]=x._level):I&Y&&(g[S]=v.level);else
122
- g[S]=x._level,x._override&&I!==on&&p(S,x._override)}for(var et=[],R=null,V=v.start;V<=v.end;V++){var he=i[V];if(!(he&f)){var ar=g[V],or=he&o,gn=he===tt;R&&ar===R._level?(R._end=V,R._endsWithIsolInit=or):
123
- et.push(R={_start:V,_end:V,_level:ar,_startsWithPDI:gn,_endsWithIsolInit:or})}}for(var ge=[],Et=0;Et<et.length;Et++){var qt=et[Et];if(!qt._startsWithPDI||qt._startsWithPDI&&!C.has(qt._start)){for(var pe=[
124
- R=qt],ir=void 0;R&&R._endsWithIsolInit&&(ir=C.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(jt))for(var $t=0;$t<c.length;$t++){var fr=c[$t];if(i[fr]&jt){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)?It:we)}}
128
- if(d.get(j))for(var Rt=0;Rt<c.length;Rt++){var ur=c[Rt];if(i[ur]&j)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(St))for(var ut=1;ut<c.length-1;ut++){var _e=c[ut];if(i[_e]&(st|St)){for(var at=0,Be=0,Ce=ut-1;Ce>=0&&(at=i[c[Ce]],!!(at&f));Ce--);for(var Me=ut+1;Me<
130
- c.length&&(Be=i[c[Me]],!!(Be&f));Me++);at===Be&&(i[_e]===st?at===j:at&(j|ct))&&p(_e,at)}}if(d.get(j))for(var z=0;z<c.length;z++){var yn=c[z];if(i[yn]&j){for(var At=z-1;At>=0&&i[c[At]]&(Mt|f);At--)p(c[At],
131
- j);for(z++;z<c.length&&i[c[z]]&(Mt|f|j);z++)i[c[z]]!==j&&p(c[z],j)}}if(d.get(Mt)||d.get(st)||d.get(St))for(var dt=0;dt<c.length;dt++){var gr=c[dt];if(i[gr]&(Mt|st|St)){p(gr,It);for(var Ot=dt-1;Ot>=0&&
132
- i[c[Ot]]&f;Ot--)p(c[Ot],It);for(var Wt=dt+1;Wt<c.length&&i[c[Wt]]&f;Wt++)p(c[Wt],It)}}if(d.get(j))for(var Se=0,pr=ft;Se<c.length;Se++){var mr=c[Se],Ie=i[mr];Ie&j?pr===E&&p(mr,E):Ie&l&&(pr=Ie)}if(d.get(
133
- s)){var ht=D|j|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 je=ot[pt].char;if(je===yr||je===ie(le(gt))||oe(le(je))===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],Gt=br[0],Fe=br[1],kr=!1,T=0,Ee=Gt+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=Gt-
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[Gt]]=i[c[Fe]]=T,T!==nt){for(var mt=Gt+1;mt<c.length;mt++)if(!(i[c[mt]]&f)){w(u[c[mt]])&jt&&(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]])&jt&&(i[c[vt]]=T);break}}}}for(var Z=0;Z<c.length;Z++)if(i[c[Z]]&s){for(var Cr=Z,Ne=Z,De=ft,yt=Z-1;yt>=0;yt--)if(i[c[yt]]&
138
- f)Cr=yt;else{De=i[c[yt]]&ht?D:E;break}for(var Mr=vn,bt=Z+1;bt<c.length;bt++)if(i[c[bt]]&(s|f))Ne=bt;else{Mr=i[c[bt]]&ht?D:E;break}for(var Te=Cr;Te<=Ne;Te++)i[c[Te]]=De===Mr?De:nt;Z=Ne}}}for(var q=v.start;q<=
139
- v.end;q++){var bn=g[q],Zt=i[q];if(bn&1?Zt&(E|j|ct)&&g[q]++:Zt&D?g[q]++:Zt&(ct|j)&&(g[q]+=2),Zt&f&&(g[q]=q===0?v.level:g[q-1]),q===v.end||w(u[q])&(an|Y))for(var Ht=q;Ht>=0&&w(u[Ht])&m;Ht--)g[Ht]=v.level}}
140
- return{levels:g,paragraphs:M};function Sr(L,$){for(var F=L;F<u.length;F++){var H=i[F];if(H&(D|Lt))return 1;if(H&(Y|E)||$&&H===tt)return 0;if(H&o){var Ir=kn(F);F=Ir===-1?u.length:Ir}}return 0}function kn(L){
141
- for(var $=1,F=L+1;F<u.length;F++){var H=i[F];if(H&Y)break;if(H&tt){if(--$===0)return F}else H&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),C=Math.min(i,p.end);if(g<C){for(var M=k.levels.slice(g,C+1),v=C;v>=g&&w(u[v])&m;v--)M[v]=p.level;for(var B=p.level,P=1/0,J=0;J<M.length;J++){var W=M[J];W>B&&(B=W),W<P&&(P=W|1)}for(var X=B;X>=
148
- P;X--)for(var b=0;b<M.length;b++)if(M[b]>=X){for(var x=b;b+1<M.length&&M[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 C=g[0],M=g[1],v=d.slice(C,M+1),B=v.
150
- length;B--;)d[M-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 Ze=null;function ee(){return Ze||
155
- (Ze=ha()),Ze}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 Ct=s[w];s[w]=s[K],s[K]=Ct,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,In as B,Qn as C,ea as D,O as F,Qr as H,te as L,Vn as a,Jr as b,nn as c,fa as d,Ur as e,Zn as f,Xr as g,Yt as h,aa as i,Xn as j,Ln as k,$e as l,Gn as m,na as n,Hr as o,en as p,Re as q,ma as r,Gr as s,
160
- rn as t,tn as u,ua as v,da as w,Jn as x,ba as y,oa as z};