@office-open/core 0.10.2 → 0.10.4

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.
@@ -1,7 +1,7 @@
1
- import "./patch-DocIv0Sn.mjs";
1
+ import "./patch-DEPPafeB.mjs";
2
2
  import "./smartart-DCY-Vdv7.mjs";
3
3
  import "./chart-DwE8FCFk.mjs";
4
- import { d as parse$1, f as stringify$1 } from "./descriptor-BdWTH1vv.mjs";
4
+ import { d as stringify$1, u as parse$1 } from "./descriptor-DAER86Rt.mjs";
5
5
  import "./theme-CiNzdl-9.mjs";
6
6
  import { attr, attrMeasure, attrNum, element, escapeXml, findChild, js2xml, stringify, textOf, xml2js } from "@office-open/xml";
7
7
  import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
@@ -40,6 +40,69 @@ var Relationships = class {
40
40
  return p.join("");
41
41
  }
42
42
  };
43
+ /**
44
+ * Serialize a Relationships part only when it carries at least one
45
+ * relationship. Optional parts (fontTable, headers, footers, charts, drawings,
46
+ * worksheets, …) emit no .rels part when empty — Office strips empty rels
47
+ * shells when re-saving, so skipping them keeps generated packages free of
48
+ * redundant empty parts and matches Office's normalized output.
49
+ *
50
+ * Always-on parts (the package `_rels/.rels` and the main
51
+ * document/presentation/workbook parts) carry relationships by construction
52
+ * and must NOT use this gate.
53
+ */
54
+ function optionalRelsPart(rel, xmlDeclaration, path) {
55
+ return rel.relationshipCount > 0 ? {
56
+ data: xmlDeclaration + rel.serialize(),
57
+ path
58
+ } : void 0;
59
+ }
60
+ //#endregion
61
+ //#region src/opc/media.ts
62
+ /**
63
+ * Shared media collection for docx/pptx/xlsx. Generic over the package's entry
64
+ * type so each package keeps its own metadata while sharing the registration +
65
+ * dedup logic.
66
+ */
67
+ var Media = class {
68
+ map = /* @__PURE__ */ new Map();
69
+ counter = 0;
70
+ /**
71
+ * Register media, reusing the existing entry when the bytes already exist.
72
+ * Returns the canonical entry (shared across all identical references) —
73
+ * callers read `entry.fileName` for placeholders/relationship targets or use
74
+ * the whole entry (e.g. drawing XML). The `build` callback constructs the
75
+ * package-specific entry from the allocated file name.
76
+ *
77
+ * Pass `fileName` to pin the name (round-trip scenarios preserving a source
78
+ * file name); omit it to allocate the next sequential `imageN.ext`.
79
+ */
80
+ addMedia(data, type, build, fileName) {
81
+ const existingKey = this.findByContent(data);
82
+ if (existingKey) return this.map.get(existingKey);
83
+ const resolvedName = fileName ?? `image${++this.counter}.${type}`;
84
+ const entry = build(resolvedName);
85
+ this.map.set(resolvedName, entry);
86
+ return entry;
87
+ }
88
+ /** Find the key of an existing entry with byte-identical content. */
89
+ findByContent(data) {
90
+ for (const [key, entry] of this.map) {
91
+ const existing = entry.data;
92
+ if (existing.length !== data.length) continue;
93
+ let match = true;
94
+ for (let i = 0; i < existing.length; i++) if (existing[i] !== data[i]) {
95
+ match = false;
96
+ break;
97
+ }
98
+ if (match) return key;
99
+ }
100
+ }
101
+ /** All registered media entries. */
102
+ get array() {
103
+ return [...this.map.values()];
104
+ }
105
+ };
43
106
  //#endregion
44
107
  //#region src/opc/content-types.ts
45
108
  /**
@@ -2409,9 +2472,10 @@ const DOCX_PARTS = {
2409
2472
  },
2410
2473
  {
2411
2474
  path: "word/theme/theme1.xml",
2475
+ contentType: "application/vnd.openxmlformats-officedocument.theme+xml",
2412
2476
  presence: {
2413
2477
  kind: "conditional",
2414
- flag: "rawParts theme"
2478
+ flag: "freshCompile"
2415
2479
  }
2416
2480
  }
2417
2481
  ]
@@ -3443,13 +3507,14 @@ function isBase64DataURL(input) {
3443
3507
  return DATA_URL_RE.test(input);
3444
3508
  }
3445
3509
  /** Normalize any supported binary input to a `Uint8Array`. */
