docrev 0.8.1 → 0.8.5

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 (306) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/PLAN-tables-and-postprocess.md +850 -0
  3. package/README.md +33 -0
  4. package/bin/rev.js +12 -131
  5. package/bin/rev.ts +145 -0
  6. package/dist/bin/rev.d.ts +9 -0
  7. package/dist/bin/rev.d.ts.map +1 -0
  8. package/dist/bin/rev.js +118 -0
  9. package/dist/bin/rev.js.map +1 -0
  10. package/dist/lib/annotations.d.ts +91 -0
  11. package/dist/lib/annotations.d.ts.map +1 -0
  12. package/dist/lib/annotations.js +554 -0
  13. package/dist/lib/annotations.js.map +1 -0
  14. package/dist/lib/build.d.ts +171 -0
  15. package/dist/lib/build.d.ts.map +1 -0
  16. package/dist/lib/build.js +755 -0
  17. package/dist/lib/build.js.map +1 -0
  18. package/dist/lib/citations.d.ts +34 -0
  19. package/dist/lib/citations.d.ts.map +1 -0
  20. package/dist/lib/citations.js +140 -0
  21. package/dist/lib/citations.js.map +1 -0
  22. package/dist/lib/commands/build.d.ts +13 -0
  23. package/dist/lib/commands/build.d.ts.map +1 -0
  24. package/dist/lib/commands/build.js +678 -0
  25. package/dist/lib/commands/build.js.map +1 -0
  26. package/dist/lib/commands/citations.d.ts +11 -0
  27. package/dist/lib/commands/citations.d.ts.map +1 -0
  28. package/dist/lib/commands/citations.js +428 -0
  29. package/dist/lib/commands/citations.js.map +1 -0
  30. package/dist/lib/commands/comments.d.ts +11 -0
  31. package/dist/lib/commands/comments.d.ts.map +1 -0
  32. package/dist/lib/commands/comments.js +883 -0
  33. package/dist/lib/commands/comments.js.map +1 -0
  34. package/dist/lib/commands/context.d.ts +35 -0
  35. package/dist/lib/commands/context.d.ts.map +1 -0
  36. package/dist/lib/commands/context.js +59 -0
  37. package/dist/lib/commands/context.js.map +1 -0
  38. package/dist/lib/commands/core.d.ts +11 -0
  39. package/dist/lib/commands/core.d.ts.map +1 -0
  40. package/dist/lib/commands/core.js +246 -0
  41. package/dist/lib/commands/core.js.map +1 -0
  42. package/dist/lib/commands/doi.d.ts +11 -0
  43. package/dist/lib/commands/doi.d.ts.map +1 -0
  44. package/dist/lib/commands/doi.js +373 -0
  45. package/dist/lib/commands/doi.js.map +1 -0
  46. package/dist/lib/commands/history.d.ts +11 -0
  47. package/dist/lib/commands/history.d.ts.map +1 -0
  48. package/dist/lib/commands/history.js +245 -0
  49. package/dist/lib/commands/history.js.map +1 -0
  50. package/dist/lib/commands/index.d.ts +28 -0
  51. package/dist/lib/commands/index.d.ts.map +1 -0
  52. package/dist/lib/commands/index.js +35 -0
  53. package/dist/lib/commands/index.js.map +1 -0
  54. package/dist/lib/commands/init.d.ts +11 -0
  55. package/dist/lib/commands/init.d.ts.map +1 -0
  56. package/dist/lib/commands/init.js +209 -0
  57. package/dist/lib/commands/init.js.map +1 -0
  58. package/dist/lib/commands/response.d.ts +11 -0
  59. package/dist/lib/commands/response.d.ts.map +1 -0
  60. package/dist/lib/commands/response.js +317 -0
  61. package/dist/lib/commands/response.js.map +1 -0
  62. package/dist/lib/commands/sections.d.ts +11 -0
  63. package/dist/lib/commands/sections.d.ts.map +1 -0
  64. package/dist/lib/commands/sections.js +1071 -0
  65. package/dist/lib/commands/sections.js.map +1 -0
  66. package/dist/lib/commands/utilities.d.ts +19 -0
  67. package/dist/lib/commands/utilities.d.ts.map +1 -0
  68. package/dist/lib/commands/utilities.js +2009 -0
  69. package/dist/lib/commands/utilities.js.map +1 -0
  70. package/dist/lib/comment-realign.d.ts +50 -0
  71. package/dist/lib/comment-realign.d.ts.map +1 -0
  72. package/dist/lib/comment-realign.js +372 -0
  73. package/dist/lib/comment-realign.js.map +1 -0
  74. package/dist/lib/config.d.ts +41 -0
  75. package/dist/lib/config.d.ts.map +1 -0
  76. package/dist/lib/config.js +76 -0
  77. package/dist/lib/config.js.map +1 -0
  78. package/dist/lib/crossref.d.ts +108 -0
  79. package/dist/lib/crossref.d.ts.map +1 -0
  80. package/dist/lib/crossref.js +597 -0
  81. package/dist/lib/crossref.js.map +1 -0
  82. package/dist/lib/dependencies.d.ts +30 -0
  83. package/dist/lib/dependencies.d.ts.map +1 -0
  84. package/dist/lib/dependencies.js +95 -0
  85. package/dist/lib/dependencies.js.map +1 -0
  86. package/dist/lib/doi-cache.d.ts +29 -0
  87. package/dist/lib/doi-cache.d.ts.map +1 -0
  88. package/dist/lib/doi-cache.js +104 -0
  89. package/dist/lib/doi-cache.js.map +1 -0
  90. package/dist/lib/doi.d.ts +65 -0
  91. package/dist/lib/doi.d.ts.map +1 -0
  92. package/dist/lib/doi.js +710 -0
  93. package/dist/lib/doi.js.map +1 -0
  94. package/dist/lib/equations.d.ts +61 -0
  95. package/dist/lib/equations.d.ts.map +1 -0
  96. package/dist/lib/equations.js +445 -0
  97. package/dist/lib/equations.js.map +1 -0
  98. package/dist/lib/errors.d.ts +60 -0
  99. package/dist/lib/errors.d.ts.map +1 -0
  100. package/dist/lib/errors.js +303 -0
  101. package/dist/lib/errors.js.map +1 -0
  102. package/dist/lib/format.d.ts +104 -0
  103. package/dist/lib/format.d.ts.map +1 -0
  104. package/dist/lib/format.js +416 -0
  105. package/dist/lib/format.js.map +1 -0
  106. package/dist/lib/git.d.ts +88 -0
  107. package/dist/lib/git.d.ts.map +1 -0
  108. package/dist/lib/git.js +304 -0
  109. package/dist/lib/git.js.map +1 -0
  110. package/dist/lib/grammar.d.ts +62 -0
  111. package/dist/lib/grammar.d.ts.map +1 -0
  112. package/dist/lib/grammar.js +244 -0
  113. package/dist/lib/grammar.js.map +1 -0
  114. package/dist/lib/image-registry.d.ts +68 -0
  115. package/dist/lib/image-registry.d.ts.map +1 -0
  116. package/dist/lib/image-registry.js +112 -0
  117. package/dist/lib/image-registry.js.map +1 -0
  118. package/dist/lib/import.d.ts +184 -0
  119. package/dist/lib/import.d.ts.map +1 -0
  120. package/dist/lib/import.js +1581 -0
  121. package/dist/lib/import.js.map +1 -0
  122. package/dist/lib/journals.d.ts +55 -0
  123. package/dist/lib/journals.d.ts.map +1 -0
  124. package/dist/lib/journals.js +417 -0
  125. package/dist/lib/journals.js.map +1 -0
  126. package/dist/lib/merge.d.ts +138 -0
  127. package/dist/lib/merge.d.ts.map +1 -0
  128. package/dist/lib/merge.js +603 -0
  129. package/dist/lib/merge.js.map +1 -0
  130. package/dist/lib/orcid.d.ts +36 -0
  131. package/dist/lib/orcid.d.ts.map +1 -0
  132. package/dist/lib/orcid.js +117 -0
  133. package/dist/lib/orcid.js.map +1 -0
  134. package/dist/lib/pdf-comments.d.ts +95 -0
  135. package/dist/lib/pdf-comments.d.ts.map +1 -0
  136. package/dist/lib/pdf-comments.js +192 -0
  137. package/dist/lib/pdf-comments.js.map +1 -0
  138. package/dist/lib/pdf-import.d.ts +118 -0
  139. package/dist/lib/pdf-import.d.ts.map +1 -0
  140. package/dist/lib/pdf-import.js +397 -0
  141. package/dist/lib/pdf-import.js.map +1 -0
  142. package/dist/lib/plugins.d.ts +76 -0
  143. package/dist/lib/plugins.d.ts.map +1 -0
  144. package/dist/lib/plugins.js +235 -0
  145. package/dist/lib/plugins.js.map +1 -0
  146. package/dist/lib/postprocess.d.ts +42 -0
  147. package/dist/lib/postprocess.d.ts.map +1 -0
  148. package/dist/lib/postprocess.js +138 -0
  149. package/dist/lib/postprocess.js.map +1 -0
  150. package/dist/lib/pptx-template.d.ts +59 -0
  151. package/dist/lib/pptx-template.d.ts.map +1 -0
  152. package/dist/lib/pptx-template.js +613 -0
  153. package/dist/lib/pptx-template.js.map +1 -0
  154. package/dist/lib/pptx-themes.d.ts +80 -0
  155. package/dist/lib/pptx-themes.d.ts.map +1 -0
  156. package/dist/lib/pptx-themes.js +818 -0
  157. package/dist/lib/pptx-themes.js.map +1 -0
  158. package/dist/lib/protect-restore.d.ts +137 -0
  159. package/dist/lib/protect-restore.d.ts.map +1 -0
  160. package/dist/lib/protect-restore.js +394 -0
  161. package/dist/lib/protect-restore.js.map +1 -0
  162. package/dist/lib/rate-limiter.d.ts +27 -0
  163. package/dist/lib/rate-limiter.d.ts.map +1 -0
  164. package/dist/lib/rate-limiter.js +79 -0
  165. package/dist/lib/rate-limiter.js.map +1 -0
  166. package/dist/lib/response.d.ts +41 -0
  167. package/dist/lib/response.d.ts.map +1 -0
  168. package/dist/lib/response.js +150 -0
  169. package/dist/lib/response.js.map +1 -0
  170. package/dist/lib/review.d.ts +35 -0
  171. package/dist/lib/review.d.ts.map +1 -0
  172. package/dist/lib/review.js +263 -0
  173. package/dist/lib/review.js.map +1 -0
  174. package/dist/lib/schema.d.ts +66 -0
  175. package/dist/lib/schema.d.ts.map +1 -0
  176. package/dist/lib/schema.js +339 -0
  177. package/dist/lib/schema.js.map +1 -0
  178. package/dist/lib/scientific-words.d.ts +6 -0
  179. package/dist/lib/scientific-words.d.ts.map +1 -0
  180. package/dist/lib/scientific-words.js +66 -0
  181. package/dist/lib/scientific-words.js.map +1 -0
  182. package/dist/lib/sections.d.ts +40 -0
  183. package/dist/lib/sections.d.ts.map +1 -0
  184. package/dist/lib/sections.js +288 -0
  185. package/dist/lib/sections.js.map +1 -0
  186. package/dist/lib/slides.d.ts +86 -0
  187. package/dist/lib/slides.d.ts.map +1 -0
  188. package/dist/lib/slides.js +676 -0
  189. package/dist/lib/slides.js.map +1 -0
  190. package/dist/lib/spelling.d.ts +76 -0
  191. package/dist/lib/spelling.d.ts.map +1 -0
  192. package/dist/lib/spelling.js +272 -0
  193. package/dist/lib/spelling.js.map +1 -0
  194. package/dist/lib/templates.d.ts +30 -0
  195. package/dist/lib/templates.d.ts.map +1 -0
  196. package/dist/lib/templates.js +504 -0
  197. package/dist/lib/templates.js.map +1 -0
  198. package/dist/lib/themes.d.ts +85 -0
  199. package/dist/lib/themes.d.ts.map +1 -0
  200. package/dist/lib/themes.js +652 -0
  201. package/dist/lib/themes.js.map +1 -0
  202. package/dist/lib/trackchanges.d.ts +51 -0
  203. package/dist/lib/trackchanges.d.ts.map +1 -0
  204. package/dist/lib/trackchanges.js +202 -0
  205. package/dist/lib/trackchanges.js.map +1 -0
  206. package/dist/lib/tui.d.ts +76 -0
  207. package/dist/lib/tui.d.ts.map +1 -0
  208. package/dist/lib/tui.js +377 -0
  209. package/dist/lib/tui.js.map +1 -0
  210. package/dist/lib/types.d.ts +447 -0
  211. package/dist/lib/types.d.ts.map +1 -0
  212. package/dist/lib/types.js +6 -0
  213. package/dist/lib/types.js.map +1 -0
  214. package/dist/lib/undo.d.ts +57 -0
  215. package/dist/lib/undo.d.ts.map +1 -0
  216. package/dist/lib/undo.js +185 -0
  217. package/dist/lib/undo.js.map +1 -0
  218. package/dist/lib/utils.d.ts +16 -0
  219. package/dist/lib/utils.d.ts.map +1 -0
  220. package/dist/lib/utils.js +40 -0
  221. package/dist/lib/utils.js.map +1 -0
  222. package/dist/lib/variables.d.ts +42 -0
  223. package/dist/lib/variables.d.ts.map +1 -0
  224. package/dist/lib/variables.js +141 -0
  225. package/dist/lib/variables.js.map +1 -0
  226. package/dist/lib/word.d.ts +80 -0
  227. package/dist/lib/word.d.ts.map +1 -0
  228. package/dist/lib/word.js +360 -0
  229. package/dist/lib/word.js.map +1 -0
  230. package/dist/lib/wordcomments.d.ts +51 -0
  231. package/dist/lib/wordcomments.d.ts.map +1 -0
  232. package/dist/lib/wordcomments.js +587 -0
  233. package/dist/lib/wordcomments.js.map +1 -0
  234. package/eslint.config.js +27 -0
  235. package/lib/annotations.ts +622 -0
  236. package/lib/apply-buildup-colors.py +88 -0
  237. package/lib/build.ts +1013 -0
  238. package/lib/{citations.js → citations.ts} +38 -27
  239. package/lib/commands/{build.js → build.ts} +80 -27
  240. package/lib/commands/{citations.js → citations.ts} +36 -18
  241. package/lib/commands/{comments.js → comments.ts} +187 -54
  242. package/lib/commands/{context.js → context.ts} +18 -8
  243. package/lib/commands/{core.js → core.ts} +34 -20
  244. package/lib/commands/{doi.js → doi.ts} +32 -16
  245. package/lib/commands/{history.js → history.ts} +25 -12
  246. package/lib/commands/{index.js → index.ts} +9 -5
  247. package/lib/commands/{init.js → init.ts} +20 -8
  248. package/lib/commands/{response.js → response.ts} +47 -20
  249. package/lib/commands/{sections.js → sections.ts} +273 -68
  250. package/lib/commands/{utilities.js → utilities.ts} +338 -158
  251. package/lib/{comment-realign.js → comment-realign.ts} +117 -45
  252. package/lib/config.ts +84 -0
  253. package/lib/{crossref.js → crossref.ts} +213 -138
  254. package/lib/dependencies.ts +106 -0
  255. package/lib/doi-cache.ts +115 -0
  256. package/lib/{doi.js → doi.ts} +115 -281
  257. package/lib/{equations.js → equations.ts} +60 -64
  258. package/lib/{errors.js → errors.ts} +56 -48
  259. package/lib/{format.js → format.ts} +137 -63
  260. package/lib/{git.js → git.ts} +66 -63
  261. package/lib/{grammar.js → grammar.ts} +45 -32
  262. package/lib/image-registry.ts +180 -0
  263. package/lib/import.ts +2060 -0
  264. package/lib/journals.ts +505 -0
  265. package/lib/{merge.js → merge.ts} +185 -135
  266. package/lib/{orcid.js → orcid.ts} +17 -22
  267. package/lib/{pdf-comments.js → pdf-comments.ts} +76 -18
  268. package/lib/{pdf-import.js → pdf-import.ts} +148 -70
  269. package/lib/{plugins.js → plugins.ts} +82 -39
  270. package/lib/postprocess.ts +188 -0
  271. package/lib/pptx-color-filter.lua +37 -0
  272. package/lib/pptx-template.ts +625 -0
  273. package/lib/pptx-themes/academic.pptx +0 -0
  274. package/lib/pptx-themes/corporate.pptx +0 -0
  275. package/lib/pptx-themes/dark.pptx +0 -0
  276. package/lib/pptx-themes/default.pptx +0 -0
  277. package/lib/pptx-themes/minimal.pptx +0 -0
  278. package/lib/pptx-themes/plant.pptx +0 -0
  279. package/lib/pptx-themes.ts +896 -0
  280. package/lib/protect-restore.ts +516 -0
  281. package/lib/rate-limiter.ts +94 -0
  282. package/lib/{response.js → response.ts} +36 -21
  283. package/lib/{review.js → review.ts} +53 -43
  284. package/lib/{schema.js → schema.ts} +70 -25
  285. package/lib/{sections.js → sections.ts} +71 -76
  286. package/lib/slides.ts +793 -0
  287. package/lib/{spelling.js → spelling.ts} +43 -59
  288. package/lib/{templates.js → templates.ts} +20 -17
  289. package/lib/themes.ts +742 -0
  290. package/lib/{trackchanges.js → trackchanges.ts} +52 -23
  291. package/lib/types.ts +509 -0
  292. package/lib/{undo.js → undo.ts} +75 -52
  293. package/lib/utils.ts +41 -0
  294. package/lib/{variables.js → variables.ts} +60 -54
  295. package/lib/word.ts +428 -0
  296. package/lib/{wordcomments.js → wordcomments.ts} +94 -40
  297. package/package.json +15 -5
  298. package/skill/REFERENCE.md +67 -0
  299. package/tsconfig.json +26 -0
  300. package/lib/annotations.js +0 -414
  301. package/lib/build.js +0 -639
  302. package/lib/config.js +0 -79
  303. package/lib/import.js +0 -1145
  304. package/lib/journals.js +0 -629
  305. package/lib/word.js +0 -225
  306. /package/lib/{scientific-words.js → scientific-words.ts} +0 -0
