@office-open/core 0.3.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.
@@ -0,0 +1,126 @@
1
+ import { Relationship, findRel, findRelsByType, getImageType, listFiles, parseRels, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap } from "./archive.mjs";
2
+ import { A as IContext, C as AttributePayload, D as IgnoreIfEmptyXmlComponent, E as EMPTY_OBJECT, M as IXmlableObject, O as XmlComponent, S as AttributeMap, T as XmlAttributeComponent, _ as stringContainerObj, a as BuilderElement, b as wrapEl, c as NumberValueElement, d as StringEnumValueElement, f as StringValueElement, g as onOffObj, h as numberValObj, i as convertToXmlComponent, j as IXmlAttribute, k as BaseXmlComponent, l as OnOffElement, m as hpsMeasureObj, n as ImportedRootElementAttributes, o as EmptyElement, p as chartAttr, r as ImportedXmlComponent, s as HpsMeasureElement, t as InitializableXmlComponent, u as StringContainer, v as stringEnumValObj, w as NextAttributeComponent, x as AttributeData, y as stringValObj } from "./_chunks/index-3uVYzs32.mjs";
3
+ import { C as universalMeasureValue, S as uCharHexNumber, _ as positiveUniversalMeasureValue, a as ThemeColor, b as signedTwipsMeasureValue, c as dateTimeValue, d as hexColorValue, f as hpsMeasureValue, g as pointMeasureValue, h as percentageValue, i as RelativeMeasure, l as decimalNumber, m as measurementOrPercentValue, n as PositivePercentage, o as ThemeFont, p as longHexNumber, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as shortHexNumber, w as unsignedDecimalNumber, x as twipsMeasureValue, y as signedHpsMeasureValue } from "./_chunks/values-BrGywpRh.mjs";
4
+ import { COLOR_CATEGORIES, Connection, DataModel, ISmartArtData, ITreeNode, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel } from "./smartart/index.mjs";
5
+
6
+ //#region src/converters.d.ts
7
+ /**
8
+ * OOXML unit conversion utilities.
9
+ *
10
+ * @module
11
+ */
12
+ /**
13
+ * Converts millimeters to TWIP (twentieths of a point).
14
+ */
15
+ declare const convertMillimetersToTwip: (millimeters: number) => number;
16
+ /**
17
+ * Converts inches to TWIP (twentieths of a point).
18
+ */
19
+ declare const convertInchesToTwip: (inches: number) => number;
20
+ /**
21
+ * Converts pixels to EMU (96 DPI).
22
+ */
23
+ declare const convertPixelsToEmu: (pixels: number) => number;
24
+ /**
25
+ * Converts EMU to pixels (96 DPI).
26
+ */
27
+ declare const convertEmuToPixels: (emus: number) => number;
28
+ /**
29
+ * Converts inches to EMU.
30
+ */
31
+ declare const convertInchesToEmu: (inches: number) => number;
32
+ /**
33
+ * Converts EMU to inches.
34
+ */
35
+ declare const convertEmuToInches: (emus: number) => number;
36
+ /**
37
+ * Converts points to EMU.
38
+ */
39
+ declare const convertPointsToEmu: (points: number) => number;
40
+ /**
41
+ * Converts EMU to points.
42
+ */
43
+ declare const convertEmuToPoints: (emus: number) => number;
44
+ //#endregion
45
+ //#region src/id-generators.d.ts
46
+ /**
47
+ * A function that generates unique sequential numeric IDs.
48
+ */
49
+ type UniqueNumericIdCreator = () => number;
50
+ /**
51
+ * Creates a unique numeric ID generator with sequential numbering.
52
+ */
53
+ declare const uniqueNumericIdCreator: (initial?: number) => UniqueNumericIdCreator;
54
+ /**
55
+ * Generates a unique lowercase alphanumeric ID using nanoid.
56
+ */
57
+ declare const uniqueId: () => string;
58
+ /**
59
+ * Generates a SHA-1 hash of the provided data.
60
+ */
61
+ declare const hashedId: (data: Buffer | string | Uint8Array | ArrayBuffer) => string;
62
+ /**
63
+ * Generates a UUID v4-style unique identifier.
64
+ */
65
+ declare const uniqueUuid: () => string;
66
+ //#endregion
67
+ //#region src/output-type.d.ts
68
+ /**
69
+ * Output type definitions for OOXML document export.
70
+ *
71
+ * @module
72
+ */
73
+ interface OutputByType {
74
+ readonly base64: string;
75
+ readonly string: string;
76
+ readonly text: string;
77
+ readonly binarystring: string;
78
+ readonly array: readonly number[];
79
+ readonly uint8array: Uint8Array;
80
+ readonly arraybuffer: ArrayBuffer;
81
+ readonly blob: Blob;
82
+ readonly nodebuffer: Buffer;
83
+ }
84
+ type OutputType = keyof OutputByType;
85
+ //#endregion
86
+ //#region src/opc/app-properties.d.ts
87
+ declare class AppProperties extends XmlComponent {
88
+ constructor();
89
+ }
90
+ //#endregion
91
+ //#region src/opc/relationships.d.ts
92
+ type RelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" | "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors" | "http://schemas.microsoft.com/office/2007/relationships/diagramLayout" | "http://schemas.microsoft.com/office/2007/relationships/diagramStyle" | "http://schemas.microsoft.com/office/2007/relationships/diagramColors" | "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" | "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video" | "http://schemas.microsoft.com/office/2007/relationships/media";
93
+ declare const TargetModeType: {
94
+ readonly EXTERNAL: "External";
95
+ };
96
+ declare class Relationships extends BaseXmlComponent {
97
+ private entries;
98
+ constructor();
99
+ addRelationship(id: number | string, type: RelationshipType, target: string, targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType]): void;
100
+ get RelationshipCount(): number;
101
+ prepForXml(_context: IContext): IXmlableObject;
102
+ }
103
+ //#endregion
104
+ //#region src/formatter.d.ts
105
+ /**
106
+ * Converts an XmlComponent tree into a serializable XML object.
107
+ */
108
+ declare class Formatter {
109
+ format<T extends IContext = IContext>(input: BaseXmlComponent, context?: T): IXmlableObject;
110
+ }
111
+ //#endregion
112
+ //#region src/core-properties.d.ts
113
+ interface CoreProperties {
114
+ title?: string;
115
+ subject?: string;
116
+ creator?: string;
117
+ keywords?: string;
118
+ description?: string;
119
+ lastModifiedBy?: string;
120
+ revision?: string;
121
+ created?: string;
122
+ modified?: string;
123
+ }
124
+ declare function parseCoreProperties(zip: Map<string, Uint8Array>): CoreProperties;
125
+ //#endregion
126
+ export { AppProperties, AttributeData, AttributeMap, AttributePayload, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, CoreProperties, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IContext, ISmartArtData, ITreeNode, IXmlAttribute, IXmlableObject, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, NumberValueElement, OnOffElement, OutputByType, OutputType, Percentage, Point, PositivePercentage, PositiveUniversalMeasure, Relationship, type RelationshipType, Relationships, RelativeMeasure, STYLE_CATEGORIES, SmartArtCollection, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, ThemeColor, ThemeFont, TransPoint, UniqueNumericIdCreator, UniversalMeasure, XmlAttributeComponent, XmlComponent, chartAttr, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertPixelsToEmu, convertPointsToEmu, convertToXmlComponent, createDataModel, dateTimeValue, decimalNumber, eighthPointMeasureValue, findRel, findRelsByType, getImageType, hashedId, hexColorValue, hpsMeasureObj, hpsMeasureValue, listFiles, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseCoreProperties, parseRels, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, readBinaryFromZip, readTextFromZip, readXmlFromZip, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, stringContainerObj, stringEnumValObj, stringValObj, twipsMeasureValue, uCharHexNumber, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipToMap, wrapEl };
package/dist/index.mjs ADDED
@@ -0,0 +1,118 @@
1
+ import { C as EMPTY_OBJECT, E as BaseXmlComponent, S as XmlAttributeComponent, T as XmlComponent, _ as stringContainerObj, a as BuilderElement, b as wrapEl, c as NumberValueElement, d as StringEnumValueElement, f as StringValueElement, g as onOffObj, h as numberValObj, i as convertToXmlComponent, l as OnOffElement, m as hpsMeasureObj, n as ImportedRootElementAttributes, o as EmptyElement, p as chartAttr, r as ImportedXmlComponent, s as HpsMeasureElement, t as InitializableXmlComponent, u as StringContainer, v as stringEnumValObj, w as IgnoreIfEmptyXmlComponent, x as NextAttributeComponent, y as stringValObj } from "./_chunks/xml-components-DazgCiyL.mjs";
2
+ import { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber } from "./values.mjs";
3
+ import { a as convertEmuToInches, c as convertInchesToEmu, d as convertPixelsToEmu, f as convertPointsToEmu, i as uniqueUuid, l as convertInchesToTwip, n as uniqueId, o as convertEmuToPixels, r as uniqueNumericIdCreator, s as convertEmuToPoints, t as hashedId, u as convertMillimetersToTwip } from "./_chunks/id-generators-Ch07cHW1.mjs";
4
+ import { COLOR_CATEGORIES, Connection, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel } from "./smartart/index.mjs";
5
+ import { findRel, findRelsByType, getImageType, listFiles, parseRels, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap } from "./archive.mjs";
6
+ import { textOf } from "@office-open/xml";
7
+ //#region src/opc/app-properties.ts
8
+ var AppPropertiesAttributes = class extends XmlAttributeComponent {
9
+ xmlKeys = {
10
+ vt: "xmlns:vt",
11
+ xmlns: "xmlns"
12
+ };
13
+ };
14
+ var AppProperties = class extends XmlComponent {
15
+ constructor() {
16
+ super("Properties");
17
+ this.root.push(new AppPropertiesAttributes({
18
+ vt: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
19
+ xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
20
+ }));
21
+ }
22
+ };
23
+ //#endregion
24
+ //#region src/opc/relationships.ts
25
+ const TargetModeType = { EXTERNAL: "External" };
26
+ const RELS_ATTRS = { _attr: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } };
27
+ var Relationships = class extends BaseXmlComponent {
28
+ entries = [];
29
+ constructor() {
30
+ super("Relationships");
31
+ }
32
+ addRelationship(id, type, target, targetMode) {
33
+ this.entries.push({
34
+ id: `rId${id}`,
35
+ type,
36
+ target,
37
+ targetMode
38
+ });
39
+ }
40
+ get RelationshipCount() {
41
+ return this.entries.length;
42
+ }
43
+ prepForXml(_context) {
44
+ const children = [RELS_ATTRS];
45
+ for (const e of this.entries) {
46
+ const attrs = {
47
+ Id: e.id,
48
+ Type: e.type,
49
+ Target: e.target
50
+ };
51
+ if (e.targetMode) attrs.TargetMode = e.targetMode;
52
+ children.push({ Relationship: { _attr: attrs } });
53
+ }
54
+ if (children.length === 1 && "_attr" in children[0]) return { Relationships: children[0] };
55
+ return { Relationships: children };
56
+ }
57
+ };
58
+ //#endregion
59
+ //#region src/formatter.ts
60
+ /**
61
+ * Converts an XmlComponent tree into a serializable XML object.
62
+ */
63
+ var Formatter = class {
64
+ format(input, context = { stack: [] }) {
65
+ const output = input.prepForXml(context);
66
+ if (output) return output;
67
+ throw new Error("XMLComponent did not format correctly");
68
+ }
69
+ };
70
+ //#endregion
71
+ //#region src/core-properties.ts
72
+ const FIELD_MAP = [
73
+ {
74
+ name: "dc:title",
75
+ key: "title"
76
+ },
77
+ {
78
+ name: "dc:subject",
79
+ key: "subject"
80
+ },
81
+ {
82
+ name: "dc:creator",
83
+ key: "creator"
84
+ },
85
+ {
86
+ name: "dc:description",
87
+ key: "description"
88
+ },
89
+ {
90
+ name: "cp:keywords",
91
+ key: "keywords"
92
+ },
93
+ {
94
+ name: "cp:lastModifiedBy",
95
+ key: "lastModifiedBy"
96
+ }
97
+ ];
98
+ function parseCoreProperties(zip) {
99
+ const xml = readXmlFromZip(zip, "docProps/core.xml");
100
+ if (!xml) return {};
101
+ const props = {};
102
+ for (const field of FIELD_MAP) {
103
+ const el = xml.elements?.find((e) => e.name === field.name);
104
+ const value = textOf(el) || void 0;
105
+ if (value) props[field.key] = value;
106
+ }
107
+ const revEl = xml.elements?.find((e) => e.name === "cp:revision");
108
+ if (revEl) {
109
+ const rev = textOf(revEl);
110
+ if (rev) {
111
+ const n = Number(rev);
112
+ if (!isNaN(n)) props.revision = rev;
113
+ }
114
+ }
115
+ return props;
116
+ }
117
+ //#endregion
118
+ export { AppProperties, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, NumberValueElement, OnOffElement, Point, Relationships, STYLE_CATEGORIES, SmartArtCollection, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, ThemeColor, ThemeFont, TransPoint, XmlAttributeComponent, XmlComponent, chartAttr, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertPixelsToEmu, convertPointsToEmu, convertToXmlComponent, createDataModel, dateTimeValue, decimalNumber, eighthPointMeasureValue, findRel, findRelsByType, getImageType, hashedId, hexColorValue, hpsMeasureObj, hpsMeasureValue, listFiles, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseCoreProperties, parseRels, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, readBinaryFromZip, readTextFromZip, readXmlFromZip, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, stringContainerObj, stringEnumValObj, stringValObj, twipsMeasureValue, uCharHexNumber, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipToMap, wrapEl };
@@ -0,0 +1,69 @@
1
+ import { O as XmlComponent } from "../_chunks/index-3uVYzs32.mjs";
2
+
3
+ //#region src/smartart/categories.d.ts
4
+ /** Layout ID → OOXML category type */
5
+ declare const LAYOUT_CATEGORIES: Record<string, string>;
6
+ /** Style ID → OOXML category type */
7
+ declare const STYLE_CATEGORIES: Record<string, string>;
8
+ /** Color ID → OOXML category type */
9
+ declare const COLOR_CATEGORIES: Record<string, string>;
10
+ //#endregion
11
+ //#region src/smartart/data-model/connection.d.ts
12
+ /**
13
+ * dgm:cxn — SmartArt data model connection (edge).
14
+ */
15
+ declare class Connection extends XmlComponent {
16
+ constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string);
17
+ }
18
+ //#endregion
19
+ //#region src/smartart/data-model/data-model.d.ts
20
+ /**
21
+ * CT_DataModel — the complete data model for a SmartArt diagram.
22
+ */
23
+ declare class DataModel extends XmlComponent {
24
+ constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
25
+ }
26
+ //#endregion
27
+ //#region src/smartart/data-model/point.d.ts
28
+ /**
29
+ * dgm:pt — SmartArt data model point (node).
30
+ */
31
+ declare class Point extends XmlComponent {
32
+ constructor(modelId: string, text: string, type?: string);
33
+ }
34
+ /**
35
+ * Transition point (parTrans or sibTrans) — no text body, references a connection.
36
+ */
37
+ declare class TransPoint extends XmlComponent {
38
+ constructor(modelId: string, type: string, cxnId: string);
39
+ }
40
+ //#endregion
41
+ //#region src/smartart/smartart-collection.d.ts
42
+ interface ISmartArtData {
43
+ readonly key: string;
44
+ readonly dataModel: DataModel;
45
+ readonly layout: string;
46
+ readonly style: string;
47
+ readonly color: string;
48
+ }
49
+ /**
50
+ * Manages SmartArt parts in a document.
51
+ */
52
+ declare class SmartArtCollection {
53
+ private readonly map;
54
+ constructor();
55
+ addSmartArt(key: string, data: ISmartArtData): void;
56
+ get Array(): readonly ISmartArtData[];
57
+ }
58
+ //#endregion
59
+ //#region src/smartart/tree-to-model.d.ts
60
+ interface ITreeNode {
61
+ readonly text: string;
62
+ readonly children?: readonly ITreeNode[];
63
+ }
64
+ /**
65
+ * Creates a DataModel from tree nodes with layout/style/color settings.
66
+ */
67
+ declare const createDataModel: (nodes: readonly ITreeNode[], layout?: string, style?: string, color?: string) => DataModel;
68
+ //#endregion
69
+ export { COLOR_CATEGORIES, Connection, DataModel, ISmartArtData, ITreeNode, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel };
@@ -0,0 +1,304 @@
1
+ import { T as XmlComponent, p as chartAttr } from "../_chunks/xml-components-DazgCiyL.mjs";
2
+ //#region src/smartart/categories.ts
3
+ /** Layout ID → OOXML category type */
4
+ const LAYOUT_CATEGORIES = {
5
+ default: "list",
6
+ list1: "list",
7
+ list2: "list",
8
+ vList2: "list",
9
+ hList1: "list",
10
+ pList1: "list",
11
+ process1: "process",
12
+ process2: "process",
13
+ process3: "process",
14
+ process4: "process",
15
+ chevron1: "process",
16
+ chevron2: "process",
17
+ arrow1: "process",
18
+ arrow2: "process",
19
+ cycle1: "cycle",
20
+ cycle2: "cycle",
21
+ cycle3: "cycle",
22
+ cycle4: "cycle",
23
+ cycle5: "cycle",
24
+ hierarchy1: "hier",
25
+ hierarchy2: "hier",
26
+ hierarchy3: "hier",
27
+ hierarchy4: "hier",
28
+ orgChart1: "hier",
29
+ pyramid1: "pyramid",
30
+ pyramid2: "pyramid",
31
+ pyramid3: "pyramid",
32
+ matrix1: "matrix",
33
+ matrix2: "matrix",
34
+ matrix3: "matrix",
35
+ radial1: "rel",
36
+ radial2: "rel",
37
+ radial3: "rel",
38
+ venn1: "rel",
39
+ funnel1: "rel",
40
+ balance1: "rel",
41
+ gear1: "rel",
42
+ constOrg1: "rel",
43
+ oppId1: "rel"
44
+ };
45
+ /** Style ID → OOXML category type */
46
+ const STYLE_CATEGORIES = {
47
+ simple1: "simple",
48
+ simple2: "simple",
49
+ simple3: "simple",
50
+ simple4: "simple",
51
+ simple5: "simple",
52
+ moderate1: "moderate",
53
+ moderate2: "moderate",
54
+ moderate3: "moderate",
55
+ moderate4: "moderate",
56
+ polished1: "polished",
57
+ polished2: "polished",
58
+ polished3: "polished",
59
+ polished4: "polished",
60
+ professional1: "professional",
61
+ professional2: "professional",
62
+ professional3: "professional",
63
+ professional4: "professional",
64
+ cartoon1: "cartoon",
65
+ cartoon2: "cartoon",
66
+ cartoon3: "cartoon",
67
+ cartoon4: "cartoon",
68
+ powdery1: "powdery",
69
+ powdery2: "powdery",
70
+ powdery3: "powdery",
71
+ powdery4: "powdery",
72
+ burnt1: "burnt",
73
+ burnt2: "burnt",
74
+ burnt3: "burnt",
75
+ burnt4: "burnt"
76
+ };
77
+ /** Color ID → OOXML category type */
78
+ const COLOR_CATEGORIES = {
79
+ accent1_2: "accent1",
80
+ accent2_2: "accent2",
81
+ accent3_2: "accent3",
82
+ accent4_2: "accent4",
83
+ accent5_2: "accent5",
84
+ accent6_2: "accent6",
85
+ colorful1: "colorful",
86
+ colorful2: "colorful",
87
+ colorful3: "colorful",
88
+ colorful4: "colorful",
89
+ dark1: "dark",
90
+ dark2: "dark",
91
+ primary1: "primary",
92
+ primary2: "primary",
93
+ gray1: "gray",
94
+ gray2: "gray"
95
+ };
96
+ //#endregion
97
+ //#region src/smartart/data-model/connection.ts
98
+ /**
99
+ * dgm:cxn — SmartArt data model connection (edge).
100
+ */
101
+ var Connection = class extends XmlComponent {
102
+ constructor(modelId, srcId, destId, type, srcOrd = 0, destOrd = 0, parTransId, sibTransId) {
103
+ super("dgm:cxn");
104
+ const attrs = {
105
+ modelId,
106
+ srcId,
107
+ destId,
108
+ srcOrd,
109
+ destOrd
110
+ };
111
+ if (type) attrs.type = type;
112
+ if (parTransId) attrs.parTransId = parTransId;
113
+ if (sibTransId) attrs.sibTransId = sibTransId;
114
+ this.root.push(chartAttr(attrs));
115
+ }
116
+ };
117
+ //#endregion
118
+ //#region src/smartart/data-model/data-model.ts
119
+ /**
120
+ * CT_DataModel — the complete data model for a SmartArt diagram.
121
+ */
122
+ var DataModel = class extends XmlComponent {
123
+ constructor(points, connections) {
124
+ super("dgm:dataModel");
125
+ this.root.push(chartAttr({
126
+ "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
127
+ "xmlns:dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram"
128
+ }));
129
+ const ptLst = new class extends XmlComponent {
130
+ constructor() {
131
+ super("dgm:ptLst");
132
+ }
133
+ }();
134
+ for (const pt of points) ptLst["root"].push(pt);
135
+ this.root.push(ptLst);
136
+ const cxnLst = new class extends XmlComponent {
137
+ constructor() {
138
+ super("dgm:cxnLst");
139
+ }
140
+ }();
141
+ for (const cxn of connections) cxnLst["root"].push(cxn);
142
+ this.root.push(cxnLst);
143
+ this.root.push(new EmptyElement$2("dgm:bg"));
144
+ this.root.push(new EmptyElement$2("dgm:whole"));
145
+ }
146
+ };
147
+ var EmptyElement$2 = class extends XmlComponent {
148
+ constructor(tag) {
149
+ super(tag);
150
+ }
151
+ };
152
+ //#endregion
153
+ //#region src/smartart/data-model/point.ts
154
+ /**
155
+ * dgm:pt — SmartArt data model point (node).
156
+ */
157
+ var Point = class extends XmlComponent {
158
+ constructor(modelId, text, type = "node") {
159
+ super("dgm:pt");
160
+ this.root.push(chartAttr({
161
+ modelId,
162
+ type
163
+ }));
164
+ this.root.push(new PointText(text));
165
+ }
166
+ };
167
+ /**
168
+ * Transition point (parTrans or sibTrans) — no text body, references a connection.
169
+ */
170
+ var TransPoint = class extends XmlComponent {
171
+ constructor(modelId, type, cxnId) {
172
+ super("dgm:pt");
173
+ this.root.push(chartAttr({
174
+ modelId,
175
+ type,
176
+ cxnId
177
+ }));
178
+ this.root.push(new EmptyElement$1("dgm:spPr"));
179
+ }
180
+ };
181
+ var EmptyElement$1 = class extends XmlComponent {
182
+ constructor(tag) {
183
+ super(tag);
184
+ }
185
+ };
186
+ /**
187
+ * dgm:t — text body within a point.
188
+ */
189
+ var PointText = class extends XmlComponent {
190
+ constructor(text) {
191
+ super("dgm:t");
192
+ this.root.push(new EmptyElement$1("a:bodyPr"));
193
+ this.root.push(new EmptyElement$1("a:lstStyle"));
194
+ const p = new EmptyElement$1("a:p");
195
+ if (text) {
196
+ const t = new class extends XmlComponent {
197
+ constructor() {
198
+ super("a:t");
199
+ }
200
+ }();
201
+ t["root"].push(text);
202
+ const r = new class extends XmlComponent {
203
+ constructor() {
204
+ super("a:r");
205
+ }
206
+ }();
207
+ r["root"].push(t);
208
+ p["root"].push(r);
209
+ }
210
+ this.root.push(p);
211
+ }
212
+ };
213
+ //#endregion
214
+ //#region src/smartart/smartart-collection.ts
215
+ /**
216
+ * Manages SmartArt parts in a document.
217
+ */
218
+ var SmartArtCollection = class {
219
+ map;
220
+ constructor() {
221
+ this.map = /* @__PURE__ */ new Map();
222
+ }
223
+ addSmartArt(key, data) {
224
+ this.map.set(key, data);
225
+ }
226
+ get Array() {
227
+ return [...this.map.values()];
228
+ }
229
+ };
230
+ //#endregion
231
+ //#region src/smartart/tree-to-model.ts
232
+ function createDocPoint(layout, style, color) {
233
+ const pt = new class extends XmlComponent {
234
+ constructor() {
235
+ super("dgm:pt");
236
+ }
237
+ }();
238
+ pt["root"].push(chartAttr({
239
+ modelId: 0,
240
+ type: "doc"
241
+ }));
242
+ const prSet = new class extends XmlComponent {
243
+ constructor() {
244
+ super("dgm:prSet");
245
+ }
246
+ }();
247
+ prSet["root"].push(chartAttr({
248
+ loTypeId: `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`,
249
+ loCatId: LAYOUT_CATEGORIES[layout] ?? "list",
250
+ qsTypeId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`,
251
+ qsCatId: STYLE_CATEGORIES[style] ?? "simple",
252
+ csTypeId: `urn:microsoft.com/office/officeart/2005/8/colors/${color}`,
253
+ csCatId: COLOR_CATEGORIES[color] ?? "accent1",
254
+ phldr: "0"
255
+ }));
256
+ pt["root"].push(prSet);
257
+ pt["root"].push(new EmptyElement("dgm:spPr"));
258
+ pt["root"].push(createEmptyTextBody());
259
+ return pt;
260
+ }
261
+ function createEmptyTextBody() {
262
+ const t = new class extends XmlComponent {
263
+ constructor() {
264
+ super("dgm:t");
265
+ }
266
+ }();
267
+ t["root"].push(new EmptyElement("a:bodyPr"));
268
+ t["root"].push(new EmptyElement("a:lstStyle"));
269
+ t["root"].push(new EmptyElement("a:p"));
270
+ return t;
271
+ }
272
+ var EmptyElement = class extends XmlComponent {
273
+ constructor(tag) {
274
+ super(tag);
275
+ }
276
+ };
277
+ function uuid() {
278
+ return `{${crypto.randomUUID().toUpperCase()}}`;
279
+ }
280
+ /**
281
+ * Creates a DataModel from tree nodes with layout/style/color settings.
282
+ */
283
+ const createDataModel = (nodes, layout = "default", style = "simple1", color = "accent1_2") => {
284
+ const points = [];
285
+ const connections = [];
286
+ points.push(createDocPoint(layout, style, color));
287
+ for (let i = 0; i < nodes.length; i++) {
288
+ const walk = (node, parentUuid, srcOrd) => {
289
+ const nodeUuid = uuid();
290
+ const parTransUuid = uuid();
291
+ const sibTransUuid = uuid();
292
+ const cxnUuid = uuid();
293
+ points.push(new TransPoint(parTransUuid, "parTrans", cxnUuid));
294
+ points.push(new TransPoint(sibTransUuid, "sibTrans", cxnUuid));
295
+ points.push(new Point(nodeUuid, node.text));
296
+ connections.push(new Connection(parTransUuid, parentUuid, nodeUuid, void 0, srcOrd, 0, parTransUuid, sibTransUuid));
297
+ if (node.children) for (let j = 0; j < node.children.length; j++) walk(node.children[j], nodeUuid, j);
298
+ };
299
+ walk(nodes[i], "0", i);
300
+ }
301
+ return new DataModel(points, connections);
302
+ };
303
+ //#endregion
304
+ export { COLOR_CATEGORIES, Connection, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel };
@@ -0,0 +1,2 @@
1
+ import { C as universalMeasureValue, S as uCharHexNumber, _ as positiveUniversalMeasureValue, a as ThemeColor, b as signedTwipsMeasureValue, c as dateTimeValue, d as hexColorValue, f as hpsMeasureValue, g as pointMeasureValue, h as percentageValue, i as RelativeMeasure, l as decimalNumber, m as measurementOrPercentValue, n as PositivePercentage, o as ThemeFont, p as longHexNumber, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as shortHexNumber, w as unsignedDecimalNumber, x as twipsMeasureValue, y as signedHpsMeasureValue } from "./_chunks/values-BrGywpRh.mjs";
2
+ export { Percentage, PositivePercentage, PositiveUniversalMeasure, RelativeMeasure, ThemeColor, ThemeFont, UniversalMeasure, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };