pptxgenjs-plus 4.3.9 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /* PptxGenJS 4.3.9 @ 2026-12-01T20:34:30.120Z */
1
+ /* PptxGenJS 4.4.0 @ 2026-12-05T02:10:07.387Z */
2
2
 
3
3
  "use strict";
4
4
  const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
@@ -1579,6 +1579,59 @@ const XML_ILLEGAL_CHARS = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]|
1579
1579
  const points = Number(pt) || 0;
1580
1580
  return isNaN(points) ? 0 : Math.round(points * (/* inlined export .ONEPT */12700));
1581
1581
  }
1582
+ /**
1583
+ * Round a value into an inclusive integer range.
1584
+ * Non-finite inputs (`NaN`, `Infinity`, `-Infinity`) fall back to `min`.
1585
+ * Prevents out-of-range OOXML attributes (`ST_TextFontSize`, `ST_LineWidth`, `ST_TextSpacing*`,
1586
+ * `ST_GapAmount`, ...) from triggering PowerPoint repair dialogs.
1587
+ * @param {number} val - value to clamp
1588
+ * @param {number} min - inclusive lower bound
1589
+ * @param {number} max - inclusive upper bound
1590
+ * @returns {number} clamped integer
1591
+ */ function clampInt(val, min, max) {
1592
+ if (!Number.isFinite(val)) return min === 0 ? 0 : min;
1593
+ const res = Math.round(Math.min(max, Math.max(min, val)));
1594
+ return res === 0 ? 0 : res;
1595
+ }
1596
+ /**
1597
+ * Clamp an EMU extent to `ST_PositiveCoordinate` (finite non-negative integer `>= 0`).
1598
+ * Zero is legal (e.g. hairline rules); negative or non-finite values clamp to 0.
1599
+ * @param {number} val - extent in EMU
1600
+ * @returns {number} non-negative integer EMU
1601
+ */ function positiveExtent(val) {
1602
+ if (!Number.isFinite(val) || val <= 0) return 0;
1603
+ return Math.round(val);
1604
+ }
1605
+ /**
1606
+ * Convert a font size in points into OOXML `ST_TextFontSize` hundredths of a point (`100..400000`, i.e. 1pt..4000pt).
1607
+ * @param {number} val - font size in points
1608
+ * @returns {number} clamped `sz` attribute value
1609
+ */ function fontSizeToSz(val) {
1610
+ return clampInt(val * 100, 100, 400000);
1611
+ }
1612
+ /**
1613
+ * Clamp an EMU line width to `ST_LineWidth` (`0..20116800`, i.e. 0..1584pt).
1614
+ * @param {number} val - line width in EMU
1615
+ * @returns {number} clamped `w` attribute value in EMU
1616
+ */ function clampLineWidth(val) {
1617
+ return clampInt(val, 0, 20116800);
1618
+ }
1619
+ /**
1620
+ * Convert a line width in points into an EMU `a:ln@w` value clamped to `ST_LineWidth` (`0..20116800`).
1621
+ * @param {number|string|undefined} pt - line width in points
1622
+ * @returns {number} clamped `w` attribute value in EMU
1623
+ */ function valToLineWidth(pt) {
1624
+ return clampLineWidth(valToPts(pt));
1625
+ }
1626
+ /**
1627
+ * Convert a 0..100 transparency percentage into an OOXML `a:alpha@val` (`ST_PositiveFixedPercentage`, `0..100000`).
1628
+ * Non-finite inputs default to opaque (`100000`).
1629
+ * @param {number} transparency - transparency percent (0 = opaque, 100 = fully transparent)
1630
+ * @returns {number} clamped `a:alpha@val` in `0..100000`
1631
+ */ function clampAlphaPct(transparency) {
1632
+ if (!Number.isFinite(transparency)) return 100000;
1633
+ return clampInt((100 - transparency) * 1000, 0, 100000);
1634
+ }
1582
1635
  /**
1583
1636
  * Convert a margin component to EMU (same dual-unit rule as table cells)
1584
1637
  * - `>= 1` → points (`valToPts`)
@@ -1858,9 +1911,9 @@ const FLAG_COLOR_MODIFIERS = [
1858
1911
  }
1859
1912
  function createGlowElement(glow) {
1860
1913
  let strXml = '';
1861
- const size = Math.round(glow.size * (/* inlined export .ONEPT */12700));
1914
+ const size = positiveExtent(Math.round(glow.size * (/* inlined export .ONEPT */12700)));
1862
1915
  const color = glow.color;
1863
- const opacity = Math.round(glow.opacity * 100000);
1916
+ const opacity = clampInt(glow.opacity * 100000, 0, 100000);
1864
1917
  strXml += `<a:glow rad="${size}">`;
1865
1918
  strXml += createColorElement(color, `<a:alpha val="${opacity}"/>`);
1866
1919
  strXml += '</a:glow>';
@@ -1913,7 +1966,7 @@ function createGlowElement(glow) {
1913
1966
  return soleColor ? `<a:solidFill>${createColorElement(soleColor, fallbackInner)}</a:solidFill>` : '';
1914
1967
  }
1915
1968
  const gsLst = stops.map((stop)=>{
1916
- const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, stop.transparency))) * 1000)}"/>` : '';
1969
+ const inner = typeof stop.transparency === 'number' ? `<a:alpha val="${clampAlphaPct(stop.transparency)}"/>` : '';
1917
1970
  return `<a:gs pos="${stop.pos}">${createColorElement(stop.color, inner)}</a:gs>`;
1918
1971
  }).join('');
1919
1972
  const rotateWithShape = (gradient === null || gradient === void 0 ? void 0 : gradient.rotateWithShape) === false || (gradient === null || gradient === void 0 ? void 0 : gradient.rotWithShape) === false ? 0 : 1;
@@ -1984,8 +2037,8 @@ function createGlowElement(glow) {
1984
2037
  if (props.type) fillType = props.type;
1985
2038
  else if (((_props_image = props.image) === null || _props_image === void 0 ? void 0 : _props_image._rId) || props._rId) fillType = 'image';
1986
2039
  if (props.color) colorVal = props.color;
1987
- if (props.alpha) internalElements += `<a:alpha val="${Math.round((100 - props.alpha) * 1000)}"/>`; // DEPRECATED: @deprecated v3.3.0
1988
- if (props.transparency) internalElements += `<a:alpha val="${Math.round((100 - props.transparency) * 1000)}"/>`;
2040
+ if (props.alpha) internalElements += `<a:alpha val="${clampAlphaPct(props.alpha)}"/>`; // DEPRECATED: @deprecated v3.3.0
2041
+ if (props.transparency) internalElements += `<a:alpha val="${clampAlphaPct(props.transparency)}"/>`;
1989
2042
  }
1990
2043
  const isBareColor = typeof props === 'string' || isModifiedThemeColor(props) || isColorProps(props);
1991
2044
  switch(fillType){
@@ -2938,190 +2991,650 @@ function gen_tables_object_spread(target) {
2938
2991
  });
2939
2992
  }
2940
2993
 
2941
- ;// CONCATENATED MODULE: ./src/xml/hyperlink.ts
2942
- /**
2943
- * Hyperlinks and mouse-over actions.
2944
- *
2945
- * DrawingML gives the same concept two element names depending on where it appears:
2946
- *
2947
- * | host | click | mouse-over |
2948
- * | :-- | :-- | :-- |
2949
- * | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
2950
- * | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
2951
- *
2952
- * Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
2953
- * PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
2954
- */
2955
- /**
2956
- * Build one `a:hlinkClick` / mouse-over element
2957
- * @param {HyperlinkProps} link - link props
2958
- * @param {'click' | 'hover'} trigger - which interaction this element describes
2959
- * @param {HyperlinkHost} host - the element the link is attached to
2960
- * @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
2961
- * @returns {string} XML string
2962
- */ function genXmlHyperlink(link, trigger, host, children = '') {
2963
- var _link__rId;
2964
- const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
2965
- let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
2966
- if (link.slide) {
2967
- // an internal jump has no URL; the action attribute names the target kind
2968
- attrs += ' action="ppaction://hlinksldjump"';
2969
- } else {
2970
- attrs += ' invalidUrl="" action="" tgtFrame=""';
2994
+ ;// CONCATENATED MODULE: ./src/gen-media.ts
2995
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2996
+ try {
2997
+ var info = gen[key](arg);
2998
+ var value = info.value;
2999
+ } catch (error) {
3000
+ reject(error);
3001
+ return;
2971
3002
  }
2972
- attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
2973
- if (!link.slide) attrs += ' history="1"';
2974
- // both default to false in the schema, so only write them when turned on
2975
- if (link.highlightClick === true) attrs += ' highlightClick="1"';
2976
- if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
2977
- const sound = genXmlHyperlinkSound(link);
2978
- const inner = sound + children;
2979
- return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
2980
- }
2981
- /**
2982
- * Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
2983
- * - the relationship is resolved when the object is created, so `_sndRId` is set by then
2984
- * @param {HyperlinkProps} link - link props
2985
- * @returns {string} XML string
2986
- */ function genXmlHyperlinkSound(link) {
2987
- var _link_sound_name;
2988
- var _link_sound;
2989
- if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
2990
- return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
3003
+ if (info.done) resolve(value);
3004
+ else Promise.resolve(value).then(_next, _throw);
2991
3005
  }
2992
-
2993
- ;// CONCATENATED MODULE: ./src/xml/line.ts
2994
- function line_define_property(obj, key, value) {
2995
- if (key in obj) {
2996
- Object.defineProperty(obj, key, {
2997
- value: value,
2998
- enumerable: true,
2999
- configurable: true,
3000
- writable: true
3006
+ function _async_to_generator(fn) {
3007
+ return function() {
3008
+ var self = this, args = arguments;
3009
+ return new Promise(function(resolve, reject) {
3010
+ var gen = fn.apply(self, args);
3011
+ function _next(value) {
3012
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
3013
+ }
3014
+ function _throw(err) {
3015
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
3016
+ }
3017
+ _next(undefined);
3001
3018
  });
3002
- } else obj[key] = value;
3003
- return obj;
3019
+ };
3004
3020
  }
3005
- function line_object_spread(target) {
3006
- for(var i = 1; i < arguments.length; i++){
3007
- var source = arguments[i] != null ? arguments[i] : {};
3008
- var ownKeys = Object.keys(source);
3009
- if (typeof Object.getOwnPropertySymbols === "function") {
3010
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3011
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3012
- }));
3021
+ /**
3022
+ * PptxGenJS: Media Methods
3023
+ */
3024
+
3025
+ /** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
3026
+ /**
3027
+ * Deck-scoped content-hash buckets keyed by `target._allocChartId` (shared across all slides,
3028
+ * layouts, and master in one `PptxGenJS` instance) so identical raster images share one OPC media
3029
+ * part across the entire deck without leaking across presentations.
3030
+ */ const deckImageBuckets = new WeakMap();
3031
+ function getDeckImageBuckets(target) {
3032
+ var _target__allocChartId;
3033
+ const deckKey = (_target__allocChartId = target._allocChartId) !== null && _target__allocChartId !== void 0 ? _target__allocChartId : target;
3034
+ let buckets = deckImageBuckets.get(deckKey);
3035
+ if (!buckets) {
3036
+ buckets = new Map();
3037
+ deckImageBuckets.set(deckKey, buckets);
3038
+ }
3039
+ return buckets;
3040
+ }
3041
+ function isDedupeImageRel(rel) {
3042
+ if (!rel || rel.isLinked || rel.isSvgPng) return false;
3043
+ if (typeof rel.data !== 'string' || !rel.data || rel.data === IMG_BROKEN) return false;
3044
+ const type = typeof rel.type === 'string' ? rel.type.toLowerCase() : '';
3045
+ const extn = typeof rel.extn === 'string' ? rel.extn.toLowerCase() : '';
3046
+ if (extn === 'svg' || type === 'image/svg+xml') return false;
3047
+ return type === 'image' || type.startsWith('image/');
3048
+ }
3049
+ function getRelDataBody(data) {
3050
+ const commaIdx = data.indexOf(',');
3051
+ return commaIdx >= 0 ? data.substring(commaIdx + 1) : data;
3052
+ }
3053
+ function fnv1aHash(str) {
3054
+ let hash = 2166136261;
3055
+ for(let idx = 0; idx < str.length; idx++){
3056
+ hash ^= str.charCodeAt(idx);
3057
+ hash = Math.imul(hash, 16777619);
3058
+ }
3059
+ return (hash >>> 0).toString(16);
3060
+ }
3061
+ /**
3062
+ * Deduplicate one raster image relationship against the deck-scoped content-hash table.
3063
+ * When an identical image payload already exists on any slide/layout in this presentation,
3064
+ * rewrites `rel.Target` to reuse the existing OPC media part and marks `rel.isDuplicate = true`
3065
+ * while keeping `rel.rId` and `rel.data` intact.
3066
+ */ function dedupeImageMediaRel(target, rel) {
3067
+ var _buckets_get;
3068
+ if (!isDedupeImageRel(rel)) return;
3069
+ const body = getRelDataBody(rel.data);
3070
+ if (!body) return;
3071
+ const normExtn = (rel.extn || 'png').toLowerCase() === 'jpg' ? 'jpeg' : (rel.extn || 'png').toLowerCase();
3072
+ const key = `${normExtn}|${body.length}|${fnv1aHash(body)}`;
3073
+ const buckets = getDeckImageBuckets(target);
3074
+ const bucket = (_buckets_get = buckets.get(key)) !== null && _buckets_get !== void 0 ? _buckets_get : [];
3075
+ const existing = bucket.find((entry)=>entry.data === body);
3076
+ if (existing) {
3077
+ if (existing.target !== rel.Target) {
3078
+ rel.isDuplicate = true;
3079
+ rel.Target = existing.target;
3013
3080
  }
3014
- ownKeys.forEach(function(key) {
3015
- line_define_property(target, key, source[key]);
3081
+ } else {
3082
+ bucket.push({
3083
+ data: body,
3084
+ target: rel.Target
3016
3085
  });
3086
+ buckets.set(key, bucket);
3017
3087
  }
3018
- return target;
3019
- }
3020
- function line_ownKeys(object, enumerableOnly) {
3021
- var keys = Object.keys(object);
3022
- if (Object.getOwnPropertySymbols) {
3023
- var symbols = Object.getOwnPropertySymbols(object);
3024
- if (enumerableOnly) {
3025
- symbols = symbols.filter(function(sym) {
3026
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3027
- });
3028
- }
3029
- keys.push.apply(keys, symbols);
3030
- }
3031
- return keys;
3032
3088
  }
3033
- function line_object_spread_props(target, source) {
3034
- source = source != null ? source : {};
3035
- if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3036
- else {
3037
- line_ownKeys(Object(source)).forEach(function(key) {
3038
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3039
- });
3040
- }
3041
- return target;
3089
+ /**
3090
+ * Deduplicate all resolved raster image relationships on a slide/layout deck-wide.
3091
+ * Runs after `encodeSlideMediaRels` resolves so path-loaded images are deduplicated too.
3092
+ */ function dedupeSlideMediaRels(layout) {
3093
+ var _layout__relsMedia;
3094
+ ;
3095
+ ((_layout__relsMedia = layout._relsMedia) !== null && _layout__relsMedia !== void 0 ? _layout__relsMedia : []).forEach((rel)=>dedupeImageMediaRel(layout, rel));
3042
3096
  }
3043
3097
  /**
3044
- * PptxGenJS: Line properties (`a:ln` and its aliases)
3098
+ * Read the natural pixel dimensions of a raster image from its header bytes.
3099
+ * Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
3100
+ * Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
3101
+ * JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
3102
+ * little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
3045
3103
  *
3046
- * The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
3047
- * (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
3048
- */
3049
-
3050
- /**
3051
- * Create a line element
3052
- * @param {ShapeLineProps} line - line options
3053
- * @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
3054
- * @return {string} XML
3055
- */ function genXmlLine(line, tag = 'a:ln') {
3056
- // ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, and `cmpd` attributes
3057
- const cap = line.cap && [
3058
- 'flat',
3059
- 'sq',
3060
- 'rnd'
3061
- ].includes(line.cap) ? ` cap="${line.cap}"` : '';
3062
- const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
3063
- if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
3064
- console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
3065
- ...COMPOUND_TYPES
3066
- ].join(', ')} - "${String(line.compound)}" ignored`);
3104
+ * Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
3105
+ * header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
3106
+ * 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
3107
+ */ const MAX_IMAGE_PX = 100000;
3108
+ function imageDimensions(bytes) {
3109
+ if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
3110
+ ;
3111
+ const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
3112
+ const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
3113
+ width: w,
3114
+ height: h
3115
+ } : {};
3116
+ // PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
3117
+ if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
3118
+ if (bytes.length < 24) return {};
3119
+ return sane(dv.getUint32(16, false), dv.getUint32(20, false));
3067
3120
  }
3068
- const attrs = (line.width ? ` w="${valToPts(line.width)}"` : '') + cap + compound;
3069
- let xml = `<${tag}${attrs}>`;
3070
- const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
3071
- if (line.type !== 'none' && (line.color || hasGrad)) {
3072
- xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
3073
- type: 'gradient'
3074
- }) : line);
3121
+ // GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
3122
+ if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
3123
+ return sane(dv.getUint16(6, true), dv.getUint16(8, true));
3075
3124
  }
3076
- // CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
3077
- // the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
3078
- xml += genXmlDash(line);
3079
- xml += genXmlJoin(line);
3080
- xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
3081
- xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
3082
- xml += `</${tag}>`;
3083
- return xml;
3084
- }
3085
- /** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
3086
- var _line_custDash;
3087
- const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
3088
- const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
3089
- if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
3090
- return ok;
3091
- });
3092
- if (stops.length > 0) {
3093
- const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
3094
- return `<a:custDash>${items}</a:custDash>`;
3125
+ // BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
3126
+ if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
3127
+ if (bytes.length < 26) return {};
3128
+ return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
3095
3129
  }
3096
- return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
3097
- }
3098
- /** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
3099
- if (!line.join) return '';
3100
- if (line.join === 'round') return '<a:round/>';
3101
- if (line.join === 'bevel') return '<a:bevel/>';
3102
- if (line.join === 'miter') {
3103
- const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
3104
- return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
3130
+ // JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
3131
+ if (bytes[0] === 0xff && bytes[1] === 0xd8) {
3132
+ let off = 2;
3133
+ while(off + 9 <= bytes.length){
3134
+ if (bytes[off] !== 0xff) {
3135
+ off++;
3136
+ continue;
3137
+ }
3138
+ const marker = bytes[off + 1];
3139
+ const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
3140
+ if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
3141
+ if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
3142
+ off += 2;
3143
+ continue;
3144
+ } // no length
3145
+ const segLen = dv.getUint16(off + 2, false);
3146
+ off += 2 + segLen;
3147
+ }
3105
3148
  }
3106
- console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
3107
- return '';
3108
- }
3109
- function resolveArrowSize(size) {
3110
- if (!size) return undefined;
3111
- if (typeof size === 'string') return {
3112
- width: size,
3113
- length: size
3114
- };
3115
- return size;
3116
- }
3117
- /** An arrow end with its optional sizing */ function genXmlArrow(tag, type, size) {
3118
- if (!type) return '';
3119
- const resolved = resolveArrowSize(size);
3120
- const w = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.width)) ? ` w="${String(resolved === null || resolved === void 0 ? void 0 : resolved.width)}"` : '';
3121
- const len = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.length)) ? ` len="${String(resolved === null || resolved === void 0 ? void 0 : resolved.length)}"` : '';
3122
- return `<${tag} type="${type}"${w}${len}/>`;
3149
+ return {};
3123
3150
  }
3124
-
3151
+ /**
3152
+ * Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
3153
+ * Returns null when the payload is missing, not a supported raster, or claims 0×0
3154
+ * (`imageDimensions` already rejects zero and bomb-sized headers).
3155
+ *
3156
+ * contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
3157
+ * placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
3158
+ */ function getImagePixelSize(base64Data) {
3159
+ if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
3160
+ try {
3161
+ const dims = imageDimensions(base64ToBytes(base64Data));
3162
+ if (dims.width && dims.height) return {
3163
+ w: dims.width,
3164
+ h: dims.height
3165
+ };
3166
+ } catch (unused) {
3167
+ // unrecognized / truncated payload
3168
+ }
3169
+ return null;
3170
+ }
3171
+ /**
3172
+ * Size images added without `w`/`h` to their natural dimensions (issue #34)
3173
+ * @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
3174
+ * @param {PresSlide | SlideLayout} layout - slide layout
3175
+ */ function applyNaturalImageSizes(layout) {
3176
+ // Media bytes for path-based images are now loaded; deduplicate identical raster payloads deck-wide
3177
+ // before slide/layout `.rels` and zip parts are emitted.
3178
+ dedupeSlideMediaRels(layout);
3179
+ layout._slideObjects.filter((obj)=>{
3180
+ var _obj_options;
3181
+ return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
3182
+ }).forEach((obj)=>{
3183
+ var _layout__relsMedia_find;
3184
+ const strData = (_layout__relsMedia_find = layout._relsMedia.find((rel)=>rel.rId === obj.imageRid)) === null || _layout__relsMedia_find === void 0 ? void 0 : _layout__relsMedia_find.data;
3185
+ if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
3186
+ // An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
3187
+ // to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
3188
+ if (obj.options.placeholder) return;
3189
+ try {
3190
+ const dims = imageDimensions(base64ToBytes(strData));
3191
+ if (dims.width && dims.height) {
3192
+ obj.options.w = dims.width / IMAGE_DPI;
3193
+ obj.options.h = dims.height / IMAGE_DPI;
3194
+ }
3195
+ } catch (_ex) {
3196
+ // Unreadable/unsupported image: keep the 1x1 inch default
3197
+ }
3198
+ });
3199
+ }
3200
+ /** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
3201
+ return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
3202
+ }
3203
+ /**
3204
+ * Mark repeated source paths so only the first relation performs I/O.
3205
+ *
3206
+ * Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
3207
+ */ function markDuplicateMedia(candidates) {
3208
+ const paths = new Set();
3209
+ candidates.forEach((rel)=>{
3210
+ var _rel_path;
3211
+ const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3212
+ rel.isDuplicate = paths.has(path);
3213
+ paths.add(path);
3214
+ });
3215
+ }
3216
+ /** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
3217
+ candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
3218
+ }
3219
+ /** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
3220
+ rel.data = IMG_BROKEN;
3221
+ copyMediaToDuplicates(candidates, rel);
3222
+ }
3223
+ function mediaLoadFailed(candidates, rel, message, onError) {
3224
+ markMediaBroken(candidates, rel);
3225
+ if (onError === 'placeholder') {
3226
+ console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
3227
+ return 'done';
3228
+ }
3229
+ throw new Error(message);
3230
+ }
3231
+ /**
3232
+ * Read one Node-local media source and encode it as base64.
3233
+ *
3234
+ * A read failure is recorded before rejection so duplicate references remain consistent.
3235
+ */ function readNodeMediaFile(rel, candidates, fs, onError) {
3236
+ return _async_to_generator(function*() {
3237
+ try {
3238
+ var _rel_path;
3239
+ var _rel_fill;
3240
+ const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3241
+ const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
3242
+ if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
3243
+ const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
3244
+ rel.data = utf8ToBase64(svgText);
3245
+ } else {
3246
+ const bitmap = fs.readFileSync(relPath);
3247
+ rel.data = bytesToBase64(new Uint8Array(bitmap));
3248
+ if (svgFill && typeof rel.data === 'string') {
3249
+ rel.data = applySvgFillToDataUrl(rel.data, svgFill);
3250
+ }
3251
+ }
3252
+ copyMediaToDuplicates(candidates, rel);
3253
+ return 'done';
3254
+ } catch (ex) {
3255
+ return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
3256
+ }
3257
+ })();
3258
+ }
3259
+ /**
3260
+ * Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
3261
+ */ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
3262
+ var _rel_path;
3263
+ const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
3264
+ return new Promise((resolve, reject)=>{
3265
+ const fail = (message)=>{
3266
+ try {
3267
+ resolve(mediaLoadFailed(candidates, rel, message, onError));
3268
+ } catch (ex) {
3269
+ reject(ex);
3270
+ }
3271
+ };
3272
+ try {
3273
+ var _rel_path;
3274
+ const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
3275
+ var _res_statusCode;
3276
+ const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
3277
+ if (status < 200 || status > 299) {
3278
+ res.resume(); // drain so the socket is freed
3279
+ fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
3280
+ return;
3281
+ }
3282
+ let raw = '';
3283
+ res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
3284
+ res.on('data', (chunk)=>raw += chunk);
3285
+ res.on('end', ()=>{
3286
+ rel.data = binaryStringToBase64(raw);
3287
+ copyMediaToDuplicates(candidates, rel);
3288
+ resolve('done');
3289
+ });
3290
+ res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
3291
+ });
3292
+ // NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
3293
+ req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
3294
+ } catch (ex) {
3295
+ fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
3296
+ }
3297
+ });
3298
+ }
3299
+ /**
3300
+ * Fetch one browser media source and convert its Blob response to a data URL.
3301
+ * SVG previews are produced only after the source relation has been populated.
3302
+ */ function loadBrowserMedia(rel, candidates, onError) {
3303
+ return new Promise((resolve, reject)=>{
3304
+ var _rel_path;
3305
+ const fail = (message)=>{
3306
+ try {
3307
+ resolve(mediaLoadFailed(candidates, rel, message, onError));
3308
+ } catch (ex) {
3309
+ reject(ex);
3310
+ }
3311
+ };
3312
+ const xhr = new XMLHttpRequest();
3313
+ xhr.onload = ()=>{
3314
+ // status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
3315
+ if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
3316
+ fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
3317
+ return;
3318
+ }
3319
+ const reader = new FileReader();
3320
+ reader.onloadend = ()=>{
3321
+ if (typeof reader.result === 'string') rel.data = reader.result;
3322
+ copyMediaToDuplicates(candidates, rel);
3323
+ if (!rel.isSvgPng) resolve('done');
3324
+ else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
3325
+ };
3326
+ reader.readAsDataURL(xhr.response);
3327
+ };
3328
+ xhr.onerror = ()=>{
3329
+ fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
3330
+ };
3331
+ xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
3332
+ xhr.responseType = 'blob';
3333
+ xhr.send();
3334
+ });
3335
+ }
3336
+ /** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
3337
+ return _async_to_generator(function*() {
3338
+ var _rel_path;
3339
+ if (!modules.https) yield loadNodeModules();
3340
+ const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
3341
+ if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
3342
+ if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
3343
+ return loadBrowserMedia(rel, candidates, onError);
3344
+ })();
3345
+ }
3346
+ /**
3347
+ * Append SVG preview work synchronously because the caller immediately snapshots `promises`.
3348
+ * Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
3349
+ */ function addSvgPreviewPromises(layout, isNode, promises) {
3350
+ layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
3351
+ // NOTE: must push synchronously - the caller snapshots this array as soon as we return
3352
+ if (isNode) {
3353
+ // SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
3354
+ rel.data = IMG_BROKEN;
3355
+ promises.push(Promise.resolve('done'));
3356
+ } else {
3357
+ promises.push(createSvgPngPreview(rel));
3358
+ }
3359
+ });
3360
+ }
3361
+ /**
3362
+ * Encode Image/Audio/Video into base64
3363
+ * @param {PresSlide | SlideLayout} layout - slide layout
3364
+ * @return {Promise} promise
3365
+ */ function encodeSlideMediaRels(layout, opts) {
3366
+ // STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
3367
+ // (and even `process.versions.node`), so also require a document-less runtime.
3368
+ const isNode = isNodeRuntime();
3369
+ const modules = {};
3370
+ // STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
3371
+ // so browser bundlers cannot statically resolve `node:https` / `https`.
3372
+ const loadNodeDeps = isNode ? ()=>_async_to_generator(function*() {
3373
+ ;
3374
+ ({ default: modules.fs } = yield importNodeBuiltin('fs'));
3375
+ ({ default: modules.https } = yield importNodeBuiltin('https'));
3376
+ ({ default: modules.http } = yield importNodeBuiltin('http'));
3377
+ })() : ()=>_async_to_generator(function*() {})();
3378
+ // Immediately start it when we know we’re in Node
3379
+ if (isNode) loadNodeDeps();
3380
+ // STEP 3: Prepare promises list
3381
+ const imageProms = [];
3382
+ // A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
3383
+ const candidateRels = getMediaCandidates(layout);
3384
+ // B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
3385
+ markDuplicateMedia(candidateRels);
3386
+ // STEP 4: Read/Encode each unique media item
3387
+ const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
3388
+ candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
3389
+ // STEP 5: SVG-PNG previews
3390
+ // ......: "SVG:" base64 data still requires a png to be generated
3391
+ // ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
3392
+ addSvgPreviewPromises(layout, isNode, imageProms);
3393
+ return imageProms;
3394
+ }
3395
+ /**
3396
+ * Create SVG preview image
3397
+ * @param {ISlideRelMedia} rel - slide rel
3398
+ * @return {Promise} promise
3399
+ */ function createSvgPngPreview(rel) {
3400
+ return _async_to_generator(function*() {
3401
+ return yield new Promise((resolve, reject)=>{
3402
+ // A: Create
3403
+ const image = new Image();
3404
+ // Shared error handler (also wired to `image.onerror`); the reason string is informational only
3405
+ const handleError = ()=>{
3406
+ rel.data = IMG_BROKEN;
3407
+ reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
3408
+ };
3409
+ // B: Set onload event
3410
+ image.onload = ()=>{
3411
+ // First: Check for any errors: This is the best method (try/catch wont work, etc.)
3412
+ if (image.width + image.height === 0) {
3413
+ handleError();
3414
+ }
3415
+ const canvas = document.createElement('canvas');
3416
+ const ctx = canvas.getContext('2d');
3417
+ if (!ctx) {
3418
+ handleError();
3419
+ return;
3420
+ }
3421
+ canvas.width = image.width;
3422
+ canvas.height = image.height;
3423
+ ctx.drawImage(image, 0, 0);
3424
+ // Users running on local machine will get the following error:
3425
+ // "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
3426
+ // when the canvas.toDataURL call executes below.
3427
+ try {
3428
+ rel.data = canvas.toDataURL(rel.type);
3429
+ resolve('done');
3430
+ } catch (_ex) {
3431
+ handleError();
3432
+ }
3433
+ };
3434
+ image.onerror = handleError;
3435
+ // C: Load image
3436
+ image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
3437
+ });
3438
+ })();
3439
+ }
3440
+
3441
+ ;// CONCATENATED MODULE: ./src/xml/hyperlink.ts
3442
+ /**
3443
+ * Hyperlinks and mouse-over actions.
3444
+ *
3445
+ * DrawingML gives the same concept two element names depending on where it appears:
3446
+ *
3447
+ * | host | click | mouse-over |
3448
+ * | :-- | :-- | :-- |
3449
+ * | `p:cNvPr` (shapes, pictures) | `a:hlinkClick` (20.1.2.2.22) | `a:hlinkHover` (20.1.2.2.23) |
3450
+ * | `a:rPr` (text runs) | `a:hlinkClick` | `a:hlinkMouseOver` (21.1.2.3.6) |
3451
+ *
3452
+ * Emitting `a:hlinkHover` inside `a:rPr` — or `a:hlinkMouseOver` inside `p:cNvPr` — produces markup
3453
+ * PowerPoint cannot parse, so the host decides the element name here rather than at each call site.
3454
+ */
3455
+ /**
3456
+ * Build one `a:hlinkClick` / mouse-over element
3457
+ * @param {HyperlinkProps} link - link props
3458
+ * @param {'click' | 'hover'} trigger - which interaction this element describes
3459
+ * @param {HyperlinkHost} host - the element the link is attached to
3460
+ * @param {string} children - child elements (`a:snd`, `a:extLst`); self-closes when empty
3461
+ * @returns {string} XML string
3462
+ */ function genXmlHyperlink(link, trigger, host, children = '') {
3463
+ var _link__rId;
3464
+ const tag = trigger === 'click' ? 'a:hlinkClick' : host === 'run' ? 'a:hlinkMouseOver' : 'a:hlinkHover';
3465
+ let attrs = `r:id="rId${(_link__rId = link._rId) !== null && _link__rId !== void 0 ? _link__rId : 0}"`;
3466
+ if (link.slide) {
3467
+ // an internal jump has no URL; the action attribute names the target kind
3468
+ attrs += ' action="ppaction://hlinksldjump"';
3469
+ } else {
3470
+ attrs += ' invalidUrl="" action="" tgtFrame=""';
3471
+ }
3472
+ attrs += ` tooltip="${link.tooltip ? encodeXmlEntities(link.tooltip) : ''}"`;
3473
+ if (!link.slide) attrs += ' history="1"';
3474
+ // both default to false in the schema, so only write them when turned on
3475
+ if (link.highlightClick === true) attrs += ' highlightClick="1"';
3476
+ if (link.stopSoundsOnClick === true) attrs += ' endSnd="1"';
3477
+ const sound = genXmlHyperlinkSound(link);
3478
+ const inner = sound + children;
3479
+ return inner ? `<${tag} ${attrs}>${inner}</${tag}>` : `<${tag} ${attrs}/>`;
3480
+ }
3481
+ /**
3482
+ * Build the `a:snd` action sound (ECMA-376 20.1.2.2.32 `CT_EmbeddedWAVAudioFile`)
3483
+ * - the relationship is resolved when the object is created, so `_sndRId` is set by then
3484
+ * @param {HyperlinkProps} link - link props
3485
+ * @returns {string} XML string
3486
+ */ function genXmlHyperlinkSound(link) {
3487
+ var _link_sound_name;
3488
+ var _link_sound;
3489
+ if (!((_link_sound = link.sound) === null || _link_sound === void 0 ? void 0 : _link_sound._sndRId)) return '';
3490
+ return `<a:snd r:embed="rId${link.sound._sndRId}" name="${encodeXmlEntities((_link_sound_name = link.sound.name) !== null && _link_sound_name !== void 0 ? _link_sound_name : 'sound.wav')}"/>`;
3491
+ }
3492
+
3493
+ ;// CONCATENATED MODULE: ./src/xml/line.ts
3494
+ function line_define_property(obj, key, value) {
3495
+ if (key in obj) {
3496
+ Object.defineProperty(obj, key, {
3497
+ value: value,
3498
+ enumerable: true,
3499
+ configurable: true,
3500
+ writable: true
3501
+ });
3502
+ } else obj[key] = value;
3503
+ return obj;
3504
+ }
3505
+ function line_object_spread(target) {
3506
+ for(var i = 1; i < arguments.length; i++){
3507
+ var source = arguments[i] != null ? arguments[i] : {};
3508
+ var ownKeys = Object.keys(source);
3509
+ if (typeof Object.getOwnPropertySymbols === "function") {
3510
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
3511
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
3512
+ }));
3513
+ }
3514
+ ownKeys.forEach(function(key) {
3515
+ line_define_property(target, key, source[key]);
3516
+ });
3517
+ }
3518
+ return target;
3519
+ }
3520
+ function line_ownKeys(object, enumerableOnly) {
3521
+ var keys = Object.keys(object);
3522
+ if (Object.getOwnPropertySymbols) {
3523
+ var symbols = Object.getOwnPropertySymbols(object);
3524
+ if (enumerableOnly) {
3525
+ symbols = symbols.filter(function(sym) {
3526
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3527
+ });
3528
+ }
3529
+ keys.push.apply(keys, symbols);
3530
+ }
3531
+ return keys;
3532
+ }
3533
+ function line_object_spread_props(target, source) {
3534
+ source = source != null ? source : {};
3535
+ if (Object.getOwnPropertyDescriptors) Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3536
+ else {
3537
+ line_ownKeys(Object(source)).forEach(function(key) {
3538
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3539
+ });
3540
+ }
3541
+ return target;
3542
+ }
3543
+ /**
3544
+ * PptxGenJS: Line properties (`a:ln` and its aliases)
3545
+ *
3546
+ * The same `CT_LineProperties` content model is used by shape outlines (`a:ln`), underlines
3547
+ * (`a:uLn`), and table cell borders, so the element name is a parameter rather than baked in.
3548
+ */
3549
+
3550
+ const LINE_ALIGNS = new Set([
3551
+ 'in',
3552
+ 'ctr',
3553
+ 'out'
3554
+ ]);
3555
+ /**
3556
+ * Create a line element
3557
+ * @param {ShapeLineProps} line - line options
3558
+ * @param {string} tag - element name; `a:ln` for a shape outline, `a:uLn` for an underline
3559
+ * @return {string} XML
3560
+ */ function genXmlLine(line, tag = 'a:ln') {
3561
+ // Explicit "no stroke" — emit `<a:noFill/>` so PowerPoint/Slides do not fall back to theme stroke
3562
+ if (line.type === 'none') {
3563
+ return `<${tag}><a:noFill/></${tag}>`;
3564
+ }
3565
+ // ECMA-376 §5.1.2.1.34: `<a:ln>` carries `w`, `cap`, `cmpd`, and `algn` attributes
3566
+ const cap = line.cap && [
3567
+ 'flat',
3568
+ 'sq',
3569
+ 'rnd'
3570
+ ].includes(line.cap) ? ` cap="${line.cap}"` : '';
3571
+ const compound = COMPOUND_TYPES.has(String(line.compound)) ? ` cmpd="${String(line.compound)}"` : '';
3572
+ if (line.compound && !COMPOUND_TYPES.has(String(line.compound))) {
3573
+ console.warn(`[pptxgenjs] line \`compound\` must be one of ${[
3574
+ ...COMPOUND_TYPES
3575
+ ].join(', ')} - "${String(line.compound)}" ignored`);
3576
+ }
3577
+ const align = line.align && LINE_ALIGNS.has(line.align) ? ` algn="${line.align}"` : '';
3578
+ if (line.align && !LINE_ALIGNS.has(line.align)) {
3579
+ console.warn(`[pptxgenjs] line \`align\` must be 'in' | 'ctr' | 'out' - "${String(line.align)}" ignored`);
3580
+ }
3581
+ const attrs = (line.width ? ` w="${valToLineWidth(line.width)}"` : '') + cap + compound + align;
3582
+ let xml = `<${tag}${attrs}>`;
3583
+ const hasGrad = !!(line.gradient || line.type === 'gradient' || line.type === 'linearGradient');
3584
+ if (line.color || hasGrad) {
3585
+ xml += genXmlColorSelection(hasGrad && !line.type ? line_object_spread_props(line_object_spread({}, line), {
3586
+ type: 'gradient'
3587
+ }) : line);
3588
+ }
3589
+ // CT_LineProperties sequence: fill, dash, join, headEnd, tailEnd. A custom pattern replaces
3590
+ // the preset one - emitting both would be ambiguous, since `a:custDash` is the same choice.
3591
+ xml += genXmlDash(line);
3592
+ xml += genXmlJoin(line);
3593
+ xml += genXmlArrow('a:headEnd', line.beginArrowType, line.beginArrowSize);
3594
+ xml += genXmlArrow('a:tailEnd', line.endArrowType, line.endArrowSize);
3595
+ xml += `</${tag}>`;
3596
+ return xml;
3597
+ }
3598
+ /** The dash choice: a custom pattern when given, otherwise the preset */ function genXmlDash(line) {
3599
+ var _line_custDash;
3600
+ const stops = ((_line_custDash = line.custDash) !== null && _line_custDash !== void 0 ? _line_custDash : []).filter((stop)=>{
3601
+ const ok = typeof (stop === null || stop === void 0 ? void 0 : stop.dash) === 'number' && isFinite(stop.dash) && stop.dash > 0 && typeof stop.space === 'number' && isFinite(stop.space) && stop.space >= 0;
3602
+ if (!ok) console.warn('[pptxgenjs] each `custDash` stop needs a positive `dash` and a non-negative `space` (percent of line width) - stop ignored');
3603
+ return ok;
3604
+ });
3605
+ if (stops.length > 0) {
3606
+ const items = stops.map((stop)=>`<a:ds d="${Math.round(stop.dash * 1000)}" sp="${Math.round(stop.space * 1000)}"/>`).join('');
3607
+ return `<a:custDash>${items}</a:custDash>`;
3608
+ }
3609
+ return line.dashType ? `<a:prstDash val="${line.dashType}"/>` : '';
3610
+ }
3611
+ /** The join choice: `a:round`, `a:bevel`, or `a:miter` with its limit */ function genXmlJoin(line) {
3612
+ if (!line.join) return '';
3613
+ if (line.join === 'round') return '<a:round/>';
3614
+ if (line.join === 'bevel') return '<a:bevel/>';
3615
+ if (line.join === 'miter') {
3616
+ const lim = typeof line.miterLimit === 'number' && isFinite(line.miterLimit) && line.miterLimit >= 0 ? line.miterLimit : 800;
3617
+ return `<a:miter lim="${Math.round(lim * 1000)}"/>`;
3618
+ }
3619
+ console.warn(`[pptxgenjs] line \`join\` must be 'round' | 'bevel' | 'miter' - "${String(line.join)}" ignored`);
3620
+ return '';
3621
+ }
3622
+ function resolveArrowSize(size) {
3623
+ if (!size) return undefined;
3624
+ if (typeof size === 'string') return {
3625
+ width: size,
3626
+ length: size
3627
+ };
3628
+ return size;
3629
+ }
3630
+ /** An arrow end with its optional sizing */ function genXmlArrow(tag, type, size) {
3631
+ if (!type) return '';
3632
+ const resolved = resolveArrowSize(size);
3633
+ const w = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.width)) ? ` w="${String(resolved === null || resolved === void 0 ? void 0 : resolved.width)}"` : '';
3634
+ const len = ARROW_SIZES.has(String(resolved === null || resolved === void 0 ? void 0 : resolved.length)) ? ` len="${String(resolved === null || resolved === void 0 ? void 0 : resolved.length)}"` : '';
3635
+ return `<${tag} type="${type}"${w}${len}/>`;
3636
+ }
3637
+
3125
3638
  ;// CONCATENATED MODULE: ./src/xml/text.ts
3126
3639
  function text_define_property(obj, key, value) {
3127
3640
  if (key in obj) {
@@ -3229,7 +3742,7 @@ function text_object_spread_props(target, source) {
3229
3742
  if (bullet.color) xml += `<a:buClr>${createColorElement(bullet.color)}</a:buClr>`;
3230
3743
  // `a:buSzPct` and `a:buSzPts` are the same choice, so only one may appear
3231
3744
  if (typeof bullet.sizePts === 'number' && isFinite(bullet.sizePts) && bullet.sizePts > 0) {
3232
- xml += `<a:buSzPts val="${Math.round(bullet.sizePts * 100)}"/>`;
3745
+ xml += `<a:buSzPts val="${fontSizeToSz(bullet.sizePts)}"/>`;
3233
3746
  } else {
3234
3747
  const pct = typeof bullet.size === 'number' && isFinite(bullet.size) ? Math.min(400, Math.max(25, bullet.size)) : 100;
3235
3748
  if (typeof bullet.size === 'number' && (bullet.size < 25 || bullet.size > 400)) {
@@ -3240,6 +3753,20 @@ function text_object_spread_props(target, source) {
3240
3753
  if (bullet.fontFace) xml += `<a:buFont typeface="${encodeXmlEntities(bullet.fontFace)}"/>`;
3241
3754
  return xml;
3242
3755
  }
3756
+ /**
3757
+ * Compute `marL` and hanging `indent` attributes for a bulleted paragraph (`a:pPr`).
3758
+ * When `bullet.hangingIndentRatio` is provided, `bullet.indent` acts as the base left margin
3759
+ * (`before text` indent) and the hanging indent is `round(marL * hangingIndentRatio)`.
3760
+ */ function genXmlBulletMarginIndent(options) {
3761
+ const bullet = typeof options.bullet === 'object' ? options.bullet : {};
3762
+ const bulletMarL = valToPts(bullet.indent || (/* inlined export .DEF_BULLET_MARGIN */27));
3763
+ const indentLevel = options.indentLevel && options.indentLevel > 0 ? options.indentLevel : 0;
3764
+ if (typeof bullet.hangingIndentRatio === 'number' && Number.isFinite(bullet.hangingIndentRatio) && bullet.hangingIndentRatio > 0) {
3765
+ const hangingIndent = Math.round(bulletMarL * bullet.hangingIndentRatio);
3766
+ return ` marL="${bulletMarL * (indentLevel || 1)}" indent="-${hangingIndent}"`;
3767
+ }
3768
+ return ` marL="${indentLevel > 0 ? bulletMarL + bulletMarL * indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3769
+ }
3243
3770
  /**
3244
3771
  * Generate XML Paragraph Properties
3245
3772
  * @param {ISlideObject|TextProps} textObj - text object
@@ -3252,7 +3779,6 @@ function text_object_spread_props(target, source) {
3252
3779
  let strXmlParaSpc = '';
3253
3780
  let strXmlTabStops = '';
3254
3781
  const tag = isDefault ? 'a:lvl1pPr' : 'a:pPr';
3255
- let bulletMarL = valToPts((/* inlined export .DEF_BULLET_MARGIN */27));
3256
3782
  const options = (_textObj_options = textObj.options) !== null && _textObj_options !== void 0 ? _textObj_options : {};
3257
3783
  let paragraphPropXml = `<${tag}${options.rtlMode ? ' rtl="1" ' : ''}`;
3258
3784
  // A: Build paragraphProperties
@@ -3277,10 +3803,12 @@ function text_object_spread_props(target, source) {
3277
3803
  break;
3278
3804
  }
3279
3805
  }
3806
+ // `a:spcPts` is ST_TextSpacingPoint (0..158400, i.e. 0..1584pt) and `a:spcPct` is
3807
+ // ST_TextSpacingPercent (0..13200000) - out-of-range spacing is a schema violation
3280
3808
  if (options.lineSpacing) {
3281
- strXmlLnSpc = `<a:lnSpc><a:spcPts val="${Math.round(options.lineSpacing * 100)}"/></a:lnSpc>`;
3809
+ strXmlLnSpc = `<a:lnSpc><a:spcPts val="${clampInt(options.lineSpacing * 100, 0, 158400)}"/></a:lnSpc>`;
3282
3810
  } else if (options.lineSpacingMultiple) {
3283
- strXmlLnSpc = `<a:lnSpc><a:spcPct val="${Math.round(options.lineSpacingMultiple * 100000)}"/></a:lnSpc>`;
3811
+ strXmlLnSpc = `<a:lnSpc><a:spcPct val="${clampInt(options.lineSpacingMultiple * 100000, 0, 13200000)}"/></a:lnSpc>`;
3284
3812
  }
3285
3813
  // OPTION: indent
3286
3814
  if (options.indentLevel && !isNaN(Number(options.indentLevel)) && options.indentLevel > 0) {
@@ -3303,28 +3831,28 @@ function text_object_spread_props(target, source) {
3303
3831
  if (para.hangingPunct === false) paragraphPropXml += ' hangingPunct="0"';
3304
3832
  // OPTION: Paragraph Spacing: Before/After
3305
3833
  if (options.paraSpaceBefore && !isNaN(Number(options.paraSpaceBefore)) && options.paraSpaceBefore > 0) {
3306
- strXmlParaSpc += `<a:spcBef><a:spcPts val="${Math.round(options.paraSpaceBefore * 100)}"/></a:spcBef>`;
3834
+ strXmlParaSpc += `<a:spcBef><a:spcPts val="${clampInt(options.paraSpaceBefore * 100, 0, 158400)}"/></a:spcBef>`;
3307
3835
  }
3308
3836
  if (options.paraSpaceAfter && !isNaN(Number(options.paraSpaceAfter)) && options.paraSpaceAfter > 0) {
3309
- strXmlParaSpc += `<a:spcAft><a:spcPts val="${Math.round(options.paraSpaceAfter * 100)}"/></a:spcAft>`;
3837
+ strXmlParaSpc += `<a:spcAft><a:spcPts val="${clampInt(options.paraSpaceAfter * 100, 0, 158400)}"/></a:spcAft>`;
3310
3838
  }
3311
3839
  // OPTION: bullet
3312
3840
  // NOTE: OOXML uses the unicode character set for Bullets
3313
3841
  // EX: Unicode Character 'BULLET' (U+2022) ==> '<a:buChar char="&#x2022;"/>'
3314
3842
  if (typeof options.bullet === 'object') {
3315
- var _options_bullet;
3316
- if ((_options_bullet = options.bullet) === null || _options_bullet === void 0 ? void 0 : _options_bullet.indent) bulletMarL = valToPts(options.bullet.indent);
3317
3843
  const buPrefix = genXmlBulletPrefix(options.bullet);
3318
- const buIndent = ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3844
+ const buIndent = genXmlBulletMarginIndent(options);
3319
3845
  if (options.bullet.image && options.bullet._imageRId) {
3320
3846
  // `a:buBlip` replaces the character or number bullet entirely
3321
3847
  paragraphPropXml += buIndent;
3322
3848
  strXmlBullet = `${buPrefix}<a:buBlip><a:blip r:embed="rId${options.bullet._imageRId}"/></a:buBlip>`;
3323
3849
  } else if (options.bullet.type && options.bullet.type.toString().toLowerCase() === 'number') {
3850
+ var _ref, _options_bullet_numberStartAt;
3324
3851
  // NOTE: only `type: 'number'` is a distinct branch; any other `type` (e.g. 'bullet') falls through to the char-bullet cases below (issue #1432)
3325
3852
  paragraphPropXml += buIndent;
3326
3853
  // auto-numbered bullets fall back to the major latin face when none is given
3327
- strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${options.bullet.numberStartAt || options.bullet.startAt || '1'}"/>`;
3854
+ strXmlBullet = `${buPrefix}${options.bullet.fontFace ? '' : '<a:buFont typeface="+mj-lt"/>'}<a:buAutoNum type="${options.bullet.numberType || options.bullet.style || 'arabicPeriod'}" startAt="${// ST_TextBulletStartAtNum is 1..32767
3855
+ clampInt(Number((_ref = (_options_bullet_numberStartAt = options.bullet.numberStartAt) !== null && _options_bullet_numberStartAt !== void 0 ? _options_bullet_numberStartAt : options.bullet.startAt) !== null && _ref !== void 0 ? _ref : 1), 1, 32767)}"/>`;
3328
3856
  } else if (options.bullet.characterCode) {
3329
3857
  let bulletCode = `&#x${options.bullet.characterCode};`;
3330
3858
  // Check value for hex-ness (s/b 4 char hex)
@@ -3349,7 +3877,7 @@ function text_object_spread_props(target, source) {
3349
3877
  strXmlBullet = `${buPrefix}<a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"&#x2022;")}"/>`;
3350
3878
  }
3351
3879
  } else if (options.bullet) {
3352
- paragraphPropXml += ` marL="${options.indentLevel && options.indentLevel > 0 ? bulletMarL + bulletMarL * options.indentLevel : bulletMarL}" indent="-${bulletMarL}"`;
3880
+ paragraphPropXml += genXmlBulletMarginIndent(options);
3353
3881
  strXmlBullet = `<a:buSzPct val="100000"/><a:buChar char="${(/* inlined export .BULLET_TYPES.DEFAULT */"&#x2022;")}"/>`;
3354
3882
  } else if (!options.bullet) {
3355
3883
  // We only add this when the user explicitely asks for no bullet, otherwise, it can override the master defaults!
@@ -3380,9 +3908,11 @@ function text_object_spread_props(target, source) {
3380
3908
  const runPropsTag = isDefault ? 'a:defRPr' : 'a:rPr';
3381
3909
  // BEGIN runProperties (ex: `<a:rPr lang="en-US" sz="1600" b="1" dirty="0">`)
3382
3910
  runProps += '<' + runPropsTag + ' lang="' + (opts.lang ? opts.lang : 'en-US') + '"' + (opts.lang ? ' altLang="en-US"' : '');
3383
- runProps += opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : ''; // NOTE: Use round so sizes like '7.5' wont cause corrupt presentations
3384
- runProps += (opts === null || opts === void 0 ? void 0 : opts.bold) ? ` b="${opts.bold ? '1' : '0'}"` : '';
3385
- runProps += (opts === null || opts === void 0 ? void 0 : opts.italic) ? ` i="${opts.italic ? '1' : '0'}"` : '';
3911
+ runProps += opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '';
3912
+ if ((opts === null || opts === void 0 ? void 0 : opts.bold) === false) runProps += ' b="0"';
3913
+ else if (opts === null || opts === void 0 ? void 0 : opts.bold) runProps += ' b="1"';
3914
+ if ((opts === null || opts === void 0 ? void 0 : opts.italic) === false) runProps += ' i="0"';
3915
+ else if (opts === null || opts === void 0 ? void 0 : opts.italic) runProps += ' i="1"';
3386
3916
  if ((opts === null || opts === void 0 ? void 0 : opts.strike) === true) warnDeprecatedOnce('strike-boolean', '`strike: true` is deprecated - use `strike: "sngStrike"` (or `"dblStrike"`)');
3387
3917
  runProps += (opts === null || opts === void 0 ? void 0 : opts.strike) ? ` strike="${typeof opts.strike === 'string' ? opts.strike : 'sngStrike'}"` : '';
3388
3918
  if (typeof opts.underline === 'object' && ((_opts_underline = opts.underline) === null || _opts_underline === void 0 ? void 0 : _opts_underline.style)) {
@@ -3416,7 +3946,7 @@ function text_object_spread_props(target, source) {
3416
3946
  // CT_TextCharacterProperties child order: ln, fill, effect, highlight, uLn, uFill, latin, ea, cs, sym
3417
3947
  if (opts.color || opts.gradient || opts.fontFace || opts.fontFaceEa || opts.fontFaceCs || opts.fontFaceSym || opts.outline || opts.glow || opts.highlight || run.underlineLine || typeof opts.underline === 'object' && opts.underline.color) {
3418
3948
  if (opts.outline && typeof opts.outline === 'object') {
3419
- runProps += `<a:ln w="${valToPts(opts.outline.size || 0.75)}">${genXmlColorSelection({
3949
+ runProps += `<a:ln w="${valToLineWidth(opts.outline.size || 0.75)}">${genXmlColorSelection({
3420
3950
  color: opts.outline.color || 'FFFFFF',
3421
3951
  transparency: opts.outline.transparency
3422
3952
  })}</a:ln>`;
@@ -3433,7 +3963,11 @@ function text_object_spread_props(target, source) {
3433
3963
  });
3434
3964
  const resolvedGlow = resolveGlowOptions(opts.glow);
3435
3965
  if (resolvedGlow) runProps += `<a:effectLst>${createGlowElement(resolvedGlow)}</a:effectLst>`;
3436
- if (opts.highlight) runProps += `<a:highlight>${createColorElement(opts.highlight)}</a:highlight>`;
3966
+ if (opts.highlight) {
3967
+ const highlightColor = typeof opts.highlight === 'string' ? opts.highlight : opts.highlight.color;
3968
+ const highlightAlpha = typeof opts.highlight === 'object' && opts.highlight.transparency ? `<a:alpha val="${clampAlphaPct(opts.highlight.transparency)}"/>` : '';
3969
+ runProps += `<a:highlight>${createColorElement(highlightColor, highlightAlpha)}</a:highlight>`;
3970
+ }
3437
3971
  if (run.underlineLine === 'text') runProps += '<a:uLnTx/>';
3438
3972
  else if (run.underlineLine && typeof run.underlineLine === 'object') runProps += genXmlLine(run.underlineLine, 'a:uLn');
3439
3973
  if (typeof opts.underline === 'object' && opts.underline.color) runProps += `<a:uFill>${genXmlColorSelection(opts.underline.color)}</a:uFill>`;
@@ -3759,18 +4293,20 @@ function genXmlTextRun(textObj) {
3759
4293
  const arrLines = [];
3760
4294
  let arrTexts = [];
3761
4295
  arrTextObjects.forEach((textObj, idx)=>{
3762
- var _textObj_options, _textObj_options1, _textObj_options2, _textObj_options3;
4296
+ var _textObj_options, _textObj_options1, _arrTexts__options, _textObj_options2, _textObj_options3;
3763
4297
  // OMML-only runs use empty `text` but must still emit content
3764
4298
  if (!textObj.text && ((_textObj_options = textObj.options) === null || _textObj_options === void 0 ? void 0 : _textObj_options.omml)) textObj.text = '';
3765
4299
  // A: Align or Bullet trigger new line
3766
- if (arrTexts.length > 0 && (((_textObj_options1 = textObj.options) === null || _textObj_options1 === void 0 ? void 0 : _textObj_options1.align) || opts.align)) {
3767
- var _textObj_options4, _arrTextObjects__options;
3768
- // Only start a new paragraph when align *changes*
3769
- if (((_textObj_options4 = textObj.options) === null || _textObj_options4 === void 0 ? void 0 : _textObj_options4.align) !== ((_arrTextObjects__options = arrTextObjects[idx - 1].options) === null || _arrTextObjects__options === void 0 ? void 0 : _arrTextObjects__options.align)) {
3770
- arrLines.push(arrTexts);
3771
- arrTexts = [];
3772
- }
3773
- } else if (arrTexts.length > 0 && ((_textObj_options2 = textObj.options) === null || _textObj_options2 === void 0 ? void 0 : _textObj_options2.bullet) && arrTexts.length > 0) {
4300
+ // Compare explicit run align against the current paragraph's effective align so inline runs
4301
+ // that omit `options.align` (e.g. inline OMML, bold runs, or `softBreakBefore` runs) stay
4302
+ // inside the same `<a:p>` instead of splitting into spurious hard paragraphs.
4303
+ const currAlign = (_textObj_options1 = textObj.options) === null || _textObj_options1 === void 0 ? void 0 : _textObj_options1.align;
4304
+ const paraAlign = arrTexts.length > 0 ? ((_arrTexts__options = arrTexts[0].options) === null || _arrTexts__options === void 0 ? void 0 : _arrTexts__options.align) || opts.align : undefined;
4305
+ if (arrTexts.length > 0 && currAlign && currAlign !== paraAlign) {
4306
+ // Only start a new paragraph when effective align *changes*
4307
+ arrLines.push(arrTexts);
4308
+ arrTexts = [];
4309
+ } else if (arrTexts.length > 0 && ((_textObj_options2 = textObj.options) === null || _textObj_options2 === void 0 ? void 0 : _textObj_options2.bullet)) {
3774
4310
  arrLines.push(arrTexts);
3775
4311
  arrTexts = [];
3776
4312
  if (textObj.options) textObj.options.breakLine = false; // For cases with both `bullet` and `brekaLine` - prevent double lineBreak
@@ -3839,7 +4375,7 @@ function genXmlTextRun(textObj) {
3839
4375
  // `glow` / softEdge / reflection belong on the shape effectLst (not per-run), unless set on the run itself
3840
4376
  // `omml` is a run-level math payload — inheriting it would replace sibling plain-text runs
3841
4377
  if (key === 'glow' || key === 'softEdge' || key === 'reflection' || key === 'shadow' || key === 'blur' || key === 'fillOverlay' || key === 'effectDag' || key === 'omml') return;
3842
- if (key !== 'bullet' && !textOpts[key]) textOpts[key] = val;
4378
+ if (key !== 'bullet' && textOpts[key] === undefined) textOpts[key] = val;
3843
4379
  });
3844
4380
  // D: Add formatted textrun
3845
4381
  strSlideXml += genXmlTextRun(textObj);
@@ -3856,17 +4392,17 @@ function genXmlTextRun(textObj) {
3856
4392
  const ea = opts.fontFaceEa || opts.fontFace;
3857
4393
  const cs = opts.fontFaceCs || opts.fontFace;
3858
4394
  if (latin || ea || cs) {
3859
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0">';
4395
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0">';
3860
4396
  if (latin) strSlideXml += `<a:latin typeface="${encodeXmlEntities(latin)}" charset="0"/>`;
3861
4397
  if (ea) strSlideXml += `<a:ea typeface="${encodeXmlEntities(ea)}" charset="0"/>`;
3862
4398
  if (cs) strSlideXml += `<a:cs typeface="${encodeXmlEntities(cs)}" charset="0"/>`;
3863
4399
  strSlideXml += '</a:endParaRPr>';
3864
4400
  } else {
3865
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0"/>';
4401
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
3866
4402
  }
3867
4403
  } else if (reqsClosingFontSize) {
3868
4404
  // Empty [lineBreak] lines should not contain runProp, however, they need to specify fontSize in `endParaRPr`
3869
- strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${Math.round(opts.fontSize * 100)}"` : '') + ' dirty="0"/>';
4405
+ strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}"` + (opts.fontSize ? ` sz="${fontSizeToSz(opts.fontSize)}"` : '') + ' dirty="0"/>';
3870
4406
  } else {
3871
4407
  strSlideXml += `<a:endParaRPr lang="${opts.lang || 'en-US'}" dirty="0"/>`; // Added 20180101 to address PPT-2007 issues
3872
4408
  }
@@ -4184,6 +4720,20 @@ function _object_without_properties_loose(source, excluded) {
4184
4720
 
4185
4721
 
4186
4722
 
4723
+
4724
+ function normalizeExtn(extn) {
4725
+ if (!extn || typeof extn !== 'string') return '';
4726
+ return extn.trim().replace(/^\./, '').toLowerCase();
4727
+ }
4728
+ function extractPathExtn(rawPath) {
4729
+ if (!rawPath) return 'png';
4730
+ const cleanPath = rawPath.split('?')[0].split('#')[0];
4731
+ const fileName = cleanPath.substring(Math.max(cleanPath.lastIndexOf('/'), cleanPath.lastIndexOf('\\')) + 1);
4732
+ const dotIdx = fileName.lastIndexOf('.');
4733
+ if (dotIdx <= 0 || dotIdx === fileName.length - 1) return 'png';
4734
+ const candidate = fileName.substring(dotIdx + 1).toLowerCase();
4735
+ return /^[a-z0-9]{1,8}$/.test(candidate) ? candidate : 'png';
4736
+ }
4187
4737
  /** Valid OOXML preset-geometry strings (the values of `SHAPE_TYPE`) - anything else corrupts the file. */ const VALID_SHAPE_PRESETS = new Set(Object.values(core_enums_SHAPE_TYPE));
4188
4738
  /** Type guard: true when `arr` is a flat (1-level) array rather than a nested one. */ function isFlatStringArray(arr) {
4189
4739
  return Array.isArray(arr) && (arr.length === 0 || !Array.isArray(arr[0]));
@@ -4521,10 +5071,11 @@ function _object_without_properties_loose(source, excluded) {
4521
5071
  const v3DPerspective = options.v3DPerspective;
4522
5072
  options.v3DPerspective = v3DPerspective !== undefined && !isNaN(v3DPerspective) && v3DPerspective >= 0 && v3DPerspective <= 240 ? v3DPerspective : 30;
4523
5073
  // D: Options: chart
5074
+ // `c:gapWidth`/`c:gapDepth` are ST_GapAmount (0..500); clamp finite values to 0..500
4524
5075
  const barGapWidthPct = options.barGapWidthPct;
4525
- options.barGapWidthPct = barGapWidthPct !== undefined && !isNaN(barGapWidthPct) && barGapWidthPct >= 0 && barGapWidthPct <= 1000 ? barGapWidthPct : 150;
5076
+ options.barGapWidthPct = typeof barGapWidthPct === 'number' && Number.isFinite(barGapWidthPct) ? clampInt(barGapWidthPct, 0, 500) : 150;
4526
5077
  const barGapDepthPct = options.barGapDepthPct;
4527
- options.barGapDepthPct = barGapDepthPct !== undefined && !isNaN(barGapDepthPct) && barGapDepthPct >= 0 && barGapDepthPct <= 1000 ? barGapDepthPct : 150;
5078
+ options.barGapDepthPct = typeof barGapDepthPct === 'number' && Number.isFinite(barGapDepthPct) ? clampInt(barGapDepthPct, 0, 500) : 150;
4528
5079
  options.chartColors = Array.isArray(options.chartColors) ? options.chartColors : options._type === core_enums_CHART_TYPE.PIE || options._type === core_enums_CHART_TYPE.DOUGHNUT ? PIECHART_COLORS : BARCHART_COLORS;
4529
5080
  options.chartColorsOpacity = options.chartColorsOpacity && !isNaN(options.chartColorsOpacity) ? options.chartColorsOpacity : undefined;
4530
5081
  // DEPRECATED: v3.11.0 - use `plotArea.border` vvv
@@ -4736,14 +5287,14 @@ function isSvgFillSource(data, path) {
4736
5287
  });
4737
5288
  return svgRid;
4738
5289
  }
4739
- let extn = (path.split('?')[0].split('#')[0].split('.').pop() || 'png').toLowerCase();
5290
+ let extn = extractPathExtn(path);
4740
5291
  const mime = data ? /image\/([\w+]+);/.exec(data) : null;
4741
- if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1] === 'svg+xml' ? 'svg' : mime[1];
5292
+ if (mime === null || mime === void 0 ? void 0 : mime[1]) extn = mime[1].toLowerCase() === 'svg+xml' ? 'svg' : mime[1].toLowerCase();
4742
5293
  if (extn === 'jpg') extn = 'jpeg';
4743
5294
  const imgType = 'image/' + extn;
4744
5295
  const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (path && item.path === path || data && item.data && item.data === data))[0];
4745
5296
  const rId = getNewRelId(target);
4746
- target._relsMedia.push({
5297
+ const mediaRel = {
4747
5298
  path: path || 'preencoded.' + extn,
4748
5299
  type: imgType,
4749
5300
  extn,
@@ -4751,7 +5302,9 @@ function isSvgFillSource(data, path) {
4751
5302
  rId,
4752
5303
  isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
4753
5304
  Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${extn}`
4754
- });
5305
+ };
5306
+ dedupeImageMediaRel(target, mediaRel);
5307
+ target._relsMedia.push(mediaRel);
4755
5308
  return rId;
4756
5309
  }
4757
5310
  function isStructuredImageFill(fill) {
@@ -4791,7 +5344,7 @@ function resolveObjectImageFills(target, options) {
4791
5344
  if ((_options_fillOverlay = options.fillOverlay) === null || _options_fillOverlay === void 0 ? void 0 : _options_fillOverlay.fill) resolveImageFill(target, options.fillOverlay.fill);
4792
5345
  }
4793
5346
  function addImageDefinition(target, opt) {
4794
- var _opt_fillOverlay, _strImagePath_substring_split__split_pop;
5347
+ var _opt_fillOverlay;
4795
5348
  if ((_opt_fillOverlay = opt.fillOverlay) === null || _opt_fillOverlay === void 0 ? void 0 : _opt_fillOverlay.fill) resolveImageFill(target, opt.fillOverlay.fill);
4796
5349
  const newObject = {
4797
5350
  _type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
@@ -4827,14 +5380,17 @@ function addImageDefinition(target, opt) {
4827
5380
  return;
4828
5381
  }
4829
5382
  // STEP 1: Set extension
4830
- // NOTE: Split to address URLs with params (eg: `path/brent.jpg?someParam=true`)
4831
- let strImgExtn = (((_strImagePath_substring_split__split_pop = strImagePath.substring(strImagePath.lastIndexOf('/') + 1).split('?')[0].split('.').pop()) === null || _strImagePath_substring_split__split_pop === void 0 ? void 0 : _strImagePath_substring_split__split_pop.split('#')[0]) || 'png').toLowerCase();
5383
+ // Honor explicit `opt.extn` (for extensionless signed CDN URLs); otherwise parse from path safely.
5384
+ const explicitExtn = normalizeExtn(opt.extn);
5385
+ let strImgExtn = explicitExtn || extractPathExtn(strImagePath);
4832
5386
  // However, pre-encoded images can be whatever mime-type they want (and good for them!)
4833
- const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
4834
- if (strImageMimeMatch && strImageMimeMatch.length > 0) {
4835
- strImgExtn = strImageMimeMatch[1];
4836
- } else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
4837
- strImgExtn = 'svg';
5387
+ if (!explicitExtn) {
5388
+ const strImageMimeMatch = strImageData ? /image\/(\w+);/.exec(strImageData) : null;
5389
+ if (strImageMimeMatch && strImageMimeMatch.length > 0) {
5390
+ strImgExtn = strImageMimeMatch[1].toLowerCase();
5391
+ } else if (strImageData === null || strImageData === void 0 ? void 0 : strImageData.toLowerCase().includes('image/svg+xml')) {
5392
+ strImgExtn = 'svg';
5393
+ }
4838
5394
  }
4839
5395
  // STEP 2: Set type/path
4840
5396
  newObject._type = (/* inlined export .SLIDE_OBJECT_TYPES.image */"image");
@@ -4926,10 +5482,10 @@ function addImageDefinition(target, opt) {
4926
5482
  } else {
4927
5483
  // PERF: Duplicate media should reuse existing `Target` value and not create an additional copy.
4928
5484
  // OPC (ECMA-376 Part 2) lets many relationships point at one part, so identical image bytes are stored once.
4929
- // Match on the source path when given, else on identical base64 `data` (issue #1339) - same content, one media file.
4930
- const imgType = 'image/' + strImgExtn;
5485
+ // Match on the source path within slide, and across the entire deck on identical base64 content hash.
5486
+ const imgType = strImgExtn === 'jpg' ? 'image/jpeg' : 'image/' + strImgExtn;
4931
5487
  const dupeItem = target._relsMedia.filter((item)=>item.type === imgType && !item.isDuplicate && !item.isSvgPng && (strImagePath && item.path === strImagePath || strImageData && item.data && item.data === strImageData))[0];
4932
- target._relsMedia.push({
5488
+ const mediaRel = {
4933
5489
  path: strImagePath || 'preencoded.' + strImgExtn,
4934
5490
  type: imgType,
4935
5491
  extn: strImgExtn,
@@ -4937,7 +5493,9 @@ function addImageDefinition(target, opt) {
4937
5493
  rId: imageRelId,
4938
5494
  isDuplicate: !!(dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target),
4939
5495
  Target: (dupeItem === null || dupeItem === void 0 ? void 0 : dupeItem.Target) ? dupeItem.Target : `../media/${imageTargetStem(target)}.${strImgExtn}`
4940
- });
5496
+ };
5497
+ dedupeImageMediaRel(target, mediaRel);
5498
+ target._relsMedia.push(mediaRel);
4941
5499
  newObject.imageRid = imageRelId;
4942
5500
  }
4943
5501
  // STEP 5: Hyperlink support
@@ -5472,8 +6030,10 @@ function nextExtPartName(target, prefix, extn) {
5472
6030
  bullet._imageRId = rId;
5473
6031
  }
5474
6032
  function addShapeDefinition(target, shapeName, opts) {
6033
+ var _options_styleRef;
5475
6034
  const options = typeof opts === 'object' ? opts : {};
5476
- options.line = options.line || {
6035
+ // With a theme `lnRef` and no explicit line, omit `<a:ln>` so the stroke inherits from the theme (matches `styleRef.fill` in slide.ts)
6036
+ if (!options.line && !((_options_styleRef = options.styleRef) === null || _options_styleRef === void 0 ? void 0 : _options_styleRef.line)) options.line = {
5477
6037
  type: 'none'
5478
6038
  };
5479
6039
  resolveHyperlinkRels(target, options.hyperlink);
@@ -5494,28 +6054,29 @@ function addShapeDefinition(target, shapeName, opts) {
5494
6054
  throw new Error(`Invalid shape "${shapeName}" - use a \`pptxgen.ShapeType\` value (ex: \`pptxgen.ShapeType.oval\` = 'ellipse')`);
5495
6055
  }
5496
6056
  // 1: ShapeLineProps defaults
5497
- const hasConnectorEnds = options.line.sourceId != null || options.line.targetId != null;
5498
- const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, options.line), {
5499
- type: options.line.type || (options.line.gradient ? 'gradient' : 'solid'),
5500
- color: options.line.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
5501
- transparency: options.line.transparency || 0,
5502
- gradient: options.line.gradient,
5503
- width: options.line.width || 1,
5504
- dashType: options.line.dashType || 'solid',
5505
- cap: options.line.cap,
5506
- beginArrowType: options.line.beginArrowType || undefined,
5507
- endArrowType: options.line.endArrowType || undefined,
6057
+ const lineSrc = typeof options.line === 'object' && options.line !== null ? options.line : {};
6058
+ const hasConnectorEnds = lineSrc.sourceId != null || lineSrc.targetId != null;
6059
+ const newLineOpts = gen_objects_object_spread_props(gen_objects_object_spread({}, lineSrc), {
6060
+ type: lineSrc.type || (lineSrc.gradient ? 'gradient' : 'solid'),
6061
+ color: lineSrc.color || (/* inlined export .DEF_SHAPE_LINE_COLOR */"333333"),
6062
+ transparency: lineSrc.transparency || 0,
6063
+ gradient: lineSrc.gradient,
6064
+ width: lineSrc.width || 1,
6065
+ dashType: lineSrc.dashType || 'solid',
6066
+ cap: lineSrc.cap,
6067
+ beginArrowType: lineSrc.beginArrowType || undefined,
6068
+ endArrowType: lineSrc.endArrowType || undefined,
5508
6069
  // ZentoSoft connectors
5509
- sourceId: options.line.sourceId,
5510
- targetId: options.line.targetId,
5511
- sourceAnchorPos: options.line.sourceAnchorPos,
5512
- targetAnchorPos: options.line.targetAnchorPos,
5513
- isConnector: options.line.isConnector || hasConnectorEnds,
5514
- curveadjust: options.line.curveadjust,
5515
- _sourceName: options.line._sourceName,
5516
- _targetName: options.line._targetName
6070
+ sourceId: lineSrc.sourceId,
6071
+ targetId: lineSrc.targetId,
6072
+ sourceAnchorPos: lineSrc.sourceAnchorPos,
6073
+ targetAnchorPos: lineSrc.targetAnchorPos,
6074
+ isConnector: lineSrc.isConnector || hasConnectorEnds,
6075
+ curveadjust: lineSrc.curveadjust,
6076
+ _sourceName: lineSrc._sourceName,
6077
+ _targetName: lineSrc._targetName
5517
6078
  });
5518
- if (typeof options.line === 'object' && options.line.type !== 'none') options.line = newLineOpts;
6079
+ if (typeof options.line === 'object' && options.line !== null && options.line.type !== 'none') options.line = newLineOpts;
5519
6080
  // 2: Set options defaults
5520
6081
  const shapeOpts = options;
5521
6082
  shapeOpts._explicitX = options.x !== undefined && options.x !== null;
@@ -5544,11 +6105,35 @@ function addShapeDefinition(target, shapeName, opts) {
5544
6105
  * @param {Function} addSlide - method
5545
6106
  * @param {Function} getSlide - method
5546
6107
  */ function addTableDefinition(target, tableRows, options, slideLayout, presLayout, addSlide, getSlide) {
6108
+ var _ref;
6109
+ var _target__slideLayout;
5547
6110
  const slides = [
5548
6111
  target
5549
6112
  ] // Create array of Slides as more may be added by auto-paging
5550
6113
  ;
5551
- const opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
6114
+ let opt = options && typeof options === 'object' ? gen_objects_object_spread({}, options) : {};
6115
+ const explicitX = opt.x !== undefined && opt.x !== null;
6116
+ const explicitY = opt.y !== undefined && opt.y !== null;
6117
+ const explicitW = opt.w !== undefined && opt.w !== null;
6118
+ const explicitH = opt.h !== undefined && opt.h !== null;
6119
+ // PR #1151: resolve layout placeholder defaults under caller options so caller overrides placeholder defaults
6120
+ const layoutObjs = (_ref = (_target__slideLayout = target._slideLayout) === null || _target__slideLayout === void 0 ? void 0 : _target__slideLayout._slideObjects) !== null && _ref !== void 0 ? _ref : slideLayout === null || slideLayout === void 0 ? void 0 : slideLayout._slideObjects;
6121
+ if (opt.placeholder && layoutObjs) {
6122
+ const placeHold = layoutObjs.find((item)=>{
6123
+ var _item_options;
6124
+ return item._type === (/* inlined export .SLIDE_OBJECT_TYPES.placeholder */"placeholder") && ((_item_options = item.options) === null || _item_options === void 0 ? void 0 : _item_options.placeholder) === opt.placeholder;
6125
+ });
6126
+ if (placeHold === null || placeHold === void 0 ? void 0 : placeHold.options) {
6127
+ const _placeHold_options = placeHold.options, { _bodyProp: _bp, line: _ln, objectName: _on, sId: _sId, shape: _sh } = _placeHold_options, placeHoldOpts = _object_without_properties(_placeHold_options, [
6128
+ "_bodyProp",
6129
+ "line",
6130
+ "objectName",
6131
+ "sId",
6132
+ "shape"
6133
+ ]);
6134
+ opt = gen_objects_object_spread({}, placeHoldOpts, opt);
6135
+ }
6136
+ }
5552
6137
  opt.objectName = opt.objectName ? encodeXmlEntities(opt.objectName) : `Table ${target._slideObjects.filter((obj)=>obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.table */"table")).length}`;
5553
6138
  // STEP 1: REALITY-CHECK
5554
6139
  {
@@ -5577,21 +6162,40 @@ function addShapeDefinition(target, shapeName, opts) {
5577
6162
  if (Array.isArray(row)) {
5578
6163
  row.forEach((cell)=>{
5579
6164
  var _newCell_options;
5580
- // A:
6165
+ // A: Clone cell options so caller-supplied objects are never mutated (PR #1553)
5581
6166
  const newCell = {
5582
6167
  _type: (/* inlined export .SLIDE_OBJECT_TYPES.tablecell */"tablecell"),
5583
6168
  text: '',
5584
- options: typeof cell === 'object' && cell.options ? cell.options : {}
6169
+ options: typeof cell === 'object' && cell !== null && cell.options && typeof cell.options === 'object' ? gen_objects_object_spread({}, cell.options) : {}
5585
6170
  };
5586
6171
  // B:
5587
6172
  if (typeof cell === 'string' || typeof cell === 'number') newCell.text = cell.toString();
5588
- else if (cell.text) {
6173
+ else if (cell && typeof cell === 'object' && cell.text !== undefined && cell.text !== null) {
5589
6174
  // Cell can contain complex text type, or string, or number
5590
6175
  if (typeof cell.text === 'string' || typeof cell.text === 'number') newCell.text = cell.text.toString();
5591
- else if (cell.text) newCell.text = cell.text;
5592
- // Capture options
5593
- if (cell.options && typeof cell.options === 'object') newCell.options = cell.options;
6176
+ else if (Array.isArray(cell.text)) {
6177
+ var _newCell_options1;
6178
+ // Clone runs and their options so caller objects are never mutated; inherit lang without overwriting explicit run lang
6179
+ const inheritedLang = ((_newCell_options1 = newCell.options) === null || _newCell_options1 === void 0 ? void 0 : _newCell_options1.lang) || opt.lang;
6180
+ newCell.text = cell.text.map((run)=>{
6181
+ if (!run || typeof run !== 'object') return run;
6182
+ const runOpts = run.options && typeof run.options === 'object' ? gen_objects_object_spread({}, run.options) : undefined;
6183
+ if (inheritedLang && !(runOpts === null || runOpts === void 0 ? void 0 : runOpts.lang)) {
6184
+ return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
6185
+ options: gen_objects_object_spread_props(gen_objects_object_spread({}, runOpts), {
6186
+ lang: inheritedLang
6187
+ })
6188
+ });
6189
+ }
6190
+ return gen_objects_object_spread_props(gen_objects_object_spread({}, run), {
6191
+ options: runOpts
6192
+ });
6193
+ });
6194
+ } else {
6195
+ newCell.text = cell.text;
6196
+ }
5594
6197
  }
6198
+ if (opt.lang && newCell.options && !newCell.options.lang) newCell.options.lang = opt.lang;
5595
6199
  // C: Set cell borders
5596
6200
  const cellOpts = (_newCell_options = newCell.options) !== null && _newCell_options !== void 0 ? _newCell_options : {};
5597
6201
  newCell.options = cellOpts;
@@ -5610,12 +6214,15 @@ function addShapeDefinition(target, shapeName, opts) {
5610
6214
  }
5611
6215
  ];
5612
6216
  // CASE 1: border interface is: BorderOptions | [BorderOptions, BorderOptions, BorderOptions, BorderOptions]
6217
+ // Defensively shallow-copy caller border arrays so we never mutate them in place (PR #1541)
5613
6218
  const cellBorder = !Array.isArray(initialBorder) && typeof initialBorder === 'object' ? [
5614
6219
  initialBorder,
5615
6220
  initialBorder,
5616
6221
  initialBorder,
5617
6222
  initialBorder
5618
- ] : initialBorder;
6223
+ ] : [
6224
+ ...initialBorder
6225
+ ];
5619
6226
  cellOpts.border = cellBorder;
5620
6227
  // Handle: [null, null, {type:'solid'}, null]
5621
6228
  if (!cellBorder[0]) cellBorder[0] = {
@@ -5664,10 +6271,10 @@ function addShapeDefinition(target, shapeName, opts) {
5664
6271
  });
5665
6272
  // STEP 3: Set options
5666
6273
  const tableOpts = opt;
5667
- tableOpts._explicitX = opt.x !== undefined && opt.x !== null;
5668
- tableOpts._explicitY = opt.y !== undefined && opt.y !== null;
5669
- tableOpts._explicitW = opt.w !== undefined && opt.w !== null;
5670
- tableOpts._explicitH = opt.h !== undefined && opt.h !== null;
6274
+ tableOpts._explicitX = explicitX;
6275
+ tableOpts._explicitY = explicitY;
6276
+ tableOpts._explicitW = explicitW;
6277
+ tableOpts._explicitH = explicitH;
5671
6278
  opt.x = getSmartParseNumber(opt.x || (opt.x === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'X', presLayout);
5672
6279
  opt.y = getSmartParseNumber(opt.y || (opt.y === 0 ? 0 : (/* inlined export .EMU */914400) / 2), 'Y', presLayout);
5673
6280
  if (opt.h) opt.h = getSmartParseNumber(opt.h, 'Y', presLayout); // NOTE: Dont set default `h` - leaving it null triggers auto-rowH in `makeXMLSlide()`
@@ -5689,7 +6296,9 @@ function addShapeDefinition(target, shapeName, opts) {
5689
6296
  console.warn('addTable `border` option must be an object. Ex: `{border: {type:\'none\'}}`');
5690
6297
  opt.border = undefined;
5691
6298
  } else if (Array.isArray(opt.border)) {
5692
- const optBorder = opt.border;
6299
+ const optBorder = [
6300
+ ...opt.border
6301
+ ];
5693
6302
  [
5694
6303
  0,
5695
6304
  1,
@@ -5706,6 +6315,7 @@ function addShapeDefinition(target, shapeName, opts) {
5706
6315
  type: 'none'
5707
6316
  };
5708
6317
  });
6318
+ opt.border = optBorder;
5709
6319
  }
5710
6320
  opt.autoPage = typeof opt.autoPage === 'boolean' ? opt.autoPage : false;
5711
6321
  opt.autoPageRepeatHeader = typeof opt.autoPageRepeatHeader === 'boolean' ? opt.autoPageRepeatHeader : false;
@@ -6052,21 +6662,29 @@ function addShapeDefinition(target, shapeName, opts) {
6052
6662
  // B: Handle media
6053
6663
  if (props && (props.path || props.data)) {
6054
6664
  // Allow the use of only the data key (`path` isnt reqd)
6055
- props.path = props.path || 'preencoded.png';
6056
- let strImgExtn = (props.path.split('.').pop() || 'png').split('?')[0] // Handle "blah.jpg?width=540" etc.
6057
- ;
6058
- if (strImgExtn === 'jpg') strImgExtn = 'jpeg'; // base64-encoded jpg's come out as "data:image/jpeg;base64,/9j/[...]", so correct exttnesion to avoid content warnings at PPT startup
6665
+ const explicitExtn = normalizeExtn(props.extn);
6666
+ props.path = props.path || `preencoded.${explicitExtn || 'png'}`;
6667
+ let strImgExtn = explicitExtn || extractPathExtn(props.path);
6668
+ if (!explicitExtn && props.data) {
6669
+ const bkgdMimeMatch = /image\/([\w+]+);/.exec(props.data);
6670
+ if (bkgdMimeMatch === null || bkgdMimeMatch === void 0 ? void 0 : bkgdMimeMatch[1]) {
6671
+ strImgExtn = bkgdMimeMatch[1].toLowerCase() === 'svg+xml' ? 'svg' : bkgdMimeMatch[1].toLowerCase();
6672
+ }
6673
+ }
6674
+ if (strImgExtn === 'jpg') strImgExtn = 'jpeg'; // base64-encoded jpg's come out as "data:image/jpeg;base64,/9j/[...]", so correct extension to avoid content warnings at PPT startup
6059
6675
  target._relsMedia = target._relsMedia || [];
6060
6676
  const intRels = target._relsMedia.length + 1;
6061
6677
  // NOTE: `Target` cannot have spaces (eg:"Slide 1-image-1.jpg") or a "presentation is corrupt" warning comes up
6062
- target._relsMedia.push({
6678
+ const bkgdRel = {
6063
6679
  path: props.path,
6064
6680
  type: (/* inlined export .SLIDE_OBJECT_TYPES.image */"image"),
6065
6681
  extn: strImgExtn,
6066
6682
  data: props.data || undefined,
6067
6683
  rId: intRels,
6068
6684
  Target: `../media/${(target._name || '').replace(/\s+/gi, '-')}-image-${target._relsMedia.length + 1}.${strImgExtn}`
6069
- });
6685
+ };
6686
+ dedupeImageMediaRel(target, bkgdRel);
6687
+ target._relsMedia.push(bkgdRel);
6070
6688
  target._bkgdImgRid = intRels;
6071
6689
  }
6072
6690
  }
@@ -6083,8 +6701,14 @@ function addShapeDefinition(target, shapeName, opts) {
6083
6701
  text
6084
6702
  ];
6085
6703
  textObjs.forEach((text, idx)=>{
6086
- // IMPORTANT: `options` are lost due to recursion/copy!
6087
- if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) text.options = gen_objects_object_spread({}, text.options, options[idx]);
6704
+ // IMPORTANT: `options` are lost due to recursion/copy! Preserve explicit run `lang` over cell `lang` (PR #1553).
6705
+ if (!Array.isArray(text) && options && options[idx] && options[idx].hyperlink) {
6706
+ var _text_options;
6707
+ const preservedLang = ((_text_options = text.options) === null || _text_options === void 0 ? void 0 : _text_options.lang) || options[idx].lang;
6708
+ text.options = gen_objects_object_spread({}, text.options, options[idx], preservedLang ? {
6709
+ lang: preservedLang
6710
+ } : {});
6711
+ }
6088
6712
  // NOTE: `text` can be an array of other `text` objects (table cell word-level formatting), continue parsing using recursion
6089
6713
  if (Array.isArray(text)) {
6090
6714
  const cellOpts = [];
@@ -6752,11 +7376,11 @@ function createShadowElement(shadow) {
6752
7376
  }
6753
7377
  let strXml = '<a:effectLst>';
6754
7378
  const type = shadow.type;
6755
- const blur = valToPts(shadow.blur);
6756
- const offset = valToPts(shadow.offset);
7379
+ const blur = Math.max(0, valToPts(shadow.blur));
7380
+ const offset = Math.max(0, valToPts(shadow.offset));
6757
7381
  const angle = Math.round(shadow.angle * 60000);
6758
7382
  const color = shadow.color;
6759
- const opacity = Math.round(shadow.opacity * 100000);
7383
+ const opacity = clampAlphaPct(100 - shadow.opacity * 100);
6760
7384
  const rotShape = shadow.rotateWithShape ? 1 : 0;
6761
7385
  strXml += `<a:${type}Shdw sx="100000" sy="100000" kx="0" ky="0" algn="bl" blurRad="${blur}" rotWithShape="${rotShape}" dist="${offset}" dir="${angle}">`;
6762
7386
  strXml += `<a:srgbClr val="${color}">`;
@@ -6772,7 +7396,7 @@ function createShadowElement(shadow) {
6772
7396
  */ function createGridLineElement(glOpts) {
6773
7397
  let strXml = '<c:majorGridlines>';
6774
7398
  strXml += ' <c:spPr>';
6775
- strXml += ` <a:ln w="${valToPts(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
7399
+ strXml += ` <a:ln w="${valToLineWidth(glOpts.size || DEF_CHART_GRIDLINE.size)}" cap="${createLineCap(glOpts.cap || DEF_CHART_GRIDLINE.cap)}">`;
6776
7400
  strXml += ` <a:solidFill>${createColorElement(glOpts.color || DEF_CHART_GRIDLINE.color)}</a:solidFill>`;
6777
7401
  strXml += ' <a:prstDash val="' + (glOpts.style || DEF_CHART_GRIDLINE.style) + '"/><a:round/>';
6778
7402
  strXml += ' </a:ln>';
@@ -6810,7 +7434,7 @@ function createLineCap(lineCap) {
6810
7434
  if (chartDash && CHART_LINE_DASH_TYPES.includes(chartDash)) return chartDash;
6811
7435
  return 'solid';
6812
7436
  }
6813
- /** Area charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
7437
+ /** Area and line charts use `c:grouping` / ST_Grouping (standard|stacked|percentStacked), not ST_BarGrouping. */ const AREA_GROUPING = [
6814
7438
  'standard',
6815
7439
  'stacked',
6816
7440
  'percentStacked'
@@ -6889,7 +7513,7 @@ function firstLabelLevel(data) {
6889
7513
  // `outEnd` is invalid on the layouts that draw labels inside their segments
6890
7514
  const defaultPos = chartType === 'treemap' || chartType === 'sunburst' || chartType === 'funnel' ? 'ctr' : 'outEnd';
6891
7515
  const pos = (_opts_dataLabelPosition = opts.dataLabelPosition) !== null && _opts_dataLabelPosition !== void 0 ? _opts_dataLabelPosition : defaultPos;
6892
- const size = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
7516
+ const size = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
6893
7517
  const txPr = '<cx:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>' + `<a:defRPr sz="${size}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace || 'Arial')}"/>` + '</a:defRPr></a:pPr></a:p></cx:txPr>';
6894
7518
  const numFmt = opts.dataLabelFormatCode ? `<cx:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode)}" sourceLinked="0"/>` : '';
6895
7519
  return `<cx:dataLabels pos="${pos}">` + `<cx:visibility seriesName="0" categoryName="${showCategory ? 1 : 0}" value="${showValue ? 1 : 0}"/>` + numFmt + txPr + '</cx:dataLabels>';
@@ -6952,7 +7576,7 @@ function firstLabelLevel(data) {
6952
7576
  }
6953
7577
  function makeTitle(opts) {
6954
7578
  if (!opts.showTitle) return '';
6955
- const size = Math.round((opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18)) * 100);
7579
+ const size = fontSizeToSz(opts.titleFontSize || (/* inlined export .DEF_FONT_TITLE_SIZE */18));
6956
7580
  const color = opts.titleColor ? `<a:solidFill>${createColorElement(opts.titleColor)}</a:solidFill>` : '';
6957
7581
  const face = opts.titleFontFace ? `<a:latin typeface="${encodeXmlEntities(opts.titleFontFace)}"/>` : '';
6958
7582
  return '<cx:title pos="t" align="ctr" overlay="0"><cx:tx><cx:rich><a:bodyPr/><a:lstStyle/><a:p><a:pPr algn="ctr"/><a:r>' + `<a:rPr lang="${opts.lang || 'en-US'}" sz="${size}" b="${opts.titleBold ? 1 : 0}">${color}${face}</a:rPr>` + `<a:t>${encodeXmlEntities(opts.title || 'Chart Title')}</a:t>` + '</a:r></a:p></cx:rich></cx:tx></cx:title>';
@@ -7073,7 +7697,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7073
7697
  const align = opts.titleAlign === 'left' || opts.titleAlign === 'right' ? `<a:pPr algn="${opts.titleAlign.substring(0, 1)}">` : '<a:pPr>';
7074
7698
  const rotate = opts.titleRotate ? `<a:bodyPr rot="${convertRotationDegrees(opts.titleRotate)}"/>` : '<a:bodyPr/>' // don't specify rotation to get default (ex. vertical for cat axis)
7075
7699
  ;
7076
- const sizeAttr = opts.fontSize ? `sz="${Math.round(opts.fontSize * 100)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
7700
+ const sizeAttr = opts.fontSize ? `sz="${fontSizeToSz(opts.fontSize)}"` : '' // only set the font size if specified. Powerpoint will handle the default size
7077
7701
  ;
7078
7702
  const titleBold = opts.titleBold ? 1 : 0;
7079
7703
  const titleItalic = opts.titleItalic ? 1 : 0;
@@ -7181,7 +7805,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7181
7805
  strXml += ' <c:tickLblPos val="' + (opts.catAxisLabelPos || (opts.barDir === 'col' ? 'low' : 'nextTo')) + '"/>';
7182
7806
  }
7183
7807
  strXml += ' <c:spPr>';
7184
- strXml += ` <a:ln w="${opts.catAxisLineSize ? valToPts(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7808
+ strXml += ` <a:ln w="${opts.catAxisLineSize ? valToLineWidth(opts.catAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7185
7809
  strXml += !opts.catAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.catAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
7186
7810
  strXml += ' <a:prstDash val="' + (opts.catAxisLineStyle || 'solid') + '"/>';
7187
7811
  strXml += ' <a:round/>';
@@ -7197,7 +7821,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7197
7821
  strXml += ' <a:lstStyle/>';
7198
7822
  strXml += ' <a:p>';
7199
7823
  strXml += ' <a:pPr>';
7200
- strXml += ` <a:defRPr sz="${Math.round((opts.catAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.catAxisLabelFontBold ? 1 : 0}" i="${opts.catAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7824
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.catAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.catAxisLabelFontBold ? 1 : 0}" i="${opts.catAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7201
7825
  strXml += ' <a:solidFill>' + createColorElement(opts.catAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7202
7826
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
7203
7827
  strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.catAxisLabelFontFace) || 'Arial') + '"/>';
@@ -7291,7 +7915,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7291
7915
  strXml += ' <c:tickLblPos val="' + (opts.valAxisLabelPos || (opts.barDir === 'col' ? 'nextTo' : 'low')) + '"/>';
7292
7916
  }
7293
7917
  strXml += ' <c:spPr>';
7294
- strXml += ` <a:ln w="${opts.valAxisLineSize ? valToPts(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7918
+ strXml += ` <a:ln w="${opts.valAxisLineSize ? valToLineWidth(opts.valAxisLineSize) : (/* inlined export .ONEPT */12700)}" cap="flat">`;
7295
7919
  strXml += !opts.valAxisLineShow ? '<a:noFill/>' : '<a:solidFill>' + createColorElement(opts.valAxisLineColor || DEF_CHART_GRIDLINE.color) + '</a:solidFill>';
7296
7920
  strXml += ' <a:prstDash val="' + (opts.valAxisLineStyle || 'solid') + '"/>';
7297
7921
  strXml += ' <a:round/>';
@@ -7302,7 +7926,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7302
7926
  strXml += ' <a:lstStyle/>';
7303
7927
  strXml += ' <a:p>';
7304
7928
  strXml += ' <a:pPr>';
7305
- strXml += ` <a:defRPr sz="${Math.round((opts.valAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.valAxisLabelFontBold ? 1 : 0}" i="${opts.valAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7929
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.valAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.valAxisLabelFontBold ? 1 : 0}" i="${opts.valAxisLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">`;
7306
7930
  strXml += ' <a:solidFill>' + createColorElement(opts.valAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
7307
7931
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
7308
7932
  strXml += ' <a:ea typeface="' + (encodeXmlEntities(opts.valAxisLabelFontFace) || 'Arial') + '"/>';
@@ -7374,7 +7998,7 @@ const NS_ATTRS = `xmlns:cs="${CHART_STYLE.ns}" xmlns:a="http://schemas.openxmlfo
7374
7998
  strXml += ' <a:lstStyle/>';
7375
7999
  strXml += ' <a:p>';
7376
8000
  strXml += ' <a:pPr>';
7377
- strXml += ` <a:defRPr sz="${Math.round((opts.serAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.serAxisLabelFontBold ? '1' : '0'}" i="${opts.serAxisLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
8001
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.serAxisLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.serAxisLabelFontBold ? '1' : '0'}" i="${opts.serAxisLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
7378
8002
  strXml += ` <a:solidFill>${createColorElement(opts.serAxisLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
7379
8003
  strXml += ` <a:latin typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
7380
8004
  strXml += ` <a:ea typeface="${encodeXmlEntities(opts.serAxisLabelFontFace) || 'Arial'}"/>`;
@@ -7477,6 +8101,7 @@ function xml_object_spread_props(target, source) {
7477
8101
  * @param {ISlideRelChart} rel - chart object
7478
8102
  * @return {string} XML
7479
8103
  */ function makeXmlCharts(rel) {
8104
+ var _ref;
7480
8105
  var _rel_opts_chartArea, _rel_opts_chartArea1, _rel_opts_chartArea_border, _rel_opts_chartArea2, _rel_opts_chartArea_border1, _rel_opts_chartArea3;
7481
8106
  let strXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
7482
8107
  let usesSecondaryValAxis = false;
@@ -7509,7 +8134,8 @@ function xml_object_spread_props(target, source) {
7509
8134
  /** Add 3D view tag
7510
8135
  * @see: https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_perspective_topic_ID0E6BUQB.html
7511
8136
  */ if (rel.opts._type === core_enums_CHART_TYPE.BAR3D) {
7512
- strXml += `<c:view3D><c:rotX val="${rel.opts.v3DRotX}"/><c:rotY val="${rel.opts.v3DRotY}"/><c:rAngAx val="${!rel.opts.v3DRAngAx ? 0 : 1}"/><c:perspective val="${rel.opts.v3DPerspective}"/></c:view3D>`;
8137
+ var _rel_opts_v3DRotX, _rel_opts_v3DRotY, _rel_opts_v3DPerspective;
8138
+ strXml += `<c:view3D><c:rotX val="${clampInt((_rel_opts_v3DRotX = rel.opts.v3DRotX) !== null && _rel_opts_v3DRotX !== void 0 ? _rel_opts_v3DRotX : 30, -90, 90)}"/><c:rotY val="${clampInt((_rel_opts_v3DRotY = rel.opts.v3DRotY) !== null && _rel_opts_v3DRotY !== void 0 ? _rel_opts_v3DRotY : 30, 0, 360)}"/><c:rAngAx val="${!rel.opts.v3DRAngAx ? 0 : 1}"/><c:perspective val="${clampInt((_rel_opts_v3DPerspective = rel.opts.v3DPerspective) !== null && _rel_opts_v3DPerspective !== void 0 ? _rel_opts_v3DPerspective : 30, 0, 240)}"/></c:view3D>`;
7513
8139
  }
7514
8140
  strXml += '<c:plotArea>';
7515
8141
  // IMPORTANT: Dont specify layout to enable auto-fit: PPT does a great job maximizing space with all 4 TRBL locations
@@ -7530,9 +8156,21 @@ function xml_object_spread_props(target, source) {
7530
8156
  }
7531
8157
  }
7532
8158
  // A: Create Chart XML -----------------------------------------------------------
8159
+ const hiddenLegendIndices = [];
7533
8160
  if (Array.isArray(rel.opts._type)) {
8161
+ let seriesIdx = 0;
7534
8162
  rel.opts._type.forEach((type)=>{
7535
8163
  var _options_secondaryValAxis;
8164
+ if (Array.isArray(type.data)) {
8165
+ var _type_options;
8166
+ const hideSubchartLegend = ((_type_options = type.options) === null || _type_options === void 0 ? void 0 : _type_options.showLegend) === false;
8167
+ type.data.forEach((obj)=>{
8168
+ var _obj__dataIndex;
8169
+ const idx = (_obj__dataIndex = obj._dataIndex) !== null && _obj__dataIndex !== void 0 ? _obj__dataIndex : seriesIdx;
8170
+ if (hideSubchartLegend) hiddenLegendIndices.push(idx);
8171
+ seriesIdx++;
8172
+ });
8173
+ }
7536
8174
  const options = xml_object_spread({}, rel.opts, type.options);
7537
8175
  if (options.dataLabelPosition) {
7538
8176
  options.dataLabelPosition = resolveDataLabelPosition(options.dataLabelPosition, type.type, options.barGrouping);
@@ -7589,6 +8227,7 @@ function xml_object_spread_props(target, source) {
7589
8227
  }
7590
8228
  // C: Chart Properties and plotArea Options: Border, Data Table, Fill, Legend
7591
8229
  {
8230
+ var _ref1;
7592
8231
  var _rel_opts_plotArea, _rel_opts_plotArea1, _rel_opts_plotArea_border, _rel_opts_plotArea2, _rel_opts_plotArea_border1, _rel_opts_plotArea3;
7593
8232
  // NOTE: DataTable goes between '</c:valAx>' and '<c:spPr>'
7594
8233
  if (rel.opts.showDataTable) {
@@ -7607,7 +8246,7 @@ function xml_object_spread_props(target, source) {
7607
8246
  strXml += ' <a:lstStyle/>';
7608
8247
  strXml += ' <a:p>';
7609
8248
  strXml += ' <a:pPr rtl="0">';
7610
- strXml += ` <a:defRPr sz="${Math.round((rel.opts.dataTableFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">`;
8249
+ strXml += ` <a:defRPr sz="${fontSizeToSz(rel.opts.dataTableFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">`;
7611
8250
  strXml += ' <a:solidFill><a:schemeClr val="tx1"><a:lumMod val="65000"/><a:lumOff val="35000"/></a:schemeClr></a:solidFill>';
7612
8251
  strXml += ' <a:latin typeface="+mn-lt"/>';
7613
8252
  strXml += ' <a:ea typeface="+mn-ea"/>';
@@ -7623,7 +8262,7 @@ function xml_object_spread_props(target, source) {
7623
8262
  // OPTION: Fill
7624
8263
  strXml += ((_rel_opts_plotArea = rel.opts.plotArea) === null || _rel_opts_plotArea === void 0 ? void 0 : _rel_opts_plotArea.fill) && (rel.opts.plotArea.fill.type === 'gradient' || rel.opts.plotArea.fill.type === 'linearGradient' || rel.opts.plotArea.fill.type === 'pattern' || rel.opts.plotArea.fill.color) ? genXmlColorSelection(rel.opts.plotArea.fill) : '<a:noFill/>';
7625
8264
  // OPTION: Border
7626
- strXml += ((_rel_opts_plotArea1 = rel.opts.plotArea) === null || _rel_opts_plotArea1 === void 0 ? void 0 : _rel_opts_plotArea1.border) ? `<a:ln w="${valToPts((_rel_opts_plotArea2 = rel.opts.plotArea) === null || _rel_opts_plotArea2 === void 0 ? void 0 : (_rel_opts_plotArea_border = _rel_opts_plotArea2.border) === null || _rel_opts_plotArea_border === void 0 ? void 0 : _rel_opts_plotArea_border.pt)}" cap="flat">${genXmlColorSelection((_rel_opts_plotArea3 = rel.opts.plotArea) === null || _rel_opts_plotArea3 === void 0 ? void 0 : (_rel_opts_plotArea_border1 = _rel_opts_plotArea3.border) === null || _rel_opts_plotArea_border1 === void 0 ? void 0 : _rel_opts_plotArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
8265
+ strXml += ((_rel_opts_plotArea1 = rel.opts.plotArea) === null || _rel_opts_plotArea1 === void 0 ? void 0 : _rel_opts_plotArea1.border) ? `<a:ln w="${valToLineWidth((_ref1 = (_rel_opts_plotArea2 = rel.opts.plotArea) === null || _rel_opts_plotArea2 === void 0 ? void 0 : (_rel_opts_plotArea_border = _rel_opts_plotArea2.border) === null || _rel_opts_plotArea_border === void 0 ? void 0 : _rel_opts_plotArea_border.pt) !== null && _ref1 !== void 0 ? _ref1 : 0)}" cap="flat">${genXmlColorSelection((_rel_opts_plotArea3 = rel.opts.plotArea) === null || _rel_opts_plotArea3 === void 0 ? void 0 : (_rel_opts_plotArea_border1 = _rel_opts_plotArea3.border) === null || _rel_opts_plotArea_border1 === void 0 ? void 0 : _rel_opts_plotArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
7627
8266
  // Close shapeProp/plotArea before Legend
7628
8267
  strXml += ' <a:effectLst/>';
7629
8268
  strXml += ' </c:spPr>';
@@ -7633,7 +8272,27 @@ function xml_object_spread_props(target, source) {
7633
8272
  if (rel.opts.showLegend) {
7634
8273
  strXml += '<c:legend>';
7635
8274
  strXml += '<c:legendPos val="' + rel.opts.legendPos + '"/>';
7636
- // strXml += '<c:layout/>'
8275
+ // ECMA-376 CT_Legend sequence: legendPos -> legendEntry* -> layout -> overlay -> spPr -> txPr
8276
+ hiddenLegendIndices.forEach((idx)=>{
8277
+ strXml += `<c:legendEntry><c:idx val="${idx}"/><c:delete val="1"/></c:legendEntry>`;
8278
+ });
8279
+ if (rel.opts.legendLayout) {
8280
+ const { x, y, w, h } = rel.opts.legendLayout;
8281
+ const hasX = typeof x === 'number' && Number.isFinite(x);
8282
+ const hasY = typeof y === 'number' && Number.isFinite(y);
8283
+ const hasW = typeof w === 'number' && Number.isFinite(w);
8284
+ const hasH = typeof h === 'number' && Number.isFinite(h);
8285
+ if (hasX || hasY || hasW || hasH) {
8286
+ strXml += '<c:layout><c:manualLayout>';
8287
+ if (hasX) strXml += '<c:xMode val="edge"/>';
8288
+ if (hasY) strXml += '<c:yMode val="edge"/>';
8289
+ if (hasX) strXml += `<c:x val="${x}"/>`;
8290
+ if (hasY) strXml += `<c:y val="${y}"/>`;
8291
+ if (hasW) strXml += `<c:w val="${w}"/>`;
8292
+ if (hasH) strXml += `<c:h val="${h}"/>`;
8293
+ strXml += '</c:manualLayout></c:layout>';
8294
+ }
8295
+ }
7637
8296
  strXml += '<c:overlay val="0"/>';
7638
8297
  if (rel.opts.legendFontFace || rel.opts.legendFontSize || rel.opts.legendColor) {
7639
8298
  strXml += '<c:txPr>';
@@ -7641,7 +8300,7 @@ function xml_object_spread_props(target, source) {
7641
8300
  strXml += ' <a:lstStyle/>';
7642
8301
  strXml += ' <a:p>';
7643
8302
  strXml += ' <a:pPr>';
7644
- strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${Math.round(Number(rel.opts.legendFontSize) * 100)}">` : '<a:defRPr>';
8303
+ strXml += rel.opts.legendFontSize ? `<a:defRPr sz="${fontSizeToSz(Number(rel.opts.legendFontSize))}">` : '<a:defRPr>';
7645
8304
  if (rel.opts.legendColor) strXml += genXmlColorSelection(rel.opts.legendColor);
7646
8305
  if (rel.opts.legendFontFace) strXml += '<a:latin typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
7647
8306
  if (rel.opts.legendFontFace) strXml += '<a:ea typeface="' + encodeXmlEntities(rel.opts.legendFontFace) + '"/>';
@@ -7662,7 +8321,7 @@ function xml_object_spread_props(target, source) {
7662
8321
  // D: CHARTSPACE SHAPE PROPS
7663
8322
  strXml += '<c:spPr>';
7664
8323
  strXml += ((_rel_opts_chartArea = rel.opts.chartArea) === null || _rel_opts_chartArea === void 0 ? void 0 : _rel_opts_chartArea.fill) && (rel.opts.chartArea.fill.type === 'gradient' || rel.opts.chartArea.fill.type === 'linearGradient' || rel.opts.chartArea.fill.type === 'pattern' || rel.opts.chartArea.fill.color) ? genXmlColorSelection(rel.opts.chartArea.fill) : '<a:noFill/>';
7665
- strXml += ((_rel_opts_chartArea1 = rel.opts.chartArea) === null || _rel_opts_chartArea1 === void 0 ? void 0 : _rel_opts_chartArea1.border) ? `<a:ln w="${valToPts((_rel_opts_chartArea2 = rel.opts.chartArea) === null || _rel_opts_chartArea2 === void 0 ? void 0 : (_rel_opts_chartArea_border = _rel_opts_chartArea2.border) === null || _rel_opts_chartArea_border === void 0 ? void 0 : _rel_opts_chartArea_border.pt)}" cap="flat">${genXmlColorSelection((_rel_opts_chartArea3 = rel.opts.chartArea) === null || _rel_opts_chartArea3 === void 0 ? void 0 : (_rel_opts_chartArea_border1 = _rel_opts_chartArea3.border) === null || _rel_opts_chartArea_border1 === void 0 ? void 0 : _rel_opts_chartArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
8324
+ strXml += ((_rel_opts_chartArea1 = rel.opts.chartArea) === null || _rel_opts_chartArea1 === void 0 ? void 0 : _rel_opts_chartArea1.border) ? `<a:ln w="${valToLineWidth((_ref = (_rel_opts_chartArea2 = rel.opts.chartArea) === null || _rel_opts_chartArea2 === void 0 ? void 0 : (_rel_opts_chartArea_border = _rel_opts_chartArea2.border) === null || _rel_opts_chartArea_border === void 0 ? void 0 : _rel_opts_chartArea_border.pt) !== null && _ref !== void 0 ? _ref : 0)}" cap="flat">${genXmlColorSelection((_rel_opts_chartArea3 = rel.opts.chartArea) === null || _rel_opts_chartArea3 === void 0 ? void 0 : (_rel_opts_chartArea_border1 = _rel_opts_chartArea3.border) === null || _rel_opts_chartArea_border1 === void 0 ? void 0 : _rel_opts_chartArea_border1.color)}</a:ln>` : '<a:ln><a:noFill/></a:ln>';
7666
8325
  strXml += ' <a:effectLst/>';
7667
8326
  strXml += '</c:spPr>';
7668
8327
  // E: DATA (Add relID)
@@ -7688,13 +8347,13 @@ function xml_object_spread_props(target, source) {
7688
8347
  * (`standards/ecma/part-23_drawingml-reference-material-drawingml-charts.txt`).
7689
8348
  * An empty `<a:defRPr/>` drops dataLabelFont* on scatter labels (gitbrent #1348).
7690
8349
  */ function genXmlDataLabelDefRPr(opts) {
7691
- return `<a:defRPr sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>` + '</a:defRPr>';
8350
+ return `<a:defRPr sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" u="none" strike="noStrike">` + `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>` + `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>` + '</a:defRPr>';
7692
8351
  }
7693
8352
  /**
7694
8353
  * Rich-text body for a custom chart data label (`c:tx` / `c:rich`).
7695
8354
  * Escapes text and applies data-label font options.
7696
8355
  */ function genXmlDataLabelRichText(text, opts) {
7697
- const sz = Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100);
8356
+ const sz = fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12));
7698
8357
  const lang = opts.lang || 'en-US';
7699
8358
  let xml = '<c:tx><c:rich><a:bodyPr/><a:lstStyle/><a:p><a:r>';
7700
8359
  xml += `<a:rPr lang="${lang}" dirty="0" sz="${sz}" b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}">`;
@@ -7764,9 +8423,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7764
8423
  case core_enums_CHART_TYPE.RADAR:
7765
8424
  // 1: Start Chart
7766
8425
  strXml += `<c:${chartType}Chart>`;
7767
- // Area charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.3.17).
8426
+ // Area and line charts: `c:grouping` / ST_Grouping (ECMA-376 §5.7.2.76 / §5.7.2.97 / §5.7.3.17).
7768
8427
  // `barGrouping` is the public option name; the element is not `c:barGrouping` (that is ST_BarGrouping on bar charts).
7769
- if (chartType === core_enums_CHART_TYPE.AREA) {
8428
+ if (chartType === core_enums_CHART_TYPE.AREA || chartType === core_enums_CHART_TYPE.LINE) {
7770
8429
  strXml += '<c:grouping val="' + resolveAreaGrouping(opts.barGrouping) + '"/>';
7771
8430
  }
7772
8431
  if (chartType === core_enums_CHART_TYPE.BAR || chartType === core_enums_CHART_TYPE.BAR3D) {
@@ -7832,7 +8491,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7832
8491
  if (seriesColor === 'transparent') {
7833
8492
  strXml += '<a:noFill/>';
7834
8493
  } else if (opts.chartColorsOpacity) {
7835
- strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${Math.round(opts.chartColorsOpacity * 1000)}"/>`) + '</a:solidFill>';
8494
+ strXml += '<a:solidFill>' + createColorElement(seriesColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
7836
8495
  } else {
7837
8496
  strXml += '<a:solidFill>' + createColorElement(seriesColor) + '</a:solidFill>';
7838
8497
  }
@@ -7840,11 +8499,13 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7840
8499
  if (opts.lineSize === 0) {
7841
8500
  strXml += '<a:ln><a:noFill/></a:ln>';
7842
8501
  } else {
7843
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(seriesColor)}</a:solidFill>`;
8502
+ var _opts_lineSize;
8503
+ strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(seriesColor)}</a:solidFill>`;
7844
8504
  strXml += '<a:prstDash val="' + resolveSeriesLineDash(obj.lineDash, opts.lineDash) + '"/><a:round/></a:ln>';
7845
8505
  }
7846
8506
  } else if (opts.dataBorder) {
7847
- strXml += `<a:ln w="${valToPts(opts.dataBorder.pt)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8507
+ var _opts_dataBorder_pt;
8508
+ strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
7848
8509
  }
7849
8510
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
7850
8511
  strXml += ' </c:spPr>';
@@ -7860,7 +8521,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7860
8521
  strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
7861
8522
  if (opts.dataLabelBkgrdColors) strXml += `<c:spPr><a:solidFill>${createColorElement(seriesColor)}</a:solidFill></c:spPr>`;
7862
8523
  strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
7863
- strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
8524
+ strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
7864
8525
  strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
7865
8526
  strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
7866
8527
  strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
@@ -7875,9 +8536,10 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7875
8536
  }
7876
8537
  // 'c:marker' tag: `lineDataSymbol`
7877
8538
  if (chartType === core_enums_CHART_TYPE.LINE || chartType === core_enums_CHART_TYPE.RADAR) {
8539
+ var _opts_lineDataSymbolLineSize;
7878
8540
  strXml += '<c:marker>';
7879
8541
  strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
7880
- if (opts.lineDataSymbolSize) strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
8542
+ if (opts.lineDataSymbolSize) strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`; // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
7881
8543
  strXml += ' <c:spPr>';
7882
8544
  // NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
7883
8545
  {
@@ -7885,7 +8547,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7885
8547
  const markerColor = (_obj_color1 = obj.color) !== null && _obj_color1 !== void 0 ? _obj_color1 : chartColors[dataIndex + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : dataIndex];
7886
8548
  strXml += markerColor === 'transparent' ? ' <a:noFill/>' : ` <a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
7887
8549
  }
7888
- strXml += ` <a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8550
+ strXml += ` <a:ln w="${clampLineWidth((_opts_lineDataSymbolLineSize = opts.lineDataSymbolLineSize) !== null && _opts_lineDataSymbolLineSize !== void 0 ? _opts_lineDataSymbolLineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || seriesColor)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
7889
8551
  strXml += ' <a:effectLst/>';
7890
8552
  strXml += ' </c:spPr>';
7891
8553
  strXml += '</c:marker>';
@@ -7996,7 +8658,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
7996
8658
  strXml += ' <a:bodyPr/>';
7997
8659
  strXml += ' <a:lstStyle/>';
7998
8660
  strXml += ' <a:p><a:pPr>';
7999
- strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
8661
+ strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
8000
8662
  strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
8001
8663
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
8002
8664
  strXml += ' </a:defRPr>';
@@ -8014,16 +8676,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8014
8676
  }
8015
8677
  // 4: Add more chart options (gapWidth, line Marker, etc.)
8016
8678
  if (chartType === core_enums_CHART_TYPE.BAR) {
8017
- strXml += ` <c:gapWidth val="${opts.barGapWidthPct}"/>`;
8679
+ var _opts_barGapWidthPct;
8680
+ strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct = opts.barGapWidthPct) !== null && _opts_barGapWidthPct !== void 0 ? _opts_barGapWidthPct : 150, 0, 500)}"/>`;
8018
8681
  // istevkovski/prioritize-overlap: honor barOverlapPct even when grouping is stacked
8019
8682
  // (also treat 0 as explicit — upstream used a truthy check that skipped 0)
8020
8683
  {
8021
- const overlap = typeof opts.barOverlapPct === 'number' ? opts.barOverlapPct : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
8684
+ const overlap = typeof opts.barOverlapPct === 'number' ? clampInt(opts.barOverlapPct, -100, 100) : (opts.barGrouping || '').includes('tacked') ? 100 : 0;
8022
8685
  strXml += ` <c:overlap val="${overlap}"/>`;
8023
8686
  }
8024
8687
  } else if (chartType === core_enums_CHART_TYPE.BAR3D) {
8025
- strXml += ` <c:gapWidth val="${opts.barGapWidthPct}"/>`;
8026
- strXml += ` <c:gapDepth val="${opts.barGapDepthPct}"/>`;
8688
+ var _opts_barGapWidthPct1, _opts_barGapDepthPct;
8689
+ strXml += ` <c:gapWidth val="${clampInt((_opts_barGapWidthPct1 = opts.barGapWidthPct) !== null && _opts_barGapWidthPct1 !== void 0 ? _opts_barGapWidthPct1 : 150, 0, 500)}"/>`;
8690
+ strXml += ` <c:gapDepth val="${clampInt((_opts_barGapDepthPct = opts.barGapDepthPct) !== null && _opts_barGapDepthPct !== void 0 ? _opts_barGapDepthPct : 150, 0, 500)}"/>`;
8027
8691
  strXml += ' <c:shape val="' + opts.bar3DShape + '"/>';
8028
8692
  } else if (chartType === core_enums_CHART_TYPE.LINE) {
8029
8693
  strXml += ' <c:marker val="1"/>';
@@ -8069,14 +8733,15 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8069
8733
  if (tmpSerColor === 'transparent') {
8070
8734
  strXml += '<a:noFill/>';
8071
8735
  } else if (opts.chartColorsOpacity) {
8072
- strXml += '<a:solidFill>' + createColorElement(tmpSerColor, '<a:alpha val="' + Math.round(opts.chartColorsOpacity * 1000).toString() + '"/>') + '</a:solidFill>';
8736
+ strXml += '<a:solidFill>' + createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`) + '</a:solidFill>';
8073
8737
  } else {
8074
8738
  strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
8075
8739
  }
8076
8740
  if (opts.lineSize === 0) {
8077
8741
  strXml += '<a:ln><a:noFill/></a:ln>';
8078
8742
  } else {
8079
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8743
+ var _opts_lineSize;
8744
+ strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="${createLineCap(opts.lineCap)}"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8080
8745
  strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
8081
8746
  }
8082
8747
  // Shadow
@@ -8085,11 +8750,12 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8085
8750
  strXml += ' </c:spPr>';
8086
8751
  // 'c:marker' tag: `lineDataSymbol`
8087
8752
  {
8753
+ var _opts_lineDataSymbolLineSize;
8088
8754
  strXml += '<c:marker>';
8089
8755
  strXml += ' <c:symbol val="' + opts.lineDataSymbol + '"/>';
8090
8756
  if (opts.lineDataSymbolSize) {
8091
8757
  // Defaults to "auto" otherwise (but this is usually too small, so there is a default)
8092
- strXml += `<c:size val="${opts.lineDataSymbolSize}"/>`;
8758
+ strXml += `<c:size val="${clampInt(opts.lineDataSymbolSize, 2, 72)}"/>`;
8093
8759
  }
8094
8760
  strXml += '<c:spPr>';
8095
8761
  // NateRadebaugh/transparent-markers: `'transparent'` → noFill (same as series fill)
@@ -8098,7 +8764,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8098
8764
  const markerColor = (_obj_color1 = obj.color) !== null && _obj_color1 !== void 0 ? _obj_color1 : chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx];
8099
8765
  strXml += markerColor === 'transparent' ? '<a:noFill/>' : `<a:solidFill>${createColorElement(markerColor)}</a:solidFill>`;
8100
8766
  }
8101
- strXml += `<a:ln w="${opts.lineDataSymbolLineSize}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || obj.color || chartColors[colorIndex % chartColors.length])}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8767
+ strXml += `<a:ln w="${clampLineWidth((_opts_lineDataSymbolLineSize = opts.lineDataSymbolLineSize) !== null && _opts_lineDataSymbolLineSize !== void 0 ? _opts_lineDataSymbolLineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.lineDataSymbolLineColor || obj.color || chartColors[colorIndex % chartColors.length])}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8102
8768
  strXml += '<a:effectLst/>';
8103
8769
  strXml += '</c:spPr>';
8104
8770
  strXml += '</c:marker>';
@@ -8287,7 +8953,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8287
8953
  strXml += ' <a:bodyPr/>';
8288
8954
  strXml += ' <a:lstStyle/>';
8289
8955
  strXml += ' <a:p><a:pPr>';
8290
- strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" strike="noStrike" sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
8956
+ strXml += ` <a:defRPr b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
8291
8957
  strXml += ' <a:solidFill>' + createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000")) + '</a:solidFill>';
8292
8958
  strXml += ' <a:latin typeface="' + (encodeXmlEntities(opts.dataLabelFontFace) || 'Arial') + '"/>';
8293
8959
  strXml += ' </a:defRPr>';
@@ -8343,16 +9009,18 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8343
9009
  if (tmpSerColor === 'transparent') {
8344
9010
  strXml += '<a:noFill/>';
8345
9011
  } else if (opts.chartColorsOpacity) {
8346
- strXml += `<a:solidFill>${createColorElement(tmpSerColor, '<a:alpha val="' + Math.round(opts.chartColorsOpacity * 1000).toString() + '"/>')}</a:solidFill>`;
9012
+ strXml += `<a:solidFill>${createColorElement(tmpSerColor, `<a:alpha val="${clampAlphaPct(100 - opts.chartColorsOpacity)}"/>`)}</a:solidFill>`;
8347
9013
  } else {
8348
9014
  strXml += '<a:solidFill>' + createColorElement(tmpSerColor) + '</a:solidFill>';
8349
9015
  }
8350
9016
  if (opts.lineSize === 0) {
8351
9017
  strXml += '<a:ln><a:noFill/></a:ln>';
8352
9018
  } else if (opts.dataBorder) {
8353
- strXml += `<a:ln w="${valToPts(opts.dataBorder.pt)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
9019
+ var _opts_dataBorder_pt;
9020
+ strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8354
9021
  } else {
8355
- strXml += `<a:ln w="${valToPts(opts.lineSize)}" cap="flat"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
9022
+ var _opts_lineSize;
9023
+ strXml += `<a:ln w="${valToLineWidth((_opts_lineSize = opts.lineSize) !== null && _opts_lineSize !== void 0 ? _opts_lineSize : 0)}" cap="flat"><a:solidFill>${createColorElement(tmpSerColor)}</a:solidFill>`;
8356
9024
  strXml += `<a:prstDash val="${resolveSeriesLineDash(obj.lineDash, opts.lineDash)}"/><a:round/></a:ln>`;
8357
9025
  }
8358
9026
  // Shadow
@@ -8415,7 +9083,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8415
9083
  strXml += '<c:dLbls>';
8416
9084
  strXml += `<c:numFmt formatCode="${encodeXmlEntities(opts.dataLabelFormatCode) || 'General'}" sourceLinked="0"/>`;
8417
9085
  strXml += '<c:txPr><a:bodyPr/><a:lstStyle/><a:p><a:pPr>';
8418
- strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${Math.round(Math.round(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" u="none">`;
9086
+ strXml += `<a:defRPr b="${opts.dataLabelFontBold ? 1 : 0}" i="${opts.dataLabelFontItalic ? 1 : 0}" strike="noStrike" sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" u="none">`;
8419
9087
  strXml += `<a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill>`;
8420
9088
  strXml += `<a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
8421
9089
  strXml += '</a:defRPr></a:pPr></a:p></c:txPr>';
@@ -8442,7 +9110,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8442
9110
  case core_enums_CHART_TYPE.DOUGHNUT:
8443
9111
  case core_enums_CHART_TYPE.PIE:
8444
9112
  {
8445
- var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition;
9113
+ var _optsChartData_labels, _optsChartData_values, _opts_dataLabelPosition, _opts_firstSliceAng;
8446
9114
  const optsChartData = data[0];
8447
9115
  // NOTE: chart data arrays are always populated at render time; guarded locals keep this null-safe without changing output
8448
9116
  const chartDataLabels = (_optsChartData_labels = optsChartData.labels) !== null && _optsChartData_labels !== void 0 ? _optsChartData_labels : [];
@@ -8479,7 +9147,9 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8479
9147
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
8480
9148
  }
8481
9149
  strXml += ' </c:spPr>';
8482
- // strXml += '<c:explosion val="0"/>'
9150
+ if (typeof opts.chartPieExplosion === 'number' && Number.isFinite(opts.chartPieExplosion) && opts.chartPieExplosion > 0) {
9151
+ strXml += `<c:explosion val="${clampInt(opts.chartPieExplosion, 0, 1000)}"/>`;
9152
+ }
8483
9153
  // 2: "Data Point" block for every data row
8484
9154
  chartDataLabels[0].forEach((_label, idx)=>{
8485
9155
  strXml += '<c:dPt>';
@@ -8488,7 +9158,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8488
9158
  strXml += ' <c:spPr>';
8489
9159
  strXml += `<a:solidFill>${createColorElement(chartColors[idx + 1 > chartColors.length ? Math.floor(Math.random() * chartColors.length) : idx])}</a:solidFill>`;
8490
9160
  if (opts.dataBorder) {
8491
- strXml += `<a:ln w="${valToPts(opts.dataBorder.pt)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
9161
+ var _opts_dataBorder_pt;
9162
+ strXml += `<a:ln w="${valToLineWidth((_opts_dataBorder_pt = opts.dataBorder.pt) !== null && _opts_dataBorder_pt !== void 0 ? _opts_dataBorder_pt : 0)}" cap="flat"><a:solidFill>${createColorElement(opts.dataBorder.color)}</a:solidFill><a:prstDash val="solid"/><a:round/></a:ln>`;
8492
9163
  }
8493
9164
  strXml += createShadowElement(resolveShadowOptions(opts.shadow));
8494
9165
  strXml += ' </c:spPr>';
@@ -8503,7 +9174,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8503
9174
  strXml += ' <a:lstStyle/>';
8504
9175
  strXml += ' <a:p>';
8505
9176
  strXml += ' <a:pPr>';
8506
- strXml += ` <a:defRPr sz="${Math.round((opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12)) * 100)}" b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
9177
+ strXml += ` <a:defRPr sz="${fontSizeToSz(opts.dataLabelFontSize || (/* inlined export .DEF_FONT_SIZE */12))}" b="${opts.dataLabelFontBold ? '1' : '0'}" i="${opts.dataLabelFontItalic ? '1' : '0'}" u="none" strike="noStrike">`;
8507
9178
  strXml += ` <a:solidFill>${createColorElement(opts.dataLabelColor || (/* inlined export .DEF_FONT_COLOR */"000000"))}</a:solidFill><a:latin typeface="${encodeXmlEntities(opts.dataLabelFontFace) || 'Arial'}"/>`;
8508
9179
  strXml += ' </a:defRPr>';
8509
9180
  strXml += ' </a:pPr>';
@@ -8545,8 +9216,8 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8545
9216
  strXml += ' </c:val>';
8546
9217
  // 4: Close "SERIES"
8547
9218
  strXml += ' </c:ser>';
8548
- strXml += ` <c:firstSliceAng val="${opts.firstSliceAng ? Math.round(opts.firstSliceAng) : 0}"/>`;
8549
- if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${typeof opts.holeSize === 'number' ? opts.holeSize : '50'}"/>`;
9219
+ strXml += ` <c:firstSliceAng val="${clampInt((_opts_firstSliceAng = opts.firstSliceAng) !== null && _opts_firstSliceAng !== void 0 ? _opts_firstSliceAng : 0, 0, 360)}"/>`;
9220
+ if (chartType === core_enums_CHART_TYPE.DOUGHNUT) strXml += `<c:holeSize val="${clampInt(typeof opts.holeSize === 'number' ? opts.holeSize : 50, 1, 90)}"/>`;
8550
9221
  strXml += '</c:' + chartType + 'Chart>';
8551
9222
  break;
8552
9223
  }
@@ -8558,7 +9229,7 @@ function makeChartType(chartType, data, opts, valAxisId, catAxisId, _isMultiType
8558
9229
  }
8559
9230
 
8560
9231
  ;// CONCATENATED MODULE: ./src/charts/workbook.ts
8561
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
9232
+ function workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8562
9233
  try {
8563
9234
  var info = gen[key](arg);
8564
9235
  var value = info.value;
@@ -8569,16 +9240,16 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8569
9240
  if (info.done) resolve(value);
8570
9241
  else Promise.resolve(value).then(_next, _throw);
8571
9242
  }
8572
- function _async_to_generator(fn) {
9243
+ function workbook_async_to_generator(fn) {
8573
9244
  return function() {
8574
9245
  var self = this, args = arguments;
8575
9246
  return new Promise(function(resolve, reject) {
8576
9247
  var gen = fn.apply(self, args);
8577
9248
  function _next(value) {
8578
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
9249
+ workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
8579
9250
  }
8580
9251
  function _throw(err) {
8581
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
9252
+ workbook_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
8582
9253
  }
8583
9254
  _next(undefined);
8584
9255
  });
@@ -8617,7 +9288,7 @@ function makeNumberStyles(formats) {
8617
9288
  * @param {JSZip} zip - file that the resulting XLSX should be added to
8618
9289
  * @return {Promise} promise of generating the XLSX file
8619
9290
  */ function createExcelWorksheet(chartObject, zip) {
8620
- return _async_to_generator(function*() {
9291
+ return workbook_async_to_generator(function*() {
8621
9292
  const zipExcel = new jszip_namespaceObject.JSZip();
8622
9293
  const dataTableStyles = getDataTableStyles(chartObject);
8623
9294
  addCoreWorkbookFiles(zipExcel, dataTableStyles.customFormats);
@@ -17111,181 +17782,29 @@ function convert_to_eot_object_spread(target) {
17111
17782
  if (typeof opts.inflate !== 'function') {
17112
17783
  throw new Error('WOFF conversion requires options.inflate (pako)');
17113
17784
  }
17114
- const ttfBuffer = woff2ttf(fontBuffer, opts);
17115
- ttfObject = new TTFReader(opts).read(ttfBuffer);
17116
- } else {
17117
- throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
17118
- }
17119
- const ttfBuffer = new TTFWriter(opts).write(ttfObject);
17120
- return ttf2eot(ttfBuffer, opts);
17121
- }
17122
-
17123
- ;// CONCATENATED MODULE: ./src/gen-fonts.ts
17124
- /**
17125
- * PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
17126
- *
17127
- * `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
17128
- * writes Font parts, fntdata content types, or Presentation font relationships.
17129
- * Callers supply their own font bytes via `addFont` and must have a license
17130
- * that permits embedding those files. This library ships no font files.
17131
- *
17132
- * Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
17133
- * (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
17134
- * vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
17135
- * (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
17136
- */ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17137
- try {
17138
- var info = gen[key](arg);
17139
- var value = info.value;
17140
- } catch (error) {
17141
- reject(error);
17142
- return;
17143
- }
17144
- if (info.done) resolve(value);
17145
- else Promise.resolve(value).then(_next, _throw);
17146
- }
17147
- function gen_fonts_async_to_generator(fn) {
17148
- return function() {
17149
- var self = this, args = arguments;
17150
- return new Promise(function(resolve, reject) {
17151
- var gen = fn.apply(self, args);
17152
- function _next(value) {
17153
- gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17154
- }
17155
- function _throw(err) {
17156
- gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17157
- }
17158
- _next(undefined);
17159
- });
17160
- };
17161
- }
17162
-
17163
-
17164
- /** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
17165
- const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
17166
- /**
17167
- * Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
17168
- * Lazy-loads pako only for WOFF.
17169
- */ function fontToEot(type, fontBuffer) {
17170
- return gen_fonts_async_to_generator(function*() {
17171
- const options = {
17172
- hinting: true
17173
- };
17174
- if (type === 'woff') {
17175
- // pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
17176
- const { inflate } = yield import("pako");
17177
- options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
17178
- }
17179
- return convertToEot(type, fontBuffer, options);
17180
- })();
17181
- }
17182
- function toFntdata(fontType, fontFile) {
17183
- return gen_fonts_async_to_generator(function*() {
17184
- switch(fontType){
17185
- case 'eot':
17186
- // EOT bytes are stored as-is under ppt/fonts/*.fntdata
17187
- return fontFile;
17188
- case 'ttf':
17189
- case 'otf':
17190
- case 'woff':
17191
- return yield fontToEot(fontType, fontFile);
17192
- default:
17193
- throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
17194
- }
17195
- })();
17196
- }
17197
- function ensureFntdataContentType(contentTypesXml) {
17198
- if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
17199
- const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
17200
- // Prefer inserting among other Defaults near the top of <Types>
17201
- if (/<Default\b/i.test(contentTypesXml)) {
17202
- return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
17203
- }
17204
- return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
17205
- }
17206
- function ensurePresentationFontAttrs(presentationXml) {
17207
- let xml = presentationXml;
17208
- if (/embedTrueTypeFonts=/i.test(xml)) {
17209
- xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
17210
- } else {
17211
- xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
17212
- }
17213
- if (/saveSubsetFonts=/i.test(xml)) {
17214
- xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
17215
- } else {
17216
- xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
17217
- }
17218
- return xml;
17219
- }
17220
- function buildEmbeddedFontLst(fonts) {
17221
- let lst = '<p:embeddedFontLst>';
17222
- for (const font of fonts){
17223
- lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
17224
- }
17225
- lst += '</p:embeddedFontLst>';
17226
- return lst;
17227
- }
17228
- function escapeXmlAttr(value) {
17229
- return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
17230
- }
17231
- function ensureEmbeddedFontLst(presentationXml, fonts) {
17232
- const lst = buildEmbeddedFontLst(fonts);
17233
- if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
17234
- // Replace existing list wholesale (export always owns the registered set)
17235
- return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
17236
- }
17237
- // ISO 29500: embeddedFontLst precedes defaultTextStyle.
17238
- // Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
17239
- const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
17240
- if (dtsOpen) {
17241
- return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
17242
- }
17243
- // Fallback: before closing presentation
17244
- return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
17245
- }
17246
- function appendFontRelationships(relsXml, fonts) {
17247
- const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
17248
- if (!nodes) return relsXml;
17249
- return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
17250
- }
17251
- /**
17252
- * Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
17253
- * Mutates `zip` in place (before generateAsync).
17254
- */ function embedFontsIntoZip(zip, fonts) {
17255
- return gen_fonts_async_to_generator(function*() {
17256
- if (fonts.length === 0) return;
17257
- const prepared = [];
17258
- let nextRid = FONT_RID_START;
17259
- for (const font of fonts){
17260
- prepared.push({
17261
- name: font.fontFace,
17262
- data: yield toFntdata(font.fontType, font.fontFile),
17263
- rid: nextRid++
17264
- });
17265
- }
17266
- const contentTypesFile = zip.file('[Content_Types].xml');
17267
- if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
17268
- addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
17269
- const presentationFile = zip.file('ppt/presentation.xml');
17270
- if (!presentationFile) throw new Error('ppt/presentation.xml not found');
17271
- let presentationXml = yield presentationFile.async('string');
17272
- presentationXml = ensurePresentationFontAttrs(presentationXml);
17273
- presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
17274
- addZipFile(zip, 'ppt/presentation.xml', presentationXml);
17275
- const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
17276
- if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
17277
- addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
17278
- for (const font of prepared){
17279
- addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
17280
- binary: true,
17281
- compression: 'DEFLATE'
17282
- });
17283
- }
17284
- })();
17785
+ const ttfBuffer = woff2ttf(fontBuffer, opts);
17786
+ ttfObject = new TTFReader(opts).read(ttfBuffer);
17787
+ } else {
17788
+ throw new Error(`Unsupported font type for EOT conversion: ${String(type)}`);
17789
+ }
17790
+ const ttfBuffer = new TTFWriter(opts).write(ttfObject);
17791
+ return ttf2eot(ttfBuffer, opts);
17285
17792
  }
17286
17793
 
17287
- ;// CONCATENATED MODULE: ./src/gen-media.ts
17288
- function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17794
+ ;// CONCATENATED MODULE: ./src/gen-fonts.ts
17795
+ /**
17796
+ * PptxGenJS: Opt-in embedded TrueType fonts (OOXML `ppt/fonts/*.fntdata`)
17797
+ *
17798
+ * `embedFontsIntoZip` is a no-op when `fonts` is empty — default export never
17799
+ * writes Font parts, fntdata content types, or Presentation font relationships.
17800
+ * Callers supply their own font bytes via `addFont` and must have a license
17801
+ * that permits embedding those files. This library ships no font files.
17802
+ *
17803
+ * Font-embed orchestration absorbed from MIT `pptx-embed-fonts`
17804
+ * (https://github.com/liyao1520/pptx-embed-fonts). TTF/OTF/WOFF→EOT conversion is a
17805
+ * vendored subset of MIT `fonteditor-core` under `src/vendor/fonteditor-core`
17806
+ * (https://github.com/kekee000/fonteditor-core). WOFF inflate uses pako 3.
17807
+ */ function gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
17289
17808
  try {
17290
17809
  var info = gen[key](arg);
17291
17810
  var value = info.value;
@@ -17296,364 +17815,143 @@ function gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key,
17296
17815
  if (info.done) resolve(value);
17297
17816
  else Promise.resolve(value).then(_next, _throw);
17298
17817
  }
17299
- function gen_media_async_to_generator(fn) {
17818
+ function gen_fonts_async_to_generator(fn) {
17300
17819
  return function() {
17301
- var self = this, args = arguments;
17302
- return new Promise(function(resolve, reject) {
17303
- var gen = fn.apply(self, args);
17304
- function _next(value) {
17305
- gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17306
- }
17307
- function _throw(err) {
17308
- gen_media_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17309
- }
17310
- _next(undefined);
17311
- });
17312
- };
17313
- }
17314
- /**
17315
- * PptxGenJS: Media Methods
17316
- */
17317
-
17318
- /** Images are measured in pixels; PowerPoint slide dimensions are inches at 96 DPI */ const IMAGE_DPI = 96;
17319
- /**
17320
- * Read the natural pixel dimensions of a raster image from its header bytes.
17321
- * Self-contained replacement for the `image-size` package (PNG/JPEG/GIF/BMP).
17322
- * Format refs: PNG spec §11.2.2 (IHDR is always the first chunk, width/height big-endian at bytes 16-24);
17323
- * JPEG (JFIF) SOF0-SOF15 markers carry height then width big-endian; GIF87a/89a logical-screen descriptor
17324
- * little-endian at bytes 6-10; BMP DIB header little-endian at bytes 18-26. SVG is sized separately (gen-objects).
17325
- *
17326
- * Declared dims are header-only (we never decode pixels), so clamp to a sane ceiling: a maliciously crafted
17327
- * header can claim 0xFFFFFFFF px and emit a ~44-million-inch slide (a corrupt pptx). PowerPoint's max slide is
17328
- * 56 in (5376 px @ 96 DPI); 100 000 px is generous headroom for legit high-res sources while rejecting bombs.
17329
- */ const MAX_IMAGE_PX = 100000;
17330
- function imageDimensions(bytes) {
17331
- if (bytes.length < 10) return {} // every supported header's dims start at/after byte 6
17332
- ;
17333
- const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
17334
- const sane = (w, h)=>w > 0 && h > 0 && w <= MAX_IMAGE_PX && h <= MAX_IMAGE_PX ? {
17335
- width: w,
17336
- height: h
17337
- } : {};
17338
- // PNG: 8-byte signature 89 50 4E 47 0D 0A 1A 0A, then IHDR length(4)+type(4)+width(4)+height(4)
17339
- if (bytes[0] === 0x89 && bytes[1] === 0x50 && bytes[2] === 0x4e && bytes[3] === 0x47) {
17340
- if (bytes.length < 24) return {};
17341
- return sane(dv.getUint32(16, false), dv.getUint32(20, false));
17342
- }
17343
- // GIF: 'GIF87a'/'GIF89a', logical screen width/height little-endian at bytes 6-10
17344
- if (bytes[0] === 0x47 && bytes[1] === 0x49 && bytes[2] === 0x46) {
17345
- return sane(dv.getUint16(6, true), dv.getUint16(8, true));
17346
- }
17347
- // BMP: 'BM', DIB width/height little-endian at bytes 18-26 (signed; height may be negative = top-down)
17348
- if (bytes[0] === 0x42 && bytes[1] === 0x4d) {
17349
- if (bytes.length < 26) return {};
17350
- return sane(Math.abs(dv.getInt32(18, true)), Math.abs(dv.getInt32(22, true)));
17351
- }
17352
- // JPEG: FF D8, then walk marker segments until a Start-Of-Frame (C0-CF except C4/C8/CC) carries the dims
17353
- if (bytes[0] === 0xff && bytes[1] === 0xd8) {
17354
- let off = 2;
17355
- while(off + 9 <= bytes.length){
17356
- if (bytes[off] !== 0xff) {
17357
- off++;
17358
- continue;
17359
- }
17360
- const marker = bytes[off + 1];
17361
- const isSOF = marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc;
17362
- if (isSOF) return sane(dv.getUint16(off + 7, false), dv.getUint16(off + 5, false));
17363
- if (marker === 0xd8 || marker === 0xd9 || marker >= 0xd0 && marker <= 0xd7) {
17364
- off += 2;
17365
- continue;
17366
- } // no length
17367
- const segLen = dv.getUint16(off + 2, false);
17368
- off += 2 + segLen;
17369
- }
17370
- }
17371
- return {};
17372
- }
17373
- /**
17374
- * Natural pixel size from encoded image bytes (PNG/JPEG/GIF/BMP headers).
17375
- * Returns null when the payload is missing, not a supported raster, or claims 0×0
17376
- * (`imageDimensions` already rejects zero and bomb-sized headers).
17377
- *
17378
- * contain/cover `a:srcRect` (ECMA-376 §5.1.10.55) needs the *blip* aspect, not the
17379
- * placement box — using w/h as imgSize makes srcRect a no-op whenever they match the sizing box.
17380
- */ function getImagePixelSize(base64Data) {
17381
- if (typeof base64Data !== 'string' || !base64Data || base64Data === IMG_BROKEN) return null;
17382
- try {
17383
- const dims = imageDimensions(base64ToBytes(base64Data));
17384
- if (dims.width && dims.height) return {
17385
- w: dims.width,
17386
- h: dims.height
17387
- };
17388
- } catch (unused) {
17389
- // unrecognized / truncated payload
17390
- }
17391
- return null;
17392
- }
17393
- /**
17394
- * Size images added without `w`/`h` to their natural dimensions (issue #34)
17395
- * @note must run after `encodeSlideMediaRels` has resolved - it reads the encoded image bytes
17396
- * @param {PresSlide | SlideLayout} layout - slide layout
17397
- */ function applyNaturalImageSizes(layout) {
17398
- layout._slideObjects.filter((obj)=>{
17399
- var _obj_options;
17400
- return obj._type === (/* inlined export .SLIDE_OBJECT_TYPES.image */"image") && ((_obj_options = obj.options) === null || _obj_options === void 0 ? void 0 : _obj_options._sizeFromImage);
17401
- }).forEach((obj)=>{
17402
- var _layout__relsMedia_find;
17403
- const strData = (_layout__relsMedia_find = layout._relsMedia.find((rel)=>rel.rId === obj.imageRid)) === null || _layout__relsMedia_find === void 0 ? void 0 : _layout__relsMedia_find.data;
17404
- if (!obj.options || typeof strData !== 'string' || !strData || strData === IMG_BROKEN) return;
17405
- // An image bound to a placeholder inherits the placeholder's w/h (slide XML resolves it); sizing it
17406
- // to its natural pixel dims instead would collapse it to ~px/96 inches (issue #996).
17407
- if (obj.options.placeholder) return;
17408
- try {
17409
- const dims = imageDimensions(base64ToBytes(strData));
17410
- if (dims.width && dims.height) {
17411
- obj.options.w = dims.width / IMAGE_DPI;
17412
- obj.options.h = dims.height / IMAGE_DPI;
17413
- }
17414
- } catch (_ex) {
17415
- // Unreadable/unsupported image: keep the 1x1 inch default
17416
- }
17417
- });
17418
- }
17419
- /** Select relations that still need their local or remote media encoded. */ function getMediaCandidates(layout) {
17420
- return layout._relsMedia.filter((rel)=>!rel.isLinked && rel.type !== 'online' && !rel.data && (!rel.path || rel.path && !rel.path.includes('preencoded')));
17421
- }
17422
- /**
17423
- * Mark repeated source paths so only the first relation performs I/O.
17424
- *
17425
- * Mutates `isDuplicate`; subsequent helpers copy the first result to every duplicate.
17426
- */ function markDuplicateMedia(candidates) {
17427
- const paths = new Set();
17428
- candidates.forEach((rel)=>{
17429
- var _rel_path;
17430
- const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17431
- rel.isDuplicate = paths.has(path);
17432
- paths.add(path);
17433
- });
17434
- }
17435
- /** Copy an encoded or broken source relation's data to every duplicate path. */ function copyMediaToDuplicates(candidates, rel) {
17436
- candidates.filter((duplicate)=>duplicate.isDuplicate && duplicate.path === rel.path).forEach((duplicate)=>duplicate.data = rel.data);
17437
- }
17438
- /** Mark a failed source and all duplicates with the sentinel expected by package generation. */ function markMediaBroken(candidates, rel) {
17439
- rel.data = IMG_BROKEN;
17440
- copyMediaToDuplicates(candidates, rel);
17441
- }
17442
- function mediaLoadFailed(candidates, rel, message, onError) {
17443
- markMediaBroken(candidates, rel);
17444
- if (onError === 'placeholder') {
17445
- console.warn(`WARN: Unable to load image, using placeholder: ${rel.path}${message ? ` (${message})` : ''}`);
17446
- return 'done';
17447
- }
17448
- throw new Error(message);
17449
- }
17450
- /**
17451
- * Read one Node-local media source and encode it as base64.
17452
- *
17453
- * A read failure is recorded before rejection so duplicate references remain consistent.
17454
- */ function readNodeMediaFile(rel, candidates, fs, onError) {
17455
- return gen_media_async_to_generator(function*() {
17456
- try {
17457
- var _rel_path;
17458
- var _rel_fill;
17459
- const relPath = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17460
- const svgFill = typeof ((_rel_fill = rel.fill) === null || _rel_fill === void 0 ? void 0 : _rel_fill.color) === 'string' ? rel.fill.color : undefined;
17461
- if (svgFill && (rel.type === 'image/svg+xml' || rel.extn === 'svg')) {
17462
- const svgText = applySvgFillColor(fs.readFileSync(relPath, 'utf8'), svgFill);
17463
- rel.data = utf8ToBase64(svgText);
17464
- } else {
17465
- const bitmap = fs.readFileSync(relPath);
17466
- rel.data = bytesToBase64(new Uint8Array(bitmap));
17467
- if (svgFill && typeof rel.data === 'string') {
17468
- rel.data = applySvgFillToDataUrl(rel.data, svgFill);
17469
- }
17470
- }
17471
- copyMediaToDuplicates(candidates, rel);
17472
- return 'done';
17473
- } catch (ex) {
17474
- return mediaLoadFailed(candidates, rel, `ERROR: Unable to read media: "${rel.path}"\n${String(ex)}`, onError);
17475
- }
17476
- })();
17477
- }
17478
- /**
17479
- * Load one HTTP(S) source in Node, draining error responses and handling both request and response errors.
17480
- */ function loadNodeMediaUrl(rel, candidates, https, http, onError) {
17481
- var _rel_path;
17482
- const httpMod = ((_rel_path = rel.path) === null || _rel_path === void 0 ? void 0 : _rel_path.startsWith('http://')) ? http : https;
17483
- return new Promise((resolve, reject)=>{
17484
- const fail = (message)=>{
17485
- try {
17486
- resolve(mediaLoadFailed(candidates, rel, message, onError));
17487
- } catch (ex) {
17488
- reject(ex);
17489
- }
17490
- };
17491
- try {
17492
- var _rel_path;
17493
- const req = httpMod.get((_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '', (res)=>{
17494
- var _res_statusCode;
17495
- const status = (_res_statusCode = res.statusCode) !== null && _res_statusCode !== void 0 ? _res_statusCode : 0;
17496
- if (status < 200 || status > 299) {
17497
- res.resume(); // drain so the socket is freed
17498
- fail(`ERROR! Unable to load image (HTTP ${status}): ${rel.path}`);
17499
- return;
17500
- }
17501
- let raw = '';
17502
- res.setEncoding('binary'); // IMPORTANT: Only binary encoding works
17503
- res.on('data', (chunk)=>raw += chunk);
17504
- res.on('end', ()=>{
17505
- rel.data = binaryStringToBase64(raw);
17506
- copyMediaToDuplicates(candidates, rel);
17507
- resolve('done');
17508
- });
17509
- res.on('error', ()=>fail(`ERROR! Unable to load image (response): ${rel.path}`));
17510
- });
17511
- // NOTE: without this, a DNS/TLS/connection failure emits an unhandled 'error' and kills the process
17512
- req.on('error', (ex)=>fail(`ERROR! Unable to load image (request): ${rel.path}\n${String(ex)}`));
17513
- } catch (ex) {
17514
- fail(`ERROR! Unable to load image (https.get): ${rel.path}\n${String(ex)}`);
17515
- }
17516
- });
17517
- }
17518
- /**
17519
- * Fetch one browser media source and convert its Blob response to a data URL.
17520
- * SVG previews are produced only after the source relation has been populated.
17521
- */ function loadBrowserMedia(rel, candidates, onError) {
17522
- return new Promise((resolve, reject)=>{
17523
- var _rel_path;
17524
- const fail = (message)=>{
17525
- try {
17526
- resolve(mediaLoadFailed(candidates, rel, message, onError));
17527
- } catch (ex) {
17528
- reject(ex);
17529
- }
17530
- };
17531
- const xhr = new XMLHttpRequest();
17532
- xhr.onload = ()=>{
17533
- // status 0 = non-HTTP schemes (file://); anything outside 2xx is an error page, not image bytes
17534
- if (xhr.status !== 0 && (xhr.status < 200 || xhr.status > 299)) {
17535
- fail(`ERROR! HTTP status ${xhr.status} loading image: ${rel.path}`);
17536
- return;
17820
+ var self = this, args = arguments;
17821
+ return new Promise(function(resolve, reject) {
17822
+ var gen = fn.apply(self, args);
17823
+ function _next(value) {
17824
+ gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
17537
17825
  }
17538
- const reader = new FileReader();
17539
- reader.onloadend = ()=>{
17540
- if (typeof reader.result === 'string') rel.data = reader.result;
17541
- copyMediaToDuplicates(candidates, rel);
17542
- if (!rel.isSvgPng) resolve('done');
17543
- else createSvgPngPreview(rel).then(()=>resolve('done')).catch(reject);
17544
- };
17545
- reader.readAsDataURL(xhr.response);
17546
- };
17547
- xhr.onerror = ()=>{
17548
- fail(`ERROR! Unable to load image (xhr.onerror): ${rel.path}`);
17549
- };
17550
- xhr.open('GET', (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '');
17551
- xhr.responseType = 'blob';
17552
- xhr.send();
17553
- });
17826
+ function _throw(err) {
17827
+ gen_fonts_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
17828
+ }
17829
+ _next(undefined);
17830
+ });
17831
+ };
17554
17832
  }
17555
- /** Route one source relation to the loader valid for the active runtime. */ function encodeMediaRelation(rel, candidates, isNode, modules, loadNodeModules, onError) {
17556
- return gen_media_async_to_generator(function*() {
17557
- var _rel_path;
17558
- if (!modules.https) yield loadNodeModules();
17559
- const path = (_rel_path = rel.path) !== null && _rel_path !== void 0 ? _rel_path : '';
17560
- if (isNode && modules.fs && !path.startsWith('http')) return readNodeMediaFile(rel, candidates, modules.fs, onError);
17561
- if (isNode && modules.https && modules.http && path.startsWith('http')) return loadNodeMediaUrl(rel, candidates, modules.https, modules.http, onError);
17562
- return loadBrowserMedia(rel, candidates, onError);
17833
+
17834
+
17835
+ /** High rId base so font relationships do not collide with slide/master rIds */ const FONT_RID_START = 201314;
17836
+ const FONT_REL_TYPE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font';
17837
+ /**
17838
+ * Convert TTF / OTF / WOFF bytes to EOT (Office `fntdata` payload).
17839
+ * Lazy-loads pako only for WOFF.
17840
+ */ function fontToEot(type, fontBuffer) {
17841
+ return gen_fonts_async_to_generator(function*() {
17842
+ const options = {
17843
+ hinting: true
17844
+ };
17845
+ if (type === 'woff') {
17846
+ // pako 3: named exports only; InflateInput is Uint8Array | ArrayBuffer (not number[])
17847
+ const { inflate } = yield import("pako");
17848
+ options.inflate = (deflatedData)=>Array.from(inflate(Uint8Array.from(deflatedData)));
17849
+ }
17850
+ return convertToEot(type, fontBuffer, options);
17563
17851
  })();
17564
17852
  }
17565
- /**
17566
- * Append SVG preview work synchronously because the caller immediately snapshots `promises`.
17567
- * Node cannot rasterize SVG here, so it keeps the historical broken-preview sentinel behavior.
17568
- */ function addSvgPreviewPromises(layout, isNode, promises) {
17569
- layout._relsMedia.filter((rel)=>rel.isSvgPng && rel.data).forEach((rel)=>{
17570
- // NOTE: must push synchronously - the caller snapshots this array as soon as we return
17571
- if (isNode) {
17572
- // SVG is not supported in Node (more info: https://github.com/gitbrent/PptxGenJS/issues/401)
17573
- rel.data = IMG_BROKEN;
17574
- promises.push(Promise.resolve('done'));
17575
- } else {
17576
- promises.push(createSvgPngPreview(rel));
17853
+ function toFntdata(fontType, fontFile) {
17854
+ return gen_fonts_async_to_generator(function*() {
17855
+ switch(fontType){
17856
+ case 'eot':
17857
+ // EOT bytes are stored as-is under ppt/fonts/*.fntdata
17858
+ return fontFile;
17859
+ case 'ttf':
17860
+ case 'otf':
17861
+ case 'woff':
17862
+ return yield fontToEot(fontType, fontFile);
17863
+ default:
17864
+ throw new Error(`Invalid font type "${String(fontType)}" - use ttf | otf | woff | eot`);
17577
17865
  }
17578
- });
17866
+ })();
17579
17867
  }
17580
- /**
17581
- * Encode Image/Audio/Video into base64
17582
- * @param {PresSlide | SlideLayout} layout - slide layout
17583
- * @return {Promise} promise
17584
- */ function encodeSlideMediaRels(layout, opts) {
17585
- // STEP 1: Detect a real Node process. Browser bundles often polyfill `process`
17586
- // (and even `process.versions.node`), so also require a document-less runtime.
17587
- const isNode = isNodeRuntime();
17588
- const modules = {};
17589
- // STEP 2: Lazy-load Node built-ins if needed. The specifier is built at runtime
17590
- // so browser bundlers cannot statically resolve `node:https` / `https`.
17591
- const loadNodeDeps = isNode ? ()=>gen_media_async_to_generator(function*() {
17592
- ;
17593
- ({ default: modules.fs } = yield importNodeBuiltin('fs'));
17594
- ({ default: modules.https } = yield importNodeBuiltin('https'));
17595
- ({ default: modules.http } = yield importNodeBuiltin('http'));
17596
- })() : ()=>gen_media_async_to_generator(function*() {})();
17597
- // Immediately start it when we know we’re in Node
17598
- if (isNode) loadNodeDeps();
17599
- // STEP 3: Prepare promises list
17600
- const imageProms = [];
17601
- // A: Capture all audio/image/video candidates for encoding (filtering online/pre-encoded)
17602
- const candidateRels = getMediaCandidates(layout);
17603
- // B: PERF: Mark dupes (same `path`) to avoid loading the same media over-and-over!
17604
- markDuplicateMedia(candidateRels);
17605
- // STEP 4: Read/Encode each unique media item
17606
- const onError = (opts === null || opts === void 0 ? void 0 : opts.onError) === 'placeholder' ? 'placeholder' : 'throw';
17607
- candidateRels.filter((rel)=>!rel.isDuplicate).forEach((rel)=>imageProms.push(encodeMediaRelation(rel, candidateRels, isNode, modules, loadNodeDeps, onError)));
17608
- // STEP 5: SVG-PNG previews
17609
- // ......: "SVG:" base64 data still requires a png to be generated
17610
- // ......: (`isSvgPng` flag this as the preview image, not the SVG itself)
17611
- addSvgPreviewPromises(layout, isNode, imageProms);
17612
- return imageProms;
17868
+ function ensureFntdataContentType(contentTypesXml) {
17869
+ if (/Extension="fntdata"/i.test(contentTypesXml)) return contentTypesXml;
17870
+ const entry = '<Default Extension="fntdata" ContentType="application/x-fontdata"/>';
17871
+ // Prefer inserting among other Defaults near the top of <Types>
17872
+ if (/<Default\b/i.test(contentTypesXml)) {
17873
+ return contentTypesXml.replace(/<Default\b/i, `${entry}<Default`);
17874
+ }
17875
+ return contentTypesXml.replace(/<Types([^>]*)>/i, `<Types$1>${entry}`);
17876
+ }
17877
+ function ensurePresentationFontAttrs(presentationXml) {
17878
+ let xml = presentationXml;
17879
+ if (/embedTrueTypeFonts=/i.test(xml)) {
17880
+ xml = xml.replace(/embedTrueTypeFonts="[^"]*"/i, 'embedTrueTypeFonts="true"');
17881
+ } else {
17882
+ xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 embedTrueTypeFonts="true">');
17883
+ }
17884
+ if (/saveSubsetFonts=/i.test(xml)) {
17885
+ xml = xml.replace(/saveSubsetFonts="[^"]*"/i, 'saveSubsetFonts="true"');
17886
+ } else {
17887
+ xml = xml.replace(/<p:presentation\b([^>]*)>/i, '<p:presentation$1 saveSubsetFonts="true">');
17888
+ }
17889
+ return xml;
17890
+ }
17891
+ function buildEmbeddedFontLst(fonts) {
17892
+ let lst = '<p:embeddedFontLst>';
17893
+ for (const font of fonts){
17894
+ lst += '<p:embeddedFont>' + `<p:font typeface="${escapeXmlAttr(font.name)}"/>` + `<p:regular r:id="rId${font.rid}"/>` + '</p:embeddedFont>';
17895
+ }
17896
+ lst += '</p:embeddedFontLst>';
17897
+ return lst;
17898
+ }
17899
+ function escapeXmlAttr(value) {
17900
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
17901
+ }
17902
+ function ensureEmbeddedFontLst(presentationXml, fonts) {
17903
+ const lst = buildEmbeddedFontLst(fonts);
17904
+ if (/<p:embeddedFontLst[\s>]/i.test(presentationXml)) {
17905
+ // Replace existing list wholesale (export always owns the registered set)
17906
+ return presentationXml.replace(/<p:embeddedFontLst[\s\S]*?<\/p:embeddedFontLst>/i, lst);
17907
+ }
17908
+ // ISO 29500: embeddedFontLst precedes defaultTextStyle.
17909
+ // Insert after the full opening tag (match consumes `>` or attrs so it's preserved).
17910
+ const dtsOpen = presentationXml.match(/<p:defaultTextStyle(?:\s[^>]*)?>/i);
17911
+ if (dtsOpen) {
17912
+ return presentationXml.replace(dtsOpen[0], `${lst}${dtsOpen[0]}`);
17913
+ }
17914
+ // Fallback: before closing presentation
17915
+ return presentationXml.replace(/<\/p:presentation>/i, `${lst}</p:presentation>`);
17916
+ }
17917
+ function appendFontRelationships(relsXml, fonts) {
17918
+ const nodes = fonts.map((font)=>`<Relationship Id="rId${font.rid}" ` + `Type="${FONT_REL_TYPE}" ` + `Target="fonts/${font.rid}.fntdata"/>`).join('');
17919
+ if (!nodes) return relsXml;
17920
+ return relsXml.replace(/<\/Relationships>/i, `${nodes}</Relationships>`);
17613
17921
  }
17614
17922
  /**
17615
- * Create SVG preview image
17616
- * @param {ISlideRelMedia} rel - slide rel
17617
- * @return {Promise} promise
17618
- */ function createSvgPngPreview(rel) {
17619
- return gen_media_async_to_generator(function*() {
17620
- return yield new Promise((resolve, reject)=>{
17621
- // A: Create
17622
- const image = new Image();
17623
- // Shared error handler (also wired to `image.onerror`); the reason string is informational only
17624
- const handleError = ()=>{
17625
- rel.data = IMG_BROKEN;
17626
- reject(new Error(`ERROR! Unable to load image (image.onerror): ${rel.path}`));
17627
- };
17628
- // B: Set onload event
17629
- image.onload = ()=>{
17630
- // First: Check for any errors: This is the best method (try/catch wont work, etc.)
17631
- if (image.width + image.height === 0) {
17632
- handleError();
17633
- }
17634
- const canvas = document.createElement('canvas');
17635
- const ctx = canvas.getContext('2d');
17636
- if (!ctx) {
17637
- handleError();
17638
- return;
17639
- }
17640
- canvas.width = image.width;
17641
- canvas.height = image.height;
17642
- ctx.drawImage(image, 0, 0);
17643
- // Users running on local machine will get the following error:
17644
- // "SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported."
17645
- // when the canvas.toDataURL call executes below.
17646
- try {
17647
- rel.data = canvas.toDataURL(rel.type);
17648
- resolve('done');
17649
- } catch (_ex) {
17650
- handleError();
17651
- }
17652
- };
17653
- image.onerror = handleError;
17654
- // C: Load image
17655
- image.src = typeof rel.data === 'string' ? rel.data : IMG_BROKEN;
17656
- });
17923
+ * Convert registered fonts into OOXML `ppt/fonts/*.fntdata` + presentation.xml entries.
17924
+ * Mutates `zip` in place (before generateAsync).
17925
+ */ function embedFontsIntoZip(zip, fonts) {
17926
+ return gen_fonts_async_to_generator(function*() {
17927
+ if (fonts.length === 0) return;
17928
+ const prepared = [];
17929
+ let nextRid = FONT_RID_START;
17930
+ for (const font of fonts){
17931
+ prepared.push({
17932
+ name: font.fontFace,
17933
+ data: yield toFntdata(font.fontType, font.fontFile),
17934
+ rid: nextRid++
17935
+ });
17936
+ }
17937
+ const contentTypesFile = zip.file('[Content_Types].xml');
17938
+ if (!contentTypesFile) throw new Error('[Content_Types].xml not found');
17939
+ addZipFile(zip, '[Content_Types].xml', ensureFntdataContentType((yield contentTypesFile.async('string'))));
17940
+ const presentationFile = zip.file('ppt/presentation.xml');
17941
+ if (!presentationFile) throw new Error('ppt/presentation.xml not found');
17942
+ let presentationXml = yield presentationFile.async('string');
17943
+ presentationXml = ensurePresentationFontAttrs(presentationXml);
17944
+ presentationXml = ensureEmbeddedFontLst(presentationXml, prepared);
17945
+ addZipFile(zip, 'ppt/presentation.xml', presentationXml);
17946
+ const relsFile = zip.file('ppt/_rels/presentation.xml.rels');
17947
+ if (!relsFile) throw new Error('ppt/_rels/presentation.xml.rels not found');
17948
+ addZipFile(zip, 'ppt/_rels/presentation.xml.rels', appendFontRelationships((yield relsFile.async('string')), prepared));
17949
+ for (const font of prepared){
17950
+ addZipFile(zip, `ppt/fonts/${font.rid}.fntdata`, font.data, {
17951
+ binary: true,
17952
+ compression: 'DEFLATE'
17953
+ });
17954
+ }
17657
17955
  })();
17658
17956
  }
17659
17957
 
@@ -21287,11 +21585,11 @@ const ImageSizingXml = {
21287
21585
  * @returns {string} XML
21288
21586
  */ function genXmlCellBorder(name, border) {
21289
21587
  var _ref, _border_width, _border_color;
21290
- if (border.type === 'none') return `<a:${name} w="0" cap="flat" cmpd="sng" algn="ctr"><a:noFill/></a:${name}>`;
21588
+ if (border.type === 'none') return `<a:${name}><a:noFill/></a:${name}>`;
21291
21589
  const width = (_ref = (_border_width = border.width) !== null && _border_width !== void 0 ? _border_width : border.pt) !== null && _ref !== void 0 ? _ref : DEF_CELL_BORDER.pt;
21292
21590
  const borderTransparency = border.transparency;
21293
- const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${Math.round((100 - Math.min(100, Math.max(0, borderTransparency))) * 1000)}"/>` : '';
21294
- return `<a:${name} w="${valToPts(width)}" cap="flat" cmpd="sng" algn="ctr">` + `<a:solidFill>${createColorElement((_border_color = border.color) !== null && _border_color !== void 0 ? _border_color : DEF_CELL_BORDER.color, borderAlpha)}</a:solidFill>` + `<a:prstDash val="${border.type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/>` + '<a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>' + `</a:${name}>`;
21591
+ const borderAlpha = typeof borderTransparency === 'number' ? `<a:alpha val="${clampAlphaPct(borderTransparency)}"/>` : '';
21592
+ return `<a:${name} w="${valToLineWidth(width)}" cap="flat" cmpd="sng" algn="ctr">` + `<a:solidFill>${createColorElement((_border_color = border.color) !== null && _border_color !== void 0 ? _border_color : DEF_CELL_BORDER.color, borderAlpha)}</a:solidFill>` + `<a:prstDash val="${border.type === 'dash' ? 'sysDash' : 'solid'}"/><a:round/>` + '<a:headEnd type="none" w="med" len="med"/><a:tailEnd type="none" w="med" len="med"/>' + `</a:${name}>`;
21295
21593
  }
21296
21594
  /**
21297
21595
  * One `a:audioCd` endpoint (`a:st` or `a:end`).
@@ -21431,7 +21729,7 @@ const ImageSizingXml = {
21431
21729
  /**
21432
21730
  * Alpha + recolor effects for an image's `a:blip`.
21433
21731
  */ function genXmlBlipEffects(transparency, alpha, recolor) {
21434
- let xml = transparency ? `<a:alphaModFix amt="${Math.round((100 - transparency) * 1000)}"/>` : '';
21732
+ let xml = transparency ? `<a:alphaModFix amt="${clampAlphaPct(transparency)}"/>` : '';
21435
21733
  xml += genXmlBlipRecolor(recolor);
21436
21734
  if (!alpha) return xml;
21437
21735
  if (typeof alpha.replace === 'number' && isFinite(alpha.replace)) xml += `<a:alphaRepl a="${Math.round(Math.min(100, Math.max(0, alpha.replace)) * 1000)}"/>`;
@@ -21593,7 +21891,7 @@ function resolveShapeId(options, idx, usedIds) {
21593
21891
  xml += '<a:rect l="l" t="t" r="r" b="b" />';
21594
21892
  xml += '<a:pathLst>';
21595
21893
  for (const points of pathArrays){
21596
- xml += `<a:path w="${Math.round(pathW)}" h="${Math.round(pathH)}">`;
21894
+ xml += `<a:path w="${positiveExtent(pathW)}" h="${positiveExtent(pathH)}">`;
21597
21895
  points === null || points === void 0 ? void 0 : points.forEach((point, i)=>{
21598
21896
  if ('curve' in point) {
21599
21897
  switch(point.curve.type){
@@ -21762,6 +22060,14 @@ function slideObjectToXml(slide) {
21762
22060
  flipH = line.flipH;
21763
22061
  flipV = line.flipV;
21764
22062
  }
22063
+ // Clamp extents to ST_PositiveCoordinate (>= 0) after line flip so lines keep negative endpoint deltas
22064
+ if (cx < 0 || cy < 0) {
22065
+ console.warn(`[pptxgenjs] negative size on ${slideItemObj._type}${slideItemObj.options.objectName ? ` "${slideItemObj.options.objectName}"` : ''} - w/h cannot be negative, clamped to 0`);
22066
+ }
22067
+ cx = positiveExtent(cx);
22068
+ cy = positiveExtent(cy);
22069
+ imgWidth = positiveExtent(imgWidth);
22070
+ imgHeight = positiveExtent(imgHeight);
21765
22071
  if (flipH) locationAttr += ' flipH="1"';
21766
22072
  if (flipV) locationAttr += ' flipV="1"';
21767
22073
  if (slideItemObj.options.rotate) locationAttr += ` rot="${convertRotationDegrees(slideItemObj.options.rotate)}"`;
@@ -21806,7 +22112,7 @@ function slideObjectToXml(slide) {
21806
22112
  if (w == null || isNaN(w)) {
21807
22113
  w = (typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt;
21808
22114
  }
21809
- strXml += `<a:gridCol w="${Math.round(w)}"/>`;
22115
+ strXml += `<a:gridCol w="${positiveExtent(w)}"/>`;
21810
22116
  }
21811
22117
  strXml += '</a:tblGrid>';
21812
22118
  } else {
@@ -21814,7 +22120,7 @@ function slideObjectToXml(slide) {
21814
22120
  if (slideItemObj.options.w && !objTabOpts.colW) intColW = Math.round((typeof slideItemObj.options.w === 'number' ? slideItemObj.options.w : 1) / intColCnt);
21815
22121
  strXml += '<a:tblGrid>';
21816
22122
  for(let colw = 0; colw < intColCnt; colw++){
21817
- strXml += `<a:gridCol w="${intColW}"/>`;
22123
+ strXml += `<a:gridCol w="${positiveExtent(intColW)}"/>`;
21818
22124
  }
21819
22125
  strXml += '</a:tblGrid>';
21820
22126
  }
@@ -21892,7 +22198,7 @@ function slideObjectToXml(slide) {
21892
22198
  intRowH = Math.round((itemOpts.h ? inch2Emu(itemOpts.h) : typeof itemOpts.cy === 'number' ? itemOpts.cy : 1) / arrTabRows.length);
21893
22199
  }
21894
22200
  // B: Start row
21895
- strXml += `<a:tr h="${intRowH}">`;
22201
+ strXml += `<a:tr h="${positiveExtent(intRowH)}">`;
21896
22202
  // C: Loop over each CELL
21897
22203
  cells.forEach((cellObj)=>{
21898
22204
  var _ref, _ref1;
@@ -21925,6 +22231,7 @@ function slideObjectToXml(slide) {
21925
22231
  'fill',
21926
22232
  'fontFace',
21927
22233
  'fontSize',
22234
+ 'lang',
21928
22235
  'margin',
21929
22236
  'textDirection',
21930
22237
  'vert',
@@ -21933,7 +22240,7 @@ function slideObjectToXml(slide) {
21933
22240
  ].forEach((name)=>{
21934
22241
  if (objTabOpts[name] && !cellOpts[name] && cellOpts[name] !== 0) cellOpts[name] = objTabOpts[name];
21935
22242
  });
21936
- const cellValign = cellOpts.valign ? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m$/i, 'ctr').replace('center', 'ctr').replace('middle', 'ctr').replace('top', 't').replace('btm', 'b').replace('bottom', 'b')}"` : '';
22243
+ const cellValign = cellOpts.valign ? ` anchor="${cellOpts.valign.replace(/^c$/i, 'ctr').replace(/^m(id(dle)?)?$/i, 'ctr').replace(/^center$/i, 'ctr').replace(/^top$/i, 't').replace(/^b(tm|ottom)$/i, 'b')}"` : '';
21937
22244
  // `vert` = Martin-N alias of `textDirection`
21938
22245
  const cellDir = cellOpts.textDirection || cellOpts.vert;
21939
22246
  const cellTextDir = cellDir && cellDir !== 'horz' ? ` vert="${cellDir}"` : '';
@@ -22082,9 +22389,17 @@ function slideObjectToXml(slide) {
22082
22389
  } else {
22083
22390
  var _slideItemObj_options_line_curveadjust, _slideItemObj_options_line7;
22084
22391
  strSlideXml += '<a:prstGeom prst="' + slideItemObj.shape + '"><a:avLst>';
22085
- // `rectRadius: 0` is a valid sharp-corner adj (ECMA-376 §5.1.11 preset geom `gd name="adj"`).
22086
- if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
22087
- strSlideXml += `<a:gd name="adj" fmla="val ${Math.round(slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / Math.min(cx, cy))}"/>`;
22392
+ // `rectRadius` adj is a 0..50000 fraction of the shorter side; clamp out-of-range / zero-extent results.
22393
+ // `round2SameRect` uses two handles (`adj1` top corners, `adj2` bottom corners) — single `adj` is ignored.
22394
+ if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
22395
+ const minDim = Math.min(cx, cy);
22396
+ const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
22397
+ const adjVal = clampInt(rawAdj, 0, 50000);
22398
+ if (slideItemObj.shape === core_enums_SHAPE_TYPE.ROUND_2_SAME_RECTANGLE) {
22399
+ strSlideXml += `<a:gd name="adj1" fmla="val ${adjVal}"/><a:gd name="adj2" fmla="val 0"/>`;
22400
+ } else {
22401
+ strSlideXml += `<a:gd name="adj" fmla="val ${adjVal}"/>`;
22402
+ }
22088
22403
  } else if (slideItemObj.options.angleRange) {
22089
22404
  for(let i = 0; i < 2; i++){
22090
22405
  const angle = slideItemObj.options.angleRange[i];
@@ -22197,8 +22512,8 @@ function slideObjectToXml(slide) {
22197
22512
  // the frame must keep the user's w/h container - collapsing it to the crop box (or 0) breaks
22198
22513
  // rendering (issue #1399).
22199
22514
  if (sizing.type !== 'crop') {
22200
- imgWidth = boxW;
22201
- imgHeight = boxH;
22515
+ imgWidth = positiveExtent(boxW);
22516
+ imgHeight = positiveExtent(boxH);
22202
22517
  }
22203
22518
  } else {
22204
22519
  strSlideXml += ' <a:stretch><a:fillRect/></a:stretch>';
@@ -22211,8 +22526,10 @@ function slideObjectToXml(slide) {
22211
22526
  strSlideXml += ' </a:xfrm>';
22212
22527
  // Geometry: rectRadius → roundRect; rounding (legacy) → ellipse; else rect
22213
22528
  // Selective port of niranjan-uma-shankar/feature/html-to-pptx (keeps ellipse back-compat)
22214
- if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius) && slideItemObj.options.rectRadius >= 0) {
22215
- const adjValue = Math.round(slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / Math.min(imgWidth, imgHeight));
22529
+ if (typeof slideItemObj.options.rectRadius === 'number' && Number.isFinite(slideItemObj.options.rectRadius)) {
22530
+ const minDim = Math.min(imgWidth, imgHeight);
22531
+ const rawAdj = minDim > 0 ? slideItemObj.options.rectRadius * (/* inlined export .EMU */914400) * 100000 / minDim : slideItemObj.options.rectRadius > 0 ? 50000 : 0;
22532
+ const adjValue = clampInt(rawAdj, 0, 50000);
22216
22533
  strSlideXml += ` <a:prstGeom prst="roundRect"><a:avLst><a:gd name="adj" fmla="val ${adjValue}"/></a:avLst></a:prstGeom>`;
22217
22534
  } else {
22218
22535
  strSlideXml += ` <a:prstGeom prst="${rounding ? 'ellipse' : 'rect'}"><a:avLst/></a:prstGeom>`;
@@ -22242,7 +22559,7 @@ function slideObjectToXml(slide) {
22242
22559
  const coverRid = (_slideItemObj__coverRid = slideItemObj._coverRid) !== null && _slideItemObj__coverRid !== void 0 ? _slideItemObj__coverRid : 2;
22243
22560
  strSlideXml += '<p:pic>';
22244
22561
  strSlideXml += ' <p:nvPicPr>';
22245
- strSlideXml += `<p:cNvPr id="${coverRid}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22562
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22246
22563
  strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
22247
22564
  if (slideItemObj.mtype === 'audioCd') {
22248
22565
  const cd = slideItemObj.options.audioCd;
@@ -22258,34 +22575,32 @@ function slideObjectToXml(slide) {
22258
22575
  strSlideXml += ' </p:spPr>';
22259
22576
  strSlideXml += '</p:pic>';
22260
22577
  } else if (slideItemObj.mtype === 'online') {
22261
- var _slideItemObj_mediaRid, _slideItemObj_mediaRid1;
22578
+ var _slideItemObj_mediaRid;
22262
22579
  const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
22263
22580
  strSlideXml += '<p:pic>';
22264
22581
  strSlideXml += ' <p:nvPicPr>';
22265
- // IMPORTANT: <p:cNvPr id="" value is critical - if its not the same number as preview image `rId`, PowerPoint throws error!
22266
- strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 2}" name="${slideItemObj.options.objectName}"/>`;
22582
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"/>`;
22267
22583
  strSlideXml += ' <p:cNvPicPr/>';
22268
22584
  strSlideXml += genXmlNvPr(slideItemObj.options, `<a:videoFile r:link="rId${slideItemObj.mediaRid}"${contentType}/>`);
22269
22585
  strSlideXml += ' </p:nvPicPr>';
22270
22586
  // NOTE: `blip` is diferent than videos; also there's no preview "p:extLst" above but exists in videos
22271
- strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid1 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid1 !== void 0 ? _slideItemObj_mediaRid1 : 0) + 1}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22587
+ strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid !== void 0 ? _slideItemObj_mediaRid : 0) + 1}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22272
22588
  strSlideXml += ' <p:spPr>';
22273
22589
  strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
22274
22590
  strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
22275
22591
  strSlideXml += ' </p:spPr>';
22276
22592
  strSlideXml += '</p:pic>';
22277
22593
  } else {
22278
- var _slideItemObj_mediaRid2, _slideItemObj_mediaRid3, _slideItemObj_mediaRid4, _slideItemObj_mediaRid5;
22594
+ var _slideItemObj_mediaRid1, _slideItemObj_mediaRid2, _slideItemObj_mediaRid3;
22279
22595
  // ECMA-376: audio uses `<a:audioFile>`, video uses `<a:videoFile>` under nvPr.
22280
22596
  const mediaFileTag = slideItemObj.mtype === 'audio' ? 'a:audioFile' : 'a:videoFile';
22281
22597
  const contentType = slideItemObj.options.contentType ? ` contentType="${encodeXmlEntities(slideItemObj.options.contentType)}"` : '';
22282
22598
  strSlideXml += '<p:pic>';
22283
22599
  strSlideXml += ' <p:nvPicPr>';
22284
- // IMPORTANT: <p:cNvPr id="" value is critical - if not the same number as preiew image rId, PowerPoint throws error!
22285
- strSlideXml += `<p:cNvPr id="${((_slideItemObj_mediaRid2 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid2 !== void 0 ? _slideItemObj_mediaRid2 : 0) + 2}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22600
+ strSlideXml += `<p:cNvPr id="${shapeId}" name="${slideItemObj.options.objectName}"><a:hlinkClick r:id="" action="ppaction://media"/></p:cNvPr>`;
22286
22601
  strSlideXml += ' <p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr>';
22287
22602
  const mediaExtras = genXmlMediaExtras(slideItemObj.options);
22288
- const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid3 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid3 !== void 0 ? _slideItemObj_mediaRid3 : 0) + 1}">${mediaExtras} </p14:media>` : ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid4 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid4 !== void 0 ? _slideItemObj_mediaRid4 : 0) + 1}"/>`) + '</p:ext>';
22603
+ const mediaExt = '<p:ext uri="{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}">' + (mediaExtras ? ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid1 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid1 !== void 0 ? _slideItemObj_mediaRid1 : 0) + 1}">${mediaExtras} </p14:media>` : ` <p14:media xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" r:embed="rId${((_slideItemObj_mediaRid2 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid2 !== void 0 ? _slideItemObj_mediaRid2 : 0) + 1}"/>`) + '</p:ext>';
22289
22604
  const narrationExt = slideItemObj.options.isNarration ? '<p:ext uri="{42D2F446-02D8-4167-A562-619A0277C38B}"><p15:isNarration xmlns:p15="http://schemas.microsoft.com/office/powerpoint/2012/main" val="1"/></p:ext>' : '';
22290
22605
  strSlideXml += genXmlNvPr(slideItemObj.options, `<${mediaFileTag} r:link="rId${slideItemObj.mediaRid}"${contentType}/>`, narrationExt ? [
22291
22606
  mediaExt,
@@ -22294,7 +22609,7 @@ function slideObjectToXml(slide) {
22294
22609
  mediaExt
22295
22610
  ]);
22296
22611
  strSlideXml += ' </p:nvPicPr>';
22297
- strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid5 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid5 !== void 0 ? _slideItemObj_mediaRid5 : 0) + 2}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22612
+ strSlideXml += ` <p:blipFill><a:blip r:embed="rId${((_slideItemObj_mediaRid3 = slideItemObj.mediaRid) !== null && _slideItemObj_mediaRid3 !== void 0 ? _slideItemObj_mediaRid3 : 0) + 2}"/><a:stretch><a:fillRect/></a:stretch></p:blipFill>`; // NOTE: Preview image is required!
22298
22613
  strSlideXml += ' <p:spPr>';
22299
22614
  strSlideXml += ` <a:xfrm${locationAttr}><a:off x="${x}" y="${y}"/><a:ext cx="${cx}" cy="${cy}"/></a:xfrm>`;
22300
22615
  strSlideXml += ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>';
@@ -22477,7 +22792,7 @@ function slideObjectToXml(slide) {
22477
22792
  strSlideXml += ' <p:nvPr><p:ph type="sldNum" sz="quarter" idx="4294967295"/></p:nvPr>';
22478
22793
  strSlideXml += ' </p:nvSpPr>';
22479
22794
  strSlideXml += ' <p:spPr>';
22480
- strSlideXml += '<a:xfrm>' + `<a:off x="${getSmartParseNumber(slide._slideNumberProps.x, 'X', slide._presLayout)}" y="${getSmartParseNumber(slide._slideNumberProps.y, 'Y', slide._presLayout)}"/>` + `<a:ext cx="${slide._slideNumberProps.w ? getSmartParseNumber(slide._slideNumberProps.w, 'X', slide._presLayout) : '800000'}" cy="${slide._slideNumberProps.h ? getSmartParseNumber(slide._slideNumberProps.h, 'Y', slide._presLayout) : '300000'}"/>` + '</a:xfrm>' + ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + ' <a:extLst><a:ext uri="{C572A759-6A51-4108-AA02-DFA0A04FC94B}"><ma14:wrappingTextBoxFlag val="0" xmlns:ma14="http://schemas.microsoft.com/office/mac/drawingml/2011/main"/></a:ext></a:extLst>' + '</p:spPr>';
22795
+ strSlideXml += '<a:xfrm>' + `<a:off x="${getSmartParseNumber(slide._slideNumberProps.x, 'X', slide._presLayout)}" y="${getSmartParseNumber(slide._slideNumberProps.y, 'Y', slide._presLayout)}"/>` + `<a:ext cx="${slide._slideNumberProps.w ? positiveExtent(getSmartParseNumber(slide._slideNumberProps.w, 'X', slide._presLayout)) : '800000'}" cy="${slide._slideNumberProps.h ? positiveExtent(getSmartParseNumber(slide._slideNumberProps.h, 'Y', slide._presLayout)) : '300000'}"/>` + '</a:xfrm>' + ' <a:prstGeom prst="rect"><a:avLst/></a:prstGeom>' + ' <a:extLst><a:ext uri="{C572A759-6A51-4108-AA02-DFA0A04FC94B}"><ma14:wrappingTextBoxFlag val="0" xmlns:ma14="http://schemas.microsoft.com/office/mac/drawingml/2011/main"/></a:ext></a:extLst>' + '</p:spPr>';
22481
22796
  strSlideXml += '<p:txBody>';
22482
22797
  strSlideXml += '<a:bodyPr';
22483
22798
  if (slide._slideNumberProps.margin && Array.isArray(slide._slideNumberProps.margin)) {
@@ -22497,7 +22812,7 @@ function slideObjectToXml(slide) {
22497
22812
  strSlideXml += '/>';
22498
22813
  strSlideXml += ' <a:lstStyle><a:lvl1pPr>';
22499
22814
  if (slide._slideNumberProps.fontFace || slide._slideNumberProps.fontSize || slide._slideNumberProps.color) {
22500
- strSlideXml += `<a:defRPr sz="${Math.round((slide._slideNumberProps.fontSize || 12) * 100)}">`;
22815
+ strSlideXml += `<a:defRPr sz="${fontSizeToSz(slide._slideNumberProps.fontSize || 12)}">`;
22501
22816
  if (slide._slideNumberProps.color) strSlideXml += genXmlColorSelection(slide._slideNumberProps.color);
22502
22817
  if (slide._slideNumberProps.fontFace) {
22503
22818
  strSlideXml += `<a:latin typeface="${slide._slideNumberProps.fontFace}"/><a:ea typeface="${slide._slideNumberProps.fontFace}"/><a:cs typeface="${slide._slideNumberProps.fontFace}"/>`;
@@ -22859,20 +23174,21 @@ function slideShowExtLst(slide) {
22859
23174
  * @returns {SlideObjectAnimation[]} array of object animations with their indices
22860
23175
  */ /**
22861
23176
  * Collect media shapes that need a playback entry in the slide timing tree.
22862
- * The shape id targeted by `<p:spTgt spid>` is the media `<p:cNvPr id>`, which the
22863
- * media emitter computes as `mediaRid + 2`. Online (linked) videos are excluded —
23177
+ * The shape id targeted by `<p:spTgt spid>` is the allocated `<p:cNvPr id>` stamped onto
23178
+ * `obj.options.sId` by `slideObjectToXml`. Online (linked) videos are excluded —
22864
23179
  * they don't support the embedded playback timing tree.
22865
23180
  */ function collectMediaPlayback(slide) {
22866
23181
  var _slide__slideObjects;
22867
23182
  const entries = [];
22868
- ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).forEach((obj)=>{
22869
- var _obj_mediaRid;
23183
+ const renderable = ((_slide__slideObjects = slide._slideObjects) !== null && _slide__slideObjects !== void 0 ? _slide__slideObjects : []).filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
23184
+ renderable.forEach((obj, idx)=>{
23185
+ var _o_sId;
22870
23186
  if (obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") || obj.mtype !== 'audio' && obj.mtype !== 'video') return;
22871
23187
  const o = obj.options;
22872
23188
  // Defaults are all false: no timing node unless at least one playback flag is set.
22873
23189
  if (!o || !(o.autoplay || o.loop || o.fullScreen || o.mute)) return;
22874
23190
  entries.push({
22875
- spid: ((_obj_mediaRid = obj.mediaRid) !== null && _obj_mediaRid !== void 0 ? _obj_mediaRid : 0) + 2,
23191
+ spid: (_o_sId = o.sId) !== null && _o_sId !== void 0 ? _o_sId : idx + 2,
22876
23192
  kind: obj.mtype === 'video' ? 'video' : 'audio',
22877
23193
  autoplay: o.autoplay,
22878
23194
  loop: o.loop,
@@ -22886,7 +23202,8 @@ function slideShowExtLst(slide) {
22886
23202
  function collectSlideAnimations(slide) {
22887
23203
  const animations = [];
22888
23204
  if (!slide._slideObjects) return animations;
22889
- slide._slideObjects.forEach((slideObj, index)=>{
23205
+ const renderable = slide._slideObjects.filter((obj)=>obj._type !== (/* inlined export .SLIDE_OBJECT_TYPES.notes */"notes"));
23206
+ renderable.forEach((slideObj, index)=>{
22890
23207
  var _ref;
22891
23208
  var _slideObj_options, _slideObj_options1, _slideObj_options2;
22892
23209
  // Warn when animations are incorrectly attached to individual text runs
@@ -22925,8 +23242,8 @@ function collectSlideAnimations(slide) {
22925
23242
  delay: 0
22926
23243
  }, animConfig);
22927
23244
  }
22928
- // Media cNvPr id is mediaRid+2 (not the auto shape index). Charts keep index+2 / sId.
22929
- const shapeId = slideObj._type === (/* inlined export .SLIDE_OBJECT_TYPES.media */"media") && slideObj.mediaRid != null ? slideObj.mediaRid + 2 : (_ref = (_slideObj_options2 = slideObj.options) === null || _slideObj_options2 === void 0 ? void 0 : _slideObj_options2.sId) !== null && _ref !== void 0 ? _ref : index + 2;
23245
+ // `slideObjectToXml` runs first and stamps every object's allocated `p:cNvPr/@id` onto `options.sId`
23246
+ const shapeId = (_ref = (_slideObj_options2 = slideObj.options) === null || _slideObj_options2 === void 0 ? void 0 : _slideObj_options2.sId) !== null && _ref !== void 0 ? _ref : index + 2;
22930
23247
  animations.push({
22931
23248
  objectIndex: index,
22932
23249
  shapeId,
@@ -22948,6 +23265,9 @@ function collectSlideAnimations(slide) {
22948
23265
  if (!s._id) s._id = getUuid('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
22949
23266
  });
22950
23267
  resolveZoomSections(slide, sections);
23268
+ // Render `p:cSld` first so `resolveShapeId` allocates unique `p:cNvPr/@id` values (including media)
23269
+ // and stamps `options.sId` before animations & media playback timing target `<p:spTgt spid="..."/>`.
23270
+ const cSldXml = slideObjectToXml(slide);
22951
23271
  const animations = collectSlideAnimations(slide);
22952
23272
  const mediaPlayback = collectMediaPlayback(slide);
22953
23273
  const timingXml = animations.length > 0 || mediaPlayback.length > 0 ? createTimingXml(animations, mediaPlayback) : '';
@@ -22962,7 +23282,7 @@ function collectSlideAnimations(slide) {
22962
23282
  commentRelExt
22963
23283
  ].filter(Boolean);
22964
23284
  const sldExtXml = sldExtLst.length > 0 ? `<p:extLst>${sldExtLst.join('')}</p:extLst>` : '';
22965
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + 'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ' + `xmlns:m="${MATH_NS}" ` + `xmlns:a14="${A14_NS}" ` + (hasP14 ? `xmlns:p14="${P14_NS}" ` : '') + `xmlns:mc="${MC_NS}" mc:Ignorable="a14${hasP14 ? ' p14' : ''}"` + `${(slide === null || slide === void 0 ? void 0 : slide.hidden) ? ' show="0"' : ''}>` + `${slideObjectToXml(slide)}` + '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>' + `${transitionXml}` + `${timingXml}` + `${sldExtXml}` + '</p:sld>';
23285
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${(/* inlined export .CRLF */"\r\n")}` + '<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" ' + 'xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ' + `xmlns:m="${MATH_NS}" ` + `xmlns:a14="${A14_NS}" ` + (hasP14 ? `xmlns:p14="${P14_NS}" ` : '') + `xmlns:mc="${MC_NS}" mc:Ignorable="a14${hasP14 ? ' p14' : ''}"` + `${(slide === null || slide === void 0 ? void 0 : slide.hidden) ? ' show="0"' : ''}>` + `${cSldXml}` + '<p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr>' + `${transitionXml}` + `${timingXml}` + `${sldExtXml}` + '</p:sld>';
22966
23286
  }
22967
23287
  /**
22968
23288
  * Get text content of Notes from Slide
@@ -23056,21 +23376,54 @@ function collectSlideAnimations(slide) {
23056
23376
  * Distinct `thm15:themeFamily` ids keep the notes theme from being a byte-identical twin
23057
23377
  * (Office repair creates theme2 when notesMaster shares theme1; Juliussssssss 9bdfe09 / SCV-Soft 1a1998e).
23058
23378
  * @return {string} XML
23059
- */ function makeXmlTheme(pres, variant = 'slide') {
23060
- var _ref, _ref1;
23061
- var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6;
23062
- const majorFont = ((_pres_theme = pres.theme) === null || _pres_theme === void 0 ? void 0 : _pres_theme.headFontFace) ? `<a:latin typeface="${(_pres_theme1 = pres.theme) === null || _pres_theme1 === void 0 ? void 0 : _pres_theme1.headFontFace}"/>` : '<a:latin typeface="Calibri Light" panose="020F0302020204030204"/>';
23063
- const minorFont = ((_pres_theme2 = pres.theme) === null || _pres_theme2 === void 0 ? void 0 : _pres_theme2.bodyFontFace) ? `<a:latin typeface="${(_pres_theme3 = pres.theme) === null || _pres_theme3 === void 0 ? void 0 : _pres_theme3.bodyFontFace}"/>` : '<a:latin typeface="Calibri" panose="020F0502020204030204"/>';
23064
- const eaFace = (_ref = (_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.eaFontFace) !== null && _ref !== void 0 ? _ref : '';
23065
- const csFace = (_ref1 = (_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.csFontFace) !== null && _ref1 !== void 0 ? _ref1 : '';
23379
+ */ const THEME_COLOR_SLOT_ORDER = [
23380
+ 'dk1',
23381
+ 'lt1',
23382
+ 'dk2',
23383
+ 'lt2',
23384
+ 'accent1',
23385
+ 'accent2',
23386
+ 'accent3',
23387
+ 'accent4',
23388
+ 'accent5',
23389
+ 'accent6',
23390
+ 'hlink',
23391
+ 'folHlink'
23392
+ ];
23393
+ function makeXmlTheme(pres, variant = 'slide') {
23394
+ var _pres_theme, _pres_theme1, _pres_theme2, _pres_theme3, _pres_theme4, _pres_theme5, _pres_theme6, _pres_theme7;
23395
+ const headFace = ((_pres_theme = pres.theme) === null || _pres_theme === void 0 ? void 0 : _pres_theme.headFontFace) ? encodeXmlEntities(pres.theme.headFontFace) : '';
23396
+ const bodyFace = ((_pres_theme1 = pres.theme) === null || _pres_theme1 === void 0 ? void 0 : _pres_theme1.bodyFontFace) ? encodeXmlEntities(pres.theme.bodyFontFace) : '';
23397
+ const explicitEa = ((_pres_theme2 = pres.theme) === null || _pres_theme2 === void 0 ? void 0 : _pres_theme2.eaFontFace) !== undefined ? encodeXmlEntities(pres.theme.eaFontFace) : undefined;
23398
+ const explicitCs = ((_pres_theme3 = pres.theme) === null || _pres_theme3 === void 0 ? void 0 : _pres_theme3.csFontFace) !== undefined ? encodeXmlEntities(pres.theme.csFontFace) : undefined;
23399
+ // Without ea/cs faces, East Asian and complex-script runs inheriting the theme font fall back to app defaults.
23400
+ // When `eaFontFace`/`csFontFace` are unset, mirror `headFontFace`/`bodyFontFace` (pitch-io 3049ea49).
23401
+ const majorFont = headFace ? `<a:latin typeface="${headFace}"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : headFace}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : headFace}"/>` : `<a:latin typeface="Calibri Light" panose="020F0302020204030204"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : ''}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : ''}"/>`;
23402
+ const minorFont = bodyFace ? `<a:latin typeface="${bodyFace}"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : bodyFace}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : bodyFace}"/>` : `<a:latin typeface="Calibri" panose="020F0502020204030204"/><a:ea typeface="${explicitEa !== null && explicitEa !== void 0 ? explicitEa : ''}"/><a:cs typeface="${explicitCs !== null && explicitCs !== void 0 ? explicitCs : ''}"/>`;
23066
23403
  const themeFamilyId = variant === 'notes' ? '{2E142A2C-CD16-42D6-873A-C26D2A0506FA}' : '{62F939B6-93AF-4DB8-9C6B-D6C7DFDC589F}';
23067
23404
  const themeFamilyVid = variant === 'notes' ? '{1BDDFF52-6CD6-40A5-AB3C-68EB2F1E4D0A}' : '{4A3C46E8-61CC-4603-A589-7422A47A8E4A}';
23068
23405
  // Exactly 12 hex colors required (upstream only checked truthy `.length`, which allowed short arrays → undefined attrs)
23069
- const isCustomColors = Array.isArray((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.themeColors) && pres.theme.themeColors.length === 12;
23070
23406
  const c = resolveThemeColors(pres.theme);
23071
- const themeName = isCustomColors ? 'Custom Theme' : 'Office Theme';
23072
- const schemeName = isCustomColors ? 'Custom' : 'Office';
23073
- return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${themeName}"><a:themeElements><a:clrScheme name="${schemeName}"><a:dk1><a:sysClr val="windowText" lastClr="${c[0]}"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="${c[1]}"/></a:lt1><a:dk2><a:srgbClr val="${c[2]}"/></a:dk2><a:lt2><a:srgbClr val="${c[3]}"/></a:lt2><a:accent1><a:srgbClr val="${c[4]}"/></a:accent1><a:accent2><a:srgbClr val="${c[5]}"/></a:accent2><a:accent3><a:srgbClr val="${c[6]}"/></a:accent3><a:accent4><a:srgbClr val="${c[7]}"/></a:accent4><a:accent5><a:srgbClr val="${c[8]}"/></a:accent5><a:accent6><a:srgbClr val="${c[9]}"/></a:accent6><a:hlink><a:srgbClr val="${c[10]}"/></a:hlink><a:folHlink><a:srgbClr val="${c[11]}"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont>${majorFont}<a:ea typeface="${eaFace}"/><a:cs typeface="${csFace}"/><a:font script="Jpan" typeface="游ゴシック Light"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线 Light"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:majorFont><a:minorFont>${minorFont}<a:ea typeface="${eaFace}"/><a:cs typeface="${csFace}"/><a:font script="Jpan" typeface="游ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="${themeFamilyId}" vid="${themeFamilyVid}"/></a:ext></a:extLst></a:theme>`;
23407
+ let hasNamedColorOverrides = false;
23408
+ if (((_pres_theme4 = pres.theme) === null || _pres_theme4 === void 0 ? void 0 : _pres_theme4.colors) && typeof pres.theme.colors === 'object') {
23409
+ for (const [slot, raw] of Object.entries(pres.theme.colors)){
23410
+ const idx = THEME_COLOR_SLOT_ORDER.indexOf(slot);
23411
+ if (idx < 0 || typeof raw !== 'string') continue;
23412
+ const hex = raw.replace(/^#/, '').toUpperCase();
23413
+ if (/^[0-9A-F]{6}$/.test(hex)) {
23414
+ c[idx] = hex;
23415
+ hasNamedColorOverrides = true;
23416
+ } else {
23417
+ console.warn(`[pptxgenjs] theme.colors.${slot}="${raw}" is not a valid 6-digit hex; using ${c[idx]}`);
23418
+ }
23419
+ }
23420
+ }
23421
+ const isCustomColors = Array.isArray((_pres_theme5 = pres.theme) === null || _pres_theme5 === void 0 ? void 0 : _pres_theme5.themeColors) && pres.theme.themeColors.length === 12 || hasNamedColorOverrides;
23422
+ const customName = ((_pres_theme6 = pres.theme) === null || _pres_theme6 === void 0 ? void 0 : _pres_theme6.name) ? encodeXmlEntities(pres.theme.name) : '';
23423
+ const themeName = customName || (isCustomColors ? 'Custom Theme' : 'Office Theme');
23424
+ const schemeName = customName || (isCustomColors ? 'Custom' : 'Office');
23425
+ const fontSchemeName = ((_pres_theme7 = pres.theme) === null || _pres_theme7 === void 0 ? void 0 : _pres_theme7.fontSchemeName) ? encodeXmlEntities(pres.theme.fontSchemeName) : customName || 'Office';
23426
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="${themeName}"><a:themeElements><a:clrScheme name="${schemeName}"><a:dk1><a:sysClr val="windowText" lastClr="${c[0]}"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="${c[1]}"/></a:lt1><a:dk2><a:srgbClr val="${c[2]}"/></a:dk2><a:lt2><a:srgbClr val="${c[3]}"/></a:lt2><a:accent1><a:srgbClr val="${c[4]}"/></a:accent1><a:accent2><a:srgbClr val="${c[5]}"/></a:accent2><a:accent3><a:srgbClr val="${c[6]}"/></a:accent3><a:accent4><a:srgbClr val="${c[7]}"/></a:accent4><a:accent5><a:srgbClr val="${c[8]}"/></a:accent5><a:accent6><a:srgbClr val="${c[9]}"/></a:accent6><a:hlink><a:srgbClr val="${c[10]}"/></a:hlink><a:folHlink><a:srgbClr val="${c[11]}"/></a:folHlink></a:clrScheme><a:fontScheme name="${fontSchemeName}"><a:majorFont>${majorFont}<a:font script="Jpan" typeface="游ゴシック Light"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线 Light"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Angsana New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:majorFont><a:minorFont>${minorFont}<a:font script="Jpan" typeface="游ゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="等线"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Cordia New"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/><a:font script="Armn" typeface="Arial"/><a:font script="Bugi" typeface="Leelawadee UI"/><a:font script="Bopo" typeface="Microsoft JhengHei"/><a:font script="Java" typeface="Javanese Text"/><a:font script="Lisu" typeface="Segoe UI"/><a:font script="Mymr" typeface="Myanmar Text"/><a:font script="Nkoo" typeface="Ebrima"/><a:font script="Olck" typeface="Nirmala UI"/><a:font script="Osma" typeface="Ebrima"/><a:font script="Phag" typeface="Phagspa"/><a:font script="Syrn" typeface="Estrangelo Edessa"/><a:font script="Syrj" typeface="Estrangelo Edessa"/><a:font script="Syre" typeface="Estrangelo Edessa"/><a:font script="Sora" typeface="Nirmala UI"/><a:font script="Tale" typeface="Microsoft Tai Le"/><a:font script="Talu" typeface="Microsoft New Tai Lue"/><a:font script="Tfng" typeface="Ebrima"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="57150" dist="19050" dir="5400000" algn="ctr" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="63000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/><a:extLst><a:ext uri="{05A4C25C-085E-4340-85A3-A5531E510DB2}"><thm15:themeFamily xmlns:thm15="http://schemas.microsoft.com/office/thememl/2012/main" name="Office Theme" id="${themeFamilyId}" vid="${themeFamilyVid}"/></a:ext></a:extLst></a:theme>`;
23074
23427
  }
23075
23428
  const package_P15_NS = 'http://schemas.microsoft.com/office/powerpoint/2012/main';
23076
23429
  const SLD_GUIDE_URI = '{EFAFB233-063F-42B5-8137-9DF3F51BA10A}';
@@ -23124,7 +23477,8 @@ const NOTES_GUIDE_URI = '{2D200454-40CA-4A62-9FC3-DE9A4176ACB9}';
23124
23477
  // STEP 4: Add sizes
23125
23478
  // `@type` records which preset the dimensions match; omitted when the caller does not say
23126
23479
  strXml += `<p:sldSz cx="${pres.presLayout.width}" cy="${pres.presLayout.height}"${pres.slideSizeType ? ` type="${pres.slideSizeType}"` : ''}/>`;
23127
- strXml += `<p:notesSz cx="${pres.presLayout.height}" cy="${pres.presLayout.width}"/>`;
23480
+ // Diffit-Inc 15c5bade: fixed 7.5×10in portrait notes page matching standard notesMaster placeholders
23481
+ strXml += '<p:notesSz cx="6858000" cy="9144000"/>';
23128
23482
  // CT_Presentation sequence puts these between `notesSz` and `defaultTextStyle` (photoAlbum, kinsoku)
23129
23483
  if (pres.photoAlbum) {
23130
23484
  const album = pres.photoAlbum;
@@ -23929,7 +24283,7 @@ class PptxGenJS {
23929
24283
  */ pptxgen_define_property(this, "_layout", void 0);
23930
24284
  /**
23931
24285
  * PptxGenJS Library Version
23932
- */ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.3.9"));
24286
+ */ pptxgen_define_property(this, "_version", (/* inlined export .VERSION */"4.4.0"));
23933
24287
  /**
23934
24288
  * @type {string}
23935
24289
  */ pptxgen_define_property(this, "_author", void 0);