@@ -0,0 +1,185 @@
1
+ /**
2
+ * In-session undo stack for comment/annotation operations
3
+ *
4
+ * Provides undo/redo functionality during interactive sessions
5
+ */
6
+ /**
7
+ * Create an undo stack
8
+ */
9
+ export function createUndoStack(maxSize = 50) {
10
+ const stack = [];
11
+ let position = -1;
12
+ return {
13
+ /**
14
+ * Push a new state onto the stack
15
+ */
16
+ push(state, description = '') {
17
+ // Remove any states after current position (for redo)
18
+ if (position < stack.length - 1) {
19
+ stack.splice(position + 1);
20
+ }
21
+ // Add new state
22
+ stack.push({
23
+ state: typeof state === 'string' ? state : JSON.parse(JSON.stringify(state)),
24
+ description,
25
+ timestamp: Date.now(),
26
+ });
27
+ // Enforce max size
28
+ while (stack.length > maxSize) {
29
+ stack.shift();
30
+ }
31
+ position = stack.length - 1;
32
+ },
33
+ /**
34
+ * Undo to previous state
35
+ */
36
+ undo() {
37
+ if (position <= 0) {
38
+ return null;
39
+ }
40
+ position--;
41
+ return stack[position] || null;
42
+ },
43
+ /**
44
+ * Redo to next state
45
+ */
46
+ redo() {
47
+ if (position >= stack.length - 1) {
48
+ return null;
49
+ }
50
+ position++;
51
+ return stack[position] || null;
52
+ },
53
+ /**
54
+ * Get current state
55
+ */
56
+ current() {
57
+ if (position < 0 || position >= stack.length) {
58
+ return null;
59
+ }
60
+ return stack[position] || null;
61
+ },
62
+ /**
63
+ * Check if undo is available
64
+ */
65
+ canUndo() {
66
+ return position > 0;
67
+ },
68
+ /**
69
+ * Check if redo is available
70
+ */
71
+ canRedo() {
72
+ return position < stack.length - 1;
73
+ },
74
+ /**
75
+ * Get stack info
76
+ */
77
+ info() {
78
+ return {
79
+ position,
80
+ size: stack.length,
81
+ undoSteps: position,
82
+ redoSteps: stack.length - position - 1,
83
+ };
84
+ },
85
+ /**
86
+ * Get history of changes
87
+ */
88
+ history(limit = 10) {
89
+ const start = Math.max(0, position - Math.floor(limit / 2));
90
+ const end = Math.min(stack.length, start + limit);
91
+ return stack.slice(start, end).map((item, i) => ({
92
+ description: item.description,
93
+ current: start + i === position,
94
+ index: start + i,
95
+ }));
96
+ },
97
+ /**
98
+ * Clear the stack
99
+ */
100
+ clear() {
101
+ stack.length = 0;
102
+ position = -1;
103
+ },
104
+ /**
105
+ * Get the full stack (for debugging)
106
+ */
107
+ getStack() {
108
+ return [...stack];
109
+ },
110
+ };
111
+ }
112
+ /**
113
+ * Create a document session with undo support
114
+ */
115
+ export function createDocumentSession(initialText) {
116
+ const undoStack = createUndoStack();
117
+ // Save initial state
118
+ undoStack.push(initialText, 'Initial state');
119
+ return {
120
+ /**
121
+ * Get current text
122
+ */
123
+ getText() {
124
+ const current = undoStack.current();
125
+ return current ? current.state : initialText;
126
+ },
127
+ /**
128
+ * Apply a change
129
+ */
130
+ applyChange(newText, description) {
131
+ undoStack.push(newText, description);
132
+ },
133
+ /**
134
+ * Undo last change
135
+ */
136
+ undo() {
137
+ const result = undoStack.undo();
138
+ if (result) {
139
+ return {
140
+ text: result.state,
141
+ description: result.description,
142
+ };
143
+ }
144
+ return null;
145
+ },
146
+ /**
147
+ * Redo last undone change
148
+ */
149
+ redo() {
150
+ const result = undoStack.redo();
151
+ if (result) {
152
+ return {
153
+ text: result.state,
154
+ description: result.description,
155
+ };
156
+ }
157
+ return null;
158
+ },
159
+ /**
160
+ * Check if undo is available
161
+ */
162
+ canUndo() {
163
+ return undoStack.canUndo();
164
+ },
165
+ /**
166
+ * Check if redo is available
167
+ */
168
+ canRedo() {
169
+ return undoStack.canRedo();
170
+ },
171
+ /**
172
+ * Get stack info
173
+ */
174
+ info() {
175
+ return undoStack.info();
176
+ },
177
+ /**
178
+ * Get change history
179
+ */
180
+ history(limit = 10) {
181
+ return undoStack.history(limit);
182
+ },
183
+ };
184
+ }
185
+ //# sourceMappingURL=undo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"undo.js","sourceRoot":"","sources":["../../lib/undo.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkDH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB,EAAE;IAClD,MAAM,KAAK,GAAiB,EAAE,CAAC;IAC/B,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC;IAElB,OAAO;QACL;;WAEG;QACH,IAAI,CAAC,KAAsB,EAAE,cAAsB,EAAE;YACnD,sDAAsD;YACtD,IAAI,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,KAAK,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAC7B,CAAC;YAED,gBAAgB;YAChB,KAAK,CAAC,IAAI,CAAC;gBACT,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBAC5E,WAAW;gBACX,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC;YAEH,mBAAmB;YACnB,OAAO,KAAK,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;gBAC9B,KAAK,CAAC,KAAK,EAA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AC,KAAe;oBAC5B,WAAW,EAAE,MAAM,CAAC,WAAW;iBAChC,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;WAEG;QACH,IAAI;YACF,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;YAChC,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO;oBACL,IAAI,EAAE,MAAM,CAAC,KAAe;oBAC5B,WAAW,EAAE,MAAM,CAAC,WAAW;iBAChC,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED;;WAEG;QACH,OAAO;YACL,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QAED;;WAEG;QACH,OAAO;YACL,OAAO,SAAS,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QAED;;WAEG;QACH,IAAI;YACF,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC;QAC1B,CAAC;QAED;;WAEG;QACH,OAAO,CAAC,QAAgB,EAAE;YACxB,OAAO,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared utility functions
3
+ */
4
+ /**
5
+ * Count words in text (excluding markdown syntax)
6
+ * @param text - Markdown text
7
+ * @returns Word count
8
+ */
9
+ export declare function countWords(text: string): number;
10
+ /**
11
+ * Normalize whitespace in text
12
+ * @param text - Input text
13
+ * @returns Normalized text
14
+ */
15
+ export declare function normalizeWhitespace(text: string): string;
16
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkB/C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMxD"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Shared utility functions
3
+ */
4
+ /**
5
+ * Count words in text (excluding markdown syntax)
6
+ * @param text - Markdown text
7
+ * @returns Word count
8
+ */
9
+ export function countWords(text) {
10
+ return text
11
+ .replace(/^---[\s\S]*?---/m, '') // Remove YAML frontmatter
12
+ .replace(/!\[.*?\]\(.*?\)/g, '') // Remove images
13
+ .replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Keep link text
14
+ .replace(/#+\s*/g, '') // Remove headers
15
+ .replace(/\*\*|__|[*_`]/g, '') // Remove formatting
16
+ .replace(/```[\s\S]*?```/g, '') // Remove code blocks
17
+ .replace(/\{[^}]+\}/g, '') // Remove CriticMarkup and attributes
18
+ .replace(/@\w+:\w+/g, '') // Remove cross-references
19
+ .replace(/@\w+/g, '') // Remove citations
20
+ .replace(/\|[^|]+\|/g, ' ') // Remove table cells
21
+ .replace(/[-=]{3,}/g, '') // Remove horizontal rules
22
+ .replace(/\n+/g, ' ') // Newlines to spaces
23
+ .replace(/\s+/g, ' ') // Collapse multiple spaces
24
+ .trim()
25
+ .split(/\s+/)
26
+ .filter(w => w.length > 0).length;
27
+ }
28
+ /**
29
+ * Normalize whitespace in text
30
+ * @param text - Input text
31
+ * @returns Normalized text
32
+ */
33
+ export function normalizeWhitespace(text) {
34
+ return text
35
+ .replace(/\r\n/g, '\n')
36
+ .replace(/\t/g, ' ')
37
+ .replace(/ +/g, ' ')
38
+ .trim();
39
+ }
40
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI;SACR,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,0BAA0B;SAC1D,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,gBAAgB;SAChD,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,iBAAiB;SACzD,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,iBAAiB;SACvC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,oBAAoB;SAClD,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC,qBAAqB;SACpD,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,qCAAqC;SAC/D,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,0BAA0B;SACnD,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,mBAAmB;SACxC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,qBAAqB;SAChD,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,0BAA0B;SACnD,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,qBAAqB;SAC1C,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,2BAA2B;SAChD,IAAI,EAAE;SACN,KAAK,CAAC,KAAK,CAAC;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC;AACtC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI;SACR,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;SACtB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,IAAI,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Template variable substitution for rev
3
+ *
4
+ * Supported variables:
5
+ * {{date}} - Current date (YYYY-MM-DD)
6
+ * {{date:format}} - Custom date format (e.g., {{date:MMMM D, YYYY}})
7
+ * {{version}} - Version from rev.yaml
8
+ * {{word_count}} - Total word count
9
+ * {{author}} - First author name
10
+ * {{authors}} - All authors (comma-separated)
11
+ * {{title}} - Document title
12
+ * {{year}} - Current year
13
+ */
14
+ import type { Author } from './types.js';
15
+ /**
16
+ * Options for variable processing
17
+ */
18
+ interface ProcessVariablesOptions {
19
+ sectionContents?: string[];
20
+ }
21
+ /**
22
+ * Config object (minimal subset needed for variables)
23
+ */
24
+ interface Config {
25
+ version?: string;
26
+ title?: string;
27
+ authors?: Author[] | string;
28
+ }
29
+ /**
30
+ * Process template variables in text
31
+ */
32
+ export declare function processVariables(text: string, config?: Config, options?: ProcessVariablesOptions): string;
33
+ /**
34
+ * Check if text contains any template variables
35
+ */
36
+ export declare function hasVariables(text: string): boolean;
37
+ /**
38
+ * List all variables found in text
39
+ */
40
+ export declare function findVariables(text: string): string[];
41
+ export {};
42
+ //# sourceMappingURL=variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../lib/variables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAqFzC;;GAEG;AACH,UAAU,uBAAuB;IAC/B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,MAAW,EACnB,OAAO,GAAE,uBAA4B,GACpC,MAAM,CAuCR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGpD"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Template variable substitution for rev
3
+ *
4
+ * Supported variables:
5
+ * {{date}} - Current date (YYYY-MM-DD)
6
+ * {{date:format}} - Custom date format (e.g., {{date:MMMM D, YYYY}})
7
+ * {{version}} - Version from rev.yaml
8
+ * {{word_count}} - Total word count
9
+ * {{author}} - First author name
10
+ * {{authors}} - All authors (comma-separated)
11
+ * {{title}} - Document title
12
+ * {{year}} - Current year
13
+ */
14
+ import { countWords } from './utils.js';
15
+ /**
16
+ * Format date with simple pattern
17
+ */
18
+ function formatDate(date, format = 'YYYY-MM-DD') {
19
+ const months = [
20
+ 'January',
21
+ 'February',
22
+ 'March',
23
+ 'April',
24
+ 'May',
25
+ 'June',
26
+ 'July',
27
+ 'August',
28
+ 'September',
29
+ 'October',
30
+ 'November',
31
+ 'December',
32
+ ];
33
+ const monthsShort = [
34
+ 'Jan',
35
+ 'Feb',
36
+ 'Mar',
37
+ 'Apr',
38
+ 'May',
39
+ 'Jun',
40
+ 'Jul',
41
+ 'Aug',
42
+ 'Sep',
43
+ 'Oct',
44
+ 'Nov',
45
+ 'Dec',
46
+ ];
47
+ const year = date.getFullYear();
48
+ const month = date.getMonth();
49
+ const day = date.getDate();
50
+ // Use placeholders to avoid replacement conflicts (e.g., D in December)
51
+ const monthFull = months[month] || '';
52
+ const monthShort = monthsShort[month] || '';
53
+ return format
54
+ .replace('YYYY', '\x00YEAR\x00')
55
+ .replace('MMMM', '\x00MONTHFULL\x00')
56
+ .replace('MMM', '\x00MONTHSHORT\x00')
57
+ .replace('MM', '\x00MONTHNUM\x00')
58
+ .replace('DD', '\x00DAYPAD\x00')
59
+ .replace(/\bD\b/, '\x00DAY\x00')
60
+ .replace('\x00YEAR\x00', year.toString())
61
+ .replace('\x00MONTHFULL\x00', monthFull)
62
+ .replace('\x00MONTHSHORT\x00', monthShort)
63
+ .replace('\x00MONTHNUM\x00', (month + 1).toString().padStart(2, '0'))
64
+ .replace('\x00DAYPAD\x00', day.toString().padStart(2, '0'))
65
+ .replace('\x00DAY\x00', day.toString());
66
+ }
67
+ /**
68
+ * Get first author name from authors array
69
+ */
70
+ function getFirstAuthor(authors) {
71
+ if (!authors || (Array.isArray(authors) && authors.length === 0))
72
+ return '';
73
+ const first = Array.isArray(authors) ? authors[0] : authors;
74
+ if (!first)
75
+ return '';
76
+ if (typeof first === 'string')
77
+ return first;
78
+ if (first.name)
79
+ return first.name;
80
+ return '';
81
+ }
82
+ /**
83
+ * Get all author names
84
+ */
85
+ function getAllAuthors(authors) {
86
+ if (!authors)
87
+ return '';
88
+ if (typeof authors === 'string')
89
+ return authors;
90
+ return authors
91
+ .map((a) => (typeof a === 'string' ? a : (a.name || '')))
92
+ .filter(Boolean)
93
+ .join(', ');
94
+ }
95
+ /**
96
+ * Process template variables in text
97
+ */
98
+ export function processVariables(text, config = {}, options = {}) {
99
+ const now = new Date();
100
+ let result = text;
101
+ // Calculate word count from sections if provided
102
+ let wordCount = 0;
103
+ if (options.sectionContents) {
104
+ for (const content of options.sectionContents) {
105
+ wordCount += countWords(content);
106
+ }
107
+ }
108
+ // {{date}} - Current date
109
+ result = result.replace(/\{\{date\}\}/g, formatDate(now));
110
+ // {{date:format}} - Custom date format
111
+ result = result.replace(/\{\{date:([^}]+)\}\}/g, (match, format) => {
112
+ return formatDate(now, format);
113
+ });
114
+ // {{year}} - Current year
115
+ result = result.replace(/\{\{year\}\}/g, now.getFullYear().toString());
116
+ // {{version}} - From config
117
+ result = result.replace(/\{\{version\}\}/g, config.version || '');
118
+ // {{title}} - Document title
119
+ result = result.replace(/\{\{title\}\}/g, config.title || '');
120
+ // {{author}} - First author
121
+ result = result.replace(/\{\{author\}\}/g, getFirstAuthor(config.authors));
122
+ // {{authors}} - All authors
123
+ result = result.replace(/\{\{authors\}\}/g, getAllAuthors(config.authors));
124
+ // {{word_count}} - Total word count
125
+ result = result.replace(/\{\{word_count\}\}/g, wordCount.toLocaleString());
126
+ return result;
127
+ }
128
+ /**
129
+ * Check if text contains any template variables
130
+ */
131
+ export function hasVariables(text) {
132
+ return /\{\{[^}]+\}\}/.test(text);
133
+ }
134
+ /**
135
+ * List all variables found in text
136
+ */
137
+ export function findVariables(text) {
138
+ const matches = text.match(/\{\{([^}]+)\}\}/g) || [];
139
+ return [...new Set(matches.map((m) => m.slice(2, -2)))];
140
+ }
141
+ //# sourceMappingURL=variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.js","sourceRoot":"","sources":["../../lib/variables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC;;GAEG;AACH,SAAS,UAAU,CAAC,IAAU,EAAE,SAAiB,YAAY;IAC3D,MAAM,MAAM,GAAG;QACb,SAAS;QACT,UAAU;QACV,OAAO;QACP,OAAO;QACP,KAAK;QACL,MAAM;QACN,MAAM;QACN,QAAQ;QACR,WAAW;QACX,SAAS;QACT,UAAU;QACV,UAAU;KACX,CAAC;IACF,MAAM,WAAW,GAAG;QAClB,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;KACN,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAE3B,wEAAwE;IACxE,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC5C,OAAO,MAAM;SACV,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC;SAC/B,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC;SACpC,OAAO,CAAC,KAAK,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AAE,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAElE,6BAA6B;IAC7B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAE9D,4BAA4B;IAC5B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3E,4BAA4B;IAC5B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3E,oCAAoC;IACpC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;IAE3E,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC;IACrD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Word document extraction utilities
3
+ * Handle reading text, comments, and anchors from .docx files
4
+ */
5
+ import type { WordComment, CommentAnchor, WordContent, WordMetadata, TrackChangesResult } from './types.js';
6
+ /**
7
+ * Extract comments from Word document's comments.xml
8
+ * @param docxPath - Path to .docx file
9
+ * @returns Array of extracted comments
10
+ * @throws {TypeError} If docxPath is not a string
11
+ * @throws {Error} If file not found or invalid docx
12
+ */
13
+ export declare function extractWordComments(docxPath: string): Promise<WordComment[]>;
14
+ /**
15
+ * Extract comment anchors (where comments are attached) from document.xml
16
+ * Returns mapping of comment ID to the text they're anchored to
17
+ * @param docxPath - Path to .docx file
18
+ * @returns Map of comment ID to anchor info
19
+ * @throws {TypeError} If docxPath is not a string
20
+ * @throws {Error} If invalid docx structure
21
+ */
22
+ export declare function extractCommentAnchors(docxPath: string): Promise<Map<string, CommentAnchor>>;
23
+ /**
24
+ * Extract plain text from Word document using mammoth
25
+ * @param docxPath - Path to .docx file
26
+ * @returns Extracted plain text
27
+ * @throws {TypeError} If docxPath is not a string
28
+ * @throws {Error} If file not found
29
+ */
30
+ export declare function extractTextFromWord(docxPath: string): Promise<string>;
31
+ /**
32
+ * Extract rich content from Word with basic formatting
33
+ * @param docxPath - Path to .docx file
34
+ * @returns Text and HTML content
35
+ * @throws {TypeError} If docxPath is not a string
36
+ * @throws {Error} If file not found
37
+ */
38
+ export declare function extractFromWord(docxPath: string): Promise<WordContent>;
39
+ /**
40
+ * Get document metadata from Word file
41
+ * @param docxPath - Path to .docx file
42
+ * @returns Document metadata
43
+ * @throws {TypeError} If docxPath is not a string
44
+ */
45
+ export declare function getWordMetadata(docxPath: string): Promise<WordMetadata>;
46
+ /**
47
+ * Check if file is a valid Word document
48
+ * @param filePath - Path to file to check
49
+ * @returns True if valid .docx file
50
+ */
51
+ export declare function isWordDocument(filePath: string): boolean;
52
+ /**
53
+ * Extract track changes (insertions and deletions) from Word document
54
+ * Converts Word's w:ins and w:del elements to CriticMarkup format
55
+ *
56
+ * @param docxPath - Path to Word document
57
+ * @returns Track changes result with content and stats
58
+ */
59
+ export declare function extractTrackChanges(docxPath: string): Promise<TrackChangesResult>;
60
+ interface ExtractWithTrackChangesOptions {
61
+ mediaDir?: string;
62
+ }
63
+ /**
64
+ * Extract Word document content with track changes preserved as CriticMarkup
65
+ * Uses pandoc with track-changes=all option to preserve insertions/deletions
66
+ *
67
+ * @param docxPath - Path to Word document
68
+ * @param options - Options
69
+ * @returns Track changes result with text and stats
70
+ */
71
+ export declare function extractWithTrackChanges(docxPath: string, options?: ExtractWithTrackChangesOptions): Promise<{
72
+ text: string;
73
+ hasTrackChanges: boolean;
74
+ stats: {
75
+ insertions: number;
76
+ deletions: number;
77
+ };
78
+ }>;
79
+ export {};
80
+ //# sourceMappingURL=word.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"word.d.ts","sourceRoot":"","sources":["../../lib/word.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAkB5G;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsDlF;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAkEjG;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW3E;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAmB5E;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CA+B7E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAWxD;AAuBD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkDvF;AAED,UAAU,8BAA8B;IACtC,QAAQ,CAAC,EA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