@office-kit/xlsx 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +319 -0
  3. package/THIRD_PARTY_NOTICES.md +56 -0
  4. package/dist/cell/cell.d.ts +234 -0
  5. package/dist/cell/index.d.ts +4 -0
  6. package/dist/cell/rich-text.d.ts +37 -0
  7. package/dist/cell-D9CaNKnU.mjs +320 -0
  8. package/dist/cell-D9CaNKnU.mjs.map +1 -0
  9. package/dist/cell-style-BEDjMX1y.mjs +1579 -0
  10. package/dist/cell-style-BEDjMX1y.mjs.map +1 -0
  11. package/dist/cell.mjs +2 -0
  12. package/dist/chart/chart-xml.d.ts +16 -0
  13. package/dist/chart/chart.d.ts +735 -0
  14. package/dist/chart/cx/chartex-xml.d.ts +6 -0
  15. package/dist/chart/cx/chartex.d.ts +279 -0
  16. package/dist/chart/index.d.ts +6 -0
  17. package/dist/chart/user-shapes-xml.d.ts +4 -0
  18. package/dist/chart/user-shapes.d.ts +61 -0
  19. package/dist/chart.mjs +232 -0
  20. package/dist/chart.mjs.map +1 -0
  21. package/dist/chartsheet/chartsheet-xml.d.ts +17 -0
  22. package/dist/chartsheet/chartsheet.d.ts +121 -0
  23. package/dist/chartsheet/index.d.ts +2 -0
  24. package/dist/chartsheet-C3-tqkPy.mjs +23 -0
  25. package/dist/chartsheet-C3-tqkPy.mjs.map +1 -0
  26. package/dist/chartsheet.mjs +2 -0
  27. package/dist/colors-ovWAwnZI.mjs +67 -0
  28. package/dist/colors-ovWAwnZI.mjs.map +1 -0
  29. package/dist/compat/numbers.d.ts +14 -0
  30. package/dist/coordinate-96Ecci4d.mjs +276 -0
  31. package/dist/coordinate-96Ecci4d.mjs.map +1 -0
  32. package/dist/datetime-B2ySVlXt.mjs +71 -0
  33. package/dist/datetime-B2ySVlXt.mjs.map +1 -0
  34. package/dist/defined-names-CviWmtQg.mjs +89 -0
  35. package/dist/defined-names-CviWmtQg.mjs.map +1 -0
  36. package/dist/differential-D4dg-qtZ.mjs +37 -0
  37. package/dist/differential-D4dg-qtZ.mjs.map +1 -0
  38. package/dist/drawing/anchor.d.ts +63 -0
  39. package/dist/drawing/dml/colors.d.ts +109 -0
  40. package/dist/drawing/dml/dml-xml.d.ts +35 -0
  41. package/dist/drawing/dml/effect.d.ts +92 -0
  42. package/dist/drawing/dml/fill.d.ts +115 -0
  43. package/dist/drawing/dml/geometry.d.ts +113 -0
  44. package/dist/drawing/dml/line.d.ts +41 -0
  45. package/dist/drawing/dml/shape-properties.d.ts +33 -0
  46. package/dist/drawing/dml/text.d.ts +218 -0
  47. package/dist/drawing/drawing-xml.d.ts +5 -0
  48. package/dist/drawing/drawing.d.ts +117 -0
  49. package/dist/drawing/image.d.ts +40 -0
  50. package/dist/drawing/index.d.ts +14 -0
  51. package/dist/drawing-BxzLuryn.mjs +415 -0
  52. package/dist/drawing-BxzLuryn.mjs.map +1 -0
  53. package/dist/drawing.mjs +119 -0
  54. package/dist/drawing.mjs.map +1 -0
  55. package/dist/escape-DFTE7ZJc.mjs +51 -0
  56. package/dist/escape-DFTE7ZJc.mjs.map +1 -0
  57. package/dist/exceptions-D-CFwxgm.mjs +37 -0
  58. package/dist/exceptions-D-CFwxgm.mjs.map +1 -0
  59. package/dist/formula/tokenizer.d.ts +61 -0
  60. package/dist/formula/translate.d.ts +67 -0
  61. package/dist/inference-B3ES3KEJ.mjs +42 -0
  62. package/dist/inference-B3ES3KEJ.mjs.map +1 -0
  63. package/dist/io/browser.d.ts +41 -0
  64. package/dist/io/index.d.ts +7 -0
  65. package/dist/io/load.d.ts +46 -0
  66. package/dist/io/node-fs.d.ts +62 -0
  67. package/dist/io/node-save.d.ts +3 -0
  68. package/dist/io/node.d.ts +17 -0
  69. package/dist/io/save.d.ts +14 -0
  70. package/dist/io/sink.d.ts +54 -0
  71. package/dist/io/source.d.ts +14 -0
  72. package/dist/io.mjs +212 -0
  73. package/dist/io.mjs.map +1 -0
  74. package/dist/load-D5cbhoGx.mjs +1069 -0
  75. package/dist/load-D5cbhoGx.mjs.map +1 -0
  76. package/dist/manifest-Dps1-OpP.mjs +801 -0
  77. package/dist/manifest-Dps1-OpP.mjs.map +1 -0
  78. package/dist/node.d.ts +3 -0
  79. package/dist/node.mjs +308 -0
  80. package/dist/node.mjs.map +1 -0
  81. package/dist/packaging/core.d.ts +45 -0
  82. package/dist/packaging/custom.d.ts +62 -0
  83. package/dist/packaging/extended.d.ts +45 -0
  84. package/dist/packaging/index.d.ts +10 -0
  85. package/dist/packaging/manifest.d.ts +24 -0
  86. package/dist/packaging/relationships.d.ts +30 -0
  87. package/dist/packaging.mjs +2 -0
  88. package/dist/parser-DuLejQy1.mjs +156 -0
  89. package/dist/parser-DuLejQy1.mjs.map +1 -0
  90. package/dist/reader-D1fNW9k1.mjs +534 -0
  91. package/dist/reader-D1fNW9k1.mjs.map +1 -0
  92. package/dist/save-RohQtgEZ.mjs +745 -0
  93. package/dist/save-RohQtgEZ.mjs.map +1 -0
  94. package/dist/schema/core.d.ts +133 -0
  95. package/dist/schema/index.d.ts +3 -0
  96. package/dist/schema/serialize.d.ts +6 -0
  97. package/dist/schema.mjs +2 -0
  98. package/dist/serialize-55EnT30e.mjs +254 -0
  99. package/dist/serialize-55EnT30e.mjs.map +1 -0
  100. package/dist/serializer-BwbgHYJV.mjs +116 -0
  101. package/dist/serializer-BwbgHYJV.mjs.map +1 -0
  102. package/dist/streaming/index.d.ts +2 -0
  103. package/dist/streaming/read-only.d.ts +38 -0
  104. package/dist/streaming/write-only.d.ts +47 -0
  105. package/dist/streaming.mjs +612 -0
  106. package/dist/streaming.mjs.map +1 -0
  107. package/dist/styles/alignment.d.ts +33 -0
  108. package/dist/styles/alignment.schema.d.ts +3 -0
  109. package/dist/styles/borders.d.ts +40 -0
  110. package/dist/styles/borders.schema.d.ts +4 -0
  111. package/dist/styles/cell-style.d.ts +270 -0
  112. package/dist/styles/colors.d.ts +128 -0
  113. package/dist/styles/colors.schema.d.ts +3 -0
  114. package/dist/styles/differential.d.ts +41 -0
  115. package/dist/styles/fills.d.ts +54 -0
  116. package/dist/styles/fills.schema.d.ts +6 -0
  117. package/dist/styles/fonts.d.ts +44 -0
  118. package/dist/styles/fonts.schema.d.ts +3 -0
  119. package/dist/styles/index.d.ts +21 -0
  120. package/dist/styles/named-styles.d.ts +52 -0
  121. package/dist/styles/numbers.d.ts +39 -0
  122. package/dist/styles/numbers.schema.d.ts +3 -0
  123. package/dist/styles/protection.d.ts +9 -0
  124. package/dist/styles/protection.schema.d.ts +3 -0
  125. package/dist/styles/stylesheet-reader.d.ts +7 -0
  126. package/dist/styles/stylesheet-writer.d.ts +3 -0
  127. package/dist/styles/stylesheet.d.ts +95 -0
  128. package/dist/styles.mjs +4 -0
  129. package/dist/stylesheet-writer-C2eRmn22.mjs +8624 -0
  130. package/dist/stylesheet-writer-C2eRmn22.mjs.map +1 -0
  131. package/dist/table-DkX6UniA.mjs +113 -0
  132. package/dist/table-DkX6UniA.mjs.map +1 -0
  133. package/dist/tree-Bbs1C8Rc.mjs +192 -0
  134. package/dist/tree-Bbs1C8Rc.mjs.map +1 -0
  135. package/dist/units-rOMQqXh2.mjs +41 -0
  136. package/dist/units-rOMQqXh2.mjs.map +1 -0
  137. package/dist/user-shapes-DfmCGKB0.mjs +252 -0
  138. package/dist/user-shapes-DfmCGKB0.mjs.map +1 -0
  139. package/dist/utf8-D91g1XTG.mjs +143 -0
  140. package/dist/utf8-D91g1XTG.mjs.map +1 -0
  141. package/dist/utils/coordinate.d.ts +103 -0
  142. package/dist/utils/css.d.ts +18 -0
  143. package/dist/utils/datetime.d.ts +38 -0
  144. package/dist/utils/escape.d.ts +34 -0
  145. package/dist/utils/exceptions.d.ts +34 -0
  146. package/dist/utils/index.d.ts +11 -0
  147. package/dist/utils/inference.d.ts +24 -0
  148. package/dist/utils/stable-stringify.d.ts +7 -0
  149. package/dist/utils/units.d.ts +14 -0
  150. package/dist/utils/utf8.d.ts +1 -0
  151. package/dist/utils.mjs +39 -0
  152. package/dist/utils.mjs.map +1 -0
  153. package/dist/workbook/calc-properties.d.ts +47 -0
  154. package/dist/workbook/defined-names.d.ts +121 -0
  155. package/dist/workbook/file-recovery.d.ts +11 -0
  156. package/dist/workbook/file-sharing.d.ts +14 -0
  157. package/dist/workbook/file-version.d.ts +13 -0
  158. package/dist/workbook/function-groups.d.ts +10 -0
  159. package/dist/workbook/index.d.ts +24 -0
  160. package/dist/workbook/protection.d.ts +35 -0
  161. package/dist/workbook/shared-strings.d.ts +57 -0
  162. package/dist/workbook/smart-tags.d.ts +13 -0
  163. package/dist/workbook/views.d.ts +89 -0
  164. package/dist/workbook/workbook-properties.d.ts +57 -0
  165. package/dist/workbook/workbook.d.ts +643 -0
  166. package/dist/workbook-HGYNRBlV.mjs +636 -0
  167. package/dist/workbook-HGYNRBlV.mjs.map +1 -0
  168. package/dist/workbook.mjs +58 -0
  169. package/dist/workbook.mjs.map +1 -0
  170. package/dist/worksheet/auto-filter.d.ts +34 -0
  171. package/dist/worksheet/cell-range.d.ts +121 -0
  172. package/dist/worksheet/comments-xml.d.ts +24 -0
  173. package/dist/worksheet/comments.d.ts +13 -0
  174. package/dist/worksheet/conditional-formatting.d.ts +150 -0
  175. package/dist/worksheet/custom-sheet-views.d.ts +43 -0
  176. package/dist/worksheet/data-consolidate.d.ts +29 -0
  177. package/dist/worksheet/data-validations.d.ts +72 -0
  178. package/dist/worksheet/dimensions.d.ts +40 -0
  179. package/dist/worksheet/errors.d.ts +40 -0
  180. package/dist/worksheet/hyperlinks.d.ts +42 -0
  181. package/dist/worksheet/index.d.ts +46 -0
  182. package/dist/worksheet/ole-objects.d.ts +37 -0
  183. package/dist/worksheet/page-setup.d.ts +173 -0
  184. package/dist/worksheet/phonetic.d.ts +11 -0
  185. package/dist/worksheet/properties.d.ts +34 -0
  186. package/dist/worksheet/protected-ranges.d.ts +19 -0
  187. package/dist/worksheet/protection.d.ts +44 -0
  188. package/dist/worksheet/reader.d.ts +38 -0
  189. package/dist/worksheet/scenarios.d.ts +36 -0
  190. package/dist/worksheet/smart-tags.d.ts +23 -0
  191. package/dist/worksheet/sort-state.d.ts +28 -0
  192. package/dist/worksheet/table-xml.d.ts +5 -0
  193. package/dist/worksheet/table.d.ts +80 -0
  194. package/dist/worksheet/views.d.ts +47 -0
  195. package/dist/worksheet/web-publish.d.ts +21 -0
  196. package/dist/worksheet/worksheet.d.ts +935 -0
  197. package/dist/worksheet/writer.d.ts +72 -0
  198. package/dist/worksheet-CmCNoIgD.mjs +1726 -0
  199. package/dist/worksheet-CmCNoIgD.mjs.map +1 -0
  200. package/dist/worksheet.mjs +247 -0
  201. package/dist/worksheet.mjs.map +1 -0
  202. package/dist/writer-DspzfkNA.mjs +221 -0
  203. package/dist/writer-DspzfkNA.mjs.map +1 -0
  204. package/dist/xml/index.d.ts +10 -0
  205. package/dist/xml/iterparse.d.ts +22 -0
  206. package/dist/xml/namespaces.d.ts +91 -0
  207. package/dist/xml/parser.d.ts +7 -0
  208. package/dist/xml/serializer.d.ts +14 -0
  209. package/dist/xml/stream-writer.d.ts +39 -0
  210. package/dist/xml/tree.d.ts +37 -0
  211. package/dist/xml.mjs +140 -0
  212. package/dist/xml.mjs.map +1 -0
  213. package/dist/zip/decompression-guard.d.ts +70 -0
  214. package/dist/zip/index.d.ts +6 -0
  215. package/dist/zip/random-access-reader.d.ts +16 -0
  216. package/dist/zip/reader.d.ts +45 -0
  217. package/dist/zip/writer.d.ts +65 -0
  218. package/dist/zip/zip64-patch.d.ts +12 -0
  219. package/dist/zip.mjs +3 -0
  220. package/package.json +147 -0
@@ -0,0 +1,415 @@
1
+ import { i as OpenXmlIoError, o as OpenXmlSchemaError } from "./exceptions-D-CFwxgm.mjs";
2
+ import { i as columnIndexFromLetter } from "./coordinate-96Ecci4d.mjs";
3
+ import { l as emuFromPx } from "./units-rOMQqXh2.mjs";
4
+ //#region src/drawing/image.ts
5
+ /**
6
+ * Map from image format to the Content-Types Default extension that Excel uses
7
+ * in `[Content_Types].xml`. SVG / EMF / WMF use the same extension as the
8
+ * format string; PNG/JPEG/GIF/BMP do too. WebP and TIFF use their canonical
9
+ * short names.
10
+ */
11
+ const IMAGE_FORMAT_EXTENSION = {
12
+ png: "png",
13
+ jpeg: "jpeg",
14
+ gif: "gif",
15
+ bmp: "bmp",
16
+ webp: "webp",
17
+ tiff: "tiff",
18
+ svg: "svg",
19
+ emf: "emf",
20
+ wmf: "wmf"
21
+ };
22
+ /** Map from image format to its IANA `image/*` MIME type. */
23
+ const IMAGE_FORMAT_MIME = {
24
+ png: "image/png",
25
+ jpeg: "image/jpeg",
26
+ gif: "image/gif",
27
+ bmp: "image/bmp",
28
+ webp: "image/webp",
29
+ tiff: "image/tiff",
30
+ svg: "image/svg+xml",
31
+ emf: "image/x-emf",
32
+ wmf: "image/x-wmf"
33
+ };
34
+ const startsWith = (bytes, sig, offset = 0) => {
35
+ if (bytes.length < offset + sig.length) return false;
36
+ for (let i = 0; i < sig.length; i++) if (bytes[offset + i] !== sig[i]) return false;
37
+ return true;
38
+ };
39
+ const PNG_SIG = [
40
+ 137,
41
+ 80,
42
+ 78,
43
+ 71,
44
+ 13,
45
+ 10,
46
+ 26,
47
+ 10
48
+ ];
49
+ const JPEG_SIG = [
50
+ 255,
51
+ 216,
52
+ 255
53
+ ];
54
+ const GIF87 = [
55
+ 71,
56
+ 73,
57
+ 70,
58
+ 56,
59
+ 55,
60
+ 97
61
+ ];
62
+ const GIF89 = [
63
+ 71,
64
+ 73,
65
+ 70,
66
+ 56,
67
+ 57,
68
+ 97
69
+ ];
70
+ const BMP_SIG = [66, 77];
71
+ const RIFF_SIG = [
72
+ 82,
73
+ 73,
74
+ 70,
75
+ 70
76
+ ];
77
+ const WEBP_TAG = [
78
+ 87,
79
+ 69,
80
+ 66,
81
+ 80
82
+ ];
83
+ const TIFF_LE = [
84
+ 73,
85
+ 73,
86
+ 42,
87
+ 0
88
+ ];
89
+ const TIFF_BE = [
90
+ 77,
91
+ 77,
92
+ 0,
93
+ 42
94
+ ];
95
+ const EMF_SIG = [
96
+ 1,
97
+ 0,
98
+ 0,
99
+ 0
100
+ ];
101
+ const EMF_TAG = [
102
+ 32,
103
+ 69,
104
+ 77,
105
+ 70
106
+ ];
107
+ const WMF_SIG_PLACEABLE = [
108
+ 215,
109
+ 205,
110
+ 198,
111
+ 154
112
+ ];
113
+ const WMF_SIG_BARE = [
114
+ 1,
115
+ 0,
116
+ 9,
117
+ 0
118
+ ];
119
+ const isSvg = (bytes) => {
120
+ const head = new TextDecoder("utf-8", { fatal: false }).decode(bytes.subarray(0, Math.min(bytes.length, 512)));
121
+ return /<svg\b/i.test(head);
122
+ };
123
+ function detectImageFormat(bytes) {
124
+ if (startsWith(bytes, PNG_SIG)) return "png";
125
+ if (startsWith(bytes, JPEG_SIG)) return "jpeg";
126
+ if (startsWith(bytes, GIF87) || startsWith(bytes, GIF89)) return "gif";
127
+ if (startsWith(bytes, BMP_SIG)) return "bmp";
128
+ if (startsWith(bytes, RIFF_SIG) && startsWith(bytes, WEBP_TAG, 8)) return "webp";
129
+ if (startsWith(bytes, TIFF_LE) || startsWith(bytes, TIFF_BE)) return "tiff";
130
+ if (startsWith(bytes, EMF_SIG) && startsWith(bytes, EMF_TAG, 40)) return "emf";
131
+ if (startsWith(bytes, WMF_SIG_PLACEABLE) || startsWith(bytes, WMF_SIG_BARE)) return "wmf";
132
+ if (isSvg(bytes)) return "svg";
133
+ }
134
+ const readU32BE = (bytes, offset) => (bytes[offset] ?? 0) << 24 | (bytes[offset + 1] ?? 0) << 16 | (bytes[offset + 2] ?? 0) << 8 | (bytes[offset + 3] ?? 0);
135
+ const readU16LE = (bytes, offset) => (bytes[offset] ?? 0) | (bytes[offset + 1] ?? 0) << 8;
136
+ const readU16BE = (bytes, offset) => (bytes[offset] ?? 0) << 8 | (bytes[offset + 1] ?? 0);
137
+ const pngDimensions = (bytes) => {
138
+ if (bytes.length < 24) return void 0;
139
+ if (bytes[12] !== 73 || bytes[13] !== 72 || bytes[14] !== 68 || bytes[15] !== 82) return;
140
+ return {
141
+ width: readU32BE(bytes, 16),
142
+ height: readU32BE(bytes, 20)
143
+ };
144
+ };
145
+ const gifDimensions = (bytes) => {
146
+ if (bytes.length < 10) return void 0;
147
+ return {
148
+ width: readU16LE(bytes, 6),
149
+ height: readU16LE(bytes, 8)
150
+ };
151
+ };
152
+ const bmpDimensions = (bytes) => {
153
+ if (bytes.length < 26) return void 0;
154
+ const w = (bytes[18] ?? 0) | (bytes[19] ?? 0) << 8 | (bytes[20] ?? 0) << 16 | (bytes[21] ?? 0) << 24;
155
+ const hRaw = (bytes[22] ?? 0) | (bytes[23] ?? 0) << 8 | (bytes[24] ?? 0) << 16 | (bytes[25] ?? 0) << 24;
156
+ const wSigned = (w | 0) >>> 0 > 2147483647 ? (w | 0) - 4294967296 : w;
157
+ const hSigned = (hRaw | 0) >>> 0 > 2147483647 ? (hRaw | 0) - 4294967296 : hRaw;
158
+ return {
159
+ width: wSigned,
160
+ height: Math.abs(hSigned)
161
+ };
162
+ };
163
+ const jpegDimensions = (bytes) => {
164
+ let i = 2;
165
+ while (i + 9 < bytes.length) {
166
+ if (bytes[i] !== 255) return void 0;
167
+ let marker = bytes[i + 1] ?? 0;
168
+ while (marker === 255) {
169
+ i += 1;
170
+ marker = bytes[i + 1] ?? 0;
171
+ }
172
+ i += 2;
173
+ const isSof = marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204;
174
+ const len = readU16BE(bytes, i);
175
+ if (isSof) {
176
+ if (i + 7 > bytes.length) return void 0;
177
+ const height = readU16BE(bytes, i + 3);
178
+ return {
179
+ width: readU16BE(bytes, i + 5),
180
+ height
181
+ };
182
+ }
183
+ i += len;
184
+ }
185
+ };
186
+ const webpDimensions = (bytes) => {
187
+ if (bytes.length < 30) return void 0;
188
+ if (bytes[12] === 86 && bytes[13] === 80 && bytes[14] === 56 && bytes[15] === 32) return {
189
+ width: readU16LE(bytes, 26) & 16383,
190
+ height: readU16LE(bytes, 28) & 16383
191
+ };
192
+ if (bytes[12] === 86 && bytes[13] === 80 && bytes[14] === 56 && bytes[15] === 76) {
193
+ if (bytes.length < 25) return void 0;
194
+ const b0 = bytes[21] ?? 0;
195
+ const b1 = bytes[22] ?? 0;
196
+ const b2 = bytes[23] ?? 0;
197
+ const b3 = bytes[24] ?? 0;
198
+ const w = (b0 | b1 << 8) & 16383;
199
+ const h = (b1 >> 6 | b2 << 2 | (b3 & 15) << 10) & 16383;
200
+ return {
201
+ width: w + 1,
202
+ height: h + 1
203
+ };
204
+ }
205
+ if (bytes[12] === 86 && bytes[13] === 80 && bytes[14] === 56 && bytes[15] === 88) {
206
+ if (bytes.length < 30) return void 0;
207
+ const w = (bytes[24] ?? 0) | (bytes[25] ?? 0) << 8 | (bytes[26] ?? 0) << 16;
208
+ const h = (bytes[27] ?? 0) | (bytes[28] ?? 0) << 8 | (bytes[29] ?? 0) << 16;
209
+ return {
210
+ width: w + 1,
211
+ height: h + 1
212
+ };
213
+ }
214
+ };
215
+ function detectImageDimensions(bytes, format) {
216
+ let dims;
217
+ switch (format) {
218
+ case "png":
219
+ dims = pngDimensions(bytes);
220
+ break;
221
+ case "jpeg":
222
+ dims = jpegDimensions(bytes);
223
+ break;
224
+ case "gif":
225
+ dims = gifDimensions(bytes);
226
+ break;
227
+ case "bmp":
228
+ dims = bmpDimensions(bytes);
229
+ break;
230
+ case "webp":
231
+ dims = webpDimensions(bytes);
232
+ break;
233
+ default: dims = void 0;
234
+ }
235
+ return dims ?? {
236
+ width: 0,
237
+ height: 0
238
+ };
239
+ }
240
+ /**
241
+ * Build an `XlsxImage` from raw bytes. Detects the format and dimensions
242
+ * automatically. Caller may pass an explicit `format` to override detection
243
+ * (e.g. when bytes were read from a `data:` URL with a known MIME type) or
244
+ * `width`/`height` to skip the parser.
245
+ */
246
+ function loadImage(bytes, opts = {}) {
247
+ const format = opts.format ?? detectImageFormat(bytes);
248
+ if (!format) throw new OpenXmlIoError("loadImage: could not determine image format from bytes");
249
+ const dims = opts.width !== void 0 && opts.height !== void 0 ? {
250
+ width: opts.width,
251
+ height: opts.height
252
+ } : detectImageDimensions(bytes, format);
253
+ return {
254
+ bytes,
255
+ format,
256
+ width: dims.width,
257
+ height: dims.height
258
+ };
259
+ }
260
+ //#endregion
261
+ //#region src/drawing/anchor.ts
262
+ const A1_RE = /^([A-Za-z]{1,3})([1-9][0-9]*)$/;
263
+ /**
264
+ * Convert a cell ref ("A1", "C5") to a 0-based AnchorMarker with `colOff =
265
+ * rowOff = 0`. Throws on malformed refs.
266
+ */
267
+ function anchorMarkerFromCellRef(ref) {
268
+ const m = A1_RE.exec(ref);
269
+ if (!m || m[1] === void 0 || m[2] === void 0) throw new OpenXmlSchemaError(`anchorMarkerFromCellRef: invalid coordinate "${ref}"`);
270
+ return {
271
+ col: columnIndexFromLetter(m[1]) - 1,
272
+ colOff: 0,
273
+ row: Number.parseInt(m[2], 10) - 1,
274
+ rowOff: 0
275
+ };
276
+ }
277
+ /** Build an absolute anchor from an (x, y, cx, cy) EMU bundle. */
278
+ function makeAbsoluteAnchor(opts) {
279
+ return {
280
+ kind: "absolute",
281
+ pos: {
282
+ x: opts.x,
283
+ y: opts.y
284
+ },
285
+ ext: {
286
+ cx: opts.cx,
287
+ cy: opts.cy
288
+ }
289
+ };
290
+ }
291
+ /** Build a one-cell anchor pinned at `from` with an explicit pixel extent. */
292
+ function makeOneCellAnchor(opts) {
293
+ return {
294
+ kind: "oneCell",
295
+ from: typeof opts.from === "string" ? anchorMarkerFromCellRef(opts.from) : opts.from,
296
+ ext: {
297
+ cx: emuFromPx(opts.widthPx),
298
+ cy: emuFromPx(opts.heightPx)
299
+ }
300
+ };
301
+ }
302
+ //#endregion
303
+ //#region src/drawing/drawing.ts
304
+ function makeDrawing(items = []) {
305
+ return { items };
306
+ }
307
+ function makeChartDrawingItem(anchor, chart = {}) {
308
+ return {
309
+ anchor,
310
+ content: {
311
+ kind: "chart",
312
+ chart
313
+ }
314
+ };
315
+ }
316
+ function makePictureDrawingItem(anchor, picture) {
317
+ return {
318
+ anchor,
319
+ content: {
320
+ kind: "picture",
321
+ picture: "format" in picture ? { image: picture } : picture
322
+ }
323
+ };
324
+ }
325
+ /**
326
+ * Drop an image onto a worksheet at a single-cell anchor. Lazy-allocates
327
+ * `ws.drawing` (as `makeDrawing([])`) on first call and appends a picture
328
+ * DrawingItem.
329
+ *
330
+ * `image` accepts either an `XlsxImage` (already loaded via `loadImage`) or raw
331
+ * image bytes — in the bytes case, this helper sniffs the format with
332
+ * `loadImage` itself.
333
+ *
334
+ * `at` is a cell ref like `"C3"`. Override `widthPx` / `heightPx` to scale;
335
+ * otherwise the helper uses 96×96 defaults that look fine for typical icons.
336
+ */
337
+ const addImageAt = (ws, at, image, opts = {}) => {
338
+ const xlsxImage = image instanceof Uint8Array ? loadImage(image) : image;
339
+ const item = makePictureDrawingItem(makeOneCellAnchor({
340
+ from: at,
341
+ widthPx: opts.widthPx ?? 96,
342
+ heightPx: opts.heightPx ?? 96
343
+ }), xlsxImage);
344
+ if (!ws.drawing) ws.drawing = makeDrawing([]);
345
+ ws.drawing.items.push(item);
346
+ return item;
347
+ };
348
+ /**
349
+ * Anchor a chart to a worksheet at a single-cell ref. Lazy-allocates
350
+ * `ws.drawing`. `chart` is the same `ChartReference` shape `makeChart
351
+ * DrawingItem` accepts (`{ space }` for legacy chart, `{ cxSpace }` for
352
+ * chartex).
353
+ */
354
+ const addChartAt = (ws, at, chart, opts = {}) => {
355
+ const item = makeChartDrawingItem(makeOneCellAnchor({
356
+ from: at,
357
+ widthPx: opts.widthPx ?? 480,
358
+ heightPx: opts.heightPx ?? 320
359
+ }), chart);
360
+ if (!ws.drawing) ws.drawing = makeDrawing([]);
361
+ ws.drawing.items.push(item);
362
+ return item;
363
+ };
364
+ /**
365
+ * Read-only snapshot of every picture DrawingItem on the sheet. Returns the
366
+ * matching items (each with its anchor + picture reference). Empty array when
367
+ * the sheet has no drawing or only non-picture items.
368
+ */
369
+ const listImagesOnSheet = (ws) => {
370
+ if (!ws.drawing) return [];
371
+ return ws.drawing.items.filter((it) => it.content.kind === "picture");
372
+ };
373
+ /**
374
+ * Read-only snapshot of every chart DrawingItem on the sheet. Each item has its
375
+ * anchor + chart reference.
376
+ */
377
+ const listChartsOnSheet = (ws) => {
378
+ if (!ws.drawing) return [];
379
+ return ws.drawing.items.filter((it) => it.content.kind === "chart");
380
+ };
381
+ /**
382
+ * Drop every DrawingItem from the worksheet. Returns the count removed. The
383
+ * `ws.drawing` field itself is left in place (empty) so subsequent `addImageAt`
384
+ * / `addChartAt` calls don't have to re-allocate.
385
+ */
386
+ const removeAllDrawingItems = (ws) => {
387
+ if (!ws.drawing) return 0;
388
+ const n = ws.drawing.items.length;
389
+ ws.drawing.items = [];
390
+ return n;
391
+ };
392
+ /**
393
+ * Drop every picture DrawingItem from the worksheet, leaving charts and any
394
+ * other content kinds untouched. Returns the count removed.
395
+ */
396
+ const removeAllImages = (ws) => {
397
+ if (!ws.drawing) return 0;
398
+ const before = ws.drawing.items.length;
399
+ ws.drawing.items = ws.drawing.items.filter((it) => it.content.kind !== "picture");
400
+ return before - ws.drawing.items.length;
401
+ };
402
+ /**
403
+ * Drop every chart DrawingItem from the worksheet, leaving pictures and any
404
+ * other content kinds untouched. Returns the count removed.
405
+ */
406
+ const removeAllCharts = (ws) => {
407
+ if (!ws.drawing) return 0;
408
+ const before = ws.drawing.items.length;
409
+ ws.drawing.items = ws.drawing.items.filter((it) => it.content.kind !== "chart");
410
+ return before - ws.drawing.items.length;
411
+ };
412
+ //#endregion
413
+ export { makeChartDrawingItem as a, removeAllCharts as c, makeAbsoluteAnchor as d, makeOneCellAnchor as f, loadImage as h, listImagesOnSheet as i, removeAllDrawingItems as l, IMAGE_FORMAT_MIME as m, addImageAt as n, makeDrawing as o, IMAGE_FORMAT_EXTENSION as p, listChartsOnSheet as r, makePictureDrawingItem as s, addChartAt as t, removeAllImages as u };
414
+
415
+ //# sourceMappingURL=drawing-BxzLuryn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawing-BxzLuryn.mjs","names":[],"sources":["../src/drawing/image.ts","../src/drawing/anchor.ts","../src/drawing/drawing.ts"],"sourcesContent":["// Image embedding.\n//\n// `XlsxImage` is the workbook-level handle for any image referenced from a\n// worksheet drawing (or chart `<a:blipFill>`). Bytes are kept verbatim so\n// re-saving never re-encodes; format / width / height are detected from the\n// file header so callers don't have to specify them.\n\nimport { OpenXmlIoError } from '../utils/exceptions';\n\nexport type XlsxImageFormat = 'png' | 'jpeg' | 'gif' | 'bmp' | 'webp' | 'tiff' | 'svg' | 'emf' | 'wmf';\n\n/**\n * Map from image format to the Content-Types Default extension that Excel uses\n * in `[Content_Types].xml`. SVG / EMF / WMF use the same extension as the\n * format string; PNG/JPEG/GIF/BMP do too. WebP and TIFF use their canonical\n * short names.\n */\nexport const IMAGE_FORMAT_EXTENSION: Readonly<Record<XlsxImageFormat, string>> = {\n png: 'png',\n jpeg: 'jpeg',\n gif: 'gif',\n bmp: 'bmp',\n webp: 'webp',\n tiff: 'tiff',\n svg: 'svg',\n emf: 'emf',\n wmf: 'wmf',\n};\n\n/** Map from image format to its IANA `image/*` MIME type. */\nexport const IMAGE_FORMAT_MIME: Readonly<Record<XlsxImageFormat, string>> = {\n png: 'image/png',\n jpeg: 'image/jpeg',\n gif: 'image/gif',\n bmp: 'image/bmp',\n webp: 'image/webp',\n tiff: 'image/tiff',\n svg: 'image/svg+xml',\n emf: 'image/x-emf',\n wmf: 'image/x-wmf',\n};\n\nexport interface XlsxImage {\n bytes: Uint8Array;\n format: XlsxImageFormat;\n /** Pixel width. Zero when dimensions can't be determined for the format. */\n width: number;\n /** Pixel height. Zero when dimensions can't be determined for the format. */\n height: number;\n /** ZIP archive path, e.g. `xl/media/image3.png`. Set by the writer. */\n path?: string;\n /** rels-resolved id used by `<a:blip r:embed=\"...\">`. Set by the loader. */\n rId?: string;\n}\n\n// ---- Magic-byte format detection ------------------------------------------\n\nconst startsWith = (bytes: Uint8Array, sig: ReadonlyArray<number>, offset = 0): boolean => {\n if (bytes.length < offset + sig.length) return false;\n for (let i = 0; i < sig.length; i++) {\n if (bytes[offset + i] !== sig[i]) return false;\n }\n return true;\n};\n\nconst PNG_SIG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];\nconst JPEG_SIG = [0xff, 0xd8, 0xff];\nconst GIF87 = [0x47, 0x49, 0x46, 0x38, 0x37, 0x61];\nconst GIF89 = [0x47, 0x49, 0x46, 0x38, 0x39, 0x61];\nconst BMP_SIG = [0x42, 0x4d];\nconst RIFF_SIG = [0x52, 0x49, 0x46, 0x46];\nconst WEBP_TAG = [0x57, 0x45, 0x42, 0x50];\nconst TIFF_LE = [0x49, 0x49, 0x2a, 0x00];\nconst TIFF_BE = [0x4d, 0x4d, 0x00, 0x2a];\nconst EMF_SIG = [0x01, 0x00, 0x00, 0x00];\nconst EMF_TAG = [0x20, 0x45, 0x4d, 0x46]; // ' EMF' at offset 40\nconst WMF_SIG_PLACEABLE = [0xd7, 0xcd, 0xc6, 0x9a];\nconst WMF_SIG_BARE = [0x01, 0x00, 0x09, 0x00];\n\nconst isSvg = (bytes: Uint8Array): boolean => {\n // Inspect the first ~512 bytes for an `<svg` tag (with optional XML / DOCTYPE\n // preamble).\n const head = new TextDecoder('utf-8', { fatal: false }).decode(bytes.subarray(0, Math.min(bytes.length, 512)));\n return /<svg\\b/i.test(head);\n};\n\nexport function detectImageFormat(bytes: Uint8Array): XlsxImageFormat | undefined {\n if (startsWith(bytes, PNG_SIG)) return 'png';\n if (startsWith(bytes, JPEG_SIG)) return 'jpeg';\n if (startsWith(bytes, GIF87) || startsWith(bytes, GIF89)) return 'gif';\n if (startsWith(bytes, BMP_SIG)) return 'bmp';\n if (startsWith(bytes, RIFF_SIG) && startsWith(bytes, WEBP_TAG, 8)) return 'webp';\n if (startsWith(bytes, TIFF_LE) || startsWith(bytes, TIFF_BE)) return 'tiff';\n if (startsWith(bytes, EMF_SIG) && startsWith(bytes, EMF_TAG, 40)) return 'emf';\n if (startsWith(bytes, WMF_SIG_PLACEABLE) || startsWith(bytes, WMF_SIG_BARE)) return 'wmf';\n if (isSvg(bytes)) return 'svg';\n return undefined;\n}\n\n// ---- Per-format dimension extraction --------------------------------------\n\nconst readU32BE = (bytes: Uint8Array, offset: number): number =>\n ((bytes[offset] ?? 0) << 24) |\n ((bytes[offset + 1] ?? 0) << 16) |\n ((bytes[offset + 2] ?? 0) << 8) |\n (bytes[offset + 3] ?? 0);\n\nconst readU16LE = (bytes: Uint8Array, offset: number): number => (bytes[offset] ?? 0) | ((bytes[offset + 1] ?? 0) << 8);\n\nconst readU16BE = (bytes: Uint8Array, offset: number): number => ((bytes[offset] ?? 0) << 8) | (bytes[offset + 1] ?? 0);\n\ninterface Dimensions {\n width: number;\n height: number;\n}\n\nconst pngDimensions = (bytes: Uint8Array): Dimensions | undefined => {\n // PNG: 8-byte signature, 4-byte chunk-length, 4-byte type (\"IHDR\"), then\n // 4-byte width, 4-byte height (both big-endian).\n if (bytes.length < 24) return undefined;\n if (bytes[12] !== 0x49 || bytes[13] !== 0x48 || bytes[14] !== 0x44 || bytes[15] !== 0x52) {\n return undefined;\n }\n return { width: readU32BE(bytes, 16), height: readU32BE(bytes, 20) };\n};\n\nconst gifDimensions = (bytes: Uint8Array): Dimensions | undefined => {\n if (bytes.length < 10) return undefined;\n return { width: readU16LE(bytes, 6), height: readU16LE(bytes, 8) };\n};\n\nconst bmpDimensions = (bytes: Uint8Array): Dimensions | undefined => {\n if (bytes.length < 26) return undefined;\n // BITMAPINFOHEADER: width (LE int32) at offset 18, height at offset 22.\n // Height can be negative for top-down bitmaps; we report absolute pixels.\n const w = (bytes[18] ?? 0) | ((bytes[19] ?? 0) << 8) | ((bytes[20] ?? 0) << 16) | ((bytes[21] ?? 0) << 24);\n const hRaw = (bytes[22] ?? 0) | ((bytes[23] ?? 0) << 8) | ((bytes[24] ?? 0) << 16) | ((bytes[25] ?? 0) << 24);\n // Treat width as signed; for height take absolute value (top-down bitmaps\n // store negative).\n const wSigned = (w | 0) >>> 0 > 0x7fffffff ? (w | 0) - 0x100000000 : w;\n const hSigned = (hRaw | 0) >>> 0 > 0x7fffffff ? (hRaw | 0) - 0x100000000 : hRaw;\n return { width: wSigned, height: Math.abs(hSigned) };\n};\n\nconst jpegDimensions = (bytes: Uint8Array): Dimensions | undefined => {\n // Walk the marker stream until an SOFn (FFC0..FFCF, excluding FFC4/C8/CC).\n let i = 2; // skip SOI (FFD8)\n while (i + 9 < bytes.length) {\n if (bytes[i] !== 0xff) return undefined;\n let marker = bytes[i + 1] ?? 0;\n while (marker === 0xff) {\n // Padding bytes. Advance to the next non-FF.\n i += 1;\n marker = bytes[i + 1] ?? 0;\n }\n i += 2;\n const isSof = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;\n const len = readU16BE(bytes, i);\n if (isSof) {\n // SOF segment: 2 bytes length, 1 byte precision, 2 bytes height, 2 bytes\n // width.\n if (i + 7 > bytes.length) return undefined;\n const height = readU16BE(bytes, i + 3);\n const width = readU16BE(bytes, i + 5);\n return { width, height };\n }\n i += len;\n }\n return undefined;\n};\n\nconst webpDimensions = (bytes: Uint8Array): Dimensions | undefined => {\n // RIFF header is 12 bytes; chunk type is at offset 12.\n if (bytes.length < 30) return undefined;\n // VP8 (lossy): \"VP8 \" chunk; width / height at offset 26 / 28 (LE 14-bit each\n // + 2 unused bits).\n if (\n bytes[12] === 0x56 && // V\n bytes[13] === 0x50 && // P\n bytes[14] === 0x38 && // 8\n bytes[15] === 0x20 // space\n ) {\n const w = readU16LE(bytes, 26) & 0x3fff;\n const h = readU16LE(bytes, 28) & 0x3fff;\n return { width: w, height: h };\n }\n // VP8L (lossless): 14-bit width-1 / height-1 packed little-endian starting at\n // offset 21.\n if (\n bytes[12] === 0x56 &&\n bytes[13] === 0x50 &&\n bytes[14] === 0x38 &&\n bytes[15] === 0x4c // L\n ) {\n if (bytes.length < 25) return undefined;\n const b0 = bytes[21] ?? 0;\n const b1 = bytes[22] ?? 0;\n const b2 = bytes[23] ?? 0;\n const b3 = bytes[24] ?? 0;\n const w = (b0 | (b1 << 8)) & 0x3fff;\n const h = ((b1 >> 6) | (b2 << 2) | ((b3 & 0x0f) << 10)) & 0x3fff;\n return { width: w + 1, height: h + 1 };\n }\n // VP8X (extended): width-1 (24 bits) / height-1 (24 bits) at offset 24 / 27.\n if (\n bytes[12] === 0x56 &&\n bytes[13] === 0x50 &&\n bytes[14] === 0x38 &&\n bytes[15] === 0x58 // X\n ) {\n if (bytes.length < 30) return undefined;\n const w = (bytes[24] ?? 0) | ((bytes[25] ?? 0) << 8) | ((bytes[26] ?? 0) << 16);\n const h = (bytes[27] ?? 0) | ((bytes[28] ?? 0) << 8) | ((bytes[29] ?? 0) << 16);\n return { width: w + 1, height: h + 1 };\n }\n return undefined;\n};\n\nexport function detectImageDimensions(bytes: Uint8Array, format: XlsxImageFormat): Dimensions {\n let dims: Dimensions | undefined;\n switch (format) {\n case 'png':\n dims = pngDimensions(bytes);\n break;\n case 'jpeg':\n dims = jpegDimensions(bytes);\n break;\n case 'gif':\n dims = gifDimensions(bytes);\n break;\n case 'bmp':\n dims = bmpDimensions(bytes);\n break;\n case 'webp':\n dims = webpDimensions(bytes);\n break;\n default:\n // tiff / svg / emf / wmf — readers can fall back to 0 and Excel will\n // assign defaults.\n dims = undefined;\n }\n return dims ?? { width: 0, height: 0 };\n}\n\n// ---- Public factory --------------------------------------------------------\n\n/**\n * Build an `XlsxImage` from raw bytes. Detects the format and dimensions\n * automatically. Caller may pass an explicit `format` to override detection\n * (e.g. when bytes were read from a `data:` URL with a known MIME type) or\n * `width`/`height` to skip the parser.\n */\nexport function loadImage(\n bytes: Uint8Array,\n opts: { format?: XlsxImageFormat; width?: number; height?: number } = {},\n): XlsxImage {\n const format = opts.format ?? detectImageFormat(bytes);\n if (!format) {\n throw new OpenXmlIoError('loadImage: could not determine image format from bytes');\n }\n const dims =\n opts.width !== undefined && opts.height !== undefined\n ? { width: opts.width, height: opts.height }\n : detectImageDimensions(bytes, format);\n return { bytes, format, width: dims.width, height: dims.height };\n}\n","// DrawingML anchors.\n//\n// An anchor positions a drawing (chart / image / shape) inside a worksheet.\n// ECMA-376 §20.5.2 defines three kinds:\n//\n// absolute — fixed (x, y) and (cx, cy) in EMU; ignores cell layout. oneCell —\n// pinned at `from` cell, fixed extent. Resizes with the\n// cell only on its top-left corner.\n// twoCell — anchored to `from` and `to` cells. Resizes / moves with\n// both corners depending on `editAs`.\n//\n// Coordinates are EMU (English Metric Units). 1 inch = 914400 EMU, 1 cm =\n// 360000 EMU, 1 px = 9525 EMU at 96 dpi.\n\nimport { columnIndexFromLetter } from '../utils/coordinate';\nimport { OpenXmlSchemaError } from '../utils/exceptions';\nimport { emuFromPx } from '../utils/units';\n\n/** EMU = English Metric Units. Drawing coordinates are stored in EMU on the wire. */\nexport interface Point2D {\n /** Horizontal offset in EMU. */\n x: number;\n /** Vertical offset in EMU. */\n y: number;\n}\n\nexport interface PositiveSize2D {\n cx: number;\n cy: number;\n}\n\n/**\n * `from` / `to` corners reference a cell by 0-based column + row index plus an\n * EMU offset within the cell. Excel's wire format is 0-based here even though\n * cell references in formulas / sheetData are 1-based.\n */\nexport interface AnchorMarker {\n col: number;\n colOff: number;\n row: number;\n rowOff: number;\n}\n\nexport type DrawingAnchor =\n | { kind: 'absolute'; pos: Point2D; ext: PositiveSize2D }\n | { kind: 'oneCell'; from: AnchorMarker; ext: PositiveSize2D }\n | { kind: 'twoCell'; from: AnchorMarker; to: AnchorMarker; editAs?: 'twoCell' | 'oneCell' | 'absolute' };\n\nconst A1_RE = /^([A-Za-z]{1,3})([1-9][0-9]*)$/;\n\n/**\n * Convert a cell ref (\"A1\", \"C5\") to a 0-based AnchorMarker with `colOff =\n * rowOff = 0`. Throws on malformed refs.\n */\nexport function anchorMarkerFromCellRef(ref: string): AnchorMarker {\n const m = A1_RE.exec(ref);\n if (!m || m[1] === undefined || m[2] === undefined) {\n throw new OpenXmlSchemaError(`anchorMarkerFromCellRef: invalid coordinate \"${ref}\"`);\n }\n const col = columnIndexFromLetter(m[1]) - 1; // 0-based\n const row = Number.parseInt(m[2], 10) - 1; // 0-based\n return { col, colOff: 0, row, rowOff: 0 };\n}\n\n/** Build an absolute anchor from an (x, y, cx, cy) EMU bundle. */\nexport function makeAbsoluteAnchor(opts: { x: number; y: number; cx: number; cy: number }): DrawingAnchor {\n return { kind: 'absolute', pos: { x: opts.x, y: opts.y }, ext: { cx: opts.cx, cy: opts.cy } };\n}\n\n/** Build a one-cell anchor pinned at `from` with an explicit pixel extent. */\nexport function makeOneCellAnchor(opts: {\n from: string | AnchorMarker;\n widthPx: number;\n heightPx: number;\n}): DrawingAnchor {\n const from = typeof opts.from === 'string' ? anchorMarkerFromCellRef(opts.from) : opts.from;\n return {\n kind: 'oneCell',\n from,\n ext: { cx: emuFromPx(opts.widthPx), cy: emuFromPx(opts.heightPx) },\n };\n}\n\n/**\n * Build a two-cell anchor from cell-ref pairs (or pre-built markers). Defaults\n * to `editAs='twoCell'` — drag both corners with the cells.\n */\nexport function makeTwoCellAnchor(opts: {\n from: string | AnchorMarker;\n to: string | AnchorMarker;\n editAs?: 'twoCell' | 'oneCell' | 'absolute';\n}): DrawingAnchor {\n const from = typeof opts.from === 'string' ? anchorMarkerFromCellRef(opts.from) : opts.from;\n const to = typeof opts.to === 'string' ? anchorMarkerFromCellRef(opts.to) : opts.to;\n return {\n kind: 'twoCell',\n from,\n to,\n ...(opts.editAs !== undefined ? { editAs: opts.editAs } : {}),\n };\n}\n","// Spreadsheet drawing data model.\n//\n// A `Drawing` is the per-worksheet `xl/drawings/drawingN.xml` part — a list of\n// anchor entries, each carrying a content variant (chart, picture, shape,\n// connector, group). Stage-1 implements the chart variant as a \"rels-only\"\n// reference (the full ChartML model lands in later iterations); picture / shape\n// / connector / group are reserved for later.\n\nimport type { ChartSpace } from '../chart/chart';\nimport type { CxChartSpace } from '../chart/cx/chartex';\nimport type { DrawingAnchor } from './anchor';\nimport type { ShapeProperties } from './dml/shape-properties';\nimport type { XlsxImage } from './image';\n\n/** Reference to a chart part — the chart's drawing-rels rId resolves to xl/charts/chartN.xml. */\nexport interface ChartReference {\n /** Drawing-rels rId pointing at the chart part. Populated on read; the writer assigns its own. */\n rId?: string;\n /**\n * Legacy ECMA-376 chart payload (`c:chartSpace`). Stage-1 supports BarChart\n * end-to-end; other chart kinds populate this field as their parsers /\n * writers land.\n */\n space?: ChartSpace;\n /**\n * Excel-2016 chartex payload (`cx:chartSpace`). Mutually exclusive with\n * {@link space} for any given drawing item; the parser sniffs the root\n * element and populates whichever is appropriate.\n */\n cxSpace?: CxChartSpace;\n /**\n * `true` when the resolved chart part is a chartex (`cx:`) chart. Set by the\n * package writer so the drawing emitter knows to use the chartex\n * `<a:graphicData uri>` instead of the legacy chart URI — Excel rejects the\n * workbook when the URI doesn't match the chart's actual root namespace.\n */\n isCx?: boolean;\n}\n\n/** Reference to an embedded picture inside a worksheet drawing. */\nexport interface PictureReference {\n /** Drawing-rels rId pointing at the embedded image. Populated on read; the writer assigns its own. */\n rId?: string;\n /** Resolved image bytes + metadata. Populated on read; the writer reads it back. */\n image?: XlsxImage;\n /** Picture display name (`<xdr:cNvPr name=\"...\">`). */\n name?: string;\n /** Optional alt-text description. */\n descr?: string;\n /** Hidden flag (`<xdr:cNvPr hidden=\"1\"/>`). */\n hidden?: boolean;\n /** Per-picture shape properties (extra fill / line / rotation). */\n spPr?: ShapeProperties;\n}\n\nexport interface DrawingItem {\n anchor: DrawingAnchor;\n content:\n | { kind: 'chart'; chart: ChartReference }\n | { kind: 'picture'; picture: PictureReference }\n | { kind: 'unsupported'; rawTag: string };\n}\n\nexport interface Drawing {\n items: DrawingItem[];\n}\n\nexport function makeDrawing(items: DrawingItem[] = []): Drawing {\n return { items };\n}\n\nexport function makeChartDrawingItem(anchor: DrawingAnchor, chart: ChartReference = {}): DrawingItem {\n return { anchor, content: { kind: 'chart', chart } };\n}\n\nexport function makePictureDrawingItem(anchor: DrawingAnchor, picture: PictureReference | XlsxImage): DrawingItem {\n // Distinguish raw image bytes from a full PictureReference by checking the\n // discriminator: XlsxImage carries `format`, PictureReference doesn't.\n const ref: PictureReference = 'format' in picture ? { image: picture as XlsxImage } : (picture as PictureReference);\n return { anchor, content: { kind: 'picture', picture: ref } };\n}\n\n// ---- Worksheet ergonomic helpers ----------------------------------------\n\nimport { loadImage } from './image';\nimport { makeOneCellAnchor } from './anchor';\nimport type { Worksheet } from '../worksheet/worksheet';\n\n/**\n * Drop an image onto a worksheet at a single-cell anchor. Lazy-allocates\n * `ws.drawing` (as `makeDrawing([])`) on first call and appends a picture\n * DrawingItem.\n *\n * `image` accepts either an `XlsxImage` (already loaded via `loadImage`) or raw\n * image bytes — in the bytes case, this helper sniffs the format with\n * `loadImage` itself.\n *\n * `at` is a cell ref like `\"C3\"`. Override `widthPx` / `heightPx` to scale;\n * otherwise the helper uses 96×96 defaults that look fine for typical icons.\n */\nexport const addImageAt = (\n ws: Worksheet,\n at: string,\n image: XlsxImage | Uint8Array,\n opts: { widthPx?: number; heightPx?: number } = {},\n): DrawingItem => {\n const xlsxImage: XlsxImage = image instanceof Uint8Array ? loadImage(image) : image;\n const anchor = makeOneCellAnchor({\n from: at,\n widthPx: opts.widthPx ?? 96,\n heightPx: opts.heightPx ?? 96,\n });\n const item = makePictureDrawingItem(anchor, xlsxImage);\n if (!ws.drawing) ws.drawing = makeDrawing([]);\n ws.drawing.items.push(item);\n return item;\n};\n\n/**\n * Anchor a chart to a worksheet at a single-cell ref. Lazy-allocates\n * `ws.drawing`. `chart` is the same `ChartReference` shape `makeChart\n * DrawingItem` accepts (`{ space }` for legacy chart, `{ cxSpace }` for\n * chartex).\n */\nexport const addChartAt = (\n ws: Worksheet,\n at: string,\n chart: ChartReference,\n opts: { widthPx?: number; heightPx?: number } = {},\n): DrawingItem => {\n const anchor = makeOneCellAnchor({\n from: at,\n widthPx: opts.widthPx ?? 480,\n heightPx: opts.heightPx ?? 320,\n });\n const item = makeChartDrawingItem(anchor, chart);\n if (!ws.drawing) ws.drawing = makeDrawing([]);\n ws.drawing.items.push(item);\n return item;\n};\n\n/**\n * Read-only snapshot of every picture DrawingItem on the sheet. Returns the\n * matching items (each with its anchor + picture reference). Empty array when\n * the sheet has no drawing or only non-picture items.\n */\nexport const listImagesOnSheet = (ws: Worksheet): ReadonlyArray<DrawingItem> => {\n if (!ws.drawing) return [];\n return ws.drawing.items.filter((it) => it.content.kind === 'picture');\n};\n\n/**\n * Read-only snapshot of every chart DrawingItem on the sheet. Each item has its\n * anchor + chart reference.\n */\nexport const listChartsOnSheet = (ws: Worksheet): ReadonlyArray<DrawingItem> => {\n if (!ws.drawing) return [];\n return ws.drawing.items.filter((it) => it.content.kind === 'chart');\n};\n\n/**\n * Drop every DrawingItem from the worksheet. Returns the count removed. The\n * `ws.drawing` field itself is left in place (empty) so subsequent `addImageAt`\n * / `addChartAt` calls don't have to re-allocate.\n */\nexport const removeAllDrawingItems = (ws: Worksheet): number => {\n if (!ws.drawing) return 0;\n const n = ws.drawing.items.length;\n ws.drawing.items = [];\n return n;\n};\n\n/**\n * Drop every picture DrawingItem from the worksheet, leaving charts and any\n * other content kinds untouched. Returns the count removed.\n */\nexport const removeAllImages = (ws: Worksheet): number => {\n if (!ws.drawing) return 0;\n const before = ws.drawing.items.length;\n ws.drawing.items = ws.drawing.items.filter((it) => it.content.kind !== 'picture');\n return before - ws.drawing.items.length;\n};\n\n/**\n * Drop every chart DrawingItem from the worksheet, leaving pictures and any\n * other content kinds untouched. Returns the count removed.\n */\nexport const removeAllCharts = (ws: Worksheet): number => {\n if (!ws.drawing) return 0;\n const before = ws.drawing.items.length;\n ws.drawing.items = ws.drawing.items.filter((it) => it.content.kind !== 'chart');\n return before - ws.drawing.items.length;\n};\n"],"mappings":";;;;;;;;;;AAiBA,MAAa,yBAAoE;CAC/E,KAAK;CACL,MAAM;C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C3B,GAAG,QAAQ,QAAQ,CAAC;CACpB,OAAO;AACT;;;;;AAMA,MAAa,mBAAmB,OAA0B;CACxD,IAAI,CAAC,GAAG,SAAS,OAAO;CACxB,MAAM,SAAS,GAAG,QAAQ,MAAM;CAChC,GAAG,QAAQ,QAAQ,GAAG,QAAQ,MAAM,QAAQ,OAAO,GAAG,QAAQ,SAAS,SAAS;CAChF,OAAO,SAAS,GAAG,QAAQ,MAAM;AACnC;;;;;AAMA,MAAa,mBAAmB,OAA0B;CACxD,IAAI,CAAC,GAAG,SAAS,OAAO;CACxB,MAAM,SAAS,GAAG,QAAQ,MAAM;CAChC,GAAG,QAAQ,QAAQ,GAAG,QAAQ,MAAM,QAAQ,OAAO,GAAG,QAAQ,SAAS,OAAO;CAC9E,OAAO,SAAS,GAAG,QAAQ,MAAM;AACnC"}
@@ -0,0 +1,119 @@
1
+ import { a as makeChartDrawingItem, c as removeAllCharts, f as makeOneCellAnchor, h as loadImage, i as listImagesOnSheet, l as removeAllDrawingItems, n as addImageAt, o as makeDrawing, r as listChartsOnSheet, s as makePictureDrawingItem, t as addChartAt, u as removeAllImages } from "./drawing-BxzLuryn.mjs";
2
+ import { a as makeSchemeColor, i as makeColor, n as VALUED_COLOR_MOD_KINDS, o as makeSrgbColor, r as VALUELESS_COLOR_MOD_KINDS, t as SCHEME_COLOR_NAMES } from "./colors-ovWAwnZI.mjs";
3
+ //#region src/drawing/dml/shape-properties.ts
4
+ const makeShapeProperties = (opts = {}) => ({
5
+ ...opts.bwMode !== void 0 ? { bwMode: opts.bwMode } : {},
6
+ ...opts.xfrm ? { xfrm: opts.xfrm } : {},
7
+ ...opts.geometry ? { geometry: opts.geometry } : {},
8
+ ...opts.fill ? { fill: opts.fill } : {},
9
+ ...opts.ln ? { ln: opts.ln } : {},
10
+ ...opts.effects ? { effects: opts.effects } : {}
11
+ });
12
+ //#endregion
13
+ //#region src/drawing/dml/fill.ts
14
+ const makeNoFill = () => ({ kind: "noFill" });
15
+ const makeSolidFill = (color) => ({
16
+ kind: "solidFill",
17
+ color
18
+ });
19
+ const makeGradientFill = (opts) => ({
20
+ kind: "gradFill",
21
+ stops: opts.stops,
22
+ ...opts.flip !== void 0 ? { flip: opts.flip } : {},
23
+ ...opts.rotWithShape !== void 0 ? { rotWithShape: opts.rotWithShape } : {},
24
+ ...opts.lineDir ? { lineDir: opts.lineDir } : {}
25
+ });
26
+ const makePatternFill = (opts) => ({
27
+ kind: "pattFill",
28
+ preset: opts.preset,
29
+ ...opts.fgClr ? { fgClr: opts.fgClr } : {},
30
+ ...opts.bgClr ? { bgClr: opts.bgClr } : {}
31
+ });
32
+ /** Excel's preset pattern names (54 entries, ECMA-376 §20.1.10.50; matches openpyxl). */
33
+ const PRESET_PATTERN_NAMES = [
34
+ "pct5",
35
+ "pct10",
36
+ "pct20",
37
+ "pct25",
38
+ "pct30",
39
+ "pct40",
40
+ "pct50",
41
+ "pct60",
42
+ "pct70",
43
+ "pct75",
44
+ "pct80",
45
+ "pct90",
46
+ "horz",
47
+ "vert",
48
+ "ltHorz",
49
+ "ltVert",
50
+ "dkHorz",
51
+ "dkVert",
52
+ "narHorz",
53
+ "narVert",
54
+ "dashHorz",
55
+ "dashVert",
56
+ "cross",
57
+ "dnDiag",
58
+ "upDiag",
59
+ "ltDnDiag",
60
+ "ltUpDiag",
61
+ "dkDnDiag",
62
+ "dkUpDiag",
63
+ "wdDnDiag",
64
+ "wdUpDiag",
65
+ "dashDnDiag",
66
+ "dashUpDiag",
67
+ "diagCross",
68
+ "smCheck",
69
+ "lgCheck",
70
+ "smGrid",
71
+ "lgGrid",
72
+ "dotGrid",
73
+ "smConfetti",
74
+ "lgConfetti",
75
+ "horzBrick",
76
+ "diagBrick",
77
+ "solidDmnd",
78
+ "openDmnd",
79
+ "dotDmnd",
80
+ "plaid",
81
+ "sphere",
82
+ "weave",
83
+ "divot",
84
+ "shingle",
85
+ "wave",
86
+ "trellis",
87
+ "zigZag"
88
+ ];
89
+ //#endregion
90
+ //#region src/drawing/dml/text.ts
91
+ const makeRunProperties = (opts = {}) => ({ ...opts });
92
+ const makeRun = (text, rPr) => rPr ? {
93
+ kind: "r",
94
+ rPr,
95
+ t: text
96
+ } : {
97
+ kind: "r",
98
+ t: text
99
+ };
100
+ const makeBreak = (rPr) => rPr ? {
101
+ kind: "br",
102
+ rPr
103
+ } : { kind: "br" };
104
+ const makeParagraph = (runs, pPr, endParaRPr) => ({
105
+ runs,
106
+ ...pPr ? { pPr } : {},
107
+ ...endParaRPr ? { endParaRPr } : {}
108
+ });
109
+ const makeTextBody = (paragraphs, bodyPr = {}, lstStyle) => ({
110
+ bodyPr,
111
+ ...lstStyle ? { lstStyle } : {},
112
+ paragraphs
113
+ });
114
+ /** Convenience: build a single-paragraph body with one run. */
115
+ const makeSimpleTextBody = (text, rPr) => makeTextBody([makeParagraph([makeRun(text, rPr)])]);
116
+ //#endregion
117
+ export { PRESET_PATTERN_NAMES, SCHEME_COLOR_NAMES, VALUED_COLOR_MOD_KINDS, VALUELESS_COLOR_MOD_KINDS, addChartAt, addImageAt, listChartsOnSheet, listImagesOnSheet, loadImage, makeBreak, makeChartDrawingItem, makeColor, makeDrawing, makeGradientFill, makeNoFill, makeOneCellAnchor, makeParagraph, makePatternFill, makePictureDrawingItem, makeRun, makeRunProperties, makeSchemeColor, makeShapeProperties, makeSimpleTextBody, makeSolidFill, makeSrgbColor, makeTextBody, removeAllCharts, removeAllDrawingItems, removeAllImages };
118
+
119
+ //# sourceMappingURL=drawing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawing.mjs","names":[],"sources":["../src/drawing/dml/shape-properties.ts","../src/drawing/dml/fill.ts","../src/drawing/dml/text.ts"],"sourcesContent":["// DrawingML shape properties.\n//\n// `<a:spPr>` is the universal \"how should this be drawn\" wrapper that every\n// chart element (chartSpace, chart container, plotArea, series, dataPoint,\n// axis, …) accepts. The model intentionally splits the wrapper (this file) from\n// the leaves (colors / fill / line / geometry / effect / text) so the slot\n// grows by attribute as new primitive modules land.\n\nimport type { Point2D, PositiveSize2D } from '../anchor';\nimport type { EffectsRef } from './effect';\nimport type { Fill } from './fill';\nimport type { Geometry } from './geometry';\nimport type { LineProperties } from './line';\n\nexport type { Point2D, PositiveSize2D };\n\nexport type BlackWhiteMode =\n | 'clr'\n | 'auto'\n | 'gray'\n | 'ltGray'\n | 'invGray'\n | 'grayWhite'\n | 'blackGray'\n | 'blackWhite'\n | 'black'\n | 'white'\n | 'hidden';\n\n/** `<a:xfrm>`. Position / size / rotation transformation. */\nexport interface Transform2D {\n off?: Point2D;\n ext?: PositiveSize2D;\n /** Rotation in 60_000-ths of a degree (0..21_600_000). */\n rot?: number;\n flipH?: boolean;\n flipV?: boolean;\n chOff?: Point2D;\n chExt?: PositiveSize2D;\n}\n\n/**\n * `<a:spPr>` wrapper. 3-D / text-body slots will be added as their primitive\n * modules land — kept absent here so the type stays closed under the modules\n * currently shipped.\n */\nexport interface ShapeProperties {\n bwMode?: BlackWhiteMode;\n xfrm?: Transform2D;\n geometry?: Geometry;\n fill?: Fill;\n ln?: LineProperties;\n /** Either `<a:effectLst>` (kind: 'lst') or `<a:effectDag>` (kind: 'dag'). */\n effects?: EffectsRef;\n}\n\nexport const makeShapeProperties = (opts: Partial<ShapeProperties> = {}): ShapeProperties => ({\n ...(opts.bwMode !== undefined ? { bwMode: opts.bwMode } : {}),\n ...(opts.xfrm ? { xfrm: opts.xfrm } : {}),\n ...(opts.geometry ? { geometry: opts.geometry } : {}),\n ...(opts.fill ? { fill: opts.fill } : {}),\n ...(opts.ln ? { ln: opts.ln } : {}),\n ...(opts.effects ? { effects: opts.effects } : {}),\n});\n","// DrawingML fills.\n\nimport type { DmlColor, DmlColorWithMods } from './colors';\n\n/** Relative rectangle (0..100000-thousandths). */\nexport interface RelativeRect {\n l?: number;\n t?: number;\n r?: number;\n b?: number;\n}\n\nexport interface GradientStop {\n /** Position along the gradient (0..100000). */\n pos: number;\n color: DmlColorWithMods;\n}\n\nexport type GradientLineDir =\n | { kind: 'lin'; ang: number; scaled?: boolean }\n | { kind: 'path'; pathType: 'shape' | 'circle' | 'rect'; tileRect?: RelativeRect };\n\nexport type TileFlip = 'x' | 'y' | 'xy' | 'none';\n\nexport interface TileFill {\n tx?: number;\n ty?: number;\n sx?: number;\n sy?: number;\n flip?: TileFlip;\n algn?: 'tl' | 't' | 'tr' | 'l' | 'ctr' | 'r' | 'bl' | 'b' | 'br';\n}\n\n/** Blip-source effects. The full ECMA-376 list is preserved here; `kind` discriminates. */\nexport type BlipEffect =\n | { kind: 'biLevel'; thresh: number }\n | { kind: 'blur'; rad: number; grow?: boolean }\n | { kind: 'clrChange'; useA?: boolean; clrFrom: DmlColor; clrTo: DmlColor }\n | { kind: 'clrRepl'; color: DmlColor }\n | { kind: 'duotone'; colors: [DmlColor, DmlColor] }\n | { kind: 'grayscl' }\n | { kind: 'lum'; bright?: number; contrast?: number }\n | { kind: 'tint'; hue?: number; amt?: number }\n | { kind: 'alphaModFix'; amt: number };\n\nexport interface Blip {\n embedRId?: string;\n linkRId?: string;\n cstate?: 'email' | 'screen' | 'print' | 'hqprint';\n effects?: BlipEffect[];\n}\n\n/** Discriminated union for any fill that can attach to a shape. */\nexport type Fill =\n | { kind: 'noFill' }\n | { kind: 'solidFill'; color: DmlColorWithMods }\n | {\n kind: 'gradFill';\n flip?: TileFlip;\n rotWithShape?: boolean;\n stops: GradientStop[];\n lineDir?: GradientLineDir;\n }\n | {\n kind: 'blipFill';\n blip: Blip;\n tile?: TileFill;\n stretch?: { fillRect?: RelativeRect };\n srcRect?: RelativeRect;\n dpi?: number;\n rotWithShape?: boolean;\n }\n | {\n kind: 'pattFill';\n preset: string;\n fgClr?: DmlColorWithMods;\n bgClr?: DmlColorWithMods;\n }\n | { kind: 'grpFill' };\n\nexport const makeNoFill = (): Fill => ({ kind: 'noFill' });\nexport const makeSolidFill = (color: DmlColorWithMods): Fill => ({ kind: 'solidFill', color });\n\nexport const makeGradientFill = (opts: {\n stops: GradientStop[];\n flip?: TileFlip;\n rotWithShape?: boolean;\n lineDir?: GradientLineDir;\n}): Fill => ({\n kind: 'gradFill',\n stops: opts.stops,\n ...(opts.flip !== undefined ? { flip: opts.flip } : {}),\n ...(opts.rotWithShape !== undefined ? { rotWithShape: opts.rotWithShape } : {}),\n ...(opts.lineDir ? { lineDir: opts.lineDir } : {}),\n});\n\nexport const makePatternFill = (opts: {\n preset: string;\n fgClr?: DmlColorWithMods;\n bgClr?: DmlColorWithMods;\n}): Fill => ({\n kind: 'pattFill',\n preset: opts.preset,\n ...(opts.fgClr ? { fgClr: opts.fgClr } : {}),\n ...(opts.bgClr ? { bgClr: opts.bgClr } : {}),\n});\n\n/** Excel's preset pattern names (54 entries, ECMA-376 §20.1.10.50; matches openpyxl). */\nexport const PRESET_PATTERN_NAMES: ReadonlyArray<string> = [\n 'pct5',\n 'pct10',\n 'pct20',\n 'pct25',\n 'pct30',\n 'pct40',\n 'pct50',\n 'pct60',\n 'pct70',\n 'pct75',\n 'pct80',\n 'pct90',\n 'horz',\n 'vert',\n 'ltHorz',\n 'ltVert',\n 'dkHorz',\n 'dkVert',\n 'narHorz',\n 'narVert',\n 'dashHorz',\n 'dashVert',\n 'cross',\n 'dnDiag',\n 'upDiag',\n 'ltDnDiag',\n 'ltUpDiag',\n 'dkDnDiag',\n 'dkUpDiag',\n 'wdDnDiag',\n 'wdUpDiag',\n 'dashDnDiag',\n 'dashUpDiag',\n 'diagCross',\n 'smCheck',\n 'lgCheck',\n 'smGrid',\n 'lgGrid',\n 'dotGrid',\n 'smConfetti',\n 'lgConfetti',\n 'horzBrick',\n 'diagBrick',\n 'solidDmnd',\n 'openDmnd',\n 'dotDmnd',\n 'plaid',\n 'sphere',\n 'weave',\n 'divot',\n 'shingle',\n 'wave',\n 'trellis',\n 'zigZag',\n];\n","// DrawingML text.\n//\n// Text body (`<a:txBody>`) is the universal \"rich text\" container chart\n// elements use for titles, axis labels, legend entries, etc. The model covers\n// ECMA-376 §21.1.2 (Text Body), §21.1.2.2 (Text Body Properties), §21.1.2.3\n// (List Style), §21.1.2.4 (Text Paragraph), §21.1.2.5 (Run / Break / Field),\n// and the Run / Paragraph property element groups.\n\nimport type { DmlColorWithMods } from './colors';\nimport type { EffectsRef } from './effect';\nimport type { Fill } from './fill';\nimport type { LineProperties } from './line';\n\n// ---- Common building blocks ------------------------------------------------\n\nexport type FontAlign = 'auto' | 't' | 'ctr' | 'base' | 'b';\nexport type ParagraphAlign = 'l' | 'ctr' | 'r' | 'just' | 'justLow' | 'dist' | 'thaiDist';\nexport type TextUnderline =\n | 'none'\n | 'words'\n | 'sng'\n | 'dbl'\n | 'heavy'\n | 'dotted'\n | 'dottedHeavy'\n | 'dash'\n | 'dashHeavy'\n | 'dashLong'\n | 'dashLongHeavy'\n | 'dotDash'\n | 'dotDashHeavy'\n | 'dotDotDash'\n | 'dotDotDashHeavy'\n | 'wavy'\n | 'wavyHeavy'\n | 'wavyDbl';\nexport type TextStrike = 'noStrike' | 'sngStrike' | 'dblStrike';\nexport type TextCap = 'none' | 'small' | 'all';\n\nexport type TextOverflow = 'overflow' | 'ellipsis' | 'clip';\nexport type TextHorzOverflow = 'overflow' | 'clip';\nexport type TextVertical = 'horz' | 'vert' | 'vert270' | 'wordArtVert' | 'eaVert' | 'mongolianVert' | 'wordArtVertRtl';\nexport type TextWrap = 'none' | 'square';\nexport type TextAnchor = 't' | 'ctr' | 'b' | 'just' | 'dist';\n\n/** `<a:lnSpc>` / `<a:spcBef>` / `<a:spcAft>` — either percent (×1000) or points (×100). */\nexport type TextSpacing = { kind: 'pct'; val: number } | { kind: 'pts'; val: number };\n\n/** `<a:tab>`. */\nexport interface TabStop {\n pos: number;\n algn?: 'l' | 'ctr' | 'r' | 'dec';\n}\n\n/** `<a:latin>` / `<a:ea>` / `<a:cs>` / `<a:sym>`. */\nexport interface TextFont {\n typeface: string;\n panose?: string;\n pitchFamily?: number;\n charset?: number;\n}\n\n/** `<a:hlinkClick>` / `<a:hlinkMouseOver>`. */\nexport interface HyperlinkInfo {\n rId?: string;\n invalidUrl?: string;\n action?: string;\n tgtFrame?: string;\n tooltip?: string;\n history?: boolean;\n highlightClick?: boolean;\n endSnd?: boolean;\n}\n\n/** `<a:rPr>` / `<a:endParaRPr>` / `<a:defRPr>`. */\nexport interface RunProperties {\n kumimoji?: boolean;\n lang?: string;\n altLang?: string;\n /** Font size in 1/100ths of a point. */\n sz?: number;\n b?: boolean;\n i?: boolean;\n u?: TextUnderline;\n strike?: TextStrike;\n kern?: number;\n cap?: TextCap;\n spc?: number;\n normalizeH?: boolean;\n /** Baseline shift × 1000 (super/subscript). */\n baseline?: number;\n noProof?: boolean;\n dirty?: boolean;\n err?: boolean;\n smtClean?: boolean;\n smtId?: number;\n bmk?: string;\n /** Right-to-left flag. */\n rtl?: boolean;\n ln?: LineProperties;\n fill?: Fill;\n effects?: EffectsRef;\n highlight?: DmlColorWithMods;\n /** Underline-line: either `'follow'` (`<a:uLnTx/>`) or an explicit LineProperties (`<a:uLn>`). */\n uLn?: 'follow' | LineProperties;\n /** Underline-fill: either `'follow'` (`<a:uFillTx/>`) or an explicit Fill (`<a:uFill>`). */\n uFill?: 'follow' | Fill;\n latin?: TextFont;\n ea?: TextFont;\n cs?: TextFont;\n sym?: TextFont;\n hlinkClick?: HyperlinkInfo;\n hlinkMouseOver?: HyperlinkInfo;\n}\n\n/** `<a:buChar>` / `<a:buAutoNum>` / `<a:buBlip>` / `<a:buNone>`. */\nexport type BulletProperties =\n | { kind: 'none' }\n | { kind: 'char'; char: string }\n | {\n kind: 'autoNum';\n type: string;\n startAt?: number;\n }\n | { kind: 'blip'; embedRId?: string; linkRId?: string };\n\n/** `<a:pPr>`. */\nexport interface ParagraphProperties {\n marL?: number;\n marR?: number;\n /** Indent level (0..8). */\n lvl?: number;\n indent?: number;\n algn?: ParagraphAlign;\n defTabSz?: number;\n rtl?: boolean;\n eaLnBrk?: boolean;\n fontAlgn?: FontAlign;\n latinLnBrk?: boolean;\n hangingPunct?: boolean;\n lnSpc?: TextSpacing;\n spcBef?: TextSpacing;\n spcAft?: TextSpacing;\n tabLst?: TabStop[];\n defRPr?: RunProperties;\n bullet?: BulletProperties;\n /** Bullet font (`<a:buFont>` / `<a:buFontTx/>`). */\n buFont?: 'follow' | TextFont;\n /** Bullet color (`<a:buClr>` / `<a:buClrTx/>`). */\n buClr?: 'follow' | DmlColorWithMods;\n /** Bullet size: percent of run size, points, or \"follow run\". */\n buSz?: 'follow' | { kind: 'pct'; val: number } | { kind: 'pts'; val: number };\n}\n\n/** `<a:r>` (regular run), `<a:br>` (line break), `<a:fld>` (field). */\nexport type TextRun =\n | { kind: 'r'; rPr?: RunProperties; t: string }\n | { kind: 'br'; rPr?: RunProperties }\n | { kind: 'fld'; id: string; type?: string; rPr?: RunProperties; pPr?: ParagraphProperties; t?: string };\n\n/** `<a:p>`. */\nexport interface TextParagraph {\n pPr?: ParagraphProperties;\n runs: TextRun[];\n endParaRPr?: RunProperties;\n}\n\n/** `<a:bodyPr>` autofit choice. */\nexport type AutoFit =\n | { kind: 'noAutofit' }\n | { kind: 'normAutofit'; fontScale?: number; lnSpcReduction?: number }\n | { kind: 'spAutoFit' };\n\n/** `<a:bodyPr>`. */\nexport interface TextBodyProperties {\n rot?: number;\n spcFirstLastPara?: boolean;\n vertOverflow?: TextOverflow;\n horzOverflow?: TextHorzOverflow;\n vert?: TextVertical;\n wrap?: TextWrap;\n lIns?: number;\n tIns?: number;\n rIns?: number;\n bIns?: number;\n numCol?: number;\n spcCol?: number;\n rtlCol?: boolean;\n fromWordArt?: boolean;\n anchor?: TextAnchor;\n anchorCtr?: boolean;\n forceAA?: boolean;\n upright?: boolean;\n compatLnSpc?: boolean;\n autoFit?: AutoFit;\n flatTxZ?: number;\n}\n\n/**\n * `<a:lstStyle>` (list / level styles). ECMA-376 §21.1.2.4.12. One\n * ParagraphProperties per indent level (0..8). `defPPr` is the default applied\n * when no level-specific override exists.\n */\nexport interface TextListStyle {\n defPPr?: ParagraphProperties;\n lvl1pPr?: ParagraphProperties;\n lvl2pPr?: ParagraphProperties;\n lvl3pPr?: ParagraphProperties;\n lvl4pPr?: ParagraphProperties;\n lvl5pPr?: ParagraphProperties;\n lvl6pPr?: ParagraphProperties;\n lvl7pPr?: ParagraphProperties;\n lvl8pPr?: ParagraphProperties;\n lvl9pPr?: ParagraphProperties;\n}\n\nexport interface TextBody {\n bodyPr: TextBodyProperties;\n lstStyle?: TextListStyle;\n paragraphs: TextParagraph[];\n}\n\n// ---- Factories -------------------------------------------------------------\n\nexport const makeRunProperties = (opts: Partial<RunProperties> = {}): RunProperties => ({ ...opts });\n\nexport const makeRun = (text: string, rPr?: RunProperties): TextRun =>\n rPr ? { kind: 'r', rPr, t: text } : { kind: 'r', t: text };\n\nexport const makeBreak = (rPr?: RunProperties): TextRun => (rPr ? { kind: 'br', rPr } : { kind: 'br' });\n\nexport const makeParagraph = (\n runs: TextRun[],\n pPr?: ParagraphProperties,\n endParaRPr?: RunProperties,\n): TextParagraph => ({\n runs,\n ...(pPr ? { pPr } : {}),\n ...(endParaRPr ? { endParaRPr } : {}),\n});\n\nexport const makeTextBody = (\n paragraphs: TextParagraph[],\n bodyPr: TextBodyProperties = {},\n lstStyle?: TextListStyle,\n): TextBody => ({\n bodyPr,\n ...(lstStyle ? { lstStyle } : {}),\n paragraphs,\n});\n\n/** Convenience: build a single-paragraph body with one run. */\nexport const makeSimpleTextBody = (text: string, rPr?: RunProperties): TextBody =>\n makeTextBody([makeParagraph([makeRun(text, rPr)])]);\n"],"mappings":";;;AAwDA,MAAa,uBAAuB,OAAiC,CAAC,OAAwB;CAC5F,GAAI,KAAK,WAAW,KAAA,IAAY,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC;CAC3D,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;CACvC,GAAI,KAAK,WAAW,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;CACnD,GAAI,KAAK,OAAO,EAAE,MAAM,KAAK,KAAK,IA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