@embedpdf/models 1.0.11 → 1.0.13

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.js CHANGED
@@ -1,4 +1,3 @@
1
- // src/geometry.ts
2
1
  var Rotation = /* @__PURE__ */ ((Rotation2) => {
3
2
  Rotation2[Rotation2["Degree0"] = 0] = "Degree0";
4
3
  Rotation2[Rotation2["Degree90"] = 1] = "Degree90";
@@ -20,13 +19,13 @@ function toIntRect(r) {
20
19
  }
21
20
  function calculateDegree(rotation) {
22
21
  switch (rotation) {
23
- case 0 /* Degree0 */:
22
+ case 0:
24
23
  return 0;
25
- case 1 /* Degree90 */:
24
+ case 1:
26
25
  return 90;
27
- case 2 /* Degree180 */:
26
+ case 2:
28
27
  return 180;
29
- case 3 /* Degree270 */:
28
+ case 3:
30
29
  return 270;
31
30
  }
32
31
  }
@@ -70,19 +69,19 @@ function rotatePosition(containerSize, position, rotation) {
70
69
  let x = position.x;
71
70
  let y = position.y;
72
71
  switch (rotation) {
73
- case 0 /* Degree0 */:
72
+ case 0:
74
73
  x = position.x;
75
74
  y = position.y;
76
75
  break;
77
- case 1 /* Degree90 */:
76
+ case 1:
78
77
  x = containerSize.height - position.y;
79
78
  y = position.x;
80
79
  break;
81
- case 2 /* Degree180 */:
80
+ case 2:
82
81
  x = containerSize.width - position.x;
83
82
  y = containerSize.height - position.y;
84
83
  break;
85
- case 3 /* Degree270 */:
84
+ case 3:
86
85
  x = position.y;
87
86
  y = containerSize.width - position.x;
88
87
  break;
@@ -107,23 +106,58 @@ function restorePosition(containerSize, position, rotation, scaleFactor) {
107
106
  1 / scaleFactor
108
107
  );
109
108
  }
109
+ function rectEquals(a, b) {
110
+ return a.origin.x === b.origin.x && a.origin.y === b.origin.y && a.size.width === b.size.width && a.size.height === b.size.height;
111
+ }
112
+ function rectFromPoints(positions) {
113
+ if (positions.length === 0) {
114
+ return { origin: { x: 0, y: 0 }, size: { width: 0, height: 0 } };
115
+ }
116
+ const xs = positions.map((p) => p.x);
117
+ const ys = positions.map((p) => p.y);
118
+ const minX = Math.min(...xs);
119
+ const minY = Math.min(...ys);
120
+ return {
121
+ origin: { x: minX, y: minY },
122
+ size: {
123
+ width: Math.max(...xs) - minX,
124
+ height: Math.max(...ys) - minY
125
+ }
126
+ };
127
+ }
128
+ function rotateAndTranslatePoint(pos, angleRad, translate) {
129
+ const cos = Math.cos(angleRad);
130
+ const sin = Math.sin(angleRad);
131
+ const newX = pos.x * cos - pos.y * sin;
132
+ const newY = pos.x * sin + pos.y * cos;
133
+ return {
134
+ x: newX + translate.x,
135
+ y: newY + translate.y
136
+ };
137
+ }
138
+ function expandRect(rect, padding) {
139
+ return {
140
+ origin: { x: rect.origin.x - padding, y: rect.origin.y - padding },
141
+ size: { width: rect.size.width + padding * 2, height: rect.size.height + padding * 2 }
142
+ };
143
+ }
110
144
  function rotateRect(containerSize, rect, rotation) {
111
145
  let x = rect.origin.x;
112
146
  let y = rect.origin.y;
113
147
  let size = rect.size;
114
148
  switch (rotation) {
115
- case 0 /* Degree0 */:
149
+ case 0:
116
150
  break;
117
- case 1 /* Degree90 */:
151
+ case 1:
118
152
  x = containerSize.height - rect.origin.y - rect.size.height;
119
153
  y = rect.origin.x;
120
154
  size = swap(rect.size);
121
155
  break;
122
- case 2 /* Degree180 */:
156
+ case 2:
123
157
  x = containerSize.width - rect.origin.x - rect.size.width;
124
158
  y = containerSize.height - rect.origin.y - rect.size.height;
125
159
  break;
126
- case 3 /* Degree270 */:
160
+ case 3:
127
161
  x = rect.origin.y;
128
162
  y = containerSize.width - rect.origin.x - rect.size.width;
129
163
  size = swap(rect.size);
@@ -162,19 +196,19 @@ function restoreOffset(offset, rotation, scaleFactor) {
162
196
  let offsetX = offset.x;
163
197
  let offsetY = offset.y;
164
198
  switch (rotation) {
165
- case 0 /* Degree0 */:
199
+ case 0:
166
200
  offsetX = offset.x / scaleFactor;
167
201
  offsetY = offset.y / scaleFactor;
168
202
  break;
169
- case 1 /* Degree90 */:
203
+ case 1:
170
204
  offsetX = offset.y / scaleFactor;
171
205
  offsetY = -offset.x / scaleFactor;
172
206
  break;
173
- case 2 /* Degree180 */:
207
+ case 2:
174
208
  offsetX = -offset.x / scaleFactor;
175
209
  offsetY = -offset.y / scaleFactor;
176
210
  break;
177
- case 3 /* Degree270 */:
211
+ case 3:
178
212
  offsetX = -offset.y / scaleFactor;
179
213
  offsetY = offset.x / scaleFactor;
180
214
  break;
@@ -204,10 +238,10 @@ function boundingRect(rects) {
204
238
  }
205
239
  };
206
240
  }
207
- var makeMatrix = (rectangle, rotation, scaleFactor) => {
241
+ const makeMatrix = (rectangle, rotation, scaleFactor) => {
208
242
  const { width, height } = rectangle.size;
209
243
  switch (rotation) {
210
- case 0 /* Degree0 */:
244
+ case 0:
211
245
  return {
212
246
  a: scaleFactor,
213
247
  b: 0,
@@ -216,7 +250,7 @@ var makeMatrix = (rectangle, rotation, scaleFactor) => {
216
250
  e: 0,
217
251
  f: height * scaleFactor
218
252
  };
219
- case 1 /* Degree90 */:
253
+ case 1:
220
254
  return {
221
255
  a: 0,
222
256
  b: scaleFactor,
@@ -225,7 +259,7 @@ var makeMatrix = (rectangle, rotation, scaleFactor) => {
225
259
  e: 0,
226
260
  f: 0
227
261
  };
228
- case 2 /* Degree180 */:
262
+ case 2:
229
263
  return {
230
264
  a: -scaleFactor,
231
265
  b: 0,
@@ -234,7 +268,7 @@ var makeMatrix = (rectangle, rotation, scaleFactor) => {
234
268
  e: width * scaleFactor,
235
269
  f: 0
236
270
  };
237
- case 3 /* Degree270 */:
271
+ case 3:
238
272
  return {
239
273
  a: 0,
240
274
  b: -scaleFactor,
@@ -245,9 +279,7 @@ var makeMatrix = (rectangle, rotation, scaleFactor) => {
245
279
  };
246
280
  }
247
281
  };
248
-
249
- // src/logger.ts
250
- var NoopLogger = class {
282
+ class NoopLogger {
251
283
  /** {@inheritDoc Logger.debug} */
252
284
  debug() {
253
285
  }
@@ -263,8 +295,8 @@ var NoopLogger = class {
263
295
  /** {@inheritDoc Logger.perf} */
264
296
  perf() {
265
297
  }
266
- };
267
- var ConsoleLogger = class {
298
+ }
299
+ class ConsoleLogger {
268
300
  /** {@inheritDoc Logger.debug} */
269
301
  debug(source, category, ...args) {
270
302
  console.debug(`${source}.${category}`, ...args);
@@ -285,7 +317,7 @@ var ConsoleLogger = class {
285
317
  perf(source, category, event, phase, ...args) {
286
318
  console.info(`${source}.${category}.${event}.${phase}`, ...args);
287
319
  }
288
- };
320
+ }
289
321
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
290
322
  LogLevel2[LogLevel2["Debug"] = 0] = "Debug";
291
323
  LogLevel2[LogLevel2["Info"] = 1] = "Info";
@@ -293,7 +325,7 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
293
325
  LogLevel2[LogLevel2["Error"] = 3] = "Error";
294
326
  return LogLevel2;
295
327
  })(LogLevel || {});
296
- var LevelLogger = class {
328
+ class LevelLogger {
297
329
  /**
298
330
  * create new LevelLogger
299
331
  * @param logger - the original logger
@@ -305,25 +337,25 @@ var LevelLogger = class {
305
337
  }
306
338
  /** {@inheritDoc Logger.debug} */
307
339
  debug(source, category, ...args) {
308
- if (this.level <= 0 /* Debug */) {
340
+ if (this.level <= 0) {
309
341
  this.logger.debug(source, category, ...args);
310
342
  }
311
343
  }
312
344
  /** {@inheritDoc Logger.info} */
313
345
  info(source, category, ...args) {
314
- if (this.level <= 1 /* Info */) {
346
+ if (this.level <= 1) {
315
347
  this.logger.info(source, category, ...args);
316
348
  }
317
349
  }
318
350
  /** {@inheritDoc Logger.warn} */
319
351
  warn(source, category, ...args) {
320
- if (this.level <= 2 /* Warn */) {
352
+ if (this.level <= 2) {
321
353
  this.logger.warn(source, category, ...args);
322
354
  }
323
355
  }
324
356
  /** {@inheritDoc Logger.error} */
325
357
  error(source, category, ...args) {
326
- if (this.level <= 3 /* Error */) {
358
+ if (this.level <= 3) {
327
359
  this.logger.error(source, category, ...args);
328
360
  }
329
361
  }
@@ -331,8 +363,8 @@ var LevelLogger = class {
331
363
  perf(source, category, event, phase, ...args) {
332
364
  this.logger.perf(source, category, event, phase, ...args);
333
365
  }
334
- };
335
- var PerfLogger = class {
366
+ }
367
+ class PerfLogger {
336
368
  /**
337
369
  * create new PerfLogger
338
370
  */
@@ -370,8 +402,8 @@ var PerfLogger = class {
370
402
  break;
371
403
  }
372
404
  }
373
- };
374
- var AllLogger = class {
405
+ }
406
+ class AllLogger {
375
407
  /**
376
408
  * create new PerfLogger
377
409
  */
@@ -408,9 +440,7 @@ var AllLogger = class {
408
440
  logger.perf(source, category, event, phase, ...args);
409
441
  }
410
442
  }
411
- };
412
-
413
- // src/task.ts
443
+ }
414
444
  var TaskStage = /* @__PURE__ */ ((TaskStage2) => {
415
445
  TaskStage2[TaskStage2["Pending"] = 0] = "Pending";
416
446
  TaskStage2[TaskStage2["Resolved"] = 1] = "Resolved";
@@ -418,34 +448,26 @@ var TaskStage = /* @__PURE__ */ ((TaskStage2) => {
418
448
  TaskStage2[TaskStage2["Aborted"] = 3] = "Aborted";
419
449
  return TaskStage2;
420
450
  })(TaskStage || {});
421
- var TaskAbortedError = class extends Error {
451
+ class TaskAbortedError extends Error {
422
452
  constructor(reason) {
423
453
  super(`Task aborted: ${JSON.stringify(reason)}`);
424
454
  this.name = "TaskAbortedError";
425
455
  }
426
- };
427
- var TaskRejectedError = class extends Error {
456
+ }
457
+ class TaskRejectedError extends Error {
428
458
  constructor(reason) {
429
459
  super(`Task rejected: ${JSON.stringify(reason)}`);
430
460
  this.name = "TaskRejectedError";
431
461
  }
432
- };
433
- var Task = class _Task {
462
+ }
463
+ class Task {
434
464
  constructor() {
435
465
  this.state = {
436
- stage: 0 /* Pending */
466
+ stage: 0
467
+ /* Pending */
437
468
  };
438
- /**
439
- * callbacks that will be executed when task is resolved
440
- */
441
469
  this.resolvedCallbacks = [];
442
- /**
443
- * callbacks that will be executed when task is rejected
444
- */
445
470
  this.rejectedCallbacks = [];
446
- /**
447
- * Promise that will be resolved when task is settled
448
- */
449
471
  this._promise = null;
450
472
  }
451
473
  /**
@@ -476,20 +498,20 @@ var Task = class _Task {
476
498
  */
477
499
  wait(resolvedCallback, rejectedCallback) {
478
500
  switch (this.state.stage) {
479
- case 0 /* Pending */:
501
+ case 0:
480
502
  this.resolvedCallbacks.push(resolvedCallback);
481
503
  this.rejectedCallbacks.push(rejectedCallback);
482
504
  break;
483
- case 1 /* Resolved */:
505
+ case 1:
484
506
  resolvedCallback(this.state.result);
485
507
  break;
486
- case 2 /* Rejected */:
508
+ case 2:
487
509
  rejectedCallback({
488
510
  type: "reject",
489
511
  reason: this.state.reason
490
512
  });
491
513
  break;
492
- case 3 /* Aborted */:
514
+ case 3:
493
515
  rejectedCallback({
494
516
  type: "abort",
495
517
  reason: this.state.reason
@@ -502,9 +524,9 @@ var Task = class _Task {
502
524
  * @param result - result value
503
525
  */
504
526
  resolve(result) {
505
- if (this.state.stage === 0 /* Pending */) {
527
+ if (this.state.stage === 0) {
506
528
  this.state = {
507
- stage: 1 /* Resolved */,
529
+ stage: 1,
508
530
  result
509
531
  };
510
532
  for (const resolvedCallback of this.resolvedCallbacks) {
@@ -523,9 +545,9 @@ var Task = class _Task {
523
545
  *
524
546
  */
525
547
  reject(reason) {
526
- if (this.state.stage === 0 /* Pending */) {
548
+ if (this.state.stage === 0) {
527
549
  this.state = {
528
- stage: 2 /* Rejected */,
550
+ stage: 2,
529
551
  reason
530
552
  };
531
553
  for (const rejectedCallback of this.rejectedCallbacks) {
@@ -546,9 +568,9 @@ var Task = class _Task {
546
568
  * @param reason - abort reason
547
569
  */
548
570
  abort(reason) {
549
- if (this.state.stage === 0 /* Pending */) {
571
+ if (this.state.stage === 0) {
550
572
  this.state = {
551
- stage: 3 /* Aborted */,
573
+ stage: 3,
552
574
  reason
553
575
  };
554
576
  for (const rejectedCallback of this.rejectedCallbacks) {
@@ -586,7 +608,7 @@ var Task = class _Task {
586
608
  * @public
587
609
  */
588
610
  static all(tasks) {
589
- const combinedTask = new _Task();
611
+ const combinedTask = new Task();
590
612
  if (tasks.length === 0) {
591
613
  combinedTask.resolve([]);
592
614
  return combinedTask;
@@ -627,7 +649,7 @@ var Task = class _Task {
627
649
  * @public
628
650
  */
629
651
  static allSettled(tasks) {
630
- const combinedTask = new _Task();
652
+ const combinedTask = new Task();
631
653
  if (tasks.length === 0) {
632
654
  combinedTask.resolve([]);
633
655
  return combinedTask;
@@ -665,7 +687,7 @@ var Task = class _Task {
665
687
  * @public
666
688
  */
667
689
  static race(tasks) {
668
- const combinedTask = new _Task();
690
+ const combinedTask = new Task();
669
691
  if (tasks.length === 0) {
670
692
  combinedTask.reject("No tasks provided");
671
693
  return combinedTask;
@@ -700,7 +722,7 @@ var Task = class _Task {
700
722
  * @public
701
723
  */
702
724
  static withProgress(tasks, onProgress) {
703
- const combinedTask = _Task.all(tasks);
725
+ const combinedTask = Task.all(tasks);
704
726
  if (onProgress) {
705
727
  let completedCount = 0;
706
728
  tasks.forEach((task) => {
@@ -718,16 +740,14 @@ var Task = class _Task {
718
740
  }
719
741
  return combinedTask;
720
742
  }
721
- };
722
-
723
- // src/pdf.ts
724
- var PdfSoftHyphenMarker = "\xAD";
725
- var PdfZeroWidthSpace = "\u200B";
726
- var PdfWordJoiner = "\u2060";
727
- var PdfBomOrZwnbsp = "\uFEFF";
728
- var PdfNonCharacterFFFE = "\uFFFE";
729
- var PdfNonCharacterFFFF = "\uFFFF";
730
- var PdfUnwantedTextMarkers = Object.freeze([
743
+ }
744
+ const PdfSoftHyphenMarker = "­";
745
+ const PdfZeroWidthSpace = "​";
746
+ const PdfWordJoiner = "";
747
+ const PdfBomOrZwnbsp = "\uFEFF";
748
+ const PdfNonCharacterFFFE = "";
749
+ const PdfNonCharacterFFFF = "￿";
750
+ const PdfUnwantedTextMarkers = Object.freeze([
731
751
  PdfSoftHyphenMarker,
732
752
  PdfZeroWidthSpace,
733
753
  PdfWordJoiner,
@@ -735,7 +755,7 @@ var PdfUnwantedTextMarkers = Object.freeze([
735
755
  PdfNonCharacterFFFE,
736
756
  PdfNonCharacterFFFF
737
757
  ]);
738
- var PdfUnwantedTextRegex = new RegExp(`[${PdfUnwantedTextMarkers.join("")}]`, "g");
758
+ const PdfUnwantedTextRegex = new RegExp(`[${PdfUnwantedTextMarkers.join("")}]`, "g");
739
759
  function stripPdfUnwantedMarkers(text) {
740
760
  return text.replace(PdfUnwantedTextRegex, "");
741
761
  }
@@ -748,6 +768,85 @@ var PdfZoomMode = /* @__PURE__ */ ((PdfZoomMode2) => {
748
768
  PdfZoomMode2[PdfZoomMode2["FitRectangle"] = 5] = "FitRectangle";
749
769
  return PdfZoomMode2;
750
770
  })(PdfZoomMode || {});
771
+ var PdfBlendMode = /* @__PURE__ */ ((PdfBlendMode2) => {
772
+ PdfBlendMode2[PdfBlendMode2["Normal"] = 0] = "Normal";
773
+ PdfBlendMode2[PdfBlendMode2["Multiply"] = 1] = "Multiply";
774
+ PdfBlendMode2[PdfBlendMode2["Screen"] = 2] = "Screen";
775
+ PdfBlendMode2[PdfBlendMode2["Overlay"] = 3] = "Overlay";
776
+ PdfBlendMode2[PdfBlendMode2["Darken"] = 4] = "Darken";
777
+ PdfBlendMode2[PdfBlendMode2["Lighten"] = 5] = "Lighten";
778
+ PdfBlendMode2[PdfBlendMode2["ColorDodge"] = 6] = "ColorDodge";
779
+ PdfBlendMode2[PdfBlendMode2["ColorBurn"] = 7] = "ColorBurn";
780
+ PdfBlendMode2[PdfBlendMode2["HardLight"] = 8] = "HardLight";
781
+ PdfBlendMode2[PdfBlendMode2["SoftLight"] = 9] = "SoftLight";
782
+ PdfBlendMode2[PdfBlendMode2["Difference"] = 10] = "Difference";
783
+ PdfBlendMode2[PdfBlendMode2["Exclusion"] = 11] = "Exclusion";
784
+ PdfBlendMode2[PdfBlendMode2["Hue"] = 12] = "Hue";
785
+ PdfBlendMode2[PdfBlendMode2["Saturation"] = 13] = "Saturation";
786
+ PdfBlendMode2[PdfBlendMode2["Color"] = 14] = "Color";
787
+ PdfBlendMode2[PdfBlendMode2["Luminosity"] = 15] = "Luminosity";
788
+ return PdfBlendMode2;
789
+ })(PdfBlendMode || {});
790
+ const MixedBlendMode = Symbol("mixed");
791
+ const BLEND_MODE_INFOS = Object.freeze([
792
+ { id: 0, label: "Normal", css: "normal" },
793
+ { id: 1, label: "Multiply", css: "multiply" },
794
+ { id: 2, label: "Screen", css: "screen" },
795
+ { id: 3, label: "Overlay", css: "overlay" },
796
+ { id: 4, label: "Darken", css: "darken" },
797
+ { id: 5, label: "Lighten", css: "lighten" },
798
+ { id: 6, label: "Color Dodge", css: "color-dodge" },
799
+ { id: 7, label: "Color Burn", css: "color-burn" },
800
+ { id: 8, label: "Hard Light", css: "hard-light" },
801
+ { id: 9, label: "Soft Light", css: "soft-light" },
802
+ { id: 10, label: "Difference", css: "difference" },
803
+ { id: 11, label: "Exclusion", css: "exclusion" },
804
+ { id: 12, label: "Hue", css: "hue" },
805
+ { id: 13, label: "Saturation", css: "saturation" },
806
+ { id: 14, label: "Color", css: "color" },
807
+ { id: 15, label: "Luminosity", css: "luminosity" }
808
+ ]);
809
+ const enumToInfo = BLEND_MODE_INFOS.reduce(
810
+ (m, info) => {
811
+ m[info.id] = info;
812
+ return m;
813
+ },
814
+ {}
815
+ );
816
+ const cssToEnum = BLEND_MODE_INFOS.reduce(
817
+ (m, info) => {
818
+ m[info.css] = info.id;
819
+ return m;
820
+ },
821
+ {}
822
+ );
823
+ function getBlendModeInfo(mode) {
824
+ return enumToInfo[mode] ?? enumToInfo[
825
+ 0
826
+ /* Normal */
827
+ ];
828
+ }
829
+ function blendModeToCss(mode) {
830
+ return getBlendModeInfo(mode).css;
831
+ }
832
+ function cssToBlendMode(value) {
833
+ return cssToEnum[value];
834
+ }
835
+ function blendModeLabel(mode) {
836
+ return getBlendModeInfo(mode).label;
837
+ }
838
+ function reduceBlendModes(modes) {
839
+ if (!modes.length) return 0;
840
+ const first = modes[0];
841
+ return modes.every((m) => m === first) ? first : MixedBlendMode;
842
+ }
843
+ const blendModeSelectOptions = BLEND_MODE_INFOS.map((info) => ({
844
+ value: info.id,
845
+ label: info.label
846
+ }));
847
+ function uiBlendModeDisplay(value) {
848
+ return value === MixedBlendMode ? "(mixed)" : blendModeLabel(value);
849
+ }
751
850
  var PdfActionType = /* @__PURE__ */ ((PdfActionType2) => {
752
851
  PdfActionType2[PdfActionType2["Unsupported"] = 0] = "Unsupported";
753
852
  PdfActionType2[PdfActionType2["Goto"] = 1] = "Goto";
@@ -788,36 +887,123 @@ var PdfAnnotationSubtype = /* @__PURE__ */ ((PdfAnnotationSubtype2) => {
788
887
  PdfAnnotationSubtype2[PdfAnnotationSubtype2["REDACT"] = 28] = "REDACT";
789
888
  return PdfAnnotationSubtype2;
790
889
  })(PdfAnnotationSubtype || {});
791
- var PdfAnnotationSubtypeName = {
792
- [0 /* UNKNOWN */]: "unknow",
793
- [1 /* TEXT */]: "text",
794
- [2 /* LINK */]: "link",
795
- [3 /* FREETEXT */]: "freetext",
796
- [4 /* LINE */]: "line",
797
- [5 /* SQUARE */]: "square",
798
- [6 /* CIRCLE */]: "circle",
799
- [7 /* POLYGON */]: "polygon",
800
- [8 /* POLYLINE */]: "polyline",
801
- [9 /* HIGHLIGHT */]: "highlight",
802
- [10 /* UNDERLINE */]: "underline",
803
- [11 /* SQUIGGLY */]: "squiggly",
804
- [12 /* STRIKEOUT */]: "strikeout",
805
- [13 /* STAMP */]: "stamp",
806
- [14 /* CARET */]: "caret",
807
- [15 /* INK */]: "ink",
808
- [16 /* POPUP */]: "popup",
809
- [17 /* FILEATTACHMENT */]: "fileattachment",
810
- [18 /* SOUND */]: "sound",
811
- [19 /* MOVIE */]: "movie",
812
- [20 /* WIDGET */]: "widget",
813
- [21 /* SCREEN */]: "screen",
814
- [22 /* PRINTERMARK */]: "printermark",
815
- [23 /* TRAPNET */]: "trapnet",
816
- [24 /* WATERMARK */]: "watermark",
817
- [25 /* THREED */]: "threed",
818
- [26 /* RICHMEDIA */]: "richmedia",
819
- [27 /* XFAWIDGET */]: "xfawidget",
820
- [28 /* REDACT */]: "redact"
890
+ const PdfAnnotationSubtypeName = {
891
+ [
892
+ 0
893
+ /* UNKNOWN */
894
+ ]: "unknow",
895
+ [
896
+ 1
897
+ /* TEXT */
898
+ ]: "text",
899
+ [
900
+ 2
901
+ /* LINK */
902
+ ]: "link",
903
+ [
904
+ 3
905
+ /* FREETEXT */
906
+ ]: "freetext",
907
+ [
908
+ 4
909
+ /* LINE */
910
+ ]: "line",
911
+ [
912
+ 5
913
+ /* SQUARE */
914
+ ]: "square",
915
+ [
916
+ 6
917
+ /* CIRCLE */
918
+ ]: "circle",
919
+ [
920
+ 7
921
+ /* POLYGON */
922
+ ]: "polygon",
923
+ [
924
+ 8
925
+ /* POLYLINE */
926
+ ]: "polyline",
927
+ [
928
+ 9
929
+ /* HIGHLIGHT */
930
+ ]: "highlight",
931
+ [
932
+ 10
933
+ /* UNDERLINE */
934
+ ]: "underline",
935
+ [
936
+ 11
937
+ /* SQUIGGLY */
938
+ ]: "squiggly",
939
+ [
940
+ 12
941
+ /* STRIKEOUT */
942
+ ]: "strikeout",
943
+ [
944
+ 13
945
+ /* STAMP */
946
+ ]: "stamp",
947
+ [
948
+ 14
949
+ /* CARET */
950
+ ]: "caret",
951
+ [
952
+ 15
953
+ /* INK */
954
+ ]: "ink",
955
+ [
956
+ 16
957
+ /* POPUP */
958
+ ]: "popup",
959
+ [
960
+ 17
961
+ /* FILEATTACHMENT */
962
+ ]: "fileattachment",
963
+ [
964
+ 18
965
+ /* SOUND */
966
+ ]: "sound",
967
+ [
968
+ 19
969
+ /* MOVIE */
970
+ ]: "movie",
971
+ [
972
+ 20
973
+ /* WIDGET */
974
+ ]: "widget",
975
+ [
976
+ 21
977
+ /* SCREEN */
978
+ ]: "screen",
979
+ [
980
+ 22
981
+ /* PRINTERMARK */
982
+ ]: "printermark",
983
+ [
984
+ 23
985
+ /* TRAPNET */
986
+ ]: "trapnet",
987
+ [
988
+ 24
989
+ /* WATERMARK */
990
+ ]: "watermark",
991
+ [
992
+ 25
993
+ /* THREED */
994
+ ]: "threed",
995
+ [
996
+ 26
997
+ /* RICHMEDIA */
998
+ ]: "richmedia",
999
+ [
1000
+ 27
1001
+ /* XFAWIDGET */
1002
+ ]: "xfawidget",
1003
+ [
1004
+ 28
1005
+ /* REDACT */
1006
+ ]: "redact"
821
1007
  };
822
1008
  var PdfAnnotationObjectStatus = /* @__PURE__ */ ((PdfAnnotationObjectStatus2) => {
823
1009
  PdfAnnotationObjectStatus2[PdfAnnotationObjectStatus2["Created"] = 0] = "Created";
@@ -845,6 +1031,20 @@ var PdfAnnotationStateModel = /* @__PURE__ */ ((PdfAnnotationStateModel2) => {
845
1031
  PdfAnnotationStateModel2["Reviewed"] = "Reviewed";
846
1032
  return PdfAnnotationStateModel2;
847
1033
  })(PdfAnnotationStateModel || {});
1034
+ var PdfAnnotationLineEnding = /* @__PURE__ */ ((PdfAnnotationLineEnding2) => {
1035
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["None"] = 0] = "None";
1036
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Square"] = 1] = "Square";
1037
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Circle"] = 2] = "Circle";
1038
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Diamond"] = 3] = "Diamond";
1039
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["OpenArrow"] = 4] = "OpenArrow";
1040
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["ClosedArrow"] = 5] = "ClosedArrow";
1041
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Butt"] = 6] = "Butt";
1042
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["ROpenArrow"] = 7] = "ROpenArrow";
1043
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["RClosedArrow"] = 8] = "RClosedArrow";
1044
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Slash"] = 9] = "Slash";
1045
+ PdfAnnotationLineEnding2[PdfAnnotationLineEnding2["Unknown"] = 10] = "Unknown";
1046
+ return PdfAnnotationLineEnding2;
1047
+ })(PdfAnnotationLineEnding || {});
848
1048
  var PDF_FORM_FIELD_TYPE = /* @__PURE__ */ ((PDF_FORM_FIELD_TYPE2) => {
849
1049
  PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["UNKNOWN"] = 0] = "UNKNOWN";
850
1050
  PDF_FORM_FIELD_TYPE2[PDF_FORM_FIELD_TYPE2["PUSHBUTTON"] = 1] = "PUSHBUTTON";
@@ -913,18 +1113,45 @@ var PdfPageObjectType = /* @__PURE__ */ ((PdfPageObjectType2) => {
913
1113
  PdfPageObjectType2[PdfPageObjectType2["FORM"] = 5] = "FORM";
914
1114
  return PdfPageObjectType2;
915
1115
  })(PdfPageObjectType || {});
916
- var PdfAnnotationFlagName = Object.freeze({
917
- [1 /* INVISIBLE */]: "invisible",
918
- [2 /* HIDDEN */]: "hidden",
919
- [4 /* PRINT */]: "print",
920
- [8 /* NO_ZOOM */]: "noZoom",
921
- [16 /* NO_ROTATE */]: "noRotate",
922
- [32 /* NO_VIEW */]: "noView",
923
- [64 /* READ_ONLY */]: "readOnly",
924
- [128 /* LOCKED */]: "locked",
925
- [256 /* TOGGLE_NOVIEW */]: "toggleNoView"
1116
+ const PdfAnnotationFlagName = Object.freeze({
1117
+ [
1118
+ 1
1119
+ /* INVISIBLE */
1120
+ ]: "invisible",
1121
+ [
1122
+ 2
1123
+ /* HIDDEN */
1124
+ ]: "hidden",
1125
+ [
1126
+ 4
1127
+ /* PRINT */
1128
+ ]: "print",
1129
+ [
1130
+ 8
1131
+ /* NO_ZOOM */
1132
+ ]: "noZoom",
1133
+ [
1134
+ 16
1135
+ /* NO_ROTATE */
1136
+ ]: "noRotate",
1137
+ [
1138
+ 32
1139
+ /* NO_VIEW */
1140
+ ]: "noView",
1141
+ [
1142
+ 64
1143
+ /* READ_ONLY */
1144
+ ]: "readOnly",
1145
+ [
1146
+ 128
1147
+ /* LOCKED */
1148
+ ]: "locked",
1149
+ [
1150
+ 256
1151
+ /* TOGGLE_NOVIEW */
1152
+ ]: "toggleNoView"
926
1153
  });
927
- var PdfAnnotationFlagValue = Object.entries(
1154
+ const PdfAnnotationFlagValue = Object.entries(
928
1155
  PdfAnnotationFlagName
929
1156
  ).reduce(
930
1157
  (acc, [bit, name]) => {
@@ -939,7 +1166,8 @@ function flagsToNames(raw) {
939
1166
  function namesToFlags(names) {
940
1167
  return names.reduce(
941
1168
  (mask, name) => mask | PdfAnnotationFlagValue[name],
942
- 0 /* NONE */
1169
+ 0
1170
+ /* NONE */
943
1171
  );
944
1172
  }
945
1173
  var PdfSegmentObjectType = /* @__PURE__ */ ((PdfSegmentObjectType2) => {
@@ -972,9 +1200,13 @@ var MatchFlag = /* @__PURE__ */ ((MatchFlag2) => {
972
1200
  return MatchFlag2;
973
1201
  })(MatchFlag || {});
974
1202
  function unionFlags(flags) {
975
- return flags.reduce((flag, currFlag) => {
976
- return flag | currFlag;
977
- }, 0 /* None */);
1203
+ return flags.reduce(
1204
+ (flag, currFlag) => {
1205
+ return flag | currFlag;
1206
+ },
1207
+ 0
1208
+ /* None */
1209
+ );
978
1210
  }
979
1211
  function compareSearchTarget(targetA, targetB) {
980
1212
  const flagA = unionFlags(targetA.flags);
@@ -1035,7 +1267,7 @@ var PdfErrorCode = /* @__PURE__ */ ((PdfErrorCode2) => {
1035
1267
  PdfErrorCode2[PdfErrorCode2["CantCheckField"] = 28] = "CantCheckField";
1036
1268
  return PdfErrorCode2;
1037
1269
  })(PdfErrorCode || {});
1038
- var PdfTaskHelper = class {
1270
+ class PdfTaskHelper {
1039
1271
  /**
1040
1272
  * Create a task
1041
1273
  * @returns new task
@@ -1073,9 +1305,7 @@ var PdfTaskHelper = class {
1073
1305
  task.reject(reason);
1074
1306
  return task;
1075
1307
  }
1076
- };
1077
-
1078
- // src/color.ts
1308
+ }
1079
1309
  function pdfAlphaColorToWebAlphaColor(c) {
1080
1310
  const clamp = (n) => Math.max(0, Math.min(255, n));
1081
1311
  const toHex = (n) => clamp(n).toString(16).padStart(2, "0");
@@ -1088,7 +1318,7 @@ function webAlphaColorToPdfAlphaColor({ color, opacity }) {
1088
1318
  color = color.replace(/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i, "#$1$1$2$2$3$3").toLowerCase();
1089
1319
  }
1090
1320
  const [, r, g, b] = /^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(color) ?? (() => {
1091
- throw new Error(`Invalid hex colour: \u201C${color}\u201D`);
1321
+ throw new Error(`Invalid hex colour: “${color}”`);
1092
1322
  })();
1093
1323
  const clamp = (n, hi = 255) => Math.max(0, Math.min(hi, n));
1094
1324
  return {
@@ -1098,10 +1328,8 @@ function webAlphaColorToPdfAlphaColor({ color, opacity }) {
1098
1328
  alpha: clamp(Math.round(opacity * 255))
1099
1329
  };
1100
1330
  }
1101
-
1102
- // src/date.ts
1103
1331
  function pdfDateToDate(pdf) {
1104
- if (!pdf?.startsWith("D:") || pdf.length < 16) return;
1332
+ if (!(pdf == null ? void 0 : pdf.startsWith("D:")) || pdf.length < 16) return;
1105
1333
  const y = +pdf.slice(2, 6);
1106
1334
  const mo = +pdf.slice(6, 8) - 1;
1107
1335
  const d = +pdf.slice(8, 10);
@@ -1120,8 +1348,6 @@ function dateToPdfDate(date = /* @__PURE__ */ new Date()) {
1120
1348
  const SS = z(date.getUTCSeconds());
1121
1349
  return `D:${YYYY}${MM}${DD}${HH}${mm}${SS}`;
1122
1350
  }
1123
-
1124
- // src/index.ts
1125
1351
  function ignore() {
1126
1352
  }
1127
1353
  export {
@@ -1131,6 +1357,7 @@ export {
1131
1357
  LevelLogger,
1132
1358
  LogLevel,
1133
1359
  MatchFlag,
1360
+ MixedBlendMode,
1134
1361
  NoopLogger,
1135
1362
  PDF_FORM_FIELD_FLAG,
1136
1363
  PDF_FORM_FIELD_TYPE,
@@ -1139,11 +1366,13 @@ export {
1139
1366
  PdfAnnotationColorType,
1140
1367
  PdfAnnotationFlagName,
1141
1368
  PdfAnnotationFlags,
1369
+ PdfAnnotationLineEnding,
1142
1370
  PdfAnnotationObjectStatus,
1143
1371
  PdfAnnotationState,
1144
1372
  PdfAnnotationStateModel,
1145
1373
  PdfAnnotationSubtype,
1146
1374
  PdfAnnotationSubtypeName,
1375
+ PdfBlendMode,
1147
1376
  PdfBomOrZwnbsp,
1148
1377
  PdfEngineFeature,
1149
1378
  PdfEngineOperation,
@@ -1168,22 +1397,32 @@ export {
1168
1397
  TaskAbortedError,
1169
1398
  TaskRejectedError,
1170
1399
  TaskStage,
1400
+ blendModeLabel,
1401
+ blendModeSelectOptions,
1402
+ blendModeToCss,
1171
1403
  boundingRect,
1172
1404
  calculateAngle,
1173
1405
  calculateDegree,
1174
1406
  compareSearchTarget,
1407
+ cssToBlendMode,
1175
1408
  dateToPdfDate,
1409
+ expandRect,
1176
1410
  flagsToNames,
1411
+ getBlendModeInfo,
1177
1412
  ignore,
1178
1413
  makeMatrix,
1179
1414
  namesToFlags,
1180
1415
  pdfAlphaColorToWebAlphaColor,
1181
1416
  pdfDateToDate,
1182
1417
  quadToRect,
1418
+ rectEquals,
1419
+ rectFromPoints,
1183
1420
  rectToQuad,
1421
+ reduceBlendModes,
1184
1422
  restoreOffset,
1185
1423
  restorePosition,
1186
1424
  restoreRect,
1425
+ rotateAndTranslatePoint,
1187
1426
  rotatePosition,
1188
1427
  rotateRect,
1189
1428
  scalePosition,
@@ -1196,7 +1435,8 @@ export {
1196
1435
  transformPosition,
1197
1436
  transformRect,
1198
1437
  transformSize,
1438
+ uiBlendModeDisplay,
1199
1439
  unionFlags,
1200
1440
  webAlphaColorToPdfAlphaColor
1201
1441
  };
1202
- //# sourceMappingURL=index.js.map
1442
+ //# sourceMappingURL=index.js.map