docx-plus 0.0.3 → 0.0.5

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.
package/dist/index.mjs CHANGED
@@ -2,10 +2,9 @@ import { js2xml, xml2js } from "xml-js";
2
2
  import hash from "hash.js";
3
3
  import { customAlphabet, nanoid } from "nanoid/non-secure";
4
4
  import { textToUint8Array, toUint8Array } from "undio";
5
- import { Readable } from "stream";
6
5
  import { Zip, ZipDeflate, ZipPassThrough, strFromU8, unzipSync, zipSync } from "fflate";
7
6
  import xml from "xml";
8
- //#region \0@oxc-project+runtime@0.123.0/helpers/typeof.js
7
+ //#region \0@oxc-project+runtime@0.124.0/helpers/typeof.js
9
8
  function _typeof(o) {
10
9
  "@babel/helpers - typeof";
11
10
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -15,7 +14,7 @@ function _typeof(o) {
15
14
  }, _typeof(o);
16
15
  }
17
16
  //#endregion
18
- //#region \0@oxc-project+runtime@0.123.0/helpers/toPrimitive.js
17
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPrimitive.js
19
18
  function toPrimitive(t, r) {
20
19
  if ("object" != _typeof(t) || !t) return t;
21
20
  var e = t[Symbol.toPrimitive];
@@ -27,13 +26,13 @@ function toPrimitive(t, r) {
27
26
  return ("string" === r ? String : Number)(t);
28
27
  }
29
28
  //#endregion
30
- //#region \0@oxc-project+runtime@0.123.0/helpers/toPropertyKey.js
29
+ //#region \0@oxc-project+runtime@0.124.0/helpers/toPropertyKey.js
31
30
  function toPropertyKey(t) {
32
31
  var i = toPrimitive(t, "string");
33
32
  return "symbol" == _typeof(i) ? i : i + "";
34
33
  }
35
34
  //#endregion
36
- //#region \0@oxc-project+runtime@0.123.0/helpers/defineProperty.js
35
+ //#region \0@oxc-project+runtime@0.124.0/helpers/defineProperty.js
37
36
  function _defineProperty(e, r, t) {
38
37
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
39
38
  value: t,
@@ -218,29 +217,6 @@ var IgnoreIfEmptyXmlComponent = class extends XmlComponent {
218
217
  }
219
218
  };
220
219
  //#endregion
221
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectSpread2.js
222
- function ownKeys(e, r) {
223
- var t = Object.keys(e);
224
- if (Object.getOwnPropertySymbols) {
225
- var o = Object.getOwnPropertySymbols(e);
226
- r && (o = o.filter(function(r) {
227
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
228
- })), t.push.apply(t, o);
229
- }
230
- return t;
231
- }
232
- function _objectSpread2(e) {
233
- for (var r = 1; r < arguments.length; r++) {
234
- var t = null != arguments[r] ? arguments[r] : {};
235
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
236
- _defineProperty(e, r, t[r]);
237
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
238
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
239
- });
240
- }
241
- return e;
242
- }
243
- //#endregion
244
220
  //#region src/file/xml-components/default-attributes.ts
245
221
  /**
246
222
  * XML attribute components for the docx library.
@@ -334,7 +310,10 @@ var NextAttributeComponent = class extends BaseXmlComponent {
334
310
  * @returns Object with _attr key containing the attributes
335
311
  */
336
312
  prepForXml(_) {
337
- return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => _objectSpread2(_objectSpread2({}, acc), {}, { [key]: value }), {}) };
313
+ return { _attr: Object.values(this.root).filter(({ value }) => value !== void 0).reduce((acc, { key, value }) => ({
314
+ ...acc,
315
+ [key]: value
316
+ }), {}) };
338
317
  }
339
318
  };
340
319
  //#endregion