3446
- function toUint8Array(data) {
3510
+ function toUint8Array(data, options) {
3447
3511
  if (data instanceof Uint8Array) return data;
3448
3512
  if (data instanceof ArrayBuffer) return new Uint8Array(data);
3449
3513
  if (data instanceof DataView) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
3450
3514
  if (typeof data === "string") {
3451
3515
  const match = data.match(DATA_URL_RE);
3452
3516
  if (match) return decodeBase64(data.slice(match[0].length));
3517
+ if (options?.encoding === "base64") return decodeBase64(data);
3453
3518
  return new TextEncoder().encode(data);
3454
3519
  }
3455
3520
  if (Array.isArray(data)) return new Uint8Array(data);
@@ -4207,7 +4272,7 @@ const extractBlipFillMedia = (fill, nameAllocator) => {
4207
4272
  /**
4208
4273
  * Builds a DrawingML fill XML string from a FillOptions config.
4209
4274
  */
4210
- const buildFill = (options) => {
4275
+ const buildFill = (options, embedPlaceholder) => {
4211
4276
  if (typeof options === "string") return createSolidFill({ value: options.replace("#", "") });
4212
4277
  switch (options.type) {
4213
4278
  case "solid": return createSolidFill(normalizeColor(options.color));
@@ -4227,11 +4292,12 @@ const buildFill = (options) => {
4227
4292
  });
4228
4293
  case "blip": {
4229
4294
  const fileName = `${uniqueId()}.${options.imageType}`;
4295
+ const embed = embedPlaceholder ?? `{${fileName}}`;
4230
4296
  const blipChildren = [];
4231
4297
  if (options.blipEffects) blipChildren.push(...createBlipEffects(options.blipEffects));
4232
4298
  const children = [element("a:blip", {
4233
4299
  cstate: "none",
4234
- "r:embed": `{${fileName}}`
4300
+ "r:embed": embed
4235
4301
  }, blipChildren.length > 0 ? blipChildren : void 0), createSourceRectangle(options.sourceRectangle)];
4236
4302
  if (options.tile) children.push(createTileInfo(options.tile));
4237
4303
  else children.push("<a:stretch><a:fillRect/></a:stretch>");
@@ -5746,212 +5812,6 @@ const createGroupTransform2D = (options, elementName = "a:xfrm") => {
5746
5812
  return element(elementName, buildXfrmAttrs(options), children);
5747
5813
  };
5748
5814
  //#endregion
5749
- //#region src/util/converters.ts
5750
- /**
5751
- * OOXML unit conversion utilities.
5752
- *
5753
- * @module
5754
- */
5755
- /**
5756
- * Converts millimeters to TWIP (twentieths of a point).
5757
- */
5758
- const convertMillimetersToTwip = (millimeters) => Math.floor(millimeters / 25.4 * 72 * 20);
5759
- /**
5760
- * Converts inches to TWIP (twentieths of a point).
5761
- */
5762
- const convertInchesToTwip = (inches) => Math.floor(inches * 72 * 20);
5763
- /**
5764
- * Converts pixels to EMU (96 DPI).
5765
- */
5766
- const convertPixelsToEmu = (pixels) => Math.round(pixels * 9525);
5767
- /**
5768
- * Converts EMU to pixels (96 DPI).
5769
- *
5770
- * Returns a possibly fractional (sub-pixel) value. The integer rounding that
5771
- * lived here before permanently discarded sub-pixel precision, which made an
5772
- * EMU → pixel → EMU round-trip lossy (e.g. 5521960 EMU → 580 px → 5524500 EMU).
5773
- * Keeping the fraction lets convertPixelsToEmu restore the exact original EMU.
5774
- * Callers needing an integer pixel for display should Math.round the result.
5775
- */
5776
- const convertEmuToPixels = (emus) => emus / 9525;
5777
- /**
5778
- * Converts inches to EMU.
5779
- */
5780
- const convertInchesToEmu = (inches) => Math.round(inches * 914400);
5781
- /**
5782
- * Converts EMU to inches.
5783
- */
5784
- const convertEmuToInches = (emus) => emus / 914400;
5785
- /**
5786
- * Converts points to EMU.
5787
- */
5788
- const convertPointsToEmu = (points) => Math.round(points * 12700);
5789
- /**
5790
- * Converts EMU to points.
5791
- */
5792
- const convertEmuToPoints = (emus) => emus / 12700;
5793
- /**
5794
- * Converts a pixel-based position to EMU coordinates.
5795
- */
5796
- const convertPositionToEmu = (pos) => ({
5797
- x: convertPixelsToEmu(pos.x),
5798
- y: convertPixelsToEmu(pos.y),
5799
- cx: convertPixelsToEmu(pos.width),
5800
- cy: convertPixelsToEmu(pos.height)
5801
- });
5802
- /**
5803
- * Parse a UniversalMeasure string into its numeric value and unit.
5804
- *
5805
- * @param measure - A universal measure string like "2.54cm", "-10mm", "1in"
5806
- * @returns The parsed value and unit
5807
- * @throws Error if the format is invalid
5808
- *
5809
- * @example
5810
- * ```typescript
5811
- * parseUniversalMeasure("2.54cm"); // { value: 2.54, unit: "cm" }
5812
- * parseUniversalMeasure("-10mm"); // { value: -10, unit: "mm" }
5813
- * ```
5814
- */
5815
- const parseUniversalMeasure = (measure) => {
5816
- const match = measure.match(/^(-?[0-9]+(?:\.[0-9]+)?)(mm|cm|in|pt|pc|pi)$/);
5817
- if (!match) throw new Error(`Invalid universal measure: '${measure}'`);
5818
- return {
5819
- value: parseFloat(match[1]),
5820
- unit: match[2]
5821
- };
5822
- };
5823
- /**
5824
- * Converts a UniversalMeasure string to TWIP (twentieths of a point).
5825
- *
5826
- * Supports units: mm, cm, in, pt, pc (picas, 1pc = 12pt), pi (alias for pc).
5827
- *
5828
- * @param measure - A universal measure string like "2.54cm", "1in", "12pt"
5829
- * @returns The value in TWIP
5830
- *
5831
- * @example
5832
- * ```typescript
5833
- * convertUniversalMeasureToTwip("1in"); // 1440
5834
- * convertUniversalMeasureToTwip("2.54cm"); // ~1440 (1 inch)
5835
- * convertUniversalMeasureToTwip("72pt"); // 1440 (1 inch = 72pt = 1440 twips)
5836
- * ```
5837
- */
5838
- const convertUniversalMeasureToTwip = (measure) => {
5839
- const { value, unit } = parseUniversalMeasure(measure);
5840
- switch (unit) {
5841
- case "mm": return convertMillimetersToTwip(value);
5842
- case "cm": return convertMillimetersToTwip(value * 10);
5843
- case "in": return convertInchesToTwip(value);
5844
- case "pt": return Math.floor(value * 20);
5845
- case "pc":
5846
- case "pi": return Math.floor(value * 12 * 20);
5847
- }
5848
- };
5849
- /**
5850
- * Converts a measurement value (number or UniversalMeasure) to TWIP.
5851
- *
5852
- * If the value is already a number, it is returned as-is (assumed to be in twips).
5853
- * If the value is a UniversalMeasure string, it is converted to twips.
5854
- *
5855
- * Useful for accepting both `number` and `UniversalMeasure` inputs where
5856
- * the XSD type is a union (e.g., ST_TwipsMeasure, ST_SignedTwipsMeasure).
5857
- *
5858
- * @param val - A numeric twip value or a universal measure string
5859
- * @returns The value in TWIP
5860
- *
5861
- * @example
5862
- * ```typescript
5863
- * convertToTwip(1440); // 1440 (already twips)
5864
- * convertToTwip("1in"); // 1440
5865
- * convertToTwip("2.54cm"); // ~1440
5866
- * ```
5867
- */
5868
- const convertToTwip = (val) => typeof val === "string" ? convertUniversalMeasureToTwip(val) : val;
5869
- /**
5870
- * Converts a UniversalMeasure string to EMU (English Metric Units).
5871
- *
5872
- * Supports units: mm, cm, in, pt, pc (picas, 1pc = 12pt), pi (alias for pc).
5873
- *
5874
- * @param measure - A universal measure string like "2.54cm", "1in", "12pt"
5875
- * @returns The value in EMU
5876
- *
5877
- * @example
5878
- * ```typescript
5879
- * convertUniversalMeasureToEmu("1in"); // 914400
5880
- * convertUniversalMeasureToEmu("2.54cm"); // 914400
5881
- * convertUniversalMeasureToEmu("12pt"); // 152400
5882
- * ```
5883
- */
5884
- const convertUniversalMeasureToEmu = (measure) => {
5885
- const { value, unit } = parseUniversalMeasure(measure);
5886
- switch (unit) {
5887
- case "mm": return Math.round(value * 36e3);
5888
- case "cm": return Math.round(value * 36e4);
5889
- case "in": return convertInchesToEmu(value);
5890
- case "pt": return convertPointsToEmu(value);
5891
- case "pc":
5892
- case "pi": return convertPointsToEmu(value * 12);
5893
- }
5894
- };
5895
- /**
5896
- * Converts a measurement value (number or UniversalMeasure) to EMU.
5897
- *
5898
- * If the value is already a number, it is returned as-is (assumed to be in EMU).
5899
- * If the value is a UniversalMeasure string, it is converted to EMU.
5900
- *
5901
- * Useful for accepting both `number` and `UniversalMeasure` inputs in DrawingML
5902
- * where the XSD type is a union (e.g., ST_Coordinate).
5903
- *
5904
- * @param val - A numeric EMU value or a universal measure string
5905
- * @returns The value in EMU
5906
- *
5907
- * @example
5908
- * ```typescript
5909
- * convertToEmu(914400); // 914400 (already EMU)
5910
- * convertToEmu("1in"); // 914400
5911
- * convertToEmu("2.54cm"); // 914400
5912
- * ```
5913
- */
5914
- const convertToEmu = (val) => typeof val === "string" ? convertUniversalMeasureToEmu(val) : val;
5915
- //#endregion
5916
- //#region src/drawingml/media/transformation.ts
5917
- /**
5918
- * Media transformation utilities for DrawingML.
5919
- *
5920
- * Converts user-facing transformation options (pixels) to internal
5921
- * transformation data (pixels + EMUs).
5922
- *
5923
- * @module
5924
- */
5925
- /**
5926
- * Converts user-facing transformation options (pixels) to internal
5927
- * transformation data (pixels + EMUs).
5928
- *
5929
- * @param options - User-facing transformation in pixels
5930
- * @returns Internal transformation data with both pixel and EMU values
5931
- */
5932
- const createTransformation = (options) => ({
5933
- emus: {
5934
- x: convertPixelsToEmu(options.width),
5935
- y: convertPixelsToEmu(options.height)
5936
- },
5937
- flip: options.flip,
5938
- offset: {
5939
- emus: {
5940
- x: convertPixelsToEmu(options.offset?.left ?? 0),
5941
- y: convertPixelsToEmu(options.offset?.top ?? 0)
5942
- },
5943
- pixels: {
5944
- x: Math.round(options.offset?.left ?? 0),
5945
- y: Math.round(options.offset?.top ?? 0)
5946
- }
5947
- },
5948
- pixels: {
5949
- x: Math.round(options.width),
5950
- y: Math.round(options.height)
5951
- },
5952
- rotation: options.rotation ? options.rotation * 6e4 : void 0
5953
- });
5954
- //#endregion
5955
5815
  //#region src/drawingml/table-style.ts
5956
5816
  /**
5957
5817
  * Table Style system for DrawingML.
@@ -6769,14 +6629,17 @@ const scRgbColorDesc = {
6769
6629
  const SYSTEM_COLOR_VALUES = new Set(Object.values(SystemColor));
6770
6630
  const PRESET_COLOR_VALUES = new Set(Object.values(PresetColor));
6771
6631
  const SCHEME_COLOR_VALUES = new Set(Object.values(SchemeColor));
6772
- function getColorDescriptor(color) {
6773
- if ("hue" in color && "saturation" in color && "luminance" in color) return hslColorDesc;
6774
- if ("r" in color && "g" in color && "b" in color) return scRgbColorDesc;
6632
+ /** Stringify an EG_ColorChoice (direct color element, no `a:solidFill` wrapper).
6633
+ * Used for gradient stops, fg/bg clr, and effect colors. Replaces the former
6634
+ * `getColorDescriptor` which returned a polymorphic `CustomDescriptor<any>`. */
6635
+ function stringifyColorChoice(color, ctx) {
6636
+ if ("hue" in color) return stringify$1(hslColorDesc, color, ctx) ?? "";
6637
+ if ("r" in color) return stringify$1(scRgbColorDesc, color, ctx) ?? "";
6775
6638
  const colorValue = color.value;
6776
- if (SYSTEM_COLOR_VALUES.has(colorValue)) return systemColorDesc;
6777
- if (PRESET_COLOR_VALUES.has(colorValue)) return presetColorDesc;
6778
- if (SCHEME_COLOR_VALUES.has(colorValue)) return schemeColorDesc;
6779
- return rgbColorDesc;
6639
+ if (SYSTEM_COLOR_VALUES.has(colorValue)) return stringify$1(systemColorDesc, color, ctx) ?? "";
6640
+ if (PRESET_COLOR_VALUES.has(colorValue)) return stringify$1(presetColorDesc, color, ctx) ?? "";
6641
+ if (SCHEME_COLOR_VALUES.has(colorValue)) return stringify$1(schemeColorDesc, color, ctx) ?? "";
6642
+ return stringify$1(rgbColorDesc, color, ctx) ?? "";
6780
6643
  }
6781
6644
  /**
6782
6645
  * Parse an EG_ColorChoice from an element's direct children. Handles all six
@@ -6799,7 +6662,7 @@ function parseColorChoice(el, ctx) {
6799
6662
  const solidFillDesc = {
6800
6663
  kind: "custom",
6801
6664
  stringify(color, ctx) {
6802
- const inner = stringify$1(getColorDescriptor(color), color, ctx);
6665
+ const inner = stringifyColorChoice(color, ctx);
6803
6666
  if (!inner) return void 0;
6804
6667
  return `<a:solidFill>${inner}</a:solidFill>`;
6805
6668
  },
@@ -6808,1431 +6671,1676 @@ const solidFillDesc = {
6808
6671
  }
6809
6672
  };
6810
6673
  //#endregion
6811
- //#region src/drawingml/fill/fill-descriptors.ts
6674
+ //#region src/drawingml/blip/blip-descriptors.ts
6812
6675
  /**
6813
- * Fill descriptors for DrawingML EG_FillProperties.
6676
+ * Blip descriptor for DrawingML pictures.
6814
6677
  *
6815
6678
  * @module
6816
6679
  */
6817
- function stringifyRelativeRect(tag, rect) {
6818
- const parts = [];
6819
- if (rect.left) parts.push(`l="${escapeXml(rect.left)}"`);
6820
- if (rect.top) parts.push(`t="${escapeXml(rect.top)}"`);
6821
- if (rect.right) parts.push(`r="${escapeXml(rect.right)}"`);
6822
- if (rect.bottom) parts.push(`b="${escapeXml(rect.bottom)}"`);
6823
- return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
6824
- }
6825
- function readRelativeRect(el) {
6826
- const result = {};
6827
- if (el.attributes?.["l"]) result.left = String(el.attributes["l"]);
6828
- if (el.attributes?.["t"]) result.top = String(el.attributes["t"]);
6829
- if (el.attributes?.["r"]) result.right = String(el.attributes["r"]);
6830
- if (el.attributes?.["b"]) result.bottom = String(el.attributes["b"]);
6831
- return result;
6832
- }
6833
- function stringifyShade(shade) {
6834
- if ("angle" in shade) {
6835
- const parts = [];
6836
- if (shade.angle !== void 0) parts.push(`ang="${shade.angle}"`);
6837
- if (shade.scaled !== void 0) parts.push(`scaled="${shade.scaled ? 1 : 0}"`);
6838
- return `<a:lin${parts.length ? " " + parts.join(" ") : ""}/>`;
6839
- }
6840
- const pathShade = shade;
6841
- const parts = [];
6842
- if (pathShade.path) parts.push(`path="${escapeXml(pathShade.path)}"`);
6843
- const attrStr = parts.length ? " " + parts.join(" ") : "";
6844
- if (pathShade.fillToRectangle) return `<a:path${attrStr}>${stringifyRelativeRect("a:fillToRect", pathShade.fillToRectangle)}</a:path>`;
6845
- return `<a:path${attrStr}/>`;
6846
- }
6847
- const gradientFillDesc = {
6680
+ const tileDesc = {
6848
6681
  kind: "custom",
6849
- stringify(opts, ctx) {
6850
- const parts = [];
6851
- const stopsXml = opts.stops.map((stop) => {
6852
- const colorXml = stringify$1(getColorDescriptor(stop.color), stop.color, ctx);
6853
- if (!colorXml) return `<a:gs pos="${stop.position}"/>`;
6854
- return `<a:gs pos="${stop.position}">${colorXml}</a:gs>`;
6855
- }).join("");
6856
- parts.push(`<a:gsLst>${stopsXml}</a:gsLst>`);
6857
- if (opts.shade) parts.push(stringifyShade(opts.shade));
6858
- if (opts.tileRectangle) parts.push(stringifyRelativeRect("a:tileRect", opts.tileRectangle));
6682
+ stringify(opts, _ctx) {
6859
6683
  const attrParts = [];
6860
- if (opts.flip) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
6861
- if (opts.rotateWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotateWithShape ? 1 : 0}"`);
6862
- return `<a:gradFill${attrParts.length ? " " + attrParts.join(" ") : ""}>${parts.join("")}</a:gradFill>`;
6684
+ if (opts.tx !== void 0) attrParts.push(`tx="${opts.tx}"`);
6685
+ if (opts.ty !== void 0) attrParts.push(`ty="${opts.ty}"`);
6686
+ if (opts.sx !== void 0) attrParts.push(`sx="${opts.sx}"`);
6687
+ if (opts.sy !== void 0) attrParts.push(`sy="${opts.sy}"`);
6688
+ if (opts.flip !== void 0) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
6689
+ if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(xsdRectAlignment.to(opts.align))}"`);
6690
+ return `<a:tile${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
6863
6691
  },
6864
- parse(el, ctx) {
6692
+ parse(el, _ctx) {
6865
6693
  const result = {};
6866
- const gsLst = findChild(el, "a:gsLst");
6867
- if (gsLst?.elements) result.stops = gsLst.elements.filter((c) => c.name === "a:gs").map((gs) => {
6868
- return {
6869
- position: Number(gs.attributes?.["pos"] ?? 0),
6870
- color: readDirectColor(gs, ctx)
6871
- };
6872
- });
6873
- const lin = findChild(el, "a:lin");
6874
- if (lin) {
6875
- const shade = {};
6876
- if (lin.attributes?.["ang"] !== void 0) shade.angle = Number(lin.attributes["ang"]);
6877
- if (lin.attributes?.["scaled"] !== void 0) shade.scaled = lin.attributes["scaled"] !== "0";
6878
- result.shade = shade;
6879
- } else {
6880
- const path = findChild(el, "a:path");
6881
- if (path) {
6882
- const shade = {};
6883
- if (path.attributes?.["path"] !== void 0) shade.path = String(path.attributes["path"]);
6884
- const fillToRectangle = findChild(path, "a:fillToRect");
6885
- if (fillToRectangle) shade.fillToRectangle = readRelativeRect(fillToRectangle);
6886
- result.shade = shade;
6887
- }
6888
- }
6694
+ if (el.attributes?.["tx"] !== void 0) result.tx = Number(el.attributes["tx"]);
6695
+ if (el.attributes?.["ty"] !== void 0) result.ty = Number(el.attributes["ty"]);
6696
+ if (el.attributes?.["sx"] !== void 0) result.sx = Number(el.attributes["sx"]);
6697
+ if (el.attributes?.["sy"] !== void 0) result.sy = Number(el.attributes["sy"]);
6889
6698
  if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
6890
- if (el.attributes?.["rotWithShape"] !== void 0) result.rotateWithShape = el.attributes["rotWithShape"] !== "0";
6891
- const tileRectangle = findChild(el, "a:tileRect");
6892
- if (tileRectangle) result.tileRectangle = readRelativeRect(tileRectangle);
6699
+ if (el.attributes?.["algn"] !== void 0) result.align = xsdRectAlignment.from(String(el.attributes["algn"]));
6893
6700
  return result;
6894
6701
  }
6895
6702
  };
6896
- const patternFillDesc = {
6703
+ const sourceRectangleDesc = {
6897
6704
  kind: "custom",
6898
- stringify(opts, ctx) {
6899
- const parts = [];
6900
- const prst = xsdPattern.to(opts.pattern);
6901
- if (opts.foregroundColor) {
6902
- const colorXml = stringify$1(getColorDescriptor(opts.foregroundColor), opts.foregroundColor, ctx);
6903
- if (colorXml) parts.push(`<a:fgClr>${colorXml}</a:fgClr>`);
6904
- }
6905
- if (opts.backgroundColor) {
6906
- const colorXml = stringify$1(getColorDescriptor(opts.backgroundColor), opts.backgroundColor, ctx);
6907
- if (colorXml) parts.push(`<a:bgClr>${colorXml}</a:bgClr>`);
6908
- }
6909
- const inner = parts.join("");
6910
- return `<a:pattFill prst="${escapeXml(prst)}">${inner}</a:pattFill>`;
6705
+ stringify(opts, _ctx) {
6706
+ const attrParts = [];
6707
+ if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
6708
+ if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
6709
+ if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
6710
+ if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
6711
+ return `<a:srcRect${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
6911
6712
  },
6912
- parse(el, ctx) {
6713
+ parse(el, _ctx) {
6913
6714
  const result = {};
6914
- const prst = el.attributes?.["prst"];
6915
- if (prst) result.pattern = xsdPattern.from(String(prst));
6916
- const fgClr = findChild(el, "a:fgClr");
6917
- if (fgClr) result.foregroundColor = readDirectColor(fgClr, ctx);
6918
- const bgClr = findChild(el, "a:bgClr");
6919
- if (bgClr) result.backgroundColor = readDirectColor(bgClr, ctx);
6715
+ if (el.attributes?.["l"] !== void 0) result.left = Number(el.attributes["l"]);
6716
+ if (el.attributes?.["t"] !== void 0) result.top = Number(el.attributes["t"]);
6717
+ if (el.attributes?.["r"] !== void 0) result.right = Number(el.attributes["r"]);
6718
+ if (el.attributes?.["b"] !== void 0) result.bottom = Number(el.attributes["b"]);
6920
6719
  return result;
6921
6720
  }
6922
6721
  };
6923
- const fillDesc = {
6924
- kind: "custom",
6925
- stringify(opts, ctx) {
6926
- if (typeof opts === "string") return stringify$1(solidFillDesc, { value: opts.replace("#", "") }, ctx);
6927
- switch (opts.type) {
6928
- case "none": return "<a:noFill/>";
6929
- case "solid": return stringify$1(solidFillDesc, typeof opts.color === "string" ? { value: opts.color.replace("#", "") } : opts.color, ctx);
6930
- case "gradient": {
6931
- if ("options" in opts) return stringify$1(gradientFillDesc, opts.options, ctx);
6932
- const gradOpts = { stops: opts.stops.map((stop) => ({
6933
- position: stop.position * 1e3,
6934
- color: typeof stop.color === "string" ? { value: stop.color.replace("#", "") } : stop.color
6935
- })) };
6936
- if (!opts.path && opts.angle !== void 0) gradOpts.shade = {
6937
- angle: opts.angle * 6e4,
6938
- scaled: opts.scaled ?? true
6939
- };
6940
- if (opts.path) gradOpts.shade = { path: opts.path };
6941
- return stringify$1(gradientFillDesc, gradOpts, ctx);
6942
- }
6943
- case "blip": return;
6944
- case "pattern": return stringify$1(patternFillDesc, {
6945
- pattern: opts.pattern,
6946
- ...opts.foregroundColor && { foregroundColor: typeof opts.foregroundColor === "string" ? { value: opts.foregroundColor.replace("#", "") } : opts.foregroundColor },
6947
- ...opts.backgroundColor && { backgroundColor: typeof opts.backgroundColor === "string" ? { value: opts.backgroundColor.replace("#", "") } : opts.backgroundColor }
6948
- }, ctx);
6949
- case "group": return "<a:grpFill/>";
6950
- }
6951
- },
6952
- parse(el, ctx) {
6953
- const resolve = (tag) => el.name === tag ? el : findChild(el, tag);
6954
- if (resolve("a:noFill")) return { type: "none" };
6955
- const solidFill = resolve("a:solidFill");
6956
- if (solidFill) return {
6957
- type: "solid",
6958
- color: parse$1(solidFillDesc, solidFill, ctx)
6959
- };
6960
- const gradFill = resolve("a:gradFill");
6961
- if (gradFill) return {
6962
- type: "gradient",
6963
- options: parse$1(gradientFillDesc, gradFill, ctx)
6964
- };
6965
- const pattFill = resolve("a:pattFill");
6966
- if (pattFill) return {
6967
- type: "pattern",
6968
- ...parse$1(patternFillDesc, pattFill, ctx)
6969
- };
6970
- if (resolve("a:grpFill")) return { type: "group" };
6971
- return { type: "none" };
6972
- }
6973
- };
6974
- function readDirectColor(el, ctx) {
6975
- const color = parseColorChoice(el, ctx);
6976
- if (Object.keys(color).length > 0) return color;
6977
- const solidFill = findChild(el, "a:solidFill");
6978
- if (solidFill) return parse$1(solidFillDesc, solidFill, ctx);
6979
- return { value: "" };
6980
- }
6981
- //#endregion
6982
- //#region src/drawingml/outline/outline-descriptors.ts
6983
- /**
6984
- * Outline descriptor for DrawingML shapes.
6985
- *
6986
- * @module
6987
- */
6988
- function stringifyLineEnd(tag, opts) {
6989
- const parts = [];
6990
- if (opts.type) parts.push(`type="${escapeXml(opts.type)}"`);
6991
- if (opts.width) parts.push(`w="${escapeXml(opts.width)}"`);
6992
- if (opts.length) parts.push(`len="${escapeXml(opts.length)}"`);
6993
- return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
6994
- }
6995
- function readLineEnd(el) {
6996
- const result = {};
6997
- if (el.attributes?.["type"]) result.type = String(el.attributes["type"]);
6998
- if (el.attributes?.["w"]) result.width = String(el.attributes["w"]);
6999
- if (el.attributes?.["len"]) result.length = String(el.attributes["len"]);
7000
- return result;
7001
- }
7002
- function stringifyCustomDash(stops) {
7003
- return `<a:custDash>${stops.map((s) => `<a:ds d="${escapeXml(s.d)}" sp="${escapeXml(s.sp)}"/>`).join("")}</a:custDash>`;
7004
- }
7005
- const outlineDesc = {
6722
+ const stretchDesc = {
7006
6723
  kind: "custom",
7007
- stringify(opts, ctx) {
7008
- const parts = [];
6724
+ stringify(opts, _ctx) {
7009
6725
  const attrParts = [];
7010
- if (opts.width !== void 0) attrParts.push(`w="${convertToEmu(opts.width)}"`);
7011
- if (opts.cap !== void 0) attrParts.push(`cap="${escapeXml(opts.cap)}"`);
7012
- if (opts.compoundLine !== void 0) attrParts.push(`cmpd="${escapeXml(opts.compoundLine)}"`);
7013
- if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(opts.align)}"`);
7014
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7015
- if (opts.type === "noFill") parts.push("<a:noFill/>");
7016
- else if (opts.type === "solidFill" && opts.color) {
7017
- const fillXml = stringify$1(solidFillDesc, opts.color, ctx);
7018
- if (fillXml) parts.push(fillXml);
7019
- } else if (opts.type === "gradFill" && opts.gradientFill) {
7020
- const gradXml = stringify$1(gradientFillDesc, opts.gradientFill, ctx);
7021
- if (gradXml) parts.push(gradXml);
7022
- }
7023
- if (opts.customDash) parts.push(stringifyCustomDash(opts.customDash));
7024
- else if (opts.dash) parts.push(`<a:prstDash val="${escapeXml(opts.dash)}"/>`);
7025
- if (opts.join) if (opts.join === "miter" && opts.miterLimit !== void 0) parts.push(`<a:miter lim="${opts.miterLimit}"/>`);
7026
- else parts.push(`<a:${opts.join}/>`);
7027
- if (opts.headEnd) parts.push(stringifyLineEnd("a:headEnd", opts.headEnd));
7028
- if (opts.tailEnd) parts.push(stringifyLineEnd("a:tailEnd", opts.tailEnd));
7029
- if (parts.length === 0 && !attrStr) return void 0;
7030
- if (parts.length === 0) return `<a:ln${attrStr}/>`;
7031
- return `<a:ln${attrStr}>${parts.join("")}</a:ln>`;
6726
+ if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
6727
+ if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
6728
+ if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
6729
+ if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
6730
+ return `<a:stretch><a:fillRect${attrParts.length ? " " + attrParts.join(" ") : ""}/></a:stretch>`;
7032
6731
  },
7033
6732
  parse(el, _ctx) {
6733
+ const fillRect = findChild(el, "a:fillRect");
6734
+ if (!fillRect) return {};
7034
6735
  const result = {};
7035
- if (el.attributes) {
7036
- if (el.attributes["w"] !== void 0) result.width = Number(el.attributes["w"]);
7037
- if (el.attributes["cap"] !== void 0) result.cap = String(el.attributes["cap"]);
7038
- if (el.attributes["cmpd"] !== void 0) result.compoundLine = String(el.attributes["cmpd"]);
7039
- if (el.attributes["algn"] !== void 0) result.align = String(el.attributes["algn"]);
7040
- }
7041
- const solidFill = findChild(el, "a:solidFill");
7042
- if (solidFill) {
7043
- result.type = "solidFill";
7044
- result.color = parse$1(solidFillDesc, solidFill, _ctx);
7045
- }
7046
- if (findChild(el, "a:noFill")) result.type = "noFill";
7047
- if (findChild(el, "a:gradFill")) {
7048
- result.type = "gradFill";
7049
- result.gradientFill = parse$1(gradientFillDesc, findChild(el, "a:gradFill"), _ctx);
7050
- }
7051
- const prstDash = findChild(el, "a:prstDash");
7052
- if (prstDash?.attributes?.["val"]) result.dash = String(prstDash.attributes["val"]);
7053
- const custDash = findChild(el, "a:custDash");
7054
- if (custDash?.elements) result.customDash = custDash.elements.filter((c) => c.name === "a:ds").map((c) => ({
7055
- d: String(c.attributes?.["d"] ?? ""),
7056
- sp: String(c.attributes?.["sp"] ?? "")
7057
- }));
7058
- if (findChild(el, "a:round")) result.join = "round";
7059
- else if (findChild(el, "a:bevel")) result.join = "bevel";
7060
- else {
7061
- const miter = findChild(el, "a:miter");
7062
- if (miter) {
7063
- result.join = "miter";
7064
- if (miter.attributes?.["lim"]) result.miterLimit = Number(miter.attributes["lim"]);
7065
- }
7066
- }
7067
- const headEnd = findChild(el, "a:headEnd");
7068
- if (headEnd) result.headEnd = readLineEnd(headEnd);
7069
- const tailEnd = findChild(el, "a:tailEnd");
7070
- if (tailEnd) result.tailEnd = readLineEnd(tailEnd);
6736
+ if (fillRect.attributes?.["l"] !== void 0) result.left = Number(fillRect.attributes["l"]);
6737
+ if (fillRect.attributes?.["t"] !== void 0) result.top = Number(fillRect.attributes["t"]);
6738
+ if (fillRect.attributes?.["r"] !== void 0) result.right = Number(fillRect.attributes["r"]);
6739
+ if (fillRect.attributes?.["b"] !== void 0) result.bottom = Number(fillRect.attributes["b"]);
7071
6740
  return result;
7072
6741
  }
7073
6742
  };
7074
- //#endregion
7075
- //#region src/drawingml/effects/effect-descriptors.ts
7076
- /**
7077
- * Effect list descriptor for DrawingML shapes.
7078
- *
7079
- * @module
7080
- */
7081
- function stringifyEffectColor(color, ctx) {
7082
- if (!color) return void 0;
7083
- return stringify$1(getColorDescriptor(color), color, ctx);
7084
- }
7085
- function stringifyColorEffect(tag, attrs, color, ctx) {
7086
- const attrParts = [];
7087
- for (const [key, val] of Object.entries(attrs)) if (val !== void 0) attrParts.push(`${key}="${escapeXml(String(val))}"`);
7088
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7089
- const colorXml = stringifyEffectColor(color, ctx);
7090
- if (!colorXml && !attrStr) return void 0;
7091
- if (!colorXml) return `<${tag}${attrStr}/>`;
7092
- return `<${tag}${attrStr}>${colorXml}</${tag}>`;
7093
- }
7094
- function readColorFromElement(el, ctx) {
7095
- const color = parseColorChoice(el, ctx);
7096
- if (!color || Object.keys(color).length === 0) return void 0;
7097
- return color;
7098
- }
7099
- const effectListDesc = {
7100
- kind: "custom",
7101
- stringify(opts, ctx) {
7102
- const parts = [];
7103
- if (opts.blur) {
7104
- const attrParts = [];
7105
- if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
7106
- if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
7107
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7108
- parts.push(`<a:blur${attrStr}/>`);
7109
- }
7110
- if (opts.fillOverlay) parts.push(`<a:fillOverlay blend="${escapeXml(opts.fillOverlay.blend)}"/>`);
7111
- if (opts.glow) parts.push(stringifyColorEffect("a:glow", { rad: opts.glow.radius }, opts.glow.color, ctx) ?? "");
7112
- if (opts.innerShadow) parts.push(stringifyColorEffect("a:innerShdw", {
7113
- blurRad: opts.innerShadow.blurRadius,
7114
- dist: opts.innerShadow.distance,
7115
- dir: opts.innerShadow.direction
7116
- }, opts.innerShadow.color, ctx) ?? "");
7117
- if (opts.outerShadow) parts.push(stringifyColorEffect("a:outerShdw", {
7118
- blurRad: opts.outerShadow.blurRadius,
7119
- dist: opts.outerShadow.distance,
7120
- dir: opts.outerShadow.direction,
7121
- sx: opts.outerShadow.scaleX,
7122
- sy: opts.outerShadow.scaleY,
7123
- kx: opts.outerShadow.skewX,
7124
- ky: opts.outerShadow.skewY,
7125
- algn: opts.outerShadow.alignment,
7126
- rotWithShape: opts.outerShadow.rotWithShape === false ? 0 : void 0
7127
- }, opts.outerShadow.color, ctx) ?? "");
7128
- if (opts.presetShadow) parts.push(stringifyColorEffect("a:prstShdw", {
7129
- prst: opts.presetShadow.preset,
7130
- dist: opts.presetShadow.distance,
7131
- dir: opts.presetShadow.direction
7132
- }, opts.presetShadow.color, ctx) ?? "");
7133
- if (opts.reflection) {
7134
- const refOpts = opts.reflection === true ? {} : opts.reflection;
7135
- const attrParts = [];
7136
- if (refOpts.blurRadius !== void 0) attrParts.push(`blurRad="${refOpts.blurRadius}"`);
7137
- if (refOpts.startAlpha !== void 0) attrParts.push(`stA="${refOpts.startAlpha}"`);
7138
- if (refOpts.startPosition !== void 0) attrParts.push(`stPos="${refOpts.startPosition}"`);
7139
- if (refOpts.endAlpha !== void 0) attrParts.push(`endA="${refOpts.endAlpha}"`);
7140
- if (refOpts.endPosition !== void 0) attrParts.push(`endPos="${refOpts.endPosition}"`);
7141
- if (refOpts.distance !== void 0) attrParts.push(`dist="${refOpts.distance}"`);
7142
- if (refOpts.direction !== void 0) attrParts.push(`dir="${refOpts.direction}"`);
7143
- if (refOpts.fadeDirection !== void 0) attrParts.push(`fadeDir="${refOpts.fadeDirection}"`);
7144
- if (refOpts.scaleX !== void 0) attrParts.push(`sx="${refOpts.scaleX}"`);
7145
- if (refOpts.scaleY !== void 0) attrParts.push(`sy="${refOpts.scaleY}"`);
7146
- if (refOpts.skewX !== void 0) attrParts.push(`kx="${refOpts.skewX}"`);
7147
- if (refOpts.skewY !== void 0) attrParts.push(`ky="${refOpts.skewY}"`);
7148
- if (refOpts.alignment !== void 0) attrParts.push(`algn="${refOpts.alignment}"`);
7149
- if (refOpts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${refOpts.rotWithShape ? 1 : 0}"`);
7150
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7151
- parts.push(`<a:reflection${attrStr}/>`);
6743
+ function stringifyBlipEffects(opts, ctx) {
6744
+ const parts = [];
6745
+ if (opts.grayscale) parts.push("<a:grayscl/>");
6746
+ if (opts.luminance) {
6747
+ const attrParts = [];
6748
+ if (opts.luminance.bright !== void 0) attrParts.push(`bright="${opts.luminance.bright}"`);
6749
+ if (opts.luminance.contrast !== void 0) attrParts.push(`contrast="${opts.luminance.contrast}"`);
6750
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6751
+ parts.push(`<a:lum${attrStr}/>`);
6752
+ }
6753
+ if (opts.hsl) {
6754
+ const attrParts = [];
6755
+ if (opts.hsl.hue !== void 0) attrParts.push(`hue="${opts.hsl.hue}"`);
6756
+ if (opts.hsl.saturation !== void 0) attrParts.push(`sat="${opts.hsl.saturation}"`);
6757
+ if (opts.hsl.luminance !== void 0) attrParts.push(`lum="${opts.hsl.luminance}"`);
6758
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6759
+ parts.push(`<a:hsl${attrStr}/>`);
6760
+ }
6761
+ if (opts.tint) {
6762
+ const attrParts = [];
6763
+ if (opts.tint.hue !== void 0) attrParts.push(`hue="${opts.tint.hue}"`);
6764
+ if (opts.tint.amount !== void 0) attrParts.push(`amt="${opts.tint.amount}"`);
6765
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6766
+ parts.push(`<a:tint${attrStr}/>`);
6767
+ }
6768
+ if (opts.duotone) {
6769
+ const c1 = stringify$1(solidFillDesc, opts.duotone.color1, ctx);
6770
+ const c2 = stringify$1(solidFillDesc, opts.duotone.color2, ctx);
6771
+ parts.push(`<a:duotone>${c1 ?? ""}${c2 ?? ""}</a:duotone>`);
6772
+ }
6773
+ if (opts.biLevel) parts.push(`<a:biLevel thresh="${opts.biLevel.threshold}"/>`);
6774
+ if (opts.alphaCeiling) parts.push("<a:alphaCeiling/>");
6775
+ if (opts.alphaFloor) parts.push("<a:alphaFloor/>");
6776
+ if (opts.alphaInverse !== void 0) if (typeof opts.alphaInverse === "boolean") parts.push("<a:alphaInv/>");
6777
+ else {
6778
+ const colorXml = stringify$1(solidFillDesc, opts.alphaInverse, ctx);
6779
+ parts.push(`<a:alphaInv>${colorXml ?? ""}</a:alphaInv>`);
6780
+ }
6781
+ if (opts.alphaModFix) {
6782
+ const amt = opts.alphaModFix.amount ?? 100;
6783
+ parts.push(`<a:alphaModFix amt="${amt}"/>`);
6784
+ }
6785
+ if (opts.alphaRepl) parts.push(`<a:alphaRepl a="${opts.alphaRepl.amount}"/>`);
6786
+ if (opts.alphaBiLevel) parts.push(`<a:alphaBiLevel thresh="${opts.alphaBiLevel.threshold}"/>`);
6787
+ if (opts.colorChange) {
6788
+ const fromXml = stringify$1(solidFillDesc, opts.colorChange.from, ctx);
6789
+ const toXml = stringify$1(solidFillDesc, opts.colorChange.to, ctx);
6790
+ const attrParts = [];
6791
+ if (opts.colorChange.useAlpha === false) attrParts.push("useA=\"0\"");
6792
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6793
+ parts.push(`<a:clrChange${attrStr}><a:clrFrom>${fromXml ?? ""}</a:clrFrom><a:clrTo>${toXml ?? ""}</a:clrTo></a:clrChange>`);
6794
+ }
6795
+ if (opts.colorRepl) {
6796
+ const colorXml = stringify$1(solidFillDesc, opts.colorRepl.color, ctx);
6797
+ parts.push(`<a:clrRepl>${colorXml ?? ""}</a:clrRepl>`);
6798
+ }
6799
+ if (opts.blur) {
6800
+ const attrParts = [];
6801
+ if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
6802
+ if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
6803
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6804
+ parts.push(`<a:blur${attrStr}/>`);
6805
+ }
6806
+ return parts.join("");
6807
+ }
6808
+ function readBlipEffects(el, ctx) {
6809
+ const result = {};
6810
+ if (findChild(el, "a:grayscl")) result.grayscale = true;
6811
+ const lum = findChild(el, "a:lum");
6812
+ if (lum) {
6813
+ const opts = {};
6814
+ if (lum.attributes?.["bright"] !== void 0) opts.bright = Number(String(lum.attributes["bright"]).replace("%", ""));
6815
+ if (lum.attributes?.["contrast"] !== void 0) opts.contrast = Number(String(lum.attributes["contrast"]).replace("%", ""));
6816
+ result.luminance = opts;
6817
+ }
6818
+ const hsl = findChild(el, "a:hsl");
6819
+ if (hsl) {
6820
+ const opts = {};
6821
+ if (hsl.attributes?.["hue"] !== void 0) opts.hue = Number(hsl.attributes["hue"]);
6822
+ if (hsl.attributes?.["sat"] !== void 0) opts.saturation = Number(String(hsl.attributes["sat"]).replace("%", ""));
6823
+ if (hsl.attributes?.["lum"] !== void 0) opts.luminance = Number(String(hsl.attributes["lum"]).replace("%", ""));
6824
+ result.hsl = opts;
6825
+ }
6826
+ const tint = findChild(el, "a:tint");
6827
+ if (tint) {
6828
+ const opts = {};
6829
+ if (tint.attributes?.["hue"] !== void 0) opts.hue = Number(tint.attributes["hue"]);
6830
+ if (tint.attributes?.["amt"] !== void 0) opts.amount = Number(String(tint.attributes["amt"]).replace("%", ""));
6831
+ result.tint = opts;
6832
+ }
6833
+ const biLevel = findChild(el, "a:biLevel");
6834
+ if (biLevel?.attributes?.["thresh"] !== void 0) result.biLevel = { threshold: Number(String(biLevel.attributes["thresh"]).replace("%", "")) };
6835
+ if (findChild(el, "a:alphaCeiling")) result.alphaCeiling = true;
6836
+ if (findChild(el, "a:alphaFloor")) result.alphaFloor = true;
6837
+ const alphaInv = findChild(el, "a:alphaInv");
6838
+ if (alphaInv) {
6839
+ const solidFill = findChild(alphaInv, "a:solidFill");
6840
+ if (solidFill) result.alphaInverse = parse$1(solidFillDesc, solidFill, ctx);
6841
+ else result.alphaInverse = {};
6842
+ }
6843
+ const alphaModFix = findChild(el, "a:alphaModFix");
6844
+ if (alphaModFix) {
6845
+ const opts = {};
6846
+ if (alphaModFix.attributes?.["amt"] !== void 0) opts.amount = Number(String(alphaModFix.attributes["amt"]).replace("%", ""));
6847
+ result.alphaModFix = opts;
6848
+ }
6849
+ const alphaRepl = findChild(el, "a:alphaRepl");
6850
+ if (alphaRepl?.attributes?.["a"] !== void 0) result.alphaRepl = { amount: Number(String(alphaRepl.attributes["a"]).replace("%", "")) };
6851
+ const alphaBiLevel = findChild(el, "a:alphaBiLevel");
6852
+ if (alphaBiLevel?.attributes?.["thresh"] !== void 0) result.alphaBiLevel = { threshold: Number(String(alphaBiLevel.attributes["thresh"]).replace("%", "")) };
6853
+ const clrChange = findChild(el, "a:clrChange");
6854
+ if (clrChange) {
6855
+ const opts = {};
6856
+ if (clrChange.attributes?.["useA"] !== void 0) opts.useAlpha = clrChange.attributes["useA"] !== "0";
6857
+ const clrFrom = findChild(clrChange, "a:clrFrom");
6858
+ if (clrFrom) {
6859
+ const fromFill = findChild(clrFrom, "a:solidFill");
6860
+ if (fromFill) opts.from = parse$1(solidFillDesc, fromFill, ctx);
7152
6861
  }
7153
- if (opts.softEdge !== void 0) parts.push(`<a:softEdge rad="${opts.softEdge}"/>`);
7154
- const content = parts.filter(Boolean).join("");
7155
- if (!content) return void 0;
7156
- return `<a:effectLst>${content}</a:effectLst>`;
6862
+ const clrTo = findChild(clrChange, "a:clrTo");
6863
+ if (clrTo) {
6864
+ const toFill = findChild(clrTo, "a:solidFill");
6865
+ if (toFill) opts.to = parse$1(solidFillDesc, toFill, ctx);
6866
+ }
6867
+ result.colorChange = opts;
6868
+ }
6869
+ const clrRepl = findChild(el, "a:clrRepl");
6870
+ if (clrRepl) {
6871
+ const solidFill = findChild(clrRepl, "a:solidFill");
6872
+ if (solidFill) result.colorRepl = { color: parse$1(solidFillDesc, solidFill, ctx) };
6873
+ }
6874
+ const blur = findChild(el, "a:blur");
6875
+ if (blur) {
6876
+ const opts = {};
6877
+ if (blur.attributes?.["rad"] !== void 0) opts.radius = Number(blur.attributes["rad"]);
6878
+ if (blur.attributes?.["grow"] !== void 0) opts.grow = blur.attributes["grow"] !== "0";
6879
+ result.blur = opts;
6880
+ }
6881
+ const duotone = findChild(el, "a:duotone");
6882
+ if (duotone?.elements) {
6883
+ const fills = [];
6884
+ for (const child of duotone.elements) {
6885
+ const sf = findChild(child, "a:solidFill");
6886
+ if (sf) fills.push(parse$1(solidFillDesc, sf, ctx));
6887
+ }
6888
+ if (fills.length >= 2) result.duotone = {
6889
+ color1: fills[0],
6890
+ color2: fills[1]
6891
+ };
6892
+ }
6893
+ return Object.keys(result).length > 0 ? result : void 0;
6894
+ }
6895
+ const blipDesc = {
6896
+ kind: "custom",
6897
+ stringify(opts, ctx) {
6898
+ const attrParts = [];
6899
+ const embedValue = `{${opts.referenceId}}`;
6900
+ attrParts.push(`r:embed="${escapeXml(embedValue)}"`);
6901
+ attrParts.push("cstate=\"none\"");
6902
+ const attrStr = " " + attrParts.join(" ");
6903
+ const parts = [];
6904
+ if (opts.blipEffects) parts.push(stringifyBlipEffects(opts.blipEffects, ctx));
6905
+ const content = parts.join("");
6906
+ if (!content) return `<a:blip${attrStr}/>`;
6907
+ return `<a:blip${attrStr}>${content}</a:blip>`;
7157
6908
  },
7158
6909
  parse(el, ctx) {
7159
6910
  const result = {};
7160
- const blur = findChild(el, "a:blur");
7161
- if (blur) {
7162
- const blurOpts = {};
7163
- if (blur.attributes?.["rad"] !== void 0) blurOpts.radius = Number(blur.attributes["rad"]);
7164
- if (blur.attributes?.["grow"] !== void 0) blurOpts.grow = blur.attributes["grow"] !== "0";
7165
- result.blur = blurOpts;
7166
- }
7167
- const glow = findChild(el, "a:glow");
7168
- if (glow) {
7169
- const glowOpts = {};
7170
- if (glow.attributes?.["rad"] !== void 0) glowOpts.radius = Number(glow.attributes["rad"]);
7171
- const color = readColorFromElement(glow, ctx);
7172
- if (color) glowOpts.color = color;
7173
- result.glow = glowOpts;
7174
- }
7175
- const innerShdw = findChild(el, "a:innerShdw");
7176
- if (innerShdw) {
7177
- const innerOpts = {};
7178
- if (innerShdw.attributes?.["blurRad"] !== void 0) innerOpts.blurRadius = Number(innerShdw.attributes["blurRad"]);
7179
- if (innerShdw.attributes?.["dist"] !== void 0) innerOpts.distance = Number(innerShdw.attributes["dist"]);
7180
- if (innerShdw.attributes?.["dir"] !== void 0) innerOpts.direction = Number(innerShdw.attributes["dir"]);
7181
- const color = readColorFromElement(innerShdw, ctx);
7182
- if (color) innerOpts.color = color;
7183
- result.innerShadow = innerOpts;
7184
- }
7185
- const outerShdw = findChild(el, "a:outerShdw");
7186
- if (outerShdw) {
7187
- const outerOpts = {};
7188
- if (outerShdw.attributes?.["blurRad"] !== void 0) outerOpts.blurRadius = Number(outerShdw.attributes["blurRad"]);
7189
- if (outerShdw.attributes?.["dist"] !== void 0) outerOpts.distance = Number(outerShdw.attributes["dist"]);
7190
- if (outerShdw.attributes?.["dir"] !== void 0) outerOpts.direction = Number(outerShdw.attributes["dir"]);
7191
- if (outerShdw.attributes?.["sx"] !== void 0) outerOpts.scaleX = Number(outerShdw.attributes["sx"]);
7192
- if (outerShdw.attributes?.["sy"] !== void 0) outerOpts.scaleY = Number(outerShdw.attributes["sy"]);
7193
- if (outerShdw.attributes?.["kx"] !== void 0) outerOpts.skewX = Number(outerShdw.attributes["kx"]);
7194
- if (outerShdw.attributes?.["ky"] !== void 0) outerOpts.skewY = Number(outerShdw.attributes["ky"]);
7195
- if (outerShdw.attributes?.["algn"] !== void 0) outerOpts.alignment = String(outerShdw.attributes["algn"]);
7196
- if (outerShdw.attributes?.["rotWithShape"] !== void 0) outerOpts.rotWithShape = outerShdw.attributes["rotWithShape"] !== "0";
7197
- const color = readColorFromElement(outerShdw, ctx);
7198
- if (color) outerOpts.color = color;
7199
- result.outerShadow = outerOpts;
7200
- }
7201
- const fillOverlay = findChild(el, "a:fillOverlay");
7202
- if (fillOverlay) {
7203
- const overlayOpts = {};
7204
- if (fillOverlay.attributes?.["blend"] !== void 0) overlayOpts.blend = String(fillOverlay.attributes["blend"]);
7205
- result.fillOverlay = overlayOpts;
7206
- }
7207
- const prstShdw = findChild(el, "a:prstShdw");
7208
- if (prstShdw) {
7209
- const prstOpts = {};
7210
- if (prstShdw.attributes?.["prst"] !== void 0) prstOpts.preset = String(prstShdw.attributes["prst"]);
7211
- if (prstShdw.attributes?.["dist"] !== void 0) prstOpts.distance = Number(prstShdw.attributes["dist"]);
7212
- if (prstShdw.attributes?.["dir"] !== void 0) prstOpts.direction = Number(prstShdw.attributes["dir"]);
7213
- const color = readColorFromElement(prstShdw, ctx);
7214
- if (color) prstOpts.color = color;
7215
- result.presetShadow = prstOpts;
7216
- }
7217
- const reflection = findChild(el, "a:reflection");
7218
- if (reflection) {
7219
- const refOpts = {};
7220
- if (reflection.attributes?.["blurRad"] !== void 0) refOpts.blurRadius = Number(reflection.attributes["blurRad"]);
7221
- if (reflection.attributes?.["stA"] !== void 0) refOpts.startAlpha = Number(reflection.attributes["stA"]);
7222
- if (reflection.attributes?.["stPos"] !== void 0) refOpts.startPosition = Number(reflection.attributes["stPos"]);
7223
- if (reflection.attributes?.["endA"] !== void 0) refOpts.endAlpha = Number(reflection.attributes["endA"]);
7224
- if (reflection.attributes?.["endPos"] !== void 0) refOpts.endPosition = Number(reflection.attributes["endPos"]);
7225
- if (reflection.attributes?.["dist"] !== void 0) refOpts.distance = Number(reflection.attributes["dist"]);
7226
- if (reflection.attributes?.["dir"] !== void 0) refOpts.direction = Number(reflection.attributes["dir"]);
7227
- if (reflection.attributes?.["fadeDir"] !== void 0) refOpts.fadeDirection = Number(reflection.attributes["fadeDir"]);
7228
- if (reflection.attributes?.["sx"] !== void 0) refOpts.scaleX = Number(reflection.attributes["sx"]);
7229
- if (reflection.attributes?.["sy"] !== void 0) refOpts.scaleY = Number(reflection.attributes["sy"]);
7230
- if (reflection.attributes?.["kx"] !== void 0) refOpts.skewX = Number(reflection.attributes["kx"]);
7231
- if (reflection.attributes?.["ky"] !== void 0) refOpts.skewY = Number(reflection.attributes["ky"]);
7232
- if (reflection.attributes?.["algn"] !== void 0) refOpts.alignment = String(reflection.attributes["algn"]);
7233
- if (reflection.attributes?.["rotWithShape"] !== void 0) refOpts.rotWithShape = reflection.attributes["rotWithShape"] !== "0";
7234
- result.reflection = refOpts;
6911
+ const embed = el.attributes?.["r:embed"];
6912
+ if (embed !== void 0) result.referenceId = String(embed).replace(/^\{(.+)\}$/, "$1");
6913
+ const link = el.attributes?.["r:link"];
6914
+ if (link !== void 0) result.referenceId = String(link).replace(/^\{(.+)\}$/, "$1");
6915
+ const effects = readBlipEffects(el, ctx);
6916
+ if (effects) result.blipEffects = effects;
6917
+ return result;
6918
+ }
6919
+ };
6920
+ const blipFillDesc = {
6921
+ kind: "custom",
6922
+ stringify(opts, ctx) {
6923
+ const attrParts = [];
6924
+ if (opts.dpi !== void 0) attrParts.push(`dpi="${opts.dpi}"`);
6925
+ if (opts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotWithShape ? 1 : 0}"`);
6926
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
6927
+ const parts = [];
6928
+ if (opts.referenceId) {
6929
+ const blipXml = stringify$1(blipDesc, {
6930
+ referenceId: opts.referenceId,
6931
+ blipEffects: opts.blipEffects
6932
+ }, ctx);
6933
+ if (blipXml) parts.push(blipXml);
7235
6934
  }
7236
- const softEdge = findChild(el, "a:softEdge");
7237
- if (softEdge?.attributes?.["rad"] !== void 0) result.softEdge = Number(softEdge.attributes["rad"]);
6935
+ if (opts.sourceRectangle) {
6936
+ const srcRectXml = stringify$1(sourceRectangleDesc, opts.sourceRectangle, ctx);
6937
+ if (srcRectXml) parts.push(srcRectXml);
6938
+ }
6939
+ if (opts.tile) {
6940
+ const tileXml = stringify$1(tileDesc, opts.tile, ctx);
6941
+ if (tileXml) parts.push(tileXml);
6942
+ } else parts.push("<a:stretch><a:fillRect/></a:stretch>");
6943
+ const content = parts.join("");
6944
+ if (!attrStr && !content) return void 0;
6945
+ if (!content) return `<pic:blipFill${attrStr}/>`;
6946
+ return `<pic:blipFill${attrStr}>${content}</pic:blipFill>`;
6947
+ },
6948
+ parse(el, ctx) {
6949
+ const result = {};
6950
+ if (el.attributes?.["dpi"] !== void 0) result.dpi = Number(el.attributes["dpi"]);
6951
+ if (el.attributes?.["rotWithShape"] !== void 0) result.rotWithShape = el.attributes["rotWithShape"] !== "0";
6952
+ const blip = findChild(el, "a:blip");
6953
+ if (blip) {
6954
+ const blipResult = parse$1(blipDesc, blip, ctx);
6955
+ if (blipResult.referenceId) result.referenceId = blipResult.referenceId;
6956
+ if (blipResult.blipEffects) result.blipEffects = blipResult.blipEffects;
6957
+ }
6958
+ const srcRect = findChild(el, "a:srcRect");
6959
+ if (srcRect) result.sourceRectangle = parse$1(sourceRectangleDesc, srcRect, ctx);
6960
+ const tile = findChild(el, "a:tile");
6961
+ if (tile) result.tile = parse$1(tileDesc, tile, ctx);
7238
6962
  return result;
7239
6963
  }
7240
6964
  };
7241
6965
  //#endregion
7242
- //#region src/drawingml/locking/locking-descriptors.ts
7243
- const BASE_LOCKING_KEYS = [
7244
- "noGrp",
7245
- "noSelect",
7246
- "noRot",
7247
- "noChangeAspect",
7248
- "noMove",
7249
- "noResize",
7250
- "noEditPoints",
7251
- "noAdjustHandles",
7252
- "noChangeArrowheads",
7253
- "noChangeShapeType"
7254
- ];
7255
- const SHAPE_EXTRA_KEYS = ["noTextEdit"];
7256
- const PICTURE_EXTRA_KEYS = ["noCrop"];
7257
- const GROUP_EXTRA_KEYS = ["noUngrp"];
7258
- const FRAME_EXTRA_KEYS = ["noDrilldown"];
7259
- function stringifyLockingAttrs(opts, keys) {
6966
+ //#region src/drawingml/fill/fill-descriptors.ts
6967
+ /**
6968
+ * Fill descriptors for DrawingML EG_FillProperties.
6969
+ *
6970
+ * @module
6971
+ */
6972
+ function stringifyRelativeRect(tag, rect) {
7260
6973
  const parts = [];
7261
- for (const key of keys) if (opts[key] !== void 0) parts.push(`${key}="${opts[key] ? 1 : 0}"`);
7262
- return parts.length ? " " + parts.join(" ") : "";
6974
+ if (rect.left) parts.push(`l="${escapeXml(rect.left)}"`);
6975
+ if (rect.top) parts.push(`t="${escapeXml(rect.top)}"`);
6976
+ if (rect.right) parts.push(`r="${escapeXml(rect.right)}"`);
6977
+ if (rect.bottom) parts.push(`b="${escapeXml(rect.bottom)}"`);
6978
+ return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
7263
6979
  }
7264
- function readLockingAttrs(el, keys) {
6980
+ function readRelativeRect(el) {
7265
6981
  const result = {};
7266
- if (!el.attributes) return result;
7267
- for (const key of keys) {
7268
- const val = el.attributes[key];
7269
- if (val !== void 0) result[key] = val === "1" || val === 1 || val === "true";
7270
- }
6982
+ if (el.attributes?.["l"]) result.left = String(el.attributes["l"]);
6983
+ if (el.attributes?.["t"]) result.top = String(el.attributes["t"]);
6984
+ if (el.attributes?.["r"]) result.right = String(el.attributes["r"]);
6985
+ if (el.attributes?.["b"]) result.bottom = String(el.attributes["b"]);
7271
6986
  return result;
7272
6987
  }
7273
- const shapeLockingDesc = {
7274
- kind: "custom",
7275
- stringify(opts, _ctx) {
7276
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7277
- if (!attrStr) return void 0;
7278
- return `<a:spLocks${attrStr}/>`;
7279
- },
7280
- parse(el, _ctx) {
7281
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
6988
+ function stringifyShade(shade) {
6989
+ if ("angle" in shade) {
6990
+ const parts = [];
6991
+ if (shade.angle !== void 0) parts.push(`ang="${shade.angle}"`);
6992
+ if (shade.scaled !== void 0) parts.push(`scaled="${shade.scaled ? 1 : 0}"`);
6993
+ return `<a:lin${parts.length ? " " + parts.join(" ") : ""}/>`;
7282
6994
  }
7283
- };
7284
- const pictureLockingDesc = {
6995
+ const pathShade = shade;
6996
+ const parts = [];
6997
+ if (pathShade.path) parts.push(`path="${escapeXml(pathShade.path)}"`);
6998
+ const attrStr = parts.length ? " " + parts.join(" ") : "";
6999
+ if (pathShade.fillToRectangle) return `<a:path${attrStr}>${stringifyRelativeRect("a:fillToRect", pathShade.fillToRectangle)}</a:path>`;
7000
+ return `<a:path${attrStr}/>`;
7001
+ }
7002
+ const gradientFillDesc = {
7285
7003
  kind: "custom",
7286
- stringify(opts, _ctx) {
7287
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7288
- if (!attrStr) return void 0;
7289
- return `<a:picLocks${attrStr}/>`;
7004
+ stringify(opts, ctx) {
7005
+ const parts = [];
7006
+ const stopsXml = opts.stops.map((stop) => {
7007
+ const colorXml = stringifyColorChoice(stop.color, ctx);
7008
+ if (!colorXml) return `<a:gs pos="${stop.position}"/>`;
7009
+ return `<a:gs pos="${stop.position}">${colorXml}</a:gs>`;
7010
+ }).join("");
7011
+ parts.push(`<a:gsLst>${stopsXml}</a:gsLst>`);
7012
+ if (opts.shade) parts.push(stringifyShade(opts.shade));
7013
+ if (opts.tileRectangle) parts.push(stringifyRelativeRect("a:tileRect", opts.tileRectangle));
7014
+ const attrParts = [];
7015
+ if (opts.flip) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
7016
+ if (opts.rotateWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotateWithShape ? 1 : 0}"`);
7017
+ return `<a:gradFill${attrParts.length ? " " + attrParts.join(" ") : ""}>${parts.join("")}</a:gradFill>`;
7290
7018
  },
7291
- parse(el, _ctx) {
7292
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7019
+ parse(el, ctx) {
7020
+ const result = {};
7021
+ const gsLst = findChild(el, "a:gsLst");
7022
+ if (gsLst?.elements) result.stops = gsLst.elements.filter((c) => c.name === "a:gs").map((gs) => {
7023
+ return {
7024
+ position: Number(gs.attributes?.["pos"] ?? 0),
7025
+ color: readDirectColor(gs, ctx)
7026
+ };
7027
+ });
7028
+ const lin = findChild(el, "a:lin");
7029
+ if (lin) {
7030
+ const shade = {};
7031
+ if (lin.attributes?.["ang"] !== void 0) shade.angle = Number(lin.attributes["ang"]);
7032
+ if (lin.attributes?.["scaled"] !== void 0) shade.scaled = lin.attributes["scaled"] !== "0";
7033
+ result.shade = shade;
7034
+ } else {
7035
+ const path = findChild(el, "a:path");
7036
+ if (path) {
7037
+ const shade = {};
7038
+ if (path.attributes?.["path"] !== void 0) shade.path = String(path.attributes["path"]);
7039
+ const fillToRectangle = findChild(path, "a:fillToRect");
7040
+ if (fillToRectangle) shade.fillToRectangle = readRelativeRect(fillToRectangle);
7041
+ result.shade = shade;
7042
+ }
7043
+ }
7044
+ if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
7045
+ if (el.attributes?.["rotWithShape"] !== void 0) result.rotateWithShape = el.attributes["rotWithShape"] !== "0";
7046
+ const tileRectangle = findChild(el, "a:tileRect");
7047
+ if (tileRectangle) result.tileRectangle = readRelativeRect(tileRectangle);
7048
+ return result;
7293
7049
  }
7294
7050
  };
7295
- const groupLockingDesc = {
7051
+ const patternFillDesc = {
7296
7052
  kind: "custom",
7297
- stringify(opts, _ctx) {
7298
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7299
- if (!attrStr) return void 0;
7300
- return `<a:grpSpLocks${attrStr}/>`;
7053
+ stringify(opts, ctx) {
7054
+ const parts = [];
7055
+ const prst = xsdPattern.to(opts.pattern);
7056
+ if (opts.foregroundColor) {
7057
+ const colorXml = stringifyColorChoice(opts.foregroundColor, ctx);
7058
+ if (colorXml) parts.push(`<a:fgClr>${colorXml}</a:fgClr>`);
7059
+ }
7060
+ if (opts.backgroundColor) {
7061
+ const colorXml = stringifyColorChoice(opts.backgroundColor, ctx);
7062
+ if (colorXml) parts.push(`<a:bgClr>${colorXml}</a:bgClr>`);
7063
+ }
7064
+ const inner = parts.join("");
7065
+ return `<a:pattFill prst="${escapeXml(prst)}">${inner}</a:pattFill>`;
7301
7066
  },
7302
- parse(el, _ctx) {
7303
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7067
+ parse(el, ctx) {
7068
+ const result = {};
7069
+ const prst = el.attributes?.["prst"];
7070
+ if (prst) result.pattern = xsdPattern.from(String(prst));
7071
+ const fgClr = findChild(el, "a:fgClr");
7072
+ if (fgClr) result.foregroundColor = readDirectColor(fgClr, ctx);
7073
+ const bgClr = findChild(el, "a:bgClr");
7074
+ if (bgClr) result.backgroundColor = readDirectColor(bgClr, ctx);
7075
+ return result;
7304
7076
  }
7305
7077
  };
7306
- const graphicFrameLockingDesc = {
7078
+ function imageTypeFromPath(path) {
7079
+ switch (path.split(".").pop()?.toLowerCase() ?? "") {
7080
+ case "png": return "png";
7081
+ case "jpg":
7082
+ case "jpeg": return "jpg";
7083
+ case "gif": return "gif";
7084
+ case "bmp": return "bmp";
7085
+ case "tif":
7086
+ case "tiff": return "tif";
7087
+ case "ico": return "ico";
7088
+ case "emf": return "emf";
7089
+ case "wmf": return "wmf";
7090
+ default: return "png";
7091
+ }
7092
+ }
7093
+ const fillDesc = {
7307
7094
  kind: "custom",
7308
- stringify(opts, _ctx) {
7309
- const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7310
- if (!attrStr) return void 0;
7311
- return `<a:graphicFrameLocks${attrStr}/>`;
7095
+ stringify(opts, ctx) {
7096
+ if (typeof opts === "string") return stringify$1(solidFillDesc, { value: opts.replace("#", "") }, ctx);
7097
+ switch (opts.type) {
7098
+ case "none": return "<a:noFill/>";
7099
+ case "solid": return stringify$1(solidFillDesc, typeof opts.color === "string" ? { value: opts.color.replace("#", "") } : opts.color, ctx);
7100
+ case "gradient": {
7101
+ if ("options" in opts) return stringify$1(gradientFillDesc, opts.options, ctx);
7102
+ const gradOpts = { stops: opts.stops.map((stop) => ({
7103
+ position: stop.position * 1e3,
7104
+ color: typeof stop.color === "string" ? { value: stop.color.replace("#", "") } : stop.color
7105
+ })) };
7106
+ if (!opts.path && opts.angle !== void 0) gradOpts.shade = {
7107
+ angle: opts.angle * 6e4,
7108
+ scaled: opts.scaled ?? true
7109
+ };
7110
+ if (opts.path) gradOpts.shade = { path: opts.path };
7111
+ return stringify$1(gradientFillDesc, gradOpts, ctx);
7112
+ }
7113
+ case "blip": return buildFill(opts, ctx.addMedia(toUint8Array(opts.data, { encoding: "base64" }), opts.imageType));
7114
+ case "pattern": return stringify$1(patternFillDesc, {
7115
+ pattern: opts.pattern,
7116
+ ...opts.foregroundColor && { foregroundColor: typeof opts.foregroundColor === "string" ? { value: opts.foregroundColor.replace("#", "") } : opts.foregroundColor },
7117
+ ...opts.backgroundColor && { backgroundColor: typeof opts.backgroundColor === "string" ? { value: opts.backgroundColor.replace("#", "") } : opts.backgroundColor }
7118
+ }, ctx);
7119
+ case "group": return "<a:grpFill/>";
7120
+ }
7312
7121
  },
7313
- parse(el, _ctx) {
7314
- return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7122
+ parse(el, ctx) {
7123
+ const resolve = (tag) => el.name === tag ? el : findChild(el, tag);
7124
+ if (resolve("a:noFill")) return { type: "none" };
7125
+ const solidFill = resolve("a:solidFill");
7126
+ if (solidFill) return {
7127
+ type: "solid",
7128
+ color: parse$1(solidFillDesc, solidFill, ctx)
7129
+ };
7130
+ const gradFill = resolve("a:gradFill");
7131
+ if (gradFill) return {
7132
+ type: "gradient",
7133
+ options: parse$1(gradientFillDesc, gradFill, ctx)
7134
+ };
7135
+ const pattFill = resolve("a:pattFill");
7136
+ if (pattFill) return {
7137
+ type: "pattern",
7138
+ ...parse$1(patternFillDesc, pattFill, ctx)
7139
+ };
7140
+ if (resolve("a:grpFill")) return { type: "group" };
7141
+ const blipFill = resolve("a:blipFill");
7142
+ if (blipFill) {
7143
+ const blipOpts = parse$1(blipFillDesc, blipFill, ctx);
7144
+ const mediaPath = blipOpts.referenceId ? ctx.resolveRelationship(blipOpts.referenceId) : void 0;
7145
+ const data = mediaPath ? ctx.getRaw(mediaPath) : void 0;
7146
+ if (mediaPath && data) {
7147
+ const blip = {
7148
+ type: "blip",
7149
+ data,
7150
+ imageType: imageTypeFromPath(mediaPath)
7151
+ };
7152
+ if (blipOpts.dpi !== void 0) blip.dpi = blipOpts.dpi;
7153
+ if (blipOpts.rotWithShape !== void 0) blip.rotWithShape = blipOpts.rotWithShape;
7154
+ if (blipOpts.blipEffects) blip.blipEffects = blipOpts.blipEffects;
7155
+ if (blipOpts.sourceRectangle) blip.sourceRectangle = blipOpts.sourceRectangle;
7156
+ if (blipOpts.tile) blip.tile = blipOpts.tile;
7157
+ return blip;
7158
+ }
7159
+ }
7160
+ return { type: "none" };
7315
7161
  }
7316
7162
  };
7317
- //#endregion
7318
- //#region src/drawingml/geometry/geometry-descriptors.ts
7163
+ function readDirectColor(el, ctx) {
7164
+ const color = parseColorChoice(el, ctx);
7165
+ if (Object.keys(color).length > 0) return color;
7166
+ const solidFill = findChild(el, "a:solidFill");
7167
+ if (solidFill) return parse$1(solidFillDesc, solidFill, ctx);
7168
+ return { value: "" };
7169
+ }
7170
+ //#endregion
7171
+ //#region src/util/converters.ts
7172
+ /**
7173
+ * OOXML unit conversion utilities.
7174
+ *
7175
+ * @module
7176
+ */
7177
+ /**
7178
+ * Converts millimeters to TWIP (twentieths of a point).
7179
+ */
7180
+ const convertMillimetersToTwip = (millimeters) => Math.floor(millimeters / 25.4 * 72 * 20);
7181
+ /**
7182
+ * Converts inches to TWIP (twentieths of a point).
7183
+ */
7184
+ const convertInchesToTwip = (inches) => Math.floor(inches * 72 * 20);
7185
+ /**
7186
+ * Converts pixels to EMU (96 DPI).
7187
+ */
7188
+ const convertPixelsToEmu = (pixels) => Math.round(pixels * 9525);
7189
+ /**
7190
+ * Converts EMU to pixels (96 DPI).
7191
+ *
7192
+ * Returns a possibly fractional (sub-pixel) value. The integer rounding that
7193
+ * lived here before permanently discarded sub-pixel precision, which made an
7194
+ * EMU → pixel → EMU round-trip lossy (e.g. 5521960 EMU → 580 px → 5524500 EMU).
7195
+ * Keeping the fraction lets convertPixelsToEmu restore the exact original EMU.
7196
+ * Callers needing an integer pixel for display should Math.round the result.
7197
+ */
7198
+ const convertEmuToPixels = (emus) => emus / 9525;
7199
+ /**
7200
+ * Converts inches to EMU.
7201
+ */
7202
+ const convertInchesToEmu = (inches) => Math.round(inches * 914400);
7203
+ /**
7204
+ * Converts EMU to inches.
7205
+ */
7206
+ const convertEmuToInches = (emus) => emus / 914400;
7207
+ /**
7208
+ * Converts points to EMU.
7209
+ */
7210
+ const convertPointsToEmu = (points) => Math.round(points * 12700);
7211
+ /**
7212
+ * Converts EMU to points.
7213
+ */
7214
+ const convertEmuToPoints = (emus) => emus / 12700;
7215
+ /**
7216
+ * Parse a UniversalMeasure string into its numeric value and unit.
7217
+ *
7218
+ * @param measure - A universal measure string like "2.54cm", "-10mm", "1in"
7219
+ * @returns The parsed value and unit
7220
+ * @throws Error if the format is invalid
7221
+ *
7222
+ * @example
7223
+ * ```typescript
7224
+ * parseUniversalMeasure("2.54cm"); // { value: 2.54, unit: "cm" }
7225
+ * parseUniversalMeasure("-10mm"); // { value: -10, unit: "mm" }
7226
+ * ```
7227
+ */
7228
+ const parseUniversalMeasure = (measure) => {
7229
+ const match = measure.match(/^(-?[0-9]+(?:\.[0-9]+)?)(mm|cm|in|pt|pc|pi|px)$/);
7230
+ if (!match) throw new Error(`Invalid universal measure: '${measure}'`);
7231
+ return {
7232
+ value: parseFloat(match[1]),
7233
+ unit: match[2]
7234
+ };
7235
+ };
7319
7236
  /**
7320
- * Geometry descriptors for DrawingML shapes.
7237
+ * Converts a UniversalMeasure string to TWIP (twentieths of a point).
7321
7238
  *
7322
- * @module
7239
+ * Supports units: mm, cm, in, pt, pc (picas, 1pc = 12pt), pi (alias for pc).
7240
+ *
7241
+ * @param measure - A universal measure string like "2.54cm", "1in", "12pt"
7242
+ * @returns The value in TWIP
7243
+ *
7244
+ * @example
7245
+ * ```typescript
7246
+ * convertUniversalMeasureToTwip("1in"); // 1440
7247
+ * convertUniversalMeasureToTwip("2.54cm"); // ~1440 (1 inch)
7248
+ * convertUniversalMeasureToTwip("72pt"); // 1440 (1 inch = 72pt = 1440 twips)
7249
+ * ```
7323
7250
  */
7324
- const adjustmentValuesDesc = {
7325
- kind: "custom",
7326
- stringify(guides, _ctx) {
7327
- if (!guides || guides.length === 0) return "<a:avLst/>";
7328
- return `<a:avLst>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</a:avLst>`;
7329
- },
7330
- parse(el, _ctx) {
7331
- const result = [];
7332
- if (el.elements) {
7333
- for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7334
- const name = child.attributes["name"];
7335
- const fmla = child.attributes["fmla"];
7336
- if (name !== void 0 && fmla !== void 0) result.push({
7337
- name: String(name),
7338
- formula: String(fmla)
7339
- });
7340
- }
7341
- }
7342
- return result;
7251
+ const convertUniversalMeasureToTwip = (measure) => {
7252
+ const { value, unit } = parseUniversalMeasure(measure);
7253
+ switch (unit) {
7254
+ case "mm": return convertMillimetersToTwip(value);
7255
+ case "cm": return convertMillimetersToTwip(value * 10);
7256
+ case "in": return convertInchesToTwip(value);
7257
+ case "pt": return Math.floor(value * 20);
7258
+ case "pc":
7259
+ case "pi": return Math.floor(value * 12 * 20);
7260
+ case "px": return Math.round(value * 15);
7343
7261
  }
7344
7262
  };
7345
- const presetGeometryDesc = {
7346
- kind: "custom",
7347
- stringify(opts, ctx) {
7348
- const prst = opts.preset ?? "rect";
7349
- let avXml = "";
7350
- if (opts.adjustmentValues) avXml = stringify$1(adjustmentValuesDesc, opts.adjustmentValues, ctx) ?? "<a:avLst/>";
7351
- else avXml = "<a:avLst/>";
7352
- return `<a:prstGeom prst="${escapeXml(prst)}">${avXml}</a:prstGeom>`;
7353
- },
7354
- parse(el, ctx) {
7355
- const result = {};
7356
- if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
7357
- const avLst = findChild(el, "a:avLst");
7358
- if (avLst) {
7359
- const guides = parse$1(adjustmentValuesDesc, avLst, ctx);
7360
- if (guides.length > 0) result.adjustmentValues = guides;
7361
- }
7362
- return result;
7263
+ /**
7264
+ * Converts a measurement value (number or UniversalMeasure) to TWIP.
7265
+ *
7266
+ * If the value is already a number, it is returned as-is (assumed to be in twips).
7267
+ * If the value is a UniversalMeasure string, it is converted to twips.
7268
+ *
7269
+ * Useful for accepting both `number` and `UniversalMeasure` inputs where
7270
+ * the XSD type is a union (e.g., ST_TwipsMeasure, ST_SignedTwipsMeasure).
7271
+ *
7272
+ * @param val - A numeric twip value or a universal measure string
7273
+ * @returns The value in TWIP
7274
+ *
7275
+ * @example
7276
+ * ```typescript
7277
+ * convertToTwip(1440); // 1440 (already twips)
7278
+ * convertToTwip("1in"); // 1440
7279
+ * convertToTwip("2.54cm"); // ~1440
7280
+ * ```
7281
+ */
7282
+ const convertToTwip = (val) => typeof val === "string" ? convertUniversalMeasureToTwip(val) : val;
7283
+ /**
7284
+ * Converts a UniversalMeasure string to EMU (English Metric Units).
7285
+ *
7286
+ * Supports units: mm, cm, in, pt, pc (picas, 1pc = 12pt), pi (alias for pc).
7287
+ *
7288
+ * @param measure - A universal measure string like "2.54cm", "1in", "12pt"
7289
+ * @returns The value in EMU
7290
+ *
7291
+ * @example
7292
+ * ```typescript
7293
+ * convertUniversalMeasureToEmu("1in"); // 914400
7294
+ * convertUniversalMeasureToEmu("2.54cm"); // 914400
7295
+ * convertUniversalMeasureToEmu("12pt"); // 152400
7296
+ * ```
7297
+ */
7298
+ const convertUniversalMeasureToEmu = (measure) => {
7299
+ const { value, unit } = parseUniversalMeasure(measure);
7300
+ switch (unit) {
7301
+ case "mm": return Math.round(value * 36e3);
7302
+ case "cm": return Math.round(value * 36e4);
7303
+ case "in": return convertInchesToEmu(value);
7304
+ case "pt": return convertPointsToEmu(value);
7305
+ case "pc":
7306
+ case "pi": return convertPointsToEmu(value * 12);
7307
+ case "px": return convertPixelsToEmu(value);
7363
7308
  }
7364
7309
  };
7365
- function stringifyAdjustPoint(pt) {
7366
- return `<a:pt x="${escapeXml(pt.x)}" y="${escapeXml(pt.y)}"/>`;
7367
- }
7368
- function stringifyPathCommand(cmd) {
7369
- switch (cmd.command) {
7370
- case "moveTo": return `<a:moveTo>${stringifyAdjustPoint(cmd.point)}</a:moveTo>`;
7371
- case "lineTo": return `<a:lnTo>${stringifyAdjustPoint(cmd.point)}</a:lnTo>`;
7372
- case "arcTo": return `<a:arcTo wR="${escapeXml(cmd.widthRadius)}" hR="${escapeXml(cmd.heightRadius)}" stAng="${escapeXml(cmd.startAngle)}" swAng="${escapeXml(cmd.sweepAngle)}"/>`;
7373
- case "quadBezTo": return `<a:quadBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:quadBezTo>`;
7374
- case "cubicBezTo": return `<a:cubicBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:cubicBezTo>`;
7375
- case "close": return "<a:close/>";
7376
- }
7377
- }
7378
- function stringifyPath(path) {
7379
- const attrs = [];
7380
- if (path.w !== void 0) attrs.push(`w="${path.w}"`);
7381
- if (path.h !== void 0) attrs.push(`h="${path.h}"`);
7382
- if (path.fill !== void 0) attrs.push(`fill="${escapeXml(path.fill)}"`);
7383
- if (path.stroke !== void 0) attrs.push(`stroke="${path.stroke}"`);
7384
- if (path.extrusionOk !== void 0) attrs.push(`extrusionOk="${path.extrusionOk}"`);
7385
- const attrStr = attrs.length ? " " + attrs.join(" ") : "";
7386
- const cmds = path.commands.map(stringifyPathCommand).join("");
7387
- if (!cmds && !attrStr) return "<a:path/>";
7388
- return `<a:path${attrStr}>${cmds}</a:path>`;
7389
- }
7390
- function readAdjustPoint(el) {
7391
- if (!el.attributes) return void 0;
7392
- const x = el.attributes["x"];
7393
- const y = el.attributes["y"];
7394
- if (x === void 0 || y === void 0) return void 0;
7395
- return {
7396
- x: String(x),
7397
- y: String(y)
7398
- };
7399
- }
7400
- function readPathCommand(tag, el) {
7401
- switch (tag) {
7402
- case "a:moveTo": {
7403
- const pt = el.elements?.find((c) => c.name === "a:pt");
7404
- if (!pt) return void 0;
7405
- const point = readAdjustPoint(pt);
7406
- if (!point) return void 0;
7407
- return {
7408
- command: "moveTo",
7409
- point
7410
- };
7411
- }
7412
- case "a:lnTo": {
7413
- const pt = el.elements?.find((c) => c.name === "a:pt");
7414
- if (!pt) return void 0;
7415
- const point = readAdjustPoint(pt);
7416
- if (!point) return void 0;
7417
- return {
7418
- command: "lineTo",
7419
- point
7420
- };
7421
- }
7422
- case "a:arcTo": {
7423
- const a = el.attributes;
7424
- if (!a) return void 0;
7425
- return {
7426
- command: "arcTo",
7427
- widthRadius: String(a["wR"] ?? ""),
7428
- heightRadius: String(a["hR"] ?? ""),
7429
- startAngle: String(a["stAng"] ?? ""),
7430
- sweepAngle: String(a["swAng"] ?? "")
7431
- };
7432
- }
7433
- case "a:quadBezTo": {
7434
- const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7435
- if (points.length < 2) return void 0;
7436
- return {
7437
- command: "quadBezTo",
7438
- points: [points[0], points[1]]
7439
- };
7440
- }
7441
- case "a:cubicBezTo": {
7442
- const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7443
- if (points.length < 3) return void 0;
7444
- return {
7445
- command: "cubicBezTo",
7446
- points: [
7447
- points[0],
7448
- points[1],
7449
- points[2]
7450
- ]
7451
- };
7452
- }
7453
- case "a:close": return { command: "close" };
7454
- default: return;
7310
+ /**
7311
+ * Converts a measurement value (number or UniversalMeasure) to EMU.
7312
+ *
7313
+ * Numbers are returned as-is (assumed EMU). Strings are parsed as
7314
+ * UniversalMeasure via {@link convertUniversalMeasureToEmu} — including the
7315
+ * project-only `px` unit (96 DPI). The result is always an EMU number written to
7316
+ * XML, so px never appears verbatim in the document.
7317
+ *
7318
+ * Useful for DrawingML fields where the XSD type is a union (e.g., ST_Coordinate).
7319
+ *
7320
+ * @param val - A numeric EMU value, or a UniversalMeasure string (incl. `${n}px`)
7321
+ * @returns The value in EMU
7322
+ *
7323
+ * @example
7324
+ * ```typescript
7325
+ * convertToEmu(914400); // 914400 (already EMU)
7326
+ * convertToEmu("1in"); // 914400
7327
+ * convertToEmu("2.54cm"); // 914400
7328
+ * convertToEmu("200px"); // 1905000 (200 * 9525)
7329
+ * ```
7330
+ */
7331
+ const convertToEmu = (val) => typeof val === "string" ? convertUniversalMeasureToEmu(val) : val;
7332
+ /**
7333
+ * Converts a UniversalMeasure string to points (1pt = 1/72 inch).
7334
+ *
7335
+ * Supports units: mm, cm, in, pt, pc (picas, 1pc = 12pt), pi (alias for pc),
7336
+ * px (96 DPI).
7337
+ */
7338
+ const convertUniversalMeasureToPt = (measure) => {
7339
+ const { value, unit } = parseUniversalMeasure(measure);
7340
+ switch (unit) {
7341
+ case "mm": return value / 25.4 * 72;
7342
+ case "cm": return value * 10 / 25.4 * 72;
7343
+ case "in": return value * 72;
7344
+ case "pt": return value;
7345
+ case "pc":
7346
+ case "pi": return value * 12;
7347
+ case "px": return value / 96 * 72;
7348
+ }
7349
+ };
7350
+ /**
7351
+ * Converts a measurement value (number or UniversalMeasure) to points.
7352
+ *
7353
+ * Numbers are returned as-is (assumed to be in points). Strings are parsed as
7354
+ * UniversalMeasure. Useful for SpreadsheetML fields where a number is points.
7355
+ */
7356
+ const convertToPt = (val) => typeof val === "string" ? convertUniversalMeasureToPt(val) : val;
7357
+ /**
7358
+ * Converts a UniversalMeasure string to inches.
7359
+ *
7360
+ * Supports units: mm, cm, in, pt, pc, pi, px (96 DPI).
7361
+ */
7362
+ const convertUniversalMeasureToInch = (measure) => {
7363
+ const { value, unit } = parseUniversalMeasure(measure);
7364
+ switch (unit) {
7365
+ case "mm": return value / 25.4;
7366
+ case "cm": return value * 10 / 25.4;
7367
+ case "in": return value;
7368
+ case "pt": return value / 72;
7369
+ case "pc":
7370
+ case "pi": return value * 12 / 72;
7371
+ case "px": return value / 96;
7455
7372
  }
7373
+ };
7374
+ /**
7375
+ * Converts a measurement value (number or UniversalMeasure) to inches.
7376
+ *
7377
+ * Numbers are returned as-is (assumed to be in inches). Useful for SpreadsheetML
7378
+ * page-margin fields where a number is inches.
7379
+ */
7380
+ const convertToInch = (val) => typeof val === "string" ? convertUniversalMeasureToInch(val) : val;
7381
+ //#endregion
7382
+ //#region src/drawingml/outline/outline-descriptors.ts
7383
+ /**
7384
+ * Outline descriptor for DrawingML shapes.
7385
+ *
7386
+ * @module
7387
+ */
7388
+ function stringifyLineEnd(tag, opts) {
7389
+ const parts = [];
7390
+ if (opts.type) parts.push(`type="${escapeXml(opts.type)}"`);
7391
+ if (opts.width) parts.push(`w="${escapeXml(opts.width)}"`);
7392
+ if (opts.length) parts.push(`len="${escapeXml(opts.length)}"`);
7393
+ return `<${tag}${parts.length ? " " + parts.join(" ") : ""}/>`;
7456
7394
  }
7457
- function readPath(el) {
7395
+ function readLineEnd(el) {
7458
7396
  const result = {};
7459
- if (el.attributes) {
7460
- if (el.attributes["w"] !== void 0) result.w = Number(el.attributes["w"]);
7461
- if (el.attributes["h"] !== void 0) result.h = Number(el.attributes["h"]);
7462
- if (el.attributes["fill"] !== void 0) result.fill = String(el.attributes["fill"]);
7463
- if (el.attributes["stroke"] !== void 0) result.stroke = el.attributes["stroke"] !== "0" && el.attributes["stroke"] !== "false";
7464
- if (el.attributes["extrusionOk"] !== void 0) result.extrusionOk = el.attributes["extrusionOk"] !== "0" && el.attributes["extrusionOk"] !== "false";
7465
- }
7466
- const commands = [];
7467
- if (el.elements) {
7468
- for (const child of el.elements) if (child.name) {
7469
- const cmd = readPathCommand(child.name, child);
7470
- if (cmd) commands.push(cmd);
7471
- }
7472
- }
7473
- if (commands.length > 0) result.commands = commands;
7397
+ if (el.attributes?.["type"]) result.type = String(el.attributes["type"]);
7398
+ if (el.attributes?.["w"]) result.width = String(el.attributes["w"]);
7399
+ if (el.attributes?.["len"]) result.length = String(el.attributes["len"]);
7474
7400
  return result;
7475
7401
  }
7476
- function stringifyGuideList(tag, guides) {
7477
- if (!guides || guides.length === 0) return `<${tag}/>`;
7478
- return `<${tag}>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</${tag}>`;
7402
+ function stringifyCustomDash(stops) {
7403
+ return `<a:custDash>${stops.map((s) => `<a:ds d="${escapeXml(s.d)}" sp="${escapeXml(s.sp)}"/>`).join("")}</a:custDash>`;
7479
7404
  }
7480
- function readGuideList(el) {
7481
- const result = [];
7482
- if (el.elements) {
7483
- for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7484
- const name = child.attributes["name"];
7485
- const fmla = child.attributes["fmla"];
7486
- if (name !== void 0 && fmla !== void 0) result.push({
7487
- name: String(name),
7488
- formula: String(fmla)
7489
- });
7405
+ const outlineDesc = {
7406
+ kind: "custom",
7407
+ stringify(opts, ctx) {
7408
+ const parts = [];
7409
+ const attrParts = [];
7410
+ if (opts.width !== void 0) attrParts.push(`w="${convertToEmu(opts.width)}"`);
7411
+ if (opts.cap !== void 0) attrParts.push(`cap="${escapeXml(opts.cap)}"`);
7412
+ if (opts.compoundLine !== void 0) attrParts.push(`cmpd="${escapeXml(opts.compoundLine)}"`);
7413
+ if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(opts.align)}"`);
7414
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7415
+ if (opts.type === "noFill") parts.push("<a:noFill/>");
7416
+ else if (opts.type === "solidFill" && opts.color) {
7417
+ const fillXml = stringify$1(solidFillDesc, opts.color, ctx);
7418
+ if (fillXml) parts.push(fillXml);
7419
+ } else if (opts.type === "gradFill" && opts.gradientFill) {
7420
+ const gradXml = stringify$1(gradientFillDesc, opts.gradientFill, ctx);
7421
+ if (gradXml) parts.push(gradXml);
7422
+ }
7423
+ if (opts.customDash) parts.push(stringifyCustomDash(opts.customDash));
7424
+ else if (opts.dash) parts.push(`<a:prstDash val="${escapeXml(opts.dash)}"/>`);
7425
+ if (opts.join) if (opts.join === "miter" && opts.miterLimit !== void 0) parts.push(`<a:miter lim="${opts.miterLimit}"/>`);
7426
+ else parts.push(`<a:${opts.join}/>`);
7427
+ if (opts.headEnd) parts.push(stringifyLineEnd("a:headEnd", opts.headEnd));
7428
+ if (opts.tailEnd) parts.push(stringifyLineEnd("a:tailEnd", opts.tailEnd));
7429
+ if (parts.length === 0 && !attrStr) return void 0;
7430
+ if (parts.length === 0) return `<a:ln${attrStr}/>`;
7431
+ return `<a:ln${attrStr}>${parts.join("")}</a:ln>`;
7432
+ },
7433
+ parse(el, _ctx) {
7434
+ const result = {};
7435
+ if (el.attributes) {
7436
+ if (el.attributes["w"] !== void 0) result.width = Number(el.attributes["w"]);
7437
+ if (el.attributes["cap"] !== void 0) result.cap = String(el.attributes["cap"]);
7438
+ if (el.attributes["cmpd"] !== void 0) result.compoundLine = String(el.attributes["cmpd"]);
7439
+ if (el.attributes["algn"] !== void 0) result.align = String(el.attributes["algn"]);
7440
+ }
7441
+ const solidFill = findChild(el, "a:solidFill");
7442
+ if (solidFill) {
7443
+ result.type = "solidFill";
7444
+ result.color = parse$1(solidFillDesc, solidFill, _ctx);
7445
+ }
7446
+ if (findChild(el, "a:noFill")) result.type = "noFill";
7447
+ if (findChild(el, "a:gradFill")) {
7448
+ result.type = "gradFill";
7449
+ result.gradientFill = parse$1(gradientFillDesc, findChild(el, "a:gradFill"), _ctx);
7450
+ }
7451
+ const prstDash = findChild(el, "a:prstDash");
7452
+ if (prstDash?.attributes?.["val"]) result.dash = String(prstDash.attributes["val"]);
7453
+ const custDash = findChild(el, "a:custDash");
7454
+ if (custDash?.elements) result.customDash = custDash.elements.filter((c) => c.name === "a:ds").map((c) => ({
7455
+ d: String(c.attributes?.["d"] ?? ""),
7456
+ sp: String(c.attributes?.["sp"] ?? "")
7457
+ }));
7458
+ if (findChild(el, "a:round")) result.join = "round";
7459
+ else if (findChild(el, "a:bevel")) result.join = "bevel";
7460
+ else {
7461
+ const miter = findChild(el, "a:miter");
7462
+ if (miter) {
7463
+ result.join = "miter";
7464
+ if (miter.attributes?.["lim"]) result.miterLimit = Number(miter.attributes["lim"]);
7465
+ }
7490
7466
  }
7467
+ const headEnd = findChild(el, "a:headEnd");
7468
+ if (headEnd) result.headEnd = readLineEnd(headEnd);
7469
+ const tailEnd = findChild(el, "a:tailEnd");
7470
+ if (tailEnd) result.tailEnd = readLineEnd(tailEnd);
7471
+ return result;
7491
7472
  }
7492
- return result;
7493
- }
7494
- function stringifyAdjustHandlePos(pos) {
7495
- return `<a:pos x="${escapeXml(pos.x)}" y="${escapeXml(pos.y)}"/>`;
7496
- }
7497
- function stringifyXYAdjustHandle(h) {
7498
- const attrs = [];
7499
- if (h.guideRefX !== void 0) attrs.push(`gdRefX="${escapeXml(h.guideRefX)}"`);
7500
- if (h.minX !== void 0) attrs.push(`minX="${escapeXml(h.minX)}"`);
7501
- if (h.maxX !== void 0) attrs.push(`maxX="${escapeXml(h.maxX)}"`);
7502
- if (h.guideRefY !== void 0) attrs.push(`gdRefY="${escapeXml(h.guideRefY)}"`);
7503
- if (h.minY !== void 0) attrs.push(`minY="${escapeXml(h.minY)}"`);
7504
- if (h.maxY !== void 0) attrs.push(`maxY="${escapeXml(h.maxY)}"`);
7505
- return `<a:ahXY${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahXY>`;
7506
- }
7507
- function stringifyPolarAdjustHandle(h) {
7508
- const attrs = [];
7509
- if (h.guideRefRadius !== void 0) attrs.push(`gdRefR="${escapeXml(h.guideRefRadius)}"`);
7510
- if (h.minRadius !== void 0) attrs.push(`minR="${escapeXml(h.minRadius)}"`);
7511
- if (h.maxRadius !== void 0) attrs.push(`maxR="${escapeXml(h.maxRadius)}"`);
7512
- if (h.guideRefAngle !== void 0) attrs.push(`gdRefAng="${escapeXml(h.guideRefAngle)}"`);
7513
- if (h.minAngle !== void 0) attrs.push(`minAng="${escapeXml(h.minAngle)}"`);
7514
- if (h.maxAngle !== void 0) attrs.push(`maxAng="${escapeXml(h.maxAngle)}"`);
7515
- return `<a:ahPolar${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahPolar>`;
7516
- }
7517
- function stringifyAdjustHandle(h) {
7518
- return h.type === "xy" ? stringifyXYAdjustHandle(h) : stringifyPolarAdjustHandle(h);
7519
- }
7520
- function readAdjustHandlePos(el) {
7521
- const pos = el.elements?.find((c) => c.name === "a:pos");
7522
- if (!pos?.attributes) return void 0;
7523
- const x = pos.attributes["x"];
7524
- const y = pos.attributes["y"];
7525
- if (x === void 0 || y === void 0) return void 0;
7526
- return {
7527
- x: String(x),
7528
- y: String(y)
7529
- };
7530
- }
7531
- function readXYAdjustHandle(el) {
7532
- const position = readAdjustHandlePos(el);
7533
- if (!position) return void 0;
7534
- const result = {
7535
- type: "xy",
7536
- position
7537
- };
7538
- if (el.attributes?.["gdRefX"] !== void 0) result.guideRefX = String(el.attributes["gdRefX"]);
7539
- if (el.attributes?.["minX"] !== void 0) result.minX = String(el.attributes["minX"]);
7540
- if (el.attributes?.["maxX"] !== void 0) result.maxX = String(el.attributes["maxX"]);
7541
- if (el.attributes?.["gdRefY"] !== void 0) result.guideRefY = String(el.attributes["gdRefY"]);
7542
- if (el.attributes?.["minY"] !== void 0) result.minY = String(el.attributes["minY"]);
7543
- if (el.attributes?.["maxY"] !== void 0) result.maxY = String(el.attributes["maxY"]);
7544
- return result;
7545
- }
7546
- function readPolarAdjustHandle(el) {
7547
- const position = readAdjustHandlePos(el);
7548
- if (!position) return void 0;
7549
- const result = {
7550
- type: "polar",
7551
- position
7552
- };
7553
- if (el.attributes?.["gdRefR"] !== void 0) result.guideRefRadius = String(el.attributes["gdRefR"]);
7554
- if (el.attributes?.["minR"] !== void 0) result.minRadius = String(el.attributes["minR"]);
7555
- if (el.attributes?.["maxR"] !== void 0) result.maxRadius = String(el.attributes["maxR"]);
7556
- if (el.attributes?.["gdRefAng"] !== void 0) result.guideRefAngle = String(el.attributes["gdRefAng"]);
7557
- if (el.attributes?.["minAng"] !== void 0) result.minAngle = String(el.attributes["minAng"]);
7558
- if (el.attributes?.["maxAng"] !== void 0) result.maxAngle = String(el.attributes["maxAng"]);
7559
- return result;
7560
- }
7561
- function stringifyConnectionSite(site) {
7562
- return `<a:cxn ang="${escapeXml(site.angle)}">${stringifyAdjustHandlePos(site.position)}</a:cxn>`;
7563
- }
7564
- function readConnectionSite(el) {
7565
- const ang = el.attributes?.["ang"];
7566
- if (ang === void 0) return void 0;
7567
- const position = readAdjustHandlePos(el);
7568
- if (!position) return void 0;
7569
- return {
7570
- angle: String(ang),
7571
- position
7572
- };
7473
+ };
7474
+ //#endregion
7475
+ //#region src/drawingml/effects/effect-descriptors.ts
7476
+ /**
7477
+ * Effect list descriptor for DrawingML shapes.
7478
+ *
7479
+ * @module
7480
+ */
7481
+ function stringifyEffectColor(color, ctx) {
7482
+ if (!color) return void 0;
7483
+ return stringifyColorChoice(color, ctx);
7573
7484
  }
7574
- function stringifyGeomRect(rect) {
7575
- return `<a:rect l="${escapeXml(rect.left)}" t="${escapeXml(rect.top)}" r="${escapeXml(rect.right)}" b="${escapeXml(rect.bottom)}"/>`;
7485
+ function stringifyColorEffect(tag, attrs, color, ctx) {
7486
+ const attrParts = [];
7487
+ for (const [key, val] of Object.entries(attrs)) if (val !== void 0) attrParts.push(`${key}="${escapeXml(String(val))}"`);
7488
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7489
+ const colorXml = stringifyEffectColor(color, ctx);
7490
+ if (!colorXml && !attrStr) return void 0;
7491
+ if (!colorXml) return `<${tag}${attrStr}/>`;
7492
+ return `<${tag}${attrStr}>${colorXml}</${tag}>`;
7576
7493
  }
7577
- function readGeomRect(el) {
7578
- const a = el.attributes;
7579
- if (!a) return void 0;
7580
- const l = a["l"];
7581
- const t = a["t"];
7582
- const r = a["r"];
7583
- const b = a["b"];
7584
- if (l === void 0 || t === void 0 || r === void 0 || b === void 0) return void 0;
7585
- return {
7586
- left: String(l),
7587
- top: String(t),
7588
- right: String(r),
7589
- bottom: String(b)
7590
- };
7494
+ function readColorFromElement(el, ctx) {
7495
+ const color = parseColorChoice(el, ctx);
7496
+ if (!color || Object.keys(color).length === 0) return void 0;
7497
+ return color;
7591
7498
  }
7592
- const customGeometryDesc = {
7499
+ const effectListDesc = {
7593
7500
  kind: "custom",
7594
- stringify(opts, _ctx) {
7501
+ stringify(opts, ctx) {
7595
7502
  const parts = [];
7596
- if (opts.adjustmentValues && opts.adjustmentValues.length > 0) parts.push(stringifyGuideList("a:avLst", opts.adjustmentValues));
7597
- else parts.push("<a:avLst/>");
7598
- if (opts.guides && opts.guides.length > 0) parts.push(stringifyGuideList("a:gdLst", opts.guides));
7599
- if (opts.adjustHandles && opts.adjustHandles.length > 0) {
7600
- const inner = opts.adjustHandles.map(stringifyAdjustHandle).join("");
7601
- parts.push(`<a:ahLst>${inner}</a:ahLst>`);
7503
+ if (opts.blur) {
7504
+ const attrParts = [];
7505
+ if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
7506
+ if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
7507
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7508
+ parts.push(`<a:blur${attrStr}/>`);
7602
7509
  }
7603
- if (opts.connectionSites && opts.connectionSites.length > 0) {
7604
- const inner = opts.connectionSites.map(stringifyConnectionSite).join("");
7605
- parts.push(`<a:cxnLst>${inner}</a:cxnLst>`);
7510
+ if (opts.fillOverlay) parts.push(`<a:fillOverlay blend="${escapeXml(opts.fillOverlay.blend)}"/>`);
7511
+ if (opts.glow) parts.push(stringifyColorEffect("a:glow", { rad: opts.glow.radius }, opts.glow.color, ctx) ?? "");
7512
+ if (opts.innerShadow) parts.push(stringifyColorEffect("a:innerShdw", {
7513
+ blurRad: opts.innerShadow.blurRadius,
7514
+ dist: opts.innerShadow.distance,
7515
+ dir: opts.innerShadow.direction
7516
+ }, opts.innerShadow.color, ctx) ?? "");
7517
+ if (opts.outerShadow) parts.push(stringifyColorEffect("a:outerShdw", {
7518
+ blurRad: opts.outerShadow.blurRadius,
7519
+ dist: opts.outerShadow.distance,
7520
+ dir: opts.outerShadow.direction,
7521
+ sx: opts.outerShadow.scaleX,
7522
+ sy: opts.outerShadow.scaleY,
7523
+ kx: opts.outerShadow.skewX,
7524
+ ky: opts.outerShadow.skewY,
7525
+ algn: opts.outerShadow.alignment,
7526
+ rotWithShape: opts.outerShadow.rotWithShape === false ? 0 : void 0
7527
+ }, opts.outerShadow.color, ctx) ?? "");
7528
+ if (opts.presetShadow) parts.push(stringifyColorEffect("a:prstShdw", {
7529
+ prst: opts.presetShadow.preset,
7530
+ dist: opts.presetShadow.distance,
7531
+ dir: opts.presetShadow.direction
7532
+ }, opts.presetShadow.color, ctx) ?? "");
7533
+ if (opts.reflection) {
7534
+ const refOpts = opts.reflection === true ? {} : opts.reflection;
7535
+ const attrParts = [];
7536
+ if (refOpts.blurRadius !== void 0) attrParts.push(`blurRad="${refOpts.blurRadius}"`);
7537
+ if (refOpts.startAlpha !== void 0) attrParts.push(`stA="${refOpts.startAlpha}"`);
7538
+ if (refOpts.startPosition !== void 0) attrParts.push(`stPos="${refOpts.startPosition}"`);
7539
+ if (refOpts.endAlpha !== void 0) attrParts.push(`endA="${refOpts.endAlpha}"`);
7540
+ if (refOpts.endPosition !== void 0) attrParts.push(`endPos="${refOpts.endPosition}"`);
7541
+ if (refOpts.distance !== void 0) attrParts.push(`dist="${refOpts.distance}"`);
7542
+ if (refOpts.direction !== void 0) attrParts.push(`dir="${refOpts.direction}"`);
7543
+ if (refOpts.fadeDirection !== void 0) attrParts.push(`fadeDir="${refOpts.fadeDirection}"`);
7544
+ if (refOpts.scaleX !== void 0) attrParts.push(`sx="${refOpts.scaleX}"`);
7545
+ if (refOpts.scaleY !== void 0) attrParts.push(`sy="${refOpts.scaleY}"`);
7546
+ if (refOpts.skewX !== void 0) attrParts.push(`kx="${refOpts.skewX}"`);
7547
+ if (refOpts.skewY !== void 0) attrParts.push(`ky="${refOpts.skewY}"`);
7548
+ if (refOpts.alignment !== void 0) attrParts.push(`algn="${refOpts.alignment}"`);
7549
+ if (refOpts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${refOpts.rotWithShape ? 1 : 0}"`);
7550
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7551
+ parts.push(`<a:reflection${attrStr}/>`);
7606
7552
  }
7607
- if (opts.textRectangle) parts.push(stringifyGeomRect(opts.textRectangle));
7608
- const pathsXml = opts.pathList.map(stringifyPath).join("");
7609
- parts.push(`<a:pathLst>${pathsXml}</a:pathLst>`);
7610
- return `<a:custGeom>${parts.join("")}</a:custGeom>`;
7553
+ if (opts.softEdge !== void 0) parts.push(`<a:softEdge rad="${opts.softEdge}"/>`);
7554
+ const content = parts.filter(Boolean).join("");
7555
+ if (!content) return void 0;
7556
+ return `<a:effectLst>${content}</a:effectLst>`;
7611
7557
  },
7612
- parse(el, _ctx) {
7558
+ parse(el, ctx) {
7613
7559
  const result = {};
7614
- const avLst = findChild(el, "a:avLst");
7615
- if (avLst) {
7616
- const guides = readGuideList(avLst);
7617
- if (guides.length > 0) result.adjustmentValues = guides;
7560
+ const blur = findChild(el, "a:blur");
7561
+ if (blur) {
7562
+ const blurOpts = {};
7563
+ if (blur.attributes?.["rad"] !== void 0) blurOpts.radius = Number(blur.attributes["rad"]);
7564
+ if (blur.attributes?.["grow"] !== void 0) blurOpts.grow = blur.attributes["grow"] !== "0";
7565
+ result.blur = blurOpts;
7618
7566
  }
7619
- const gdLst = findChild(el, "a:gdLst");
7620
- if (gdLst) {
7621
- const guides = readGuideList(gdLst);
7622
- if (guides.length > 0) result.guides = guides;
7567
+ const glow = findChild(el, "a:glow");
7568
+ if (glow) {
7569
+ const glowOpts = {};
7570
+ if (glow.attributes?.["rad"] !== void 0) glowOpts.radius = Number(glow.attributes["rad"]);
7571
+ const color = readColorFromElement(glow, ctx);
7572
+ if (color) glowOpts.color = color;
7573
+ result.glow = glowOpts;
7623
7574
  }
7624
- const ahLst = findChild(el, "a:ahLst");
7625
- if (ahLst?.elements) {
7626
- const handles = [];
7627
- for (const child of ahLst.elements) if (child.name === "a:ahXY") {
7628
- const h = readXYAdjustHandle(child);
7629
- if (h) handles.push(h);
7630
- } else if (child.name === "a:ahPolar") {
7631
- const h = readPolarAdjustHandle(child);
7632
- if (h) handles.push(h);
7633
- }
7634
- if (handles.length > 0) result.adjustHandles = handles;
7575
+ const innerShdw = findChild(el, "a:innerShdw");
7576
+ if (innerShdw) {
7577
+ const innerOpts = {};
7578
+ if (innerShdw.attributes?.["blurRad"] !== void 0) innerOpts.blurRadius = Number(innerShdw.attributes["blurRad"]);
7579
+ if (innerShdw.attributes?.["dist"] !== void 0) innerOpts.distance = Number(innerShdw.attributes["dist"]);
7580
+ if (innerShdw.attributes?.["dir"] !== void 0) innerOpts.direction = Number(innerShdw.attributes["dir"]);
7581
+ const color = readColorFromElement(innerShdw, ctx);
7582
+ if (color) innerOpts.color = color;
7583
+ result.innerShadow = innerOpts;
7635
7584
  }
7636
- const cxnLst = findChild(el, "a:cxnLst");
7637
- if (cxnLst?.elements) {
7638
- const sites = [];
7639
- for (const child of cxnLst.elements) if (child.name === "a:cxn") {
7640
- const site = readConnectionSite(child);
7641
- if (site) sites.push(site);
7642
- }
7643
- if (sites.length > 0) result.connectionSites = sites;
7585
+ const outerShdw = findChild(el, "a:outerShdw");
7586
+ if (outerShdw) {
7587
+ const outerOpts = {};
7588
+ if (outerShdw.attributes?.["blurRad"] !== void 0) outerOpts.blurRadius = Number(outerShdw.attributes["blurRad"]);
7589
+ if (outerShdw.attributes?.["dist"] !== void 0) outerOpts.distance = Number(outerShdw.attributes["dist"]);
7590
+ if (outerShdw.attributes?.["dir"] !== void 0) outerOpts.direction = Number(outerShdw.attributes["dir"]);
7591
+ if (outerShdw.attributes?.["sx"] !== void 0) outerOpts.scaleX = Number(outerShdw.attributes["sx"]);
7592
+ if (outerShdw.attributes?.["sy"] !== void 0) outerOpts.scaleY = Number(outerShdw.attributes["sy"]);
7593
+ if (outerShdw.attributes?.["kx"] !== void 0) outerOpts.skewX = Number(outerShdw.attributes["kx"]);
7594
+ if (outerShdw.attributes?.["ky"] !== void 0) outerOpts.skewY = Number(outerShdw.attributes["ky"]);
7595
+ if (outerShdw.attributes?.["algn"] !== void 0) outerOpts.alignment = String(outerShdw.attributes["algn"]);
7596
+ if (outerShdw.attributes?.["rotWithShape"] !== void 0) outerOpts.rotWithShape = outerShdw.attributes["rotWithShape"] !== "0";
7597
+ const color = readColorFromElement(outerShdw, ctx);
7598
+ if (color) outerOpts.color = color;
7599
+ result.outerShadow = outerOpts;
7644
7600
  }
7645
- const rect = findChild(el, "a:rect");
7646
- if (rect) {
7647
- const textRectangle = readGeomRect(rect);
7648
- if (textRectangle) result.textRectangle = textRectangle;
7601
+ const fillOverlay = findChild(el, "a:fillOverlay");
7602
+ if (fillOverlay) {
7603
+ const overlayOpts = {};
7604
+ if (fillOverlay.attributes?.["blend"] !== void 0) overlayOpts.blend = String(fillOverlay.attributes["blend"]);
7605
+ result.fillOverlay = overlayOpts;
7649
7606
  }
7650
- const pathLst = findChild(el, "a:pathLst");
7651
- if (pathLst?.elements) {
7652
- const paths = [];
7653
- for (const child of pathLst.elements) if (child.name === "a:path") {
7654
- const p = readPath(child);
7655
- if (p.commands && p.commands.length > 0) paths.push(p);
7656
- }
7657
- if (paths.length > 0) result.pathList = paths;
7607
+ const prstShdw = findChild(el, "a:prstShdw");
7608
+ if (prstShdw) {
7609
+ const prstOpts = {};
7610
+ if (prstShdw.attributes?.["prst"] !== void 0) prstOpts.preset = String(prstShdw.attributes["prst"]);
7611
+ if (prstShdw.attributes?.["dist"] !== void 0) prstOpts.distance = Number(prstShdw.attributes["dist"]);
7612
+ if (prstShdw.attributes?.["dir"] !== void 0) prstOpts.direction = Number(prstShdw.attributes["dir"]);
7613
+ const color = readColorFromElement(prstShdw, ctx);
7614
+ if (color) prstOpts.color = color;
7615
+ result.presetShadow = prstOpts;
7616
+ }
7617
+ const reflection = findChild(el, "a:reflection");
7618
+ if (reflection) {
7619
+ const refOpts = {};
7620
+ if (reflection.attributes?.["blurRad"] !== void 0) refOpts.blurRadius = Number(reflection.attributes["blurRad"]);
7621
+ if (reflection.attributes?.["stA"] !== void 0) refOpts.startAlpha = Number(reflection.attributes["stA"]);
7622
+ if (reflection.attributes?.["stPos"] !== void 0) refOpts.startPosition = Number(reflection.attributes["stPos"]);
7623
+ if (reflection.attributes?.["endA"] !== void 0) refOpts.endAlpha = Number(reflection.attributes["endA"]);
7624
+ if (reflection.attributes?.["endPos"] !== void 0) refOpts.endPosition = Number(reflection.attributes["endPos"]);
7625
+ if (reflection.attributes?.["dist"] !== void 0) refOpts.distance = Number(reflection.attributes["dist"]);
7626
+ if (reflection.attributes?.["dir"] !== void 0) refOpts.direction = Number(reflection.attributes["dir"]);
7627
+ if (reflection.attributes?.["fadeDir"] !== void 0) refOpts.fadeDirection = Number(reflection.attributes["fadeDir"]);
7628
+ if (reflection.attributes?.["sx"] !== void 0) refOpts.scaleX = Number(reflection.attributes["sx"]);
7629
+ if (reflection.attributes?.["sy"] !== void 0) refOpts.scaleY = Number(reflection.attributes["sy"]);
7630
+ if (reflection.attributes?.["kx"] !== void 0) refOpts.skewX = Number(reflection.attributes["kx"]);
7631
+ if (reflection.attributes?.["ky"] !== void 0) refOpts.skewY = Number(reflection.attributes["ky"]);
7632
+ if (reflection.attributes?.["algn"] !== void 0) refOpts.alignment = String(reflection.attributes["algn"]);
7633
+ if (reflection.attributes?.["rotWithShape"] !== void 0) refOpts.rotWithShape = reflection.attributes["rotWithShape"] !== "0";
7634
+ result.reflection = refOpts;
7658
7635
  }
7636
+ const softEdge = findChild(el, "a:softEdge");
7637
+ if (softEdge?.attributes?.["rad"] !== void 0) result.softEdge = Number(softEdge.attributes["rad"]);
7659
7638
  return result;
7660
7639
  }
7661
7640
  };
7662
7641
  //#endregion
7663
- //#region src/drawingml/transform-descriptors.ts
7664
- /**
7665
- * Transform 2D descriptor for DrawingML shapes.
7666
- *
7667
- * @module
7668
- */
7669
- const transform2DDesc = {
7642
+ //#region src/drawingml/locking/locking-descriptors.ts
7643
+ const BASE_LOCKING_KEYS = [
7644
+ "noGrp",
7645
+ "noSelect",
7646
+ "noRot",
7647
+ "noChangeAspect",
7648
+ "noMove",
7649
+ "noResize",
7650
+ "noEditPoints",
7651
+ "noAdjustHandles",
7652
+ "noChangeArrowheads",
7653
+ "noChangeShapeType"
7654
+ ];
7655
+ const SHAPE_EXTRA_KEYS = ["noTextEdit"];
7656
+ const PICTURE_EXTRA_KEYS = ["noCrop"];
7657
+ const GROUP_EXTRA_KEYS = ["noUngrp"];
7658
+ const FRAME_EXTRA_KEYS = ["noDrilldown"];
7659
+ function stringifyLockingAttrs(opts, keys) {
7660
+ const parts = [];
7661
+ for (const key of keys) if (opts[key] !== void 0) parts.push(`${key}="${opts[key] ? 1 : 0}"`);
7662
+ return parts.length ? " " + parts.join(" ") : "";
7663
+ }
7664
+ function readLockingAttrs(el, keys) {
7665
+ const result = {};
7666
+ if (!el.attributes) return result;
7667
+ for (const key of keys) {
7668
+ const val = el.attributes[key];
7669
+ if (val !== void 0) result[key] = val === "1" || val === 1 || val === "true";
7670
+ }
7671
+ return result;
7672
+ }
7673
+ const shapeLockingDesc = {
7670
7674
  kind: "custom",
7671
7675
  stringify(opts, _ctx) {
7672
- const parts = [];
7673
- const attrParts = [];
7674
- if (opts.flipHorizontal !== void 0) attrParts.push(`flipH="${opts.flipHorizontal ? 1 : 0}"`);
7675
- if (opts.flipVertical !== void 0) attrParts.push(`flipV="${opts.flipVertical ? 1 : 0}"`);
7676
- if (opts.rotation !== void 0) attrParts.push(`rot="${opts.rotation}"`);
7677
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7678
- if (opts.x !== void 0 || opts.y !== void 0) {
7679
- const x = opts.x !== void 0 ? convertToEmu(opts.x) : 0;
7680
- const y = opts.y !== void 0 ? convertToEmu(opts.y) : 0;
7681
- parts.push(`<a:off x="${x}" y="${y}"/>`);
7682
- }
7683
- if (opts.width !== void 0 || opts.height !== void 0) {
7684
- const cx = opts.width !== void 0 ? convertToEmu(opts.width) : 0;
7685
- const cy = opts.height !== void 0 ? convertToEmu(opts.height) : 0;
7686
- parts.push(`<a:ext cx="${cx}" cy="${cy}"/>`);
7687
- }
7688
- if (parts.length === 0 && !attrStr) return void 0;
7689
- if (parts.length === 0) return `<a:xfrm${attrStr}/>`;
7690
- return `<a:xfrm${attrStr}>${parts.join("")}</a:xfrm>`;
7676
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7677
+ if (!attrStr) return void 0;
7678
+ return `<a:spLocks${attrStr}/>`;
7679
+ },
7680
+ parse(el, _ctx) {
7681
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...SHAPE_EXTRA_KEYS]);
7682
+ }
7683
+ };
7684
+ const pictureLockingDesc = {
7685
+ kind: "custom",
7686
+ stringify(opts, _ctx) {
7687
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7688
+ if (!attrStr) return void 0;
7689
+ return `<a:picLocks${attrStr}/>`;
7691
7690
  },
7692
7691
  parse(el, _ctx) {
7693
- const result = {};
7694
- if (el.attributes) {
7695
- if (el.attributes["flipH"] !== void 0) result.flipHorizontal = el.attributes["flipH"] === 1 || el.attributes["flipH"] === "1";
7696
- if (el.attributes["flipV"] !== void 0) result.flipVertical = el.attributes["flipV"] === 1 || el.attributes["flipV"] === "1";
7697
- if (el.attributes["rot"] !== void 0) result.rotation = Number(el.attributes["rot"]);
7698
- }
7699
- const off = findChild(el, "a:off");
7700
- if (off?.attributes) {
7701
- result.x = attrMeasure(off, "x") ?? 0;
7702
- result.y = attrMeasure(off, "y") ?? 0;
7703
- }
7704
- const ext = findChild(el, "a:ext");
7705
- if (ext?.attributes) {
7706
- result.width = attrMeasure(ext, "cx") ?? 0;
7707
- result.height = attrMeasure(ext, "cy") ?? 0;
7708
- }
7709
- return result;
7692
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...PICTURE_EXTRA_KEYS]);
7710
7693
  }
7711
7694
  };
7712
- const groupTransform2DDesc = {
7695
+ const groupLockingDesc = {
7713
7696
  kind: "custom",
7714
- stringify(opts, ctx) {
7715
- const base = transform2DDesc.stringify(opts, ctx) ?? "<a:xfrm/>";
7716
- const chOff = `<a:chOff x="${opts.childOffsetX ?? 0}" y="${opts.childOffsetY ?? 0}"/>`;
7717
- const chExt = `<a:chExt cx="${opts.childExtentWidth ?? 0}" cy="${opts.childExtentHeight ?? 0}"/>`;
7718
- if (base.endsWith("/>")) return `<a:xfrm>${chOff}${chExt}</a:xfrm>`;
7719
- return base.replace(/<\/a:xfrm>$/, `${chOff}${chExt}</a:xfrm>`);
7697
+ stringify(opts, _ctx) {
7698
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7699
+ if (!attrStr) return void 0;
7700
+ return `<a:grpSpLocks${attrStr}/>`;
7720
7701
  },
7721
- parse(el, ctx) {
7722
- const result = transform2DDesc.parse(el, ctx);
7723
- const chOff = findChild(el, "a:chOff");
7724
- if (chOff?.attributes) {
7725
- result.childOffsetX = attrMeasure(chOff, "x") ?? 0;
7726
- result.childOffsetY = attrMeasure(chOff, "y") ?? 0;
7727
- }
7728
- const chExt = findChild(el, "a:chExt");
7729
- if (chExt?.attributes) {
7730
- result.childExtentWidth = attrMeasure(chExt, "cx") ?? 0;
7731
- result.childExtentHeight = attrMeasure(chExt, "cy") ?? 0;
7732
- }
7733
- return result;
7702
+ parse(el, _ctx) {
7703
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...GROUP_EXTRA_KEYS]);
7704
+ }
7705
+ };
7706
+ const graphicFrameLockingDesc = {
7707
+ kind: "custom",
7708
+ stringify(opts, _ctx) {
7709
+ const attrStr = stringifyLockingAttrs(opts, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7710
+ if (!attrStr) return void 0;
7711
+ return `<a:graphicFrameLocks${attrStr}/>`;
7712
+ },
7713
+ parse(el, _ctx) {
7714
+ return readLockingAttrs(el, [...BASE_LOCKING_KEYS, ...FRAME_EXTRA_KEYS]);
7734
7715
  }
7735
7716
  };
7736
7717
  //#endregion
7737
- //#region src/drawingml/three-d/three-d-descriptors.ts
7718
+ //#region src/drawingml/geometry/geometry-descriptors.ts
7738
7719
  /**
7739
- * 3D descriptor for DrawingML shapes.
7720
+ * Geometry descriptors for DrawingML shapes.
7740
7721
  *
7741
7722
  * @module
7742
7723
  */
7743
- function stringifySphereCoords(coords) {
7744
- return `<a:rot lat="${coords.lat}" lon="${coords.lon}" rev="${coords.rev}"/>`;
7745
- }
7746
- function readSphereCoords(el) {
7747
- const lat = el.attributes?.["lat"];
7748
- const lon = el.attributes?.["lon"];
7749
- const rev = el.attributes?.["rev"];
7750
- if (lat === void 0 || lon === void 0 || rev === void 0) return void 0;
7751
- return {
7752
- lat: Number(lat),
7753
- lon: Number(lon),
7754
- rev: Number(rev)
7755
- };
7756
- }
7757
- const bevelDesc = {
7724
+ const adjustmentValuesDesc = {
7758
7725
  kind: "custom",
7759
- stringify(opts, _ctx) {
7760
- const attrParts = [];
7761
- if (opts.w !== void 0) attrParts.push(`w="${opts.w}"`);
7762
- if (opts.h !== void 0) attrParts.push(`h="${opts.h}"`);
7763
- if (opts.prst !== void 0) attrParts.push(`prst="${escapeXml(opts.prst)}"`);
7764
- return `<a:bevel${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
7726
+ stringify(guides, _ctx) {
7727
+ if (!guides || guides.length === 0) return "<a:avLst/>";
7728
+ return `<a:avLst>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</a:avLst>`;
7765
7729
  },
7766
7730
  parse(el, _ctx) {
7767
- const result = {};
7768
- if (el.attributes?.["w"] !== void 0) result.w = Number(el.attributes["w"]);
7769
- if (el.attributes?.["h"] !== void 0) result.h = Number(el.attributes["h"]);
7770
- if (el.attributes?.["prst"] !== void 0) result.prst = String(el.attributes["prst"]);
7731
+ const result = [];
7732
+ if (el.elements) {
7733
+ for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7734
+ const name = child.attributes["name"];
7735
+ const fmla = child.attributes["fmla"];
7736
+ if (name !== void 0 && fmla !== void 0) result.push({
7737
+ name: String(name),
7738
+ formula: String(fmla)
7739
+ });
7740
+ }
7741
+ }
7771
7742
  return result;
7772
7743
  }
7773
7744
  };
7774
- const shape3DDesc = {
7745
+ const presetGeometryDesc = {
7775
7746
  kind: "custom",
7776
7747
  stringify(opts, ctx) {
7777
- const parts = [];
7778
- if (opts.bevelT) {
7779
- const bevelXml = stringify$1(bevelDesc, opts.bevelT, ctx);
7780
- if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelT"));
7781
- }
7782
- if (opts.bevelB) {
7783
- const bevelXml = stringify$1(bevelDesc, opts.bevelB, ctx);
7784
- if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelB"));
7785
- }
7786
- if (opts.extrusionColor) {
7787
- const colorXml = stringify$1(solidFillDesc, opts.extrusionColor, ctx);
7788
- if (colorXml) parts.push(`<a:extrusionClr>${colorXml}</a:extrusionClr>`);
7789
- }
7790
- if (opts.contourColor) {
7791
- const colorXml = stringify$1(solidFillDesc, opts.contourColor, ctx);
7792
- if (colorXml) parts.push(`<a:contourClr>${colorXml}</a:contourClr>`);
7793
- }
7794
- const attrParts = [];
7795
- if (opts.z !== void 0) attrParts.push(`z="${opts.z}"`);
7796
- if (opts.extrusionH !== void 0) attrParts.push(`extrusionH="${opts.extrusionH}"`);
7797
- if (opts.contourW !== void 0) attrParts.push(`contourW="${opts.contourW}"`);
7798
- if (opts.prstMaterial !== void 0) attrParts.push(`prstMaterial="${escapeXml(xsdMaterialType.to(opts.prstMaterial))}"`);
7799
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
7800
- const content = parts.join("");
7801
- if (!attrStr && !content) return void 0;
7802
- if (!content) return `<a:sp3d${attrStr}/>`;
7803
- return `<a:sp3d${attrStr}>${content}</a:sp3d>`;
7748
+ const prst = opts.preset ?? "rect";
7749
+ let avXml = "";
7750
+ if (opts.adjustmentValues) avXml = stringify$1(adjustmentValuesDesc, opts.adjustmentValues, ctx) ?? "<a:avLst/>";
7751
+ else avXml = "<a:avLst/>";
7752
+ return `<a:prstGeom prst="${escapeXml(prst)}">${avXml}</a:prstGeom>`;
7804
7753
  },
7805
7754
  parse(el, ctx) {
7806
7755
  const result = {};
7807
- if (el.attributes?.["z"] !== void 0) result.z = Number(el.attributes["z"]);
7808
- if (el.attributes?.["extrusionH"] !== void 0) result.extrusionH = Number(el.attributes["extrusionH"]);
7809
- if (el.attributes?.["contourW"] !== void 0) result.contourW = Number(el.attributes["contourW"]);
7810
- if (el.attributes?.["prstMaterial"] !== void 0) result.prstMaterial = xsdMaterialType.from(String(el.attributes["prstMaterial"]));
7811
- const bevelT = findChild(el, "a:bevelT");
7812
- if (bevelT) result.bevelT = parse$1(bevelDesc, bevelT, ctx);
7813
- const bevelB = findChild(el, "a:bevelB");
7814
- if (bevelB) result.bevelB = parse$1(bevelDesc, bevelB, ctx);
7815
- const extrusionClr = findChild(el, "a:extrusionClr");
7816
- if (extrusionClr) {
7817
- const solidFill = findChild(extrusionClr, "a:solidFill");
7818
- if (solidFill) result.extrusionColor = parse$1(solidFillDesc, solidFill, ctx);
7819
- }
7820
- const contourClr = findChild(el, "a:contourClr");
7821
- if (contourClr) {
7822
- const solidFill = findChild(contourClr, "a:solidFill");
7823
- if (solidFill) result.contourColor = parse$1(solidFillDesc, solidFill, ctx);
7756
+ if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
7757
+ const avLst = findChild(el, "a:avLst");
7758
+ if (avLst) {
7759
+ const guides = parse$1(adjustmentValuesDesc, avLst, ctx);
7760
+ if (guides.length > 0) result.adjustmentValues = guides;
7824
7761
  }
7825
7762
  return result;
7826
7763
  }
7827
7764
  };
7828
- const cameraDesc = {
7829
- kind: "custom",
7830
- stringify(opts, _ctx) {
7831
- const attrParts = [];
7832
- attrParts.push(`prst="${escapeXml(opts.preset)}"`);
7833
- if (opts.fov !== void 0) attrParts.push(`fov="${opts.fov}"`);
7834
- if (opts.zoom !== void 0) attrParts.push(`zoom="${escapeXml(opts.zoom)}"`);
7835
- const attrStr = " " + attrParts.join(" ");
7836
- const parts = [];
7837
- if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
7838
- const content = parts.join("");
7839
- if (!content) return `<a:camera${attrStr}/>`;
7840
- return `<a:camera${attrStr}>${content}</a:camera>`;
7841
- },
7842
- parse(el, _ctx) {
7843
- const result = {};
7844
- if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
7845
- if (el.attributes?.["fov"] !== void 0) result.fov = Number(el.attributes["fov"]);
7846
- if (el.attributes?.["zoom"] !== void 0) result.zoom = String(el.attributes["zoom"]);
7847
- const rot = findChild(el, "a:rot");
7848
- if (rot) result.rotation = readSphereCoords(rot);
7849
- return result;
7765
+ function stringifyAdjustPoint(pt) {
7766
+ return `<a:pt x="${escapeXml(pt.x)}" y="${escapeXml(pt.y)}"/>`;
7767
+ }
7768
+ function stringifyPathCommand(cmd) {
7769
+ switch (cmd.command) {
7770
+ case "moveTo": return `<a:moveTo>${stringifyAdjustPoint(cmd.point)}</a:moveTo>`;
7771
+ case "lineTo": return `<a:lnTo>${stringifyAdjustPoint(cmd.point)}</a:lnTo>`;
7772
+ case "arcTo": return `<a:arcTo wR="${escapeXml(cmd.widthRadius)}" hR="${escapeXml(cmd.heightRadius)}" stAng="${escapeXml(cmd.startAngle)}" swAng="${escapeXml(cmd.sweepAngle)}"/>`;
7773
+ case "quadBezTo": return `<a:quadBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:quadBezTo>`;
7774
+ case "cubicBezTo": return `<a:cubicBezTo>${cmd.points.map(stringifyAdjustPoint).join("")}</a:cubicBezTo>`;
7775
+ case "close": return "<a:close/>";
7776
+ }
7777
+ }
7778
+ function stringifyPath(path) {
7779
+ const attrs = [];
7780
+ if (path.w !== void 0) attrs.push(`w="${path.w}"`);
7781
+ if (path.h !== void 0) attrs.push(`h="${path.h}"`);
7782
+ if (path.fill !== void 0) attrs.push(`fill="${escapeXml(path.fill)}"`);
7783
+ if (path.stroke !== void 0) attrs.push(`stroke="${path.stroke}"`);
7784
+ if (path.extrusionOk !== void 0) attrs.push(`extrusionOk="${path.extrusionOk}"`);
7785
+ const attrStr = attrs.length ? " " + attrs.join(" ") : "";
7786
+ const cmds = path.commands.map(stringifyPathCommand).join("");
7787
+ if (!cmds && !attrStr) return "<a:path/>";
7788
+ return `<a:path${attrStr}>${cmds}</a:path>`;
7789
+ }
7790
+ function readAdjustPoint(el) {
7791
+ if (!el.attributes) return void 0;
7792
+ const x = el.attributes["x"];
7793
+ const y = el.attributes["y"];
7794
+ if (x === void 0 || y === void 0) return void 0;
7795
+ return {
7796
+ x: String(x),
7797
+ y: String(y)
7798
+ };
7799
+ }
7800
+ function readPathCommand(tag, el) {
7801
+ switch (tag) {
7802
+ case "a:moveTo": {
7803
+ const pt = el.elements?.find((c) => c.name === "a:pt");
7804
+ if (!pt) return void 0;
7805
+ const point = readAdjustPoint(pt);
7806
+ if (!point) return void 0;
7807
+ return {
7808
+ command: "moveTo",
7809
+ point
7810
+ };
7811
+ }
7812
+ case "a:lnTo": {
7813
+ const pt = el.elements?.find((c) => c.name === "a:pt");
7814
+ if (!pt) return void 0;
7815
+ const point = readAdjustPoint(pt);
7816
+ if (!point) return void 0;
7817
+ return {
7818
+ command: "lineTo",
7819
+ point
7820
+ };
7821
+ }
7822
+ case "a:arcTo": {
7823
+ const a = el.attributes;
7824
+ if (!a) return void 0;
7825
+ return {
7826
+ command: "arcTo",
7827
+ widthRadius: String(a["wR"] ?? ""),
7828
+ heightRadius: String(a["hR"] ?? ""),
7829
+ startAngle: String(a["stAng"] ?? ""),
7830
+ sweepAngle: String(a["swAng"] ?? "")
7831
+ };
7832
+ }
7833
+ case "a:quadBezTo": {
7834
+ const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7835
+ if (points.length < 2) return void 0;
7836
+ return {
7837
+ command: "quadBezTo",
7838
+ points: [points[0], points[1]]
7839
+ };
7840
+ }
7841
+ case "a:cubicBezTo": {
7842
+ const points = (el.elements ?? []).filter((c) => c.name === "a:pt").map(readAdjustPoint).filter((p) => p !== void 0);
7843
+ if (points.length < 3) return void 0;
7844
+ return {
7845
+ command: "cubicBezTo",
7846
+ points: [
7847
+ points[0],
7848
+ points[1],
7849
+ points[2]
7850
+ ]
7851
+ };
7852
+ }
7853
+ case "a:close": return { command: "close" };
7854
+ default: return;
7850
7855
  }
7851
- };
7852
- const lightRigDesc = {
7853
- kind: "custom",
7854
- stringify(opts, _ctx) {
7855
- const attrParts = [];
7856
- attrParts.push(`rig="${escapeXml(opts.rig)}"`);
7857
- attrParts.push(`dir="${escapeXml(opts.direction)}"`);
7858
- const attrStr = " " + attrParts.join(" ");
7859
- const parts = [];
7860
- if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
7861
- const content = parts.join("");
7862
- if (!content) return `<a:lightRig${attrStr}/>`;
7863
- return `<a:lightRig${attrStr}>${content}</a:lightRig>`;
7864
- },
7865
- parse(el, _ctx) {
7866
- const result = {};
7867
- if (el.attributes?.["rig"] !== void 0) result.rig = String(el.attributes["rig"]);
7868
- if (el.attributes?.["dir"] !== void 0) result.direction = String(el.attributes["dir"]);
7869
- const rot = findChild(el, "a:rot");
7870
- if (rot) result.rotation = readSphereCoords(rot);
7871
- return result;
7856
+ }
7857
+ function readPath(el) {
7858
+ const result = {};
7859
+ if (el.attributes) {
7860
+ if (el.attributes["w"] !== void 0) result.w = Number(el.attributes["w"]);
7861
+ if (el.attributes["h"] !== void 0) result.h = Number(el.attributes["h"]);
7862
+ if (el.attributes["fill"] !== void 0) result.fill = String(el.attributes["fill"]);
7863
+ if (el.attributes["stroke"] !== void 0) result.stroke = el.attributes["stroke"] !== "0" && el.attributes["stroke"] !== "false";
7864
+ if (el.attributes["extrusionOk"] !== void 0) result.extrusionOk = el.attributes["extrusionOk"] !== "0" && el.attributes["extrusionOk"] !== "false";
7872
7865
  }
7873
- };
7874
- const scene3DDesc = {
7875
- kind: "custom",
7876
- stringify(opts, ctx) {
7877
- const parts = [];
7878
- const cameraXml = stringify$1(cameraDesc, opts.camera, ctx);
7879
- if (cameraXml) parts.push(cameraXml);
7880
- const lightRigXml = stringify$1(lightRigDesc, opts.lightRig, ctx);
7881
- if (lightRigXml) parts.push(lightRigXml);
7882
- if (opts.backdrop) parts.push(stringifyBackdrop(opts.backdrop));
7883
- const content = parts.join("");
7884
- if (!content) return void 0;
7885
- return `<a:scene3d>${content}</a:scene3d>`;
7886
- },
7887
- parse(el, ctx) {
7888
- const result = {};
7889
- const camera = findChild(el, "a:camera");
7890
- if (camera) result.camera = parse$1(cameraDesc, camera, ctx);
7891
- const lightRig = findChild(el, "a:lightRig");
7892
- if (lightRig) result.lightRig = parse$1(lightRigDesc, lightRig, ctx);
7893
- const backdrop = findChild(el, "a:backdrop");
7894
- if (backdrop) result.backdrop = readBackdrop(backdrop);
7895
- return result;
7866
+ const commands = [];
7867
+ if (el.elements) {
7868
+ for (const child of el.elements) if (child.name) {
7869
+ const cmd = readPathCommand(child.name, child);
7870
+ if (cmd) commands.push(cmd);
7871
+ }
7896
7872
  }
7897
- };
7898
- function stringifyPoint3D(name, point) {
7899
- return `<${name} x="${point.x}" y="${point.y}" z="${point.z}"/>`;
7873
+ if (commands.length > 0) result.commands = commands;
7874
+ return result;
7900
7875
  }
7901
- function stringifyVector3D(name, vector) {
7902
- return `<${name} dx="${vector.dx}" dy="${vector.dy}" dz="${vector.dz}"/>`;
7876
+ function stringifyGuideList(tag, guides) {
7877
+ if (!guides || guides.length === 0) return `<${tag}/>`;
7878
+ return `<${tag}>${guides.map((g) => `<a:gd name="${escapeXml(g.name)}" fmla="${escapeXml(g.formula)}"/>`).join("")}</${tag}>`;
7903
7879
  }
7904
- function stringifyBackdrop(opts) {
7905
- return `<a:backdrop>${stringifyPoint3D("a:anchor", opts.anchor) + stringifyVector3D("a:norm", opts.normal) + stringifyVector3D("a:up", opts.up)}</a:backdrop>`;
7880
+ function readGuideList(el) {
7881
+ const result = [];
7882
+ if (el.elements) {
7883
+ for (const child of el.elements) if (child.name === "a:gd" && child.attributes) {
7884
+ const name = child.attributes["name"];
7885
+ const fmla = child.attributes["fmla"];
7886
+ if (name !== void 0 && fmla !== void 0) result.push({
7887
+ name: String(name),
7888
+ formula: String(fmla)
7889
+ });
7890
+ }
7891
+ }
7892
+ return result;
7906
7893
  }
7907
- function readPoint3D(el) {
7908
- const x = el.attributes?.["x"];
7909
- const y = el.attributes?.["y"];
7910
- const z = el.attributes?.["z"];
7911
- if (x === void 0 || y === void 0 || z === void 0) return void 0;
7894
+ function stringifyAdjustHandlePos(pos) {
7895
+ return `<a:pos x="${escapeXml(pos.x)}" y="${escapeXml(pos.y)}"/>`;
7896
+ }
7897
+ function stringifyXYAdjustHandle(h) {
7898
+ const attrs = [];
7899
+ if (h.guideRefX !== void 0) attrs.push(`gdRefX="${escapeXml(h.guideRefX)}"`);
7900
+ if (h.minX !== void 0) attrs.push(`minX="${escapeXml(h.minX)}"`);
7901
+ if (h.maxX !== void 0) attrs.push(`maxX="${escapeXml(h.maxX)}"`);
7902
+ if (h.guideRefY !== void 0) attrs.push(`gdRefY="${escapeXml(h.guideRefY)}"`);
7903
+ if (h.minY !== void 0) attrs.push(`minY="${escapeXml(h.minY)}"`);
7904
+ if (h.maxY !== void 0) attrs.push(`maxY="${escapeXml(h.maxY)}"`);
7905
+ return `<a:ahXY${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahXY>`;
7906
+ }
7907
+ function stringifyPolarAdjustHandle(h) {
7908
+ const attrs = [];
7909
+ if (h.guideRefRadius !== void 0) attrs.push(`gdRefR="${escapeXml(h.guideRefRadius)}"`);
7910
+ if (h.minRadius !== void 0) attrs.push(`minR="${escapeXml(h.minRadius)}"`);
7911
+ if (h.maxRadius !== void 0) attrs.push(`maxR="${escapeXml(h.maxRadius)}"`);
7912
+ if (h.guideRefAngle !== void 0) attrs.push(`gdRefAng="${escapeXml(h.guideRefAngle)}"`);
7913
+ if (h.minAngle !== void 0) attrs.push(`minAng="${escapeXml(h.minAngle)}"`);
7914
+ if (h.maxAngle !== void 0) attrs.push(`maxAng="${escapeXml(h.maxAngle)}"`);
7915
+ return `<a:ahPolar${attrs.length ? " " + attrs.join(" ") : ""}>${stringifyAdjustHandlePos(h.position)}</a:ahPolar>`;
7916
+ }
7917
+ function stringifyAdjustHandle(h) {
7918
+ return h.type === "xy" ? stringifyXYAdjustHandle(h) : stringifyPolarAdjustHandle(h);
7919
+ }
7920
+ function readAdjustHandlePos(el) {
7921
+ const pos = el.elements?.find((c) => c.name === "a:pos");
7922
+ if (!pos?.attributes) return void 0;
7923
+ const x = pos.attributes["x"];
7924
+ const y = pos.attributes["y"];
7925
+ if (x === void 0 || y === void 0) return void 0;
7912
7926
  return {
7913
- x: Number(x),
7914
- y: Number(y),
7915
- z: Number(z)
7927
+ x: String(x),
7928
+ y: String(y)
7916
7929
  };
7917
7930
  }
7918
- function readVector3D(el) {
7919
- const dx = el.attributes?.["dx"];
7920
- const dy = el.attributes?.["dy"];
7921
- const dz = el.attributes?.["dz"];
7922
- if (dx === void 0 || dy === void 0 || dz === void 0) return void 0;
7931
+ function readXYAdjustHandle(el) {
7932
+ const position = readAdjustHandlePos(el);
7933
+ if (!position) return void 0;
7934
+ const result = {
7935
+ type: "xy",
7936
+ position
7937
+ };
7938
+ if (el.attributes?.["gdRefX"] !== void 0) result.guideRefX = String(el.attributes["gdRefX"]);
7939
+ if (el.attributes?.["minX"] !== void 0) result.minX = String(el.attributes["minX"]);
7940
+ if (el.attributes?.["maxX"] !== void 0) result.maxX = String(el.attributes["maxX"]);
7941
+ if (el.attributes?.["gdRefY"] !== void 0) result.guideRefY = String(el.attributes["gdRefY"]);
7942
+ if (el.attributes?.["minY"] !== void 0) result.minY = String(el.attributes["minY"]);
7943
+ if (el.attributes?.["maxY"] !== void 0) result.maxY = String(el.attributes["maxY"]);
7944
+ return result;
7945
+ }
7946
+ function readPolarAdjustHandle(el) {
7947
+ const position = readAdjustHandlePos(el);
7948
+ if (!position) return void 0;
7949
+ const result = {
7950
+ type: "polar",
7951
+ position
7952
+ };
7953
+ if (el.attributes?.["gdRefR"] !== void 0) result.guideRefRadius = String(el.attributes["gdRefR"]);
7954
+ if (el.attributes?.["minR"] !== void 0) result.minRadius = String(el.attributes["minR"]);
7955
+ if (el.attributes?.["maxR"] !== void 0) result.maxRadius = String(el.attributes["maxR"]);
7956
+ if (el.attributes?.["gdRefAng"] !== void 0) result.guideRefAngle = String(el.attributes["gdRefAng"]);
7957
+ if (el.attributes?.["minAng"] !== void 0) result.minAngle = String(el.attributes["minAng"]);
7958
+ if (el.attributes?.["maxAng"] !== void 0) result.maxAngle = String(el.attributes["maxAng"]);
7959
+ return result;
7960
+ }
7961
+ function stringifyConnectionSite(site) {
7962
+ return `<a:cxn ang="${escapeXml(site.angle)}">${stringifyAdjustHandlePos(site.position)}</a:cxn>`;
7963
+ }
7964
+ function readConnectionSite(el) {
7965
+ const ang = el.attributes?.["ang"];
7966
+ if (ang === void 0) return void 0;
7967
+ const position = readAdjustHandlePos(el);
7968
+ if (!position) return void 0;
7923
7969
  return {
7924
- dx: Number(dx),
7925
- dy: Number(dy),
7926
- dz: Number(dz)
7970
+ angle: String(ang),
7971
+ position
7927
7972
  };
7928
7973
  }
7929
- function readBackdrop(el) {
7930
- const anchor = findChild(el, "a:anchor");
7931
- const norm = findChild(el, "a:norm");
7932
- const up = findChild(el, "a:up");
7933
- if (!anchor || !norm || !up) return void 0;
7934
- const anchorPt = readPoint3D(anchor);
7935
- const normVec = readVector3D(norm);
7936
- const upVec = readVector3D(up);
7937
- if (!anchorPt || !normVec || !upVec) return void 0;
7974
+ function stringifyGeomRect(rect) {
7975
+ return `<a:rect l="${escapeXml(rect.left)}" t="${escapeXml(rect.top)}" r="${escapeXml(rect.right)}" b="${escapeXml(rect.bottom)}"/>`;
7976
+ }
7977
+ function readGeomRect(el) {
7978
+ const a = el.attributes;
7979
+ if (!a) return void 0;
7980
+ const l = a["l"];
7981
+ const t = a["t"];
7982
+ const r = a["r"];
7983
+ const b = a["b"];
7984
+ if (l === void 0 || t === void 0 || r === void 0 || b === void 0) return void 0;
7938
7985
  return {
7939
- anchor: anchorPt,
7940
- normal: normVec,
7941
- up: upVec
7986
+ left: String(l),
7987
+ top: String(t),
7988
+ right: String(r),
7989
+ bottom: String(b)
7942
7990
  };
7943
7991
  }
7992
+ const customGeometryDesc = {
7993
+ kind: "custom",
7994
+ stringify(opts, _ctx) {
7995
+ const parts = [];
7996
+ if (opts.adjustmentValues && opts.adjustmentValues.length > 0) parts.push(stringifyGuideList("a:avLst", opts.adjustmentValues));
7997
+ else parts.push("<a:avLst/>");
7998
+ if (opts.guides && opts.guides.length > 0) parts.push(stringifyGuideList("a:gdLst", opts.guides));
7999
+ if (opts.adjustHandles && opts.adjustHandles.length > 0) {
8000
+ const inner = opts.adjustHandles.map(stringifyAdjustHandle).join("");
8001
+ parts.push(`<a:ahLst>${inner}</a:ahLst>`);
8002
+ }
8003
+ if (opts.connectionSites && opts.connectionSites.length > 0) {
8004
+ const inner = opts.connectionSites.map(stringifyConnectionSite).join("");
8005
+ parts.push(`<a:cxnLst>${inner}</a:cxnLst>`);
8006
+ }
8007
+ if (opts.textRectangle) parts.push(stringifyGeomRect(opts.textRectangle));
8008
+ const pathsXml = opts.pathList.map(stringifyPath).join("");
8009
+ parts.push(`<a:pathLst>${pathsXml}</a:pathLst>`);
8010
+ return `<a:custGeom>${parts.join("")}</a:custGeom>`;
8011
+ },
8012
+ parse(el, _ctx) {
8013
+ const result = {};
8014
+ const avLst = findChild(el, "a:avLst");
8015
+ if (avLst) {
8016
+ const guides = readGuideList(avLst);
8017
+ if (guides.length > 0) result.adjustmentValues = guides;
8018
+ }
8019
+ const gdLst = findChild(el, "a:gdLst");
8020
+ if (gdLst) {
8021
+ const guides = readGuideList(gdLst);
8022
+ if (guides.length > 0) result.guides = guides;
8023
+ }
8024
+ const ahLst = findChild(el, "a:ahLst");
8025
+ if (ahLst?.elements) {
8026
+ const handles = [];
8027
+ for (const child of ahLst.elements) if (child.name === "a:ahXY") {
8028
+ const h = readXYAdjustHandle(child);
8029
+ if (h) handles.push(h);
8030
+ } else if (child.name === "a:ahPolar") {
8031
+ const h = readPolarAdjustHandle(child);
8032
+ if (h) handles.push(h);
8033
+ }
8034
+ if (handles.length > 0) result.adjustHandles = handles;
8035
+ }
8036
+ const cxnLst = findChild(el, "a:cxnLst");
8037
+ if (cxnLst?.elements) {
8038
+ const sites = [];
8039
+ for (const child of cxnLst.elements) if (child.name === "a:cxn") {
8040
+ const site = readConnectionSite(child);
8041
+ if (site) sites.push(site);
8042
+ }
8043
+ if (sites.length > 0) result.connectionSites = sites;
8044
+ }
8045
+ const rect = findChild(el, "a:rect");
8046
+ if (rect) {
8047
+ const textRectangle = readGeomRect(rect);
8048
+ if (textRectangle) result.textRectangle = textRectangle;
8049
+ }
8050
+ const pathLst = findChild(el, "a:pathLst");
8051
+ if (pathLst?.elements) {
8052
+ const paths = [];
8053
+ for (const child of pathLst.elements) if (child.name === "a:path") {
8054
+ const p = readPath(child);
8055
+ if (p.commands && p.commands.length > 0) paths.push(p);
8056
+ }
8057
+ if (paths.length > 0) result.pathList = paths;
8058
+ }
8059
+ return result;
8060
+ }
8061
+ };
7944
8062
  //#endregion
7945
- //#region src/drawingml/blip/blip-descriptors.ts
8063
+ //#region src/drawingml/transform-descriptors.ts
7946
8064
  /**
7947
- * Blip descriptor for DrawingML pictures.
8065
+ * Transform 2D descriptor for DrawingML shapes.
7948
8066
  *
7949
8067
  * @module
7950
8068
  */
7951
- const tileDesc = {
7952
- kind: "custom",
7953
- stringify(opts, _ctx) {
7954
- const attrParts = [];
7955
- if (opts.tx !== void 0) attrParts.push(`tx="${opts.tx}"`);
7956
- if (opts.ty !== void 0) attrParts.push(`ty="${opts.ty}"`);
7957
- if (opts.sx !== void 0) attrParts.push(`sx="${opts.sx}"`);
7958
- if (opts.sy !== void 0) attrParts.push(`sy="${opts.sy}"`);
7959
- if (opts.flip !== void 0) attrParts.push(`flip="${escapeXml(opts.flip)}"`);
7960
- if (opts.align !== void 0) attrParts.push(`algn="${escapeXml(xsdRectAlignment.to(opts.align))}"`);
7961
- return `<a:tile${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
7962
- },
7963
- parse(el, _ctx) {
7964
- const result = {};
7965
- if (el.attributes?.["tx"] !== void 0) result.tx = Number(el.attributes["tx"]);
7966
- if (el.attributes?.["ty"] !== void 0) result.ty = Number(el.attributes["ty"]);
7967
- if (el.attributes?.["sx"] !== void 0) result.sx = Number(el.attributes["sx"]);
7968
- if (el.attributes?.["sy"] !== void 0) result.sy = Number(el.attributes["sy"]);
7969
- if (el.attributes?.["flip"] !== void 0) result.flip = String(el.attributes["flip"]);
7970
- if (el.attributes?.["algn"] !== void 0) result.align = xsdRectAlignment.from(String(el.attributes["algn"]));
7971
- return result;
7972
- }
7973
- };
7974
- const sourceRectangleDesc = {
8069
+ const transform2DDesc = {
7975
8070
  kind: "custom",
7976
8071
  stringify(opts, _ctx) {
8072
+ const parts = [];
7977
8073
  const attrParts = [];
7978
- if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
7979
- if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
7980
- if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
7981
- if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
7982
- return `<a:srcRect${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
8074
+ if (opts.flipHorizontal !== void 0) attrParts.push(`flipH="${opts.flipHorizontal ? 1 : 0}"`);
8075
+ if (opts.flipVertical !== void 0) attrParts.push(`flipV="${opts.flipVertical ? 1 : 0}"`);
8076
+ if (opts.rotation !== void 0) attrParts.push(`rot="${opts.rotation}"`);
8077
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8078
+ if (opts.x !== void 0 || opts.y !== void 0) {
8079
+ const x = opts.x !== void 0 ? convertToEmu(opts.x) : 0;
8080
+ const y = opts.y !== void 0 ? convertToEmu(opts.y) : 0;
8081
+ parts.push(`<a:off x="${x}" y="${y}"/>`);
8082
+ }
8083
+ if (opts.width !== void 0 || opts.height !== void 0) {
8084
+ const cx = opts.width !== void 0 ? convertToEmu(opts.width) : 0;
8085
+ const cy = opts.height !== void 0 ? convertToEmu(opts.height) : 0;
8086
+ parts.push(`<a:ext cx="${cx}" cy="${cy}"/>`);
8087
+ }
8088
+ if (parts.length === 0 && !attrStr) return void 0;
8089
+ if (parts.length === 0) return `<a:xfrm${attrStr}/>`;
8090
+ return `<a:xfrm${attrStr}>${parts.join("")}</a:xfrm>`;
7983
8091
  },
7984
8092
  parse(el, _ctx) {
7985
8093
  const result = {};
7986
- if (el.attributes?.["l"] !== void 0) result.left = Number(el.attributes["l"]);
7987
- if (el.attributes?.["t"] !== void 0) result.top = Number(el.attributes["t"]);
7988
- if (el.attributes?.["r"] !== void 0) result.right = Number(el.attributes["r"]);
7989
- if (el.attributes?.["b"] !== void 0) result.bottom = Number(el.attributes["b"]);
8094
+ if (el.attributes) {
8095
+ if (el.attributes["flipH"] !== void 0) result.flipHorizontal = el.attributes["flipH"] === 1 || el.attributes["flipH"] === "1";
8096
+ if (el.attributes["flipV"] !== void 0) result.flipVertical = el.attributes["flipV"] === 1 || el.attributes["flipV"] === "1";
8097
+ if (el.attributes["rot"] !== void 0) result.rotation = Number(el.attributes["rot"]);
8098
+ }
8099
+ const off = findChild(el, "a:off");
8100
+ if (off?.attributes) {
8101
+ result.x = attrMeasure(off, "x") ?? 0;
8102
+ result.y = attrMeasure(off, "y") ?? 0;
8103
+ }
8104
+ const ext = findChild(el, "a:ext");
8105
+ if (ext?.attributes) {
8106
+ result.width = attrMeasure(ext, "cx") ?? 0;
8107
+ result.height = attrMeasure(ext, "cy") ?? 0;
8108
+ }
7990
8109
  return result;
7991
8110
  }
7992
8111
  };
7993
- const stretchDesc = {
8112
+ const groupTransform2DDesc = {
7994
8113
  kind: "custom",
7995
- stringify(opts, _ctx) {
7996
- const attrParts = [];
7997
- if (opts.left !== void 0) attrParts.push(`l="${opts.left}"`);
7998
- if (opts.top !== void 0) attrParts.push(`t="${opts.top}"`);
7999
- if (opts.right !== void 0) attrParts.push(`r="${opts.right}"`);
8000
- if (opts.bottom !== void 0) attrParts.push(`b="${opts.bottom}"`);
8001
- return `<a:stretch><a:fillRect${attrParts.length ? " " + attrParts.join(" ") : ""}/></a:stretch>`;
8114
+ stringify(opts, ctx) {
8115
+ const base = transform2DDesc.stringify(opts, ctx) ?? "<a:xfrm/>";
8116
+ const chOff = `<a:chOff x="${opts.childOffsetX ?? 0}" y="${opts.childOffsetY ?? 0}"/>`;
8117
+ const chExt = `<a:chExt cx="${opts.childExtentWidth ?? 0}" cy="${opts.childExtentHeight ?? 0}"/>`;
8118
+ if (base.endsWith("/>")) return `<a:xfrm>${chOff}${chExt}</a:xfrm>`;
8119
+ return base.replace(/<\/a:xfrm>$/, `${chOff}${chExt}</a:xfrm>`);
8002
8120
  },
8003
- parse(el, _ctx) {
8004
- const fillRect = findChild(el, "a:fillRect");
8005
- if (!fillRect) return {};
8006
- const result = {};
8007
- if (fillRect.attributes?.["l"] !== void 0) result.left = Number(fillRect.attributes["l"]);
8008
- if (fillRect.attributes?.["t"] !== void 0) result.top = Number(fillRect.attributes["t"]);
8009
- if (fillRect.attributes?.["r"] !== void 0) result.right = Number(fillRect.attributes["r"]);
8010
- if (fillRect.attributes?.["b"] !== void 0) result.bottom = Number(fillRect.attributes["b"]);
8121
+ parse(el, ctx) {
8122
+ const result = transform2DDesc.parse(el, ctx);
8123
+ const chOff = findChild(el, "a:chOff");
8124
+ if (chOff?.attributes) {
8125
+ result.childOffsetX = attrMeasure(chOff, "x") ?? 0;
8126
+ result.childOffsetY = attrMeasure(chOff, "y") ?? 0;
8127
+ }
8128
+ const chExt = findChild(el, "a:chExt");
8129
+ if (chExt?.attributes) {
8130
+ result.childExtentWidth = attrMeasure(chExt, "cx") ?? 0;
8131
+ result.childExtentHeight = attrMeasure(chExt, "cy") ?? 0;
8132
+ }
8011
8133
  return result;
8012
8134
  }
8013
8135
  };
8014
- function stringifyBlipEffects(opts, ctx) {
8015
- const parts = [];
8016
- if (opts.grayscale) parts.push("<a:grayscl/>");
8017
- if (opts.luminance) {
8018
- const attrParts = [];
8019
- if (opts.luminance.bright !== void 0) attrParts.push(`bright="${opts.luminance.bright}"`);
8020
- if (opts.luminance.contrast !== void 0) attrParts.push(`contrast="${opts.luminance.contrast}"`);
8021
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8022
- parts.push(`<a:lum${attrStr}/>`);
8023
- }
8024
- if (opts.hsl) {
8025
- const attrParts = [];
8026
- if (opts.hsl.hue !== void 0) attrParts.push(`hue="${opts.hsl.hue}"`);
8027
- if (opts.hsl.saturation !== void 0) attrParts.push(`sat="${opts.hsl.saturation}"`);
8028
- if (opts.hsl.luminance !== void 0) attrParts.push(`lum="${opts.hsl.luminance}"`);
8029
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8030
- parts.push(`<a:hsl${attrStr}/>`);
8031
- }
8032
- if (opts.tint) {
8033
- const attrParts = [];
8034
- if (opts.tint.hue !== void 0) attrParts.push(`hue="${opts.tint.hue}"`);
8035
- if (opts.tint.amount !== void 0) attrParts.push(`amt="${opts.tint.amount}"`);
8036
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8037
- parts.push(`<a:tint${attrStr}/>`);
8038
- }
8039
- if (opts.duotone) {
8040
- const c1 = stringify$1(solidFillDesc, opts.duotone.color1, ctx);
8041
- const c2 = stringify$1(solidFillDesc, opts.duotone.color2, ctx);
8042
- parts.push(`<a:duotone>${c1 ?? ""}${c2 ?? ""}</a:duotone>`);
8043
- }
8044
- if (opts.biLevel) parts.push(`<a:biLevel thresh="${opts.biLevel.threshold}"/>`);
8045
- if (opts.alphaCeiling) parts.push("<a:alphaCeiling/>");
8046
- if (opts.alphaFloor) parts.push("<a:alphaFloor/>");
8047
- if (opts.alphaInverse !== void 0) if (typeof opts.alphaInverse === "boolean") parts.push("<a:alphaInv/>");
8048
- else {
8049
- const colorXml = stringify$1(solidFillDesc, opts.alphaInverse, ctx);
8050
- parts.push(`<a:alphaInv>${colorXml ?? ""}</a:alphaInv>`);
8051
- }
8052
- if (opts.alphaModFix) {
8053
- const amt = opts.alphaModFix.amount ?? 100;
8054
- parts.push(`<a:alphaModFix amt="${amt}"/>`);
8055
- }
8056
- if (opts.alphaRepl) parts.push(`<a:alphaRepl a="${opts.alphaRepl.amount}"/>`);
8057
- if (opts.alphaBiLevel) parts.push(`<a:alphaBiLevel thresh="${opts.alphaBiLevel.threshold}"/>`);
8058
- if (opts.colorChange) {
8059
- const fromXml = stringify$1(solidFillDesc, opts.colorChange.from, ctx);
8060
- const toXml = stringify$1(solidFillDesc, opts.colorChange.to, ctx);
8061
- const attrParts = [];
8062
- if (opts.colorChange.useAlpha === false) attrParts.push("useA=\"0\"");
8063
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8064
- parts.push(`<a:clrChange${attrStr}><a:clrFrom>${fromXml ?? ""}</a:clrFrom><a:clrTo>${toXml ?? ""}</a:clrTo></a:clrChange>`);
8065
- }
8066
- if (opts.colorRepl) {
8067
- const colorXml = stringify$1(solidFillDesc, opts.colorRepl.color, ctx);
8068
- parts.push(`<a:clrRepl>${colorXml ?? ""}</a:clrRepl>`);
8069
- }
8070
- if (opts.blur) {
8071
- const attrParts = [];
8072
- if (opts.blur.radius !== void 0) attrParts.push(`rad="${opts.blur.radius}"`);
8073
- if (opts.blur.grow === false) attrParts.push("grow=\"0\"");
8074
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8075
- parts.push(`<a:blur${attrStr}/>`);
8076
- }
8077
- return parts.join("");
8136
+ //#endregion
8137
+ //#region src/drawingml/three-d/three-d-descriptors.ts
8138
+ /**
8139
+ * 3D descriptor for DrawingML shapes.
8140
+ *
8141
+ * @module
8142
+ */
8143
+ function stringifySphereCoords(coords) {
8144
+ return `<a:rot lat="${coords.lat}" lon="${coords.lon}" rev="${coords.rev}"/>`;
8078
8145
  }
8079
- function readBlipEffects(el, ctx) {
8080
- const result = {};
8081
- if (findChild(el, "a:grayscl")) result.grayscale = true;
8082
- const lum = findChild(el, "a:lum");
8083
- if (lum) {
8084
- const opts = {};
8085
- if (lum.attributes?.["bright"] !== void 0) opts.bright = Number(String(lum.attributes["bright"]).replace("%", ""));
8086
- if (lum.attributes?.["contrast"] !== void 0) opts.contrast = Number(String(lum.attributes["contrast"]).replace("%", ""));
8087
- result.luminance = opts;
8088
- }
8089
- const hsl = findChild(el, "a:hsl");
8090
- if (hsl) {
8091
- const opts = {};
8092
- if (hsl.attributes?.["hue"] !== void 0) opts.hue = Number(hsl.attributes["hue"]);
8093
- if (hsl.attributes?.["sat"] !== void 0) opts.saturation = Number(String(hsl.attributes["sat"]).replace("%", ""));
8094
- if (hsl.attributes?.["lum"] !== void 0) opts.luminance = Number(String(hsl.attributes["lum"]).replace("%", ""));
8095
- result.hsl = opts;
8096
- }
8097
- const tint = findChild(el, "a:tint");
8098
- if (tint) {
8099
- const opts = {};
8100
- if (tint.attributes?.["hue"] !== void 0) opts.hue = Number(tint.attributes["hue"]);
8101
- if (tint.attributes?.["amt"] !== void 0) opts.amount = Number(String(tint.attributes["amt"]).replace("%", ""));
8102
- result.tint = opts;
8103
- }
8104
- const biLevel = findChild(el, "a:biLevel");
8105
- if (biLevel?.attributes?.["thresh"] !== void 0) result.biLevel = { threshold: Number(String(biLevel.attributes["thresh"]).replace("%", "")) };
8106
- if (findChild(el, "a:alphaCeiling")) result.alphaCeiling = true;
8107
- if (findChild(el, "a:alphaFloor")) result.alphaFloor = true;
8108
- const alphaInv = findChild(el, "a:alphaInv");
8109
- if (alphaInv) {
8110
- const solidFill = findChild(alphaInv, "a:solidFill");
8111
- if (solidFill) result.alphaInverse = parse$1(solidFillDesc, solidFill, ctx);
8112
- else result.alphaInverse = {};
8113
- }
8114
- const alphaModFix = findChild(el, "a:alphaModFix");
8115
- if (alphaModFix) {
8116
- const opts = {};
8117
- if (alphaModFix.attributes?.["amt"] !== void 0) opts.amount = Number(String(alphaModFix.attributes["amt"]).replace("%", ""));
8118
- result.alphaModFix = opts;
8146
+ function readSphereCoords(el) {
8147
+ const lat = el.attributes?.["lat"];
8148
+ const lon = el.attributes?.["lon"];
8149
+ const rev = el.attributes?.["rev"];
8150
+ if (lat === void 0 || lon === void 0 || rev === void 0) return void 0;
8151
+ return {
8152
+ lat: Number(lat),
8153
+ lon: Number(lon),
8154
+ rev: Number(rev)
8155
+ };
8156
+ }
8157
+ const bevelDesc = {
8158
+ kind: "custom",
8159
+ stringify(opts, _ctx) {
8160
+ const attrParts = [];
8161
+ if (opts.w !== void 0) attrParts.push(`w="${opts.w}"`);
8162
+ if (opts.h !== void 0) attrParts.push(`h="${opts.h}"`);
8163
+ if (opts.prst !== void 0) attrParts.push(`prst="${escapeXml(opts.prst)}"`);
8164
+ return `<a:bevel${attrParts.length ? " " + attrParts.join(" ") : ""}/>`;
8165
+ },
8166
+ parse(el, _ctx) {
8167
+ const result = {};
8168
+ if (el.attributes?.["w"] !== void 0) result.w = Number(el.attributes["w"]);
8169
+ if (el.attributes?.["h"] !== void 0) result.h = Number(el.attributes["h"]);
8170
+ if (el.attributes?.["prst"] !== void 0) result.prst = String(el.attributes["prst"]);
8171
+ return result;
8119
8172
  }
8120
- const alphaRepl = findChild(el, "a:alphaRepl");
8121
- if (alphaRepl?.attributes?.["a"] !== void 0) result.alphaRepl = { amount: Number(String(alphaRepl.attributes["a"]).replace("%", "")) };
8122
- const alphaBiLevel = findChild(el, "a:alphaBiLevel");
8123
- if (alphaBiLevel?.attributes?.["thresh"] !== void 0) result.alphaBiLevel = { threshold: Number(String(alphaBiLevel.attributes["thresh"]).replace("%", "")) };
8124
- const clrChange = findChild(el, "a:clrChange");
8125
- if (clrChange) {
8126
- const opts = {};
8127
- if (clrChange.attributes?.["useA"] !== void 0) opts.useAlpha = clrChange.attributes["useA"] !== "0";
8128
- const clrFrom = findChild(clrChange, "a:clrFrom");
8129
- if (clrFrom) {
8130
- const fromFill = findChild(clrFrom, "a:solidFill");
8131
- if (fromFill) opts.from = parse$1(solidFillDesc, fromFill, ctx);
8173
+ };
8174
+ const shape3DDesc = {
8175
+ kind: "custom",
8176
+ stringify(opts, ctx) {
8177
+ const parts = [];
8178
+ if (opts.bevelT) {
8179
+ const bevelXml = stringify$1(bevelDesc, opts.bevelT, ctx);
8180
+ if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelT"));
8132
8181
  }
8133
- const clrTo = findChild(clrChange, "a:clrTo");
8134
- if (clrTo) {
8135
- const toFill = findChild(clrTo, "a:solidFill");
8136
- if (toFill) opts.to = parse$1(solidFillDesc, toFill, ctx);
8182
+ if (opts.bevelB) {
8183
+ const bevelXml = stringify$1(bevelDesc, opts.bevelB, ctx);
8184
+ if (bevelXml) parts.push(bevelXml.replace("<a:bevel", "<a:bevelB"));
8137
8185
  }
8138
- result.colorChange = opts;
8139
- }
8140
- const clrRepl = findChild(el, "a:clrRepl");
8141
- if (clrRepl) {
8142
- const solidFill = findChild(clrRepl, "a:solidFill");
8143
- if (solidFill) result.colorRepl = { color: parse$1(solidFillDesc, solidFill, ctx) };
8144
- }
8145
- const blur = findChild(el, "a:blur");
8146
- if (blur) {
8147
- const opts = {};
8148
- if (blur.attributes?.["rad"] !== void 0) opts.radius = Number(blur.attributes["rad"]);
8149
- if (blur.attributes?.["grow"] !== void 0) opts.grow = blur.attributes["grow"] !== "0";
8150
- result.blur = opts;
8151
- }
8152
- const duotone = findChild(el, "a:duotone");
8153
- if (duotone?.elements) {
8154
- const fills = [];
8155
- for (const child of duotone.elements) {
8156
- const sf = findChild(child, "a:solidFill");
8157
- if (sf) fills.push(parse$1(solidFillDesc, sf, ctx));
8186
+ if (opts.extrusionColor) {
8187
+ const colorXml = stringify$1(solidFillDesc, opts.extrusionColor, ctx);
8188
+ if (colorXml) parts.push(`<a:extrusionClr>${colorXml}</a:extrusionClr>`);
8158
8189
  }
8159
- if (fills.length >= 2) result.duotone = {
8160
- color1: fills[0],
8161
- color2: fills[1]
8162
- };
8190
+ if (opts.contourColor) {
8191
+ const colorXml = stringify$1(solidFillDesc, opts.contourColor, ctx);
8192
+ if (colorXml) parts.push(`<a:contourClr>${colorXml}</a:contourClr>`);
8193
+ }
8194
+ const attrParts = [];
8195
+ if (opts.z !== void 0) attrParts.push(`z="${opts.z}"`);
8196
+ if (opts.extrusionH !== void 0) attrParts.push(`extrusionH="${opts.extrusionH}"`);
8197
+ if (opts.contourW !== void 0) attrParts.push(`contourW="${opts.contourW}"`);
8198
+ if (opts.prstMaterial !== void 0) attrParts.push(`prstMaterial="${escapeXml(xsdMaterialType.to(opts.prstMaterial))}"`);
8199
+ const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8200
+ const content = parts.join("");
8201
+ if (!attrStr && !content) return void 0;
8202
+ if (!content) return `<a:sp3d${attrStr}/>`;
8203
+ return `<a:sp3d${attrStr}>${content}</a:sp3d>`;
8204
+ },
8205
+ parse(el, ctx) {
8206
+ const result = {};
8207
+ if (el.attributes?.["z"] !== void 0) result.z = Number(el.attributes["z"]);
8208
+ if (el.attributes?.["extrusionH"] !== void 0) result.extrusionH = Number(el.attributes["extrusionH"]);
8209
+ if (el.attributes?.["contourW"] !== void 0) result.contourW = Number(el.attributes["contourW"]);
8210
+ if (el.attributes?.["prstMaterial"] !== void 0) result.prstMaterial = xsdMaterialType.from(String(el.attributes["prstMaterial"]));
8211
+ const bevelT = findChild(el, "a:bevelT");
8212
+ if (bevelT) result.bevelT = parse$1(bevelDesc, bevelT, ctx);
8213
+ const bevelB = findChild(el, "a:bevelB");
8214
+ if (bevelB) result.bevelB = parse$1(bevelDesc, bevelB, ctx);
8215
+ const extrusionClr = findChild(el, "a:extrusionClr");
8216
+ if (extrusionClr) {
8217
+ const solidFill = findChild(extrusionClr, "a:solidFill");
8218
+ if (solidFill) result.extrusionColor = parse$1(solidFillDesc, solidFill, ctx);
8219
+ }
8220
+ const contourClr = findChild(el, "a:contourClr");
8221
+ if (contourClr) {
8222
+ const solidFill = findChild(contourClr, "a:solidFill");
8223
+ if (solidFill) result.contourColor = parse$1(solidFillDesc, solidFill, ctx);
8224
+ }
8225
+ return result;
8163
8226
  }
8164
- return Object.keys(result).length > 0 ? result : void 0;
8165
- }
8166
- const blipDesc = {
8227
+ };
8228
+ const cameraDesc = {
8167
8229
  kind: "custom",
8168
- stringify(opts, ctx) {
8230
+ stringify(opts, _ctx) {
8169
8231
  const attrParts = [];
8170
- const embedValue = `{${opts.referenceId}}`;
8171
- attrParts.push(`r:embed="${escapeXml(embedValue)}"`);
8172
- attrParts.push("cstate=\"none\"");
8232
+ attrParts.push(`prst="${escapeXml(opts.preset)}"`);
8233
+ if (opts.fov !== void 0) attrParts.push(`fov="${opts.fov}"`);
8234
+ if (opts.zoom !== void 0) attrParts.push(`zoom="${escapeXml(opts.zoom)}"`);
8173
8235
  const attrStr = " " + attrParts.join(" ");
8174
8236
  const parts = [];
8175
- if (opts.blipEffects) parts.push(stringifyBlipEffects(opts.blipEffects, ctx));
8237
+ if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
8176
8238
  const content = parts.join("");
8177
- if (!content) return `<a:blip${attrStr}/>`;
8178
- return `<a:blip${attrStr}>${content}</a:blip>`;
8239
+ if (!content) return `<a:camera${attrStr}/>`;
8240
+ return `<a:camera${attrStr}>${content}</a:camera>`;
8179
8241
  },
8180
- parse(el, ctx) {
8242
+ parse(el, _ctx) {
8181
8243
  const result = {};
8182
- const embed = el.attributes?.["r:embed"];
8183
- if (embed !== void 0) result.referenceId = String(embed).replace(/^\{(.+)\}$/, "$1");
8184
- const link = el.attributes?.["r:link"];
8185
- if (link !== void 0) result.referenceId = String(link).replace(/^\{(.+)\}$/, "$1");
8186
- const effects = readBlipEffects(el, ctx);
8187
- if (effects) result.blipEffects = effects;
8244
+ if (el.attributes?.["prst"] !== void 0) result.preset = String(el.attributes["prst"]);
8245
+ if (el.attributes?.["fov"] !== void 0) result.fov = Number(el.attributes["fov"]);
8246
+ if (el.attributes?.["zoom"] !== void 0) result.zoom = String(el.attributes["zoom"]);
8247
+ const rot = findChild(el, "a:rot");
8248
+ if (rot) result.rotation = readSphereCoords(rot);
8188
8249
  return result;
8189
8250
  }
8190
8251
  };
8191
- const blipFillDesc = {
8252
+ const lightRigDesc = {
8192
8253
  kind: "custom",
8193
- stringify(opts, ctx) {
8254
+ stringify(opts, _ctx) {
8194
8255
  const attrParts = [];
8195
- if (opts.dpi !== void 0) attrParts.push(`dpi="${opts.dpi}"`);
8196
- if (opts.rotWithShape !== void 0) attrParts.push(`rotWithShape="${opts.rotWithShape ? 1 : 0}"`);
8197
- const attrStr = attrParts.length ? " " + attrParts.join(" ") : "";
8256
+ attrParts.push(`rig="${escapeXml(opts.rig)}"`);
8257
+ attrParts.push(`dir="${escapeXml(opts.direction)}"`);
8258
+ const attrStr = " " + attrParts.join(" ");
8198
8259
  const parts = [];
8199
- if (opts.referenceId) {
8200
- const blipXml = stringify$1(blipDesc, {
8201
- referenceId: opts.referenceId,
8202
- blipEffects: opts.blipEffects
8203
- }, ctx);
8204
- if (blipXml) parts.push(blipXml);
8205
- }
8206
- if (opts.sourceRectangle) {
8207
- const srcRectXml = stringify$1(sourceRectangleDesc, opts.sourceRectangle, ctx);
8208
- if (srcRectXml) parts.push(srcRectXml);
8209
- }
8210
- if (opts.tile) {
8211
- const tileXml = stringify$1(tileDesc, opts.tile, ctx);
8212
- if (tileXml) parts.push(tileXml);
8213
- } else parts.push("<a:stretch><a:fillRect/></a:stretch>");
8260
+ if (opts.rotation) parts.push(stringifySphereCoords(opts.rotation));
8214
8261
  const content = parts.join("");
8215
- if (!attrStr && !content) return void 0;
8216
- if (!content) return `<pic:blipFill${attrStr}/>`;
8217
- return `<pic:blipFill${attrStr}>${content}</pic:blipFill>`;
8262
+ if (!content) return `<a:lightRig${attrStr}/>`;
8263
+ return `<a:lightRig${attrStr}>${content}</a:lightRig>`;
8264
+ },
8265
+ parse(el, _ctx) {
8266
+ const result = {};
8267
+ if (el.attributes?.["rig"] !== void 0) result.rig = String(el.attributes["rig"]);
8268
+ if (el.attributes?.["dir"] !== void 0) result.direction = String(el.attributes["dir"]);
8269
+ const rot = findChild(el, "a:rot");
8270
+ if (rot) result.rotation = readSphereCoords(rot);
8271
+ return result;
8272
+ }
8273
+ };
8274
+ const scene3DDesc = {
8275
+ kind: "custom",
8276
+ stringify(opts, ctx) {
8277
+ const parts = [];
8278
+ const cameraXml = stringify$1(cameraDesc, opts.camera, ctx);
8279
+ if (cameraXml) parts.push(cameraXml);
8280
+ const lightRigXml = stringify$1(lightRigDesc, opts.lightRig, ctx);
8281
+ if (lightRigXml) parts.push(lightRigXml);
8282
+ if (opts.backdrop) parts.push(stringifyBackdrop(opts.backdrop));
8283
+ const content = parts.join("");
8284
+ if (!content) return void 0;
8285
+ return `<a:scene3d>${content}</a:scene3d>`;
8218
8286
  },
8219
8287
  parse(el, ctx) {
8220
8288
  const result = {};
8221
- if (el.attributes?.["dpi"] !== void 0) result.dpi = Number(el.attributes["dpi"]);
8222
- if (el.attributes?.["rotWithShape"] !== void 0) result.rotWithShape = el.attributes["rotWithShape"] !== "0";
8223
- const blip = findChild(el, "a:blip");
8224
- if (blip) {
8225
- const blipResult = parse$1(blipDesc, blip, ctx);
8226
- if (blipResult.referenceId) result.referenceId = blipResult.referenceId;
8227
- if (blipResult.blipEffects) result.blipEffects = blipResult.blipEffects;
8228
- }
8229
- const srcRect = findChild(el, "a:srcRect");
8230
- if (srcRect) result.sourceRectangle = parse$1(sourceRectangleDesc, srcRect, ctx);
8231
- const tile = findChild(el, "a:tile");
8232
- if (tile) result.tile = parse$1(tileDesc, tile, ctx);
8289
+ const camera = findChild(el, "a:camera");
8290
+ if (camera) result.camera = parse$1(cameraDesc, camera, ctx);
8291
+ const lightRig = findChild(el, "a:lightRig");
8292
+ if (lightRig) result.lightRig = parse$1(lightRigDesc, lightRig, ctx);
8293
+ const backdrop = findChild(el, "a:backdrop");
8294
+ if (backdrop) result.backdrop = readBackdrop(backdrop);
8233
8295
  return result;
8234
8296
  }
8235
8297
  };
8298
+ function stringifyPoint3D(name, point) {
8299
+ return `<${name} x="${point.x}" y="${point.y}" z="${point.z}"/>`;
8300
+ }
8301
+ function stringifyVector3D(name, vector) {
8302
+ return `<${name} dx="${vector.dx}" dy="${vector.dy}" dz="${vector.dz}"/>`;
8303
+ }
8304
+ function stringifyBackdrop(opts) {
8305
+ return `<a:backdrop>${stringifyPoint3D("a:anchor", opts.anchor) + stringifyVector3D("a:norm", opts.normal) + stringifyVector3D("a:up", opts.up)}</a:backdrop>`;
8306
+ }
8307
+ function readPoint3D(el) {
8308
+ const x = el.attributes?.["x"];
8309
+ const y = el.attributes?.["y"];
8310
+ const z = el.attributes?.["z"];
8311
+ if (x === void 0 || y === void 0 || z === void 0) return void 0;
8312
+ return {
8313
+ x: Number(x),
8314
+ y: Number(y),
8315
+ z: Number(z)
8316
+ };
8317
+ }
8318
+ function readVector3D(el) {
8319
+ const dx = el.attributes?.["dx"];
8320
+ const dy = el.attributes?.["dy"];
8321
+ const dz = el.attributes?.["dz"];
8322
+ if (dx === void 0 || dy === void 0 || dz === void 0) return void 0;
8323
+ return {
8324
+ dx: Number(dx),
8325
+ dy: Number(dy),
8326
+ dz: Number(dz)
8327
+ };
8328
+ }
8329
+ function readBackdrop(el) {
8330
+ const anchor = findChild(el, "a:anchor");
8331
+ const norm = findChild(el, "a:norm");
8332
+ const up = findChild(el, "a:up");
8333
+ if (!anchor || !norm || !up) return void 0;
8334
+ const anchorPt = readPoint3D(anchor);
8335
+ const normVec = readVector3D(norm);
8336
+ const upVec = readVector3D(up);
8337
+ if (!anchorPt || !normVec || !upVec) return void 0;
8338
+ return {
8339
+ anchor: anchorPt,
8340
+ normal: normVec,
8341
+ up: upVec
8342
+ };
8343
+ }
8236
8344
  //#endregion
8237
8345
  //#region src/drawingml/diagram/diagram-descriptors.ts
8238
8346
  /**
@@ -8590,4 +8698,4 @@ function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
8590
8698
  return replacePlaceholders(xml, map);
8591
8699
  }
8592
8700
  //#endregion
8593
- export { solidFillDesc as $, createTileInfo as $n, unzipSync$1 as $r, convertToTwip as $t, bevelDesc as A, createFillOverlayEffect as An, SchemeColor as Ar, createHierBranch as At, shapeLockingDesc as B, createLineEnd as Bn, PART_REGISTRIES as Br, createTableStyleList as Bt, diagramStyleDesc as C, PresetShadowVal as Cn, uniqueUuid as Cr, AnimateOneByOneValue as Ct, sourceRectangleDesc as D, createInnerShadowEffect as Dn, createSolidFill as Dr, createAdjustList as Dt, blipFillDesc as E, createOuterShadowEffect as En, createColorElement as Er, createAdjust as Et, customGeometryDesc as F, PresetDash as Fn, createPresetColor as Fr, createGraphicFrameLocking as Ft, patternFillDesc as G, extractBlipFillMedia as Gn, ParsedArchive as Gr, convertEmuToPoints as Gt, outlineDesc as H, createGroupFill as Hn, XLSX_PARTS as Hr, createTransformation as Ht, presetGeometryDesc as I, createOutline as In, createHslColor as Ir, createGroupLocking as It, parseColorChoice as J, PathShadeType as Jn, ZIP_STORED_LEVEL as Jr, convertMillimetersToTwip as Jt, getColorDescriptor as K, PresetPattern as Kn, parseArchive as Kr, convertInchesToEmu as Kt, graphicFrameLockingDesc as L, LineEndLength as Ln, createColorTransforms as Lr, createPictureLocking as Lt, shape3DDesc as M, LineCap as Mn, createScRgbColor as Mr, createOrgChart as Mt, groupTransform2DDesc as N, LineJoin as Nn, createRgbColor as Nr, createPreferredChildren as Nt, stretchDesc as O, createGlowEffect as On, SystemColor as Or, createAnimateOneByOne as Ot, transform2DDesc as P, PenAlignment as Pn, PresetColor as Pr, createPresentationLayoutVariables as Pt, schemeColorDesc as Q, TileAlignment as Qn, strFromU8$1 as Qr, convertToEmu as Qt, groupLockingDesc as R, LineEndType as Rn, buildContentTypeOverrides as Rr, createShapeLocking as Rt, diagramRelationshipIdsDesc as S, createReflectionEffect as Sn, uniqueNumericIdCreator as Sr, createStyleDefinitionHeaderList as St, blipDesc as T, RectAlignment as Tn, toUint8Array as Tr, HierBranchStyle as Tt, fillDesc as U, createNoFill as Un, summarizeOpcIssues as Ur, convertEmuToInches as Ut, effectListDesc as V, createCustomDash as Vn, PPTX_PARTS as Vr, parseTableStyleList as Vt, gradientFillDesc as W, buildFill as Wn, validateOpcConsistency as Wr, convertEmuToPixels as Wt, rgbColorDesc as X, createGradientFill as Xn, createZipStream as Xr, convertPointsToEmu as Xt, presetColorDesc as Y, TileFlipMode as Yn, createPacker as Yr, convertPixelsToEmu as Yt, scRgbColorDesc as Z, createGradientStop as Zn, levelForMediaName as Zr, convertPositionToEmu as Zt, derivePasswordHash as _, createScene3D as _n, xsdVerticalMergeRev as _r, createColorsDefinitionHeader as _t, getMediaRefs as a, encodeBase64 as ai, stringifyStretch as an, xsdLineEndSize as ar, ColorMethod as at, compileMapping as b, createEffectList as bn, hashedId as br, createLayoutDefinitionHeaderList as bt, hasPlaceholders as c, createDefault as ci, createExtentionList as cn, xsdPattern as cr, StyleMatrixIndex as ct, replaceHyperlinkPlaceholders as d, TargetModeType as di, stringifyAdjustmentValues as dn, xsdRectAlignment as dr, createFillColorList as dt, zipAndConvert as ei, convertUniversalMeasureToEmu as en, invertMap as er, systemColorDesc as et, replaceImagePlaceholders as f, PresetMaterialType as fn, xsdStrikeStyle as fr, createLineColorList as ft, replaceVideoPlaceholders as g, createBottomBevel as gn, xsdUnderlineStyle as gr, createTextLineColorList as gt, replaceSmartArtPlaceholders as h, createBevel as hn, xsdTextCaps as hr, createTextFillColorList as ht, formatId as i, decodeBase64 as ii, createTransform2D as in, xsdLineCap as ir, createDiagramRelationshipIds as it, scene3DDesc as j, CompoundLine as jn, createSchemeColor as jr, createMaxChildren as jt, tileDesc as k, BlendMode as kn, createSystemColor as kr, createAnimationLevel as kt, replaceAllPlaceholders as l, createOverride as li, createCustomGeometry as ln, xsdPenAlignment as lr, createDiagramStyle as lt, replaceNumberingPlaceholders as m, BevelPresetType as mn, xsdTextAnchor as mr, createTextEffectColorList as mt, collectPlaceholderKeys as n, OoxmlMimeType as ni, parseUniversalMeasure as nn, xsdCompoundLine as nr, createDiagramShape3D as nt, getReferencedMedia as o, customPropertiesDesc as oi, createBlipFill as on, xsdMaterialType as or, FontCollectionIndex as ot, replaceMediaPlaceholders as p, createShape3D as pn, xsdTextAlign as pr, createStyleLabel as pt, hslColorDesc as q, createPatternFill as qn, ZIP_DEFLATE_LEVEL as qr, convertInchesToTwip as qt, findAndReplaceImagePlaceholders as r, convertOutput as ri, createGroupTransform2D as rn, xsdEffectContainer as rr, createDiagramTextProperties as rt, getVideoRefs as s, appPropertiesDesc as si, createBlip as sn, xsdPathFillMode as sr, HueDirection as st, addSmartArtRelationships as t, zipSyncAndConvert as ti, convertUniversalMeasureToTwip as tn, xsdBlendMode as tr, createDiagramExtensionList as tt, replaceChartPlaceholders as u, Relationships as ui, stringifyPresetGeometry as un, xsdPresetShadow as ur, createEffectColorList as ut, hashPasswordAgile as v, createEffectDag as vn, createSourceRectangle as vr, createColorsDefinitionHeaderList as vt, presentationLayoutVariablesDesc as w, createPresetShadowEffect as wn, isBase64DataURL as wr, AnimationLevelValue as wt, diagramExtensionListDesc as x, createSoftEdgeEffect as xn, uniqueId as xr, createStyleDefinitionHeader as xt, randomBytes as y, calculateEffectExtent as yn, createBlipEffects as yr, createLayoutDefinitionHeader as yt, pictureLockingDesc as z, LineEndWidth as zn, DOCX_PARTS as zr, createTableStyle as zt };
8701
+ export { convertUniversalMeasureToTwip as $, createGradientStop as $n, levelForMediaName as $r, createGroupLocking as $t, customGeometryDesc as A, createGlowEffect as An, SystemColor as Ar, createStyleLabel as At, convertEmuToPoints as B, LineEndType as Bn, buildContentTypeOverrides as Br, AnimateOneByOneValue as Bt, diagramStyleDesc as C, createSoftEdgeEffect as Cn, uniqueId as Cr, FontCollectionIndex as Ct, shape3DDesc as D, RectAlignment as Dn, toUint8Array as Dr, createEffectColorList as Dt, scene3DDesc as E, createPresetShadowEffect as En, isBase64DataURL as Er, createDiagramStyle as Et, shapeLockingDesc as F, LineJoin as Fn, createRgbColor as Fr, createColorsDefinitionHeaderList as Ft, convertPointsToEmu as G, createNoFill as Gn, summarizeOpcIssues as Gr, createAnimateOneByOne as Gt, convertInchesToTwip as H, createLineEnd as Hn, PART_REGISTRIES as Hr, HierBranchStyle as Ht, effectListDesc as I, PenAlignment as In, PresetColor as Ir, createLayoutDefinitionHeader as It, convertToPt as J, PresetPattern as Jn, parseArchive as Jr, createMaxChildren as Jt, convertToEmu as K, buildFill as Kn, validateOpcConsistency as Kr, createAnimationLevel as Kt, outlineDesc as L, PresetDash as Ln, createPresetColor as Lr, createLayoutDefinitionHeaderList as Lt, graphicFrameLockingDesc as M, createFillOverlayEffect as Mn, SchemeColor as Mr, createTextFillColorList as Mt, groupLockingDesc as N, CompoundLine as Nn, createSchemeColor as Nr, createTextLineColorList as Nt, groupTransform2DDesc as O, createOuterShadowEffect as On, createColorElement as Or, createFillColorList as Ot, pictureLockingDesc as P, LineCap as Pn, createScRgbColor as Pr, createColorsDefinitionHeader as Pt, convertUniversalMeasureToPt as Q, createGradientFill as Qn, createZipStream as Qr, createGraphicFrameLocking as Qt, convertEmuToInches as R, createOutline as Rn, createHslColor as Rr, createStyleDefinitionHeader as Rt, diagramRelationshipIdsDesc as S, createEffectList as Sn, hashedId as Sr, ColorMethod as St, bevelDesc as T, PresetShadowVal as Tn, uniqueUuid as Tr, StyleMatrixIndex as Tt, convertMillimetersToTwip as U, createCustomDash as Un, PPTX_PARTS as Ur, createAdjust as Ut, convertInchesToEmu as V, LineEndWidth as Vn, DOCX_PARTS as Vr, AnimationLevelValue as Vt, convertPixelsToEmu as W, createGroupFill as Wn, XLSX_PARTS as Wr, createAdjustList as Wt, convertUniversalMeasureToEmu as X, PathShadeType as Xn, ZIP_STORED_LEVEL as Xr, createPreferredChildren as Xt, convertToTwip as Y, createPatternFill as Yn, ZIP_DEFLATE_LEVEL as Yr, createOrgChart as Yt, convertUniversalMeasureToInch as Z, TileFlipMode as Zn, createPacker as Zr, createPresentationLayoutVariables as Zt, derivePasswordHash as _, createBevel as _n, xsdTextCaps as _r, systemColorDesc as _t, getMediaRefs as a, convertOutput as ai, createGroupTransform2D as an, xsdEffectContainer as ar, blipFillDesc as at, compileMapping as b, createEffectDag as bn, createSourceRectangle as br, createDiagramTextProperties as bt, hasPlaceholders as c, customPropertiesDesc as ci, createBlipFill as cn, xsdMaterialType as cr, tileDesc as ct, replaceHyperlinkPlaceholders as d, createOverride as di, createCustomGeometry as dn, xsdPenAlignment as dr, presetColorDesc as dt, strFromU8$1 as ei, createPictureLocking as en, TileAlignment as er, parseUniversalMeasure as et, replaceImagePlaceholders as f, Media as fi, stringifyPresetGeometry as fn, xsdPresetShadow as fr, rgbColorDesc as ft, replaceVideoPlaceholders as g, BevelPresetType as gn, xsdTextAnchor as gr, stringifyColorChoice as gt, replaceSmartArtPlaceholders as h, optionalRelsPart as hi, createShape3D as hn, xsdTextAlign as hr, solidFillDesc as ht, formatId as i, OoxmlMimeType as ii, parseTableStyleList as in, xsdCompoundLine as ir, blipDesc as it, presetGeometryDesc as j, BlendMode as jn, createSystemColor as jr, createTextEffectColorList as jt, transform2DDesc as k, createInnerShadowEffect as kn, createSolidFill as kr, createLineColorList as kt, replaceAllPlaceholders as l, appPropertiesDesc as li, createBlip as ln, xsdPathFillMode as lr, hslColorDesc as lt, replaceNumberingPlaceholders as m, TargetModeType as mi, PresetMaterialType as mn, xsdStrikeStyle as mr, schemeColorDesc as mt, collectPlaceholderKeys as n, zipAndConvert as ni, createTableStyle as nn, invertMap as nr, gradientFillDesc as nt, getReferencedMedia as o, decodeBase64 as oi, createTransform2D as on, xsdLineCap as or, sourceRectangleDesc as ot, replaceMediaPlaceholders as p, Relationships as pi, stringifyAdjustmentValues as pn, xsdRectAlignment as pr, scRgbColorDesc as pt, convertToInch as q, extractBlipFillMedia as qn, ParsedArchive as qr, createHierBranch as qt, findAndReplaceImagePlaceholders as r, zipSyncAndConvert as ri, createTableStyleList as rn, xsdBlendMode as rr, patternFillDesc as rt, getVideoRefs as s, encodeBase64 as si, stringifyStretch as sn, xsdLineEndSize as sr, stretchDesc as st, addSmartArtRelationships as t, unzipSync$1 as ti, createShapeLocking as tn, createTileInfo as tr, fillDesc as tt, replaceChartPlaceholders as u, createDefault as ui, createExtentionList as un, xsdPattern as ur, parseColorChoice as ut, hashPasswordAgile as v, createBottomBevel as vn, xsdUnderlineStyle as vr, createDiagramExtensionList as vt, presentationLayoutVariablesDesc as w, createReflectionEffect as wn, uniqueNumericIdCreator as wr, HueDirection as wt, diagramExtensionListDesc as x, calculateEffectExtent as xn, createBlipEffects as xr, createDiagramRelationshipIds as xt, randomBytes as y, createScene3D as yn, xsdVerticalMergeRev as yr, createDiagramShape3D as yt, convertEmuToPixels as z, LineEndLength as zn, createColorTransforms as zr, createStyleDefinitionHeaderList as zt };