@syncfusion/ej2-office-common 35.1.37

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 (147) hide show
  1. package/.eslintrc.json +263 -0
  2. package/.prettierrc.json +5 -0
  3. package/README.md +167 -0
  4. package/api-extractor.json +35 -0
  5. package/core.js +4 -0
  6. package/dist/ej2-office-common.umd.min.js +11 -0
  7. package/dist/ej2-office-common.umd.min.js.map +1 -0
  8. package/dist/es6/ej2-office-common.es2015.js +6585 -0
  9. package/dist/es6/ej2-office-common.es2015.js.map +1 -0
  10. package/dist/es6/ej2-office-common.es5.js +7955 -0
  11. package/dist/es6/ej2-office-common.es5.js.map +1 -0
  12. package/dist/global/ej2-office-common.min.js +11 -0
  13. package/dist/global/ej2-office-common.min.js.map +1 -0
  14. package/dist/global/index.d.ts +14 -0
  15. package/encryption.js +4 -0
  16. package/features.js +4 -0
  17. package/global.json +6 -0
  18. package/index.js +4 -0
  19. package/license +10 -0
  20. package/nuget.config +7 -0
  21. package/package.json +23 -0
  22. package/src/all.d.ts +41 -0
  23. package/src/all.js +38 -0
  24. package/src/core/index.d.ts +6 -0
  25. package/src/core/index.js +6 -0
  26. package/src/core/xml/index.d.ts +7 -0
  27. package/src/core/xml/index.js +6 -0
  28. package/src/core/xml/model.d.ts +71 -0
  29. package/src/core/xml/model.js +20 -0
  30. package/src/encryption/agile-constants.d.ts +61 -0
  31. package/src/encryption/agile-constants.js +71 -0
  32. package/src/encryption/agile-encryption-info.d.ts +46 -0
  33. package/src/encryption/agile-encryption-info.js +333 -0
  34. package/src/encryption/agile-password.d.ts +8 -0
  35. package/src/encryption/agile-password.js +58 -0
  36. package/src/encryption/cfb-reader.d.ts +11 -0
  37. package/src/encryption/cfb-reader.js +345 -0
  38. package/src/encryption/crypto-primitives.d.ts +74 -0
  39. package/src/encryption/crypto-primitives.js +302 -0
  40. package/src/encryption/decrypt-encrypted-package.d.ts +16 -0
  41. package/src/encryption/decrypt-encrypted-package.js +138 -0
  42. package/src/encryption/encryption-info-xml.d.ts +21 -0
  43. package/src/encryption/encryption-info-xml.js +282 -0
  44. package/src/encryption/errors.d.ts +66 -0
  45. package/src/encryption/errors.js +124 -0
  46. package/src/encryption/index.d.ts +35 -0
  47. package/src/encryption/index.js +100 -0
  48. package/src/features/diagrams/constants.d.ts +83 -0
  49. package/src/features/diagrams/constants.js +101 -0
  50. package/src/features/diagrams/diagram-data-model.d.ts +148 -0
  51. package/src/features/diagrams/diagram-data-model.js +446 -0
  52. package/src/features/diagrams/diagram-parsers.d.ts +28 -0
  53. package/src/features/diagrams/diagram-parsers.js +182 -0
  54. package/src/features/diagrams/diagram-serializers.d.ts +20 -0
  55. package/src/features/diagrams/diagram-serializers.js +110 -0
  56. package/src/features/diagrams/diagram-views.d.ts +60 -0
  57. package/src/features/diagrams/diagram-views.js +213 -0
  58. package/src/features/diagrams/element-tree.d.ts +55 -0
  59. package/src/features/diagrams/element-tree.js +197 -0
  60. package/src/features/diagrams/errors.d.ts +17 -0
  61. package/src/features/diagrams/errors.js +59 -0
  62. package/src/features/diagrams/index.d.ts +17 -0
  63. package/src/features/diagrams/index.js +17 -0
  64. package/src/features/diagrams/smart-art-catalog.d.ts +107 -0
  65. package/src/features/diagrams/smart-art-catalog.js +422 -0
  66. package/src/features/diagrams/smart-art-diagram.d.ts +96 -0
  67. package/src/features/diagrams/smart-art-diagram.js +258 -0
  68. package/src/features/index.d.ts +11 -0
  69. package/src/features/index.js +11 -0
  70. package/src/features/ink/constants.d.ts +54 -0
  71. package/src/features/ink/constants.js +54 -0
  72. package/src/features/ink/index.d.ts +18 -0
  73. package/src/features/ink/index.js +15 -0
  74. package/src/features/ink/ink-effects.d.ts +35 -0
  75. package/src/features/ink/ink-effects.js +45 -0
  76. package/src/features/ink/ink-model.d.ts +237 -0
  77. package/src/features/ink/ink-model.js +406 -0
  78. package/src/features/ink/ink-parser.d.ts +59 -0
  79. package/src/features/ink/ink-parser.js +671 -0
  80. package/src/features/ink/ink-serializer.d.ts +16 -0
  81. package/src/features/ink/ink-serializer.js +281 -0
  82. package/src/features/ink/ink-units.d.ts +33 -0
  83. package/src/features/ink/ink-units.js +92 -0
  84. package/src/features/ink/ink-xml.d.ts +26 -0
  85. package/src/features/ink/ink-xml.js +165 -0
  86. package/src/features/ink/trace-codec.d.ts +127 -0
  87. package/src/features/ink/trace-codec.js +266 -0
  88. package/src/features/mathml/constants.d.ts +47 -0
  89. package/src/features/mathml/constants.js +47 -0
  90. package/src/features/mathml/errors.d.ts +50 -0
  91. package/src/features/mathml/errors.js +69 -0
  92. package/src/features/mathml/index.d.ts +30 -0
  93. package/src/features/mathml/index.js +22 -0
  94. package/src/features/mathml/math-factory.d.ts +26 -0
  95. package/src/features/mathml/math-factory.js +568 -0
  96. package/src/features/mathml/model/controls.d.ts +896 -0
  97. package/src/features/mathml/model/controls.js +1541 -0
  98. package/src/features/mathml/model/enums.d.ts +153 -0
  99. package/src/features/mathml/model/enums.js +133 -0
  100. package/src/features/mathml/model/math-element.d.ts +173 -0
  101. package/src/features/mathml/model/math-element.js +315 -0
  102. package/src/features/mathml/model/roots.d.ts +82 -0
  103. package/src/features/mathml/model/roots.js +177 -0
  104. package/src/features/mathml/openxml.d.ts +56 -0
  105. package/src/features/mathml/openxml.js +87 -0
  106. package/src/features/mathml/parse/math-parser.d.ts +43 -0
  107. package/src/features/mathml/parse/math-parser.js +636 -0
  108. package/src/features/mathml/serialize/math-serializer.d.ts +34 -0
  109. package/src/features/mathml/serialize/math-serializer.js +749 -0
  110. package/src/features/smart-art/diagram-xml.d.ts +63 -0
  111. package/src/features/smart-art/diagram-xml.js +459 -0
  112. package/src/features/smart-art/errors.d.ts +24 -0
  113. package/src/features/smart-art/errors.js +47 -0
  114. package/src/features/smart-art/index.d.ts +26 -0
  115. package/src/features/smart-art/index.js +26 -0
  116. package/src/features/smart-art/minimal-samples.d.ts +18 -0
  117. package/src/features/smart-art/minimal-samples.js +40 -0
  118. package/src/features/smart-art/mutators.d.ts +60 -0
  119. package/src/features/smart-art/mutators.js +566 -0
  120. package/src/features/smart-art/namespaces.d.ts +153 -0
  121. package/src/features/smart-art/namespaces.js +163 -0
  122. package/src/features/smart-art/package-graph.d.ts +61 -0
  123. package/src/features/smart-art/package-graph.js +413 -0
  124. package/src/features/smart-art/parse-colors.d.ts +19 -0
  125. package/src/features/smart-art/parse-colors.js +39 -0
  126. package/src/features/smart-art/parse-data.d.ts +21 -0
  127. package/src/features/smart-art/parse-data.js +121 -0
  128. package/src/features/smart-art/parse-layout.d.ts +20 -0
  129. package/src/features/smart-art/parse-layout.js +40 -0
  130. package/src/features/smart-art/parse-rel-ids.d.ts +71 -0
  131. package/src/features/smart-art/parse-rel-ids.js +233 -0
  132. package/src/features/smart-art/parse-style.d.ts +19 -0
  133. package/src/features/smart-art/parse-style.js +39 -0
  134. package/src/features/smart-art/point-text.d.ts +80 -0
  135. package/src/features/smart-art/point-text.js +424 -0
  136. package/src/features/smart-art/register.d.ts +33 -0
  137. package/src/features/smart-art/register.js +95 -0
  138. package/src/features/smart-art/serialize.d.ts +40 -0
  139. package/src/features/smart-art/serialize.js +48 -0
  140. package/src/features/smart-art/types.d.ts +403 -0
  141. package/src/features/smart-art/types.js +28 -0
  142. package/src/global.js +1 -0
  143. package/src/index.d.ts +21 -0
  144. package/src/index.js +22 -0
  145. package/tsconfig.build.json +13 -0
  146. package/tsconfig.harness.json +32 -0
  147. package/tslint.json +111 -0
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Typed errors for diagram parse / model / catalog operations.
3
+ * Load of recoverable diagram damage MUST NOT throw at package level;
4
+ * parsers of a single part MAY throw DiagramParseError for that part.
5
+ */
6
+ var __extends = (this && this.__extends) || (function () {
7
+ var extendStatics = function (d, b) {
8
+ extendStatics = Object.setPrototypeOf ||
9
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
11
+ return extendStatics(d, b);
12
+ };
13
+ return function (d, b) {
14
+ extendStatics(d, b);
15
+ function __() { this.constructor = d; }
16
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
+ };
18
+ })();
19
+ var DiagramError = /** @class */ (function (_super) {
20
+ __extends(DiagramError, _super);
21
+ function DiagramError(code, message) {
22
+ var _newTarget = this.constructor;
23
+ var _this = _super.call(this, message) || this;
24
+ _this.name = 'DiagramError';
25
+ _this.code = code;
26
+ // ES5 / AMD emit: restore prototype so `instanceof` works in browsers.
27
+ Object.setPrototypeOf(_this, _newTarget.prototype);
28
+ return _this;
29
+ }
30
+ return DiagramError;
31
+ }(Error));
32
+ export { DiagramError };
33
+ var DiagramParseError = /** @class */ (function (_super) {
34
+ __extends(DiagramParseError, _super);
35
+ function DiagramParseError(code, message) {
36
+ var _newTarget = this.constructor;
37
+ var _this = _super.call(this, code, message) || this;
38
+ _this.name = 'DiagramParseError';
39
+ Object.setPrototypeOf(_this, _newTarget.prototype);
40
+ return _this;
41
+ }
42
+ return DiagramParseError;
43
+ }(DiagramError));
44
+ export { DiagramParseError };
45
+ var DiagramModelError = /** @class */ (function (_super) {
46
+ __extends(DiagramModelError, _super);
47
+ function DiagramModelError(code, message) {
48
+ var _newTarget = this.constructor;
49
+ var _this = _super.call(this, code, message) || this;
50
+ _this.name = 'DiagramModelError';
51
+ Object.setPrototypeOf(_this, _newTarget.prototype);
52
+ return _this;
53
+ }
54
+ return DiagramModelError;
55
+ }(DiagramError));
56
+ export { DiagramModelError };
57
+ export function isDiagramError(value) {
58
+ return value instanceof DiagramError;
59
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Public surface: `@syncfusion/ej2-office-common/diagrams`
3
+ *
4
+ * SmartArt / DrawingML diagram parser, model, serializer, and catalog.
5
+ * TASK-9008. Host wiring for docx is TASK-9009.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { A_NAMESPACE, A_NAMESPACE_STRICT, DGM14_NAMESPACE, DGM14_RECOLOR_IMG_EXT_URI, DGM_NAMESPACE, DGM_NAMESPACE_STRICT, DIAGRAMS_FEATURE_ID, DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_COLORS_RELATIONSHIP_TYPE, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_DATA_RELATIONSHIP_TYPE, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_RELATIONSHIP_TYPE, DIAGRAM_GRAPHIC_DATA_URI, DIAGRAM_GRAPHIC_DATA_URI_STRICT, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_LAYOUT_RELATIONSHIP_TYPE, DIAGRAM_QUICK_STYLE_CONTENT_TYPE, DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE, DSP_NAMESPACE, isANamespace, isDgmNamespace, isDiagramGraphicDataUri, isRNamespace, MAX_DIAGRAM_CONNECTIONS, MAX_DIAGRAM_POINTS, MS_DIAGRAM_DATA_MODEL_EXT_URI, R_NAMESPACE, R_NAMESPACE_STRICT, W_NAMESPACE, WP_NAMESPACE, } from './constants';
10
+ export { attr, cloneElement, el, elementChildren, findChild, findChildren, getAttr, getAttrNS, isElementNode, isTextNode, text, textContent, ElementAttr, ElementChild, ElementNode, ElementTree, TextNode, } from './element-tree';
11
+ export { DiagramError, DiagramModelError, DiagramParseError, isDiagramError, DiagramErrorCode, } from './errors';
12
+ export { DiagramDataModel, isDiagramDataModel, DiagramConnection, DiagramConnectionProps, DiagramConnectionType, DiagramDataModelInit, DiagramPoint, DiagramPointProps, DiagramPointType, ModelId, } from './diagram-data-model';
13
+ export { DiagramColors, DiagramDrawing, DiagramLayout, DiagramQuickStyle, isDiagramColors, isDiagramDrawing, isDiagramLayout, isDiagramQuickStyle, } from './diagram-views';
14
+ export { parseDiagramColors, parseDiagramData, parseDiagramDrawing, parseDiagramLayout, parseDiagramQuickStyle, } from './diagram-parsers';
15
+ export { extLst, serializeDiagramColors, serializeDiagramData, serializeDiagramDrawing, serializeDiagramLayout, serializeDiagramQuickStyle, } from './diagram-serializers';
16
+ export { detectSmartArtInTree, findDiagramRelIdsInGraphicData, isSmartArtDiagram, isSmartArtGraphicDataUri, parseRelIds, SmartArtDiagram, DiagramRelIds, SmartArtDiagramInit, } from './smart-art-diagram';
17
+ export { isSmartArtCatalog, relIds, SmartArtCatalog, ApplyToPackageOptions, ApplyToPackageResult, DiagramPartKind, DiagramPartRecord, PackageView, SmartArtRecord, } from './smart-art-catalog';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Public surface: `@syncfusion/ej2-office-common/diagrams`
3
+ *
4
+ * SmartArt / DrawingML diagram parser, model, serializer, and catalog.
5
+ * TASK-9008. Host wiring for docx is TASK-9009.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { A_NAMESPACE, A_NAMESPACE_STRICT, DGM14_NAMESPACE, DGM14_RECOLOR_IMG_EXT_URI, DGM_NAMESPACE, DGM_NAMESPACE_STRICT, DIAGRAMS_FEATURE_ID, DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_COLORS_RELATIONSHIP_TYPE, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_DATA_RELATIONSHIP_TYPE, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_RELATIONSHIP_TYPE, DIAGRAM_GRAPHIC_DATA_URI, DIAGRAM_GRAPHIC_DATA_URI_STRICT, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_LAYOUT_RELATIONSHIP_TYPE, DIAGRAM_QUICK_STYLE_CONTENT_TYPE, DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE, DSP_NAMESPACE, isANamespace, isDgmNamespace, isDiagramGraphicDataUri, isRNamespace, MAX_DIAGRAM_CONNECTIONS, MAX_DIAGRAM_POINTS, MS_DIAGRAM_DATA_MODEL_EXT_URI, R_NAMESPACE, R_NAMESPACE_STRICT, W_NAMESPACE, WP_NAMESPACE, } from './constants';
10
+ export { attr, cloneElement, el, elementChildren, findChild, findChildren, getAttr, getAttrNS, isElementNode, isTextNode, text, textContent, } from './element-tree';
11
+ export { DiagramError, DiagramModelError, DiagramParseError, isDiagramError, } from './errors';
12
+ export { DiagramDataModel, isDiagramDataModel, } from './diagram-data-model';
13
+ export { DiagramColors, DiagramDrawing, DiagramLayout, DiagramQuickStyle, isDiagramColors, isDiagramDrawing, isDiagramLayout, isDiagramQuickStyle, } from './diagram-views';
14
+ export { parseDiagramColors, parseDiagramData, parseDiagramDrawing, parseDiagramLayout, parseDiagramQuickStyle, } from './diagram-parsers';
15
+ export { extLst, serializeDiagramColors, serializeDiagramData, serializeDiagramDrawing, serializeDiagramLayout, serializeDiagramQuickStyle, } from './diagram-serializers';
16
+ export { detectSmartArtInTree, findDiagramRelIdsInGraphicData, isSmartArtDiagram, isSmartArtGraphicDataUri, parseRelIds, SmartArtDiagram, } from './smart-art-diagram';
17
+ export { isSmartArtCatalog, relIds, SmartArtCatalog, } from './smart-art-catalog';
@@ -0,0 +1,107 @@
1
+ /**
2
+ * SmartArtCatalog — package-level index of diagram parts and SmartArt instances.
3
+ *
4
+ * D14: when a part is clean and originalBytes are present, applyToPackage
5
+ * writes those bytes; otherwise serializes ElementTree (caller encodes XML).
6
+ *
7
+ * Clone remaps modelIds; orphan-GC drops unreferenced parts after apply plan.
8
+ *
9
+ * Citations: requirement §12–§14; TASK-9008 catalog contract.
10
+ */
11
+ import { DiagramDataModel } from './diagram-data-model';
12
+ import { DiagramColors, DiagramDrawing, DiagramLayout, DiagramQuickStyle } from './diagram-views';
13
+ import { ElementNode } from './element-tree';
14
+ import { DiagramRelIds, SmartArtDiagram } from './smart-art-diagram';
15
+ declare const CATALOG_BRAND: unique symbol;
16
+ export declare type DiagramPartKind = 'data' | 'layout' | 'quickStyle' | 'colors' | 'drawing';
17
+ export interface DiagramPartRecord {
18
+ readonly kind: DiagramPartKind;
19
+ readonly partName: string;
20
+ readonly relationshipId?: string;
21
+ readonly contentType: string;
22
+ readonly relationshipType: string;
23
+ /** Model or view instance. */
24
+ readonly part: DiagramDataModel | DiagramLayout | DiagramQuickStyle | DiagramColors | DiagramDrawing;
25
+ }
26
+ export interface SmartArtRecord {
27
+ readonly id: string;
28
+ readonly diagram: SmartArtDiagram;
29
+ /** Package part names keyed by role. */
30
+ readonly partNames: {
31
+ readonly data: string;
32
+ readonly layout: string;
33
+ readonly quickStyle: string;
34
+ readonly colors: string;
35
+ readonly drawing?: string;
36
+ };
37
+ }
38
+ /**
39
+ * Minimal package mutation view for applyToPackage.
40
+ * Hosts (docx) implement this against their OPC layer.
41
+ */
42
+ export interface PackageView {
43
+ /** Upsert part bytes. */
44
+ putPart(partName: string, contentType: string, bytes: Uint8Array): void;
45
+ /** Optional: remove part. */
46
+ removePart?(partName: string): void;
47
+ /** Optional: ensure relationship. */
48
+ ensureRelationship?(sourcePartName: string, relationshipId: string, relationshipType: string, target: string): void;
49
+ }
50
+ export interface ApplyToPackageOptions {
51
+ /**
52
+ * Encode ElementTree → UTF-8 bytes. Required when a dirty part lacks originalBytes.
53
+ */
54
+ encodeXml: (tree: ElementNode) => Uint8Array;
55
+ /** When true, remove parts not referenced by any SmartArtRecord (orphan-GC). */
56
+ garbageCollectOrphans?: boolean;
57
+ }
58
+ export interface ApplyToPackageResult {
59
+ readonly written: string[];
60
+ readonly reusedBytes: string[];
61
+ readonly removed: string[];
62
+ }
63
+ export declare class SmartArtCatalog {
64
+ readonly [CATALOG_BRAND]: true;
65
+ private readonly _parts;
66
+ private readonly _smartArts;
67
+ private _seq;
68
+ readonly parts: ReadonlyArray<DiagramPartRecord>;
69
+ readonly smartArts: ReadonlyArray<SmartArtRecord>;
70
+ partCount(): number;
71
+ smartArtCount(): number;
72
+ getPart(partName: string): DiagramPartRecord | undefined;
73
+ getSmartArt(id: string): SmartArtRecord | undefined;
74
+ registerPart(record: DiagramPartRecord): void;
75
+ registerSmartArt(record: SmartArtRecord): void;
76
+ /**
77
+ * Allocate a new SmartArt id and register the diagram + its parts.
78
+ */
79
+ addSmartArt(diagram: SmartArtDiagram, partNames: SmartArtRecord['partNames'], id?: string): SmartArtRecord;
80
+ removeSmartArt(id: string): void;
81
+ /**
82
+ * Deep-clone a SmartArt instance with optional modelId remap prefix.
83
+ * Registers the clone under a new id; parts get new names when `partNamePrefix` set.
84
+ */
85
+ cloneSmartArt(id: string, options?: {
86
+ newId?: string;
87
+ partNamePrefix?: string;
88
+ modelIdPrefix?: string;
89
+ }): SmartArtRecord;
90
+ /**
91
+ * Parts referenced by at least one SmartArtRecord.
92
+ */
93
+ referencedPartNames(): Set<string>;
94
+ /**
95
+ * Remove part records not referenced by any SmartArt (in-memory orphan-GC).
96
+ */
97
+ garbageCollectOrphans(): string[];
98
+ /**
99
+ * Apply dirty (or all) parts to a PackageView.
100
+ * Clean parts with originalBytes reuse bytes (D14).
101
+ */
102
+ applyToPackage(pkg: PackageView, options: ApplyToPackageOptions): ApplyToPackageResult;
103
+ }
104
+ export declare function isSmartArtCatalog(value: unknown): value is SmartArtCatalog;
105
+ /** Build DiagramRelIds helper for tests/hosts. */
106
+ export declare function relIds(dm: string, lo: string, qs: string, cs: string): DiagramRelIds;
107
+ export {};
@@ -0,0 +1,422 @@
1
+ /**
2
+ * SmartArtCatalog — package-level index of diagram parts and SmartArt instances.
3
+ *
4
+ * D14: when a part is clean and originalBytes are present, applyToPackage
5
+ * writes those bytes; otherwise serializes ElementTree (caller encodes XML).
6
+ *
7
+ * Clone remaps modelIds; orphan-GC drops unreferenced parts after apply plan.
8
+ *
9
+ * Citations: requirement §12–§14; TASK-9008 catalog contract.
10
+ */
11
+ var __assign = (this && this.__assign) || function () {
12
+ __assign = Object.assign || function(t) {
13
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
14
+ s = arguments[i];
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
16
+ t[p] = s[p];
17
+ }
18
+ return t;
19
+ };
20
+ return __assign.apply(this, arguments);
21
+ };
22
+ var __read = (this && this.__read) || function (o, n) {
23
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
24
+ if (!m) return o;
25
+ var i = m.call(o), r, ar = [], e;
26
+ try {
27
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
28
+ }
29
+ catch (error) { e = { error: error }; }
30
+ finally {
31
+ try {
32
+ if (r && !r.done && (m = i["return"])) m.call(i);
33
+ }
34
+ finally { if (e) throw e.error; }
35
+ }
36
+ return ar;
37
+ };
38
+ var __spread = (this && this.__spread) || function () {
39
+ for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
40
+ return ar;
41
+ };
42
+ var __values = (this && this.__values) || function (o) {
43
+ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
44
+ if (m) return m.call(o);
45
+ return {
46
+ next: function () {
47
+ if (o && i >= o.length) o = void 0;
48
+ return { value: o && o[i++], done: !o };
49
+ }
50
+ };
51
+ };
52
+ var _a;
53
+ import { DIAGRAM_COLORS_CONTENT_TYPE, DIAGRAM_COLORS_RELATIONSHIP_TYPE, DIAGRAM_DATA_CONTENT_TYPE, DIAGRAM_DATA_RELATIONSHIP_TYPE, DIAGRAM_DRAWING_CONTENT_TYPE, DIAGRAM_DRAWING_RELATIONSHIP_TYPE, DIAGRAM_LAYOUT_CONTENT_TYPE, DIAGRAM_LAYOUT_RELATIONSHIP_TYPE, DIAGRAM_QUICK_STYLE_CONTENT_TYPE, DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE } from './constants';
54
+ import { serializeDiagramData } from './diagram-serializers';
55
+ import { serializeDiagramColors, serializeDiagramDrawing, serializeDiagramLayout, serializeDiagramQuickStyle } from './diagram-serializers';
56
+ import { DiagramError } from './errors';
57
+ var CATALOG_BRAND = Symbol.for('@syncfusion/ej2-office-common.SmartArtCatalog');
58
+ function contentTypeFor(kind) {
59
+ switch (kind) {
60
+ case 'data':
61
+ return DIAGRAM_DATA_CONTENT_TYPE;
62
+ case 'layout':
63
+ return DIAGRAM_LAYOUT_CONTENT_TYPE;
64
+ case 'quickStyle':
65
+ return DIAGRAM_QUICK_STYLE_CONTENT_TYPE;
66
+ case 'colors':
67
+ return DIAGRAM_COLORS_CONTENT_TYPE;
68
+ case 'drawing':
69
+ return DIAGRAM_DRAWING_CONTENT_TYPE;
70
+ }
71
+ }
72
+ function relationshipTypeFor(kind) {
73
+ switch (kind) {
74
+ case 'data':
75
+ return DIAGRAM_DATA_RELATIONSHIP_TYPE;
76
+ case 'layout':
77
+ return DIAGRAM_LAYOUT_RELATIONSHIP_TYPE;
78
+ case 'quickStyle':
79
+ return DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE;
80
+ case 'colors':
81
+ return DIAGRAM_COLORS_RELATIONSHIP_TYPE;
82
+ case 'drawing':
83
+ return DIAGRAM_DRAWING_RELATIONSHIP_TYPE;
84
+ }
85
+ }
86
+ function isDirtyPart(part) {
87
+ return part.dirty;
88
+ }
89
+ function originalBytesOf(part) {
90
+ return part.originalBytes;
91
+ }
92
+ function serializePart(kind, part) {
93
+ switch (kind) {
94
+ case 'data':
95
+ return serializeDiagramData(part);
96
+ case 'layout':
97
+ return serializeDiagramLayout(part);
98
+ case 'quickStyle':
99
+ return serializeDiagramQuickStyle(part);
100
+ case 'colors':
101
+ return serializeDiagramColors(part);
102
+ case 'drawing':
103
+ return serializeDiagramDrawing(part);
104
+ }
105
+ }
106
+ function clearPartDirty(part, bytes) {
107
+ part.clearDirty(bytes);
108
+ }
109
+ var SmartArtCatalog = /** @class */ (function () {
110
+ function SmartArtCatalog() {
111
+ this[_a] = true;
112
+ this._parts = new Map();
113
+ this._smartArts = new Map();
114
+ this._seq = 0;
115
+ }
116
+ Object.defineProperty(SmartArtCatalog.prototype, "parts", {
117
+ get: function () {
118
+ return __spread(this._parts.values());
119
+ },
120
+ enumerable: true,
121
+ configurable: true
122
+ });
123
+ Object.defineProperty(SmartArtCatalog.prototype, "smartArts", {
124
+ get: function () {
125
+ return __spread(this._smartArts.values());
126
+ },
127
+ enumerable: true,
128
+ configurable: true
129
+ });
130
+ SmartArtCatalog.prototype.partCount = function () {
131
+ return this._parts.size;
132
+ };
133
+ SmartArtCatalog.prototype.smartArtCount = function () {
134
+ return this._smartArts.size;
135
+ };
136
+ SmartArtCatalog.prototype.getPart = function (partName) {
137
+ return this._parts.get(partName);
138
+ };
139
+ SmartArtCatalog.prototype.getSmartArt = function (id) {
140
+ return this._smartArts.get(id);
141
+ };
142
+ SmartArtCatalog.prototype.registerPart = function (record) {
143
+ this._parts.set(record.partName, __assign({}, record, { contentType: record.contentType || contentTypeFor(record.kind), relationshipType: record.relationshipType || relationshipTypeFor(record.kind) }));
144
+ };
145
+ SmartArtCatalog.prototype.registerSmartArt = function (record) {
146
+ this._smartArts.set(record.id, record);
147
+ };
148
+ /**
149
+ * Allocate a new SmartArt id and register the diagram + its parts.
150
+ */
151
+ SmartArtCatalog.prototype.addSmartArt = function (diagram, partNames, id) {
152
+ var _this = this;
153
+ var sid = id != null ? id : "smartart-" + String(++this._seq);
154
+ if (this._smartArts.has(sid)) {
155
+ throw new DiagramError('catalog_error', "SmartArt id already exists: " + sid);
156
+ }
157
+ var rec = {
158
+ id: sid,
159
+ diagram: diagram,
160
+ partNames: partNames
161
+ };
162
+ this._smartArts.set(sid, rec);
163
+ var ensure = function (kind, name, part) {
164
+ if (!_this._parts.has(name)) {
165
+ _this.registerPart({
166
+ kind: kind,
167
+ partName: name,
168
+ contentType: contentTypeFor(kind),
169
+ relationshipType: relationshipTypeFor(kind),
170
+ part: part
171
+ });
172
+ }
173
+ };
174
+ ensure('data', partNames.data, diagram.data());
175
+ ensure('layout', partNames.layout, diagram.layout());
176
+ ensure('quickStyle', partNames.quickStyle, diagram.quickStyle());
177
+ ensure('colors', partNames.colors, diagram.colors());
178
+ var drawingPart = diagram.drawing();
179
+ if (partNames.drawing && drawingPart) {
180
+ ensure('drawing', partNames.drawing, drawingPart);
181
+ }
182
+ return rec;
183
+ };
184
+ SmartArtCatalog.prototype.removeSmartArt = function (id) {
185
+ this._smartArts.delete(id);
186
+ };
187
+ /**
188
+ * Deep-clone a SmartArt instance with optional modelId remap prefix.
189
+ * Registers the clone under a new id; parts get new names when `partNamePrefix` set.
190
+ */
191
+ SmartArtCatalog.prototype.cloneSmartArt = function (id, options) {
192
+ var e_1, _a, e_2, _b;
193
+ var src = this._smartArts.get(id);
194
+ if (!src) {
195
+ throw new DiagramError('catalog_error', "SmartArt not found: " + id);
196
+ }
197
+ var cloned = src.diagram.clone();
198
+ if (options == null ? void 0 : options.modelIdPrefix) {
199
+ var prefix = options.modelIdPrefix;
200
+ var data = cloned.data();
201
+ try {
202
+ for (var _c = __values(data.points), _d = _c.next(); !_d.done; _d = _c.next()) {
203
+ var p = _d.value;
204
+ p.modelId = prefix + p.modelId;
205
+ }
206
+ }
207
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
208
+ finally {
209
+ try {
210
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
211
+ }
212
+ finally { if (e_1) throw e_1.error; }
213
+ }
214
+ try {
215
+ for (var _e = __values(data.connections), _f = _e.next(); !_f.done; _f = _e.next()) {
216
+ var c = _f.value;
217
+ c.modelId = prefix + c.modelId;
218
+ c.srcId = prefix + c.srcId;
219
+ c.destId = prefix + c.destId;
220
+ if (c.parTransId !== '0') {
221
+ c.parTransId = prefix + c.parTransId;
222
+ }
223
+ if (c.sibTransId !== '0') {
224
+ c.sibTransId = prefix + c.sibTransId;
225
+ }
226
+ data.markDirty();
227
+ }
228
+ }
229
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
230
+ finally {
231
+ try {
232
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
233
+ }
234
+ finally { if (e_2) throw e_2.error; }
235
+ }
236
+ }
237
+ var pfx = function () {
238
+ var _nc = options == null ? void 0 : options.partNamePrefix;
239
+ return _nc != null ? _nc : "cloned/" + id + "/";
240
+ }();
241
+ var partNames = __assign({ data: pfx + "data.xml", layout: pfx + "layout.xml", quickStyle: pfx + "quickStyle.xml", colors: pfx + "colors.xml" }, (src.partNames.drawing ? {
242
+ drawing: pfx + "drawing.xml"
243
+ } : {}));
244
+ return this.addSmartArt(cloned, partNames, options == null ? void 0 : options.newId);
245
+ };
246
+ /**
247
+ * Parts referenced by at least one SmartArtRecord.
248
+ */
249
+ SmartArtCatalog.prototype.referencedPartNames = function () {
250
+ var e_3, _a;
251
+ var set = new Set();
252
+ try {
253
+ for (var _b = __values(this._smartArts.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
254
+ var s = _c.value;
255
+ set.add(s.partNames.data);
256
+ set.add(s.partNames.layout);
257
+ set.add(s.partNames.quickStyle);
258
+ set.add(s.partNames.colors);
259
+ if (s.partNames.drawing)
260
+ set.add(s.partNames.drawing);
261
+ }
262
+ }
263
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
264
+ finally {
265
+ try {
266
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
267
+ }
268
+ finally { if (e_3) throw e_3.error; }
269
+ }
270
+ return set;
271
+ };
272
+ /**
273
+ * Remove part records not referenced by any SmartArt (in-memory orphan-GC).
274
+ */
275
+ SmartArtCatalog.prototype.garbageCollectOrphans = function () {
276
+ var e_4, _a;
277
+ var ref = this.referencedPartNames();
278
+ var removed = [];
279
+ try {
280
+ for (var _b = __values(__spread(this._parts.keys())), _c = _b.next(); !_c.done; _c = _b.next()) {
281
+ var name_1 = _c.value;
282
+ if (!ref.has(name_1)) {
283
+ this._parts.delete(name_1);
284
+ removed.push(name_1);
285
+ }
286
+ }
287
+ }
288
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
289
+ finally {
290
+ try {
291
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
292
+ }
293
+ finally { if (e_4) throw e_4.error; }
294
+ }
295
+ return removed;
296
+ };
297
+ /**
298
+ * Apply dirty (or all) parts to a PackageView.
299
+ * Clean parts with originalBytes reuse bytes (D14).
300
+ */
301
+ SmartArtCatalog.prototype.applyToPackage = function (pkg, options) {
302
+ var e_5, _a, e_6, _b, e_7, _c;
303
+ var written = [];
304
+ var reusedBytes = [];
305
+ var removed = [];
306
+ try {
307
+ // Sync part map from smart arts (model identity may share).
308
+ for (var _d = __values(this._smartArts.values()), _e = _d.next(); !_e.done; _e = _d.next()) {
309
+ var s = _e.value;
310
+ var d = s.diagram;
311
+ this.registerPart({
312
+ kind: 'data',
313
+ partName: s.partNames.data,
314
+ contentType: DIAGRAM_DATA_CONTENT_TYPE,
315
+ relationshipType: DIAGRAM_DATA_RELATIONSHIP_TYPE,
316
+ part: d.data()
317
+ });
318
+ this.registerPart({
319
+ kind: 'layout',
320
+ partName: s.partNames.layout,
321
+ contentType: DIAGRAM_LAYOUT_CONTENT_TYPE,
322
+ relationshipType: DIAGRAM_LAYOUT_RELATIONSHIP_TYPE,
323
+ part: d.layout()
324
+ });
325
+ this.registerPart({
326
+ kind: 'quickStyle',
327
+ partName: s.partNames.quickStyle,
328
+ contentType: DIAGRAM_QUICK_STYLE_CONTENT_TYPE,
329
+ relationshipType: DIAGRAM_QUICK_STYLE_RELATIONSHIP_TYPE,
330
+ part: d.quickStyle()
331
+ });
332
+ this.registerPart({
333
+ kind: 'colors',
334
+ partName: s.partNames.colors,
335
+ contentType: DIAGRAM_COLORS_CONTENT_TYPE,
336
+ relationshipType: DIAGRAM_COLORS_RELATIONSHIP_TYPE,
337
+ part: d.colors()
338
+ });
339
+ var drawingPart = d.drawing();
340
+ if (s.partNames.drawing && drawingPart) {
341
+ this.registerPart({
342
+ kind: 'drawing',
343
+ partName: s.partNames.drawing,
344
+ contentType: DIAGRAM_DRAWING_CONTENT_TYPE,
345
+ relationshipType: DIAGRAM_DRAWING_RELATIONSHIP_TYPE,
346
+ part: drawingPart
347
+ });
348
+ }
349
+ }
350
+ }
351
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
352
+ finally {
353
+ try {
354
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
355
+ }
356
+ finally { if (e_5) throw e_5.error; }
357
+ }
358
+ try {
359
+ for (var _f = __values(this._parts.values()), _g = _f.next(); !_g.done; _g = _f.next()) {
360
+ var rec = _g.value;
361
+ var dirty = isDirtyPart(rec.part);
362
+ var orig = originalBytesOf(rec.part);
363
+ var bytes = void 0;
364
+ if (!dirty && orig) {
365
+ bytes = orig;
366
+ reusedBytes.push(rec.partName);
367
+ }
368
+ else {
369
+ var tree = serializePart(rec.kind, rec.part);
370
+ bytes = options.encodeXml(tree);
371
+ written.push(rec.partName);
372
+ }
373
+ pkg.putPart(rec.partName, rec.contentType, bytes);
374
+ clearPartDirty(rec.part, bytes);
375
+ }
376
+ }
377
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
378
+ finally {
379
+ try {
380
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
381
+ }
382
+ finally { if (e_6) throw e_6.error; }
383
+ }
384
+ if (options.garbageCollectOrphans) {
385
+ var gone = this.garbageCollectOrphans();
386
+ try {
387
+ for (var gone_1 = __values(gone), gone_1_1 = gone_1.next(); !gone_1_1.done; gone_1_1 = gone_1.next()) {
388
+ var name_2 = gone_1_1.value;
389
+ pkg.removePart == null ? void 0 : pkg.removePart(name_2);
390
+ removed.push(name_2);
391
+ }
392
+ }
393
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
394
+ finally {
395
+ try {
396
+ if (gone_1_1 && !gone_1_1.done && (_c = gone_1.return)) _c.call(gone_1);
397
+ }
398
+ finally { if (e_7) throw e_7.error; }
399
+ }
400
+ }
401
+ return {
402
+ written: written,
403
+ reusedBytes: reusedBytes,
404
+ removed: removed
405
+ };
406
+ };
407
+ return SmartArtCatalog;
408
+ }());
409
+ export { SmartArtCatalog };
410
+ _a = CATALOG_BRAND;
411
+ export function isSmartArtCatalog(value) {
412
+ return value instanceof SmartArtCatalog;
413
+ }
414
+ /** Build DiagramRelIds helper for tests/hosts. */
415
+ export function relIds(dm, lo, qs, cs) {
416
+ return {
417
+ dm: dm,
418
+ lo: lo,
419
+ qs: qs,
420
+ cs: cs
421
+ };
422
+ }