@office-open/core 0.10.15 → 0.12.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 (93) hide show
  1. package/README.md +2 -1
  2. package/dist/chart/index.d.mts +2 -2
  3. package/dist/chart/index.mjs +2 -2
  4. package/dist/chart-DED4tXC9.mjs +2325 -0
  5. package/dist/chart-DED4tXC9.mjs.map +1 -0
  6. package/dist/color-mapping-CFF0vRSe.mjs +117 -0
  7. package/dist/color-mapping-CFF0vRSe.mjs.map +1 -0
  8. package/dist/data-type-CZMKVaaT.d.mts.map +1 -1
  9. package/dist/descriptor/index.d.mts +2 -2
  10. package/dist/descriptor/index.mjs +1 -1
  11. package/dist/{descriptor-BjNkn5jo.mjs → descriptor-BqaNZrrZ.mjs} +43 -11
  12. package/dist/{descriptor-BjNkn5jo.mjs.map → descriptor-BqaNZrrZ.mjs.map} +1 -1
  13. package/dist/drawing/index.d.mts +2 -0
  14. package/dist/drawing/index.mjs +2 -0
  15. package/dist/{drawingml-sj1J3lb0.mjs → drawing-BCAyrCCw.mjs} +4456 -3452
  16. package/dist/drawing-BCAyrCCw.mjs.map +1 -0
  17. package/dist/{converters-C_Y2QX1w.mjs → ext-uri-BHBcIrW7.mjs} +742 -45
  18. package/dist/ext-uri-BHBcIrW7.mjs.map +1 -0
  19. package/dist/index-BAxlDUQ1.d.mts +590 -0
  20. package/dist/index-BAxlDUQ1.d.mts.map +1 -0
  21. package/dist/index-BP541uS-.d.mts +489 -0
  22. package/dist/index-BP541uS-.d.mts.map +1 -0
  23. package/dist/{index-BVK2dv6C.d.mts → index-BQLIofaF.d.mts} +10 -4
  24. package/dist/index-BQLIofaF.d.mts.map +1 -0
  25. package/dist/{index-k8WKLXnA.d.mts → index-CaNwM5_e.d.mts} +19 -20
  26. package/dist/index-CaNwM5_e.d.mts.map +1 -0
  27. package/dist/index-DPkf_CtG.d.mts +1578 -0
  28. package/dist/index-DPkf_CtG.d.mts.map +1 -0
  29. package/dist/index-DcukVskh.d.mts +31 -0
  30. package/dist/index-DcukVskh.d.mts.map +1 -0
  31. package/dist/index-Di6XPdGl.d.mts +322 -0
  32. package/dist/index-Di6XPdGl.d.mts.map +1 -0
  33. package/dist/index-L6AXewfV.d.mts +872 -0
  34. package/dist/index-L6AXewfV.d.mts.map +1 -0
  35. package/dist/index.d.mts +294 -30
  36. package/dist/index.d.mts.map +1 -1
  37. package/dist/index.mjs +1327 -112
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/{output-D_G_JR_8.d.mts → output-yyxdkG0C.d.mts} +2 -3
  40. package/dist/output-yyxdkG0C.d.mts.map +1 -0
  41. package/dist/patch/index.d.mts +2 -2
  42. package/dist/patch/index.mjs +2 -2
  43. package/dist/{patch-BmRfghOo.mjs → patch-AkQY17CD.mjs} +73 -28
  44. package/dist/patch-AkQY17CD.mjs.map +1 -0
  45. package/dist/smartart/index.d.mts +2 -2
  46. package/dist/smartart/index.mjs +2 -2
  47. package/dist/smartart-n1kYJ6Jg.mjs +1650 -0
  48. package/dist/smartart-n1kYJ6Jg.mjs.map +1 -0
  49. package/dist/style-matrix-B6jhPAT3.mjs +123 -0
  50. package/dist/style-matrix-B6jhPAT3.mjs.map +1 -0
  51. package/dist/theme/index.d.mts +4 -2
  52. package/dist/theme/index.mjs +4 -2
  53. package/dist/theme-BKnXRmvn.mjs +426 -0
  54. package/dist/theme-BKnXRmvn.mjs.map +1 -0
  55. package/dist/theme-options-kO89NUEX.d.mts +109 -0
  56. package/dist/theme-options-kO89NUEX.d.mts.map +1 -0
  57. package/dist/util/index.d.mts +3 -3
  58. package/dist/util/index.mjs +3 -3
  59. package/dist/{util-Tq9PSjK0.mjs → util-ptE16MEk.mjs} +237 -459
  60. package/dist/util-ptE16MEk.mjs.map +1 -0
  61. package/dist/{values-8di32lIe.d.mts → values-BECDm4zr.d.mts} +17 -31
  62. package/dist/values-BECDm4zr.d.mts.map +1 -0
  63. package/dist/vector/index.d.mts +2 -0
  64. package/dist/vector/index.mjs +2 -0
  65. package/dist/vector-DhLGZjP5.mjs +3049 -0
  66. package/dist/vector-DhLGZjP5.mjs.map +1 -0
  67. package/package.json +16 -8
  68. package/dist/chart-DIGJna_6.mjs +0 -582
  69. package/dist/chart-DIGJna_6.mjs.map +0 -1
  70. package/dist/converters-C_Y2QX1w.mjs.map +0 -1
  71. package/dist/drawingml/index.d.mts +0 -2
  72. package/dist/drawingml/index.mjs +0 -2
  73. package/dist/drawingml-sj1J3lb0.mjs.map +0 -1
  74. package/dist/index-BVK2dv6C.d.mts.map +0 -1
  75. package/dist/index-BfHfKuKy.d.mts +0 -275
  76. package/dist/index-BfHfKuKy.d.mts.map +0 -1
  77. package/dist/index-CE53SwpZ.d.mts +0 -1463
  78. package/dist/index-CE53SwpZ.d.mts.map +0 -1
  79. package/dist/index-D6VE-MnJ.d.mts +0 -43
  80. package/dist/index-D6VE-MnJ.d.mts.map +0 -1
  81. package/dist/index-DE4CLElr.d.mts +0 -145
  82. package/dist/index-DE4CLElr.d.mts.map +0 -1
  83. package/dist/index-DlPA26cw.d.mts +0 -91
  84. package/dist/index-DlPA26cw.d.mts.map +0 -1
  85. package/dist/index-k8WKLXnA.d.mts.map +0 -1
  86. package/dist/output-D_G_JR_8.d.mts.map +0 -1
  87. package/dist/patch-BmRfghOo.mjs.map +0 -1
  88. package/dist/smartart-B7ukZ-Tw.mjs +0 -305
  89. package/dist/smartart-B7ukZ-Tw.mjs.map +0 -1
  90. package/dist/theme-CiNzdl-9.mjs +0 -177
  91. package/dist/theme-CiNzdl-9.mjs.map +0 -1
  92. package/dist/util-Tq9PSjK0.mjs.map +0 -1
  93. package/dist/values-8di32lIe.d.mts.map +0 -1