@@ -385,6 +364,9 @@ var Attributes = class extends XmlAttributeComponent {
385
364
  rsidSect: "w:rsidSect",
386
365
  space: "w:space",
387
366
  sz: "w:sz",
367
+ themeColor: "w:themeColor",
368
+ themeShade: "w:themeShade",
369
+ themeTint: "w:themeTint",
388
370
  top: "w:top",
389
371
  type: "w:type",
390
372
  val: "w:val",
@@ -911,6 +893,49 @@ const pointMeasureValue = unsignedDecimalNumber;
911
893
  * ```
912
894
  */
913
895
  const dateTimeValue = (val) => val.toISOString();
896
+ /**
897
+ * Theme color values used throughout OOXML for referencing document theme colors.
898
+ *
899
+ * Reference: ST_ThemeColor in OOXML specification
900
+ *
901
+ * @publicApi
902
+ */
903
+ const ThemeColor = {
904
+ DARK1: "dark1",
905
+ LIGHT1: "light1",
906
+ DARK2: "dark2",
907
+ LIGHT2: "light2",
908
+ ACCENT1: "accent1",
909
+ ACCENT2: "accent2",
910
+ ACCENT3: "accent3",
911
+ ACCENT4: "accent4",
912
+ ACCENT5: "accent5",
913
+ ACCENT6: "accent6",
914
+ HYPERLINK: "hyperlink",
915
+ FOLLOWED_HYPERLINK: "followedHyperlink",
916
+ NONE: "none",
917
+ BACKGROUND1: "background1",
918
+ TEXT1: "text1",
919
+ BACKGROUND2: "background2",
920
+ TEXT2: "text2"
921
+ };
922
+ /**
923
+ * Theme font values used for referencing document theme fonts.
924
+ *
925
+ * Reference: ST_Theme in OOXML specification
926
+ *
927
+ * @publicApi
928
+ */
929
+ const ThemeFont = {
930
+ MAJOR_EAST_ASIA: "majorEastAsia",
931
+ MAJOR_BIDI: "majorBidi",
932
+ MAJOR_ASCII: "majorAscii",
933
+ MAJOR_H_ANSI: "majorHAnsi",
934
+ MINOR_EAST_ASIA: "minorEastAsia",
935
+ MINOR_BIDI: "minorBidi",
936
+ MINOR_ASCII: "minorAscii",
937
+ MINOR_H_ANSI: "minorHAnsi"
938
+ };
914
939
  //#endregion
915
940
  //#region src/file/xml-components/simple-elements.ts
916
941
  /**
@@ -1323,12 +1348,20 @@ const createAlignment = (type) => new BuilderElement({
1323
1348
  * });
1324
1349
  * ```
1325
1350
  */
1326
- const createBorderElement = (elementName, { color, size, space, style }) => new BuilderElement({
1351
+ const createBorderElement = (elementName, { color, size, space, style, themeColor, themeTint, themeShade, shadow, frame }) => new BuilderElement({
1327
1352
  attributes: {
1328
1353
  color: {
1329
1354
  key: "w:color",
1330
1355
  value: color === void 0 ? void 0 : hexColorValue(color)
1331
1356
  },
1357
+ frame: {
1358
+ key: "w:frame",
1359
+ value: frame
1360
+ },
1361
+ shadow: {
1362
+ key: "w:shadow",
1363
+ value: shadow
1364
+ },
1332
1365
  size: {
1333
1366
  key: "w:sz",
1334
1367
  value: size === void 0 ? void 0 : eighthPointMeasureValue(size)
@@ -1340,6 +1373,18 @@ const createBorderElement = (elementName, { color, size, space, style }) => new
1340
1373
  style: {
1341
1374
  key: "w:val",
1342
1375
  value: style
1376
+ },
1377
+ themeColor: {
1378
+ key: "w:themeColor",
1379
+ value: themeColor
1380
+ },
1381
+ themeShade: {
1382
+ key: "w:themeShade",
1383
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
1384
+ },
1385
+ themeTint: {
1386
+ key: "w:themeTint",
1387
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
1343
1388
  }
1344
1389
  },
1345
1390
  name: elementName
@@ -1543,20 +1588,32 @@ var ThematicBreak = class extends XmlComponent {
1543
1588
  * </xsd:complexType>
1544
1589
  * ```
1545
1590
  */
1546
- const createIndent = ({ start, end, left, right, hanging, firstLine }) => new BuilderElement({
1591
+ const createIndent = ({ start, startChars, end, endChars, left, right, hanging, hangingChars, firstLine, firstLineChars }) => new BuilderElement({
1547
1592
  attributes: {
1548
1593
  end: {
1549
1594
  key: "w:end",
1550
1595
  value: end === void 0 ? void 0 : signedTwipsMeasureValue(end)
1551
1596
  },
1597
+ endChars: {
1598
+ key: "w:endChars",
1599
+ value: endChars === void 0 ? void 0 : decimalNumber(endChars)
1600
+ },
1552
1601
  firstLine: {
1553
1602
  key: "w:firstLine",
1554
1603
  value: firstLine === void 0 ? void 0 : twipsMeasureValue(firstLine)
1555
1604
  },
1605
+ firstLineChars: {
1606
+ key: "w:firstLineChars",
1607
+ value: firstLineChars === void 0 ? void 0 : decimalNumber(firstLineChars)
1608
+ },
1556
1609
  hanging: {
1557
1610
  key: "w:hanging",
1558
1611
  value: hanging === void 0 ? void 0 : twipsMeasureValue(hanging)
1559
1612
  },
1613
+ hangingChars: {
1614
+ key: "w:hangingChars",
1615
+ value: hangingChars === void 0 ? void 0 : decimalNumber(hangingChars)
1616
+ },
1560
1617
  left: {
1561
1618
  key: "w:left",
1562
1619
  value: left === void 0 ? void 0 : signedTwipsMeasureValue(left)
@@ -1568,6 +1625,10 @@ const createIndent = ({ start, end, left, right, hanging, firstLine }) => new Bu
1568
1625
  start: {
1569
1626
  key: "w:start",
1570
1627
  value: start === void 0 ? void 0 : signedTwipsMeasureValue(start)
1628
+ },
1629
+ startChars: {
1630
+ key: "w:startChars",
1631
+ value: startChars === void 0 ? void 0 : decimalNumber(startChars)
1571
1632
  }
1572
1633
  },
1573
1634
  name: "w:ind"
@@ -2018,7 +2079,7 @@ var CurrentSection = class extends XmlComponent {
2018
2079
  *
2019
2080
  * Reference: http://officeopenxml.com/WPshading.php
2020
2081
  */
2021
- const createShading = ({ fill, color, type }) => new BuilderElement({
2082
+ const createShading = ({ fill, color, type, themeColor, themeTint, themeShade, themeFill, themeFillTint, themeFillShade }) => new BuilderElement({
2022
2083
  attributes: {
2023
2084
  color: {
2024
2085
  key: "w:color",
@@ -2028,6 +2089,30 @@ const createShading = ({ fill, color, type }) => new BuilderElement({
2028
2089
  key: "w:fill",
2029
2090
  value: fill === void 0 ? void 0 : hexColorValue(fill)
2030
2091
  },
2092
+ themeColor: {
2093
+ key: "w:themeColor",
2094
+ value: themeColor
2095
+ },
2096
+ themeFill: {
2097
+ key: "w:themeFill",
2098
+ value: themeFill
2099
+ },
2100
+ themeFillShade: {
2101
+ key: "w:themeFillShade",
2102
+ value: themeFillShade === void 0 ? void 0 : uCharHexNumber(themeFillShade)
2103
+ },
2104
+ themeFillTint: {
2105
+ key: "w:themeFillTint",
2106
+ value: themeFillTint === void 0 ? void 0 : uCharHexNumber(themeFillTint)
2107
+ },
2108
+ themeShade: {
2109
+ key: "w:themeShade",
2110
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2111
+ },
2112
+ themeTint: {
2113
+ key: "w:themeTint",
2114
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2115
+ },
2031
2116
  type: {
2032
2117
  key: "w:val",
2033
2118
  value: type
@@ -2206,7 +2291,13 @@ var InsertionTrackChange = class extends XmlComponent {
2206
2291
  *
2207
2292
  * @publicApi
2208
2293
  */
2209
- const EmphasisMarkType = { DOT: "dot" };
2294
+ const EmphasisMarkType = {
2295
+ NONE: "none",
2296
+ COMMA: "comma",
2297
+ CIRCLE: "circle",
2298
+ DOT: "dot",
2299
+ UNDER_DOT: "underDot"
2300
+ };
2210
2301
  /**
2211
2302
  * Creates an emphasis mark element for a WordprocessingML document.
2212
2303
  *
@@ -2297,16 +2388,27 @@ var CharacterSpacing = class extends XmlComponent {
2297
2388
  *
2298
2389
  * @example
2299
2390
  * ```typescript
2300
- * new Color("FF0000"); // Red text
2391
+ * new Color("FF0000"); // Red text (backward compatible)
2301
2392
  * new Color("auto"); // Automatic color
2393
+ * new Color({ themeColor: ThemeColor.ACCENT1, themeTint: "99" }); // Theme color with tint
2302
2394
  * ```
2303
2395
  *
2304
2396
  * @internal
2305
2397
  */
2306
2398
  var Color = class extends XmlComponent {
2307
- constructor(color) {
2399
+ constructor(colorOrOptions) {
2308
2400
  super("w:color");
2309
- this.root.push(new Attributes({ val: hexColorValue(color) }));
2401
+ if (typeof colorOrOptions === "string") {
2402
+ this.root.push(new Attributes({ val: hexColorValue(colorOrOptions) }));
2403
+ return;
2404
+ }
2405
+ const opts = colorOrOptions;
2406
+ this.root.push(new Attributes({
2407
+ val: opts.val === void 0 ? void 0 : hexColorValue(opts.val),
2408
+ themeColor: opts.themeColor,
2409
+ themeTint: opts.themeTint === void 0 ? void 0 : uCharHexNumber(opts.themeTint),
2410
+ themeShade: opts.themeShade === void 0 ? void 0 : uCharHexNumber(opts.themeShade)
2411
+ }));
2310
2412
  }
2311
2413
  };
2312
2414
  /**
@@ -2505,18 +2607,34 @@ const createRunFonts = (nameOrAttrs, hint) => {
2505
2607
  key: "w:ascii",
2506
2608
  value: attrs.ascii
2507
2609
  },
2610
+ asciiTheme: {
2611
+ key: "w:asciiTheme",
2612
+ value: attrs.asciiTheme
2613
+ },
2508
2614
  cs: {
2509
2615
  key: "w:cs",
2510
2616
  value: attrs.cs
2511
2617
  },
2618
+ cstheme: {
2619
+ key: "w:cstheme",
2620
+ value: attrs.cstheme
2621
+ },
2512
2622
  eastAsia: {
2513
2623
  key: "w:eastAsia",
2514
2624
  value: attrs.eastAsia
2515
2625
  },
2626
+ eastAsiaTheme: {
2627
+ key: "w:eastAsiaTheme",
2628
+ value: attrs.eastAsiaTheme
2629
+ },
2516
2630
  hAnsi: {
2517
2631
  key: "w:hAnsi",
2518
2632
  value: attrs.hAnsi
2519
2633
  },
2634
+ hAnsiTheme: {
2635
+ key: "w:hAnsiTheme",
2636
+ value: attrs.hAnsiTheme
2637
+ },
2520
2638
  hint: {
2521
2639
  key: "w:hint",
2522
2640
  value: attrs.hint
@@ -2673,12 +2791,24 @@ const UnderlineType = {
2673
2791
  * createUnderline(UnderlineType.WAVE, "FF0000");
2674
2792
  * ```
2675
2793
  */
2676
- const createUnderline = (underlineType = UnderlineType.SINGLE, color) => new BuilderElement({
2794
+ const createUnderline = (underlineType = UnderlineType.SINGLE, color, themeColor, themeTint, themeShade) => new BuilderElement({
2677
2795
  attributes: {
2678
2796
  color: {
2679
2797
  key: "w:color",
2680
2798
  value: color === void 0 ? void 0 : hexColorValue(color)
2681
2799
  },
2800
+ themeColor: {
2801
+ key: "w:themeColor",
2802
+ value: themeColor
2803
+ },
2804
+ themeShade: {
2805
+ key: "w:themeShade",
2806
+ value: themeShade === void 0 ? void 0 : uCharHexNumber(themeShade)
2807
+ },
2808
+ themeTint: {
2809
+ key: "w:themeTint",
2810
+ value: themeTint === void 0 ? void 0 : uCharHexNumber(themeTint)
2811
+ },
2682
2812
  val: {
2683
2813
  key: "w:val",
2684
2814
  value: underlineType
@@ -2830,6 +2960,9 @@ var RunProperties = class extends IgnoreIfEmptyXmlComponent {
2830
2960
  if (options.doubleStrike !== void 0) this.push(new OnOffElement("w:dstrike", options.doubleStrike));
2831
2961
  if (options.emboss !== void 0) this.push(new OnOffElement("w:emboss", options.emboss));
2832
2962
  if (options.imprint !== void 0) this.push(new OnOffElement("w:imprint", options.imprint));
2963
+ if (options.outline !== void 0) this.push(new OnOffElement("w:outline", options.outline));
2964
+ if (options.shadow !== void 0) this.push(new OnOffElement("w:shadow", options.shadow));
2965
+ if (options.webHidden !== void 0) this.push(new OnOffElement("w:webHidden", options.webHidden));
2833
2966
  if (options.noProof !== void 0) this.push(new OnOffElement("w:noProof", options.noProof));
2834
2967
  if (options.snapToGrid !== void 0) this.push(new OnOffElement("w:snapToGrid", options.snapToGrid));
2835
2968
  if (options.vanish) this.push(new OnOffElement("w:vanish", options.vanish));
@@ -2855,6 +2988,8 @@ var RunProperties = class extends IgnoreIfEmptyXmlComponent {
2855
2988
  if (options.language) this.push(createLanguageComponent(options.language));
2856
2989
  if (options.specVanish) this.push(new OnOffElement("w:specVanish", options.vanish));
2857
2990
  if (options.math) this.push(new OnOffElement("w:oMath", options.math));
2991
+ if (options.fitText !== void 0) this.push(new NumberValueElement("w:fitText", options.fitText));
2992
+ if (options.complexScript !== void 0) this.push(new OnOffElement("w:cs", options.complexScript));
2858
2993
  if (options.revision) this.push(new RunPropertiesChange(options.revision));
2859
2994
  }
2860
2995
  push(item) {
@@ -3290,18 +3425,6 @@ const generateUuidPart = (count) => customAlphabet("1234567890abcdef", count)();
3290
3425
  * ```
3291
3426
  */
3292
3427
  const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
3293
- /**
3294
- * Encode a string to UTF-8 bytes.
3295
- *
3296
- * This is used to pre-encode XML content before passing to fflate's zipSync,
3297
- * which expects Uint8Array input for text content.
3298
- *
3299
- * The copy via `new Uint8Array()` ensures the returned array uses the
3300
- * current module's Uint8Array constructor, avoiding cross-realm issues
3301
- * in test environments (happy-dom) where TextEncoder returns a different
3302
- * realm's Uint8Array.
3303
- */
3304
- const encodeUtf8 = (str) => new Uint8Array(new TextEncoder().encode(str));
3305
3428
  //#endregion
3306
3429
  //#region src/file/drawing/floating/floating-position.ts
3307
3430
  /**
@@ -4708,13 +4831,16 @@ var ChildNonVisualProperties = class extends XmlComponent {
4708
4831
  * @returns An XML component representing the click hyperlink
4709
4832
  */
4710
4833
  const createHyperlinkClick = (linkId, hasXmlNs) => new BuilderElement({
4711
- attributes: _objectSpread2(_objectSpread2({}, hasXmlNs ? { xmlns: {
4712
- key: "xmlns:a",
4713
- value: "http://schemas.openxmlformats.org/drawingml/2006/main"
4714
- } } : {}), {}, { id: {
4715
- key: "r:id",
4716
- value: `rId${linkId}`
4717
- } }),
4834
+ attributes: {
4835
+ ...hasXmlNs ? { xmlns: {
4836
+ key: "xmlns:a",
4837
+ value: "http://schemas.openxmlformats.org/drawingml/2006/main"
4838
+ } } : {},
4839
+ id: {
4840
+ key: "r:id",
4841
+ value: `rId${linkId}`
4842
+ }
4843
+ },
4718
4844
  name: "a:hlinkClick"
4719
4845
  });
4720
4846
  //#endregion
@@ -4962,21 +5088,23 @@ var GraphicData = class extends XmlComponent {
4962
5088
  super("a:graphicData");
4963
5089
  if (mediaData.type === "wps") {
4964
5090
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }));
4965
- const wps = createWpsShape(_objectSpread2(_objectSpread2({}, mediaData.data), {}, {
5091
+ const wps = createWpsShape({
5092
+ ...mediaData.data,
4966
5093
  outline,
4967
5094
  solidFill,
4968
5095
  transformation: transform
4969
- }));
5096
+ });
4970
5097
  this.root.push(wps);
4971
5098
  } else if (mediaData.type === "wpg") {
4972
5099
  this.root.push(new GraphicDataAttributes({ uri: "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" }));
4973
5100
  const wpg = createWpgGroup({
4974
5101
  children: mediaData.children.map((child) => {
4975
- if (child.type === "wps") return createWpsShape(_objectSpread2(_objectSpread2({}, child.data), {}, {
5102
+ if (child.type === "wps") return createWpsShape({
5103
+ ...child.data,
4976
5104
  outline: child.outline,
4977
5105
  solidFill: child.solidFill,
4978
5106
  transformation: child.transformation
4979
- }));
5107
+ });
4980
5108
  else return new Pic({
4981
5109
  mediaData: child,
4982
5110
  outline: child.outline,
@@ -5605,14 +5733,15 @@ var AnchorAttributes = class extends XmlAttributeComponent {
5605
5733
  var Anchor = class extends XmlComponent {
5606
5734
  constructor({ mediaData, transform, drawingOptions }) {
5607
5735
  super("wp:anchor");
5608
- const floating = _objectSpread2({
5736
+ const floating = {
5609
5737
  allowOverlap: true,
5610
5738
  behindDocument: false,
5611
5739
  horizontalPosition: {},
5612
5740
  layoutInCell: true,
5613
5741
  lockAnchor: false,
5614
- verticalPosition: {}
5615
- }, drawingOptions.floating);
5742
+ verticalPosition: {},
5743
+ ...drawingOptions.floating
5744
+ };
5616
5745
  this.root.push(new AnchorAttributes({
5617
5746
  distT: floating.margins ? floating.margins.top || 0 : 0,
5618
5747
  distB: floating.margins ? floating.margins.bottom || 0 : 0,
@@ -5798,8 +5927,18 @@ var ImageRun = class extends Run {
5798
5927
  const key = `${hashedId(rawData)}.${options.type}`;
5799
5928
  if (options.type === "svg") {
5800
5929
  const fallbackData = toUint8Array(options.fallback.data);
5801
- this.imageData = _objectSpread2(_objectSpread2({ type: options.type }, createImageData(rawData, options.transformation, key)), {}, { fallback: _objectSpread2({ type: options.fallback.type }, createImageData(fallbackData, options.transformation, `${hashedId(fallbackData)}.${options.fallback.type}`)) });
5802
- } else this.imageData = _objectSpread2({ type: options.type }, createImageData(rawData, options.transformation, key));
5930
+ this.imageData = {
5931
+ type: options.type,
5932
+ ...createImageData(rawData, options.transformation, key),
5933
+ fallback: {
5934
+ type: options.fallback.type,
5935
+ ...createImageData(fallbackData, options.transformation, `${hashedId(fallbackData)}.${options.fallback.type}`)
5936
+ }
5937
+ };
5938
+ } else this.imageData = {
5939
+ type: options.type,
5940
+ ...createImageData(rawData, options.transformation, key)
5941
+ };
5803
5942
  const drawing = new Drawing(this.imageData, {
5804
5943
  docProperties: options.altText,
5805
5944
  floating: options.floating,
@@ -5848,7 +5987,7 @@ var WpsShapeRun = class extends Run {
5848
5987
  super({});
5849
5988
  _defineProperty(this, "wpsShapeData", void 0);
5850
5989
  this.wpsShapeData = {
5851
- data: _objectSpread2({}, options),
5990
+ data: { ...options },
5852
5991
  transformation: createTransformation(options.transformation),
5853
5992
  type: options.type
5854
5993
  };
@@ -6948,7 +7087,7 @@ const LineRuleType = {
6948
7087
  * });
6949
7088
  * ```
6950
7089
  */
6951
- const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing }) => new BuilderElement({
7090
+ const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, afterAutoSpacing, beforeLines, afterLines }) => new BuilderElement({
6952
7091
  attributes: {
6953
7092
  after: {
6954
7093
  key: "w:after",
@@ -6958,6 +7097,10 @@ const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, after
6958
7097
  key: "w:afterAutospacing",
6959
7098
  value: afterAutoSpacing
6960
7099
  },
7100
+ afterLines: {
7101
+ key: "w:afterLines",
7102
+ value: afterLines === void 0 ? void 0 : decimalNumber(afterLines)
7103
+ },
6961
7104
  before: {
6962
7105
  key: "w:before",
6963
7106
  value: before
@@ -6966,6 +7109,10 @@ const createSpacing = ({ after, before, line, lineRule, beforeAutoSpacing, after
6966
7109
  key: "w:beforeAutospacing",
6967
7110
  value: beforeAutoSpacing
6968
7111
  },
7112
+ beforeLines: {
7113
+ key: "w:beforeLines",
7114
+ value: beforeLines === void 0 ? void 0 : decimalNumber(beforeLines)
7115
+ },
6969
7116
  line: {
6970
7117
  key: "w:line",
6971
7118
  value: line
@@ -7076,6 +7223,7 @@ const TabStopType = {
7076
7223
  */
7077
7224
  const LeaderType = {
7078
7225
  DOT: "dot",
7226
+ HEAVY: "heavy",
7079
7227
  HYPHEN: "hyphen",
7080
7228
  MIDDLE_DOT: "middleDot",
7081
7229
  NONE: "none",
@@ -7875,13 +8023,16 @@ const CharacterSet = {
7875
8023
  * Creates a font relationship element for embedding fonts.
7876
8024
  */
7877
8025
  const createFontRelationship = ({ id, fontKey, subsetted }, name) => new BuilderElement({
7878
- attributes: _objectSpread2({ id: {
7879
- key: "r:id",
7880
- value: id
7881
- } }, fontKey ? { fontKey: {
7882
- key: "w:fontKey",
7883
- value: `{${fontKey}}`
7884
- } } : {}),
8026
+ attributes: {
8027
+ id: {
8028
+ key: "r:id",
8029
+ value: id
8030
+ },
8031
+ ...fontKey ? { fontKey: {
8032
+ key: "w:fontKey",
8033
+ value: `{${fontKey}}`
8034
+ } } : {}
8035
+ },
7885
8036
  children: subsetted ? [new OnOffElement("w:subsetted", subsetted)] : [],
7886
8037
  name
7887
8038
  });
@@ -8119,7 +8270,10 @@ var FontWrapper = class {
8119
8270
  _defineProperty(this, "fontTable", void 0);
8120
8271
  _defineProperty(this, "relationships", void 0);
8121
8272
  _defineProperty(this, "fontOptionsWithKey", []);
8122
- this.fontOptionsWithKey = options.map((o) => _objectSpread2(_objectSpread2({}, o), {}, { fontKey: uniqueUuid() }));
8273
+ this.fontOptionsWithKey = options.map((o) => ({
8274
+ ...o,
8275
+ fontKey: uniqueUuid()
8276
+ }));
8123
8277
  this.fontTable = createFontTable(this.fontOptionsWithKey);
8124
8278
  this.relationships = new Relationships();
8125
8279
  for (let i = 0; i < options.length; i++) this.relationships.addRelationship(i + 1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font", `fonts/${options[i].name}.odttf`);
@@ -8537,7 +8691,10 @@ var ParagraphPropertiesChange = class extends XmlComponent {
8537
8691
  date: options.date,
8538
8692
  id: options.id
8539
8693
  }));
8540
- this.root.push(new ParagraphProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
8694
+ this.root.push(new ParagraphProperties({
8695
+ ...options,
8696
+ includeIfEmpty: true
8697
+ }));
8541
8698
  }
8542
8699
  };
8543
8700
  //#endregion
@@ -10752,7 +10909,10 @@ const VerticalAlignTable = {
10752
10909
  *
10753
10910
  * @publicApi
10754
10911
  */
10755
- const VerticalAlignSection = _objectSpread2(_objectSpread2({}, VerticalAlignTable), {}, { BOTH: "both" });
10912
+ const VerticalAlignSection = {
10913
+ ...VerticalAlignTable,
10914
+ BOTH: "both"
10915
+ };
10756
10916
  /**
10757
10917
  * @deprecated Use {@link VerticalAlignTable} for table cells or
10758
10918
  * {@link VerticalAlignSection} for section properties. This alias remains for
@@ -11269,7 +11429,10 @@ var TableCellPropertiesChange = class extends XmlComponent {
11269
11429
  date: options.date,
11270
11430
  id: options.id
11271
11431
  }));
11272
- this.root.push(new TableCellProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
11432
+ this.root.push(new TableCellProperties({
11433
+ ...options,
11434
+ includeIfEmpty: true
11435
+ }));
11273
11436
  }
11274
11437
  };
11275
11438
  //#endregion
@@ -11813,7 +11976,10 @@ var TablePropertiesChange = class extends XmlComponent {
11813
11976
  date: options.date,
11814
11977
  id: options.id
11815
11978
  }));
11816
- this.root.push(new TableProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
11979
+ this.root.push(new TableProperties({
11980
+ ...options,
11981
+ includeIfEmpty: true
11982
+ }));
11817
11983
  }
11818
11984
  };
11819
11985
  //#endregion
@@ -12058,7 +12224,10 @@ var TableRowPropertiesChange = class extends XmlComponent {
12058
12224
  date: options.date,
12059
12225
  id: options.id
12060
12226
  }));
12061
- this.root.push(new TableRowProperties(_objectSpread2(_objectSpread2({}, options), {}, { includeIfEmpty: true })));
12227
+ this.root.push(new TableRowProperties({
12228
+ ...options,
12229
+ includeIfEmpty: true
12230
+ }));
12062
12231
  }
12063
12232
  };
12064
12233
  //#endregion
@@ -12457,8 +12626,14 @@ const DocumentAttributeNamespaces = {
12457
12626
  */
12458
12627
  var DocumentAttributes = class extends XmlAttributeComponent {
12459
12628
  constructor(ns, Ignorable) {
12460
- super(_objectSpread2({ Ignorable }, Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))));
12461
- _defineProperty(this, "xmlKeys", _objectSpread2({ Ignorable: "mc:Ignorable" }, Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))));
12629
+ super({
12630
+ Ignorable,
12631
+ ...Object.fromEntries(ns.map((n) => [n, DocumentAttributeNamespaces[n]]))
12632
+ });
12633
+ _defineProperty(this, "xmlKeys", {
12634
+ Ignorable: "mc:Ignorable",
12635
+ ...Object.fromEntries(Object.keys(DocumentAttributeNamespaces).map((key) => [key, `xmlns:${key}`]))
12636
+ });
12462
12637
  }
12463
12638
  };
12464
12639
  //#endregion
@@ -16138,7 +16313,10 @@ var Settings = class extends XmlComponent {
16138
16313
  if (((_options$hyphenation2 = options.hyphenation) === null || _options$hyphenation2 === void 0 ? void 0 : _options$hyphenation2.hyphenationZone) !== void 0) this.root.push(new NumberValueElement("w:hyphenationZone", options.hyphenation.hyphenationZone));
16139
16314
  if (((_options$hyphenation3 = options.hyphenation) === null || _options$hyphenation3 === void 0 ? void 0 : _options$hyphenation3.consecutiveHyphenLimit) !== void 0) this.root.push(new NumberValueElement("w:consecutiveHyphenLimit", options.hyphenation.consecutiveHyphenLimit));
16140
16315
  if (((_options$hyphenation4 = options.hyphenation) === null || _options$hyphenation4 === void 0 ? void 0 : _options$hyphenation4.doNotHyphenateCaps) !== void 0) this.root.push(new OnOffElement("w:doNotHyphenateCaps", options.hyphenation.doNotHyphenateCaps));
16141
- this.root.push(new Compatibility(_objectSpread2(_objectSpread2({}, options.compatibility), {}, { version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15 })));
16316
+ this.root.push(new Compatibility({
16317
+ ...options.compatibility,
16318
+ version: (_ref = (_options$compatibilit = (_options$compatibilit2 = options.compatibility) === null || _options$compatibilit2 === void 0 ? void 0 : _options$compatibilit2.version) !== null && _options$compatibilit !== void 0 ? _options$compatibilit : options.compatibilityModeVersion) !== null && _ref !== void 0 ? _ref : 15
16319
+ }));
16142
16320
  }
16143
16321
  };
16144
16322
  //#endregion
@@ -16407,10 +16585,11 @@ var StyleForCharacter = class extends Style {
16407
16585
  super({
16408
16586
  styleId: options.id,
16409
16587
  type: "character"
16410
- }, _objectSpread2({
16588
+ }, {
16411
16589
  uiPriority: 99,
16412
- unhideWhenUsed: true
16413
- }, options));
16590
+ unhideWhenUsed: true,
16591
+ ...options
16592
+ });
16414
16593
  _defineProperty(this, "runProperties", void 0);
16415
16594
  this.runProperties = new RunProperties(options.run);
16416
16595
  this.root.push(this.runProperties);
@@ -16446,11 +16625,12 @@ var StyleForCharacter = class extends Style {
16446
16625
  */
16447
16626
  var HeadingStyle = class extends StyleForParagraph {
16448
16627
  constructor(options) {
16449
- super(_objectSpread2({
16628
+ super({
16450
16629
  basedOn: "Normal",
16451
16630
  next: "Normal",
16452
- quickFormat: true
16453
- }, options));
16631
+ quickFormat: true,
16632
+ ...options
16633
+ });
16454
16634
  }
16455
16635
  };
16456
16636
  /**
@@ -16467,10 +16647,11 @@ var HeadingStyle = class extends StyleForParagraph {
16467
16647
  */
16468
16648
  var TitleStyle = class extends HeadingStyle {
16469
16649
  constructor(options) {
16470
- super(_objectSpread2({
16650
+ super({
16471
16651
  id: "Title",
16472
- name: "Title"
16473
- }, options));
16652
+ name: "Title",
16653
+ ...options
16654
+ });
16474
16655
  }
16475
16656
  };
16476
16657
  /**
@@ -16487,10 +16668,11 @@ var TitleStyle = class extends HeadingStyle {
16487
16668
  */
16488
16669
  var Heading1Style = class extends HeadingStyle {
16489
16670
  constructor(options) {
16490
- super(_objectSpread2({
16671
+ super({
16491
16672
  id: "Heading1",
16492
- name: "Heading 1"
16493
- }, options));
16673
+ name: "Heading 1",
16674
+ ...options
16675
+ });
16494
16676
  }
16495
16677
  };
16496
16678
  /**
@@ -16500,10 +16682,11 @@ var Heading1Style = class extends HeadingStyle {
16500
16682
  */
16501
16683
  var Heading2Style = class extends HeadingStyle {
16502
16684
  constructor(options) {
16503
- super(_objectSpread2({
16685
+ super({
16504
16686
  id: "Heading2",
16505
- name: "Heading 2"
16506
- }, options));
16687
+ name: "Heading 2",
16688
+ ...options
16689
+ });
16507
16690
  }
16508
16691
  };
16509
16692
  /**
@@ -16513,10 +16696,11 @@ var Heading2Style = class extends HeadingStyle {
16513
16696
  */
16514
16697
  var Heading3Style = class extends HeadingStyle {
16515
16698
  constructor(options) {
16516
- super(_objectSpread2({
16699
+ super({
16517
16700
  id: "Heading3",
16518
- name: "Heading 3"
16519
- }, options));
16701
+ name: "Heading 3",
16702
+ ...options
16703
+ });
16520
16704
  }
16521
16705
  };
16522
16706
  /**
@@ -16526,10 +16710,11 @@ var Heading3Style = class extends HeadingStyle {
16526
16710
  */
16527
16711
  var Heading4Style = class extends HeadingStyle {
16528
16712
  constructor(options) {
16529
- super(_objectSpread2({
16713
+ super({
16530
16714
  id: "Heading4",
16531
- name: "Heading 4"
16532
- }, options));
16715
+ name: "Heading 4",
16716
+ ...options
16717
+ });
16533
16718
  }
16534
16719
  };
16535
16720
  /**
@@ -16539,10 +16724,11 @@ var Heading4Style = class extends HeadingStyle {
16539
16724
  */
16540
16725
  var Heading5Style = class extends HeadingStyle {
16541
16726
  constructor(options) {
16542
- super(_objectSpread2({
16727
+ super({
16543
16728
  id: "Heading5",
16544
- name: "Heading 5"
16545
- }, options));
16729
+ name: "Heading 5",
16730
+ ...options
16731
+ });
16546
16732
  }
16547
16733
  };
16548
16734
  /**
@@ -16552,10 +16738,11 @@ var Heading5Style = class extends HeadingStyle {
16552
16738
  */
16553
16739
  var Heading6Style = class extends HeadingStyle {
16554
16740
  constructor(options) {
16555
- super(_objectSpread2({
16741
+ super({
16556
16742
  id: "Heading6",
16557
- name: "Heading 6"
16558
- }, options));
16743
+ name: "Heading 6",
16744
+ ...options
16745
+ });
16559
16746
  }
16560
16747
  };
16561
16748
  /**
@@ -16565,10 +16752,11 @@ var Heading6Style = class extends HeadingStyle {
16565
16752
  */
16566
16753
  var StrongStyle = class extends HeadingStyle {
16567
16754
  constructor(options) {
16568
- super(_objectSpread2({
16755
+ super({
16569
16756
  id: "Strong",
16570
- name: "Strong"
16571
- }, options));
16757
+ name: "Strong",
16758
+ ...options
16759
+ });
16572
16760
  }
16573
16761
  };
16574
16762
  /**
@@ -16578,12 +16766,13 @@ var StrongStyle = class extends HeadingStyle {
16578
16766
  */
16579
16767
  var ListParagraph = class extends StyleForParagraph {
16580
16768
  constructor(options) {
16581
- super(_objectSpread2({
16769
+ super({
16582
16770
  basedOn: "Normal",
16583
16771
  id: "ListParagraph",
16584
16772
  name: "List Paragraph",
16585
- quickFormat: true
16586
- }, options));
16773
+ quickFormat: true,
16774
+ ...options
16775
+ });
16587
16776
  }
16588
16777
  };
16589
16778
  /**
@@ -16593,7 +16782,7 @@ var ListParagraph = class extends StyleForParagraph {
16593
16782
  */
16594
16783
  var FootnoteText = class extends StyleForParagraph {
16595
16784
  constructor(options) {
16596
- super(_objectSpread2({
16785
+ super({
16597
16786
  basedOn: "Normal",
16598
16787
  id: "FootnoteText",
16599
16788
  link: "FootnoteTextChar",
@@ -16606,8 +16795,9 @@ var FootnoteText = class extends StyleForParagraph {
16606
16795
  run: { size: 20 },
16607
16796
  semiHidden: true,
16608
16797
  uiPriority: 99,
16609
- unhideWhenUsed: true
16610
- }, options));
16798
+ unhideWhenUsed: true,
16799
+ ...options
16800
+ });
16611
16801
  }
16612
16802
  };
16613
16803
  /**
@@ -16617,13 +16807,14 @@ var FootnoteText = class extends StyleForParagraph {
16617
16807
  */
16618
16808
  var FootnoteReferenceStyle = class extends StyleForCharacter {
16619
16809
  constructor(options) {
16620
- super(_objectSpread2({
16810
+ super({
16621
16811
  basedOn: "DefaultParagraphFont",
16622
16812
  id: "FootnoteReference",
16623
16813
  name: "footnote reference",
16624
16814
  run: { superScript: true },
16625
- semiHidden: true
16626
- }, options));
16815
+ semiHidden: true,
16816
+ ...options
16817
+ });
16627
16818
  }
16628
16819
  };
16629
16820
  /**
@@ -16633,14 +16824,15 @@ var FootnoteReferenceStyle = class extends StyleForCharacter {
16633
16824
  */
16634
16825
  var FootnoteTextChar = class extends StyleForCharacter {
16635
16826
  constructor(options) {
16636
- super(_objectSpread2({
16827
+ super({
16637
16828
  basedOn: "DefaultParagraphFont",
16638
16829
  id: "FootnoteTextChar",
16639
16830
  link: "FootnoteText",
16640
16831
  name: "Footnote Text Char",
16641
16832
  run: { size: 20 },
16642
- semiHidden: true
16643
- }, options));
16833
+ semiHidden: true,
16834
+ ...options
16835
+ });
16644
16836
  }
16645
16837
  };
16646
16838
  /**
@@ -16650,7 +16842,7 @@ var FootnoteTextChar = class extends StyleForCharacter {
16650
16842
  */
16651
16843
  var EndnoteText = class extends StyleForParagraph {
16652
16844
  constructor(options) {
16653
- super(_objectSpread2({
16845
+ super({
16654
16846
  basedOn: "Normal",
16655
16847
  id: "EndnoteText",
16656
16848
  link: "EndnoteTextChar",
@@ -16663,8 +16855,9 @@ var EndnoteText = class extends StyleForParagraph {
16663
16855
  run: { size: 20 },
16664
16856
  semiHidden: true,
16665
16857
  uiPriority: 99,
16666
- unhideWhenUsed: true
16667
- }, options));
16858
+ unhideWhenUsed: true,
16859
+ ...options
16860
+ });
16668
16861
  }
16669
16862
  };
16670
16863
  /**
@@ -16674,13 +16867,14 @@ var EndnoteText = class extends StyleForParagraph {
16674
16867
  */
16675
16868
  var EndnoteReferenceStyle = class extends StyleForCharacter {
16676
16869
  constructor(options) {
16677
- super(_objectSpread2({
16870
+ super({
16678
16871
  basedOn: "DefaultParagraphFont",
16679
16872
  id: "EndnoteReference",
16680
16873
  name: "endnote reference",
16681
16874
  run: { superScript: true },
16682
- semiHidden: true
16683
- }, options));
16875
+ semiHidden: true,
16876
+ ...options
16877
+ });
16684
16878
  }
16685
16879
  };
16686
16880
  /**
@@ -16690,14 +16884,15 @@ var EndnoteReferenceStyle = class extends StyleForCharacter {
16690
16884
  */
16691
16885
  var EndnoteTextChar = class extends StyleForCharacter {
16692
16886
  constructor(options) {
16693
- super(_objectSpread2({
16887
+ super({
16694
16888
  basedOn: "DefaultParagraphFont",
16695
16889
  id: "EndnoteTextChar",
16696
16890
  link: "EndnoteText",
16697
16891
  name: "Endnote Text Char",
16698
16892
  run: { size: 20 },
16699
- semiHidden: true
16700
- }, options));
16893
+ semiHidden: true,
16894
+ ...options
16895
+ });
16701
16896
  }
16702
16897
  };
16703
16898
  /**
@@ -16707,15 +16902,16 @@ var EndnoteTextChar = class extends StyleForCharacter {
16707
16902
  */
16708
16903
  var HyperlinkStyle = class extends StyleForCharacter {
16709
16904
  constructor(options) {
16710
- super(_objectSpread2({
16905
+ super({
16711
16906
  basedOn: "DefaultParagraphFont",
16712
16907
  id: "Hyperlink",
16713
16908
  name: "Hyperlink",
16714
16909
  run: {
16715
16910
  color: "0563C1",
16716
16911
  underline: { type: UnderlineType.SINGLE }
16717
- }
16718
- }, options));
16912
+ },
16913
+ ...options
16914
+ });
16719
16915
  }
16720
16916
  };
16721
16917
  //#endregion
@@ -16985,26 +17181,50 @@ var DefaultStylesFactory = class {
16985
17181
  return {
16986
17182
  importedStyles: [
16987
17183
  new DocumentDefaults((_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : {}),
16988
- new TitleStyle(_objectSpread2({ run: { size: 56 } }, options.title)),
16989
- new Heading1Style(_objectSpread2({ run: {
16990
- color: "2E74B5",
16991
- size: 32
16992
- } }, options.heading1)),
16993
- new Heading2Style(_objectSpread2({ run: {
16994
- color: "2E74B5",
16995
- size: 26
16996
- } }, options.heading2)),
16997
- new Heading3Style(_objectSpread2({ run: {
16998
- color: "1F4D78",
16999
- size: 24
17000
- } }, options.heading3)),
17001
- new Heading4Style(_objectSpread2({ run: {
17002
- color: "2E74B5",
17003
- italics: true
17004
- } }, options.heading4)),
17005
- new Heading5Style(_objectSpread2({ run: { color: "2E74B5" } }, options.heading5)),
17006
- new Heading6Style(_objectSpread2({ run: { color: "1F4D78" } }, options.heading6)),
17007
- new StrongStyle(_objectSpread2({ run: { bold: true } }, options.strong)),
17184
+ new TitleStyle({
17185
+ run: { size: 56 },
17186
+ ...options.title
17187
+ }),
17188
+ new Heading1Style({
17189
+ run: {
17190
+ color: "2E74B5",
17191
+ size: 32
17192
+ },
17193
+ ...options.heading1
17194
+ }),
17195
+ new Heading2Style({
17196
+ run: {
17197
+ color: "2E74B5",
17198
+ size: 26
17199
+ },
17200
+ ...options.heading2
17201
+ }),
17202
+ new Heading3Style({
17203
+ run: {
17204
+ color: "1F4D78",
17205
+ size: 24
17206
+ },
17207
+ ...options.heading3
17208
+ }),
17209
+ new Heading4Style({
17210
+ run: {
17211
+ color: "2E74B5",
17212
+ italics: true
17213
+ },
17214
+ ...options.heading4
17215
+ }),
17216
+ new Heading5Style({
17217
+ run: { color: "2E74B5" },
17218
+ ...options.heading5
17219
+ }),
17220
+ new Heading6Style({
17221
+ run: { color: "1F4D78" },
17222
+ ...options.heading6
17223
+ }),
17224
+ new StrongStyle({
17225
+ run: { bold: true },
17226
+ ...options.strong
17227
+ }),
17008
17228
  new ListParagraph(options.listParagraph || {}),
17009
17229
  new HyperlinkStyle(options.hyperlink || {}),
17010
17230
  new FootnoteReferenceStyle(options.footnoteReference || {}),
@@ -17122,11 +17342,12 @@ var File = class {
17122
17342
  _defineProperty(this, "styles", void 0);
17123
17343
  _defineProperty(this, "comments", void 0);
17124
17344
  _defineProperty(this, "fontWrapper", void 0);
17125
- this.coreProperties = new CoreProperties(_objectSpread2(_objectSpread2({}, options), {}, {
17345
+ this.coreProperties = new CoreProperties({
17346
+ ...options,
17126
17347
  creator: (_options$creator = options.creator) !== null && _options$creator !== void 0 ? _options$creator : "Un-named",
17127
17348
  lastModifiedBy: (_options$lastModified = options.lastModifiedBy) !== null && _options$lastModified !== void 0 ? _options$lastModified : "Un-named",
17128
17349
  revision: (_options$revision = options.revision) !== null && _options$revision !== void 0 ? _options$revision : 1
17129
- }));
17350
+ });
17130
17351
  this.numbering = new Numbering(options.numbering ? options.numbering : { config: [] });
17131
17352
  this.comments = new Comments((_options$comments = options.comments) !== null && _options$comments !== void 0 ? _options$comments : { children: [] });
17132
17353
  this.fileRelationships = new Relationships();
@@ -17155,8 +17376,14 @@ var File = class {
17155
17376
  var _options$styles;
17156
17377
  const defaultStyles = new DefaultStylesFactory().newInstance((_options$styles = options.styles) === null || _options$styles === void 0 ? void 0 : _options$styles.default);
17157
17378
  const externalStyles = new ExternalStylesFactory().newInstance(options.externalStyles);
17158
- this.styles = new Styles(_objectSpread2(_objectSpread2({}, externalStyles), {}, { importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles] }));
17159
- } else if (options.styles) this.styles = new Styles(_objectSpread2(_objectSpread2({}, new DefaultStylesFactory().newInstance(options.styles.default)), options.styles));
17379
+ this.styles = new Styles({
17380
+ ...externalStyles,
17381
+ importedStyles: [...defaultStyles.importedStyles, ...externalStyles.importedStyles]
17382
+ });
17383
+ } else if (options.styles) this.styles = new Styles({
17384
+ ...new DefaultStylesFactory().newInstance(options.styles.default),
17385
+ ...options.styles
17386
+ });
17160
17387
  else this.styles = new Styles(new DefaultStylesFactory().newInstance());
17161
17388
  this.addDefaultRelationships();
17162
17389
  for (const section of options.sections) this.addSection(section);
@@ -17165,7 +17392,8 @@ var File = class {
17165
17392
  this.fontWrapper = new FontWrapper((_options$fonts = options.fonts) !== null && _options$fonts !== void 0 ? _options$fonts : []);
17166
17393
  }
17167
17394
  addSection({ headers = {}, footers = {}, children, properties }) {
17168
- this.documentWrapper.View.Body.addSection(_objectSpread2(_objectSpread2({}, properties), {}, {
17395
+ this.documentWrapper.View.Body.addSection({
17396
+ ...properties,
17169
17397
  footerWrapperGroup: {
17170
17398
  default: footers.default ? this.createFooter(footers.default) : void 0,
17171
17399
  even: footers.even ? this.createFooter(footers.even) : void 0,
@@ -17176,7 +17404,7 @@ var File = class {
17176
17404
  even: headers.even ? this.createHeader(headers.even) : void 0,
17177
17405
  first: headers.first ? this.createHeader(headers.first) : void 0
17178
17406
  }
17179
- }));
17407
+ });
17180
17408
  for (const child of children) this.documentWrapper.View.add(child);
17181
17409
  }
17182
17410
  createHeader(header) {
@@ -17433,28 +17661,6 @@ var StructuredDocumentTagProperties = class extends XmlComponent {
17433
17661
  }
17434
17662
  };
17435
17663
  //#endregion
17436
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutPropertiesLoose.js
17437
- function _objectWithoutPropertiesLoose(r, e) {
17438
- if (null == r) return {};
17439
- var t = {};
17440
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
17441
- if (e.includes(n)) continue;
17442
- t[n] = r[n];
17443
- }
17444
- return t;
17445
- }
17446
- //#endregion
17447
- //#region \0@oxc-project+runtime@0.123.0/helpers/objectWithoutProperties.js
17448
- function _objectWithoutProperties(e, t) {
17449
- if (null == e) return {};
17450
- var o, r, i = _objectWithoutPropertiesLoose(e, t);
17451
- if (Object.getOwnPropertySymbols) {
17452
- var s = Object.getOwnPropertySymbols(e);
17453
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
17454
- }
17455
- return i;
17456
- }
17457
- //#endregion
17458
17664
  //#region src/file/table-of-contents/table-of-contents.ts
17459
17665
  /**
17460
17666
  * Table of Contents module for WordprocessingML documents.
@@ -17466,11 +17672,6 @@ function _objectWithoutProperties(e, t) {
17466
17672
  *
17467
17673
  * @module
17468
17674
  */
17469
- const _excluded$1 = [
17470
- "contentChildren",
17471
- "cachedEntries",
17472
- "beginDirty"
17473
- ];
17474
17675
  /**
17475
17676
  * Represents a Table of Contents in a WordprocessingML document.
17476
17677
  *
@@ -17501,8 +17702,7 @@ const _excluded$1 = [
17501
17702
  * ```
17502
17703
  */
17503
17704
  var TableOfContents = class extends FileChild {
17504
- constructor(alias = "Table of Contents", _ref = {}) {
17505
- let { contentChildren = [], cachedEntries = [], beginDirty = true } = _ref, properties = _objectWithoutProperties(_ref, _excluded$1);
17705
+ constructor(alias = "Table of Contents", { contentChildren = [], cachedEntries = [], beginDirty = true, ...properties } = {}) {
17506
17706
  super("w:sdt");
17507
17707
  this.root.push(new StructuredDocumentTagProperties(alias));
17508
17708
  const content = new StructuredDocumentTagContent();
@@ -18198,7 +18398,6 @@ const createShape = ({ id, children, type = SHAPE_TYPE, style }) => new BuilderE
18198
18398
  *
18199
18399
  * @module
18200
18400
  */
18201
- const _excluded = ["style", "children"];
18202
18401
  /**
18203
18402
  * Represents a textbox in a WordprocessingML document.
18204
18403
  *
@@ -18248,8 +18447,7 @@ const _excluded = ["style", "children"];
18248
18447
  * ```
18249
18448
  */
18250
18449
  var Textbox = class extends FileChild {
18251
- constructor(_ref) {
18252
- let { style, children } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
18450
+ constructor({ style, children, ...rest }) {
18253
18451
  super("w:p");
18254
18452
  this.root.push(new ParagraphProperties(rest));
18255
18453
  this.root.push(createPictElement({ shape: createShape({
@@ -18260,47 +18458,3183 @@ var Textbox = class extends FileChild {
18260
18458
  }
18261
18459
  };
18262
18460
  //#endregion
18263
- //#region src/util/output-type.ts
18461
+ //#region \0polyfill-node.events.js
18462
+ var domain;
18463
+ function EventHandlers() {}
18464
+ EventHandlers.prototype = Object.create(null);
18465
+ function EventEmitter() {
18466
+ EventEmitter.init.call(this);
18467
+ }
18468
+ EventEmitter.EventEmitter = EventEmitter;
18469
+ EventEmitter.usingDomains = false;
18470
+ EventEmitter.prototype.domain = void 0;
18471
+ EventEmitter.prototype._events = void 0;
18472
+ EventEmitter.prototype._maxListeners = void 0;
18473
+ EventEmitter.defaultMaxListeners = 10;
18474
+ EventEmitter.init = function() {
18475
+ this.domain = null;
18476
+ if (EventEmitter.usingDomains) {
18477
+ if (domain.active && !(this instanceof domain.Domain)) this.domain = domain.active;
18478
+ }
18479
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
18480
+ this._events = new EventHandlers();
18481
+ this._eventsCount = 0;
18482
+ }
18483
+ this._maxListeners = this._maxListeners || void 0;
18484
+ };
18485
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
18486
+ if (typeof n !== "number" || n < 0 || isNaN(n)) throw new TypeError("\"n\" argument must be a positive number");
18487
+ this._maxListeners = n;
18488
+ return this;
18489
+ };
18490
+ function $getMaxListeners(that) {
18491
+ if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
18492
+ return that._maxListeners;
18493
+ }
18494
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
18495
+ return $getMaxListeners(this);
18496
+ };
18497
+ function emitNone(handler, isFn, self) {
18498
+ if (isFn) handler.call(self);
18499
+ else {
18500
+ var len = handler.length;
18501
+ var listeners = arrayClone(handler, len);
18502
+ for (var i = 0; i < len; ++i) listeners[i].call(self);
18503
+ }
18504
+ }
18505
+ function emitOne(handler, isFn, self, arg1) {
18506
+ if (isFn) handler.call(self, arg1);
18507
+ else {
18508
+ var len = handler.length;
18509
+ var listeners = arrayClone(handler, len);
18510
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1);
18511
+ }
18512
+ }
18513
+ function emitTwo(handler, isFn, self, arg1, arg2) {
18514
+ if (isFn) handler.call(self, arg1, arg2);
18515
+ else {
18516
+ var len = handler.length;
18517
+ var listeners = arrayClone(handler, len);
18518
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2);
18519
+ }
18520
+ }
18521
+ function emitThree(handler, isFn, self, arg1, arg2, arg3) {
18522
+ if (isFn) handler.call(self, arg1, arg2, arg3);
18523
+ else {
18524
+ var len = handler.length;
18525
+ var listeners = arrayClone(handler, len);
18526
+ for (var i = 0; i < len; ++i) listeners[i].call(self, arg1, arg2, arg3);
18527
+ }
18528
+ }
18529
+ function emitMany(handler, isFn, self, args) {
18530
+ if (isFn) handler.apply(self, args);
18531
+ else {
18532
+ var len = handler.length;
18533
+ var listeners = arrayClone(handler, len);
18534
+ for (var i = 0; i < len; ++i) listeners[i].apply(self, args);
18535
+ }
18536
+ }
18537
+ EventEmitter.prototype.emit = function emit(type) {
18538
+ var er, handler, len, args, i, events, domain;
18539
+ var needDomainExit = false;
18540
+ var doError = type === "error";
18541
+ events = this._events;
18542
+ if (events) doError = doError && events.error == null;
18543
+ else if (!doError) return false;
18544
+ domain = this.domain;
18545
+ if (doError) {
18546
+ er = arguments[1];
18547
+ if (domain) {
18548
+ if (!er) er = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event");
18549
+ er.domainEmitter = this;
18550
+ er.domain = domain;
18551
+ er.domainThrown = false;
18552
+ domain.emit("error", er);
18553
+ } else if (er instanceof Error) throw er;
18554
+ else {
18555
+ var err = /* @__PURE__ */ new Error("Uncaught, unspecified \"error\" event. (" + er + ")");
18556
+ err.context = er;
18557
+ throw err;
18558
+ }
18559
+ return false;
18560
+ }
18561
+ handler = events[type];
18562
+ if (!handler) return false;
18563
+ var isFn = typeof handler === "function";
18564
+ len = arguments.length;
18565
+ switch (len) {
18566
+ case 1:
18567
+ emitNone(handler, isFn, this);
18568
+ break;
18569
+ case 2:
18570
+ emitOne(handler, isFn, this, arguments[1]);
18571
+ break;
18572
+ case 3:
18573
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
18574
+ break;
18575
+ case 4:
18576
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
18577
+ break;
18578
+ default:
18579
+ args = new Array(len - 1);
18580
+ for (i = 1; i < len; i++) args[i - 1] = arguments[i];
18581
+ emitMany(handler, isFn, this, args);
18582
+ }
18583
+ if (needDomainExit) domain.exit();
18584
+ return true;
18585
+ };
18586
+ function _addListener(target, type, listener, prepend) {
18587
+ var m;
18588
+ var events;
18589
+ var existing;
18590
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18591
+ events = target._events;
18592
+ if (!events) {
18593
+ events = target._events = new EventHandlers();
18594
+ target._eventsCount = 0;
18595
+ } else {
18596
+ if (events.newListener) {
18597
+ target.emit("newListener", type, listener.listener ? listener.listener : listener);
18598
+ events = target._events;
18599
+ }
18600
+ existing = events[type];
18601
+ }
18602
+ if (!existing) {
18603
+ existing = events[type] = listener;
18604
+ ++target._eventsCount;
18605
+ } else {
18606
+ if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
18607
+ else if (prepend) existing.unshift(listener);
18608
+ else existing.push(listener);
18609
+ if (!existing.warned) {
18610
+ m = $getMaxListeners(target);
18611
+ if (m && m > 0 && existing.length > m) {
18612
+ existing.warned = true;
18613
+ var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type + " listeners added. Use emitter.setMaxListeners() to increase limit");
18614
+ w.name = "MaxListenersExceededWarning";
18615
+ w.emitter = target;
18616
+ w.type = type;
18617
+ w.count = existing.length;
18618
+ emitWarning(w);
18619
+ }
18620
+ }
18621
+ }
18622
+ return target;
18623
+ }
18624
+ function emitWarning(e) {
18625
+ typeof console.warn === "function" ? console.warn(e) : console.log(e);
18626
+ }
18627
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
18628
+ return _addListener(this, type, listener, false);
18629
+ };
18630
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
18631
+ EventEmitter.prototype.prependListener = function prependListener(type, listener) {
18632
+ return _addListener(this, type, listener, true);
18633
+ };
18634
+ function _onceWrap(target, type, listener) {
18635
+ var fired = false;
18636
+ function g() {
18637
+ target.removeListener(type, g);
18638
+ if (!fired) {
18639
+ fired = true;
18640
+ listener.apply(target, arguments);
18641
+ }
18642
+ }
18643
+ g.listener = listener;
18644
+ return g;
18645
+ }
18646
+ EventEmitter.prototype.once = function once(type, listener) {
18647
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18648
+ this.on(type, _onceWrap(this, type, listener));
18649
+ return this;
18650
+ };
18651
+ EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
18652
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18653
+ this.prependListener(type, _onceWrap(this, type, listener));
18654
+ return this;
18655
+ };
18656
+ EventEmitter.prototype.removeListener = function removeListener(type, listener) {
18657
+ var list, events, position, i, originalListener;
18658
+ if (typeof listener !== "function") throw new TypeError("\"listener\" argument must be a function");
18659
+ events = this._events;
18660
+ if (!events) return this;
18661
+ list = events[type];
18662
+ if (!list) return this;
18663
+ if (list === listener || list.listener && list.listener === listener) if (--this._eventsCount === 0) this._events = new EventHandlers();
18664
+ else {
18665
+ delete events[type];
18666
+ if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
18667
+ }
18668
+ else if (typeof list !== "function") {
18669
+ position = -1;
18670
+ for (i = list.length; i-- > 0;) if (list[i] === listener || list[i].listener && list[i].listener === listener) {
18671
+ originalListener = list[i].listener;
18672
+ position = i;
18673
+ break;
18674
+ }
18675
+ if (position < 0) return this;
18676
+ if (list.length === 1) {
18677
+ list[0] = void 0;
18678
+ if (--this._eventsCount === 0) {
18679
+ this._events = new EventHandlers();
18680
+ return this;
18681
+ } else delete events[type];
18682
+ } else spliceOne(list, position);
18683
+ if (events.removeListener) this.emit("removeListener", type, originalListener || listener);
18684
+ }
18685
+ return this;
18686
+ };
18687
+ EventEmitter.prototype.off = function(type, listener) {
18688
+ return this.removeListener(type, listener);
18689
+ };
18690
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
18691
+ var listeners, events = this._events;
18692
+ if (!events) return this;
18693
+ if (!events.removeListener) {
18694
+ if (arguments.length === 0) {
18695
+ this._events = new EventHandlers();
18696
+ this._eventsCount = 0;
18697
+ } else if (events[type]) if (--this._eventsCount === 0) this._events = new EventHandlers();
18698
+ else delete events[type];
18699
+ return this;
18700
+ }
18701
+ if (arguments.length === 0) {
18702
+ var keys = Object.keys(events);
18703
+ for (var i = 0, key; i < keys.length; ++i) {
18704
+ key = keys[i];
18705
+ if (key === "removeListener") continue;
18706
+ this.removeAllListeners(key);
18707
+ }
18708
+ this.removeAllListeners("removeListener");
18709
+ this._events = new EventHandlers();
18710
+ this._eventsCount = 0;
18711
+ return this;
18712
+ }
18713
+ listeners = events[type];
18714
+ if (typeof listeners === "function") this.removeListener(type, listeners);
18715
+ else if (listeners) do
18716
+ this.removeListener(type, listeners[listeners.length - 1]);
18717
+ while (listeners[0]);
18718
+ return this;
18719
+ };
18720
+ EventEmitter.prototype.listeners = function listeners(type) {
18721
+ var evlistener;
18722
+ var ret;
18723
+ var events = this._events;
18724
+ if (!events) ret = [];
18725
+ else {
18726
+ evlistener = events[type];
18727
+ if (!evlistener) ret = [];
18728
+ else if (typeof evlistener === "function") ret = [evlistener.listener || evlistener];
18729
+ else ret = unwrapListeners(evlistener);
18730
+ }
18731
+ return ret;
18732
+ };
18733
+ EventEmitter.listenerCount = function(emitter, type) {
18734
+ if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
18735
+ else return listenerCount$1.call(emitter, type);
18736
+ };
18737
+ EventEmitter.prototype.listenerCount = listenerCount$1;
18738
+ function listenerCount$1(type) {
18739
+ var events = this._events;
18740
+ if (events) {
18741
+ var evlistener = events[type];
18742
+ if (typeof evlistener === "function") return 1;
18743
+ else if (evlistener) return evlistener.length;
18744
+ }
18745
+ return 0;
18746
+ }
18747
+ EventEmitter.prototype.eventNames = function eventNames() {
18748
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
18749
+ };
18750
+ function spliceOne(list, index) {
18751
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) list[i] = list[k];
18752
+ list.pop();
18753
+ }
18754
+ function arrayClone(arr, i) {
18755
+ var copy = new Array(i);
18756
+ while (i--) copy[i] = arr[i];
18757
+ return copy;
18758
+ }
18759
+ function unwrapListeners(arr) {
18760
+ var ret = new Array(arr.length);
18761
+ for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
18762
+ return ret;
18763
+ }
18764
+ //#endregion
18765
+ //#region \0polyfill-node.global.js
18766
+ var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
18767
+ //#endregion
18768
+ //#region \0polyfill-node.buffer.js
18769
+ var lookup = [];
18770
+ var revLookup = [];
18771
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
18772
+ var inited = false;
18773
+ function init() {
18774
+ inited = true;
18775
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
18776
+ for (var i = 0, len = code.length; i < len; ++i) {
18777
+ lookup[i] = code[i];
18778
+ revLookup[code.charCodeAt(i)] = i;
18779
+ }
18780
+ revLookup["-".charCodeAt(0)] = 62;
18781
+ revLookup["_".charCodeAt(0)] = 63;
18782
+ }
18783
+ function toByteArray(b64) {
18784
+ if (!inited) init();
18785
+ var i, j, l, tmp, placeHolders, arr;
18786
+ var len = b64.length;
18787
+ if (len % 4 > 0) throw new Error("Invalid string. Length must be a multiple of 4");
18788
+ placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
18789
+ arr = new Arr(len * 3 / 4 - placeHolders);
18790
+ l = placeHolders > 0 ? len - 4 : len;
18791
+ var L = 0;
18792
+ for (i = 0, j = 0; i < l; i += 4, j += 3) {
18793
+ tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
18794
+ arr[L++] = tmp >> 16 & 255;
18795
+ arr[L++] = tmp >> 8 & 255;
18796
+ arr[L++] = tmp & 255;
18797
+ }
18798
+ if (placeHolders === 2) {
18799
+ tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
18800
+ arr[L++] = tmp & 255;
18801
+ } else if (placeHolders === 1) {
18802
+ tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
18803
+ arr[L++] = tmp >> 8 & 255;
18804
+ arr[L++] = tmp & 255;
18805
+ }
18806
+ return arr;
18807
+ }
18808
+ function tripletToBase64(num) {
18809
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
18810
+ }
18811
+ function encodeChunk(uint8, start, end) {
18812
+ var tmp;
18813
+ var output = [];
18814
+ for (var i = start; i < end; i += 3) {
18815
+ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
18816
+ output.push(tripletToBase64(tmp));
18817
+ }
18818
+ return output.join("");
18819
+ }
18820
+ function fromByteArray(uint8) {
18821
+ if (!inited) init();
18822
+ var tmp;
18823
+ var len = uint8.length;
18824
+ var extraBytes = len % 3;
18825
+ var output = "";
18826
+ var parts = [];
18827
+ var maxChunkLength = 16383;
18828
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
18829
+ if (extraBytes === 1) {
18830
+ tmp = uint8[len - 1];
18831
+ output += lookup[tmp >> 2];
18832
+ output += lookup[tmp << 4 & 63];
18833
+ output += "==";
18834
+ } else if (extraBytes === 2) {
18835
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
18836
+ output += lookup[tmp >> 10];
18837
+ output += lookup[tmp >> 4 & 63];
18838
+ output += lookup[tmp << 2 & 63];
18839
+ output += "=";
18840
+ }
18841
+ parts.push(output);
18842
+ return parts.join("");
18843
+ }
18844
+ function read(buffer, offset, isLE, mLen, nBytes) {
18845
+ var e, m;
18846
+ var eLen = nBytes * 8 - mLen - 1;
18847
+ var eMax = (1 << eLen) - 1;
18848
+ var eBias = eMax >> 1;
18849
+ var nBits = -7;
18850
+ var i = isLE ? nBytes - 1 : 0;
18851
+ var d = isLE ? -1 : 1;
18852
+ var s = buffer[offset + i];
18853
+ i += d;
18854
+ e = s & (1 << -nBits) - 1;
18855
+ s >>= -nBits;
18856
+ nBits += eLen;
18857
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);
18858
+ m = e & (1 << -nBits) - 1;
18859
+ e >>= -nBits;
18860
+ nBits += mLen;
18861
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);
18862
+ if (e === 0) e = 1 - eBias;
18863
+ else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;
18864
+ else {
18865
+ m = m + Math.pow(2, mLen);
18866
+ e = e - eBias;
18867
+ }
18868
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
18869
+ }
18870
+ function write(buffer, value, offset, isLE, mLen, nBytes) {
18871
+ var e, m, c;
18872
+ var eLen = nBytes * 8 - mLen - 1;
18873
+ var eMax = (1 << eLen) - 1;
18874
+ var eBias = eMax >> 1;
18875
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
18876
+ var i = isLE ? 0 : nBytes - 1;
18877
+ var d = isLE ? 1 : -1;
18878
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
18879
+ value = Math.abs(value);
18880
+ if (isNaN(value) || value === Infinity) {
18881
+ m = isNaN(value) ? 1 : 0;
18882
+ e = eMax;
18883
+ } else {
18884
+ e = Math.floor(Math.log(value) / Math.LN2);
18885
+ if (value * (c = Math.pow(2, -e)) < 1) {
18886
+ e--;
18887
+ c *= 2;
18888
+ }
18889
+ if (e + eBias >= 1) value += rt / c;
18890
+ else value += rt * Math.pow(2, 1 - eBias);
18891
+ if (value * c >= 2) {
18892
+ e++;
18893
+ c /= 2;
18894
+ }
18895
+ if (e + eBias >= eMax) {
18896
+ m = 0;
18897
+ e = eMax;
18898
+ } else if (e + eBias >= 1) {
18899
+ m = (value * c - 1) * Math.pow(2, mLen);
18900
+ e = e + eBias;
18901
+ } else {
18902
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
18903
+ e = 0;
18904
+ }
18905
+ }
18906
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8);
18907
+ e = e << mLen | m;
18908
+ eLen += mLen;
18909
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8);
18910
+ buffer[offset + i - d] |= s * 128;
18911
+ }
18912
+ var toString = {}.toString;
18913
+ var isArray$1 = Array.isArray || function(arr) {
18914
+ return toString.call(arr) == "[object Array]";
18915
+ };
18264
18916
  /**
18265
- * Output type definitions for document generation.
18917
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
18918
+ * === true Use Uint8Array implementation (fastest)
18919
+ * === false Use Object implementation (most compatible, even IE6)
18266
18920
  *
18267
- * This module defines the various output formats supported when generating
18268
- * .docx files. These types correspond to fflate's output formats.
18921
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
18922
+ * Opera 11.6+, iOS 4.2+.
18269
18923
  *
18270
- * @module
18924
+ * Due to various browser bugs, sometimes the Object implementation will be used even
18925
+ * when the browser supports typed arrays.
18926
+ *
18927
+ * Note:
18928
+ *
18929
+ * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
18930
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
18931
+ *
18932
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
18933
+ *
18934
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
18935
+ * incorrect length in some situations.
18936
+
18937
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
18938
+ * get the Object implementation, which is slower but behaves correctly.
18271
18939
  */
18940
+ Buffer.TYPED_ARRAY_SUPPORT = _polyfill_node_global_default.TYPED_ARRAY_SUPPORT !== void 0 ? _polyfill_node_global_default.TYPED_ARRAY_SUPPORT : true;
18941
+ kMaxLength();
18942
+ function kMaxLength() {
18943
+ return Buffer.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
18944
+ }
18945
+ function createBuffer(that, length) {
18946
+ if (kMaxLength() < length) throw new RangeError("Invalid typed array length");
18947
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
18948
+ that = new Uint8Array(length);
18949
+ that.__proto__ = Buffer.prototype;
18950
+ } else {
18951
+ if (that === null) that = new Buffer(length);
18952
+ that.length = length;
18953
+ }
18954
+ return that;
18955
+ }
18272
18956
  /**
18273
- * Converts a Uint8Array to the specified output type.
18957
+ * The Buffer constructor returns instances of `Uint8Array` that have their
18958
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
18959
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
18960
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
18961
+ * returns a single octet.
18274
18962
  *
18275
- * This is used by both the Packer and patchDocument to convert fflate's
18276
- * raw Uint8Array output into the user's requested format.
18963
+ * The `Uint8Array` prototype remains unmodified.
18277
18964
  */
18278
- const convertOutput = (data, type) => {
18279
- switch (type) {
18280
- case "nodebuffer": return Buffer.from(data);
18281
- case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
18282
- case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
18283
- case "uint8array": return data;
18284
- case "base64": return btoa(strFromU8(data, true));
18285
- case "string":
18286
- case "text":
18287
- case "binarystring": return strFromU8(data, true);
18288
- case "array": return [...data];
18289
- default: return data;
18965
+ function Buffer(arg, encodingOrOffset, length) {
18966
+ if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) return new Buffer(arg, encodingOrOffset, length);
18967
+ if (typeof arg === "number") {
18968
+ if (typeof encodingOrOffset === "string") throw new Error("If encoding is specified then the first argument must be a string");
18969
+ return allocUnsafe(this, arg);
18290
18970
  }
18971
+ return from(this, arg, encodingOrOffset, length);
18972
+ }
18973
+ Buffer.poolSize = 8192;
18974
+ Buffer._augment = function(arr) {
18975
+ arr.__proto__ = Buffer.prototype;
18976
+ return arr;
18977
+ };
18978
+ function from(that, value, encodingOrOffset, length) {
18979
+ if (typeof value === "number") throw new TypeError("\"value\" argument must not be a number");
18980
+ if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) return fromArrayBuffer(that, value, encodingOrOffset, length);
18981
+ if (typeof value === "string") return fromString(that, value, encodingOrOffset);
18982
+ return fromObject(that, value);
18983
+ }
18984
+ /**
18985
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
18986
+ * if value is a number.
18987
+ * Buffer.from(str[, encoding])
18988
+ * Buffer.from(array)
18989
+ * Buffer.from(buffer)
18990
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
18991
+ **/
18992
+ Buffer.from = function(value, encodingOrOffset, length) {
18993
+ return from(null, value, encodingOrOffset, length);
18994
+ };
18995
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
18996
+ Buffer.prototype.__proto__ = Uint8Array.prototype;
18997
+ Buffer.__proto__ = Uint8Array;
18998
+ if (typeof Symbol !== "undefined" && Symbol.species && Buffer[Symbol.species] === Buffer);
18999
+ }
19000
+ function assertSize(size) {
19001
+ if (typeof size !== "number") throw new TypeError("\"size\" argument must be a number");
19002
+ else if (size < 0) throw new RangeError("\"size\" argument must not be negative");
19003
+ }
19004
+ function alloc(that, size, fill, encoding) {
19005
+ assertSize(size);
19006
+ if (size <= 0) return createBuffer(that, size);
19007
+ if (fill !== void 0) return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
19008
+ return createBuffer(that, size);
19009
+ }
19010
+ /**
19011
+ * Creates a new filled Buffer instance.
19012
+ * alloc(size[, fill[, encoding]])
19013
+ **/
19014
+ Buffer.alloc = function(size, fill, encoding) {
19015
+ return alloc(null, size, fill, encoding);
19016
+ };
19017
+ function allocUnsafe(that, size) {
19018
+ assertSize(size);
19019
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
19020
+ if (!Buffer.TYPED_ARRAY_SUPPORT) for (var i = 0; i < size; ++i) that[i] = 0;
19021
+ return that;
19022
+ }
19023
+ /**
19024
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
19025
+ * */
19026
+ Buffer.allocUnsafe = function(size) {
19027
+ return allocUnsafe(null, size);
18291
19028
  };
18292
- //#endregion
18293
- //#region src/file/fonts/obfuscate-ttf-to-odttf.ts
18294
19029
  /**
18295
- * Font obfuscation module for embedding fonts in WordprocessingML documents.
18296
- *
18297
- * This module implements the OOXML font obfuscation algorithm used to embed
18298
- * fonts in DOCX documents. Obfuscation is required by the OOXML specification
18299
- * to prevent simple extraction of embedded font files.
18300
- *
18301
- * Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
18302
- *
18303
- * @module
19030
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
19031
+ */
19032
+ Buffer.allocUnsafeSlow = function(size) {
19033
+ return allocUnsafe(null, size);
19034
+ };
19035
+ function fromString(that, string, encoding) {
19036
+ if (typeof encoding !== "string" || encoding === "") encoding = "utf8";
19037
+ if (!Buffer.isEncoding(encoding)) throw new TypeError("\"encoding\" must be a valid string encoding");
19038
+ var length = byteLength(string, encoding) | 0;
19039
+ that = createBuffer(that, length);
19040
+ var actual = that.write(string, encoding);
19041
+ if (actual !== length) that = that.slice(0, actual);
19042
+ return that;
19043
+ }
19044
+ function fromArrayLike(that, array) {
19045
+ var length = array.length < 0 ? 0 : checked(array.length) | 0;
19046
+ that = createBuffer(that, length);
19047
+ for (var i = 0; i < length; i += 1) that[i] = array[i] & 255;
19048
+ return that;
19049
+ }
19050
+ function fromArrayBuffer(that, array, byteOffset, length) {
19051
+ array.byteLength;
19052
+ if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError("'offset' is out of bounds");
19053
+ if (array.byteLength < byteOffset + (length || 0)) throw new RangeError("'length' is out of bounds");
19054
+ if (byteOffset === void 0 && length === void 0) array = new Uint8Array(array);
19055
+ else if (length === void 0) array = new Uint8Array(array, byteOffset);
19056
+ else array = new Uint8Array(array, byteOffset, length);
19057
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19058
+ that = array;
19059
+ that.__proto__ = Buffer.prototype;
19060
+ } else that = fromArrayLike(that, array);
19061
+ return that;
19062
+ }
19063
+ function fromObject(that, obj) {
19064
+ if (internalIsBuffer(obj)) {
19065
+ var len = checked(obj.length) | 0;
19066
+ that = createBuffer(that, len);
19067
+ if (that.length === 0) return that;
19068
+ obj.copy(that, 0, 0, len);
19069
+ return that;
19070
+ }
19071
+ if (obj) {
19072
+ if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
19073
+ if (typeof obj.length !== "number" || isnan(obj.length)) return createBuffer(that, 0);
19074
+ return fromArrayLike(that, obj);
19075
+ }
19076
+ if (obj.type === "Buffer" && isArray$1(obj.data)) return fromArrayLike(that, obj.data);
19077
+ }
19078
+ throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
19079
+ }
19080
+ function checked(length) {
19081
+ if (length >= kMaxLength()) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
19082
+ return length | 0;
19083
+ }
19084
+ Buffer.isBuffer = isBuffer;
19085
+ function internalIsBuffer(b) {
19086
+ return !!(b != null && b._isBuffer);
19087
+ }
19088
+ Buffer.compare = function compare(a, b) {
19089
+ if (!internalIsBuffer(a) || !internalIsBuffer(b)) throw new TypeError("Arguments must be Buffers");
19090
+ if (a === b) return 0;
19091
+ var x = a.length;
19092
+ var y = b.length;
19093
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) if (a[i] !== b[i]) {
19094
+ x = a[i];
19095
+ y = b[i];
19096
+ break;
19097
+ }
19098
+ if (x < y) return -1;
19099
+ if (y < x) return 1;
19100
+ return 0;
19101
+ };
19102
+ Buffer.isEncoding = function isEncoding(encoding) {
19103
+ switch (String(encoding).toLowerCase()) {
19104
+ case "hex":
19105
+ case "utf8":
19106
+ case "utf-8":
19107
+ case "ascii":
19108
+ case "latin1":
19109
+ case "binary":
19110
+ case "base64":
19111
+ case "ucs2":
19112
+ case "ucs-2":
19113
+ case "utf16le":
19114
+ case "utf-16le": return true;
19115
+ default: return false;
19116
+ }
19117
+ };
19118
+ Buffer.concat = function concat(list, length) {
19119
+ if (!isArray$1(list)) throw new TypeError("\"list\" argument must be an Array of Buffers");
19120
+ if (list.length === 0) return Buffer.alloc(0);
19121
+ var i;
19122
+ if (length === void 0) {
19123
+ length = 0;
19124
+ for (i = 0; i < list.length; ++i) length += list[i].length;
19125
+ }
19126
+ var buffer = Buffer.allocUnsafe(length);
19127
+ var pos = 0;
19128
+ for (i = 0; i < list.length; ++i) {
19129
+ var buf = list[i];
19130
+ if (!internalIsBuffer(buf)) throw new TypeError("\"list\" argument must be an Array of Buffers");
19131
+ buf.copy(buffer, pos);
19132
+ pos += buf.length;
19133
+ }
19134
+ return buffer;
19135
+ };
19136
+ function byteLength(string, encoding) {
19137
+ if (internalIsBuffer(string)) return string.length;
19138
+ if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) return string.byteLength;
19139
+ if (typeof string !== "string") string = "" + string;
19140
+ var len = string.length;
19141
+ if (len === 0) return 0;
19142
+ var loweredCase = false;
19143
+ for (;;) switch (encoding) {
19144
+ case "ascii":
19145
+ case "latin1":
19146
+ case "binary": return len;
19147
+ case "utf8":
19148
+ case "utf-8":
19149
+ case void 0: return utf8ToBytes(string).length;
19150
+ case "ucs2":
19151
+ case "ucs-2":
19152
+ case "utf16le":
19153
+ case "utf-16le": return len * 2;
19154
+ case "hex": return len >>> 1;
19155
+ case "base64": return base64ToBytes(string).length;
19156
+ default:
19157
+ if (loweredCase) return utf8ToBytes(string).length;
19158
+ encoding = ("" + encoding).toLowerCase();
19159
+ loweredCase = true;
19160
+ }
19161
+ }
19162
+ Buffer.byteLength = byteLength;
19163
+ function slowToString(encoding, start, end) {
19164
+ var loweredCase = false;
19165
+ if (start === void 0 || start < 0) start = 0;
19166
+ if (start > this.length) return "";
19167
+ if (end === void 0 || end > this.length) end = this.length;
19168
+ if (end <= 0) return "";
19169
+ end >>>= 0;
19170
+ start >>>= 0;
19171
+ if (end <= start) return "";
19172
+ if (!encoding) encoding = "utf8";
19173
+ while (true) switch (encoding) {
19174
+ case "hex": return hexSlice(this, start, end);
19175
+ case "utf8":
19176
+ case "utf-8": return utf8Slice(this, start, end);
19177
+ case "ascii": return asciiSlice(this, start, end);
19178
+ case "latin1":
19179
+ case "binary": return latin1Slice(this, start, end);
19180
+ case "base64": return base64Slice(this, start, end);
19181
+ case "ucs2":
19182
+ case "ucs-2":
19183
+ case "utf16le":
19184
+ case "utf-16le": return utf16leSlice(this, start, end);
19185
+ default:
19186
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
19187
+ encoding = (encoding + "").toLowerCase();
19188
+ loweredCase = true;
19189
+ }
19190
+ }
19191
+ Buffer.prototype._isBuffer = true;
19192
+ function swap(b, n, m) {
19193
+ var i = b[n];
19194
+ b[n] = b[m];
19195
+ b[m] = i;
19196
+ }
19197
+ Buffer.prototype.swap16 = function swap16() {
19198
+ var len = this.length;
19199
+ if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
19200
+ for (var i = 0; i < len; i += 2) swap(this, i, i + 1);
19201
+ return this;
19202
+ };
19203
+ Buffer.prototype.swap32 = function swap32() {
19204
+ var len = this.length;
19205
+ if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
19206
+ for (var i = 0; i < len; i += 4) {
19207
+ swap(this, i, i + 3);
19208
+ swap(this, i + 1, i + 2);
19209
+ }
19210
+ return this;
19211
+ };
19212
+ Buffer.prototype.swap64 = function swap64() {
19213
+ var len = this.length;
19214
+ if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
19215
+ for (var i = 0; i < len; i += 8) {
19216
+ swap(this, i, i + 7);
19217
+ swap(this, i + 1, i + 6);
19218
+ swap(this, i + 2, i + 5);
19219
+ swap(this, i + 3, i + 4);
19220
+ }
19221
+ return this;
19222
+ };
19223
+ Buffer.prototype.toString = function toString() {
19224
+ var length = this.length | 0;
19225
+ if (length === 0) return "";
19226
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
19227
+ return slowToString.apply(this, arguments);
19228
+ };
19229
+ Buffer.prototype.equals = function equals(b) {
19230
+ if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
19231
+ if (this === b) return true;
19232
+ return Buffer.compare(this, b) === 0;
19233
+ };
19234
+ Buffer.prototype.inspect = function inspect() {
19235
+ var str = "";
19236
+ var max = 50;
19237
+ if (this.length > 0) {
19238
+ str = this.toString("hex", 0, max).match(/.{2}/g).join(" ");
19239
+ if (this.length > max) str += " ... ";
19240
+ }
19241
+ return "<Buffer " + str + ">";
19242
+ };
19243
+ Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
19244
+ if (!internalIsBuffer(target)) throw new TypeError("Argument must be a Buffer");
19245
+ if (start === void 0) start = 0;
19246
+ if (end === void 0) end = target ? target.length : 0;
19247
+ if (thisStart === void 0) thisStart = 0;
19248
+ if (thisEnd === void 0) thisEnd = this.length;
19249
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError("out of range index");
19250
+ if (thisStart >= thisEnd && start >= end) return 0;
19251
+ if (thisStart >= thisEnd) return -1;
19252
+ if (start >= end) return 1;
19253
+ start >>>= 0;
19254
+ end >>>= 0;
19255
+ thisStart >>>= 0;
19256
+ thisEnd >>>= 0;
19257
+ if (this === target) return 0;
19258
+ var x = thisEnd - thisStart;
19259
+ var y = end - start;
19260
+ var len = Math.min(x, y);
19261
+ var thisCopy = this.slice(thisStart, thisEnd);
19262
+ var targetCopy = target.slice(start, end);
19263
+ for (var i = 0; i < len; ++i) if (thisCopy[i] !== targetCopy[i]) {
19264
+ x = thisCopy[i];
19265
+ y = targetCopy[i];
19266
+ break;
19267
+ }
19268
+ if (x < y) return -1;
19269
+ if (y < x) return 1;
19270
+ return 0;
19271
+ };
19272
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
19273
+ if (buffer.length === 0) return -1;
19274
+ if (typeof byteOffset === "string") {
19275
+ encoding = byteOffset;
19276
+ byteOffset = 0;
19277
+ } else if (byteOffset > 2147483647) byteOffset = 2147483647;
19278
+ else if (byteOffset < -2147483648) byteOffset = -2147483648;
19279
+ byteOffset = +byteOffset;
19280
+ if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
19281
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
19282
+ if (byteOffset >= buffer.length) if (dir) return -1;
19283
+ else byteOffset = buffer.length - 1;
19284
+ else if (byteOffset < 0) if (dir) byteOffset = 0;
19285
+ else return -1;
19286
+ if (typeof val === "string") val = Buffer.from(val, encoding);
19287
+ if (internalIsBuffer(val)) {
19288
+ if (val.length === 0) return -1;
19289
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
19290
+ } else if (typeof val === "number") {
19291
+ val = val & 255;
19292
+ if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
19293
+ else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
19294
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
19295
+ }
19296
+ throw new TypeError("val must be string, number or Buffer");
19297
+ }
19298
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
19299
+ var indexSize = 1;
19300
+ var arrLength = arr.length;
19301
+ var valLength = val.length;
19302
+ if (encoding !== void 0) {
19303
+ encoding = String(encoding).toLowerCase();
19304
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
19305
+ if (arr.length < 2 || val.length < 2) return -1;
19306
+ indexSize = 2;
19307
+ arrLength /= 2;
19308
+ valLength /= 2;
19309
+ byteOffset /= 2;
19310
+ }
19311
+ }
19312
+ function read(buf, i) {
19313
+ if (indexSize === 1) return buf[i];
19314
+ else return buf.readUInt16BE(i * indexSize);
19315
+ }
19316
+ var i;
19317
+ if (dir) {
19318
+ var foundIndex = -1;
19319
+ for (i = byteOffset; i < arrLength; i++) if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
19320
+ if (foundIndex === -1) foundIndex = i;
19321
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
19322
+ } else {
19323
+ if (foundIndex !== -1) i -= i - foundIndex;
19324
+ foundIndex = -1;
19325
+ }
19326
+ } else {
19327
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
19328
+ for (i = byteOffset; i >= 0; i--) {
19329
+ var found = true;
19330
+ for (var j = 0; j < valLength; j++) if (read(arr, i + j) !== read(val, j)) {
19331
+ found = false;
19332
+ break;
19333
+ }
19334
+ if (found) return i;
19335
+ }
19336
+ }
19337
+ return -1;
19338
+ }
19339
+ Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
19340
+ return this.indexOf(val, byteOffset, encoding) !== -1;
19341
+ };
19342
+ Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
19343
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
19344
+ };
19345
+ Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
19346
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
19347
+ };
19348
+ function hexWrite(buf, string, offset, length) {
19349
+ offset = Number(offset) || 0;
19350
+ var remaining = buf.length - offset;
19351
+ if (!length) length = remaining;
19352
+ else {
19353
+ length = Number(length);
19354
+ if (length > remaining) length = remaining;
19355
+ }
19356
+ var strLen = string.length;
19357
+ if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
19358
+ if (length > strLen / 2) length = strLen / 2;
19359
+ for (var i = 0; i < length; ++i) {
19360
+ var parsed = parseInt(string.substr(i * 2, 2), 16);
19361
+ if (isNaN(parsed)) return i;
19362
+ buf[offset + i] = parsed;
19363
+ }
19364
+ return i;
19365
+ }
19366
+ function utf8Write(buf, string, offset, length) {
19367
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
19368
+ }
19369
+ function asciiWrite(buf, string, offset, length) {
19370
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
19371
+ }
19372
+ function latin1Write(buf, string, offset, length) {
19373
+ return asciiWrite(buf, string, offset, length);
19374
+ }
19375
+ function base64Write(buf, string, offset, length) {
19376
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
19377
+ }
19378
+ function ucs2Write(buf, string, offset, length) {
19379
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
19380
+ }
19381
+ Buffer.prototype.write = function write(string, offset, length, encoding) {
19382
+ if (offset === void 0) {
19383
+ encoding = "utf8";
19384
+ length = this.length;
19385
+ offset = 0;
19386
+ } else if (length === void 0 && typeof offset === "string") {
19387
+ encoding = offset;
19388
+ length = this.length;
19389
+ offset = 0;
19390
+ } else if (isFinite(offset)) {
19391
+ offset = offset | 0;
19392
+ if (isFinite(length)) {
19393
+ length = length | 0;
19394
+ if (encoding === void 0) encoding = "utf8";
19395
+ } else {
19396
+ encoding = length;
19397
+ length = void 0;
19398
+ }
19399
+ } else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
19400
+ var remaining = this.length - offset;
19401
+ if (length === void 0 || length > remaining) length = remaining;
19402
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError("Attempt to write outside buffer bounds");
19403
+ if (!encoding) encoding = "utf8";
19404
+ var loweredCase = false;
19405
+ for (;;) switch (encoding) {
19406
+ case "hex": return hexWrite(this, string, offset, length);
19407
+ case "utf8":
19408
+ case "utf-8": return utf8Write(this, string, offset, length);
19409
+ case "ascii": return asciiWrite(this, string, offset, length);
19410
+ case "latin1":
19411
+ case "binary": return latin1Write(this, string, offset, length);
19412
+ case "base64": return base64Write(this, string, offset, length);
19413
+ case "ucs2":
19414
+ case "ucs-2":
19415
+ case "utf16le":
19416
+ case "utf-16le": return ucs2Write(this, string, offset, length);
19417
+ default:
19418
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
19419
+ encoding = ("" + encoding).toLowerCase();
19420
+ loweredCase = true;
19421
+ }
19422
+ };
19423
+ Buffer.prototype.toJSON = function toJSON() {
19424
+ return {
19425
+ type: "Buffer",
19426
+ data: Array.prototype.slice.call(this._arr || this, 0)
19427
+ };
19428
+ };
19429
+ function base64Slice(buf, start, end) {
19430
+ if (start === 0 && end === buf.length) return fromByteArray(buf);
19431
+ else return fromByteArray(buf.slice(start, end));
19432
+ }
19433
+ function utf8Slice(buf, start, end) {
19434
+ end = Math.min(buf.length, end);
19435
+ var res = [];
19436
+ var i = start;
19437
+ while (i < end) {
19438
+ var firstByte = buf[i];
19439
+ var codePoint = null;
19440
+ var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
19441
+ if (i + bytesPerSequence <= end) {
19442
+ var secondByte, thirdByte, fourthByte, tempCodePoint;
19443
+ switch (bytesPerSequence) {
19444
+ case 1:
19445
+ if (firstByte < 128) codePoint = firstByte;
19446
+ break;
19447
+ case 2:
19448
+ secondByte = buf[i + 1];
19449
+ if ((secondByte & 192) === 128) {
19450
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
19451
+ if (tempCodePoint > 127) codePoint = tempCodePoint;
19452
+ }
19453
+ break;
19454
+ case 3:
19455
+ secondByte = buf[i + 1];
19456
+ thirdByte = buf[i + 2];
19457
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
19458
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
19459
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) codePoint = tempCodePoint;
19460
+ }
19461
+ break;
19462
+ case 4:
19463
+ secondByte = buf[i + 1];
19464
+ thirdByte = buf[i + 2];
19465
+ fourthByte = buf[i + 3];
19466
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
19467
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
19468
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) codePoint = tempCodePoint;
19469
+ }
19470
+ }
19471
+ }
19472
+ if (codePoint === null) {
19473
+ codePoint = 65533;
19474
+ bytesPerSequence = 1;
19475
+ } else if (codePoint > 65535) {
19476
+ codePoint -= 65536;
19477
+ res.push(codePoint >>> 10 & 1023 | 55296);
19478
+ codePoint = 56320 | codePoint & 1023;
19479
+ }
19480
+ res.push(codePoint);
19481
+ i += bytesPerSequence;
19482
+ }
19483
+ return decodeCodePointsArray(res);
19484
+ }
19485
+ var MAX_ARGUMENTS_LENGTH = 4096;
19486
+ function decodeCodePointsArray(codePoints) {
19487
+ var len = codePoints.length;
19488
+ if (len <= MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints);
19489
+ var res = "";
19490
+ var i = 0;
19491
+ while (i < len) res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
19492
+ return res;
19493
+ }
19494
+ function asciiSlice(buf, start, end) {
19495
+ var ret = "";
19496
+ end = Math.min(buf.length, end);
19497
+ for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i] & 127);
19498
+ return ret;
19499
+ }
19500
+ function latin1Slice(buf, start, end) {
19501
+ var ret = "";
19502
+ end = Math.min(buf.length, end);
19503
+ for (var i = start; i < end; ++i) ret += String.fromCharCode(buf[i]);
19504
+ return ret;
19505
+ }
19506
+ function hexSlice(buf, start, end) {
19507
+ var len = buf.length;
19508
+ if (!start || start < 0) start = 0;
19509
+ if (!end || end < 0 || end > len) end = len;
19510
+ var out = "";
19511
+ for (var i = start; i < end; ++i) out += toHex(buf[i]);
19512
+ return out;
19513
+ }
19514
+ function utf16leSlice(buf, start, end) {
19515
+ var bytes = buf.slice(start, end);
19516
+ var res = "";
19517
+ for (var i = 0; i < bytes.length; i += 2) res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
19518
+ return res;
19519
+ }
19520
+ Buffer.prototype.slice = function slice(start, end) {
19521
+ var len = this.length;
19522
+ start = ~~start;
19523
+ end = end === void 0 ? len : ~~end;
19524
+ if (start < 0) {
19525
+ start += len;
19526
+ if (start < 0) start = 0;
19527
+ } else if (start > len) start = len;
19528
+ if (end < 0) {
19529
+ end += len;
19530
+ if (end < 0) end = 0;
19531
+ } else if (end > len) end = len;
19532
+ if (end < start) end = start;
19533
+ var newBuf;
19534
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19535
+ newBuf = this.subarray(start, end);
19536
+ newBuf.__proto__ = Buffer.prototype;
19537
+ } else {
19538
+ var sliceLen = end - start;
19539
+ newBuf = new Buffer(sliceLen, void 0);
19540
+ for (var i = 0; i < sliceLen; ++i) newBuf[i] = this[i + start];
19541
+ }
19542
+ return newBuf;
19543
+ };
19544
+ function checkOffset(offset, ext, length) {
19545
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
19546
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
19547
+ }
19548
+ Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
19549
+ offset = offset | 0;
19550
+ byteLength = byteLength | 0;
19551
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19552
+ var val = this[offset];
19553
+ var mul = 1;
19554
+ var i = 0;
19555
+ while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
19556
+ return val;
19557
+ };
19558
+ Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
19559
+ offset = offset | 0;
19560
+ byteLength = byteLength | 0;
19561
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19562
+ var val = this[offset + --byteLength];
19563
+ var mul = 1;
19564
+ while (byteLength > 0 && (mul *= 256)) val += this[offset + --byteLength] * mul;
19565
+ return val;
19566
+ };
19567
+ Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
19568
+ if (!noAssert) checkOffset(offset, 1, this.length);
19569
+ return this[offset];
19570
+ };
19571
+ Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
19572
+ if (!noAssert) checkOffset(offset, 2, this.length);
19573
+ return this[offset] | this[offset + 1] << 8;
19574
+ };
19575
+ Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
19576
+ if (!noAssert) checkOffset(offset, 2, this.length);
19577
+ return this[offset] << 8 | this[offset + 1];
19578
+ };
19579
+ Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
19580
+ if (!noAssert) checkOffset(offset, 4, this.length);
19581
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
19582
+ };
19583
+ Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
19584
+ if (!noAssert) checkOffset(offset, 4, this.length);
19585
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
19586
+ };
19587
+ Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
19588
+ offset = offset | 0;
19589
+ byteLength = byteLength | 0;
19590
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19591
+ var val = this[offset];
19592
+ var mul = 1;
19593
+ var i = 0;
19594
+ while (++i < byteLength && (mul *= 256)) val += this[offset + i] * mul;
19595
+ mul *= 128;
19596
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
19597
+ return val;
19598
+ };
19599
+ Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
19600
+ offset = offset | 0;
19601
+ byteLength = byteLength | 0;
19602
+ if (!noAssert) checkOffset(offset, byteLength, this.length);
19603
+ var i = byteLength;
19604
+ var mul = 1;
19605
+ var val = this[offset + --i];
19606
+ while (i > 0 && (mul *= 256)) val += this[offset + --i] * mul;
19607
+ mul *= 128;
19608
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength);
19609
+ return val;
19610
+ };
19611
+ Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
19612
+ if (!noAssert) checkOffset(offset, 1, this.length);
19613
+ if (!(this[offset] & 128)) return this[offset];
19614
+ return (255 - this[offset] + 1) * -1;
19615
+ };
19616
+ Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
19617
+ if (!noAssert) checkOffset(offset, 2, this.length);
19618
+ var val = this[offset] | this[offset + 1] << 8;
19619
+ return val & 32768 ? val | 4294901760 : val;
19620
+ };
19621
+ Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
19622
+ if (!noAssert) checkOffset(offset, 2, this.length);
19623
+ var val = this[offset + 1] | this[offset] << 8;
19624
+ return val & 32768 ? val | 4294901760 : val;
19625
+ };
19626
+ Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
19627
+ if (!noAssert) checkOffset(offset, 4, this.length);
19628
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
19629
+ };
19630
+ Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
19631
+ if (!noAssert) checkOffset(offset, 4, this.length);
19632
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
19633
+ };
19634
+ Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
19635
+ if (!noAssert) checkOffset(offset, 4, this.length);
19636
+ return read(this, offset, true, 23, 4);
19637
+ };
19638
+ Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
19639
+ if (!noAssert) checkOffset(offset, 4, this.length);
19640
+ return read(this, offset, false, 23, 4);
19641
+ };
19642
+ Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
19643
+ if (!noAssert) checkOffset(offset, 8, this.length);
19644
+ return read(this, offset, true, 52, 8);
19645
+ };
19646
+ Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
19647
+ if (!noAssert) checkOffset(offset, 8, this.length);
19648
+ return read(this, offset, false, 52, 8);
19649
+ };
19650
+ function checkInt(buf, value, offset, ext, max, min) {
19651
+ if (!internalIsBuffer(buf)) throw new TypeError("\"buffer\" argument must be a Buffer instance");
19652
+ if (value > max || value < min) throw new RangeError("\"value\" argument is out of bounds");
19653
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
19654
+ }
19655
+ Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
19656
+ value = +value;
19657
+ offset = offset | 0;
19658
+ byteLength = byteLength | 0;
19659
+ if (!noAssert) {
19660
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1;
19661
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
19662
+ }
19663
+ var mul = 1;
19664
+ var i = 0;
19665
+ this[offset] = value & 255;
19666
+ while (++i < byteLength && (mul *= 256)) this[offset + i] = value / mul & 255;
19667
+ return offset + byteLength;
19668
+ };
19669
+ Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
19670
+ value = +value;
19671
+ offset = offset | 0;
19672
+ byteLength = byteLength | 0;
19673
+ if (!noAssert) {
19674
+ var maxBytes = Math.pow(2, 8 * byteLength) - 1;
19675
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
19676
+ }
19677
+ var i = byteLength - 1;
19678
+ var mul = 1;
19679
+ this[offset + i] = value & 255;
19680
+ while (--i >= 0 && (mul *= 256)) this[offset + i] = value / mul & 255;
19681
+ return offset + byteLength;
19682
+ };
19683
+ Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
19684
+ value = +value;
19685
+ offset = offset | 0;
19686
+ if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
19687
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
19688
+ this[offset] = value & 255;
19689
+ return offset + 1;
19690
+ };
19691
+ function objectWriteUInt16(buf, value, offset, littleEndian) {
19692
+ if (value < 0) value = 65535 + value + 1;
19693
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
19694
+ }
19695
+ Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
19696
+ value = +value;
19697
+ offset = offset | 0;
19698
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
19699
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19700
+ this[offset] = value & 255;
19701
+ this[offset + 1] = value >>> 8;
19702
+ } else objectWriteUInt16(this, value, offset, true);
19703
+ return offset + 2;
19704
+ };
19705
+ Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
19706
+ value = +value;
19707
+ offset = offset | 0;
19708
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
19709
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19710
+ this[offset] = value >>> 8;
19711
+ this[offset + 1] = value & 255;
19712
+ } else objectWriteUInt16(this, value, offset, false);
19713
+ return offset + 2;
19714
+ };
19715
+ function objectWriteUInt32(buf, value, offset, littleEndian) {
19716
+ if (value < 0) value = 4294967295 + value + 1;
19717
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
19718
+ }
19719
+ Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
19720
+ value = +value;
19721
+ offset = offset | 0;
19722
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
19723
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19724
+ this[offset + 3] = value >>> 24;
19725
+ this[offset + 2] = value >>> 16;
19726
+ this[offset + 1] = value >>> 8;
19727
+ this[offset] = value & 255;
19728
+ } else objectWriteUInt32(this, value, offset, true);
19729
+ return offset + 4;
19730
+ };
19731
+ Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
19732
+ value = +value;
19733
+ offset = offset | 0;
19734
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
19735
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19736
+ this[offset] = value >>> 24;
19737
+ this[offset + 1] = value >>> 16;
19738
+ this[offset + 2] = value >>> 8;
19739
+ this[offset + 3] = value & 255;
19740
+ } else objectWriteUInt32(this, value, offset, false);
19741
+ return offset + 4;
19742
+ };
19743
+ Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
19744
+ value = +value;
19745
+ offset = offset | 0;
19746
+ if (!noAssert) {
19747
+ var limit = Math.pow(2, 8 * byteLength - 1);
19748
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
19749
+ }
19750
+ var i = 0;
19751
+ var mul = 1;
19752
+ var sub = 0;
19753
+ this[offset] = value & 255;
19754
+ while (++i < byteLength && (mul *= 256)) {
19755
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;
19756
+ this[offset + i] = (value / mul >> 0) - sub & 255;
19757
+ }
19758
+ return offset + byteLength;
19759
+ };
19760
+ Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
19761
+ value = +value;
19762
+ offset = offset | 0;
19763
+ if (!noAssert) {
19764
+ var limit = Math.pow(2, 8 * byteLength - 1);
19765
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
19766
+ }
19767
+ var i = byteLength - 1;
19768
+ var mul = 1;
19769
+ var sub = 0;
19770
+ this[offset + i] = value & 255;
19771
+ while (--i >= 0 && (mul *= 256)) {
19772
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;
19773
+ this[offset + i] = (value / mul >> 0) - sub & 255;
19774
+ }
19775
+ return offset + byteLength;
19776
+ };
19777
+ Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
19778
+ value = +value;
19779
+ offset = offset | 0;
19780
+ if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
19781
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
19782
+ if (value < 0) value = 255 + value + 1;
19783
+ this[offset] = value & 255;
19784
+ return offset + 1;
19785
+ };
19786
+ Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
19787
+ value = +value;
19788
+ offset = offset | 0;
19789
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
19790
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19791
+ this[offset] = value & 255;
19792
+ this[offset + 1] = value >>> 8;
19793
+ } else objectWriteUInt16(this, value, offset, true);
19794
+ return offset + 2;
19795
+ };
19796
+ Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
19797
+ value = +value;
19798
+ offset = offset | 0;
19799
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
19800
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19801
+ this[offset] = value >>> 8;
19802
+ this[offset + 1] = value & 255;
19803
+ } else objectWriteUInt16(this, value, offset, false);
19804
+ return offset + 2;
19805
+ };
19806
+ Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
19807
+ value = +value;
19808
+ offset = offset | 0;
19809
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
19810
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19811
+ this[offset] = value & 255;
19812
+ this[offset + 1] = value >>> 8;
19813
+ this[offset + 2] = value >>> 16;
19814
+ this[offset + 3] = value >>> 24;
19815
+ } else objectWriteUInt32(this, value, offset, true);
19816
+ return offset + 4;
19817
+ };
19818
+ Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
19819
+ value = +value;
19820
+ offset = offset | 0;
19821
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
19822
+ if (value < 0) value = 4294967295 + value + 1;
19823
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
19824
+ this[offset] = value >>> 24;
19825
+ this[offset + 1] = value >>> 16;
19826
+ this[offset + 2] = value >>> 8;
19827
+ this[offset + 3] = value & 255;
19828
+ } else objectWriteUInt32(this, value, offset, false);
19829
+ return offset + 4;
19830
+ };
19831
+ function checkIEEE754(buf, value, offset, ext, max, min) {
19832
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
19833
+ if (offset < 0) throw new RangeError("Index out of range");
19834
+ }
19835
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
19836
+ if (!noAssert) checkIEEE754(buf, value, offset, 4);
19837
+ write(buf, value, offset, littleEndian, 23, 4);
19838
+ return offset + 4;
19839
+ }
19840
+ Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
19841
+ return writeFloat(this, value, offset, true, noAssert);
19842
+ };
19843
+ Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
19844
+ return writeFloat(this, value, offset, false, noAssert);
19845
+ };
19846
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
19847
+ if (!noAssert) checkIEEE754(buf, value, offset, 8);
19848
+ write(buf, value, offset, littleEndian, 52, 8);
19849
+ return offset + 8;
19850
+ }
19851
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
19852
+ return writeDouble(this, value, offset, true, noAssert);
19853
+ };
19854
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
19855
+ return writeDouble(this, value, offset, false, noAssert);
19856
+ };
19857
+ Buffer.prototype.copy = function copy(target, targetStart, start, end) {
19858
+ if (!start) start = 0;
19859
+ if (!end && end !== 0) end = this.length;
19860
+ if (targetStart >= target.length) targetStart = target.length;
19861
+ if (!targetStart) targetStart = 0;
19862
+ if (end > 0 && end < start) end = start;
19863
+ if (end === start) return 0;
19864
+ if (target.length === 0 || this.length === 0) return 0;
19865
+ if (targetStart < 0) throw new RangeError("targetStart out of bounds");
19866
+ if (start < 0 || start >= this.length) throw new RangeError("sourceStart out of bounds");
19867
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
19868
+ if (end > this.length) end = this.length;
19869
+ if (target.length - targetStart < end - start) end = target.length - targetStart + start;
19870
+ var len = end - start;
19871
+ var i;
19872
+ if (this === target && start < targetStart && targetStart < end) for (i = len - 1; i >= 0; --i) target[i + targetStart] = this[i + start];
19873
+ else if (len < 1e3 || !Buffer.TYPED_ARRAY_SUPPORT) for (i = 0; i < len; ++i) target[i + targetStart] = this[i + start];
19874
+ else Uint8Array.prototype.set.call(target, this.subarray(start, start + len), targetStart);
19875
+ return len;
19876
+ };
19877
+ Buffer.prototype.fill = function fill(val, start, end, encoding) {
19878
+ if (typeof val === "string") {
19879
+ if (typeof start === "string") {
19880
+ encoding = start;
19881
+ start = 0;
19882
+ end = this.length;
19883
+ } else if (typeof end === "string") {
19884
+ encoding = end;
19885
+ end = this.length;
19886
+ }
19887
+ if (val.length === 1) {
19888
+ var code = val.charCodeAt(0);
19889
+ if (code < 256) val = code;
19890
+ }
19891
+ if (encoding !== void 0 && typeof encoding !== "string") throw new TypeError("encoding must be a string");
19892
+ if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) throw new TypeError("Unknown encoding: " + encoding);
19893
+ } else if (typeof val === "number") val = val & 255;
19894
+ if (start < 0 || this.length < start || this.length < end) throw new RangeError("Out of range index");
19895
+ if (end <= start) return this;
19896
+ start = start >>> 0;
19897
+ end = end === void 0 ? this.length : end >>> 0;
19898
+ if (!val) val = 0;
19899
+ var i;
19900
+ if (typeof val === "number") for (i = start; i < end; ++i) this[i] = val;
19901
+ else {
19902
+ var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer(val, encoding).toString());
19903
+ var len = bytes.length;
19904
+ for (i = 0; i < end - start; ++i) this[i + start] = bytes[i % len];
19905
+ }
19906
+ return this;
19907
+ };
19908
+ var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
19909
+ function base64clean(str) {
19910
+ str = stringtrim(str).replace(INVALID_BASE64_RE, "");
19911
+ if (str.length < 2) return "";
19912
+ while (str.length % 4 !== 0) str = str + "=";
19913
+ return str;
19914
+ }
19915
+ function stringtrim(str) {
19916
+ if (str.trim) return str.trim();
19917
+ return str.replace(/^\s+|\s+$/g, "");
19918
+ }
19919
+ function toHex(n) {
19920
+ if (n < 16) return "0" + n.toString(16);
19921
+ return n.toString(16);
19922
+ }
19923
+ function utf8ToBytes(string, units) {
19924
+ units = units || Infinity;
19925
+ var codePoint;
19926
+ var length = string.length;
19927
+ var leadSurrogate = null;
19928
+ var bytes = [];
19929
+ for (var i = 0; i < length; ++i) {
19930
+ codePoint = string.charCodeAt(i);
19931
+ if (codePoint > 55295 && codePoint < 57344) {
19932
+ if (!leadSurrogate) {
19933
+ if (codePoint > 56319) {
19934
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19935
+ continue;
19936
+ } else if (i + 1 === length) {
19937
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19938
+ continue;
19939
+ }
19940
+ leadSurrogate = codePoint;
19941
+ continue;
19942
+ }
19943
+ if (codePoint < 56320) {
19944
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19945
+ leadSurrogate = codePoint;
19946
+ continue;
19947
+ }
19948
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
19949
+ } else if (leadSurrogate) {
19950
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
19951
+ }
19952
+ leadSurrogate = null;
19953
+ if (codePoint < 128) {
19954
+ if ((units -= 1) < 0) break;
19955
+ bytes.push(codePoint);
19956
+ } else if (codePoint < 2048) {
19957
+ if ((units -= 2) < 0) break;
19958
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
19959
+ } else if (codePoint < 65536) {
19960
+ if ((units -= 3) < 0) break;
19961
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
19962
+ } else if (codePoint < 1114112) {
19963
+ if ((units -= 4) < 0) break;
19964
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
19965
+ } else throw new Error("Invalid code point");
19966
+ }
19967
+ return bytes;
19968
+ }
19969
+ function asciiToBytes(str) {
19970
+ var byteArray = [];
19971
+ for (var i = 0; i < str.length; ++i) byteArray.push(str.charCodeAt(i) & 255);
19972
+ return byteArray;
19973
+ }
19974
+ function utf16leToBytes(str, units) {
19975
+ var c, hi, lo;
19976
+ var byteArray = [];
19977
+ for (var i = 0; i < str.length; ++i) {
19978
+ if ((units -= 2) < 0) break;
19979
+ c = str.charCodeAt(i);
19980
+ hi = c >> 8;
19981
+ lo = c % 256;
19982
+ byteArray.push(lo);
19983
+ byteArray.push(hi);
19984
+ }
19985
+ return byteArray;
19986
+ }
19987
+ function base64ToBytes(str) {
19988
+ return toByteArray(base64clean(str));
19989
+ }
19990
+ function blitBuffer(src, dst, offset, length) {
19991
+ for (var i = 0; i < length; ++i) {
19992
+ if (i + offset >= dst.length || i >= src.length) break;
19993
+ dst[i + offset] = src[i];
19994
+ }
19995
+ return i;
19996
+ }
19997
+ function isnan(val) {
19998
+ return val !== val;
19999
+ }
20000
+ function isBuffer(obj) {
20001
+ return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
20002
+ }
20003
+ function isFastBuffer(obj) {
20004
+ return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
20005
+ }
20006
+ function isSlowBuffer(obj) {
20007
+ return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
20008
+ }
20009
+ //#endregion
20010
+ //#region \0polyfill-node.process.js
20011
+ function defaultSetTimout() {
20012
+ throw new Error("setTimeout has not been defined");
20013
+ }
20014
+ function defaultClearTimeout() {
20015
+ throw new Error("clearTimeout has not been defined");
20016
+ }
20017
+ var cachedSetTimeout = defaultSetTimout;
20018
+ var cachedClearTimeout = defaultClearTimeout;
20019
+ if (typeof _polyfill_node_global_default.setTimeout === "function") cachedSetTimeout = setTimeout;
20020
+ if (typeof _polyfill_node_global_default.clearTimeout === "function") cachedClearTimeout = clearTimeout;
20021
+ function runTimeout(fun) {
20022
+ if (cachedSetTimeout === setTimeout) return setTimeout(fun, 0);
20023
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
20024
+ cachedSetTimeout = setTimeout;
20025
+ return setTimeout(fun, 0);
20026
+ }
20027
+ try {
20028
+ return cachedSetTimeout(fun, 0);
20029
+ } catch (e) {
20030
+ try {
20031
+ return cachedSetTimeout.call(null, fun, 0);
20032
+ } catch (e) {
20033
+ return cachedSetTimeout.call(this, fun, 0);
20034
+ }
20035
+ }
20036
+ }
20037
+ function runClearTimeout(marker) {
20038
+ if (cachedClearTimeout === clearTimeout) return clearTimeout(marker);
20039
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
20040
+ cachedClearTimeout = clearTimeout;
20041
+ return clearTimeout(marker);
20042
+ }
20043
+ try {
20044
+ return cachedClearTimeout(marker);
20045
+ } catch (e) {
20046
+ try {
20047
+ return cachedClearTimeout.call(null, marker);
20048
+ } catch (e) {
20049
+ return cachedClearTimeout.call(this, marker);
20050
+ }
20051
+ }
20052
+ }
20053
+ var queue = [];
20054
+ var draining = false;
20055
+ var currentQueue;
20056
+ var queueIndex = -1;
20057
+ function cleanUpNextTick() {
20058
+ if (!draining || !currentQueue) return;
20059
+ draining = false;
20060
+ if (currentQueue.length) queue = currentQueue.concat(queue);
20061
+ else queueIndex = -1;
20062
+ if (queue.length) drainQueue();
20063
+ }
20064
+ function drainQueue() {
20065
+ if (draining) return;
20066
+ var timeout = runTimeout(cleanUpNextTick);
20067
+ draining = true;
20068
+ var len = queue.length;
20069
+ while (len) {
20070
+ currentQueue = queue;
20071
+ queue = [];
20072
+ while (++queueIndex < len) if (currentQueue) currentQueue[queueIndex].run();
20073
+ queueIndex = -1;
20074
+ len = queue.length;
20075
+ }
20076
+ currentQueue = null;
20077
+ draining = false;
20078
+ runClearTimeout(timeout);
20079
+ }
20080
+ function nextTick(fun) {
20081
+ var args = new Array(arguments.length - 1);
20082
+ if (arguments.length > 1) for (var i = 1; i < arguments.length; i++) args[i - 1] = arguments[i];
20083
+ queue.push(new Item(fun, args));
20084
+ if (queue.length === 1 && !draining) runTimeout(drainQueue);
20085
+ }
20086
+ function Item(fun, array) {
20087
+ this.fun = fun;
20088
+ this.array = array;
20089
+ }
20090
+ Item.prototype.run = function() {
20091
+ this.fun.apply(null, this.array);
20092
+ };
20093
+ var title = "browser";
20094
+ var platform = "browser";
20095
+ var env = {};
20096
+ var argv = [];
20097
+ var versions = {};
20098
+ var release = {};
20099
+ var config = {};
20100
+ function noop() {}
20101
+ var on = noop;
20102
+ var addListener = noop;
20103
+ var once = noop;
20104
+ var off = noop;
20105
+ var removeListener = noop;
20106
+ var removeAllListeners = noop;
20107
+ var emit = noop;
20108
+ function binding(name) {
20109
+ throw new Error("process.binding is not supported");
20110
+ }
20111
+ function cwd() {
20112
+ return "/";
20113
+ }
20114
+ function chdir(dir) {
20115
+ throw new Error("process.chdir is not supported");
20116
+ }
20117
+ function umask() {
20118
+ return 0;
20119
+ }
20120
+ var performance = _polyfill_node_global_default.performance || {};
20121
+ var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
20122
+ return (/* @__PURE__ */ new Date()).getTime();
20123
+ };
20124
+ function hrtime(previousTimestamp) {
20125
+ var clocktime = performanceNow.call(performance) * .001;
20126
+ var seconds = Math.floor(clocktime);
20127
+ var nanoseconds = Math.floor(clocktime % 1 * 1e9);
20128
+ if (previousTimestamp) {
20129
+ seconds = seconds - previousTimestamp[0];
20130
+ nanoseconds = nanoseconds - previousTimestamp[1];
20131
+ if (nanoseconds < 0) {
20132
+ seconds--;
20133
+ nanoseconds += 1e9;
20134
+ }
20135
+ }
20136
+ return [seconds, nanoseconds];
20137
+ }
20138
+ var startTime = /* @__PURE__ */ new Date();
20139
+ function uptime() {
20140
+ return (/* @__PURE__ */ new Date() - startTime) / 1e3;
20141
+ }
20142
+ var browser$1 = {
20143
+ nextTick,
20144
+ title,
20145
+ browser: true,
20146
+ env,
20147
+ argv,
20148
+ version: "",
20149
+ versions,
20150
+ on,
20151
+ addListener,
20152
+ once,
20153
+ off,
20154
+ removeListener,
20155
+ removeAllListeners,
20156
+ emit,
20157
+ binding,
20158
+ cwd,
20159
+ chdir,
20160
+ umask,
20161
+ hrtime,
20162
+ platform,
20163
+ release,
20164
+ config,
20165
+ uptime
20166
+ };
20167
+ //#endregion
20168
+ //#region \0polyfill-node._inherits.js
20169
+ var inherits;
20170
+ if (typeof Object.create === "function") inherits = function inherits(ctor, superCtor) {
20171
+ ctor.super_ = superCtor;
20172
+ ctor.prototype = Object.create(superCtor.prototype, { constructor: {
20173
+ value: ctor,
20174
+ enumerable: false,
20175
+ writable: true,
20176
+ configurable: true
20177
+ } });
20178
+ };
20179
+ else inherits = function inherits(ctor, superCtor) {
20180
+ ctor.super_ = superCtor;
20181
+ var TempCtor = function() {};
20182
+ TempCtor.prototype = superCtor.prototype;
20183
+ ctor.prototype = new TempCtor();
20184
+ ctor.prototype.constructor = ctor;
20185
+ };
20186
+ var _polyfill_node__inherits_default = inherits;
20187
+ //#endregion
20188
+ //#region \0polyfill-node.util.js
20189
+ /**
20190
+ * Inherit the prototype methods from one constructor into another.
20191
+ *
20192
+ * The Function.prototype.inherits from lang.js rewritten as a standalone
20193
+ * function (not on Function.prototype). NOTE: If this file is to be loaded
20194
+ * during bootstrapping this function needs to be rewritten using some native
20195
+ * functions as prototype setup using normal JavaScript does not work as
20196
+ * expected during bootstrapping (see mirror.js in r114903).
20197
+ *
20198
+ * @param {function} ctor Constructor function which needs to inherit the
20199
+ * prototype.
20200
+ * @param {function} superCtor Constructor function to inherit prototype from.
20201
+ */
20202
+ var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || function getOwnPropertyDescriptors(obj) {
20203
+ var keys = Object.keys(obj);
20204
+ var descriptors = {};
20205
+ for (var i = 0; i < keys.length; i++) descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
20206
+ return descriptors;
20207
+ };
20208
+ var formatRegExp = /%[sdj%]/g;
20209
+ function format(f) {
20210
+ if (!isString(f)) {
20211
+ var objects = [];
20212
+ for (var i = 0; i < arguments.length; i++) objects.push(inspect(arguments[i]));
20213
+ return objects.join(" ");
20214
+ }
20215
+ var i = 1;
20216
+ var args = arguments;
20217
+ var len = args.length;
20218
+ var str = String(f).replace(formatRegExp, function(x) {
20219
+ if (x === "%%") return "%";
20220
+ if (i >= len) return x;
20221
+ switch (x) {
20222
+ case "%s": return String(args[i++]);
20223
+ case "%d": return Number(args[i++]);
20224
+ case "%j": try {
20225
+ return JSON.stringify(args[i++]);
20226
+ } catch (_) {
20227
+ return "[Circular]";
20228
+ }
20229
+ default: return x;
20230
+ }
20231
+ });
20232
+ for (var x = args[i]; i < len; x = args[++i]) if (isNull(x) || !isObject(x)) str += " " + x;
20233
+ else str += " " + inspect(x);
20234
+ return str;
20235
+ }
20236
+ function deprecate(fn, msg) {
20237
+ if (isUndefined(_polyfill_node_global_default.process)) return function() {
20238
+ return deprecate(fn, msg).apply(this, arguments);
20239
+ };
20240
+ if (browser$1.noDeprecation === true) return fn;
20241
+ var warned = false;
20242
+ function deprecated() {
20243
+ if (!warned) {
20244
+ if (browser$1.throwDeprecation) throw new Error(msg);
20245
+ else if (browser$1.traceDeprecation) console.trace(msg);
20246
+ else console.error(msg);
20247
+ warned = true;
20248
+ }
20249
+ return fn.apply(this, arguments);
20250
+ }
20251
+ return deprecated;
20252
+ }
20253
+ var debugs = {};
20254
+ var debugEnviron;
20255
+ function debuglog(set) {
20256
+ if (isUndefined(debugEnviron)) debugEnviron = browser$1.env.NODE_DEBUG || "";
20257
+ set = set.toUpperCase();
20258
+ if (!debugs[set]) if (new RegExp("\\b" + set + "\\b", "i").test(debugEnviron)) {
20259
+ var pid = 0;
20260
+ debugs[set] = function() {
20261
+ var msg = format.apply(null, arguments);
20262
+ console.error("%s %d: %s", set, pid, msg);
20263
+ };
20264
+ } else debugs[set] = function() {};
20265
+ return debugs[set];
20266
+ }
20267
+ /**
20268
+ * Echos the value of a value. Trys to print the value out
20269
+ * in the best way possible given the different types.
20270
+ *
20271
+ * @param {Object} obj The object to print out.
20272
+ * @param {Object} opts Optional options object that alters the output.
20273
+ */
20274
+ function inspect(obj, opts) {
20275
+ var ctx = {
20276
+ seen: [],
20277
+ stylize: stylizeNoColor
20278
+ };
20279
+ if (arguments.length >= 3) ctx.depth = arguments[2];
20280
+ if (arguments.length >= 4) ctx.colors = arguments[3];
20281
+ if (isBoolean(opts)) ctx.showHidden = opts;
20282
+ else if (opts) _extend(ctx, opts);
20283
+ if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
20284
+ if (isUndefined(ctx.depth)) ctx.depth = 2;
20285
+ if (isUndefined(ctx.colors)) ctx.colors = false;
20286
+ if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
20287
+ if (ctx.colors) ctx.stylize = stylizeWithColor;
20288
+ return formatValue(ctx, obj, ctx.depth);
20289
+ }
20290
+ inspect.colors = {
20291
+ "bold": [1, 22],
20292
+ "italic": [3, 23],
20293
+ "underline": [4, 24],
20294
+ "inverse": [7, 27],
20295
+ "white": [37, 39],
20296
+ "grey": [90, 39],
20297
+ "black": [30, 39],
20298
+ "blue": [34, 39],
20299
+ "cyan": [36, 39],
20300
+ "green": [32, 39],
20301
+ "magenta": [35, 39],
20302
+ "red": [31, 39],
20303
+ "yellow": [33, 39]
20304
+ };
20305
+ inspect.styles = {
20306
+ "special": "cyan",
20307
+ "number": "yellow",
20308
+ "boolean": "yellow",
20309
+ "undefined": "grey",
20310
+ "null": "bold",
20311
+ "string": "green",
20312
+ "date": "magenta",
20313
+ "regexp": "red"
20314
+ };
20315
+ function stylizeWithColor(str, styleType) {
20316
+ var style = inspect.styles[styleType];
20317
+ if (style) return "\x1B[" + inspect.colors[style][0] + "m" + str + "\x1B[" + inspect.colors[style][1] + "m";
20318
+ else return str;
20319
+ }
20320
+ function stylizeNoColor(str, styleType) {
20321
+ return str;
20322
+ }
20323
+ function arrayToHash(array) {
20324
+ var hash = {};
20325
+ array.forEach(function(val, idx) {
20326
+ hash[val] = true;
20327
+ });
20328
+ return hash;
20329
+ }
20330
+ function formatValue(ctx, value, recurseTimes) {
20331
+ if (ctx.customInspect && value && isFunction(value.inspect) && value.inspect !== inspect && !(value.constructor && value.constructor.prototype === value)) {
20332
+ var ret = value.inspect(recurseTimes, ctx);
20333
+ if (!isString(ret)) ret = formatValue(ctx, ret, recurseTimes);
20334
+ return ret;
20335
+ }
20336
+ var primitive = formatPrimitive(ctx, value);
20337
+ if (primitive) return primitive;
20338
+ var keys = Object.keys(value);
20339
+ var visibleKeys = arrayToHash(keys);
20340
+ if (ctx.showHidden) keys = Object.getOwnPropertyNames(value);
20341
+ if (isError(value) && (keys.indexOf("message") >= 0 || keys.indexOf("description") >= 0)) return formatError(value);
20342
+ if (keys.length === 0) {
20343
+ if (isFunction(value)) {
20344
+ var name = value.name ? ": " + value.name : "";
20345
+ return ctx.stylize("[Function" + name + "]", "special");
20346
+ }
20347
+ if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
20348
+ if (isDate(value)) return ctx.stylize(Date.prototype.toString.call(value), "date");
20349
+ if (isError(value)) return formatError(value);
20350
+ }
20351
+ var base = "", array = false, braces = ["{", "}"];
20352
+ if (isArray(value)) {
20353
+ array = true;
20354
+ braces = ["[", "]"];
20355
+ }
20356
+ if (isFunction(value)) base = " [Function" + (value.name ? ": " + value.name : "") + "]";
20357
+ if (isRegExp(value)) base = " " + RegExp.prototype.toString.call(value);
20358
+ if (isDate(value)) base = " " + Date.prototype.toUTCString.call(value);
20359
+ if (isError(value)) base = " " + formatError(value);
20360
+ if (keys.length === 0 && (!array || value.length == 0)) return braces[0] + base + braces[1];
20361
+ if (recurseTimes < 0) if (isRegExp(value)) return ctx.stylize(RegExp.prototype.toString.call(value), "regexp");
20362
+ else return ctx.stylize("[Object]", "special");
20363
+ ctx.seen.push(value);
20364
+ var output;
20365
+ if (array) output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
20366
+ else output = keys.map(function(key) {
20367
+ return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
20368
+ });
20369
+ ctx.seen.pop();
20370
+ return reduceToSingleString(output, base, braces);
20371
+ }
20372
+ function formatPrimitive(ctx, value) {
20373
+ if (isUndefined(value)) return ctx.stylize("undefined", "undefined");
20374
+ if (isString(value)) {
20375
+ var simple = "'" + JSON.stringify(value).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
20376
+ return ctx.stylize(simple, "string");
20377
+ }
20378
+ if (isNumber(value)) return ctx.stylize("" + value, "number");
20379
+ if (isBoolean(value)) return ctx.stylize("" + value, "boolean");
20380
+ if (isNull(value)) return ctx.stylize("null", "null");
20381
+ }
20382
+ function formatError(value) {
20383
+ return "[" + Error.prototype.toString.call(value) + "]";
20384
+ }
20385
+ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
20386
+ var output = [];
20387
+ for (var i = 0, l = value.length; i < l; ++i) if (hasOwnProperty(value, String(i))) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, String(i), true));
20388
+ else output.push("");
20389
+ keys.forEach(function(key) {
20390
+ if (!key.match(/^\d+$/)) output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, key, true));
20391
+ });
20392
+ return output;
20393
+ }
20394
+ function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
20395
+ var name, str, desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
20396
+ if (desc.get) if (desc.set) str = ctx.stylize("[Getter/Setter]", "special");
20397
+ else str = ctx.stylize("[Getter]", "special");
20398
+ else if (desc.set) str = ctx.stylize("[Setter]", "special");
20399
+ if (!hasOwnProperty(visibleKeys, key)) name = "[" + key + "]";
20400
+ if (!str) if (ctx.seen.indexOf(desc.value) < 0) {
20401
+ if (isNull(recurseTimes)) str = formatValue(ctx, desc.value, null);
20402
+ else str = formatValue(ctx, desc.value, recurseTimes - 1);
20403
+ if (str.indexOf("\n") > -1) if (array) str = str.split("\n").map(function(line) {
20404
+ return " " + line;
20405
+ }).join("\n").substr(2);
20406
+ else str = "\n" + str.split("\n").map(function(line) {
20407
+ return " " + line;
20408
+ }).join("\n");
20409
+ } else str = ctx.stylize("[Circular]", "special");
20410
+ if (isUndefined(name)) {
20411
+ if (array && key.match(/^\d+$/)) return str;
20412
+ name = JSON.stringify("" + key);
20413
+ if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
20414
+ name = name.substr(1, name.length - 2);
20415
+ name = ctx.stylize(name, "name");
20416
+ } else {
20417
+ name = name.replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'");
20418
+ name = ctx.stylize(name, "string");
20419
+ }
20420
+ }
20421
+ return name + ": " + str;
20422
+ }
20423
+ function reduceToSingleString(output, base, braces) {
20424
+ var numLinesEst = 0;
20425
+ if (output.reduce(function(prev, cur) {
20426
+ numLinesEst++;
20427
+ if (cur.indexOf("\n") >= 0) numLinesEst++;
20428
+ return prev + cur.replace(/\u001b\[\d\d?m/g, "").length + 1;
20429
+ }, 0) > 60) return braces[0] + (base === "" ? "" : base + "\n ") + " " + output.join(",\n ") + " " + braces[1];
20430
+ return braces[0] + base + " " + output.join(", ") + " " + braces[1];
20431
+ }
20432
+ function isArray(ar) {
20433
+ return Array.isArray(ar);
20434
+ }
20435
+ function isBoolean(arg) {
20436
+ return typeof arg === "boolean";
20437
+ }
20438
+ function isNull(arg) {
20439
+ return arg === null;
20440
+ }
20441
+ function isNumber(arg) {
20442
+ return typeof arg === "number";
20443
+ }
20444
+ function isString(arg) {
20445
+ return typeof arg === "string";
20446
+ }
20447
+ function isUndefined(arg) {
20448
+ return arg === void 0;
20449
+ }
20450
+ function isRegExp(re) {
20451
+ return isObject(re) && objectToString(re) === "[object RegExp]";
20452
+ }
20453
+ function isObject(arg) {
20454
+ return typeof arg === "object" && arg !== null;
20455
+ }
20456
+ function isDate(d) {
20457
+ return isObject(d) && objectToString(d) === "[object Date]";
20458
+ }
20459
+ function isError(e) {
20460
+ return isObject(e) && (objectToString(e) === "[object Error]" || e instanceof Error);
20461
+ }
20462
+ function isFunction(arg) {
20463
+ return typeof arg === "function";
20464
+ }
20465
+ function objectToString(o) {
20466
+ return Object.prototype.toString.call(o);
20467
+ }
20468
+ function _extend(origin, add) {
20469
+ if (!add || !isObject(add)) return origin;
20470
+ var keys = Object.keys(add);
20471
+ var i = keys.length;
20472
+ while (i--) origin[keys[i]] = add[keys[i]];
20473
+ return origin;
20474
+ }
20475
+ function hasOwnProperty(obj, prop) {
20476
+ return Object.prototype.hasOwnProperty.call(obj, prop);
20477
+ }
20478
+ var kCustomPromisifiedSymbol = typeof Symbol !== "undefined" ? Symbol("util.promisify.custom") : void 0;
20479
+ function promisify(original) {
20480
+ if (typeof original !== "function") throw new TypeError("The \"original\" argument must be of type Function");
20481
+ if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
20482
+ var fn = original[kCustomPromisifiedSymbol];
20483
+ if (typeof fn !== "function") throw new TypeError("The \"util.promisify.custom\" argument must be of type Function");
20484
+ Object.defineProperty(fn, kCustomPromisifiedSymbol, {
20485
+ value: fn,
20486
+ enumerable: false,
20487
+ writable: false,
20488
+ configurable: true
20489
+ });
20490
+ return fn;
20491
+ }
20492
+ function fn() {
20493
+ var promiseResolve, promiseReject;
20494
+ var promise = new Promise(function(resolve, reject) {
20495
+ promiseResolve = resolve;
20496
+ promiseReject = reject;
20497
+ });
20498
+ var args = [];
20499
+ for (var i = 0; i < arguments.length; i++) args.push(arguments[i]);
20500
+ args.push(function(err, value) {
20501
+ if (err) promiseReject(err);
20502
+ else promiseResolve(value);
20503
+ });
20504
+ try {
20505
+ original.apply(this, args);
20506
+ } catch (err) {
20507
+ promiseReject(err);
20508
+ }
20509
+ return promise;
20510
+ }
20511
+ Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
20512
+ if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
20513
+ value: fn,
20514
+ enumerable: false,
20515
+ writable: false,
20516
+ configurable: true
20517
+ });
20518
+ return Object.defineProperties(fn, getOwnPropertyDescriptors(original));
20519
+ }
20520
+ promisify.custom = kCustomPromisifiedSymbol;
20521
+ //#endregion
20522
+ //#region \0polyfill-node._buffer_list.js
20523
+ var _polyfill_node__buffer_list_default = BufferList;
20524
+ function BufferList() {
20525
+ this.head = null;
20526
+ this.tail = null;
20527
+ this.length = 0;
20528
+ }
20529
+ BufferList.prototype.push = function(v) {
20530
+ var entry = {
20531
+ data: v,
20532
+ next: null
20533
+ };
20534
+ if (this.length > 0) this.tail.next = entry;
20535
+ else this.head = entry;
20536
+ this.tail = entry;
20537
+ ++this.length;
20538
+ };
20539
+ BufferList.prototype.unshift = function(v) {
20540
+ var entry = {
20541
+ data: v,
20542
+ next: this.head
20543
+ };
20544
+ if (this.length === 0) this.tail = entry;
20545
+ this.head = entry;
20546
+ ++this.length;
20547
+ };
20548
+ BufferList.prototype.shift = function() {
20549
+ if (this.length === 0) return;
20550
+ var ret = this.head.data;
20551
+ if (this.length === 1) this.head = this.tail = null;
20552
+ else this.head = this.head.next;
20553
+ --this.length;
20554
+ return ret;
20555
+ };
20556
+ BufferList.prototype.clear = function() {
20557
+ this.head = this.tail = null;
20558
+ this.length = 0;
20559
+ };
20560
+ BufferList.prototype.join = function(s) {
20561
+ if (this.length === 0) return "";
20562
+ var p = this.head;
20563
+ var ret = "" + p.data;
20564
+ while (p = p.next) ret += s + p.data;
20565
+ return ret;
20566
+ };
20567
+ BufferList.prototype.concat = function(n) {
20568
+ if (this.length === 0) return Buffer.alloc(0);
20569
+ if (this.length === 1) return this.head.data;
20570
+ var ret = Buffer.allocUnsafe(n >>> 0);
20571
+ var p = this.head;
20572
+ var i = 0;
20573
+ while (p) {
20574
+ p.data.copy(ret, i);
20575
+ i += p.data.length;
20576
+ p = p.next;
20577
+ }
20578
+ return ret;
20579
+ };
20580
+ //#endregion
20581
+ //#region \0polyfill-node.string_decoder.js
20582
+ var isBufferEncoding = Buffer.isEncoding || function(encoding) {
20583
+ switch (encoding && encoding.toLowerCase()) {
20584
+ case "hex":
20585
+ case "utf8":
20586
+ case "utf-8":
20587
+ case "ascii":
20588
+ case "binary":
20589
+ case "base64":
20590
+ case "ucs2":
20591
+ case "ucs-2":
20592
+ case "utf16le":
20593
+ case "utf-16le":
20594
+ case "raw": return true;
20595
+ default: return false;
20596
+ }
20597
+ };
20598
+ function assertEncoding(encoding) {
20599
+ if (encoding && !isBufferEncoding(encoding)) throw new Error("Unknown encoding: " + encoding);
20600
+ }
20601
+ function StringDecoder(encoding) {
20602
+ this.encoding = (encoding || "utf8").toLowerCase().replace(/[-_]/, "");
20603
+ assertEncoding(encoding);
20604
+ switch (this.encoding) {
20605
+ case "utf8":
20606
+ this.surrogateSize = 3;
20607
+ break;
20608
+ case "ucs2":
20609
+ case "utf16le":
20610
+ this.surrogateSize = 2;
20611
+ this.detectIncompleteChar = utf16DetectIncompleteChar;
20612
+ break;
20613
+ case "base64":
20614
+ this.surrogateSize = 3;
20615
+ this.detectIncompleteChar = base64DetectIncompleteChar;
20616
+ break;
20617
+ default:
20618
+ this.write = passThroughWrite;
20619
+ return;
20620
+ }
20621
+ this.charBuffer = new Buffer(6);
20622
+ this.charReceived = 0;
20623
+ this.charLength = 0;
20624
+ }
20625
+ StringDecoder.prototype.write = function(buffer) {
20626
+ var charStr = "";
20627
+ while (this.charLength) {
20628
+ var available = buffer.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : buffer.length;
20629
+ buffer.copy(this.charBuffer, this.charReceived, 0, available);
20630
+ this.charReceived += available;
20631
+ if (this.charReceived < this.charLength) return "";
20632
+ buffer = buffer.slice(available, buffer.length);
20633
+ charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
20634
+ var charCode = charStr.charCodeAt(charStr.length - 1);
20635
+ if (charCode >= 55296 && charCode <= 56319) {
20636
+ this.charLength += this.surrogateSize;
20637
+ charStr = "";
20638
+ continue;
20639
+ }
20640
+ this.charReceived = this.charLength = 0;
20641
+ if (buffer.length === 0) return charStr;
20642
+ break;
20643
+ }
20644
+ this.detectIncompleteChar(buffer);
20645
+ var end = buffer.length;
20646
+ if (this.charLength) {
20647
+ buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
20648
+ end -= this.charReceived;
20649
+ }
20650
+ charStr += buffer.toString(this.encoding, 0, end);
20651
+ var end = charStr.length - 1;
20652
+ var charCode = charStr.charCodeAt(end);
20653
+ if (charCode >= 55296 && charCode <= 56319) {
20654
+ var size = this.surrogateSize;
20655
+ this.charLength += size;
20656
+ this.charReceived += size;
20657
+ this.charBuffer.copy(this.charBuffer, size, 0, size);
20658
+ buffer.copy(this.charBuffer, 0, 0, size);
20659
+ return charStr.substring(0, end);
20660
+ }
20661
+ return charStr;
20662
+ };
20663
+ StringDecoder.prototype.detectIncompleteChar = function(buffer) {
20664
+ var i = buffer.length >= 3 ? 3 : buffer.length;
20665
+ for (; i > 0; i--) {
20666
+ var c = buffer[buffer.length - i];
20667
+ if (i == 1 && c >> 5 == 6) {
20668
+ this.charLength = 2;
20669
+ break;
20670
+ }
20671
+ if (i <= 2 && c >> 4 == 14) {
20672
+ this.charLength = 3;
20673
+ break;
20674
+ }
20675
+ if (i <= 3 && c >> 3 == 30) {
20676
+ this.charLength = 4;
20677
+ break;
20678
+ }
20679
+ }
20680
+ this.charReceived = i;
20681
+ };
20682
+ StringDecoder.prototype.end = function(buffer) {
20683
+ var res = "";
20684
+ if (buffer && buffer.length) res = this.write(buffer);
20685
+ if (this.charReceived) {
20686
+ var cr = this.charReceived;
20687
+ var buf = this.charBuffer;
20688
+ var enc = this.encoding;
20689
+ res += buf.slice(0, cr).toString(enc);
20690
+ }
20691
+ return res;
20692
+ };
20693
+ function passThroughWrite(buffer) {
20694
+ return buffer.toString(this.encoding);
20695
+ }
20696
+ function utf16DetectIncompleteChar(buffer) {
20697
+ this.charReceived = buffer.length % 2;
20698
+ this.charLength = this.charReceived ? 2 : 0;
20699
+ }
20700
+ function base64DetectIncompleteChar(buffer) {
20701
+ this.charReceived = buffer.length % 3;
20702
+ this.charLength = this.charReceived ? 3 : 0;
20703
+ }
20704
+ //#endregion
20705
+ //#region \0polyfill-node._stream_readable.js
20706
+ Readable.ReadableState = ReadableState;
20707
+ var debug = debuglog("stream");
20708
+ _polyfill_node__inherits_default(Readable, EventEmitter);
20709
+ function prependListener(emitter, event, fn) {
20710
+ if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
20711
+ else if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
20712
+ else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
20713
+ else emitter._events[event] = [fn, emitter._events[event]];
20714
+ }
20715
+ function listenerCount(emitter, type) {
20716
+ return emitter.listeners(type).length;
20717
+ }
20718
+ function ReadableState(options, stream) {
20719
+ options = options || {};
20720
+ this.objectMode = !!options.objectMode;
20721
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
20722
+ var hwm = options.highWaterMark;
20723
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
20724
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
20725
+ this.highWaterMark = ~~this.highWaterMark;
20726
+ this.buffer = new _polyfill_node__buffer_list_default();
20727
+ this.length = 0;
20728
+ this.pipes = null;
20729
+ this.pipesCount = 0;
20730
+ this.flowing = null;
20731
+ this.ended = false;
20732
+ this.endEmitted = false;
20733
+ this.reading = false;
20734
+ this.sync = true;
20735
+ this.needReadable = false;
20736
+ this.emittedReadable = false;
20737
+ this.readableListening = false;
20738
+ this.resumeScheduled = false;
20739
+ this.defaultEncoding = options.defaultEncoding || "utf8";
20740
+ this.ranOut = false;
20741
+ this.awaitDrain = 0;
20742
+ this.readingMore = false;
20743
+ this.decoder = null;
20744
+ this.encoding = null;
20745
+ if (options.encoding) {
20746
+ this.decoder = new StringDecoder(options.encoding);
20747
+ this.encoding = options.encoding;
20748
+ }
20749
+ }
20750
+ function Readable(options) {
20751
+ if (!(this instanceof Readable)) return new Readable(options);
20752
+ this._readableState = new ReadableState(options, this);
20753
+ this.readable = true;
20754
+ if (options && typeof options.read === "function") this._read = options.read;
20755
+ EventEmitter.call(this);
20756
+ }
20757
+ Readable.prototype.push = function(chunk, encoding) {
20758
+ var state = this._readableState;
20759
+ if (!state.objectMode && typeof chunk === "string") {
20760
+ encoding = encoding || state.defaultEncoding;
20761
+ if (encoding !== state.encoding) {
20762
+ chunk = Buffer.from(chunk, encoding);
20763
+ encoding = "";
20764
+ }
20765
+ }
20766
+ return readableAddChunk(this, state, chunk, encoding, false);
20767
+ };
20768
+ Readable.prototype.unshift = function(chunk) {
20769
+ var state = this._readableState;
20770
+ return readableAddChunk(this, state, chunk, "", true);
20771
+ };
20772
+ Readable.prototype.isPaused = function() {
20773
+ return this._readableState.flowing === false;
20774
+ };
20775
+ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
20776
+ var er = chunkInvalid(state, chunk);
20777
+ if (er) stream.emit("error", er);
20778
+ else if (chunk === null) {
20779
+ state.reading = false;
20780
+ onEofChunk(stream, state);
20781
+ } else if (state.objectMode || chunk && chunk.length > 0) if (state.ended && !addToFront) {
20782
+ var e = /* @__PURE__ */ new Error("stream.push() after EOF");
20783
+ stream.emit("error", e);
20784
+ } else if (state.endEmitted && addToFront) {
20785
+ var _e = /* @__PURE__ */ new Error("stream.unshift() after end event");
20786
+ stream.emit("error", _e);
20787
+ } else {
20788
+ var skipAdd;
20789
+ if (state.decoder && !addToFront && !encoding) {
20790
+ chunk = state.decoder.write(chunk);
20791
+ skipAdd = !state.objectMode && chunk.length === 0;
20792
+ }
20793
+ if (!addToFront) state.reading = false;
20794
+ if (!skipAdd) if (state.flowing && state.length === 0 && !state.sync) {
20795
+ stream.emit("data", chunk);
20796
+ stream.read(0);
20797
+ } else {
20798
+ state.length += state.objectMode ? 1 : chunk.length;
20799
+ if (addToFront) state.buffer.unshift(chunk);
20800
+ else state.buffer.push(chunk);
20801
+ if (state.needReadable) emitReadable(stream);
20802
+ }
20803
+ maybeReadMore(stream, state);
20804
+ }
20805
+ else if (!addToFront) state.reading = false;
20806
+ return needMoreData(state);
20807
+ }
20808
+ function needMoreData(state) {
20809
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
20810
+ }
20811
+ Readable.prototype.setEncoding = function(enc) {
20812
+ this._readableState.decoder = new StringDecoder(enc);
20813
+ this._readableState.encoding = enc;
20814
+ return this;
20815
+ };
20816
+ var MAX_HWM = 8388608;
20817
+ function computeNewHighWaterMark(n) {
20818
+ if (n >= MAX_HWM) n = MAX_HWM;
20819
+ else {
20820
+ n--;
20821
+ n |= n >>> 1;
20822
+ n |= n >>> 2;
20823
+ n |= n >>> 4;
20824
+ n |= n >>> 8;
20825
+ n |= n >>> 16;
20826
+ n++;
20827
+ }
20828
+ return n;
20829
+ }
20830
+ function howMuchToRead(n, state) {
20831
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
20832
+ if (state.objectMode) return 1;
20833
+ if (n !== n) if (state.flowing && state.length) return state.buffer.head.data.length;
20834
+ else return state.length;
20835
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
20836
+ if (n <= state.length) return n;
20837
+ if (!state.ended) {
20838
+ state.needReadable = true;
20839
+ return 0;
20840
+ }
20841
+ return state.length;
20842
+ }
20843
+ Readable.prototype.read = function(n) {
20844
+ debug("read", n);
20845
+ n = parseInt(n, 10);
20846
+ var state = this._readableState;
20847
+ var nOrig = n;
20848
+ if (n !== 0) state.emittedReadable = false;
20849
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
20850
+ debug("read: emitReadable", state.length, state.ended);
20851
+ if (state.length === 0 && state.ended) endReadable(this);
20852
+ else emitReadable(this);
20853
+ return null;
20854
+ }
20855
+ n = howMuchToRead(n, state);
20856
+ if (n === 0 && state.ended) {
20857
+ if (state.length === 0) endReadable(this);
20858
+ return null;
20859
+ }
20860
+ var doRead = state.needReadable;
20861
+ debug("need readable", doRead);
20862
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
20863
+ doRead = true;
20864
+ debug("length less than watermark", doRead);
20865
+ }
20866
+ if (state.ended || state.reading) {
20867
+ doRead = false;
20868
+ debug("reading or ended", doRead);
20869
+ } else if (doRead) {
20870
+ debug("do read");
20871
+ state.reading = true;
20872
+ state.sync = true;
20873
+ if (state.length === 0) state.needReadable = true;
20874
+ this._read(state.highWaterMark);
20875
+ state.sync = false;
20876
+ if (!state.reading) n = howMuchToRead(nOrig, state);
20877
+ }
20878
+ var ret;
20879
+ if (n > 0) ret = fromList(n, state);
20880
+ else ret = null;
20881
+ if (ret === null) {
20882
+ state.needReadable = true;
20883
+ n = 0;
20884
+ } else state.length -= n;
20885
+ if (state.length === 0) {
20886
+ if (!state.ended) state.needReadable = true;
20887
+ if (nOrig !== n && state.ended) endReadable(this);
20888
+ }
20889
+ if (ret !== null) this.emit("data", ret);
20890
+ return ret;
20891
+ };
20892
+ function chunkInvalid(state, chunk) {
20893
+ var er = null;
20894
+ if (!Buffer.isBuffer(chunk) && typeof chunk !== "string" && chunk !== null && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
20895
+ return er;
20896
+ }
20897
+ function onEofChunk(stream, state) {
20898
+ if (state.ended) return;
20899
+ if (state.decoder) {
20900
+ var chunk = state.decoder.end();
20901
+ if (chunk && chunk.length) {
20902
+ state.buffer.push(chunk);
20903
+ state.length += state.objectMode ? 1 : chunk.length;
20904
+ }
20905
+ }
20906
+ state.ended = true;
20907
+ emitReadable(stream);
20908
+ }
20909
+ function emitReadable(stream) {
20910
+ var state = stream._readableState;
20911
+ state.needReadable = false;
20912
+ if (!state.emittedReadable) {
20913
+ debug("emitReadable", state.flowing);
20914
+ state.emittedReadable = true;
20915
+ if (state.sync) nextTick(emitReadable_, stream);
20916
+ else emitReadable_(stream);
20917
+ }
20918
+ }
20919
+ function emitReadable_(stream) {
20920
+ debug("emit readable");
20921
+ stream.emit("readable");
20922
+ flow(stream);
20923
+ }
20924
+ function maybeReadMore(stream, state) {
20925
+ if (!state.readingMore) {
20926
+ state.readingMore = true;
20927
+ nextTick(maybeReadMore_, stream, state);
20928
+ }
20929
+ }
20930
+ function maybeReadMore_(stream, state) {
20931
+ var len = state.length;
20932
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
20933
+ debug("maybeReadMore read 0");
20934
+ stream.read(0);
20935
+ if (len === state.length) break;
20936
+ else len = state.length;
20937
+ }
20938
+ state.readingMore = false;
20939
+ }
20940
+ Readable.prototype._read = function(n) {
20941
+ this.emit("error", /* @__PURE__ */ new Error("not implemented"));
20942
+ };
20943
+ Readable.prototype.pipe = function(dest, pipeOpts) {
20944
+ var src = this;
20945
+ var state = this._readableState;
20946
+ switch (state.pipesCount) {
20947
+ case 0:
20948
+ state.pipes = dest;
20949
+ break;
20950
+ case 1:
20951
+ state.pipes = [state.pipes, dest];
20952
+ break;
20953
+ default:
20954
+ state.pipes.push(dest);
20955
+ break;
20956
+ }
20957
+ state.pipesCount += 1;
20958
+ debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
20959
+ var endFn = !pipeOpts || pipeOpts.end !== false ? onend : cleanup;
20960
+ if (state.endEmitted) nextTick(endFn);
20961
+ else src.once("end", endFn);
20962
+ dest.on("unpipe", onunpipe);
20963
+ function onunpipe(readable) {
20964
+ debug("onunpipe");
20965
+ if (readable === src) cleanup();
20966
+ }
20967
+ function onend() {
20968
+ debug("onend");
20969
+ dest.end();
20970
+ }
20971
+ var ondrain = pipeOnDrain(src);
20972
+ dest.on("drain", ondrain);
20973
+ var cleanedUp = false;
20974
+ function cleanup() {
20975
+ debug("cleanup");
20976
+ dest.removeListener("close", onclose);
20977
+ dest.removeListener("finish", onfinish);
20978
+ dest.removeListener("drain", ondrain);
20979
+ dest.removeListener("error", onerror);
20980
+ dest.removeListener("unpipe", onunpipe);
20981
+ src.removeListener("end", onend);
20982
+ src.removeListener("end", cleanup);
20983
+ src.removeListener("data", ondata);
20984
+ cleanedUp = true;
20985
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
20986
+ }
20987
+ var increasedAwaitDrain = false;
20988
+ src.on("data", ondata);
20989
+ function ondata(chunk) {
20990
+ debug("ondata");
20991
+ increasedAwaitDrain = false;
20992
+ if (false === dest.write(chunk) && !increasedAwaitDrain) {
20993
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
20994
+ debug("false write response, pause", src._readableState.awaitDrain);
20995
+ src._readableState.awaitDrain++;
20996
+ increasedAwaitDrain = true;
20997
+ }
20998
+ src.pause();
20999
+ }
21000
+ }
21001
+ function onerror(er) {
21002
+ debug("onerror", er);
21003
+ unpipe();
21004
+ dest.removeListener("error", onerror);
21005
+ if (listenerCount(dest, "error") === 0) dest.emit("error", er);
21006
+ }
21007
+ prependListener(dest, "error", onerror);
21008
+ function onclose() {
21009
+ dest.removeListener("finish", onfinish);
21010
+ unpipe();
21011
+ }
21012
+ dest.once("close", onclose);
21013
+ function onfinish() {
21014
+ debug("onfinish");
21015
+ dest.removeListener("close", onclose);
21016
+ unpipe();
21017
+ }
21018
+ dest.once("finish", onfinish);
21019
+ function unpipe() {
21020
+ debug("unpipe");
21021
+ src.unpipe(dest);
21022
+ }
21023
+ dest.emit("pipe", src);
21024
+ if (!state.flowing) {
21025
+ debug("pipe resume");
21026
+ src.resume();
21027
+ }
21028
+ return dest;
21029
+ };
21030
+ function pipeOnDrain(src) {
21031
+ return function() {
21032
+ var state = src._readableState;
21033
+ debug("pipeOnDrain", state.awaitDrain);
21034
+ if (state.awaitDrain) state.awaitDrain--;
21035
+ if (state.awaitDrain === 0 && src.listeners("data").length) {
21036
+ state.flowing = true;
21037
+ flow(src);
21038
+ }
21039
+ };
21040
+ }
21041
+ Readable.prototype.unpipe = function(dest) {
21042
+ var state = this._readableState;
21043
+ if (state.pipesCount === 0) return this;
21044
+ if (state.pipesCount === 1) {
21045
+ if (dest && dest !== state.pipes) return this;
21046
+ if (!dest) dest = state.pipes;
21047
+ state.pipes = null;
21048
+ state.pipesCount = 0;
21049
+ state.flowing = false;
21050
+ if (dest) dest.emit("unpipe", this);
21051
+ return this;
21052
+ }
21053
+ if (!dest) {
21054
+ var dests = state.pipes;
21055
+ var len = state.pipesCount;
21056
+ state.pipes = null;
21057
+ state.pipesCount = 0;
21058
+ state.flowing = false;
21059
+ for (var _i = 0; _i < len; _i++) dests[_i].emit("unpipe", this);
21060
+ return this;
21061
+ }
21062
+ var i = indexOf(state.pipes, dest);
21063
+ if (i === -1) return this;
21064
+ state.pipes.splice(i, 1);
21065
+ state.pipesCount -= 1;
21066
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
21067
+ dest.emit("unpipe", this);
21068
+ return this;
21069
+ };
21070
+ Readable.prototype.on = function(ev, fn) {
21071
+ var res = EventEmitter.prototype.on.call(this, ev, fn);
21072
+ if (ev === "data") {
21073
+ if (this._readableState.flowing !== false) this.resume();
21074
+ } else if (ev === "readable") {
21075
+ var state = this._readableState;
21076
+ if (!state.endEmitted && !state.readableListening) {
21077
+ state.readableListening = state.needReadable = true;
21078
+ state.emittedReadable = false;
21079
+ if (!state.reading) nextTick(nReadingNextTick, this);
21080
+ else if (state.length) emitReadable(this, state);
21081
+ }
21082
+ }
21083
+ return res;
21084
+ };
21085
+ Readable.prototype.addListener = Readable.prototype.on;
21086
+ function nReadingNextTick(self) {
21087
+ debug("readable nexttick read 0");
21088
+ self.read(0);
21089
+ }
21090
+ Readable.prototype.resume = function() {
21091
+ var state = this._readableState;
21092
+ if (!state.flowing) {
21093
+ debug("resume");
21094
+ state.flowing = true;
21095
+ resume(this, state);
21096
+ }
21097
+ return this;
21098
+ };
21099
+ function resume(stream, state) {
21100
+ if (!state.resumeScheduled) {
21101
+ state.resumeScheduled = true;
21102
+ nextTick(resume_, stream, state);
21103
+ }
21104
+ }
21105
+ function resume_(stream, state) {
21106
+ if (!state.reading) {
21107
+ debug("resume read 0");
21108
+ stream.read(0);
21109
+ }
21110
+ state.resumeScheduled = false;
21111
+ state.awaitDrain = 0;
21112
+ stream.emit("resume");
21113
+ flow(stream);
21114
+ if (state.flowing && !state.reading) stream.read(0);
21115
+ }
21116
+ Readable.prototype.pause = function() {
21117
+ debug("call pause flowing=%j", this._readableState.flowing);
21118
+ if (false !== this._readableState.flowing) {
21119
+ debug("pause");
21120
+ this._readableState.flowing = false;
21121
+ this.emit("pause");
21122
+ }
21123
+ return this;
21124
+ };
21125
+ function flow(stream) {
21126
+ var state = stream._readableState;
21127
+ debug("flow", state.flowing);
21128
+ while (state.flowing && stream.read() !== null);
21129
+ }
21130
+ Readable.prototype.wrap = function(stream) {
21131
+ var state = this._readableState;
21132
+ var paused = false;
21133
+ var self = this;
21134
+ stream.on("end", function() {
21135
+ debug("wrapped end");
21136
+ if (state.decoder && !state.ended) {
21137
+ var chunk = state.decoder.end();
21138
+ if (chunk && chunk.length) self.push(chunk);
21139
+ }
21140
+ self.push(null);
21141
+ });
21142
+ stream.on("data", function(chunk) {
21143
+ debug("wrapped data");
21144
+ if (state.decoder) chunk = state.decoder.write(chunk);
21145
+ if (state.objectMode && (chunk === null || chunk === void 0)) return;
21146
+ else if (!state.objectMode && (!chunk || !chunk.length)) return;
21147
+ if (!self.push(chunk)) {
21148
+ paused = true;
21149
+ stream.pause();
21150
+ }
21151
+ });
21152
+ for (var i in stream) if (this[i] === void 0 && typeof stream[i] === "function") this[i] = function(method) {
21153
+ return function() {
21154
+ return stream[method].apply(stream, arguments);
21155
+ };
21156
+ }(i);
21157
+ forEach([
21158
+ "error",
21159
+ "close",
21160
+ "destroy",
21161
+ "pause",
21162
+ "resume"
21163
+ ], function(ev) {
21164
+ stream.on(ev, self.emit.bind(self, ev));
21165
+ });
21166
+ self._read = function(n) {
21167
+ debug("wrapped _read", n);
21168
+ if (paused) {
21169
+ paused = false;
21170
+ stream.resume();
21171
+ }
21172
+ };
21173
+ return self;
21174
+ };
21175
+ Readable._fromList = fromList;
21176
+ function fromList(n, state) {
21177
+ if (state.length === 0) return null;
21178
+ var ret;
21179
+ if (state.objectMode) ret = state.buffer.shift();
21180
+ else if (!n || n >= state.length) {
21181
+ if (state.decoder) ret = state.buffer.join("");
21182
+ else if (state.buffer.length === 1) ret = state.buffer.head.data;
21183
+ else ret = state.buffer.concat(state.length);
21184
+ state.buffer.clear();
21185
+ } else ret = fromListPartial(n, state.buffer, state.decoder);
21186
+ return ret;
21187
+ }
21188
+ function fromListPartial(n, list, hasStrings) {
21189
+ var ret;
21190
+ if (n < list.head.data.length) {
21191
+ ret = list.head.data.slice(0, n);
21192
+ list.head.data = list.head.data.slice(n);
21193
+ } else if (n === list.head.data.length) ret = list.shift();
21194
+ else ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
21195
+ return ret;
21196
+ }
21197
+ function copyFromBufferString(n, list) {
21198
+ var p = list.head;
21199
+ var c = 1;
21200
+ var ret = p.data;
21201
+ n -= ret.length;
21202
+ while (p = p.next) {
21203
+ var str = p.data;
21204
+ var nb = n > str.length ? str.length : n;
21205
+ if (nb === str.length) ret += str;
21206
+ else ret += str.slice(0, n);
21207
+ n -= nb;
21208
+ if (n === 0) {
21209
+ if (nb === str.length) {
21210
+ ++c;
21211
+ if (p.next) list.head = p.next;
21212
+ else list.head = list.tail = null;
21213
+ } else {
21214
+ list.head = p;
21215
+ p.data = str.slice(nb);
21216
+ }
21217
+ break;
21218
+ }
21219
+ ++c;
21220
+ }
21221
+ list.length -= c;
21222
+ return ret;
21223
+ }
21224
+ function copyFromBuffer(n, list) {
21225
+ var ret = Buffer.allocUnsafe(n);
21226
+ var p = list.head;
21227
+ var c = 1;
21228
+ p.data.copy(ret);
21229
+ n -= p.data.length;
21230
+ while (p = p.next) {
21231
+ var buf = p.data;
21232
+ var nb = n > buf.length ? buf.length : n;
21233
+ buf.copy(ret, ret.length - n, 0, nb);
21234
+ n -= nb;
21235
+ if (n === 0) {
21236
+ if (nb === buf.length) {
21237
+ ++c;
21238
+ if (p.next) list.head = p.next;
21239
+ else list.head = list.tail = null;
21240
+ } else {
21241
+ list.head = p;
21242
+ p.data = buf.slice(nb);
21243
+ }
21244
+ break;
21245
+ }
21246
+ ++c;
21247
+ }
21248
+ list.length -= c;
21249
+ return ret;
21250
+ }
21251
+ function endReadable(stream) {
21252
+ var state = stream._readableState;
21253
+ if (state.length > 0) throw new Error("\"endReadable()\" called on non-empty stream");
21254
+ if (!state.endEmitted) {
21255
+ state.ended = true;
21256
+ nextTick(endReadableNT, state, stream);
21257
+ }
21258
+ }
21259
+ function endReadableNT(state, stream) {
21260
+ if (!state.endEmitted && state.length === 0) {
21261
+ state.endEmitted = true;
21262
+ stream.readable = false;
21263
+ stream.emit("end");
21264
+ }
21265
+ }
21266
+ function forEach(xs, f) {
21267
+ for (var i = 0, l = xs.length; i < l; i++) f(xs[i], i);
21268
+ }
21269
+ function indexOf(xs, x) {
21270
+ for (var i = 0, l = xs.length; i < l; i++) if (xs[i] === x) return i;
21271
+ return -1;
21272
+ }
21273
+ //#endregion
21274
+ //#region \0polyfill-node._stream_writable.js
21275
+ Writable.WritableState = WritableState;
21276
+ _polyfill_node__inherits_default(Writable, EventEmitter);
21277
+ function nop() {}
21278
+ function WriteReq(chunk, encoding, cb) {
21279
+ this.chunk = chunk;
21280
+ this.encoding = encoding;
21281
+ this.callback = cb;
21282
+ this.next = null;
21283
+ }
21284
+ function WritableState(options, stream) {
21285
+ Object.defineProperty(this, "buffer", { get: deprecate(function() {
21286
+ return this.getBuffer();
21287
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.") });
21288
+ options = options || {};
21289
+ this.objectMode = !!options.objectMode;
21290
+ if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
21291
+ var hwm = options.highWaterMark;
21292
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
21293
+ this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;
21294
+ this.highWaterMark = ~~this.highWaterMark;
21295
+ this.needDrain = false;
21296
+ this.ending = false;
21297
+ this.ended = false;
21298
+ this.finished = false;
21299
+ this.decodeStrings = !(options.decodeStrings === false);
21300
+ this.defaultEncoding = options.defaultEncoding || "utf8";
21301
+ this.length = 0;
21302
+ this.writing = false;
21303
+ this.corked = 0;
21304
+ this.sync = true;
21305
+ this.bufferProcessing = false;
21306
+ this.onwrite = function(er) {
21307
+ onwrite(stream, er);
21308
+ };
21309
+ this.writecb = null;
21310
+ this.writelen = 0;
21311
+ this.bufferedRequest = null;
21312
+ this.lastBufferedRequest = null;
21313
+ this.pendingcb = 0;
21314
+ this.prefinished = false;
21315
+ this.errorEmitted = false;
21316
+ this.bufferedRequestCount = 0;
21317
+ this.corkedRequestsFree = new CorkedRequest(this);
21318
+ }
21319
+ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
21320
+ var current = this.bufferedRequest;
21321
+ var out = [];
21322
+ while (current) {
21323
+ out.push(current);
21324
+ current = current.next;
21325
+ }
21326
+ return out;
21327
+ };
21328
+ function Writable(options) {
21329
+ if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options);
21330
+ this._writableState = new WritableState(options, this);
21331
+ this.writable = true;
21332
+ if (options) {
21333
+ if (typeof options.write === "function") this._write = options.write;
21334
+ if (typeof options.writev === "function") this._writev = options.writev;
21335
+ }
21336
+ EventEmitter.call(this);
21337
+ }
21338
+ Writable.prototype.pipe = function() {
21339
+ this.emit("error", /* @__PURE__ */ new Error("Cannot pipe, not readable"));
21340
+ };
21341
+ function writeAfterEnd(stream, cb) {
21342
+ var er = /* @__PURE__ */ new Error("write after end");
21343
+ stream.emit("error", er);
21344
+ nextTick(cb, er);
21345
+ }
21346
+ function validChunk(stream, state, chunk, cb) {
21347
+ var valid = true;
21348
+ var er = false;
21349
+ if (chunk === null) er = /* @__PURE__ */ new TypeError("May not write null values to stream");
21350
+ else if (!Buffer.isBuffer(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
21351
+ if (er) {
21352
+ stream.emit("error", er);
21353
+ nextTick(cb, er);
21354
+ valid = false;
21355
+ }
21356
+ return valid;
21357
+ }
21358
+ Writable.prototype.write = function(chunk, encoding, cb) {
21359
+ var state = this._writableState;
21360
+ var ret = false;
21361
+ if (typeof encoding === "function") {
21362
+ cb = encoding;
21363
+ encoding = null;
21364
+ }
21365
+ if (Buffer.isBuffer(chunk)) encoding = "buffer";
21366
+ else if (!encoding) encoding = state.defaultEncoding;
21367
+ if (typeof cb !== "function") cb = nop;
21368
+ if (state.ended) writeAfterEnd(this, cb);
21369
+ else if (validChunk(this, state, chunk, cb)) {
21370
+ state.pendingcb++;
21371
+ ret = writeOrBuffer(this, state, chunk, encoding, cb);
21372
+ }
21373
+ return ret;
21374
+ };
21375
+ Writable.prototype.cork = function() {
21376
+ var state = this._writableState;
21377
+ state.corked++;
21378
+ };
21379
+ Writable.prototype.uncork = function() {
21380
+ var state = this._writableState;
21381
+ if (state.corked) {
21382
+ state.corked--;
21383
+ if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
21384
+ }
21385
+ };
21386
+ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
21387
+ if (typeof encoding === "string") encoding = encoding.toLowerCase();
21388
+ if (!([
21389
+ "hex",
21390
+ "utf8",
21391
+ "utf-8",
21392
+ "ascii",
21393
+ "binary",
21394
+ "base64",
21395
+ "ucs2",
21396
+ "ucs-2",
21397
+ "utf16le",
21398
+ "utf-16le",
21399
+ "raw"
21400
+ ].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
21401
+ this._writableState.defaultEncoding = encoding;
21402
+ return this;
21403
+ };
21404
+ function decodeChunk(state, chunk, encoding) {
21405
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = Buffer.from(chunk, encoding);
21406
+ return chunk;
21407
+ }
21408
+ function writeOrBuffer(stream, state, chunk, encoding, cb) {
21409
+ chunk = decodeChunk(state, chunk, encoding);
21410
+ if (Buffer.isBuffer(chunk)) encoding = "buffer";
21411
+ var len = state.objectMode ? 1 : chunk.length;
21412
+ state.length += len;
21413
+ var ret = state.length < state.highWaterMark;
21414
+ if (!ret) state.needDrain = true;
21415
+ if (state.writing || state.corked) {
21416
+ var last = state.lastBufferedRequest;
21417
+ state.lastBufferedRequest = new WriteReq(chunk, encoding, cb);
21418
+ if (last) last.next = state.lastBufferedRequest;
21419
+ else state.bufferedRequest = state.lastBufferedRequest;
21420
+ state.bufferedRequestCount += 1;
21421
+ } else doWrite(stream, state, false, len, chunk, encoding, cb);
21422
+ return ret;
21423
+ }
21424
+ function doWrite(stream, state, writev, len, chunk, encoding, cb) {
21425
+ state.writelen = len;
21426
+ state.writecb = cb;
21427
+ state.writing = true;
21428
+ state.sync = true;
21429
+ if (writev) stream._writev(chunk, state.onwrite);
21430
+ else stream._write(chunk, encoding, state.onwrite);
21431
+ state.sync = false;
21432
+ }
21433
+ function onwriteError(stream, state, sync, er, cb) {
21434
+ --state.pendingcb;
21435
+ if (sync) nextTick(cb, er);
21436
+ else cb(er);
21437
+ stream._writableState.errorEmitted = true;
21438
+ stream.emit("error", er);
21439
+ }
21440
+ function onwriteStateUpdate(state) {
21441
+ state.writing = false;
21442
+ state.writecb = null;
21443
+ state.length -= state.writelen;
21444
+ state.writelen = 0;
21445
+ }
21446
+ function onwrite(stream, er) {
21447
+ var state = stream._writableState;
21448
+ var sync = state.sync;
21449
+ var cb = state.writecb;
21450
+ onwriteStateUpdate(state);
21451
+ if (er) onwriteError(stream, state, sync, er, cb);
21452
+ else {
21453
+ var finished = needFinish(state);
21454
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(stream, state);
21455
+ if (sync) nextTick(afterWrite, stream, state, finished, cb);
21456
+ else afterWrite(stream, state, finished, cb);
21457
+ }
21458
+ }
21459
+ function afterWrite(stream, state, finished, cb) {
21460
+ if (!finished) onwriteDrain(stream, state);
21461
+ state.pendingcb--;
21462
+ cb();
21463
+ finishMaybe(stream, state);
21464
+ }
21465
+ function onwriteDrain(stream, state) {
21466
+ if (state.length === 0 && state.needDrain) {
21467
+ state.needDrain = false;
21468
+ stream.emit("drain");
21469
+ }
21470
+ }
21471
+ function clearBuffer(stream, state) {
21472
+ state.bufferProcessing = true;
21473
+ var entry = state.bufferedRequest;
21474
+ if (stream._writev && entry && entry.next) {
21475
+ var l = state.bufferedRequestCount;
21476
+ var buffer = new Array(l);
21477
+ var holder = state.corkedRequestsFree;
21478
+ holder.entry = entry;
21479
+ var count = 0;
21480
+ while (entry) {
21481
+ buffer[count] = entry;
21482
+ entry = entry.next;
21483
+ count += 1;
21484
+ }
21485
+ doWrite(stream, state, true, state.length, buffer, "", holder.finish);
21486
+ state.pendingcb++;
21487
+ state.lastBufferedRequest = null;
21488
+ if (holder.next) {
21489
+ state.corkedRequestsFree = holder.next;
21490
+ holder.next = null;
21491
+ } else state.corkedRequestsFree = new CorkedRequest(state);
21492
+ } else {
21493
+ while (entry) {
21494
+ var chunk = entry.chunk;
21495
+ var encoding = entry.encoding;
21496
+ var cb = entry.callback;
21497
+ doWrite(stream, state, false, state.objectMode ? 1 : chunk.length, chunk, encoding, cb);
21498
+ entry = entry.next;
21499
+ if (state.writing) break;
21500
+ }
21501
+ if (entry === null) state.lastBufferedRequest = null;
21502
+ }
21503
+ state.bufferedRequestCount = 0;
21504
+ state.bufferedRequest = entry;
21505
+ state.bufferProcessing = false;
21506
+ }
21507
+ Writable.prototype._write = function(chunk, encoding, cb) {
21508
+ cb(/* @__PURE__ */ new Error("not implemented"));
21509
+ };
21510
+ Writable.prototype._writev = null;
21511
+ Writable.prototype.end = function(chunk, encoding, cb) {
21512
+ var state = this._writableState;
21513
+ if (typeof chunk === "function") {
21514
+ cb = chunk;
21515
+ chunk = null;
21516
+ encoding = null;
21517
+ } else if (typeof encoding === "function") {
21518
+ cb = encoding;
21519
+ encoding = null;
21520
+ }
21521
+ if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
21522
+ if (state.corked) {
21523
+ state.corked = 1;
21524
+ this.uncork();
21525
+ }
21526
+ if (!state.ending && !state.finished) endWritable(this, state, cb);
21527
+ };
21528
+ function needFinish(state) {
21529
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
21530
+ }
21531
+ function prefinish(stream, state) {
21532
+ if (!state.prefinished) {
21533
+ state.prefinished = true;
21534
+ stream.emit("prefinish");
21535
+ }
21536
+ }
21537
+ function finishMaybe(stream, state) {
21538
+ var need = needFinish(state);
21539
+ if (need) if (state.pendingcb === 0) {
21540
+ prefinish(stream, state);
21541
+ state.finished = true;
21542
+ stream.emit("finish");
21543
+ } else prefinish(stream, state);
21544
+ return need;
21545
+ }
21546
+ function endWritable(stream, state, cb) {
21547
+ state.ending = true;
21548
+ finishMaybe(stream, state);
21549
+ if (cb) if (state.finished) nextTick(cb);
21550
+ else stream.once("finish", cb);
21551
+ state.ended = true;
21552
+ stream.writable = false;
21553
+ }
21554
+ function CorkedRequest(state) {
21555
+ var _this = this;
21556
+ this.next = null;
21557
+ this.entry = null;
21558
+ this.finish = function(err) {
21559
+ var entry = _this.entry;
21560
+ _this.entry = null;
21561
+ while (entry) {
21562
+ var cb = entry.callback;
21563
+ state.pendingcb--;
21564
+ cb(err);
21565
+ entry = entry.next;
21566
+ }
21567
+ if (state.corkedRequestsFree) state.corkedRequestsFree.next = _this;
21568
+ else state.corkedRequestsFree = _this;
21569
+ };
21570
+ }
21571
+ //#endregion
21572
+ //#region \0polyfill-node._stream_duplex.js
21573
+ _polyfill_node__inherits_default(Duplex, Readable);
21574
+ var keys = Object.keys(Writable.prototype);
21575
+ for (var v = 0; v < keys.length; v++) {
21576
+ var method = keys[v];
21577
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
21578
+ }
21579
+ function Duplex(options) {
21580
+ if (!(this instanceof Duplex)) return new Duplex(options);
21581
+ Readable.call(this, options);
21582
+ Writable.call(this, options);
21583
+ if (options && options.readable === false) this.readable = false;
21584
+ if (options && options.writable === false) this.writable = false;
21585
+ this.allowHalfOpen = true;
21586
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
21587
+ this.once("end", onend);
21588
+ }
21589
+ function onend() {
21590
+ if (this.allowHalfOpen || this._writableState.ended) return;
21591
+ nextTick(onEndNT, this);
21592
+ }
21593
+ function onEndNT(self) {
21594
+ self.end();
21595
+ }
21596
+ //#endregion
21597
+ //#region src/util/output-type.ts
21598
+ /**
21599
+ * Output type definitions for document generation.
21600
+ *
21601
+ * This module defines the various output formats supported when generating
21602
+ * .docx files. These types correspond to fflate's output formats.
21603
+ *
21604
+ * @module
21605
+ */
21606
+ /**
21607
+ * Converts a Uint8Array to the specified output type.
21608
+ *
21609
+ * This is used by both the Packer and patchDocument to convert fflate's
21610
+ * raw Uint8Array output into the user's requested format.
21611
+ */
21612
+ const convertOutput = (data, type) => {
21613
+ switch (type) {
21614
+ case "nodebuffer": return Buffer.from(data);
21615
+ case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
21616
+ case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
21617
+ case "uint8array": return data;
21618
+ case "base64": return btoa(strFromU8(data, true));
21619
+ case "string":
21620
+ case "text":
21621
+ case "binarystring": return strFromU8(data, true);
21622
+ case "array": return [...data];
21623
+ default: return data;
21624
+ }
21625
+ };
21626
+ //#endregion
21627
+ //#region src/file/fonts/obfuscate-ttf-to-odttf.ts
21628
+ /**
21629
+ * Font obfuscation module for embedding fonts in WordprocessingML documents.
21630
+ *
21631
+ * This module implements the OOXML font obfuscation algorithm used to embed
21632
+ * fonts in DOCX documents. Obfuscation is required by the OOXML specification
21633
+ * to prevent simple extraction of embedded font files.
21634
+ *
21635
+ * Reference: ECMA-376 Part 2, Section 11.1 (Font Embedding)
21636
+ *
21637
+ * @module
18304
21638
  */
18305
21639
  /** Start offset for obfuscation in the font file */
18306
21640
  const obfuscatedStartOffset = 0;
@@ -18500,13 +21834,12 @@ var Compiler = class {
18500
21834
  const footerFormattedViews = /* @__PURE__ */ new Map();
18501
21835
  const xmlifiedFileMapping = this.xmlifyFile(file, headerFormattedViews, footerFormattedViews, prettifyXml);
18502
21836
  const map = new Map(Object.entries(xmlifiedFileMapping));
18503
- for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = encodeUtf8(subFile.data);
18504
- else files[obj.path] = encodeUtf8(obj.data);
18505
- for (const subFile of overrides) files[subFile.path] = encodeUtf8(subFile.data);
18506
- for (const mediaData of file.Media.Array) if (mediaData.type !== "svg") files[`word/media/${mediaData.fileName}`] = [toUint8Array(mediaData.data), { level: 0 }];
18507
- else {
21837
+ for (const [, obj] of map) if (Array.isArray(obj)) for (const subFile of obj) files[subFile.path] = textToUint8Array(subFile.data);
21838
+ else files[obj.path] = textToUint8Array(obj.data);
21839
+ for (const subFile of overrides) files[subFile.path] = textToUint8Array(subFile.data);
21840
+ for (const mediaData of file.Media.Array) {
18508
21841
  files[`word/media/${mediaData.fileName}`] = [toUint8Array(mediaData.data), { level: 0 }];
18509
- files[`word/media/${mediaData.fallback.fileName}`] = [toUint8Array(mediaData.fallback.data), { level: 0 }];
21842
+ if (mediaData.type === "svg") files[`word/media/${mediaData.fallback.fileName}`] = [toUint8Array(mediaData.fallback.data), { level: 0 }];
18510
21843
  }
18511
21844
  for (const { data: buffer, name, fontKey } of file.FontTable.fontOptionsWithKey) {
18512
21845
  const [nameWithoutExtension] = name.split(".");
@@ -18859,32 +22192,6 @@ var Compiler = class {
18859
22192
  }
18860
22193
  };
18861
22194
  //#endregion
18862
- //#region \0@oxc-project+runtime@0.123.0/helpers/asyncToGenerator.js
18863
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
18864
- try {
18865
- var i = n[a](c), u = i.value;
18866
- } catch (n) {
18867
- e(n);
18868
- return;
18869
- }
18870
- i.done ? t(u) : Promise.resolve(u).then(r, o);
18871
- }
18872
- function _asyncToGenerator(n) {
18873
- return function() {
18874
- var t = this, e = arguments;
18875
- return new Promise(function(r, o) {
18876
- var a = n.apply(t, e);
18877
- function _next(n) {
18878
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
18879
- }
18880
- function _throw(n) {
18881
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
18882
- }
18883
- _next(void 0);
18884
- });
18885
- };
18886
- }
18887
- //#endregion
18888
22195
  //#region src/export/packer/packer.ts
18889
22196
  /**
18890
22197
  * Packer module for exporting documents to various output formats.
@@ -18937,11 +22244,8 @@ var Packer = class Packer {
18937
22244
  * @param overrides - Optional array of file overrides for custom XML content
18938
22245
  * @returns A promise resolving to the exported document in the specified format
18939
22246
  */
18940
- static pack(_x, _x2, _x3) {
18941
- var _this = this;
18942
- return _asyncToGenerator(function* (file, type, prettify, overrides = []) {
18943
- return convertOutput(zipSync(_this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
18944
- }).apply(this, arguments);
22247
+ static async pack(file, type, prettify, overrides = []) {
22248
+ return convertOutput(zipSync(this.compiler.compile(file, convertPrettifyType(prettify), overrides), { level: 6 }), type);
18945
22249
  }
18946
22250
  /**
18947
22251
  * Exports a document to a string representation.
@@ -19017,14 +22321,18 @@ var Packer = class Packer {
19017
22321
  * ```
19018
22322
  */
19019
22323
  static toStream(file, prettify, overrides = []) {
22324
+ /* v8 ignore start */
19020
22325
  const stream = new Readable({ read() {} });
22326
+ /* v8 ignore stop */
19021
22327
  try {
19022
22328
  const files = this.compiler.compile(file, convertPrettifyType(prettify), overrides);
19023
22329
  const zip = new Zip((err, chunk, final) => {
22330
+ /* v8 ignore start */
19024
22331
  if (err) {
19025
22332
  stream.destroy(err);
19026
22333
  return;
19027
22334
  }
22335
+ /* v8 ignore stop */
19028
22336
  if (!stream.destroyed) stream.push(chunk);
19029
22337
  if (final) stream.push(null);
19030
22338
  });
@@ -19109,7 +22417,10 @@ const createTextElementContents = (text) => {
19109
22417
  * // Adds xml:space="preserve" to maintain whitespace
19110
22418
  * ```
19111
22419
  */
19112
- const patchSpaceAttribute = (element) => _objectSpread2(_objectSpread2({}, element), {}, { attributes: { "xml:space": "preserve" } });
22420
+ const patchSpaceAttribute = (element) => ({
22421
+ ...element,
22422
+ attributes: { "xml:space": "preserve" }
22423
+ });
19113
22424
  /**
19114
22425
  * Retrieves first-level child elements by parent element name.
19115
22426
  *
@@ -19301,14 +22612,24 @@ const splitRunElement = (runElement, token) => {
19301
22612
  if (e.type === "element" && e.name === "w:t") {
19302
22613
  var _ref, _e$elements;
19303
22614
  const splitText = ((_ref = (_e$elements = e.elements) === null || _e$elements === void 0 || (_e$elements = _e$elements[0]) === null || _e$elements === void 0 ? void 0 : _e$elements.text) !== null && _ref !== void 0 ? _ref : "").split(token);
19304
- const newElements = splitText.map((t) => _objectSpread2(_objectSpread2(_objectSpread2({}, e), patchSpaceAttribute(e)), {}, { elements: createTextElementContents(t) }));
22615
+ const newElements = splitText.map((t) => ({
22616
+ ...e,
22617
+ ...patchSpaceAttribute(e),
22618
+ elements: createTextElementContents(t)
22619
+ }));
19305
22620
  if (splitText.length > 1) splitIndex = i;
19306
22621
  return newElements;
19307
22622
  } else return e;
19308
22623
  }).flat()) !== null && _runElement$elements$ !== void 0 ? _runElement$elements$ : [];
19309
22624
  return {
19310
- left: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(runElement))), {}, { elements: splitElements.slice(0, splitIndex + 1) }),
19311
- right: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(runElement))), {}, { elements: splitElements.slice(splitIndex + 1) })
22625
+ left: {
22626
+ ...JSON.parse(JSON.stringify(runElement)),
22627
+ elements: splitElements.slice(0, splitIndex + 1)
22628
+ },
22629
+ right: {
22630
+ ...JSON.parse(JSON.stringify(runElement)),
22631
+ elements: splitElements.slice(splitIndex + 1)
22632
+ }
19312
22633
  };
19313
22634
  };
19314
22635
  //#endregion
@@ -19568,9 +22889,15 @@ const replacer = ({ json, patch, patchText, context, keepOriginalStyles = true }
19568
22889
  const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === "w:rPr");
19569
22890
  newRunElements = textJson.map((e) => {
19570
22891
  var _e$elements;
19571
- return _objectSpread2(_objectSpread2({}, e), {}, { elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []] });
22892
+ return {
22893
+ ...e,
22894
+ elements: [...runElementNonTextualElements, ...(_e$elements = e.elements) !== null && _e$elements !== void 0 ? _e$elements : []]
22895
+ };
19572
22896
  });
19573
- patchedRightElement = _objectSpread2(_objectSpread2({}, right), {}, { elements: [...runElementNonTextualElements, ...right.elements] });
22897
+ patchedRightElement = {
22898
+ ...right,
22899
+ elements: [...runElementNonTextualElements, ...right.elements]
22900
+ };
19574
22901
  }
19575
22902
  paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
19576
22903
  break;
@@ -19656,69 +22983,70 @@ const compareByteArrays = (a, b) => {
19656
22983
  *
19657
22984
  * @publicApi
19658
22985
  */
19659
- const patchDocument = function() {
19660
- var _ref = _asyncToGenerator(function* ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
19661
- end: "}}",
19662
- start: "{{"
19663
- }, recursive = true }) {
19664
- const zipContent = unzipSync(toUint8Array(data));
19665
- const contexts = /* @__PURE__ */ new Map();
19666
- const file = { Media: new Media() };
19667
- const map = /* @__PURE__ */ new Map();
19668
- const imageRelationshipAdditions = [];
19669
- const hyperlinkRelationshipAdditions = [];
19670
- let hasMedia = false;
19671
- const binaryContentMap = /* @__PURE__ */ new Map();
19672
- for (const [key, value] of Object.entries(zipContent)) {
19673
- const startBytes = value.slice(0, 2);
19674
- if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
19675
- binaryContentMap.set(key, value);
19676
- continue;
19677
- }
19678
- if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
19679
- binaryContentMap.set(key, value);
19680
- continue;
19681
- }
19682
- const json = toJson(strFromU8(value));
19683
- if (key === "word/document.xml") {
19684
- var _json$elements;
19685
- const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
19686
- if (document && document.attributes) {
19687
- for (const ns of [
19688
- "mc",
19689
- "wp",
19690
- "r",
19691
- "w15",
19692
- "m"
19693
- ]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
19694
- document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
19695
- }
22986
+ const patchDocument = async ({ outputType, data, patches, keepOriginalStyles, placeholderDelimiters = {
22987
+ end: "}}",
22988
+ start: "{{"
22989
+ }, recursive = true }) => {
22990
+ const zipContent = unzipSync(toUint8Array(data));
22991
+ const contexts = /* @__PURE__ */ new Map();
22992
+ const file = { Media: new Media() };
22993
+ const map = /* @__PURE__ */ new Map();
22994
+ const imageRelationshipAdditions = [];
22995
+ const hyperlinkRelationshipAdditions = [];
22996
+ let hasMedia = false;
22997
+ const binaryContentMap = /* @__PURE__ */ new Map();
22998
+ for (const [key, value] of Object.entries(zipContent)) {
22999
+ const startBytes = value.slice(0, 2);
23000
+ if (compareByteArrays(startBytes, UTF16LE) || compareByteArrays(startBytes, UTF16BE)) {
23001
+ binaryContentMap.set(key, value);
23002
+ continue;
23003
+ }
23004
+ if (!key.endsWith(".xml") && !key.endsWith(".rels")) {
23005
+ binaryContentMap.set(key, value);
23006
+ continue;
23007
+ }
23008
+ const json = toJson(strFromU8(value));
23009
+ if (key === "word/document.xml") {
23010
+ var _json$elements;
23011
+ const document = (_json$elements = json.elements) === null || _json$elements === void 0 ? void 0 : _json$elements.find((i) => i.name === "w:document");
23012
+ if (document && document.attributes) {
23013
+ for (const ns of [
23014
+ "mc",
23015
+ "wp",
23016
+ "r",
23017
+ "w15",
23018
+ "m"
23019
+ ]) document.attributes[`xmlns:${ns}`] = DocumentAttributeNamespaces[ns];
23020
+ document.attributes["mc:Ignorable"] = `${document.attributes["mc:Ignorable"] || ""} w15`.trim();
19696
23021
  }
19697
- if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
19698
- const context = {
19699
- file,
19700
- stack: [],
19701
- viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
19702
- hyperlinkRelationshipAdditions.push({
19703
- hyperlink: {
19704
- id: linkId,
19705
- link: target
19706
- },
19707
- key
19708
- });
19709
- } } }
19710
- };
19711
- contexts.set(key, context);
19712
- if (!(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.start.trim()) || !(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.end.trim())) throw new Error("Both start and end delimiters must be non-empty strings.");
19713
- const { start, end } = placeholderDelimiters;
19714
- for (const [patchKey, patchValue] of Object.entries(patches)) {
19715
- const patchText = `${start}${patchKey}${end}`;
19716
- while (true) {
19717
- const { didFindOccurrence } = replacer({
19718
- context,
19719
- json,
19720
- keepOriginalStyles,
19721
- patch: _objectSpread2(_objectSpread2({}, patchValue), {}, { children: patchValue.children.map((element) => {
23022
+ }
23023
+ if (key.startsWith("word/") && !key.endsWith(".xml.rels")) {
23024
+ const context = {
23025
+ file,
23026
+ stack: [],
23027
+ viewWrapper: { Relationships: { addRelationship: (linkId, _, target, __) => {
23028
+ hyperlinkRelationshipAdditions.push({
23029
+ hyperlink: {
23030
+ id: linkId,
23031
+ link: target
23032
+ },
23033
+ key
23034
+ });
23035
+ } } }
23036
+ };
23037
+ contexts.set(key, context);
23038
+ if (!(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.start.trim()) || !(placeholderDelimiters === null || placeholderDelimiters === void 0 ? void 0 : placeholderDelimiters.end.trim())) throw new Error("Both start and end delimiters must be non-empty strings.");
23039
+ const { start, end } = placeholderDelimiters;
23040
+ for (const [patchKey, patchValue] of Object.entries(patches)) {
23041
+ const patchText = `${start}${patchKey}${end}`;
23042
+ while (true) {
23043
+ const { didFindOccurrence } = replacer({
23044
+ context,
23045
+ json,
23046
+ keepOriginalStyles,
23047
+ patch: {
23048
+ ...patchValue,
23049
+ children: patchValue.children.map((element) => {
19722
23050
  if (element instanceof ExternalHyperlink) {
19723
23051
  const concreteHyperlink = new ConcreteHyperlink(element.options.children, uniqueId());
19724
23052
  hyperlinkRelationshipAdditions.push({
@@ -19730,63 +23058,60 @@ const patchDocument = function() {
19730
23058
  });
19731
23059
  return concreteHyperlink;
19732
23060
  } else return element;
19733
- }) }),
19734
- patchText
19735
- });
19736
- if (!recursive || !didFindOccurrence) break;
19737
- }
19738
- }
19739
- const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
19740
- if (mediaDatas.length > 0) {
19741
- hasMedia = true;
19742
- imageRelationshipAdditions.push({
19743
- key,
19744
- mediaDatas
23061
+ })
23062
+ },
23063
+ patchText
19745
23064
  });
23065
+ if (!recursive || !didFindOccurrence) break;
19746
23066
  }
19747
23067
  }
19748
- map.set(key, json);
19749
- }
19750
- for (const { key, mediaDatas } of imageRelationshipAdditions) {
19751
- var _map$get;
19752
- const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
19753
- const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
19754
- map.set(relationshipKey, relationshipsJson);
19755
- const index = getNextRelationshipIndex(relationshipsJson);
19756
- const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
19757
- map.set(key, JSON.parse(newJson));
19758
- for (let i = 0; i < mediaDatas.length; i++) {
19759
- const { fileName } = mediaDatas[i];
19760
- appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
23068
+ const mediaDatas = imageReplacer.getMediaData(JSON.stringify(json), context.file.Media);
23069
+ if (mediaDatas.length > 0) {
23070
+ hasMedia = true;
23071
+ imageRelationshipAdditions.push({
23072
+ key,
23073
+ mediaDatas
23074
+ });
19761
23075
  }
19762
23076
  }
19763
- for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
19764
- var _map$get2;
19765
- const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
19766
- const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
19767
- map.set(relationshipKey, relationshipsJson);
19768
- appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
19769
- }
19770
- if (hasMedia) {
19771
- const contentTypesJson = map.get("[Content_Types].xml");
19772
- if (!contentTypesJson) throw new Error("Could not find content types file");
19773
- appendContentType(contentTypesJson, "image/png", "png");
19774
- appendContentType(contentTypesJson, "image/jpeg", "jpeg");
19775
- appendContentType(contentTypesJson, "image/jpeg", "jpg");
19776
- appendContentType(contentTypesJson, "image/bmp", "bmp");
19777
- appendContentType(contentTypesJson, "image/gif", "gif");
19778
- appendContentType(contentTypesJson, "image/svg+xml", "svg");
23077
+ map.set(key, json);
23078
+ }
23079
+ for (const { key, mediaDatas } of imageRelationshipAdditions) {
23080
+ var _map$get;
23081
+ const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
23082
+ const relationshipsJson = (_map$get = map.get(relationshipKey)) !== null && _map$get !== void 0 ? _map$get : createRelationshipFile();
23083
+ map.set(relationshipKey, relationshipsJson);
23084
+ const index = getNextRelationshipIndex(relationshipsJson);
23085
+ const newJson = imageReplacer.replace(JSON.stringify(map.get(key)), mediaDatas, index);
23086
+ map.set(key, JSON.parse(newJson));
23087
+ for (let i = 0; i < mediaDatas.length; i++) {
23088
+ const { fileName } = mediaDatas[i];
23089
+ appendRelationship(relationshipsJson, index + i, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", `media/${fileName}`);
19779
23090
  }
19780
- const files = {};
19781
- for (const [key, value] of map) files[key] = textToUint8Array(toXml(value));
19782
- for (const [key, value] of binaryContentMap) files[key] = value;
19783
- for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
19784
- return convertOutput(zipSync(files, { level: 6 }), outputType);
19785
- });
19786
- return function patchDocument(_x) {
19787
- return _ref.apply(this, arguments);
19788
- };
19789
- }();
23091
+ }
23092
+ for (const { key, hyperlink } of hyperlinkRelationshipAdditions) {
23093
+ var _map$get2;
23094
+ const relationshipKey = `word/_rels/${key.split("/").pop()}.rels`;
23095
+ const relationshipsJson = (_map$get2 = map.get(relationshipKey)) !== null && _map$get2 !== void 0 ? _map$get2 : createRelationshipFile();
23096
+ map.set(relationshipKey, relationshipsJson);
23097
+ appendRelationship(relationshipsJson, hyperlink.id, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", hyperlink.link, TargetModeType.EXTERNAL);
23098
+ }
23099
+ if (hasMedia) {
23100
+ const contentTypesJson = map.get("[Content_Types].xml");
23101
+ if (!contentTypesJson) throw new Error("Could not find content types file");
23102
+ appendContentType(contentTypesJson, "image/png", "png");
23103
+ appendContentType(contentTypesJson, "image/jpeg", "jpeg");
23104
+ appendContentType(contentTypesJson, "image/jpeg", "jpg");
23105
+ appendContentType(contentTypesJson, "image/bmp", "bmp");
23106
+ appendContentType(contentTypesJson, "image/gif", "gif");
23107
+ appendContentType(contentTypesJson, "image/svg+xml", "svg");
23108
+ }
23109
+ const files = {};
23110
+ for (const [key, value] of map) files[key] = textToUint8Array(toXml(value));
23111
+ for (const [key, value] of binaryContentMap) files[key] = value;
23112
+ for (const { data: mediaData, fileName } of file.Media.Array) files[`word/media/${fileName}`] = mediaData instanceof Uint8Array ? mediaData : new Uint8Array(mediaData);
23113
+ return convertOutput(zipSync(files, { level: 6 }), outputType);
23114
+ };
19790
23115
  const toXml = (jsonObj) => {
19791
23116
  return js2xml(jsonObj, { attributeValueFn: (str) => String(str).replace(/&(?!amp;|lt;|gt;|quot;|apos;)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;") });
19792
23117
  };
@@ -19835,20 +23160,15 @@ const createRelationshipFile = () => ({
19835
23160
  * });
19836
23161
  * ```
19837
23162
  */
19838
- const patchDetector = function() {
19839
- var _ref = _asyncToGenerator(function* ({ data }) {
19840
- const zipContent = unzipSync(toUint8Array(data));
19841
- const patches = /* @__PURE__ */ new Set();
19842
- for (const [key, value] of Object.entries(zipContent)) {
19843
- if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
19844
- if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson(strFromU8(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
19845
- }
19846
- return [...patches];
19847
- });
19848
- return function patchDetector(_x) {
19849
- return _ref.apply(this, arguments);
19850
- };
19851
- }();
23163
+ const patchDetector = async ({ data }) => {
23164
+ const zipContent = unzipSync(toUint8Array(data));
23165
+ const patches = /* @__PURE__ */ new Set();
23166
+ for (const [key, value] of Object.entries(zipContent)) {
23167
+ if (!key.endsWith(".xml") && !key.endsWith(".rels")) continue;
23168
+ if (key.startsWith("word/") && !key.endsWith(".xml.rels")) traverse(toJson(strFromU8(value))).forEach((p) => findPatchKeys(p.text).forEach((patch) => patches.add(patch)));
23169
+ }
23170
+ return [...patches];
23171
+ };
19852
23172
  /**
19853
23173
  * Extracts placeholder keys from text using regex pattern.
19854
23174
  *
@@ -19857,8 +23177,7 @@ const patchDetector = function() {
19857
23177
  */
19858
23178
  const findPatchKeys = (text) => {
19859
23179
  var _text$match;
19860
- const pattern = /* @__PURE__ */ new RegExp("(?<=\\{\\{).+?(?=\\}\\})", "gs");
19861
- return (_text$match = text.match(pattern)) !== null && _text$match !== void 0 ? _text$match : [];
23180
+ return (_text$match = text.match(/(?<=\{\{).+?(?=\}\})/gs)) !== null && _text$match !== void 0 ? _text$match : [];
19862
23181
  };
19863
23182
  //#endregion
19864
- export { AbstractNumbering, AlignmentType, AnnotationReference, Attributes, BaseXmlComponent, Body, Bookmark, BookmarkEnd, BookmarkStart, Border, BorderStyle, BuilderElement, CarriageReturn, CellMerge, CellMergeAttributes, CharacterSet, CheckBox, CheckBoxSymbolElement, CheckBoxUtil, Column, ColumnBreak, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments, ConcreteHyperlink, ConcreteNumbering, ContinuationSeparator, DayLong, DayShort, DeletedTableCell, DeletedTableRow, DeletedTextRun, File as Document, File, DocumentAttributeNamespaces, DocumentAttributes, DocumentBackground, DocumentBackgroundAttributes, DocumentDefaults, DocumentGridType, Drawing, DropCapType, EMPTY_OBJECT, EmphasisMarkType, EmptyElement, EndnoteIdReference, EndnoteReference, EndnoteReferenceRun, EndnoteReferenceRunAttributes, Endnotes, ExternalHyperlink, FileChild, FootNoteReferenceRunAttributes, FootNotes, Footer, FooterWrapper, FootnoteReference, FootnoteReferenceElement, FootnoteReferenceRun, FrameAnchorType, FrameWrap, GridSpan, Header, HeaderFooterReferenceType, HeaderFooterType, HeaderWrapper, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HpsMeasureElement, HyperlinkType, IgnoreIfEmptyXmlComponent, ImageRun, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InsertedTableCell, InsertedTableRow, InsertedTextRun, InternalHyperlink, LastRenderedPageBreak, LeaderType, Level, LevelBase, LevelForOverride, LevelFormat, LevelOverride, LevelSuffix, LineNumberRestartFormat, LineRuleType, Math$1 as Math, MathAngledBrackets, MathCurlyBrackets, MathDegree, MathDenominator, MathFraction, MathFunction, MathFunctionName, MathFunctionProperties, MathIntegral, MathLimit, MathLimitLower, MathLimitUpper, MathNumerator, MathPreSubSuperScript, MathRadical, MathRadicalProperties, MathRoundBrackets, MathRun, MathSquareBrackets, MathSubScript, MathSubSuperScript, MathSum, MathSuperScript, Media, MonthLong, MonthShort, NextAttributeComponent, NoBreakHyphen, NumberFormat, NumberProperties, NumberValueElement, NumberedItemReference, NumberedItemReferenceFormat, Numbering, OnOffElement, OverlapType, Packer, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageBorders, PageBreak, PageBreakBefore, PageNumber, PageNumberElement, PageNumberSeparator, PageOrientation, PageReference, PageTextDirection, PageTextDirectionType, Paragraph, ParagraphProperties, ParagraphPropertiesChange, ParagraphPropertiesDefaults, ParagraphRunProperties, PatchType, PositionalTab, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, PrettifyType, RelativeHorizontalPosition, RelativeVerticalPosition, Run, RunProperties, RunPropertiesChange, RunPropertiesDefaults, SectionProperties, SectionPropertiesChange, SectionType, Separator, SequentialIdentifier, ShadingType, SimpleField, SimpleMailMergeField, SoftHyphen, SpaceType, StringContainer, StringEnumValueElement, StringValueElement, StyleForCharacter, StyleForParagraph, StyleLevel, Styles, SymbolRun, TDirection, Tab, TabStopPosition, TabStopType, Table, TableAnchorType, TableBorders, TableCell, TableCellBorders, TableLayoutType, TableOfContents, TableProperties, TableRow, TableRowProperties, TableRowPropertiesChange, TextDirection, TextEffect, TextRun, TextWrappingSide, TextWrappingType, Textbox, ThematicBreak, UnderlineType, VerticalAlign, VerticalAlignSection, VerticalAlignTable, VerticalAnchor, VerticalMerge, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WORKAROUND2, WORKAROUND3, WORKAROUND4, WidthType, WpgGroupRun, WpsShapeRun, XmlAttributeComponent, XmlComponent, YearLong, YearShort, abstractNumUniqueNumericIdGen, bookmarkUniqueNumericIdGen, concreteNumUniqueNumericIdGen, convertInchesToTwip, convertMillimetersToTwip, convertToXmlComponent, createAlignment, createBodyProperties, createBorderElement, createColumns, createDocumentGrid, createDotEmphasisMark, createEmphasisMark, createFrameProperties, createHeaderFooterReference, createHorizontalPosition, createIndent, createLineNumberType, createMathAccentCharacter, createMathBase, createMathLimitLocation, createMathNAryProperties, createMathPreSubSuperScriptProperties, createMathSubScriptElement, createMathSubScriptProperties, createMathSubSuperScriptProperties, createMathSuperScriptElement, createMathSuperScriptProperties, createOutlineLevel, createPageMargin, createPageNumberType, createPageSize, createParagraphStyle, createRunFonts, createSectionType, createShading, createSimplePos, createSpacing, createStringElement, createTabStop, createTabStopItem, createTableFloatProperties, createTableLayout, createTableLook, createTableRowHeight, createTableWidthElement, createTransformation, createUnderline, createVerticalAlign, createVerticalPosition, createWrapNone, createWrapSquare, createWrapTight, createWrapTopAndBottom, dateTimeValue, decimalNumber, docPropertiesUniqueNumericIdGen, eighthPointMeasureValue, encodeUtf8, hashedId, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, patchDetector, patchDocument, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, sectionMarginDefaults, sectionPageSizeDefaults, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber };
23183
+ export { AbstractNumbering, AlignmentType, AnnotationReference, Attributes, BaseXmlComponent, Body, Bookmark, BookmarkEnd, BookmarkStart, Border, BorderStyle, BuilderElement, CarriageReturn, CellMerge, CellMergeAttributes, CharacterSet, CheckBox, CheckBoxSymbolElement, CheckBoxUtil, Column, ColumnBreak, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, Comments, ConcreteHyperlink, ConcreteNumbering, ContinuationSeparator, DayLong, DayShort, DeletedTableCell, DeletedTableRow, DeletedTextRun, File as Document, File, DocumentAttributeNamespaces, DocumentAttributes, DocumentBackground, DocumentBackgroundAttributes, DocumentDefaults, DocumentGridType, Drawing, DropCapType, EMPTY_OBJECT, EmphasisMarkType, EmptyElement, EndnoteIdReference, EndnoteReference, EndnoteReferenceRun, EndnoteReferenceRunAttributes, Endnotes, ExternalHyperlink, FileChild, FootNoteReferenceRunAttributes, FootNotes, Footer, FooterWrapper, FootnoteReference, FootnoteReferenceElement, FootnoteReferenceRun, FrameAnchorType, FrameWrap, GridSpan, Header, HeaderFooterReferenceType, HeaderFooterType, HeaderWrapper, HeadingLevel, HeightRule, HighlightColor, HorizontalPositionAlign, HorizontalPositionRelativeFrom, HpsMeasureElement, HyperlinkType, IgnoreIfEmptyXmlComponent, ImageRun, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InsertedTableCell, InsertedTableRow, InsertedTextRun, InternalHyperlink, LastRenderedPageBreak, LeaderType, Level, LevelBase, LevelForOverride, LevelFormat, LevelOverride, LevelSuffix, LineNumberRestartFormat, LineRuleType, Math$1 as Math, MathAngledBrackets, MathCurlyBrackets, MathDegree, MathDenominator, MathFraction, MathFunction, MathFunctionName, MathFunctionProperties, MathIntegral, MathLimit, MathLimitLower, MathLimitUpper, MathNumerator, MathPreSubSuperScript, MathRadical, MathRadicalProperties, MathRoundBrackets, MathRun, MathSquareBrackets, MathSubScript, MathSubSuperScript, MathSum, MathSuperScript, Media, MonthLong, MonthShort, NextAttributeComponent, NoBreakHyphen, NumberFormat, NumberProperties, NumberValueElement, NumberedItemReference, NumberedItemReferenceFormat, Numbering, OnOffElement, OverlapType, Packer, PageBorderDisplay, PageBorderOffsetFrom, PageBorderZOrder, PageBorders, PageBreak, PageBreakBefore, PageNumber, PageNumberElement, PageNumberSeparator, PageOrientation, PageReference, PageTextDirection, PageTextDirectionType, Paragraph, ParagraphProperties, ParagraphPropertiesChange, ParagraphPropertiesDefaults, ParagraphRunProperties, PatchType, PositionalTab, PositionalTabAlignment, PositionalTabLeader, PositionalTabRelativeTo, PrettifyType, RelativeHorizontalPosition, RelativeVerticalPosition, Run, RunProperties, RunPropertiesChange, RunPropertiesDefaults, SectionProperties, SectionPropertiesChange, SectionType, Separator, SequentialIdentifier, ShadingType, SimpleField, SimpleMailMergeField, SoftHyphen, SpaceType, StringContainer, StringEnumValueElement, StringValueElement, StyleForCharacter, StyleForParagraph, StyleLevel, Styles, SymbolRun, TDirection, Tab, TabStopPosition, TabStopType, Table, TableAnchorType, TableBorders, TableCell, TableCellBorders, TableLayoutType, TableOfContents, TableProperties, TableRow, TableRowProperties, TableRowPropertiesChange, TextDirection, TextEffect, TextRun, TextWrappingSide, TextWrappingType, Textbox, ThematicBreak, ThemeColor, ThemeFont, UnderlineType, VerticalAlign, VerticalAlignSection, VerticalAlignTable, VerticalAnchor, VerticalMerge, VerticalMergeRevisionType, VerticalMergeType, VerticalPositionAlign, VerticalPositionRelativeFrom, WORKAROUND2, WORKAROUND3, WORKAROUND4, WidthType, WpgGroupRun, WpsShapeRun, XmlAttributeComponent, XmlComponent, YearLong, YearShort, abstractNumUniqueNumericIdGen, bookmarkUniqueNumericIdGen, concreteNumUniqueNumericIdGen, convertInchesToTwip, convertMillimetersToTwip, convertToXmlComponent, createAlignment, createBodyProperties, createBorderElement, createColumns, createDocumentGrid, createDotEmphasisMark, createEmphasisMark, createFrameProperties, createHeaderFooterReference, createHorizontalPosition, createIndent, createLineNumberType, createMathAccentCharacter, createMathBase, createMathLimitLocation, createMathNAryProperties, createMathPreSubSuperScriptProperties, createMathSubScriptElement, createMathSubScriptProperties, createMathSubSuperScriptProperties, createMathSuperScriptElement, createMathSuperScriptProperties, createOutlineLevel, createPageMargin, createPageNumberType, createPageSize, createParagraphStyle, createRunFonts, createSectionType, createShading, createSimplePos, createSpacing, createStringElement, createTabStop, createTabStopItem, createTableFloatProperties, createTableLayout, createTableLook, createTableRowHeight, createTableWidthElement, createTransformation, createUnderline, createVerticalAlign, createVerticalPosition, createWrapNone, createWrapSquare, createWrapTight, createWrapTopAndBottom, dateTimeValue, decimalNumber, docPropertiesUniqueNumericIdGen, eighthPointMeasureValue, hashedId, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, patchDetector, patchDocument, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, sectionMarginDefaults, sectionPageSizeDefaults, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber };