pdfmake 0.3.9 → 0.3.10

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/build/pdfmake.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! pdfmake v0.3.9, @license MIT, @link http://pdfmake.org */
1
+ /*! pdfmake v0.3.10, @license MIT, @link http://pdfmake.org */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory();
@@ -25,7 +25,7 @@ __webpack_require__.d(__webpack_exports__, {
25
25
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.includes.js
26
26
  var es_array_includes = __webpack_require__(187);
27
27
  // EXTERNAL MODULE: ./node_modules/pdfkit/js/pdfkit.es.js
28
- var pdfkit_es = __webpack_require__(8259);
28
+ var pdfkit_es = __webpack_require__(7101);
29
29
  ;// ./src/helpers/variableType.js
30
30
  /**
31
31
  * @param {any} variable
@@ -8757,7 +8757,7 @@ class OutputDocument {
8757
8757
  }
8758
8758
  /* harmony default export */ const src_OutputDocument = (OutputDocument);
8759
8759
  // EXTERNAL MODULE: ./node_modules/file-saver/dist/FileSaver.min.js
8760
- var FileSaver_min = __webpack_require__(7286);
8760
+ var FileSaver_min = __webpack_require__(1438);
8761
8761
  ;// ./src/browser-extensions/OutputDocumentBrowser.js
8762
8762
 
8763
8763
 
@@ -15286,7 +15286,7 @@ module.exports = {
15286
15286
 
15287
15287
  /***/ },
15288
15288
 
15289
- /***/ 8259
15289
+ /***/ 7101
15290
15290
  (__unused_webpack_module, exports, __webpack_require__) {
15291
15291
 
15292
15292
  "use strict";
@@ -15307,13 +15307,11 @@ var _stream = _interopRequireDefault(__webpack_require__(9760));
15307
15307
  var _zlib = _interopRequireDefault(__webpack_require__(6729));
15308
15308
  var _utils = __webpack_require__(3973);
15309
15309
  var _jsMd = _interopRequireDefault(__webpack_require__(1632));
15310
- var _sha = __webpack_require__(7785);
15310
+ var _sha = __webpack_require__(2650);
15311
15311
  var _aes = __webpack_require__(2651);
15312
- var fontkit = _interopRequireWildcard(__webpack_require__(1715));
15313
- var _events = __webpack_require__(4785);
15312
+ var _fontkit = __webpack_require__(1715);
15314
15313
  var _linebreak = _interopRequireDefault(__webpack_require__(2532));
15315
15314
  var _pngJs = _interopRequireDefault(__webpack_require__(381));
15316
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15317
15315
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15318
15316
  var fs = __webpack_require__(2416);
15319
15317
  class PDFAbstractReference {
@@ -15322,8 +15320,10 @@ class PDFAbstractReference {
15322
15320
  }
15323
15321
  }
15324
15322
  class PDFTree {
15325
- constructor() {
15326
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15323
+ constructor(options) {
15324
+ if (options === void 0) {
15325
+ options = {};
15326
+ }
15327
15327
  this._items = {};
15328
15328
  this.limits = typeof options.limits === 'boolean' ? options.limits : true;
15329
15329
  }
@@ -15364,7 +15364,7 @@ class SpotColor {
15364
15364
  this.id = 'CS' + Object.keys(doc.spotColors).length;
15365
15365
  this.name = name;
15366
15366
  this.values = [C, M, Y, K];
15367
- this.ref = doc.ref(['Separation', this.name, 'DeviceCMYK', {
15367
+ this.ref = doc.ref(['Separation', escapeName(this.name), 'DeviceCMYK', {
15368
15368
  Range: [0, 1, 0, 1, 0, 1, 0, 1],
15369
15369
  C0: [0, 0, 0, 0],
15370
15370
  C1: this.values.map(value => value / 100),
@@ -15379,6 +15379,10 @@ class SpotColor {
15379
15379
  }
15380
15380
  }
15381
15381
  const pad = (str, length) => (Array(length + 1).join('0') + str).slice(-length);
15382
+ const isSafeCharCode = code => {
15383
+ if (code > 0x7f) return true;
15384
+ return code > 0x20 && code !== 0x7f && code !== 0x23 && code !== 0x25 && code !== 0x28 && code !== 0x29 && code !== 0x2f && code !== 0x3c && code !== 0x3e && code !== 0x5b && code !== 0x5d && code !== 0x7b && code !== 0x7d;
15385
+ };
15382
15386
  const escapableRe = /[\n\r\t\b\f()\\]/g;
15383
15387
  const escapable = {
15384
15388
  '\n': '\\n',
@@ -15390,6 +15394,18 @@ const escapable = {
15390
15394
  '(': '\\(',
15391
15395
  ')': '\\)'
15392
15396
  };
15397
+ const escapeName = function (name) {
15398
+ let escapedName = '';
15399
+ for (const char of name) {
15400
+ const code = char.charCodeAt(0);
15401
+ if (isSafeCharCode(code)) {
15402
+ escapedName += char;
15403
+ } else {
15404
+ escapedName += `#${code.toString(16).toUpperCase().padStart(2, '0')}`;
15405
+ }
15406
+ }
15407
+ return escapedName;
15408
+ };
15393
15409
  const swapBytes = function (buff) {
15394
15410
  const l = buff.length;
15395
15411
  if (l & 0x01) {
@@ -15404,8 +15420,10 @@ const swapBytes = function (buff) {
15404
15420
  return buff;
15405
15421
  };
15406
15422
  class PDFObject {
15407
- static convert(object) {
15408
- let encryptFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15423
+ static convert(object, encryptFn) {
15424
+ if (encryptFn === void 0) {
15425
+ encryptFn = null;
15426
+ }
15409
15427
  if (typeof object === 'string') {
15410
15428
  return `/${object}`;
15411
15429
  } else if (object instanceof String) {
@@ -15466,8 +15484,10 @@ class PDFObject {
15466
15484
  }
15467
15485
  }
15468
15486
  class PDFReference extends PDFAbstractReference {
15469
- constructor(document, id) {
15470
- let data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15487
+ constructor(document, id, data) {
15488
+ if (data === void 0) {
15489
+ data = {};
15490
+ }
15471
15491
  super();
15472
15492
  this.document = document;
15473
15493
  this.id = id;
@@ -15538,9 +15558,13 @@ function PDFNumber(n) {
15538
15558
  }
15539
15559
  return fArray[0];
15540
15560
  }
15541
- function normalizeSides(sides) {
15542
- let defaultDefinition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
15543
- let transformer = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : v => v;
15561
+ function normalizeSides(sides, defaultDefinition, transformer) {
15562
+ if (defaultDefinition === void 0) {
15563
+ defaultDefinition = undefined;
15564
+ }
15565
+ if (transformer === void 0) {
15566
+ transformer = v => v;
15567
+ }
15544
15568
  if (sides == null || typeof sides === 'object' && Object.keys(sides).length === 0) {
15545
15569
  sides = defaultDefinition;
15546
15570
  }
@@ -15659,8 +15683,10 @@ const SIZES = {
15659
15683
  TABLOID: [792.0, 1224.0]
15660
15684
  };
15661
15685
  class PDFPage {
15662
- constructor(document) {
15663
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15686
+ constructor(document, options) {
15687
+ if (options === void 0) {
15688
+ options = {};
15689
+ }
15664
15690
  this.document = document;
15665
15691
  this._options = options;
15666
15692
  this.size = options.size || 'letter';
@@ -15762,8 +15788,10 @@ function md5Hex(data) {
15762
15788
  function sha256Hash(data) {
15763
15789
  return (0, _sha.sha256)(data);
15764
15790
  }
15765
- function aesCbcEncrypt(data, key, iv) {
15766
- let padding = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
15791
+ function aesCbcEncrypt(data, key, iv, padding) {
15792
+ if (padding === void 0) {
15793
+ padding = true;
15794
+ }
15767
15795
  return (0, _aes.cbc)(key, iv, {
15768
15796
  disablePadding: !padding
15769
15797
  }).encrypt(data);
@@ -15781,28 +15809,24 @@ function rc4(data, key) {
15781
15809
  let j = 0;
15782
15810
  for (let i = 0; i < 256; i++) {
15783
15811
  j = j + s[i] + key[i % key.length] & 0xff;
15784
- var _ref3 = [s[j], s[i]];
15785
- s[i] = _ref3[0];
15786
- s[j] = _ref3[1];
15812
+ var _ref = [s[j], s[i]];
15813
+ s[i] = _ref[0];
15814
+ s[j] = _ref[1];
15787
15815
  }
15788
15816
  const output = new Uint8Array(data.length);
15789
15817
  for (let i = 0, j = 0, k = 0; k < data.length; k++) {
15790
15818
  i = i + 1 & 0xff;
15791
15819
  j = j + s[i] & 0xff;
15792
- var _ref4 = [s[j], s[i]];
15793
- s[i] = _ref4[0];
15794
- s[j] = _ref4[1];
15820
+ var _ref2 = [s[j], s[i]];
15821
+ s[i] = _ref2[0];
15822
+ s[j] = _ref2[1];
15795
15823
  output[k] = data[k] ^ s[s[i] + s[j] & 0xff];
15796
15824
  }
15797
15825
  return output;
15798
15826
  }
15799
15827
  function randomBytes(length) {
15800
15828
  const bytes = new Uint8Array(length);
15801
- if (globalThis.crypto?.getRandomValues) {
15802
- globalThis.crypto.getRandomValues(bytes);
15803
- } else {
15804
- (__webpack_require__(5470).randomFillSync)(bytes);
15805
- }
15829
+ globalThis.crypto.getRandomValues(bytes);
15806
15830
  return bytes;
15807
15831
  }
15808
15832
  function inRange(value, rangeGroup) {
@@ -15859,8 +15883,10 @@ function toCodePoints(input) {
15859
15883
  }
15860
15884
  return codepoints;
15861
15885
  }
15862
- function saslprep(input) {
15863
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15886
+ function saslprep(input, opts) {
15887
+ if (opts === void 0) {
15888
+ opts = {};
15889
+ }
15864
15890
  if (typeof input !== 'string') {
15865
15891
  throw new TypeError('Expected string.');
15866
15892
  }
@@ -15893,8 +15919,10 @@ function saslprep(input) {
15893
15919
  return normalized_input;
15894
15920
  }
15895
15921
  class PDFSecurity {
15896
- static generateFileID() {
15897
- let info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15922
+ static generateFileID(info) {
15923
+ if (info === void 0) {
15924
+ info = {};
15925
+ }
15898
15926
  let infoStr = `${info.CreationDate.getTime()}\n`;
15899
15927
  for (let key in info) {
15900
15928
  if (!info.hasOwnProperty(key)) {
@@ -15907,15 +15935,19 @@ class PDFSecurity {
15907
15935
  static generateRandomWordArray(bytes) {
15908
15936
  return randomBytes(bytes);
15909
15937
  }
15910
- static create(document) {
15911
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15938
+ static create(document, options) {
15939
+ if (options === void 0) {
15940
+ options = {};
15941
+ }
15912
15942
  if (!options.ownerPassword && !options.userPassword) {
15913
15943
  return null;
15914
15944
  }
15915
15945
  return new PDFSecurity(document, options);
15916
15946
  }
15917
- constructor(document) {
15918
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15947
+ constructor(document, options) {
15948
+ if (options === void 0) {
15949
+ options = {};
15950
+ }
15919
15951
  if (!options.ownerPassword && !options.userPassword) {
15920
15952
  throw new Error('None of owner password and user password is defined.');
15921
15953
  }
@@ -16064,8 +16096,10 @@ class PDFSecurity {
16064
16096
  this.dictionary.end();
16065
16097
  }
16066
16098
  }
16067
- function getPermissionsR2() {
16068
- let permissionObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16099
+ function getPermissionsR2(permissionObject) {
16100
+ if (permissionObject === void 0) {
16101
+ permissionObject = {};
16102
+ }
16069
16103
  let permissions = 0xffffffc0 >> 0;
16070
16104
  if (permissionObject.printing) {
16071
16105
  permissions |= 0b000000000100;
@@ -16081,8 +16115,10 @@ function getPermissionsR2() {
16081
16115
  }
16082
16116
  return permissions;
16083
16117
  }
16084
- function getPermissionsR3() {
16085
- let permissionObject = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16118
+ function getPermissionsR3(permissionObject) {
16119
+ if (permissionObject === void 0) {
16120
+ permissionObject = {};
16121
+ }
16086
16122
  let permissions = 0xfffff0c0 >> 0;
16087
16123
  if (permissionObject.printing === 'lowResolution') {
16088
16124
  permissions |= 0b000000000100;
@@ -16200,8 +16236,10 @@ function getEncryptedPermissionsR5(permissions, encryptionKey, generateRandomWor
16200
16236
  data.set(randomPart, 12);
16201
16237
  return aesEcbEncrypt(data, encryptionKey);
16202
16238
  }
16203
- function processPasswordR2R3R4() {
16204
- let password = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
16239
+ function processPasswordR2R3R4(password) {
16240
+ if (password === void 0) {
16241
+ password = '';
16242
+ }
16205
16243
  const out = new Uint8Array(32);
16206
16244
  const length = password.length;
16207
16245
  let index = 0;
@@ -16219,8 +16257,10 @@ function processPasswordR2R3R4() {
16219
16257
  }
16220
16258
  return out;
16221
16259
  }
16222
- function processPasswordR5() {
16223
- let password = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
16260
+ function processPasswordR5(password) {
16261
+ if (password === void 0) {
16262
+ password = '';
16263
+ }
16224
16264
  password = unescape(encodeURIComponent(saslprep(password)));
16225
16265
  const length = Math.min(127, password.length);
16226
16266
  const out = new Uint8Array(length);
@@ -16231,7 +16271,7 @@ function processPasswordR5() {
16231
16271
  }
16232
16272
  const PASSWORD_PADDING = [0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a];
16233
16273
  const number$2 = PDFObject.number;
16234
- class PDFGradient$1 {
16274
+ let PDFGradient$1 = class PDFGradient {
16235
16275
  constructor(doc) {
16236
16276
  this.doc = doc;
16237
16277
  this.stops = [];
@@ -16401,8 +16441,8 @@ class PDFGradient$1 {
16401
16441
  const op = stroke ? 'SCN' : 'scn';
16402
16442
  return this.doc.addContent(`/${this.id} ${op}`);
16403
16443
  }
16404
- }
16405
- class PDFLinearGradient$1 extends PDFGradient$1 {
16444
+ };
16445
+ let PDFLinearGradient$1 = class PDFLinearGradient extends PDFGradient$1 {
16406
16446
  constructor(doc, x1, y1, x2, y2) {
16407
16447
  super(doc);
16408
16448
  this.x1 = x1;
@@ -16420,10 +16460,10 @@ class PDFLinearGradient$1 extends PDFGradient$1 {
16420
16460
  });
16421
16461
  }
16422
16462
  opacityGradient() {
16423
- return new PDFLinearGradient$1(this.doc, this.x1, this.y1, this.x2, this.y2);
16463
+ return new PDFLinearGradient(this.doc, this.x1, this.y1, this.x2, this.y2);
16424
16464
  }
16425
- }
16426
- class PDFRadialGradient$1 extends PDFGradient$1 {
16465
+ };
16466
+ let PDFRadialGradient$1 = class PDFRadialGradient extends PDFGradient$1 {
16427
16467
  constructor(doc, x1, y1, r1, x2, y2, r2) {
16428
16468
  super(doc);
16429
16469
  this.doc = doc;
@@ -16444,16 +16484,16 @@ class PDFRadialGradient$1 extends PDFGradient$1 {
16444
16484
  });
16445
16485
  }
16446
16486
  opacityGradient() {
16447
- return new PDFRadialGradient$1(this.doc, this.x1, this.y1, this.r1, this.x2, this.y2, this.r2);
16487
+ return new PDFRadialGradient(this.doc, this.x1, this.y1, this.r1, this.x2, this.y2, this.r2);
16448
16488
  }
16449
- }
16489
+ };
16450
16490
  var Gradient = {
16451
16491
  PDFGradient: PDFGradient$1,
16452
16492
  PDFLinearGradient: PDFLinearGradient$1,
16453
16493
  PDFRadialGradient: PDFRadialGradient$1
16454
16494
  };
16455
16495
  const underlyingColorSpaces = ['DeviceCMYK', 'DeviceRGB'];
16456
- class PDFTilingPattern$1 {
16496
+ let PDFTilingPattern$1 = class PDFTilingPattern {
16457
16497
  constructor(doc, bBox, xStep, yStep, stream) {
16458
16498
  this.doc = doc;
16459
16499
  this.bBox = bBox;
@@ -16524,7 +16564,7 @@ class PDFTilingPattern$1 {
16524
16564
  const op = stroke ? 'SCN' : 'scn';
16525
16565
  return this.doc.addContent(`${normalizedColor.join(' ')} /${this.id} ${op}`);
16526
16566
  }
16527
- }
16567
+ };
16528
16568
  var pattern = {
16529
16569
  PDFTilingPattern: PDFTilingPattern$1
16530
16570
  };
@@ -17308,8 +17348,10 @@ var VectorMixin = {
17308
17348
  miterLimit(m) {
17309
17349
  return this.addContent(`${number$1(m)} M`);
17310
17350
  },
17311
- dash(length) {
17312
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17351
+ dash(length, options) {
17352
+ if (options === void 0) {
17353
+ options = {};
17354
+ }
17313
17355
  const originalLength = length;
17314
17356
  if (!Array.isArray(length)) {
17315
17357
  length = [length, options.space || length];
@@ -17339,21 +17381,42 @@ var VectorMixin = {
17339
17381
  rect(x, y, w, h) {
17340
17382
  return this.addContent(`${number$1(x)} ${number$1(y)} ${number$1(w)} ${number$1(h)} re`);
17341
17383
  },
17342
- roundedRect(x, y, w, h, r) {
17343
- if (r == null) {
17344
- r = 0;
17345
- }
17346
- r = Math.min(r, 0.5 * w, 0.5 * h);
17347
- const c = r * (1.0 - KAPPA);
17348
- this.moveTo(x + r, y);
17349
- this.lineTo(x + w - r, y);
17350
- this.bezierCurveTo(x + w - c, y, x + w, y + c, x + w, y + r);
17351
- this.lineTo(x + w, y + h - r);
17352
- this.bezierCurveTo(x + w, y + h - c, x + w - c, y + h, x + w - r, y + h);
17353
- this.lineTo(x + r, y + h);
17354
- this.bezierCurveTo(x + c, y + h, x, y + h - c, x, y + h - r);
17355
- this.lineTo(x, y + r);
17356
- this.bezierCurveTo(x, y + c, x + c, y, x + r, y);
17384
+ roundedRect(x, y, w, h, borderRadius) {
17385
+ if (borderRadius == null) {
17386
+ borderRadius = 0;
17387
+ }
17388
+ let radii;
17389
+ if (Array.isArray(borderRadius)) {
17390
+ radii = borderRadius.slice(0, 4);
17391
+ } else {
17392
+ radii = [borderRadius, borderRadius, borderRadius, borderRadius];
17393
+ }
17394
+ const limit = Math.min(0.5 * w, 0.5 * h);
17395
+ const rTL = Math.max(0, Math.min(radii[0] || 0, limit));
17396
+ const rTR = Math.max(0, Math.min(radii[1] || 0, limit));
17397
+ const rBR = Math.max(0, Math.min(radii[2] || 0, limit));
17398
+ const rBL = Math.max(0, Math.min(radii[3] || 0, limit));
17399
+ const cpTR = rTR * (1.0 - KAPPA);
17400
+ const cpBR = rBR * (1.0 - KAPPA);
17401
+ const cpBL = rBL * (1.0 - KAPPA);
17402
+ const cpTL = rTL * (1.0 - KAPPA);
17403
+ this.moveTo(x + rTL, y);
17404
+ this.lineTo(x + w - rTR, y);
17405
+ if (rTR > 0) {
17406
+ this.bezierCurveTo(x + w - cpTR, y, x + w, y + cpTR, x + w, y + rTR);
17407
+ }
17408
+ this.lineTo(x + w, y + h - rBR);
17409
+ if (rBR > 0) {
17410
+ this.bezierCurveTo(x + w, y + h - cpBR, x + w - cpBR, y + h, x + w - rBR, y + h);
17411
+ }
17412
+ this.lineTo(x + rBL, y + h);
17413
+ if (rBL > 0) {
17414
+ this.bezierCurveTo(x + cpBL, y + h, x, y + h - cpBL, x, y + h - rBL);
17415
+ }
17416
+ this.lineTo(x, y + rTL);
17417
+ if (rTL > 0) {
17418
+ this.bezierCurveTo(x, y + cpTL, x + cpTL, y, x + rTL, y);
17419
+ }
17357
17420
  return this.closePath();
17358
17421
  },
17359
17422
  ellipse(x, y, r1, r2) {
@@ -17495,8 +17558,10 @@ var VectorMixin = {
17495
17558
  translate(x, y) {
17496
17559
  return this.transform(1, 0, 0, 1, x, y);
17497
17560
  },
17498
- rotate(angle) {
17499
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
17561
+ rotate(angle, options) {
17562
+ if (options === void 0) {
17563
+ options = {};
17564
+ }
17500
17565
  let y;
17501
17566
  const rad = angle * Math.PI / 180;
17502
17567
  const cos = Math.cos(rad);
@@ -17513,8 +17578,10 @@ var VectorMixin = {
17513
17578
  }
17514
17579
  return this.transform(cos, sin, -sin, cos, x, y);
17515
17580
  },
17516
- scale(xFactor, yFactor) {
17517
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
17581
+ scale(xFactor, yFactor, options) {
17582
+ if (options === void 0) {
17583
+ options = {};
17584
+ }
17518
17585
  let y;
17519
17586
  if (yFactor == null) {
17520
17587
  yFactor = xFactor;
@@ -17658,7 +17725,7 @@ class AFMFont {
17658
17725
  if (match = line.match(/^Start(\w+)/)) {
17659
17726
  section = match[1];
17660
17727
  continue;
17661
- } else if (match = line.match(/^End(\w+)/)) {
17728
+ } else if (line.match(/^End(\w+)/)) {
17662
17729
  section = '';
17663
17730
  continue;
17664
17731
  }
@@ -17749,8 +17816,10 @@ class PDFFont {
17749
17816
  embed() {
17750
17817
  throw new Error('Must be implemented by subclasses');
17751
17818
  }
17752
- lineHeight(size) {
17753
- let includeGap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
17819
+ lineHeight(size, includeGap) {
17820
+ if (includeGap === void 0) {
17821
+ includeGap = false;
17822
+ }
17754
17823
  const gap = includeGap ? this.lineGap : 0;
17755
17824
  return (this.ascender + gap - this.descender) / 1000 * size;
17756
17825
  }
@@ -17996,9 +18065,15 @@ class EmbeddedFont extends PDFFont {
17996
18065
  descriptor.data.FontFile2 = fontFile;
17997
18066
  }
17998
18067
  if (this.document.subset && this.document.subset === 1) {
17999
- const CIDSet = Buffer.from('FFFFFFFFC0', 'hex');
18068
+ const maxCID = this.widths.length - 1;
18069
+ const cidSetBuffer = Buffer.alloc(Math.ceil((maxCID + 1) / 8), 0);
18070
+ for (let cid = 0; cid <= maxCID; cid++) {
18071
+ if (this.widths[cid] != null) {
18072
+ cidSetBuffer[Math.floor(cid / 8)] |= 0x80 >> cid % 8;
18073
+ }
18074
+ }
18000
18075
  const CIDSetRef = this.document.ref();
18001
- CIDSetRef.write(CIDSet);
18076
+ CIDSetRef.write(cidSetBuffer);
18002
18077
  CIDSetRef.end();
18003
18078
  descriptor.data.CIDSet = CIDSetRef;
18004
18079
  }
@@ -18089,9 +18164,9 @@ class PDFFontFactory {
18089
18164
  src = fs.readFileSync(src);
18090
18165
  }
18091
18166
  if (src instanceof Uint8Array) {
18092
- font = fontkit.create(src, family);
18167
+ font = (0, _fontkit.create)(src, family);
18093
18168
  } else if (src instanceof ArrayBuffer) {
18094
- font = fontkit.create(new Uint8Array(src), family);
18169
+ font = (0, _fontkit.create)(new Uint8Array(src), family);
18095
18170
  }
18096
18171
  if (font == null) {
18097
18172
  throw new Error('Not a supported font format or standard PDF font.');
@@ -18109,10 +18184,16 @@ const isEqualFont = (font1, font2) => {
18109
18184
  return true;
18110
18185
  };
18111
18186
  var FontsMixin = {
18112
- initFonts() {
18113
- let defaultFont = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Helvetica';
18114
- let defaultFontFamily = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
18115
- let defaultFontSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
18187
+ initFonts(defaultFont, defaultFontFamily, defaultFontSize) {
18188
+ if (defaultFont === void 0) {
18189
+ defaultFont = 'Helvetica';
18190
+ }
18191
+ if (defaultFontFamily === void 0) {
18192
+ defaultFontFamily = null;
18193
+ }
18194
+ if (defaultFontSize === void 0) {
18195
+ defaultFontSize = 12;
18196
+ }
18116
18197
  this._fontFamilies = {};
18117
18198
  this._fontCount = 0;
18118
18199
  this._fontSource = defaultFont;
@@ -18160,9 +18241,12 @@ var FontsMixin = {
18160
18241
  if (cacheKey) {
18161
18242
  this._fontFamilies[cacheKey] = this._font;
18162
18243
  }
18163
- if (this._font.name) {
18244
+ if (this._font.name && !this._fontFamilies[this._font.name]) {
18164
18245
  this._fontFamilies[this._font.name] = this._font;
18165
18246
  }
18247
+ if (!cacheKey && (!this._font.name || this._fontFamilies[this._font.name] !== this._font)) {
18248
+ this._fontFamilies[this._font.id] = this._font;
18249
+ }
18166
18250
  return this;
18167
18251
  },
18168
18252
  fontSize(_fontSize) {
@@ -18179,10 +18263,16 @@ var FontsMixin = {
18179
18263
  };
18180
18264
  return this;
18181
18265
  },
18182
- sizeToPoint(size) {
18183
- let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
18184
- let page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.page;
18185
- let percentageWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
18266
+ sizeToPoint(size, defaultValue, page, percentageWidth) {
18267
+ if (defaultValue === void 0) {
18268
+ defaultValue = 0;
18269
+ }
18270
+ if (page === void 0) {
18271
+ page = this.page;
18272
+ }
18273
+ if (percentageWidth === void 0) {
18274
+ percentageWidth = undefined;
18275
+ }
18186
18276
  if (!percentageWidth) percentageWidth = this._fontSize;
18187
18277
  if (typeof defaultValue !== 'number') defaultValue = this.sizeToPoint(defaultValue);
18188
18278
  if (size === undefined) return defaultValue;
@@ -18243,9 +18333,9 @@ var FontsMixin = {
18243
18333
  };
18244
18334
  const SOFT_HYPHEN = '\u00AD';
18245
18335
  const HYPHEN = '-';
18246
- class LineWrapper extends _events.EventEmitter {
18336
+ class LineWrapper {
18247
18337
  constructor(document, options) {
18248
- super();
18338
+ this._listeners = Object.create(null);
18249
18339
  this.document = document;
18250
18340
  this.horizontalScaling = options.horizontalScaling || 100;
18251
18341
  this.indent = (options.indent || 0) * this.horizontalScaling / 100;
@@ -18299,6 +18389,26 @@ class LineWrapper extends _events.EventEmitter {
18299
18389
  });
18300
18390
  });
18301
18391
  }
18392
+ on(event, listener) {
18393
+ (this._listeners[event] || (this._listeners[event] = [])).push(listener);
18394
+ }
18395
+ once(event, listener) {
18396
+ var _this = this;
18397
+ const wrapper = function () {
18398
+ const listeners = _this._listeners[event];
18399
+ listeners.splice(listeners.indexOf(wrapper), 1);
18400
+ listener(...arguments);
18401
+ };
18402
+ this.on(event, wrapper);
18403
+ }
18404
+ emit(event) {
18405
+ const listeners = this._listeners[event];
18406
+ if (!listeners) return;
18407
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
18408
+ args[_key2 - 1] = arguments[_key2];
18409
+ }
18410
+ for (const listener of listeners.slice()) listener(...args);
18411
+ }
18302
18412
  wordWidth(word) {
18303
18413
  return PDFNumber(this.document.widthOfString(word, this) + this.characterSpacing + this.wordSpacing);
18304
18414
  }
@@ -18364,6 +18474,7 @@ class LineWrapper extends _events.EventEmitter {
18364
18474
  }
18365
18475
  }
18366
18476
  wrap(text, options) {
18477
+ const document = this.document;
18367
18478
  this.horizontalScaling = options.horizontalScaling || 100;
18368
18479
  if (options.indent != null) {
18369
18480
  this.indent = options.indent * this.horizontalScaling / 100;
@@ -18377,20 +18488,20 @@ class LineWrapper extends _events.EventEmitter {
18377
18488
  if (options.ellipsis != null) {
18378
18489
  this.ellipsis = options.ellipsis;
18379
18490
  }
18380
- const nextY = this.document.y + this.document.currentLineHeight(true);
18381
- if (this.document.y > this.maxY || nextY > this.maxY) {
18491
+ const nextY = document.y + document.currentLineHeight(true);
18492
+ if (document.y > this.maxY || nextY > this.maxY) {
18382
18493
  this.nextSection();
18383
18494
  }
18384
18495
  let buffer = '';
18385
18496
  let textWidth = 0;
18386
18497
  let wc = 0;
18387
18498
  let lc = 0;
18388
- let y = this.document.y;
18499
+ let continueY = document.y;
18389
18500
  const emitLine = () => {
18390
18501
  options.textWidth = textWidth + this.wordSpacing * (wc - 1);
18391
18502
  options.wordCount = wc;
18392
18503
  options.lineWidth = this.lineWidth;
18393
- y = this.document.y;
18504
+ continueY = document.y;
18394
18505
  this.emit('line', buffer, options, this);
18395
18506
  return lc++;
18396
18507
  };
@@ -18406,8 +18517,8 @@ class LineWrapper extends _events.EventEmitter {
18406
18517
  wc++;
18407
18518
  }
18408
18519
  if (bk.required || !this.canFit(word, w)) {
18409
- const lh = this.document.currentLineHeight(true);
18410
- if (this.height != null && this.ellipsis && PDFNumber(this.document.y + lh * 2) > this.maxY && this.column >= this.columns) {
18520
+ const lh = document.currentLineHeight(true);
18521
+ if (this.height != null && this.ellipsis && PDFNumber(document.y + lh * 2) > this.maxY && this.column >= this.columns) {
18411
18522
  if (this.ellipsis === true) {
18412
18523
  this.ellipsis = '…';
18413
18524
  }
@@ -18436,7 +18547,7 @@ class LineWrapper extends _events.EventEmitter {
18436
18547
  this.spaceLeft -= this.wordWidth(HYPHEN);
18437
18548
  }
18438
18549
  emitLine();
18439
- if (PDFNumber(this.document.y + lh) > this.maxY) {
18550
+ if (PDFNumber(document.y + lh) > this.maxY) {
18440
18551
  this.emit('sectionEnd', options, this);
18441
18552
  const shouldContinue = this.nextSection();
18442
18553
  if (!shouldContinue) {
@@ -18471,9 +18582,9 @@ class LineWrapper extends _events.EventEmitter {
18471
18582
  this.continuedX = 0;
18472
18583
  }
18473
18584
  this.continuedX += options.textWidth || 0;
18474
- this.document.y = y;
18585
+ document.y = continueY;
18475
18586
  } else {
18476
- this.document.x = this.startX;
18587
+ document.x = this.startX;
18477
18588
  }
18478
18589
  }
18479
18590
  nextSection(options) {
@@ -18578,8 +18689,10 @@ var TextMixin = {
18578
18689
  text(text, x, y, options) {
18579
18690
  return this._text(text, x, y, options, this._line);
18580
18691
  },
18581
- widthOfString(string) {
18582
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
18692
+ widthOfString(string, options) {
18693
+ if (options === void 0) {
18694
+ options = {};
18695
+ }
18583
18696
  const horizontalScaling = options.horizontalScaling || 100;
18584
18697
  return (this._font.widthOfString(string, this._fontSize, options.features) + (options.characterSpacing || 0) * (string.length - 1)) * horizontalScaling / 100;
18585
18698
  },
@@ -18786,11 +18899,14 @@ var TextMixin = {
18786
18899
  }
18787
18900
  return this;
18788
18901
  },
18789
- _initOptions() {
18790
- let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18791
- let y = arguments.length > 1 ? arguments[1] : undefined;
18792
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
18793
- if (typeof x === 'object') {
18902
+ _initOptions(x, y, options) {
18903
+ if (x === void 0) {
18904
+ x = {};
18905
+ }
18906
+ if (options === void 0) {
18907
+ options = {};
18908
+ }
18909
+ if (x && typeof x === 'object') {
18794
18910
  options = x;
18795
18911
  x = null;
18796
18912
  }
@@ -18823,13 +18939,14 @@ var TextMixin = {
18823
18939
  if (result.columnGap == null) {
18824
18940
  result.columnGap = 18;
18825
18941
  }
18826
- result.rotation = Number(options.rotation ?? 0) % 360;
18942
+ result.rotation = Number(result.rotation ?? 0) % 360;
18827
18943
  if (result.rotation < 0) result.rotation += 360;
18828
18944
  return result;
18829
18945
  },
18830
- _line(text) {
18831
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
18832
- let wrapper = arguments.length > 2 ? arguments[2] : undefined;
18946
+ _line(text, options, wrapper) {
18947
+ if (options === void 0) {
18948
+ options = {};
18949
+ }
18833
18950
  this._fragment(text, this.x, this.y, options);
18834
18951
  if (wrapper) {
18835
18952
  const lineGap = options.lineGap || this._lineGap || 0;
@@ -19035,28 +19152,61 @@ var TextMixin = {
19035
19152
  this.restore();
19036
19153
  }
19037
19154
  };
19155
+ const toBinaryString = bytes => {
19156
+ const chunkSize = 0x8000;
19157
+ let out = '';
19158
+ for (let i = 0; i < bytes.length; i += chunkSize) {
19159
+ const end = Math.min(i + chunkSize, bytes.length);
19160
+ out += String.fromCharCode.apply(null, bytes.subarray(i, end));
19161
+ }
19162
+ return out;
19163
+ };
19164
+ const readUInt16BE = function (bytes, offset) {
19165
+ if (offset === void 0) {
19166
+ offset = 0;
19167
+ }
19168
+ return (bytes[offset] << 8 | bytes[offset + 1]) >>> 0;
19169
+ };
19170
+ const readUInt16LE = function (bytes, offset) {
19171
+ if (offset === void 0) {
19172
+ offset = 0;
19173
+ }
19174
+ return (bytes[offset + 1] << 8 | bytes[offset]) >>> 0;
19175
+ };
19176
+ const readUInt32BE = function (bytes, offset) {
19177
+ if (offset === void 0) {
19178
+ offset = 0;
19179
+ }
19180
+ return bytes[offset] * 0x1000000 + (bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3]) >>> 0;
19181
+ };
19182
+ const readUInt32LE = function (bytes, offset) {
19183
+ if (offset === void 0) {
19184
+ offset = 0;
19185
+ }
19186
+ return (bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16) + bytes[offset + 3] * 0x1000000 >>> 0;
19187
+ };
19038
19188
  const parseExifOrientation = data => {
19039
19189
  if (!data || data.length < 20) return null;
19040
19190
  let pos = 2;
19041
19191
  while (pos < data.length - 4) {
19042
19192
  while (pos < data.length && data[pos] !== 0xff) pos++;
19043
19193
  if (pos >= data.length - 4) return null;
19044
- const marker = data.readUInt16BE(pos);
19194
+ const marker = readUInt16BE(data, pos);
19045
19195
  pos += 2;
19046
19196
  if (marker === 0xffda) return null;
19047
19197
  if (marker >= 0xffd0 && marker <= 0xffd9 || marker === 0xff01) continue;
19048
19198
  if (pos + 2 > data.length) return null;
19049
- const segmentLength = data.readUInt16BE(pos);
19199
+ const segmentLength = readUInt16BE(data, pos);
19050
19200
  if (marker === 0xffe1 && pos + 8 <= data.length) {
19051
- const exifHeader = data.subarray(pos + 2, pos + 8).toString('binary');
19201
+ const exifHeader = toBinaryString(data.subarray(pos + 2, pos + 8));
19052
19202
  if (exifHeader === 'Exif\x00\x00') {
19053
19203
  const tiffStart = pos + 8;
19054
19204
  if (tiffStart + 8 > data.length) return null;
19055
- const byteOrder = data.subarray(tiffStart, tiffStart + 2).toString('ascii');
19205
+ const byteOrder = toBinaryString(data.subarray(tiffStart, tiffStart + 2));
19056
19206
  const isLittleEndian = byteOrder === 'II';
19057
19207
  if (!isLittleEndian && byteOrder !== 'MM') return null;
19058
- const read16 = isLittleEndian ? o => data.readUInt16LE(o) : o => data.readUInt16BE(o);
19059
- const read32 = isLittleEndian ? o => data.readUInt32LE(o) : o => data.readUInt32BE(o);
19208
+ const read16 = isLittleEndian ? o => readUInt16LE(data, o) : o => readUInt16BE(data, o);
19209
+ const read32 = isLittleEndian ? o => readUInt32LE(data, o) : o => readUInt32BE(data, o);
19060
19210
  if (read16(tiffStart + 2) !== 42) return null;
19061
19211
  const ifdPos = tiffStart + read32(tiffStart + 4);
19062
19212
  if (ifdPos + 2 > data.length) return null;
@@ -19111,7 +19261,7 @@ class JPEG {
19111
19261
  pos += 2;
19112
19262
  this.width = this.data.readUInt16BE(pos);
19113
19263
  pos += 2;
19114
- const channels = this.data[pos++];
19264
+ const channels = this.data[pos + 1];
19115
19265
  this.colorSpace = COLOR_SPACE_MAP[channels];
19116
19266
  this.obj = null;
19117
19267
  }
@@ -19145,56 +19295,56 @@ class PNGImage {
19145
19295
  this.obj = null;
19146
19296
  }
19147
19297
  embed(document) {
19148
- let dataDecoded = false;
19149
19298
  this.document = document;
19150
19299
  if (this.obj) {
19151
19300
  return;
19152
19301
  }
19153
- const hasAlphaChannel = this.image.hasAlphaChannel;
19154
- const isInterlaced = this.image.interlaceMethod === 1;
19155
- this.obj = this.document.ref({
19302
+ const image = this.image,
19303
+ height = this.height,
19304
+ width = this.width;
19305
+ const hasAlphaChannel = image.hasAlphaChannel;
19306
+ const isInterlaced = image.interlaceMethod === 1;
19307
+ const obj = this.obj = document.ref({
19156
19308
  Type: 'XObject',
19157
19309
  Subtype: 'Image',
19158
- BitsPerComponent: hasAlphaChannel ? 8 : this.image.bits,
19159
- Width: this.width,
19160
- Height: this.height,
19310
+ BitsPerComponent: hasAlphaChannel ? 8 : image.bits,
19311
+ Width: width,
19312
+ Height: height,
19161
19313
  Filter: 'FlateDecode'
19162
19314
  });
19163
19315
  if (!hasAlphaChannel) {
19164
- const params = this.document.ref({
19316
+ const params = document.ref({
19165
19317
  Predictor: isInterlaced ? 1 : 15,
19166
- Colors: this.image.colors,
19167
- BitsPerComponent: this.image.bits,
19168
- Columns: this.width
19318
+ Colors: image.colors,
19319
+ BitsPerComponent: image.bits,
19320
+ Columns: width
19169
19321
  });
19170
- this.obj.data['DecodeParms'] = params;
19322
+ obj.data['DecodeParms'] = params;
19171
19323
  params.end();
19172
19324
  }
19173
- if (this.image.palette.length === 0) {
19174
- this.obj.data['ColorSpace'] = this.image.colorSpace;
19325
+ if (image.palette.length === 0) {
19326
+ obj.data['ColorSpace'] = image.colorSpace;
19175
19327
  } else {
19176
- const palette = this.document.ref();
19177
- palette.end(Buffer.from(this.image.palette));
19178
- this.obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', this.image.palette.length / 3 - 1, palette];
19179
- }
19180
- if (this.image.transparency.grayscale != null) {
19181
- const val = this.image.transparency.grayscale;
19182
- this.obj.data['Mask'] = [val, val];
19183
- } else if (this.image.transparency.rgb) {
19184
- const rgb = this.image.transparency.rgb;
19328
+ const palette = document.ref();
19329
+ palette.end(Buffer.from(image.palette));
19330
+ obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', image.palette.length / 3 - 1, palette];
19331
+ }
19332
+ if (image.transparency.grayscale != null) {
19333
+ const val = image.transparency.grayscale;
19334
+ obj.data['Mask'] = [val, val];
19335
+ } else if (image.transparency.rgb) {
19336
+ const rgb = image.transparency.rgb;
19185
19337
  const mask = [];
19186
19338
  for (let x of rgb) {
19187
19339
  mask.push(x, x);
19188
19340
  }
19189
- this.obj.data['Mask'] = mask;
19190
- } else if (this.image.transparency.indexed) {
19191
- dataDecoded = true;
19341
+ obj.data['Mask'] = mask;
19342
+ } else if (image.transparency.indexed) {
19192
19343
  return this.loadIndexedAlphaChannel();
19193
19344
  } else if (hasAlphaChannel) {
19194
- dataDecoded = true;
19195
19345
  return this.splitAlphaChannel();
19196
19346
  }
19197
- if (isInterlaced && !dataDecoded) {
19347
+ if (isInterlaced && true) {
19198
19348
  return this.decodeData();
19199
19349
  }
19200
19350
  this.finalize();
@@ -19284,7 +19434,7 @@ class PDFImage {
19284
19434
  }
19285
19435
  if (data[0] === 0xff && data[1] === 0xd8) {
19286
19436
  return new JPEG(data, label);
19287
- } else if (data[0] === 0x89 && data.toString('ascii', 1, 4) === 'PNG') {
19437
+ } else if (data[0] === 0x89 && data[1] === 0x50 && data[2] === 0x4e && data[3] === 0x47) {
19288
19438
  return new PNGImage(data, label);
19289
19439
  } else {
19290
19440
  throw new Error('Unknown image format.');
@@ -19296,8 +19446,10 @@ var ImagesMixin = {
19296
19446
  this._imageRegistry = {};
19297
19447
  this._imageCount = 0;
19298
19448
  },
19299
- image(src, x, y) {
19300
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
19449
+ image(src, x, y, options) {
19450
+ if (options === void 0) {
19451
+ options = {};
19452
+ }
19301
19453
  let bh, bp, bw, image, ip, left, left1, originX, originY;
19302
19454
  if (typeof x === 'object') {
19303
19455
  options = x;
@@ -19327,9 +19479,9 @@ var ImagesMixin = {
19327
19479
  width = _image.width,
19328
19480
  height = _image.height;
19329
19481
  if (!ignoreOrientation && image.orientation > 4) {
19330
- var _ref5 = [height, width];
19331
- width = _ref5[0];
19332
- height = _ref5[1];
19482
+ var _ref3 = [height, width];
19483
+ width = _ref3[0];
19484
+ height = _ref3[1];
19333
19485
  }
19334
19486
  let w = options.width || width;
19335
19487
  let h = options.height || height;
@@ -19460,6 +19612,9 @@ var ImagesMixin = {
19460
19612
  this.y += h;
19461
19613
  }
19462
19614
  this.save();
19615
+ if (options.opacity != null) {
19616
+ this._doOpacity(options.opacity, null);
19617
+ }
19463
19618
  if (rotateAngle) {
19464
19619
  this.rotate(rotateAngle, {
19465
19620
  origin: [originX, originY]
@@ -19521,8 +19676,10 @@ var AnnotationsMixin = {
19521
19676
  ref.end();
19522
19677
  return this;
19523
19678
  },
19524
- note(x, y, w, h, contents) {
19525
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
19679
+ note(x, y, w, h, contents, options) {
19680
+ if (options === void 0) {
19681
+ options = {};
19682
+ }
19526
19683
  options.Subtype = 'Text';
19527
19684
  options.Contents = new String(contents);
19528
19685
  if (options.Name == null) {
@@ -19533,8 +19690,10 @@ var AnnotationsMixin = {
19533
19690
  }
19534
19691
  return this.annotate(x, y, w, h, options);
19535
19692
  },
19536
- goTo(x, y, w, h, name) {
19537
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
19693
+ goTo(x, y, w, h, name, options) {
19694
+ if (options === void 0) {
19695
+ options = {};
19696
+ }
19538
19697
  options.Subtype = 'Link';
19539
19698
  options.A = this.ref({
19540
19699
  S: 'GoTo',
@@ -19543,8 +19702,10 @@ var AnnotationsMixin = {
19543
19702
  options.A.end();
19544
19703
  return this.annotate(x, y, w, h, options);
19545
19704
  },
19546
- link(x, y, w, h, url) {
19547
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
19705
+ link(x, y, w, h, url, options) {
19706
+ if (options === void 0) {
19707
+ options = {};
19708
+ }
19548
19709
  options.Subtype = 'Link';
19549
19710
  if (typeof url === 'number') {
19550
19711
  const pages = this._root.data.Pages.data;
@@ -19569,8 +19730,10 @@ var AnnotationsMixin = {
19569
19730
  }
19570
19731
  return this.annotate(x, y, w, h, options);
19571
19732
  },
19572
- _markup(x, y, w, h) {
19573
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19733
+ _markup(x, y, w, h, options) {
19734
+ if (options === void 0) {
19735
+ options = {};
19736
+ }
19574
19737
  const _this$_convertRect = this._convertRect(x, y, w, h),
19575
19738
  x1 = _this$_convertRect[0],
19576
19739
  y1 = _this$_convertRect[1],
@@ -19580,53 +19743,71 @@ var AnnotationsMixin = {
19580
19743
  options.Contents = new String();
19581
19744
  return this.annotate(x, y, w, h, options);
19582
19745
  },
19583
- highlight(x, y, w, h) {
19584
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19746
+ highlight(x, y, w, h, options) {
19747
+ if (options === void 0) {
19748
+ options = {};
19749
+ }
19585
19750
  options.Subtype = 'Highlight';
19586
19751
  if (options.color == null) {
19587
19752
  options.color = [241, 238, 148];
19588
19753
  }
19589
19754
  return this._markup(x, y, w, h, options);
19590
19755
  },
19591
- underline(x, y, w, h) {
19592
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19756
+ underline(x, y, w, h, options) {
19757
+ if (options === void 0) {
19758
+ options = {};
19759
+ }
19593
19760
  options.Subtype = 'Underline';
19594
19761
  return this._markup(x, y, w, h, options);
19595
19762
  },
19596
- strike(x, y, w, h) {
19597
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19763
+ strike(x, y, w, h, options) {
19764
+ if (options === void 0) {
19765
+ options = {};
19766
+ }
19598
19767
  options.Subtype = 'StrikeOut';
19599
19768
  return this._markup(x, y, w, h, options);
19600
19769
  },
19601
- lineAnnotation(x1, y1, x2, y2) {
19602
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19770
+ lineAnnotation(x1, y1, x2, y2, options) {
19771
+ if (options === void 0) {
19772
+ options = {};
19773
+ }
19603
19774
  options.Subtype = 'Line';
19604
19775
  options.Contents = new String();
19605
19776
  options.L = [x1, this.page.height - y1, x2, this.page.height - y2];
19606
19777
  return this.annotate(x1, y1, x2, y2, options);
19607
19778
  },
19608
- rectAnnotation(x, y, w, h) {
19609
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19779
+ rectAnnotation(x, y, w, h, options) {
19780
+ if (options === void 0) {
19781
+ options = {};
19782
+ }
19610
19783
  options.Subtype = 'Square';
19611
19784
  options.Contents = new String();
19612
19785
  return this.annotate(x, y, w, h, options);
19613
19786
  },
19614
- ellipseAnnotation(x, y, w, h) {
19615
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19787
+ ellipseAnnotation(x, y, w, h, options) {
19788
+ if (options === void 0) {
19789
+ options = {};
19790
+ }
19616
19791
  options.Subtype = 'Circle';
19617
19792
  options.Contents = new String();
19618
19793
  return this.annotate(x, y, w, h, options);
19619
19794
  },
19620
- textAnnotation(x, y, w, h, text) {
19621
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
19795
+ textAnnotation(x, y, w, h, text, options) {
19796
+ if (options === void 0) {
19797
+ options = {};
19798
+ }
19622
19799
  options.Subtype = 'FreeText';
19623
19800
  options.Contents = new String(text);
19624
19801
  options.DA = new String();
19625
19802
  return this.annotate(x, y, w, h, options);
19626
19803
  },
19627
- fileAnnotation(x, y, w, h) {
19628
- let file = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19629
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
19804
+ fileAnnotation(x, y, w, h, file, options) {
19805
+ if (file === void 0) {
19806
+ file = {};
19807
+ }
19808
+ if (options === void 0) {
19809
+ options = {};
19810
+ }
19630
19811
  const filespec = this.file(file.src, Object.assign({
19631
19812
  hidden: true
19632
19813
  }, file));
@@ -19666,8 +19847,10 @@ const DEFAULT_OPTIONS = {
19666
19847
  expanded: false
19667
19848
  };
19668
19849
  class PDFOutline {
19669
- constructor(document, parent, title, dest) {
19670
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : DEFAULT_OPTIONS;
19850
+ constructor(document, parent, title, dest, options) {
19851
+ if (options === void 0) {
19852
+ options = DEFAULT_OPTIONS;
19853
+ }
19671
19854
  this.document = document;
19672
19855
  this.options = options;
19673
19856
  this.outlineData = {};
@@ -19688,8 +19871,10 @@ class PDFOutline {
19688
19871
  this.dictionary = this.document.ref(this.outlineData);
19689
19872
  this.children = [];
19690
19873
  }
19691
- addItem(title) {
19692
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_OPTIONS;
19874
+ addItem(title, options) {
19875
+ if (options === void 0) {
19876
+ options = DEFAULT_OPTIONS;
19877
+ }
19693
19878
  const pages = this.document._root.data.Pages.data.Kids;
19694
19879
  const dest = options.pageNumber != null ? pages[options.pageNumber] : this.document.page.dictionary;
19695
19880
  const result = new PDFOutline(this.document, this.dictionary, title, dest, options);
@@ -19743,9 +19928,13 @@ class PDFStructureContent {
19743
19928
  }
19744
19929
  }
19745
19930
  class PDFStructureElement {
19746
- constructor(document, type) {
19747
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
19748
- let children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
19931
+ constructor(document, type, options, children) {
19932
+ if (options === void 0) {
19933
+ options = {};
19934
+ }
19935
+ if (children === void 0) {
19936
+ children = null;
19937
+ }
19749
19938
  this.document = document;
19750
19939
  this._attached = false;
19751
19940
  this._ended = false;
@@ -19758,21 +19947,41 @@ class PDFStructureElement {
19758
19947
  children = options;
19759
19948
  options = {};
19760
19949
  }
19761
- if (typeof options.title !== 'undefined') {
19950
+ if (options.title) {
19762
19951
  data.T = new String(options.title);
19763
19952
  }
19764
- if (typeof options.lang !== 'undefined') {
19953
+ if (options.lang) {
19765
19954
  data.Lang = new String(options.lang);
19766
19955
  }
19767
- if (typeof options.alt !== 'undefined') {
19956
+ if (options.alt) {
19768
19957
  data.Alt = new String(options.alt);
19769
19958
  }
19770
- if (typeof options.expanded !== 'undefined') {
19959
+ if (options.expanded) {
19771
19960
  data.E = new String(options.expanded);
19772
19961
  }
19773
- if (typeof options.actual !== 'undefined') {
19962
+ if (options.actual) {
19774
19963
  data.ActualText = new String(options.actual);
19775
19964
  }
19965
+ const hasBbox = Array.isArray(options.bbox) && options.bbox.length === 4;
19966
+ const hasPlacement = typeof options.placement === 'string';
19967
+ if (hasBbox || hasPlacement) {
19968
+ const attrs = {
19969
+ O: 'Layout'
19970
+ };
19971
+ attrs.Placement = hasPlacement ? options.placement : 'Block';
19972
+ if (hasBbox) {
19973
+ const height = document.page.height;
19974
+ attrs.BBox = [options.bbox[0], height - options.bbox[3], options.bbox[2], height - options.bbox[1]];
19975
+ }
19976
+ data.A = attrs;
19977
+ }
19978
+ if (options.scope) {
19979
+ data.A = {
19980
+ ...(data.A || {}),
19981
+ O: 'Table',
19982
+ Scope: options.scope
19983
+ };
19984
+ }
19776
19985
  this._children = [];
19777
19986
  if (children) {
19778
19987
  if (!Array.isArray(children)) {
@@ -19808,9 +20017,9 @@ class PDFStructureElement {
19808
20017
  return this;
19809
20018
  }
19810
20019
  _addContentToParentTree(content) {
19811
- content.refs.forEach(_ref => {
19812
- let pageRef = _ref.pageRef,
19813
- mcid = _ref.mcid;
20020
+ content.refs.forEach(_ref4 => {
20021
+ let pageRef = _ref4.pageRef,
20022
+ mcid = _ref4.mcid;
19814
20023
  const pageStructParents = this.document.getStructParentTree().get(pageRef.data.StructParents);
19815
20024
  pageStructParents[mcid] = this.dictionary;
19816
20025
  });
@@ -19897,9 +20106,9 @@ class PDFStructureElement {
19897
20106
  this.dictionary.data.K.push(child.dictionary);
19898
20107
  }
19899
20108
  if (child instanceof PDFStructureContent) {
19900
- child.refs.forEach(_ref2 => {
19901
- let pageRef = _ref2.pageRef,
19902
- mcid = _ref2.mcid;
20109
+ child.refs.forEach(_ref5 => {
20110
+ let pageRef = _ref5.pageRef,
20111
+ mcid = _ref5.mcid;
19903
20112
  if (!this.dictionary.data.Pg) {
19904
20113
  this.dictionary.data.Pg = pageRef;
19905
20114
  }
@@ -19944,8 +20153,10 @@ var MarkingsMixin = {
19944
20153
  this.getStructTreeRoot();
19945
20154
  }
19946
20155
  },
19947
- markContent(tag) {
19948
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
20156
+ markContent(tag, options) {
20157
+ if (options === void 0) {
20158
+ options = null;
20159
+ }
19949
20160
  if (tag === 'Artifact' || options && options.mcid) {
19950
20161
  let toClose = 0;
19951
20162
  this.page.markings.forEach(marking => {
@@ -20000,8 +20211,10 @@ var MarkingsMixin = {
20000
20211
  this.addContent(`/${tag} ${PDFObject.convert(dictionary)} BDC`);
20001
20212
  return this;
20002
20213
  },
20003
- markStructureContent(tag) {
20004
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20214
+ markStructureContent(tag, options) {
20215
+ if (options === void 0) {
20216
+ options = {};
20217
+ }
20005
20218
  const pageStructParents = this.getStructParentTree().get(this.page.structParentTreeKey);
20006
20219
  const mcid = pageStructParents.length;
20007
20220
  pageStructParents.push(null);
@@ -20025,9 +20238,13 @@ var MarkingsMixin = {
20025
20238
  }
20026
20239
  return this;
20027
20240
  },
20028
- struct(type) {
20029
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20030
- let children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
20241
+ struct(type, options, children) {
20242
+ if (options === void 0) {
20243
+ options = {};
20244
+ }
20245
+ if (children === void 0) {
20246
+ children = null;
20247
+ }
20031
20248
  return new PDFStructureElement(this, type, options, children);
20032
20249
  },
20033
20250
  addStructure(structElem) {
@@ -20191,15 +20408,19 @@ var AcroFormMixin = {
20191
20408
  }
20192
20409
  return this;
20193
20410
  },
20194
- formField(name) {
20195
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20411
+ formField(name, options) {
20412
+ if (options === void 0) {
20413
+ options = {};
20414
+ }
20196
20415
  let fieldDict = this._fieldDict(name, null, options);
20197
20416
  let fieldRef = this.ref(fieldDict);
20198
20417
  this._addToParent(fieldRef);
20199
20418
  return fieldRef;
20200
20419
  },
20201
- formAnnotation(name, type, x, y, w, h) {
20202
- let options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
20420
+ formAnnotation(name, type, x, y, w, h, options) {
20421
+ if (options === void 0) {
20422
+ options = {};
20423
+ }
20203
20424
  let fieldDict = this._fieldDict(name, type, options);
20204
20425
  fieldDict.Subtype = 'Widget';
20205
20426
  if (fieldDict.F === undefined) {
@@ -20209,28 +20430,40 @@ var AcroFormMixin = {
20209
20430
  let annotRef = this.page.annotations[this.page.annotations.length - 1];
20210
20431
  return this._addToParent(annotRef);
20211
20432
  },
20212
- formText(name, x, y, w, h) {
20213
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
20433
+ formText(name, x, y, w, h, options) {
20434
+ if (options === void 0) {
20435
+ options = {};
20436
+ }
20214
20437
  return this.formAnnotation(name, 'text', x, y, w, h, options);
20215
20438
  },
20216
- formPushButton(name, x, y, w, h) {
20217
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
20439
+ formPushButton(name, x, y, w, h, options) {
20440
+ if (options === void 0) {
20441
+ options = {};
20442
+ }
20218
20443
  return this.formAnnotation(name, 'pushButton', x, y, w, h, options);
20219
20444
  },
20220
- formCombo(name, x, y, w, h) {
20221
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
20445
+ formCombo(name, x, y, w, h, options) {
20446
+ if (options === void 0) {
20447
+ options = {};
20448
+ }
20222
20449
  return this.formAnnotation(name, 'combo', x, y, w, h, options);
20223
20450
  },
20224
- formList(name, x, y, w, h) {
20225
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
20451
+ formList(name, x, y, w, h, options) {
20452
+ if (options === void 0) {
20453
+ options = {};
20454
+ }
20226
20455
  return this.formAnnotation(name, 'list', x, y, w, h, options);
20227
20456
  },
20228
- formRadioButton(name, x, y, w, h) {
20229
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
20457
+ formRadioButton(name, x, y, w, h, options) {
20458
+ if (options === void 0) {
20459
+ options = {};
20460
+ }
20230
20461
  return this.formAnnotation(name, 'radioButton', x, y, w, h, options);
20231
20462
  },
20232
- formCheckbox(name, x, y, w, h) {
20233
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
20463
+ formCheckbox(name, x, y, w, h, options) {
20464
+ if (options === void 0) {
20465
+ options = {};
20466
+ }
20234
20467
  return this.formAnnotation(name, 'checkbox', x, y, w, h, options);
20235
20468
  },
20236
20469
  _addToParent(fieldRef) {
@@ -20245,8 +20478,10 @@ var AcroFormMixin = {
20245
20478
  }
20246
20479
  return this;
20247
20480
  },
20248
- _fieldDict(name, type) {
20249
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
20481
+ _fieldDict(name, type, options) {
20482
+ if (options === void 0) {
20483
+ options = {};
20484
+ }
20250
20485
  if (!this._acroform) {
20251
20486
  throw new Error('Call document.initForm() method before adding form elements to document');
20252
20487
  }
@@ -20434,8 +20669,10 @@ var AcroFormMixin = {
20434
20669
  }
20435
20670
  };
20436
20671
  var AttachmentsMixin = {
20437
- file(src) {
20438
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20672
+ file(src, options) {
20673
+ if (options === void 0) {
20674
+ options = {};
20675
+ }
20439
20676
  options.name = options.name || src;
20440
20677
  options.relationship = options.relationship || 'Unspecified';
20441
20678
  const refBody = {
@@ -20454,7 +20691,7 @@ var AttachmentsMixin = {
20454
20691
  const match = /^data:(.*?);base64,(.*)$/.exec(src);
20455
20692
  if (match) {
20456
20693
  if (match[1]) {
20457
- refBody.Subtype = match[1].replace('/', '#2F');
20694
+ refBody.Subtype = escapeName(match[1]);
20458
20695
  }
20459
20696
  data = Buffer.from(match[2], 'base64');
20460
20697
  } else {
@@ -20476,7 +20713,7 @@ var AttachmentsMixin = {
20476
20713
  refBody.Params.ModDate = options.modifiedDate;
20477
20714
  }
20478
20715
  if (options.type) {
20479
- refBody.Subtype = options.type.replace('/', '#2F');
20716
+ refBody.Subtype = escapeName(options.type);
20480
20717
  }
20481
20718
  const checksum = md5Hex(new Uint8Array(data));
20482
20719
  refBody.Params.CheckSum = new String(checksum);
@@ -20629,8 +20866,8 @@ function isObject(item) {
20629
20866
  function deepMerge(target) {
20630
20867
  if (!isObject(target)) return target;
20631
20868
  target = deepClone(target);
20632
- for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
20633
- sources[_key - 1] = arguments[_key];
20869
+ for (var _len3 = arguments.length, sources = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
20870
+ sources[_key3 - 1] = arguments[_key3];
20634
20871
  }
20635
20872
  for (const source of sources) {
20636
20873
  if (isObject(source)) {
@@ -20659,12 +20896,12 @@ function normalizedDefaultStyle(defaultStyleInternal) {
20659
20896
  if (typeof defaultStyle !== 'object') defaultStyle = {
20660
20897
  text: defaultStyle
20661
20898
  };
20662
- const defaultRowStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref => {
20663
- let k = _ref[0];
20899
+ const defaultRowStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref6 => {
20900
+ let k = _ref6[0];
20664
20901
  return ROW_FIELDS.includes(k);
20665
20902
  }));
20666
- const defaultColStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref2 => {
20667
- let k = _ref2[0];
20903
+ const defaultColStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref7 => {
20904
+ let k = _ref7[0];
20668
20905
  return COLUMN_FIELDS.includes(k);
20669
20906
  }));
20670
20907
  defaultStyle.padding = normalizeSides(defaultStyle.padding);
@@ -21177,9 +21414,9 @@ function renderCellText(cell) {
21177
21414
  if (cell.font) doc.font(rollbackFont, rollbackFontFamily, rollbackFontSize);
21178
21415
  }
21179
21416
  function renderBorder(border, borderColor, x, y, width, height, mask) {
21180
- border = Object.fromEntries(Object.entries(border).map(_ref => {
21181
- let k = _ref[0],
21182
- v = _ref[1];
21417
+ border = Object.fromEntries(Object.entries(border).map(_ref8 => {
21418
+ let k = _ref8[0],
21419
+ v = _ref8[1];
21183
21420
  return [k, mask && !mask[k] ? 0 : v];
21184
21421
  }));
21185
21422
  const doc = this.document;
@@ -21203,8 +21440,10 @@ function renderBorder(border, borderColor, x, y, width, height, mask) {
21203
21440
  }
21204
21441
  }
21205
21442
  class PDFTable {
21206
- constructor(document) {
21207
- let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
21443
+ constructor(document, opts) {
21444
+ if (opts === void 0) {
21445
+ opts = {};
21446
+ }
21208
21447
  this.document = document;
21209
21448
  this.opts = Object.freeze(opts);
21210
21449
  normalizeTable.call(this);
@@ -21216,8 +21455,10 @@ class PDFTable {
21216
21455
  return this.end();
21217
21456
  }
21218
21457
  }
21219
- row(row) {
21220
- let lastRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
21458
+ row(row, lastRow) {
21459
+ if (lastRow === void 0) {
21460
+ lastRow = false;
21461
+ }
21221
21462
  if (this._ended) {
21222
21463
  throw new Error(`Table was marked as ended on row ${this._currRowIndex}`);
21223
21464
  }
@@ -21265,8 +21506,10 @@ class PDFMetadata {
21265
21506
  <?xpacket end="w"?>
21266
21507
  `);
21267
21508
  }
21268
- append(xml) {
21269
- let newline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
21509
+ append(xml, newline) {
21510
+ if (newline === void 0) {
21511
+ newline = true;
21512
+ }
21270
21513
  this._metadata = this._metadata.concat(xml);
21271
21514
  if (newline) this._metadata = this._metadata.concat('\n');
21272
21515
  }
@@ -21285,8 +21528,10 @@ var MetadataMixin = {
21285
21528
  initMetadata() {
21286
21529
  this.metadata = new PDFMetadata();
21287
21530
  },
21288
- appendXML(xml) {
21289
- let newline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
21531
+ appendXML(xml, newline) {
21532
+ if (newline === void 0) {
21533
+ newline = true;
21534
+ }
21290
21535
  this.metadata.append(xml, newline);
21291
21536
  },
21292
21537
  _addInfo() {
@@ -21333,7 +21578,7 @@ var MetadataMixin = {
21333
21578
  }
21334
21579
  this.appendXML(`
21335
21580
  <rdf:Description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
21336
- <pdf:Producer>${this.info.Creator}</pdf:Producer>`, false);
21581
+ <pdf:Producer>${this.info.Producer}</pdf:Producer>`, false);
21337
21582
  if (this.info.Keywords) {
21338
21583
  this.appendXML(`
21339
21584
  <pdf:Keywords>${this.info.Keywords}</pdf:Keywords>`, false);
@@ -21359,8 +21604,10 @@ var MetadataMixin = {
21359
21604
  }
21360
21605
  };
21361
21606
  class PDFDocument extends _stream.default.Readable {
21362
- constructor() {
21363
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21607
+ constructor(options) {
21608
+ if (options === void 0) {
21609
+ options = {};
21610
+ }
21364
21611
  super(options);
21365
21612
  this.options = options;
21366
21613
  switch (options.pdfVersion) {
@@ -21491,8 +21738,8 @@ class PDFDocument extends _stream.default.Readable {
21491
21738
  }
21492
21739
  }
21493
21740
  addNamedDestination(name) {
21494
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
21495
- args[_key - 1] = arguments[_key];
21741
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
21742
+ args[_key4 - 1] = arguments[_key4];
21496
21743
  }
21497
21744
  if (args.length === 0) {
21498
21745
  args = ['XYZ', null, null, null];
@@ -23468,10 +23715,9 @@ exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? glob
23468
23715
  (__unused_webpack_module, exports, __webpack_require__) {
23469
23716
 
23470
23717
  "use strict";
23471
- var __webpack_unused_export__;
23472
23718
 
23473
- __webpack_unused_export__ = ({ value: true });
23474
- __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = exports.sha224 = exports.sha256 = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = __webpack_unused_export__ = exports.SHA224 = exports.SHA256 = void 0;
23719
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
23720
+ exports.sha512_224 = exports.sha512_256 = exports.sha384 = exports.sha512 = exports.sha224 = exports.sha256 = exports.SHA512_256 = exports.SHA512_224 = exports.SHA384 = exports.SHA512 = exports.SHA224 = exports.SHA256 = void 0;
23475
23721
  /**
23476
23722
  * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
23477
23723
  * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
@@ -23745,7 +23991,7 @@ class SHA512 extends _md_ts_1.HashMD {
23745
23991
  this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
23746
23992
  }
23747
23993
  }
23748
- __webpack_unused_export__ = SHA512;
23994
+ exports.SHA512 = SHA512;
23749
23995
  class SHA384 extends SHA512 {
23750
23996
  constructor() {
23751
23997
  super(48);
@@ -23767,7 +24013,7 @@ class SHA384 extends SHA512 {
23767
24013
  this.Hl = _md_ts_1.SHA384_IV[15] | 0;
23768
24014
  }
23769
24015
  }
23770
- __webpack_unused_export__ = SHA384;
24016
+ exports.SHA384 = SHA384;
23771
24017
  /**
23772
24018
  * Truncated SHA512/256 and SHA512/224.
23773
24019
  * SHA512_IV is XORed with 0xa5a5a5a5a5a5a5a5, then used as "intermediary" IV of SHA512/t.
@@ -23805,7 +24051,7 @@ class SHA512_224 extends SHA512 {
23805
24051
  this.Hl = T224_IV[15] | 0;
23806
24052
  }
23807
24053
  }
23808
- __webpack_unused_export__ = SHA512_224;
24054
+ exports.SHA512_224 = SHA512_224;
23809
24055
  class SHA512_256 extends SHA512 {
23810
24056
  constructor() {
23811
24057
  super(32);
@@ -23827,7 +24073,7 @@ class SHA512_256 extends SHA512 {
23827
24073
  this.Hl = T256_IV[15] | 0;
23828
24074
  }
23829
24075
  }
23830
- __webpack_unused_export__ = SHA512_256;
24076
+ exports.SHA512_256 = SHA512_256;
23831
24077
  /**
23832
24078
  * SHA2-256 hash function from RFC 4634.
23833
24079
  *
@@ -23839,49 +24085,19 @@ exports.sha256 = (0, utils_ts_1.createHasher)(() => new SHA256());
23839
24085
  /** SHA2-224 hash function from RFC 4634 */
23840
24086
  exports.sha224 = (0, utils_ts_1.createHasher)(() => new SHA224());
23841
24087
  /** SHA2-512 hash function from RFC 4634. */
23842
- __webpack_unused_export__ = (0, utils_ts_1.createHasher)(() => new SHA512());
24088
+ exports.sha512 = (0, utils_ts_1.createHasher)(() => new SHA512());
23843
24089
  /** SHA2-384 hash function from RFC 4634. */
23844
- __webpack_unused_export__ = (0, utils_ts_1.createHasher)(() => new SHA384());
24090
+ exports.sha384 = (0, utils_ts_1.createHasher)(() => new SHA384());
23845
24091
  /**
23846
24092
  * SHA2-512/256 "truncated" hash function, with improved resistance to length extension attacks.
23847
24093
  * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).
23848
24094
  */
23849
- __webpack_unused_export__ = (0, utils_ts_1.createHasher)(() => new SHA512_256());
24095
+ exports.sha512_256 = (0, utils_ts_1.createHasher)(() => new SHA512_256());
23850
24096
  /**
23851
24097
  * SHA2-512/224 "truncated" hash function, with improved resistance to length extension attacks.
23852
24098
  * See the paper on [truncated SHA512](https://eprint.iacr.org/2010/548.pdf).
23853
24099
  */
23854
- __webpack_unused_export__ = (0, utils_ts_1.createHasher)(() => new SHA512_224());
23855
-
23856
-
23857
- /***/ },
23858
-
23859
- /***/ 7785
23860
- (__unused_webpack_module, exports, __webpack_require__) {
23861
-
23862
- "use strict";
23863
-
23864
- Object.defineProperty(exports, "__esModule", ({ value: true }));
23865
- exports.sha224 = exports.SHA224 = exports.sha256 = exports.SHA256 = void 0;
23866
- /**
23867
- * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
23868
- *
23869
- * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
23870
- * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
23871
- *
23872
- * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
23873
- * @module
23874
- * @deprecated
23875
- */
23876
- const sha2_ts_1 = __webpack_require__(2650);
23877
- /** @deprecated Use import from `noble/hashes/sha2` module */
23878
- exports.SHA256 = sha2_ts_1.SHA256;
23879
- /** @deprecated Use import from `noble/hashes/sha2` module */
23880
- exports.sha256 = sha2_ts_1.sha256;
23881
- /** @deprecated Use import from `noble/hashes/sha2` module */
23882
- exports.SHA224 = sha2_ts_1.SHA224;
23883
- /** @deprecated Use import from `noble/hashes/sha2` module */
23884
- exports.sha224 = sha2_ts_1.sha224;
24100
+ exports.sha512_224 = (0, utils_ts_1.createHasher)(() => new SHA512_224());
23885
24101
 
23886
24102
 
23887
24103
  /***/ },
@@ -45791,6 +46007,9 @@ var typedArrays = availableTypedArrays();
45791
46007
 
45792
46008
  var $slice = callBound('String.prototype.slice');
45793
46009
 
46010
+ /** @import { BoundSet, BoundSlice, Cache, Getter } from './types' */
46011
+ /** @import { TypedArrayName } from '.' */
46012
+
45794
46013
  /** @type {<T = unknown>(array: readonly T[], value: unknown) => number} */
45795
46014
  var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) {
45796
46015
  for (var i = 0; i < array.length; i += 1) {
@@ -45801,8 +46020,7 @@ var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(ar
45801
46020
  return -1;
45802
46021
  };
45803
46022
 
45804
- /** @typedef {import('./types').Getter} Getter */
45805
- /** @type {import('./types').Cache} */
46023
+ /** @type {Cache} */
45806
46024
  var cache = { __proto__: null };
45807
46025
  if (hasToStringTag && gOPD && getProto) {
45808
46026
  forEach(typedArrays, function (typedArray) {
@@ -45819,7 +46037,8 @@ if (hasToStringTag && gOPD && getProto) {
45819
46037
  if (descriptor && descriptor.get) {
45820
46038
  var bound = callBind(descriptor.get);
45821
46039
  cache[
45822
- /** @type {`$${import('.').TypedArrayName}`} */ ('$' + typedArray)
46040
+ /** @type {`$${TypedArrayName}`} */
46041
+ ('$' + typedArray)
45823
46042
  ] = bound;
45824
46043
  }
45825
46044
  }
@@ -45829,62 +46048,72 @@ if (hasToStringTag && gOPD && getProto) {
45829
46048
  var arr = new g[typedArray]();
45830
46049
  var fn = arr.slice || arr.set;
45831
46050
  if (fn) {
45832
- var bound = /** @type {import('./types').BoundSlice | import('./types').BoundSet} */ (
46051
+ var bound = /** @type {BoundSlice | BoundSet} */ (
45833
46052
  // @ts-expect-error TODO FIXME
45834
46053
  callBind(fn)
45835
46054
  );
45836
46055
  cache[
45837
- /** @type {`$${import('.').TypedArrayName}`} */ ('$' + typedArray)
46056
+ /** @type {`$${TypedArrayName}`} */
46057
+ ('$' + typedArray)
45838
46058
  ] = bound;
45839
46059
  }
45840
46060
  });
45841
46061
  }
45842
46062
 
45843
- /** @type {(value: object) => false | import('.').TypedArrayName} */
45844
- var tryTypedArrays = function tryAllTypedArrays(value) {
45845
- /** @type {ReturnType<typeof tryAllTypedArrays>} */ var found = false;
46063
+ /** @type {(value: object) => false | TypedArrayName} */
46064
+ function tryTypedArrays(value) {
46065
+ /** @type {ReturnType<typeof tryTypedArrays>} */ var found = false;
45846
46066
  forEach(
45847
- /** @type {Record<`\$${import('.').TypedArrayName}`, Getter>} */ (cache),
45848
- /** @type {(getter: Getter, name: `\$${import('.').TypedArrayName}`) => void} */
46067
+ /** @type {Record<`$${TypedArrayName}`, Getter>} */ (cache),
46068
+ /** @param {Getter} getter @param {`$${TypedArrayName}`} typedArray */
45849
46069
  function (getter, typedArray) {
45850
46070
  if (!found) {
45851
46071
  try {
45852
46072
  // @ts-expect-error a throw is fine here
45853
46073
  if ('$' + getter(value) === typedArray) {
45854
- found = /** @type {import('.').TypedArrayName} */ ($slice(typedArray, 1));
46074
+ found = /** @type {TypedArrayName} */ ($slice(typedArray, 1));
45855
46075
  }
45856
46076
  } catch (e) { /**/ }
45857
46077
  }
45858
46078
  }
45859
46079
  );
45860
46080
  return found;
45861
- };
46081
+ }
45862
46082
 
45863
- /** @type {(value: object) => false | import('.').TypedArrayName} */
45864
- var trySlices = function tryAllSlices(value) {
45865
- /** @type {ReturnType<typeof tryAllSlices>} */ var found = false;
46083
+ /** @type {(value: object) => false | TypedArrayName} */
46084
+ function trySlices(value) {
46085
+ /** @type {ReturnType<typeof trySlices>} */ var found = false;
45866
46086
  forEach(
45867
- /** @type {Record<`\$${import('.').TypedArrayName}`, Getter>} */(cache),
45868
- /** @type {(getter: Getter, name: `\$${import('.').TypedArrayName}`) => void} */ function (getter, name) {
46087
+ /** @type {Record<`$${TypedArrayName}`, Getter>} */(cache),
46088
+ /** @param {Getter} getter @param {`$${TypedArrayName}`} name */ function (getter, name) {
45869
46089
  if (!found) {
45870
46090
  try {
45871
46091
  // @ts-expect-error a throw is fine here
45872
46092
  getter(value);
45873
- found = /** @type {import('.').TypedArrayName} */ ($slice(name, 1));
46093
+ found = /** @type {TypedArrayName} */ ($slice(name, 1));
45874
46094
  } catch (e) { /**/ }
45875
46095
  }
45876
46096
  }
45877
46097
  );
45878
46098
  return found;
45879
- };
46099
+ }
45880
46100
 
45881
- /** @type {import('.')} */
46101
+ /** @type {(tag: unknown) => tag is typeof typedArrays[number]} */
46102
+ function isTATag(tag) {
46103
+ return $indexOf(typedArrays, tag) > -1;
46104
+ }
46105
+
46106
+ /**
46107
+ * @type {import('.')}
46108
+ * @param {unknown} value
46109
+ */
45882
46110
  module.exports = function whichTypedArray(value) {
45883
- if (!value || typeof value !== 'object') { return false; }
46111
+ if (!value || typeof value !== 'object') {
46112
+ return false;
46113
+ }
45884
46114
  if (!hasToStringTag) {
45885
- /** @type {string} */
45886
46115
  var tag = $slice($toString(value), 8, -1);
45887
- if ($indexOf(typedArrays, tag) > -1) {
46116
+ if (isTATag(tag)) {
45888
46117
  return tag;
45889
46118
  }
45890
46119
  if (tag !== 'Object') {
@@ -45900,7 +46129,7 @@ module.exports = function whichTypedArray(value) {
45900
46129
 
45901
46130
  /***/ },
45902
46131
 
45903
- /***/ 7286
46132
+ /***/ 1438
45904
46133
  (module, exports, __webpack_require__) {
45905
46134
 
45906
46135
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(a,b){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (b),
@@ -45927,13 +46156,6 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
45927
46156
 
45928
46157
  /***/ },
45929
46158
 
45930
- /***/ 5470
45931
- () {
45932
-
45933
- /* (ignored) */
45934
-
45935
- /***/ },
45936
-
45937
46159
  /***/ 3779
45938
46160
  () {
45939
46161