@@ -0,0 +1,1650 @@
1
+ import { $ as xsdDiagramDirection, L as xsdAnimLevel, rt as xsdHierBranch, xt as xsdResizeHandles } from "./ext-uri-BHBcIrW7.mjs";
2
+ import { En as shape3DDesc, Ln as parseColorList, On as createColorList, Tn as scene3DDesc } from "./drawing-BCAyrCCw.mjs";
3
+ import { i as stringifyShapeStyle, n as parseShapeStyle } from "./style-matrix-B6jhPAT3.mjs";
4
+ import { OOXML_XML_DECLARATION, attr, attrBool, attrNum, attrs, escapeXml, findChild, stringify } from "@office-open/xml";
5
+ //#region src/smartart/categories.ts
6
+ /** Layout ID → OOXML category type */
7
+ const LAYOUT_CATEGORIES = {
8
+ default: "list",
9
+ list1: "list",
10
+ list2: "list",
11
+ vList2: "list",
12
+ hList1: "list",
13
+ pList1: "list",
14
+ process1: "process",
15
+ process2: "process",
16
+ process3: "process",
17
+ process4: "process",
18
+ chevron1: "process",
19
+ chevron2: "process",
20
+ arrow1: "process",
21
+ arrow2: "process",
22
+ cycle1: "cycle",
23
+ cycle2: "cycle",
24
+ cycle3: "cycle",
25
+ cycle4: "cycle",
26
+ cycle5: "cycle",
27
+ hierarchy1: "hier",
28
+ hierarchy2: "hier",
29
+ hierarchy3: "hier",
30
+ hierarchy4: "hier",
31
+ orgChart1: "hier",
32
+ pyramid1: "pyramid",
33
+ pyramid2: "pyramid",
34
+ pyramid3: "pyramid",
35
+ matrix1: "matrix",
36
+ matrix2: "matrix",
37
+ matrix3: "matrix",
38
+ radial1: "rel",
39
+ radial2: "rel",
40
+ radial3: "rel",
41
+ venn1: "rel",
42
+ funnel1: "rel",
43
+ balance1: "rel",
44
+ gear1: "rel",
45
+ constOrg1: "rel",
46
+ oppId1: "rel"
47
+ };
48
+ /** Style ID → OOXML category type */
49
+ const STYLE_CATEGORIES = {
50
+ simple1: "simple",
51
+ simple2: "simple",
52
+ simple3: "simple",
53
+ simple4: "simple",
54
+ simple5: "simple",
55
+ moderate1: "moderate",
56
+ moderate2: "moderate",
57
+ moderate3: "moderate",
58
+ moderate4: "moderate",
59
+ polished1: "polished",
60
+ polished2: "polished",
61
+ polished3: "polished",
62
+ polished4: "polished",
63
+ professional1: "professional",
64
+ professional2: "professional",
65
+ professional3: "professional",
66
+ professional4: "professional",
67
+ cartoon1: "cartoon",
68
+ cartoon2: "cartoon",
69
+ cartoon3: "cartoon",
70
+ cartoon4: "cartoon",
71
+ powdery1: "powdery",
72
+ powdery2: "powdery",
73
+ powdery3: "powdery",
74
+ powdery4: "powdery",
75
+ burnt1: "burnt",
76
+ burnt2: "burnt",
77
+ burnt3: "burnt",
78
+ burnt4: "burnt"
79
+ };
80
+ /** Color ID → OOXML category type */
81
+ const COLOR_CATEGORIES = {
82
+ accent1_2: "accent1",
83
+ accent2_2: "accent2",
84
+ accent3_2: "accent3",
85
+ accent4_2: "accent4",
86
+ accent5_2: "accent5",
87
+ accent6_2: "accent6",
88
+ colorful1: "colorful",
89
+ colorful2: "colorful",
90
+ colorful3: "colorful",
91
+ colorful4: "colorful",
92
+ dark1: "dark",
93
+ dark2: "dark",
94
+ primary1: "primary",
95
+ primary2: "primary",
96
+ gray1: "gray",
97
+ gray2: "gray"
98
+ };
99
+ //#endregion
100
+ //#region src/smartart/data-model/connection.ts
101
+ /**
102
+ * dgm:cxn — SmartArt data model connection (edge) XML stringifier.
103
+ */
104
+ function stringifyConnection(opts) {
105
+ const attrs = [
106
+ `modelId="${escapeXml(String(opts.modelId))}"`,
107
+ `srcId="${escapeXml(String(opts.srcId))}"`,
108
+ `destId="${escapeXml(String(opts.destId))}"`,
109
+ `srcOrd="${opts.srcOrd ?? 0}"`,
110
+ `destOrd="${opts.destOrd ?? 0}"`
111
+ ];
112
+ if (opts.type) attrs.push(`type="${escapeXml(opts.type)}"`);
113
+ if (opts.parTransId) attrs.push(`parTransId="${escapeXml(opts.parTransId)}"`);
114
+ if (opts.sibTransId) attrs.push(`sibTransId="${escapeXml(opts.sibTransId)}"`);
115
+ if (opts.presId) attrs.push(`presId="${escapeXml(opts.presId)}"`);
116
+ return `<dgm:cxn ${attrs.join(" ")}/>`;
117
+ }
118
+ //#endregion
119
+ //#region src/smartart/data-model/point.ts
120
+ /**
121
+ * dgm:pt — SmartArt data model point (node) XML stringifier.
122
+ */
123
+ function stringifyPoint(modelId, text, type = "node", propertySet, connectionId) {
124
+ const cxnAttr = connectionId ? ` cxnId="${escapeXml(connectionId)}"` : "";
125
+ const parts = [];
126
+ parts.push(`<dgm:pt modelId="${escapeXml(String(modelId))}"${cxnAttr} type="${escapeXml(type)}">`);
127
+ if (propertySet) parts.push(stringifyPropertySet(propertySet));
128
+ parts.push(stringifyPointText(text));
129
+ parts.push("</dgm:pt>");
130
+ return parts.join("");
131
+ }
132
+ /**
133
+ * dgm:pt — transition point (parTrans or sibTrans) XML stringifier.
134
+ */
135
+ function stringifyTransPoint(modelId, type, cxnId) {
136
+ return `<dgm:pt modelId="${escapeXml(modelId)}" type="${escapeXml(type)}" cxnId="${escapeXml(cxnId)}"><dgm:spPr/></dgm:pt>`;
137
+ }
138
+ function stringifyPropertySet(opts) {
139
+ const attr = [];
140
+ if (opts.presentationAssociationId !== void 0) attr.push(`presAssocID="${escapeXml(opts.presentationAssociationId)}"`);
141
+ if (opts.presentationName !== void 0) attr.push(`presName="${escapeXml(opts.presentationName)}"`);
142
+ if (opts.presentationStyleLabel !== void 0) attr.push(`presStyleLbl="${escapeXml(opts.presentationStyleLabel)}"`);
143
+ if (opts.presentationStyleIndex !== void 0) attr.push(`presStyleIdx="${opts.presentationStyleIndex}"`);
144
+ if (opts.presentationStyleCount !== void 0) attr.push(`presStyleCnt="${opts.presentationStyleCount}"`);
145
+ if (opts.placeholderText !== void 0) attr.push(`phldrT="${escapeXml(opts.placeholderText)}"`);
146
+ if (opts.placeholder !== void 0) attr.push(`phldr="${opts.placeholder ? 1 : 0}"`);
147
+ if (opts.customAngle !== void 0) attr.push(`custAng="${opts.customAngle}"`);
148
+ if (opts.customFlipVertical !== void 0) attr.push(`custFlipVert="${opts.customFlipVertical ? 1 : 0}"`);
149
+ if (opts.customFlipHorizontal !== void 0) attr.push(`custFlipHor="${opts.customFlipHorizontal ? 1 : 0}"`);
150
+ if (opts.customSizeX !== void 0) attr.push(`custSzX="${opts.customSizeX}"`);
151
+ if (opts.customSizeY !== void 0) attr.push(`custSzY="${opts.customSizeY}"`);
152
+ if (opts.customScaleX !== void 0) attr.push(`custScaleX="${opts.customScaleX}"`);
153
+ if (opts.customScaleY !== void 0) attr.push(`custScaleY="${opts.customScaleY}"`);
154
+ if (opts.customText !== void 0) attr.push(`custT="${opts.customText ? 1 : 0}"`);
155
+ if (opts.customLinearFactorX !== void 0) attr.push(`custLinFactX="${opts.customLinearFactorX}"`);
156
+ if (opts.customLinearFactorY !== void 0) attr.push(`custLinFactY="${opts.customLinearFactorY}"`);
157
+ if (opts.customLinearFactorNeighborX !== void 0) attr.push(`custLinFactNeighborX="${opts.customLinearFactorNeighborX}"`);
158
+ if (opts.customLinearFactorNeighborY !== void 0) attr.push(`custLinFactNeighborY="${opts.customLinearFactorNeighborY}"`);
159
+ if (opts.customRadialScaleRadius !== void 0) attr.push(`custRadScaleRad="${opts.customRadialScaleRadius}"`);
160
+ if (opts.customRadialScaleIncrement !== void 0) attr.push(`custRadScaleInc="${opts.customRadialScaleIncrement}"`);
161
+ if (opts.coherent3DOffset !== void 0) attr.push(`coherent3DOff="${opts.coherent3DOffset ? 1 : 0}"`);
162
+ if (opts.hideGeometry !== void 0) attr.push(`hideGeom="${opts.hideGeometry ? 1 : 0}"`);
163
+ if (opts.hideLastTransition !== void 0) attr.push(`hideLastTrans="${opts.hideLastTransition ? 1 : 0}"`);
164
+ if (opts.lockTextEntry !== void 0) attr.push(`lkTxEntry="${opts.lockTextEntry ? 1 : 0}"`);
165
+ if (opts.moveWith !== void 0) attr.push(`moveWith="${escapeXml(opts.moveWith)}"`);
166
+ if (opts.useDefault !== void 0) attr.push(`useDef="${opts.useDefault ? 1 : 0}"`);
167
+ if (opts.zOrderOffset !== void 0) attr.push(`zOrderOff="${opts.zOrderOffset}"`);
168
+ if (opts.layoutTypeId !== void 0) attr.push(`loTypeId="${escapeXml(opts.layoutTypeId)}"`);
169
+ if (opts.layoutCategoryId !== void 0) attr.push(`loCatId="${escapeXml(opts.layoutCategoryId)}"`);
170
+ if (opts.quickStyleTypeId !== void 0) attr.push(`qsTypeId="${escapeXml(opts.quickStyleTypeId)}"`);
171
+ if (opts.quickStyleCategoryId !== void 0) attr.push(`qsCatId="${escapeXml(opts.quickStyleCategoryId)}"`);
172
+ if (opts.colorStyleTypeId !== void 0) attr.push(`csTypeId="${escapeXml(opts.colorStyleTypeId)}"`);
173
+ if (opts.colorStyleCategoryId !== void 0) attr.push(`csCatId="${escapeXml(opts.colorStyleCategoryId)}"`);
174
+ if (attr.length === 0) return "";
175
+ return `<dgm:prSet ${attr.join(" ")}/>`;
176
+ }
177
+ function stringifyPointText(text) {
178
+ return `<dgm:t><a:bodyPr/><a:lstStyle/><a:p>${text ? `<a:r><a:t>${escapeXml(text)}</a:t></a:r>` : ""}</a:p></dgm:t>`;
179
+ }
180
+ //#endregion
181
+ //#region src/smartart/data-model/data-model.ts
182
+ /**
183
+ * CT_DataModel XML stringifier — assembles complete SmartArt data model XML.
184
+ *
185
+ * @module
186
+ */
187
+ /**
188
+ * Build the complete dgm:dataModel XML from pre-serialized point and connection strings.
189
+ */
190
+ function stringifyDataModel(points, connections) {
191
+ return [
192
+ "<dgm:dataModel xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\">",
193
+ `<dgm:ptLst>${points.join("")}</dgm:ptLst>`,
194
+ `<dgm:cxnLst>${connections.join("")}</dgm:cxnLst>`,
195
+ "<dgm:bg/>",
196
+ "<dgm:whole/>",
197
+ "</dgm:dataModel>"
198
+ ].join("");
199
+ }
200
+ /**
201
+ * Serialize a structured data model (dgm:dataModel). Inside a layoutDef the
202
+ * part-level namespaces are already declared, so this emits the bare element.
203
+ */
204
+ function stringifyDataModelOptions(model) {
205
+ const points = (model.points ?? []).map((p) => stringifyPoint(p.modelId, p.text ?? "", p.type ?? "node", p.propertySet, p.connectionId));
206
+ const connections = (model.connections ?? []).map((c) => stringifyConnection({
207
+ modelId: c.modelId,
208
+ srcId: c.sourceId,
209
+ destId: c.destinationId,
210
+ type: c.type,
211
+ srcOrd: c.sourceOrder,
212
+ destOrd: c.destinationOrder,
213
+ parTransId: c.parentTransitionId,
214
+ sibTransId: c.siblingTransitionId,
215
+ presId: c.presentationId
216
+ }));
217
+ return `<dgm:dataModel><dgm:ptLst>${points.join("")}</dgm:ptLst><dgm:cxnLst>${connections.join("")}</dgm:cxnLst><dgm:bg/><dgm:whole/></dgm:dataModel>`;
218
+ }
219
+ /** Parse dgm:dataModel into the structured model. */
220
+ function parseDataModelOptions(el) {
221
+ if (!el) return void 0;
222
+ const result = {};
223
+ const ptLst = findChild(el, "dgm:ptLst");
224
+ if (ptLst) {
225
+ const points = [];
226
+ for (const pt of ptLst.elements ?? []) {
227
+ if (pt.name !== "dgm:pt") continue;
228
+ const point = { modelId: attr(pt, "modelId") ?? "" };
229
+ const type = attr(pt, "type");
230
+ if (type) point.type = type;
231
+ const cxnId = attr(pt, "cxnId");
232
+ if (cxnId) point.connectionId = cxnId;
233
+ const t = findChild(pt, "dgm:t");
234
+ if (t) point.text = extractPointText(t);
235
+ const prSet = findChild(pt, "dgm:prSet");
236
+ if (prSet) point.propertySet = parsePointPropertySet(prSet);
237
+ points.push(point);
238
+ }
239
+ result.points = points;
240
+ }
241
+ const cxnLst = findChild(el, "dgm:cxnLst");
242
+ if (cxnLst) {
243
+ const connections = [];
244
+ for (const cxn of cxnLst.elements ?? []) {
245
+ if (cxn.name !== "dgm:cxn") continue;
246
+ const connection = {
247
+ modelId: attr(cxn, "modelId") ?? "",
248
+ sourceId: attr(cxn, "srcId") ?? "",
249
+ destinationId: attr(cxn, "destId") ?? ""
250
+ };
251
+ const type = attr(cxn, "type");
252
+ if (type) connection.type = type;
253
+ const srcOrd = attrNum(cxn, "srcOrd");
254
+ if (srcOrd !== void 0) connection.sourceOrder = srcOrd;
255
+ const destOrd = attrNum(cxn, "destOrd");
256
+ if (destOrd !== void 0) connection.destinationOrder = destOrd;
257
+ const parTransId = attr(cxn, "parTransId");
258
+ if (parTransId) connection.parentTransitionId = parTransId;
259
+ const sibTransId = attr(cxn, "sibTransId");
260
+ if (sibTransId) connection.siblingTransitionId = sibTransId;
261
+ const presId = attr(cxn, "presId");
262
+ if (presId) connection.presentationId = presId;
263
+ connections.push(connection);
264
+ }
265
+ result.connections = connections;
266
+ }
267
+ return Object.keys(result).length > 0 ? result : void 0;
268
+ }
269
+ /** dgm:t holds an a:p paragraph tree; flatten its text runs. */
270
+ function extractPointText(t) {
271
+ let out = "";
272
+ const walk = (node) => {
273
+ for (const child of node.elements ?? []) if (child.type === "text") out += String(child.text ?? "");
274
+ else walk(child);
275
+ };
276
+ walk(t);
277
+ return out;
278
+ }
279
+ /** Attribute names of dgm:prSet keyed by PointPropertySetOptions field. */
280
+ const PRSET_ATTRS = [
281
+ [
282
+ "presentationAssociationId",
283
+ "presAssocID",
284
+ "string"
285
+ ],
286
+ [
287
+ "presentationName",
288
+ "presName",
289
+ "string"
290
+ ],
291
+ [
292
+ "presentationStyleLabel",
293
+ "presStyleLbl",
294
+ "string"
295
+ ],
296
+ [
297
+ "presentationStyleIndex",
298
+ "presStyleIdx",
299
+ "number"
300
+ ],
301
+ [
302
+ "presentationStyleCount",
303
+ "presStyleCnt",
304
+ "number"
305
+ ],
306
+ [
307
+ "placeholderText",
308
+ "phldrT",
309
+ "string"
310
+ ],
311
+ [
312
+ "placeholder",
313
+ "phldr",
314
+ "boolean"
315
+ ],
316
+ [
317
+ "customAngle",
318
+ "custAng",
319
+ "number"
320
+ ],
321
+ [
322
+ "customFlipVertical",
323
+ "custFlipVert",
324
+ "boolean"
325
+ ],
326
+ [
327
+ "customFlipHorizontal",
328
+ "custFlipHor",
329
+ "boolean"
330
+ ],
331
+ [
332
+ "customSizeX",
333
+ "custSzX",
334
+ "number"
335
+ ],
336
+ [
337
+ "customSizeY",
338
+ "custSzY",
339
+ "number"
340
+ ],
341
+ [
342
+ "customScaleX",
343
+ "custScaleX",
344
+ "number"
345
+ ],
346
+ [
347
+ "customScaleY",
348
+ "custScaleY",
349
+ "number"
350
+ ],
351
+ [
352
+ "customText",
353
+ "custT",
354
+ "boolean"
355
+ ],
356
+ [
357
+ "customLinearFactorX",
358
+ "custLinFactX",
359
+ "number"
360
+ ],
361
+ [
362
+ "customLinearFactorY",
363
+ "custLinFactY",
364
+ "number"
365
+ ],
366
+ [
367
+ "customLinearFactorNeighborX",
368
+ "custLinFactNeighborX",
369
+ "number"
370
+ ],
371
+ [
372
+ "customLinearFactorNeighborY",
373
+ "custLinFactNeighborY",
374
+ "number"
375
+ ],
376
+ [
377
+ "customRadialScaleRadius",
378
+ "custRadScaleRad",
379
+ "number"
380
+ ],
381
+ [
382
+ "customRadialScaleIncrement",
383
+ "custRadScaleInc",
384
+ "number"
385
+ ],
386
+ [
387
+ "coherent3DOffset",
388
+ "coherent3DOff",
389
+ "boolean"
390
+ ],
391
+ [
392
+ "hideGeometry",
393
+ "hideGeom",
394
+ "boolean"
395
+ ],
396
+ [
397
+ "hideLastTransition",
398
+ "hideLastTrans",
399
+ "boolean"
400
+ ],
401
+ [
402
+ "lockTextEntry",
403
+ "lkTxEntry",
404
+ "boolean"
405
+ ],
406
+ [
407
+ "moveWith",
408
+ "moveWith",
409
+ "string"
410
+ ],
411
+ [
412
+ "useDefault",
413
+ "useDef",
414
+ "boolean"
415
+ ],
416
+ [
417
+ "zOrderOffset",
418
+ "zOrderOff",
419
+ "number"
420
+ ],
421
+ [
422
+ "layoutTypeId",
423
+ "loTypeId",
424
+ "string"
425
+ ],
426
+ [
427
+ "layoutCategoryId",
428
+ "loCatId",
429
+ "string"
430
+ ],
431
+ [
432
+ "quickStyleTypeId",
433
+ "qsTypeId",
434
+ "string"
435
+ ],
436
+ [
437
+ "quickStyleCategoryId",
438
+ "qsCatId",
439
+ "string"
440
+ ],
441
+ [
442
+ "colorStyleTypeId",
443
+ "csTypeId",
444
+ "string"
445
+ ],
446
+ [
447
+ "colorStyleCategoryId",
448
+ "csCatId",
449
+ "string"
450
+ ]
451
+ ];
452
+ function parsePointPropertySet(prSet) {
453
+ const result = {};
454
+ for (const [field, xmlName, kind] of PRSET_ATTRS) if (kind === "number") {
455
+ const v = attrNum(prSet, xmlName);
456
+ if (v !== void 0) result[field] = v;
457
+ } else if (kind === "boolean") {
458
+ const v = attrBool(prSet, xmlName);
459
+ if (v !== void 0) result[field] = v;
460
+ } else {
461
+ const v = attr(prSet, xmlName);
462
+ if (v !== void 0 && v !== "") result[field] = v;
463
+ }
464
+ return result;
465
+ }
466
+ //#endregion
467
+ //#region src/smartart/layout-definition.ts
468
+ /**
469
+ * SmartArt layout definition (dgm:layoutDef, CT_DiagramDefinition) — the
470
+ * authoring-layer model describing how a diagram arranges its shapes.
471
+ *
472
+ * Bidirectional: stringify builds the layoutDef part body, parse reads one
473
+ * back into the same options shape, so custom layouts round-trip intact.
474
+ *
475
+ * Reference: ISO/IEC 29500-4, dml-diagram.xsd (CT_DiagramDefinition and the
476
+ * CT_LayoutNode tree it contains).
477
+ *
478
+ * @module
479
+ */
480
+ function emitParameterValue(value) {
481
+ return typeof value === "boolean" ? value ? "1" : "0" : String(value);
482
+ }
483
+ function stringifyAlgorithm(o) {
484
+ const params = (o.parameters ?? []).map((p) => attrs({
485
+ type: p.type,
486
+ val: emitParameterValue(p.value)
487
+ })).map((a) => `<dgm:param${a}/>`).join("");
488
+ return `<dgm:alg${attrs({
489
+ type: o.type,
490
+ rev: o.revision
491
+ })}>${params}</dgm:alg>`;
492
+ }
493
+ function stringifyShape(o) {
494
+ const adjustments = (o.adjustments ?? []).map((a) => `<dgm:adj${attrs({
495
+ idx: a.idx,
496
+ val: a.val
497
+ })}/>`).join("");
498
+ const adjLst = o.adjustments ? `<dgm:adjLst>${adjustments}</dgm:adjLst>` : "";
499
+ return `<dgm:shape${attrs({
500
+ rot: o.rotation,
501
+ type: o.type,
502
+ "r:blip": o.blip,
503
+ zOrderOff: o.zOrderOffset,
504
+ hideGeom: booleanAttr(o.hideGeometry),
505
+ lkTxEntry: booleanAttr(o.lockTextEntry),
506
+ blipPhldr: booleanAttr(o.blipPlaceholder)
507
+ })}>${adjLst}</dgm:shape>`;
508
+ }
509
+ function stringifyConstraints(list) {
510
+ return `<dgm:constrLst>${list.map((c) => {
511
+ return `<dgm:constr${attrs({
512
+ type: c.type,
513
+ for: c.for,
514
+ forName: c.forName,
515
+ ptType: c.pointType,
516
+ refType: c.referenceType,
517
+ refFor: c.referenceFor,
518
+ refForName: c.referenceForName,
519
+ refPtType: c.referencePointType,
520
+ op: c.operation,
521
+ val: c.value
522
+ })}${c.factor !== void 0 ? ` fact="${c.factor}"` : ""}/>`;
523
+ }).join("")}</dgm:constrLst>`;
524
+ }
525
+ function stringifyRules(list) {
526
+ return `<dgm:ruleLst>${list.map((r) => {
527
+ return `<dgm:rule${attrs({
528
+ type: r.type,
529
+ for: r.for,
530
+ forName: r.forName,
531
+ ptType: r.pointType,
532
+ val: r.value,
533
+ max: r.maximum
534
+ })}${r.factor !== void 0 ? ` fact="${r.factor}"` : ""}/>`;
535
+ }).join("")}</dgm:ruleLst>`;
536
+ }
537
+ function stringifyVariables(o) {
538
+ const emit = (tag, value) => value === void 0 ? "" : `<dgm:${tag}${attrs({ val: value })}/>`;
539
+ return "<dgm:varLst>" + emit("orgChart", booleanAttr(o.organizationChart)) + emit("chMax", o.childMaximum) + emit("chPref", o.childPreferred) + emit("bulletEnabled", booleanAttr(o.bulletEnabled)) + emit("dir", o.direction !== void 0 ? xsdDiagramDirection.to(o.direction) : void 0) + emit("hierBranch", o.hierarchyBranchStyle !== void 0 ? xsdHierBranch.to(o.hierarchyBranchStyle) : void 0) + emit("animOne", o.animateOne) + emit("animLvl", o.animateLevel !== void 0 ? xsdAnimLevel.to(o.animateLevel) : void 0) + emit("resizeHandles", o.resizeHandles !== void 0 ? xsdResizeHandles.to(o.resizeHandles) : void 0) + "</dgm:varLst>";
540
+ }
541
+ /** Boolean options emit "1"/"0" when set; undefined stays absent. */
542
+ function booleanAttr(value) {
543
+ return value === void 0 ? void 0 : value ? "1" : "0";
544
+ }
545
+ function selfClose(tag, record) {
546
+ return `<${tag}${attrs(record)}/>`;
547
+ }
548
+ function stringifyChildren(children) {
549
+ let out = "";
550
+ for (const child of children ?? []) if ("algorithm" in child) out += stringifyAlgorithm(child.algorithm);
551
+ else if ("shape" in child) out += stringifyShape(child.shape);
552
+ else if ("presentationOf" in child) out += selfClose("dgm:presOf", {
553
+ axis: child.presentationOf.axis,
554
+ ptType: child.presentationOf.pointType,
555
+ hideLastTrans: child.presentationOf.hideLastTransition,
556
+ st: child.presentationOf.start,
557
+ cnt: child.presentationOf.count,
558
+ step: child.presentationOf.step
559
+ });
560
+ else if ("constraints" in child) out += stringifyConstraints(child.constraints);
561
+ else if ("rules" in child) out += stringifyRules(child.rules);
562
+ else if ("variables" in child) out += stringifyVariables(child.variables);
563
+ else if ("forEach" in child) out += stringifyForEach(child.forEach);
564
+ else if ("layoutNode" in child) out += stringifyLayoutNode(child.layoutNode);
565
+ else if ("choose" in child) out += stringifyChoose(child.choose);
566
+ return out;
567
+ }
568
+ function stringifyLayoutNode(o) {
569
+ const body = stringifyChildren(o.children) + (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : "");
570
+ return `<dgm:layoutNode${attrs({
571
+ name: o.name,
572
+ styleLbl: o.styleLabel,
573
+ chOrder: o.childOrder,
574
+ moveWith: o.moveWith
575
+ })}>${body}</dgm:layoutNode>`;
576
+ }
577
+ function stringifyForEach(o) {
578
+ return `<dgm:forEach${attrs({
579
+ name: o.name,
580
+ ref: o.reference,
581
+ ...iterationRecord(o)
582
+ })}>${stringifyChildren(o.children)}</dgm:forEach>`;
583
+ }
584
+ function stringifyWhen(o) {
585
+ return `<dgm:if${attrs({
586
+ name: o.name,
587
+ ...iterationRecord(o),
588
+ func: o.function,
589
+ arg: o.argument,
590
+ op: o.operator,
591
+ val: o.value
592
+ })}>${stringifyChildren(o.children)}</dgm:if>`;
593
+ }
594
+ function stringifyOtherwise(o) {
595
+ return `<dgm:else${attrs({ name: o.name })}>${stringifyChildren(o.children)}</dgm:else>`;
596
+ }
597
+ function stringifyChoose(o) {
598
+ const body = o.conditions.map(stringifyWhen).join("") + (o.otherwise ? stringifyOtherwise(o.otherwise) : "");
599
+ return `<dgm:choose${attrs({ name: o.name })}>${body}</dgm:choose>`;
600
+ }
601
+ function iterationRecord(o) {
602
+ return {
603
+ axis: o.axis,
604
+ ptType: o.pointType,
605
+ hideLastTrans: o.hideLastTransition,
606
+ st: o.start,
607
+ cnt: o.count,
608
+ step: o.step
609
+ };
610
+ }
611
+ function stringifyLocalizedString(tag, o) {
612
+ return `<dgm:${tag}${attrs({
613
+ lang: o.lang,
614
+ val: o.val
615
+ })}/>`;
616
+ }
617
+ function stringifySampleData(tag, o) {
618
+ if (!o) return "";
619
+ const body = o.dataModel ? stringifyDataModelOptions(o.dataModel) : "";
620
+ return `<dgm:${tag}${attrs({ useDef: booleanAttr(o.useDefault) })}>${body}</dgm:${tag}>`;
621
+ }
622
+ /**
623
+ * Serialize a layout definition to the dgm:layoutDef element (no XML
624
+ * declaration, no namespace declarations — the part wrapper adds both).
625
+ */
626
+ function stringifyLayoutDefinition(o) {
627
+ const body = (o.titles ?? []).map((t) => stringifyLocalizedString("title", t)).join("") + (o.descriptions ?? []).map((d) => stringifyLocalizedString("desc", d)).join("") + (o.categories?.length ? `<dgm:catLst>${o.categories.map((c) => selfClose("dgm:cat", {
628
+ type: c.type,
629
+ pri: c.pri
630
+ })).join("")}</dgm:catLst>` : "") + stringifySampleData("sampData", o.sampleData) + stringifySampleData("styleData", o.styleData) + stringifySampleData("clrData", o.colorData) + stringifyLayoutNode(o.layoutNode) + (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : "");
631
+ return `<dgm:layoutDef${attrs({
632
+ uniqueId: o.uniqueId,
633
+ minVer: o.minVer,
634
+ defStyle: o.defaultStyle
635
+ })}>${body}</dgm:layoutDef>`;
636
+ }
637
+ const DGM_NS = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
638
+ const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
639
+ const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
640
+ /**
641
+ * Inject the part-level dgm/a namespace declarations into the root element of
642
+ * a serialized layoutDef/styleDef/colorsDef body; r joins only when the body
643
+ * actually uses the prefix (dgm:shape @r:blip preview references).
644
+ */
645
+ function withDiagramNamespaces(xml) {
646
+ const r = xml.includes("xmlns:r=") ? "" : /\sr:[\w]+=/.test(xml) ? ` xmlns:r="${R_NS}"` : "";
647
+ return xml.replace(/^<dgm:(layoutDef|styleDef|colorsDef)/, `<dgm:$1 xmlns:dgm="${DGM_NS}" xmlns:a="${A_NS}"${r}`);
648
+ }
649
+ function readIteration(el) {
650
+ const result = {};
651
+ const axis = attr(el, "axis");
652
+ if (axis !== void 0) result.axis = axis;
653
+ const ptType = attr(el, "ptType");
654
+ if (ptType !== void 0) result.pointType = ptType;
655
+ const hideLastTrans = attr(el, "hideLastTrans");
656
+ if (hideLastTrans !== void 0) result.hideLastTransition = hideLastTrans;
657
+ const st = attr(el, "st");
658
+ if (st !== void 0) result.start = st;
659
+ const cnt = attr(el, "cnt");
660
+ if (cnt !== void 0) result.count = cnt;
661
+ const step = attr(el, "step");
662
+ if (step !== void 0) result.step = step;
663
+ return result;
664
+ }
665
+ function parseAlgorithm(el) {
666
+ const result = { type: attr(el, "type") ?? "composite" };
667
+ const rev = attrNum(el, "rev");
668
+ if (rev !== void 0) result.revision = rev;
669
+ const parameters = [];
670
+ for (const child of el.elements ?? []) {
671
+ if (child.name !== "dgm:param") continue;
672
+ const raw = attr(child, "val") ?? "";
673
+ const numeric = Number(raw);
674
+ parameters.push({
675
+ type: attr(child, "type") ?? "",
676
+ value: raw === "1" || raw === "0" ? raw === "1" : Number.isFinite(numeric) && raw.trim() !== "" ? numeric : raw
677
+ });
678
+ }
679
+ if (parameters.length) result.parameters = parameters;
680
+ return result;
681
+ }
682
+ function parseShape(el) {
683
+ const result = {};
684
+ const rot = attrNum(el, "rot");
685
+ if (rot !== void 0) result.rotation = rot;
686
+ const type = attr(el, "type");
687
+ if (type !== void 0 && type !== "none") result.type = type;
688
+ const blip = attr(el, "r:blip");
689
+ if (blip) result.blip = blip;
690
+ const zOrderOff = attrNum(el, "zOrderOff");
691
+ if (zOrderOff !== void 0) result.zOrderOffset = zOrderOff;
692
+ const hideGeom = attr(el, "hideGeom");
693
+ if (hideGeom !== void 0) result.hideGeometry = hideGeom === "1" || hideGeom === "true";
694
+ const lkTxEntry = attr(el, "lkTxEntry");
695
+ if (lkTxEntry !== void 0) result.lockTextEntry = lkTxEntry === "1" || lkTxEntry === "true";
696
+ const blipPhldr = attr(el, "blipPhldr");
697
+ if (blipPhldr !== void 0) result.blipPlaceholder = blipPhldr === "1" || blipPhldr === "true";
698
+ const adjLst = findChild(el, "dgm:adjLst");
699
+ if (adjLst) {
700
+ const adjustments = [];
701
+ for (const adj of adjLst.elements ?? []) {
702
+ if (adj.name !== "dgm:adj") continue;
703
+ const idx = attrNum(adj, "idx");
704
+ const val = attrNum(adj, "val");
705
+ if (idx !== void 0 && val !== void 0) adjustments.push({
706
+ idx,
707
+ val
708
+ });
709
+ }
710
+ if (adjustments.length) result.adjustments = adjustments;
711
+ }
712
+ return result;
713
+ }
714
+ function parseConstraint(el) {
715
+ const result = { type: attr(el, "type") ?? "none" };
716
+ const forRel = attr(el, "for");
717
+ if (forRel !== void 0) result.for = forRel;
718
+ const forName = attr(el, "forName");
719
+ if (forName !== void 0 && forName !== "") result.forName = forName;
720
+ const ptType = attr(el, "ptType");
721
+ if (ptType !== void 0 && ptType !== "all") result.pointType = ptType;
722
+ const refType = attr(el, "refType");
723
+ if (refType !== void 0 && refType !== "none") result.referenceType = refType;
724
+ const refFor = attr(el, "refFor");
725
+ if (refFor !== void 0 && refFor !== "self") result.referenceFor = refFor;
726
+ const refForName = attr(el, "refForName");
727
+ if (refForName !== void 0 && refForName !== "") result.referenceForName = refForName;
728
+ const refPtType = attr(el, "refPtType");
729
+ if (refPtType !== void 0 && refPtType !== "all") result.referencePointType = refPtType;
730
+ const op = attr(el, "op");
731
+ if (op !== void 0 && op !== "none") result.operation = op;
732
+ const val = finiteAttr(el, "val");
733
+ if (val !== void 0) result.value = val;
734
+ const fact = finiteAttr(el, "fact");
735
+ if (fact !== void 0 && fact !== 1) result.factor = fact;
736
+ return result;
737
+ }
738
+ function parseRule(el) {
739
+ const result = { type: attr(el, "type") ?? "none" };
740
+ const forRel = attr(el, "for");
741
+ if (forRel !== void 0 && forRel !== "self") result.for = forRel;
742
+ const forName = attr(el, "forName");
743
+ if (forName !== void 0 && forName !== "") result.forName = forName;
744
+ const ptType = attr(el, "ptType");
745
+ if (ptType !== void 0 && ptType !== "all") result.pointType = ptType;
746
+ const val = finiteAttr(el, "val");
747
+ if (val !== void 0) result.value = val;
748
+ const fact = finiteAttr(el, "fact");
749
+ if (fact !== void 0) result.factor = fact;
750
+ const max = finiteAttr(el, "max");
751
+ if (max !== void 0) result.maximum = max;
752
+ return result;
753
+ }
754
+ /** Numeric attribute read; the XSD NaN default comes back as undefined. */
755
+ function finiteAttr(el, name) {
756
+ const raw = attr(el, name);
757
+ if (raw === void 0) return void 0;
758
+ const n = Number(raw);
759
+ return Number.isFinite(n) ? n : void 0;
760
+ }
761
+ function parseVariables(el) {
762
+ const result = {};
763
+ const readBool = (tag) => {
764
+ for (const child of el.elements ?? []) {
765
+ if (child.name !== `dgm:${tag}`) continue;
766
+ const v = attr(child, "val") ?? "1";
767
+ return v === "1" || v === "true";
768
+ }
769
+ };
770
+ const readEnum = (tag) => {
771
+ for (const child of el.elements ?? []) {
772
+ if (child.name !== `dgm:${tag}`) continue;
773
+ return attr(child, "val") ?? "";
774
+ }
775
+ };
776
+ const readNumber = (tag) => {
777
+ for (const child of el.elements ?? []) {
778
+ if (child.name !== `dgm:${tag}`) continue;
779
+ const v = attrNum(child, "val");
780
+ return v === -1 ? void 0 : v;
781
+ }
782
+ };
783
+ const orgChart = readBool("orgChart");
784
+ if (orgChart !== void 0) result.organizationChart = orgChart;
785
+ const chMax = readNumber("chMax");
786
+ if (chMax !== void 0) result.childMaximum = chMax;
787
+ const chPref = readNumber("chPref");
788
+ if (chPref !== void 0) result.childPreferred = chPref;
789
+ const bulletEnabled = readBool("bulletEnabled");
790
+ if (bulletEnabled !== void 0) result.bulletEnabled = bulletEnabled;
791
+ const direction = readEnum("dir");
792
+ if (direction) result.direction = xsdDiagramDirection.from(direction);
793
+ const hierBranch = readEnum("hierBranch");
794
+ if (hierBranch) result.hierarchyBranchStyle = xsdHierBranch.from(hierBranch);
795
+ const animOne = readEnum("animOne");
796
+ if (animOne) result.animateOne = animOne;
797
+ const animLvl = readEnum("animLvl");
798
+ if (animLvl) result.animateLevel = xsdAnimLevel.from(animLvl);
799
+ const resizeHandles = readEnum("resizeHandles");
800
+ if (resizeHandles) result.resizeHandles = xsdResizeHandles.from(resizeHandles);
801
+ return result;
802
+ }
803
+ function parseChildren(el) {
804
+ const children = [];
805
+ for (const child of el.elements ?? []) switch (child.name) {
806
+ case "dgm:alg":
807
+ children.push({ algorithm: parseAlgorithm(child) });
808
+ break;
809
+ case "dgm:shape":
810
+ children.push({ shape: parseShape(child) });
811
+ break;
812
+ case "dgm:presOf":
813
+ children.push({ presentationOf: readIteration(child) });
814
+ break;
815
+ case "dgm:constrLst":
816
+ children.push({ constraints: (child.elements ?? []).filter((c) => c.name === "dgm:constr").map(parseConstraint) });
817
+ break;
818
+ case "dgm:ruleLst":
819
+ children.push({ rules: (child.elements ?? []).filter((c) => c.name === "dgm:rule").map(parseRule) });
820
+ break;
821
+ case "dgm:varLst":
822
+ children.push({ variables: parseVariables(child) });
823
+ break;
824
+ case "dgm:forEach":
825
+ children.push({ forEach: parseForEach(child) });
826
+ break;
827
+ case "dgm:layoutNode":
828
+ children.push({ layoutNode: parseLayoutNode(child) });
829
+ break;
830
+ case "dgm:choose": children.push({ choose: parseChoose(child) });
831
+ }
832
+ return children.length ? children : void 0;
833
+ }
834
+ function parseLayoutNode(el) {
835
+ const result = {};
836
+ const name = attr(el, "name");
837
+ if (name) result.name = name;
838
+ const styleLbl = attr(el, "styleLbl");
839
+ if (styleLbl) result.styleLabel = styleLbl;
840
+ const chOrder = attr(el, "chOrder");
841
+ if (chOrder !== void 0 && chOrder !== "b") result.childOrder = chOrder;
842
+ const moveWith = attr(el, "moveWith");
843
+ if (moveWith) result.moveWith = moveWith;
844
+ const children = parseChildren(el);
845
+ if (children) result.children = children;
846
+ const extLst = findChild(el, "dgm:extLst") ?? findChild(el, "a:extLst");
847
+ if (extLst) result.ext = stringify(extLst);
848
+ return result;
849
+ }
850
+ function parseForEach(el) {
851
+ const result = readIteration(el);
852
+ const name = attr(el, "name");
853
+ if (name) result.name = name;
854
+ const ref = attr(el, "ref");
855
+ if (ref) result.reference = ref;
856
+ const children = parseChildren(el);
857
+ if (children) result.children = children;
858
+ return result;
859
+ }
860
+ function parseWhen(el) {
861
+ const result = {
862
+ ...readIteration(el),
863
+ function: attr(el, "func") ?? "cnt",
864
+ operator: attr(el, "op") ?? "equ",
865
+ value: attr(el, "val") ?? ""
866
+ };
867
+ const name = attr(el, "name");
868
+ if (name) result.name = name;
869
+ const arg = attr(el, "arg");
870
+ if (arg !== void 0 && arg !== "none") result.argument = arg;
871
+ const children = parseChildren(el);
872
+ if (children) result.children = children;
873
+ return result;
874
+ }
875
+ function parseChoose(el) {
876
+ const conditions = [];
877
+ let otherwise;
878
+ for (const child of el.elements ?? []) if (child.name === "dgm:if") conditions.push(parseWhen(child));
879
+ else if (child.name === "dgm:else") otherwise = parseOtherwise(child);
880
+ const result = { conditions };
881
+ const name = attr(el, "name");
882
+ if (name) result.name = name;
883
+ if (otherwise) result.otherwise = otherwise;
884
+ return result;
885
+ }
886
+ function parseOtherwise(el) {
887
+ const result = {};
888
+ const name = attr(el, "name");
889
+ if (name) result.name = name;
890
+ const children = parseChildren(el);
891
+ if (children) result.children = children;
892
+ return result;
893
+ }
894
+ function parseLocalizedStrings(el, tag) {
895
+ const out = [];
896
+ for (const child of el.elements ?? []) {
897
+ if (child.name !== `dgm:${tag}`) continue;
898
+ const val = attr(child, "val") ?? "";
899
+ const lang = attr(child, "lang");
900
+ out.push(lang ? {
901
+ lang,
902
+ val
903
+ } : { val });
904
+ }
905
+ return out.length ? out : void 0;
906
+ }
907
+ function parseSampleData(el) {
908
+ if (!el) return void 0;
909
+ const result = {};
910
+ const useDef = attr(el, "useDef");
911
+ if (useDef !== void 0) result.useDefault = useDef === "1" || useDef === "true";
912
+ const dataModel = parseDataModelOptions(findChild(el, "dgm:dataModel"));
913
+ if (dataModel) result.dataModel = dataModel;
914
+ return Object.keys(result).length ? result : {};
915
+ }
916
+ /** Parse a dgm:layoutDef element into options. */
917
+ function parseLayoutDefinition(el) {
918
+ const root = el.name === "dgm:layoutDef" ? el : findChild(el, "dgm:layoutDef") ?? el;
919
+ const result = {};
920
+ const uniqueId = attr(root, "uniqueId");
921
+ if (uniqueId) result.uniqueId = uniqueId;
922
+ const minVer = attr(root, "minVer");
923
+ if (minVer) result.minVer = minVer;
924
+ const defStyle = attr(root, "defStyle");
925
+ if (defStyle) result.defaultStyle = defStyle;
926
+ const titles = parseLocalizedStrings(root, "title");
927
+ if (titles) result.titles = titles;
928
+ const descriptions = parseLocalizedStrings(root, "desc");
929
+ if (descriptions) result.descriptions = descriptions;
930
+ const catLst = findChild(root, "dgm:catLst");
931
+ if (catLst) {
932
+ const categories = (catLst.elements ?? []).filter((c) => c.name === "dgm:cat").map((c) => ({
933
+ type: attr(c, "type") ?? "",
934
+ pri: attrNum(c, "pri") ?? 0
935
+ }));
936
+ if (categories.length) result.categories = categories;
937
+ }
938
+ const sampleData = parseSampleData(findChild(root, "dgm:sampData"));
939
+ if (sampleData) result.sampleData = sampleData;
940
+ const styleData = parseSampleData(findChild(root, "dgm:styleData"));
941
+ if (styleData) result.styleData = styleData;
942
+ const colorData = parseSampleData(findChild(root, "dgm:clrData"));
943
+ if (colorData) result.colorData = colorData;
944
+ const layoutNode = findChild(root, "dgm:layoutNode");
945
+ if (layoutNode) result.layoutNode = parseLayoutNode(layoutNode);
946
+ const extLst = findChild(root, "dgm:extLst") ?? findChild(root, "a:extLst");
947
+ if (extLst) result.ext = stringify(extLst);
948
+ return result;
949
+ }
950
+ /** layoutDef part descriptor — stringify emits the element, parse reads it. */
951
+ const layoutDefDesc = {
952
+ kind: "custom",
953
+ stringify: (opts) => stringifyLayoutDefinition(opts),
954
+ parse: (el) => parseLayoutDefinition(el)
955
+ };
956
+ /** Full layoutDef part body: XML declaration + namespaces + the element. */
957
+ function stringifyLayoutDefinitionPart(o) {
958
+ return OOXML_XML_DECLARATION + withDiagramNamespaces(stringifyLayoutDefinition(o));
959
+ }
960
+ //#endregion
961
+ //#region src/smartart/color-definition.ts
962
+ /**
963
+ * SmartArt color-transform definition (dgm:colorsDef, CT_ColorTransform) —
964
+ * the authoring-layer model mapping style labels to color lists.
965
+ *
966
+ * Bidirectional: stringify builds the colors part body, parse reads one back
967
+ * into the same options shape, so custom color transforms round-trip intact.
968
+ *
969
+ * Reference: ISO/IEC 29500-4, dml-diagram.xsd (CT_ColorTransform,
970
+ * CT_CTStyleLabel, CT_Colors with its EG_ColorChoice children).
971
+ *
972
+ * @module
973
+ */
974
+ const COLOR_LIST_FIELDS = [
975
+ ["fillClrLst", "fillColorList"],
976
+ ["linClrLst", "lineColorList"],
977
+ ["effectClrLst", "effectColorList"],
978
+ ["txLinClrLst", "textLineColorList"],
979
+ ["txFillClrLst", "textFillColorList"],
980
+ ["txEffectClrLst", "textEffectColorList"]
981
+ ];
982
+ function stringifyLocalized$1(tag, o) {
983
+ return `<dgm:${tag}${attrs({
984
+ lang: o.lang,
985
+ val: o.val
986
+ })}/>`;
987
+ }
988
+ function stringifyColorStyleLabel(o) {
989
+ let body = "";
990
+ for (const [tag, field] of COLOR_LIST_FIELDS) {
991
+ const list = o[field];
992
+ if (list) body += createColorList(`dgm:${tag}`, list);
993
+ }
994
+ return `<dgm:styleLbl${attrs({ name: o.name })}>${body}</dgm:styleLbl>`;
995
+ }
996
+ /**
997
+ * Serialize a color-transform definition to the dgm:colorsDef element (no XML
998
+ * declaration, no namespace declarations — the part wrapper adds both).
999
+ */
1000
+ function stringifyColorDefinition(o) {
1001
+ const body = (o.titles ?? []).map((t) => stringifyLocalized$1("title", t)).join("") + (o.descriptions ?? []).map((d) => stringifyLocalized$1("desc", d)).join("") + (o.categories?.length ? `<dgm:catLst>${o.categories.map((c) => `<dgm:cat${attrs({
1002
+ type: c.type,
1003
+ pri: c.pri
1004
+ })}/>`).join("")}</dgm:catLst>` : "") + (o.styleLabels ?? []).map(stringifyColorStyleLabel).join("") + (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : "");
1005
+ return `<dgm:colorsDef${attrs({
1006
+ uniqueId: o.uniqueId,
1007
+ minVer: o.minVer
1008
+ })}>${body}</dgm:colorsDef>`;
1009
+ }
1010
+ function parseColorStyleLabel(el) {
1011
+ const result = { name: attr(el, "name") ?? "" };
1012
+ for (const [tag, field] of COLOR_LIST_FIELDS) {
1013
+ const listEl = findChild(el, `dgm:${tag}`);
1014
+ if (listEl) result[field] = parseColorList(listEl);
1015
+ }
1016
+ return result;
1017
+ }
1018
+ function parseLocalized$1(el, tag) {
1019
+ const out = [];
1020
+ for (const child of el.elements ?? []) {
1021
+ if (child.name !== `dgm:${tag}`) continue;
1022
+ const val = attr(child, "val") ?? "";
1023
+ const lang = attr(child, "lang");
1024
+ out.push(lang ? {
1025
+ lang,
1026
+ val
1027
+ } : { val });
1028
+ }
1029
+ return out.length ? out : void 0;
1030
+ }
1031
+ /** Parse a dgm:colorsDef element into options. */
1032
+ function parseColorDefinition(el) {
1033
+ const root = el.name === "dgm:colorsDef" ? el : findChild(el, "dgm:colorsDef") ?? el;
1034
+ const result = {};
1035
+ const uniqueId = attr(root, "uniqueId");
1036
+ if (uniqueId) result.uniqueId = uniqueId;
1037
+ const minVer = attr(root, "minVer");
1038
+ if (minVer) result.minVer = minVer;
1039
+ const titles = parseLocalized$1(root, "title");
1040
+ if (titles) result.titles = titles;
1041
+ const descriptions = parseLocalized$1(root, "desc");
1042
+ if (descriptions) result.descriptions = descriptions;
1043
+ const catLst = findChild(root, "dgm:catLst");
1044
+ if (catLst) {
1045
+ const categories = (catLst.elements ?? []).filter((c) => c.name === "dgm:cat").map((c) => ({
1046
+ type: attr(c, "type") ?? "",
1047
+ pri: Number(attr(c, "pri") ?? 0)
1048
+ }));
1049
+ if (categories.length) result.categories = categories;
1050
+ }
1051
+ const styleLabels = [];
1052
+ for (const child of root.elements ?? []) if (child.name === "dgm:styleLbl") styleLabels.push(parseColorStyleLabel(child));
1053
+ if (styleLabels.length) result.styleLabels = styleLabels;
1054
+ const extLst = findChild(root, "dgm:extLst") ?? findChild(root, "a:extLst");
1055
+ if (extLst) result.ext = stringify(extLst);
1056
+ return result;
1057
+ }
1058
+ /** colors part descriptor — stringify emits the element, parse reads it. */
1059
+ const colorsDefDesc = {
1060
+ kind: "custom",
1061
+ stringify: (opts) => stringifyColorDefinition(opts),
1062
+ parse: (el) => parseColorDefinition(el)
1063
+ };
1064
+ /** Full colors part body: XML declaration + namespaces + the element. */
1065
+ function stringifyColorDefinitionPart(o) {
1066
+ return OOXML_XML_DECLARATION + withDiagramNamespaces(stringifyColorDefinition(o));
1067
+ }
1068
+ //#endregion
1069
+ //#region src/smartart/style-definition.ts
1070
+ /**
1071
+ * SmartArt quick-style definition (dgm:styleDef, CT_StyleDefinition) — the
1072
+ * authoring-layer model describing how a diagram's style labels are formatted.
1073
+ *
1074
+ * Bidirectional: stringify builds the quickStyle part body, parse reads one
1075
+ * back into the same options shape, so custom styles round-trip intact.
1076
+ *
1077
+ * Reference: ISO/IEC 29500-4, dml-diagram.xsd (CT_StyleDefinition,
1078
+ * CT_StyleLabel, CT_TextProps and the EG_Text3D group from dml-main.xsd).
1079
+ *
1080
+ * @module
1081
+ */
1082
+ const DIRECT_WRITE_CTX = {
1083
+ addRelationship: () => "",
1084
+ addMedia: () => "",
1085
+ addHyperlink: () => {}
1086
+ };
1087
+ const DIRECT_READ_CTX = {
1088
+ resolveRelationship: () => void 0,
1089
+ getPart: () => void 0,
1090
+ getRaw: () => void 0
1091
+ };
1092
+ function renamespaceTag(tag, xml) {
1093
+ return xml.replace(`<a:${tag}`, `<dgm:${tag}`).replace(`</a:${tag}>`, `</dgm:${tag}>`);
1094
+ }
1095
+ function stringifyTextProperties(o, ctx) {
1096
+ const body = o.shape3d ? shape3DDesc.stringify(o.shape3d, ctx) ?? "" : o.flatText !== void 0 ? `<a:flatTx${attrs({ z: o.flatText })}/>` : "";
1097
+ return body ? `<dgm:txPr>${body}</dgm:txPr>` : "";
1098
+ }
1099
+ function stringifyStyleLabel(o, ctx) {
1100
+ let body = "";
1101
+ if (o.scene3d) body += renamespaceTag("scene3d", scene3DDesc.stringify(o.scene3d, ctx) ?? "");
1102
+ if (o.shape3d) body += renamespaceTag("sp3d", shape3DDesc.stringify(o.shape3d, ctx) ?? "");
1103
+ if (o.textProperties) body += stringifyTextProperties(o.textProperties, ctx);
1104
+ if (o.style) body += renamespaceTag("style", stringifyShapeStyle(o.style, ctx));
1105
+ if (o.ext) body += `<dgm:extLst>${o.ext}</dgm:extLst>`;
1106
+ return `<dgm:styleLbl${attrs({ name: o.name })}>${body}</dgm:styleLbl>`;
1107
+ }
1108
+ function stringifyLocalized(tag, o) {
1109
+ return `<dgm:${tag}${attrs({
1110
+ lang: o.lang,
1111
+ val: o.val
1112
+ })}/>`;
1113
+ }
1114
+ /**
1115
+ * Serialize a style definition to the dgm:styleDef element (no XML
1116
+ * declaration, no namespace declarations — the part wrapper adds both).
1117
+ */
1118
+ function stringifyStyleDefinition(o) {
1119
+ const body = (o.titles ?? []).map((t) => stringifyLocalized("title", t)).join("") + (o.descriptions ?? []).map((d) => stringifyLocalized("desc", d)).join("") + (o.categories?.length ? `<dgm:catLst>${o.categories.map((c) => `<dgm:cat${attrs({
1120
+ type: c.type,
1121
+ pri: c.pri
1122
+ })}/>`).join("")}</dgm:catLst>` : "") + (o.scene3d ? renamespaceTag("scene3d", scene3DDesc.stringify(o.scene3d, DIRECT_WRITE_CTX) ?? "") : "") + (o.styleLabels ?? []).map((l) => stringifyStyleLabel(l, DIRECT_WRITE_CTX)).join("") + (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : "");
1123
+ return `<dgm:styleDef${attrs({
1124
+ uniqueId: o.uniqueId,
1125
+ minVer: o.minVer
1126
+ })}>${body}</dgm:styleDef>`;
1127
+ }
1128
+ function parseTextProperties(el) {
1129
+ const result = {};
1130
+ const sp3d = findChild(el, "a:sp3d");
1131
+ if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, DIRECT_READ_CTX);
1132
+ const flatTx = findChild(el, "a:flatTx");
1133
+ if (flatTx) {
1134
+ const z = attr(flatTx, "z");
1135
+ result.flatText = z !== void 0 ? Number(z) : 0;
1136
+ }
1137
+ return result;
1138
+ }
1139
+ function parseStyleLabel(el) {
1140
+ const result = { name: attr(el, "name") ?? "" };
1141
+ const scene3d = findChild(el, "dgm:scene3d");
1142
+ if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, DIRECT_READ_CTX);
1143
+ const sp3d = findChild(el, "dgm:sp3d");
1144
+ if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, DIRECT_READ_CTX);
1145
+ const txPr = findChild(el, "dgm:txPr");
1146
+ if (txPr) result.textProperties = parseTextProperties(txPr);
1147
+ const style = findChild(el, "dgm:style");
1148
+ if (style) result.style = parseShapeStyle(style, DIRECT_READ_CTX);
1149
+ const extLst = findChild(el, "dgm:extLst") ?? findChild(el, "a:extLst");
1150
+ if (extLst) result.ext = stringify(extLst);
1151
+ return result;
1152
+ }
1153
+ function parseLocalized(el, tag) {
1154
+ const out = [];
1155
+ for (const child of el.elements ?? []) {
1156
+ if (child.name !== `dgm:${tag}`) continue;
1157
+ const val = attr(child, "val") ?? "";
1158
+ const lang = attr(child, "lang");
1159
+ out.push(lang ? {
1160
+ lang,
1161
+ val
1162
+ } : { val });
1163
+ }
1164
+ return out.length ? out : void 0;
1165
+ }
1166
+ /** Parse a dgm:styleDef element into options. */
1167
+ function parseStyleDefinition(el) {
1168
+ const root = el.name === "dgm:styleDef" ? el : findChild(el, "dgm:styleDef") ?? el;
1169
+ const result = {};
1170
+ const uniqueId = attr(root, "uniqueId");
1171
+ if (uniqueId) result.uniqueId = uniqueId;
1172
+ const minVer = attr(root, "minVer");
1173
+ if (minVer) result.minVer = minVer;
1174
+ const titles = parseLocalized(root, "title");
1175
+ if (titles) result.titles = titles;
1176
+ const descriptions = parseLocalized(root, "desc");
1177
+ if (descriptions) result.descriptions = descriptions;
1178
+ const catLst = findChild(root, "dgm:catLst");
1179
+ if (catLst) {
1180
+ const categories = (catLst.elements ?? []).filter((c) => c.name === "dgm:cat").map((c) => ({
1181
+ type: attr(c, "type") ?? "",
1182
+ pri: Number(attr(c, "pri") ?? 0)
1183
+ }));
1184
+ if (categories.length) result.categories = categories;
1185
+ }
1186
+ const scene3d = findChild(root, "dgm:scene3d");
1187
+ if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, DIRECT_READ_CTX);
1188
+ const styleLabels = [];
1189
+ for (const child of root.elements ?? []) if (child.name === "dgm:styleLbl") styleLabels.push(parseStyleLabel(child));
1190
+ if (styleLabels.length) result.styleLabels = styleLabels;
1191
+ const extLst = findChild(root, "dgm:extLst") ?? findChild(root, "a:extLst");
1192
+ if (extLst) result.ext = stringify(extLst);
1193
+ return result;
1194
+ }
1195
+ /** quickStyle part descriptor — stringify emits the element, parse reads it. */
1196
+ const styleDefDesc = {
1197
+ kind: "custom",
1198
+ stringify: (opts) => stringifyStyleDefinition(opts),
1199
+ parse: (el) => parseStyleDefinition(el)
1200
+ };
1201
+ /** Full quickStyle part body: XML declaration + namespaces + the element. */
1202
+ function stringifyStyleDefinitionPart(o) {
1203
+ return OOXML_XML_DECLARATION + withDiagramNamespaces(stringifyStyleDefinition(o));
1204
+ }
1205
+ //#endregion
1206
+ //#region src/smartart/built-in-definitions.ts
1207
+ const BUILTIN_ACCENTS = [
1208
+ "accent1",
1209
+ "accent2",
1210
+ "accent3",
1211
+ "accent4",
1212
+ "accent5",
1213
+ "accent6"
1214
+ ];
1215
+ /** Sample-model point list shared by the layout stubs: a doc point plus placeholders. */
1216
+ function samplePoints(count) {
1217
+ return { dataModel: {
1218
+ points: [{
1219
+ modelId: "0",
1220
+ type: "doc"
1221
+ }, ...Array.from({ length: count }, (_, i) => ({
1222
+ modelId: String(i + 1),
1223
+ propertySet: { placeholder: true }
1224
+ }))],
1225
+ connections: Array.from({ length: count }, (_, i) => ({
1226
+ modelId: String(count + 1 + i),
1227
+ sourceId: "0",
1228
+ destinationId: String(i + 1),
1229
+ sourceOrder: i,
1230
+ destinationOrder: 0
1231
+ }))
1232
+ } };
1233
+ }
1234
+ /**
1235
+ * Full default list layout (urn:microsoft.com/office/officeart/2005/8/layout/default).
1236
+ */
1237
+ const DEFAULT_LAYOUT = {
1238
+ uniqueId: "urn:microsoft.com/office/officeart/2005/8/layout/default",
1239
+ titles: [{ val: "" }],
1240
+ descriptions: [{ val: "" }],
1241
+ categories: [{
1242
+ type: "list",
1243
+ pri: 400
1244
+ }],
1245
+ sampleData: samplePoints(5),
1246
+ styleData: { dataModel: {
1247
+ points: [
1248
+ {
1249
+ modelId: "0",
1250
+ type: "doc"
1251
+ },
1252
+ { modelId: "1" },
1253
+ { modelId: "2" }
1254
+ ],
1255
+ connections: [{
1256
+ modelId: "3",
1257
+ sourceId: "0",
1258
+ destinationId: "1",
1259
+ sourceOrder: 0,
1260
+ destinationOrder: 0
1261
+ }, {
1262
+ modelId: "4",
1263
+ sourceId: "0",
1264
+ destinationId: "2",
1265
+ sourceOrder: 1,
1266
+ destinationOrder: 0
1267
+ }]
1268
+ } },
1269
+ colorData: { dataModel: {
1270
+ points: [{
1271
+ modelId: "0",
1272
+ type: "doc"
1273
+ }, ...Array.from({ length: 6 }, (_, i) => ({ modelId: String(i + 1) }))],
1274
+ connections: Array.from({ length: 6 }, (_, i) => ({
1275
+ modelId: String(7 + i),
1276
+ sourceId: "0",
1277
+ destinationId: String(i + 1),
1278
+ sourceOrder: i,
1279
+ destinationOrder: 0
1280
+ }))
1281
+ } },
1282
+ layoutNode: {
1283
+ name: "diagram",
1284
+ childOrder: "b",
1285
+ children: [
1286
+ { variables: {
1287
+ direction: "normal",
1288
+ resizeHandles: "exact"
1289
+ } },
1290
+ { choose: {
1291
+ name: "Name0",
1292
+ conditions: [{
1293
+ name: "Name1",
1294
+ function: "var",
1295
+ argument: "dir",
1296
+ operator: "equ",
1297
+ value: "norm",
1298
+ children: [{ algorithm: {
1299
+ type: "snake",
1300
+ parameters: [
1301
+ {
1302
+ type: "grDir",
1303
+ value: "tL"
1304
+ },
1305
+ {
1306
+ type: "flowDir",
1307
+ value: "row"
1308
+ },
1309
+ {
1310
+ type: "contDir",
1311
+ value: "sameDir"
1312
+ },
1313
+ {
1314
+ type: "off",
1315
+ value: "ctr"
1316
+ }
1317
+ ]
1318
+ } }]
1319
+ }],
1320
+ otherwise: {
1321
+ name: "Name2",
1322
+ children: [{ algorithm: {
1323
+ type: "snake",
1324
+ parameters: [
1325
+ {
1326
+ type: "grDir",
1327
+ value: "tR"
1328
+ },
1329
+ {
1330
+ type: "flowDir",
1331
+ value: "row"
1332
+ },
1333
+ {
1334
+ type: "contDir",
1335
+ value: "sameDir"
1336
+ },
1337
+ {
1338
+ type: "off",
1339
+ value: "ctr"
1340
+ }
1341
+ ]
1342
+ } }]
1343
+ }
1344
+ } },
1345
+ { shape: {
1346
+ blipPlaceholder: false,
1347
+ adjustments: []
1348
+ } },
1349
+ { presentationOf: {} },
1350
+ { constraints: [
1351
+ {
1352
+ type: "w",
1353
+ for: "ch",
1354
+ forName: "node",
1355
+ referenceType: "w",
1356
+ referencePointType: "all"
1357
+ },
1358
+ {
1359
+ type: "h",
1360
+ for: "ch",
1361
+ forName: "node",
1362
+ referenceType: "w",
1363
+ referenceFor: "ch",
1364
+ referenceForName: "node",
1365
+ factor: .6
1366
+ },
1367
+ {
1368
+ type: "w",
1369
+ for: "ch",
1370
+ forName: "sibTrans",
1371
+ referenceType: "w",
1372
+ referenceFor: "ch",
1373
+ referenceForName: "node",
1374
+ factor: .1
1375
+ },
1376
+ {
1377
+ type: "sp",
1378
+ referenceType: "w",
1379
+ referenceFor: "ch",
1380
+ referenceForName: "sibTrans"
1381
+ },
1382
+ {
1383
+ type: "primFontSz",
1384
+ for: "ch",
1385
+ forName: "node",
1386
+ operation: "equ",
1387
+ value: 65
1388
+ }
1389
+ ] },
1390
+ { rules: [] },
1391
+ { forEach: {
1392
+ name: "Name3",
1393
+ axis: "ch",
1394
+ pointType: "node",
1395
+ start: "1",
1396
+ children: [{ layoutNode: {
1397
+ name: "node",
1398
+ children: [
1399
+ { variables: { bulletEnabled: true } },
1400
+ { algorithm: { type: "tx" } },
1401
+ { shape: {
1402
+ type: "rect",
1403
+ adjustments: []
1404
+ } },
1405
+ { presentationOf: {
1406
+ axis: "desOrSelf",
1407
+ pointType: "node"
1408
+ } },
1409
+ { constraints: [
1410
+ {
1411
+ type: "lMarg",
1412
+ referenceType: "primFontSz",
1413
+ factor: .3
1414
+ },
1415
+ {
1416
+ type: "rMarg",
1417
+ referenceType: "primFontSz",
1418
+ factor: .3
1419
+ },
1420
+ {
1421
+ type: "tMarg",
1422
+ referenceType: "primFontSz",
1423
+ factor: .3
1424
+ },
1425
+ {
1426
+ type: "bMarg",
1427
+ referenceType: "primFontSz",
1428
+ factor: .3
1429
+ }
1430
+ ] },
1431
+ { rules: [{
1432
+ type: "primFontSz",
1433
+ value: 5
1434
+ }] }
1435
+ ]
1436
+ } }, { forEach: {
1437
+ name: "Name4",
1438
+ axis: "followSib",
1439
+ pointType: "sibTrans",
1440
+ count: "1",
1441
+ children: [{ layoutNode: {
1442
+ name: "sibTrans",
1443
+ children: [
1444
+ { algorithm: { type: "sp" } },
1445
+ { shape: { adjustments: [] } },
1446
+ { presentationOf: {} },
1447
+ { constraints: [] },
1448
+ { rules: [] }
1449
+ ]
1450
+ } }]
1451
+ } }]
1452
+ } }
1453
+ ]
1454
+ }
1455
+ };
1456
+ /**
1457
+ * Returns layout XML. Full layout tree for "default", minimal stub for others.
1458
+ * Stubs keep a schema-required empty layoutNode; PowerPoint resolves built-in
1459
+ * definitions from the uniqueId / loTypeId in the data model.
1460
+ */
1461
+ function getLayoutXml(layoutId) {
1462
+ if (layoutId === "default") return stringifyLayoutDefinitionPart(DEFAULT_LAYOUT);
1463
+ return stringifyLayoutDefinitionPart({
1464
+ uniqueId: `urn:microsoft.com/office/officeart/2005/8/layout/${layoutId}`,
1465
+ titles: [{ val: "" }],
1466
+ descriptions: [{ val: "" }],
1467
+ categories: [{
1468
+ type: LAYOUT_CATEGORIES[layoutId] ?? "list",
1469
+ pri: 400
1470
+ }],
1471
+ sampleData: samplePoints(2),
1472
+ layoutNode: {}
1473
+ });
1474
+ }
1475
+ const STYLE_SCENE_3D = {
1476
+ camera: { preset: "orthographicFront" },
1477
+ lightRig: {
1478
+ rig: "threePt",
1479
+ direction: "top"
1480
+ }
1481
+ };
1482
+ /**
1483
+ * Returns style XML. Each label node0…node5 ties one accent color into the
1484
+ * theme style matrix (line in tx1, fill in the accent), so PowerPoint renders
1485
+ * SmartArt shapes with themed fills and effects.
1486
+ */
1487
+ function getStyleXml(styleId) {
1488
+ return stringifyStyleDefinitionPart({
1489
+ uniqueId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${styleId}`,
1490
+ titles: [{ val: "" }],
1491
+ descriptions: [{ val: "" }],
1492
+ categories: [{
1493
+ type: STYLE_CATEGORIES[styleId] ?? "simple",
1494
+ pri: 10100
1495
+ }],
1496
+ scene3d: STYLE_SCENE_3D,
1497
+ styleLabels: BUILTIN_ACCENTS.map((accent, i) => ({
1498
+ name: `node${i}`,
1499
+ style: {
1500
+ lineReference: {
1501
+ index: 2,
1502
+ color: { value: "tx1" }
1503
+ },
1504
+ fillReference: {
1505
+ index: 1,
1506
+ color: { value: accent }
1507
+ },
1508
+ effectReference: {
1509
+ index: 0,
1510
+ color: { value: "tx1" }
1511
+ },
1512
+ fontReference: {
1513
+ collection: "minor",
1514
+ color: { value: "tx1" }
1515
+ }
1516
+ }
1517
+ }))
1518
+ });
1519
+ }
1520
+ const TINTED_TEXT = {
1521
+ value: "tx1",
1522
+ transforms: { tint: 75 }
1523
+ };
1524
+ /**
1525
+ * Returns color XML mapping the node0 label to color lists for the requested
1526
+ * color scheme (accent / colorful / dark / fallback).
1527
+ */
1528
+ function getColorXml(colorId) {
1529
+ const accent = colorId.match(/^(accent\d)/)?.[1] ?? "accent1";
1530
+ let fillColorList;
1531
+ let lineColorList;
1532
+ let textFillColorList;
1533
+ if (colorId.startsWith("colorful")) {
1534
+ fillColorList = { colors: BUILTIN_ACCENTS.slice(0, 5).map((a) => ({ value: a })) };
1535
+ lineColorList = { colors: [{ value: "lt1" }] };
1536
+ textFillColorList = { colors: [{ value: "tx1" }] };
1537
+ } else if (colorId.startsWith("dark")) {
1538
+ fillColorList = { colors: [{ value: "dk1" }, { value: "dk2" }] };
1539
+ lineColorList = { colors: [{ value: "lt1" }] };
1540
+ textFillColorList = { colors: [{ value: "lt1" }] };
1541
+ } else if (colorId.startsWith("accent")) {
1542
+ fillColorList = { colors: [{ value: accent }] };
1543
+ lineColorList = { colors: [TINTED_TEXT] };
1544
+ textFillColorList = { colors: [{ value: "tx1" }] };
1545
+ } else {
1546
+ fillColorList = { colors: [{ value: "accent1" }] };
1547
+ lineColorList = { colors: [{ value: "tx1" }] };
1548
+ textFillColorList = { colors: [{ value: "tx1" }] };
1549
+ }
1550
+ return stringifyColorDefinitionPart({
1551
+ uniqueId: `urn:microsoft.com/office/officeart/2005/8/colors/${colorId}`,
1552
+ titles: [{ val: "" }],
1553
+ descriptions: [{ val: "" }],
1554
+ categories: [{
1555
+ type: COLOR_CATEGORIES[colorId] ?? "accent1",
1556
+ pri: 11200
1557
+ }],
1558
+ styleLabels: [{
1559
+ name: "node0",
1560
+ fillColorList,
1561
+ lineColorList,
1562
+ effectColorList: lineColorList,
1563
+ textFillColorList,
1564
+ textLineColorList: colorId.startsWith("accent") ? { colors: [TINTED_TEXT] } : { colors: [] },
1565
+ textEffectColorList: textFillColorList
1566
+ }]
1567
+ });
1568
+ }
1569
+ /** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
1570
+ const DEFAULT_DRAWING_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><dsp:drawing xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:dsp=\"http://schemas.microsoft.com/office/drawing/2008/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><dsp:spTree><dsp:nvGrpSpPr><dsp:cNvPr id=\"0\" name=\"\"/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr><dsp:grpSpPr/></dsp:spTree></dsp:drawing>";
1571
+ //#endregion
1572
+ //#region src/smartart/smartart-collection.ts
1573
+ /**
1574
+ * Last URN segment of a custom definition's uniqueId — the id embedded in the
1575
+ * data model's doc-point type ids. Falls back to "custom" when unset.
1576
+ */
1577
+ function definitionId(definition) {
1578
+ return definition.uniqueId?.split("/").pop() || "custom";
1579
+ }
1580
+ /**
1581
+ * Manages SmartArt parts in a document.
1582
+ */
1583
+ var SmartArtCollection = class {
1584
+ map;
1585
+ constructor() {
1586
+ this.map = /* @__PURE__ */ new Map();
1587
+ }
1588
+ addSmartArt(key, data) {
1589
+ this.map.set(key, data);
1590
+ }
1591
+ get array() {
1592
+ return [...this.map.values()];
1593
+ }
1594
+ };
1595
+ //#endregion
1596
+ //#region src/smartart/tree-to-model.ts
1597
+ function stringifyDocPoint(layout, style, color) {
1598
+ const loTypeId = `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`;
1599
+ const loCatId = LAYOUT_CATEGORIES[layout] ?? "list";
1600
+ const qsTypeId = `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`;
1601
+ const qsCatId = STYLE_CATEGORIES[style] ?? "simple";
1602
+ const csTypeId = `urn:microsoft.com/office/officeart/2005/8/colors/${color}`;
1603
+ const csCatId = COLOR_CATEGORIES[color] ?? "accent1";
1604
+ return [
1605
+ "<dgm:pt modelId=\"0\" type=\"doc\">",
1606
+ `<dgm:prSet loTypeId="${escapeXml(loTypeId)}" loCatId="${escapeXml(loCatId)}" qsTypeId="${escapeXml(qsTypeId)}" qsCatId="${escapeXml(qsCatId)}" csTypeId="${escapeXml(csTypeId)}" csCatId="${escapeXml(csCatId)}" phldr="0"/>`,
1607
+ "<dgm:spPr/>",
1608
+ "<dgm:t><a:bodyPr/><a:lstStyle/><a:p/></dgm:t>",
1609
+ "</dgm:pt>"
1610
+ ].join("");
1611
+ }
1612
+ function uuid() {
1613
+ return `{${crypto.randomUUID().toUpperCase()}}`;
1614
+ }
1615
+ /**
1616
+ * Creates SmartArt data model XML from tree nodes with layout/style/color settings.
1617
+ * Returns the XML string body (no XML declaration).
1618
+ */
1619
+ const createDataModel = (nodes, layout = "default", style = "simple1", color = "accent1_2") => {
1620
+ const pointStrs = [];
1621
+ const connectionStrs = [];
1622
+ pointStrs.push(stringifyDocPoint(layout, style, color));
1623
+ for (const [i, node] of nodes.entries()) {
1624
+ const walk = (node, parentUuid, srcOrd) => {
1625
+ const nodeUuid = uuid();
1626
+ const parTransUuid = uuid();
1627
+ const sibTransUuid = uuid();
1628
+ const cxnUuid = uuid();
1629
+ pointStrs.push(stringifyTransPoint(parTransUuid, "parTrans", cxnUuid));
1630
+ pointStrs.push(stringifyTransPoint(sibTransUuid, "sibTrans", cxnUuid));
1631
+ pointStrs.push(stringifyPoint(nodeUuid, node.text));
1632
+ connectionStrs.push(stringifyConnection({
1633
+ modelId: parTransUuid,
1634
+ srcId: parentUuid,
1635
+ destId: nodeUuid,
1636
+ srcOrd,
1637
+ destOrd: 0,
1638
+ parTransId: parTransUuid,
1639
+ sibTransId: sibTransUuid
1640
+ }));
1641
+ if (node.children) for (const [j, child] of node.children.entries()) walk(child, nodeUuid, j);
1642
+ };
1643
+ walk(node, "0", i);
1644
+ }
1645
+ return stringifyDataModel(pointStrs, connectionStrs);
1646
+ };
1647
+ //#endregion
1648
+ export { stringifyDataModelOptions as C, COLOR_CATEGORIES as D, stringifyConnection as E, LAYOUT_CATEGORIES as O, stringifyDataModel as S, stringifyTransPoint as T, parseLayoutDefinition as _, getColorXml as a, withDiagramNamespaces as b, parseStyleDefinition as c, styleDefDesc as d, colorsDefDesc as f, layoutDefDesc as g, stringifyColorDefinitionPart as h, DEFAULT_DRAWING_XML as i, STYLE_CATEGORIES as k, stringifyStyleDefinition as l, stringifyColorDefinition as m, SmartArtCollection as n, getLayoutXml as o, parseColorDefinition as p, definitionId as r, getStyleXml as s, createDataModel as t, stringifyStyleDefinitionPart as u, stringifyLayoutDefinition as v, stringifyPoint as w, parseDataModelOptions as x, stringifyLayoutDefinitionPart as y };
1649
+
1650
+ //# sourceMappingURL=smartart-n1kYJ6Jg.mjs.map