npm-pkg-hook 1.0.4 → 1.0.6

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.
@@ -0,0 +1,1201 @@
1
+ !(function (e, t) {
2
+ "object" == typeof exports && "object" == typeof module
3
+ ? (module.exports = t(require("react"), require("react-dom")))
4
+ : "function" == typeof define && define.amd
5
+ ? define("lib", ["react", "react-dom"], t)
6
+ : "object" == typeof exports
7
+ ? (exports.lib = t(require("react"), require("react-dom")))
8
+ : (e.lib = t(e.react, e["react-dom"]));
9
+ })("undefined" != typeof self ? self : this, function (e, t) {
10
+ return (function () {
11
+ "use strict";
12
+ var n = {
13
+ 655: function (e, t, n) {
14
+ n.r(t),
15
+ n.d(t, {
16
+ __assign: function () {
17
+ return i;
18
+ },
19
+ __asyncDelegator: function () {
20
+ return E;
21
+ },
22
+ __asyncGenerator: function () {
23
+ return x;
24
+ },
25
+ __asyncValues: function () {
26
+ return S;
27
+ },
28
+ __await: function () {
29
+ return O;
30
+ },
31
+ __awaiter: function () {
32
+ return h;
33
+ },
34
+ __classPrivateFieldGet: function () {
35
+ return k;
36
+ },
37
+ __classPrivateFieldIn: function () {
38
+ return R;
39
+ },
40
+ __classPrivateFieldSet: function () {
41
+ return M;
42
+ },
43
+ __createBinding: function () {
44
+ return g;
45
+ },
46
+ __decorate: function () {
47
+ return c;
48
+ },
49
+ __esDecorate: function () {
50
+ return u;
51
+ },
52
+ __exportStar: function () {
53
+ return b;
54
+ },
55
+ __extends: function () {
56
+ return o;
57
+ },
58
+ __generator: function () {
59
+ return y;
60
+ },
61
+ __importDefault: function () {
62
+ return C;
63
+ },
64
+ __importStar: function () {
65
+ return A;
66
+ },
67
+ __makeTemplateObject: function () {
68
+ return j;
69
+ },
70
+ __metadata: function () {
71
+ return p;
72
+ },
73
+ __param: function () {
74
+ return l;
75
+ },
76
+ __propKey: function () {
77
+ return f;
78
+ },
79
+ __read: function () {
80
+ return m;
81
+ },
82
+ __rest: function () {
83
+ return a;
84
+ },
85
+ __runInitializers: function () {
86
+ return s;
87
+ },
88
+ __setFunctionName: function () {
89
+ return d;
90
+ },
91
+ __spread: function () {
92
+ return w;
93
+ },
94
+ __spreadArray: function () {
95
+ return P;
96
+ },
97
+ __spreadArrays: function () {
98
+ return _;
99
+ },
100
+ __values: function () {
101
+ return v;
102
+ },
103
+ });
104
+ var r = function (e, t) {
105
+ return (
106
+ (r =
107
+ Object.setPrototypeOf ||
108
+ ({ __proto__: [] } instanceof Array &&
109
+ function (e, t) {
110
+ e.__proto__ = t;
111
+ }) ||
112
+ function (e, t) {
113
+ for (var n in t)
114
+ Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
115
+ }),
116
+ r(e, t)
117
+ );
118
+ };
119
+ function o(e, t) {
120
+ if ("function" != typeof t && null !== t)
121
+ throw new TypeError(
122
+ "Class extends value " +
123
+ String(t) +
124
+ " is not a constructor or null"
125
+ );
126
+ function n() {
127
+ this.constructor = e;
128
+ }
129
+ r(e, t),
130
+ (e.prototype =
131
+ null === t
132
+ ? Object.create(t)
133
+ : ((n.prototype = t.prototype), new n()));
134
+ }
135
+ var i = function () {
136
+ return (
137
+ (i =
138
+ Object.assign ||
139
+ function (e) {
140
+ for (var t, n = 1, r = arguments.length; n < r; n++)
141
+ for (var o in (t = arguments[n]))
142
+ Object.prototype.hasOwnProperty.call(t, o) &&
143
+ (e[o] = t[o]);
144
+ return e;
145
+ }),
146
+ i.apply(this, arguments)
147
+ );
148
+ };
149
+ function a(e, t) {
150
+ var n = {};
151
+ for (var r in e)
152
+ Object.prototype.hasOwnProperty.call(e, r) &&
153
+ t.indexOf(r) < 0 &&
154
+ (n[r] = e[r]);
155
+ if (
156
+ null != e &&
157
+ "function" == typeof Object.getOwnPropertySymbols
158
+ ) {
159
+ var o = 0;
160
+ for (r = Object.getOwnPropertySymbols(e); o < r.length; o++)
161
+ t.indexOf(r[o]) < 0 &&
162
+ Object.prototype.propertyIsEnumerable.call(e, r[o]) &&
163
+ (n[r[o]] = e[r[o]]);
164
+ }
165
+ return n;
166
+ }
167
+ function c(e, t, n, r) {
168
+ var o,
169
+ i = arguments.length,
170
+ a =
171
+ i < 3
172
+ ? t
173
+ : null === r
174
+ ? (r = Object.getOwnPropertyDescriptor(t, n))
175
+ : r;
176
+ if (
177
+ "object" == typeof Reflect &&
178
+ "function" == typeof Reflect.decorate
179
+ )
180
+ a = Reflect.decorate(e, t, n, r);
181
+ else
182
+ for (var c = e.length - 1; c >= 0; c--)
183
+ (o = e[c]) &&
184
+ (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
185
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
186
+ }
187
+ function l(e, t) {
188
+ return function (n, r) {
189
+ t(n, r, e);
190
+ };
191
+ }
192
+ function u(e, t, n, r, o, i) {
193
+ function a(e) {
194
+ if (void 0 !== e && "function" != typeof e)
195
+ throw new TypeError("Function expected");
196
+ return e;
197
+ }
198
+ for (
199
+ var c,
200
+ l = r.kind,
201
+ u = "getter" === l ? "get" : "setter" === l ? "set" : "value",
202
+ s = !t && e ? (r.static ? e : e.prototype) : null,
203
+ f = t || (s ? Object.getOwnPropertyDescriptor(s, r.name) : {}),
204
+ d = !1,
205
+ p = n.length - 1;
206
+ p >= 0;
207
+ p--
208
+ ) {
209
+ var h = {};
210
+ for (var y in r) h[y] = "access" === y ? {} : r[y];
211
+ for (var y in r.access) h.access[y] = r.access[y];
212
+ h.addInitializer = function (e) {
213
+ if (d)
214
+ throw new TypeError(
215
+ "Cannot add initializers after decoration has completed"
216
+ );
217
+ i.push(a(e || null));
218
+ };
219
+ var g = (0, n[p])(
220
+ "accessor" === l ? { get: f.get, set: f.set } : f[u],
221
+ h
222
+ );
223
+ if ("accessor" === l) {
224
+ if (void 0 === g) continue;
225
+ if (null === g || "object" != typeof g)
226
+ throw new TypeError("Object expected");
227
+ (c = a(g.get)) && (f.get = c),
228
+ (c = a(g.set)) && (f.set = c),
229
+ (c = a(g.init)) && o.push(c);
230
+ } else (c = a(g)) && ("field" === l ? o.push(c) : (f[u] = c));
231
+ }
232
+ s && Object.defineProperty(s, r.name, f), (d = !0);
233
+ }
234
+ function s(e, t, n) {
235
+ for (var r = arguments.length > 2, o = 0; o < t.length; o++)
236
+ n = r ? t[o].call(e, n) : t[o].call(e);
237
+ return r ? n : void 0;
238
+ }
239
+ function f(e) {
240
+ return "symbol" == typeof e ? e : "".concat(e);
241
+ }
242
+ function d(e, t, n) {
243
+ return (
244
+ "symbol" == typeof t &&
245
+ (t = t.description ? "[".concat(t.description, "]") : ""),
246
+ Object.defineProperty(e, "name", {
247
+ configurable: !0,
248
+ value: n ? "".concat(n, " ", t) : t,
249
+ })
250
+ );
251
+ }
252
+ function p(e, t) {
253
+ if (
254
+ "object" == typeof Reflect &&
255
+ "function" == typeof Reflect.metadata
256
+ )
257
+ return Reflect.metadata(e, t);
258
+ }
259
+ function h(e, t, n, r) {
260
+ return new (n || (n = Promise))(function (o, i) {
261
+ function a(e) {
262
+ try {
263
+ l(r.next(e));
264
+ } catch (e) {
265
+ i(e);
266
+ }
267
+ }
268
+ function c(e) {
269
+ try {
270
+ l(r.throw(e));
271
+ } catch (e) {
272
+ i(e);
273
+ }
274
+ }
275
+ function l(e) {
276
+ var t;
277
+ e.done
278
+ ? o(e.value)
279
+ : ((t = e.value),
280
+ t instanceof n
281
+ ? t
282
+ : new n(function (e) {
283
+ e(t);
284
+ })).then(a, c);
285
+ }
286
+ l((r = r.apply(e, t || [])).next());
287
+ });
288
+ }
289
+ function y(e, t) {
290
+ var n,
291
+ r,
292
+ o,
293
+ i,
294
+ a = {
295
+ label: 0,
296
+ sent: function () {
297
+ if (1 & o[0]) throw o[1];
298
+ return o[1];
299
+ },
300
+ trys: [],
301
+ ops: [],
302
+ };
303
+ return (
304
+ (i = { next: c(0), throw: c(1), return: c(2) }),
305
+ "function" == typeof Symbol &&
306
+ (i[Symbol.iterator] = function () {
307
+ return this;
308
+ }),
309
+ i
310
+ );
311
+ function c(c) {
312
+ return function (l) {
313
+ return (function (c) {
314
+ if (n) throw new TypeError("Generator is already executing.");
315
+ for (; i && ((i = 0), c[0] && (a = 0)), a; )
316
+ try {
317
+ if (
318
+ ((n = 1),
319
+ r &&
320
+ (o =
321
+ 2 & c[0]
322
+ ? r.return
323
+ : c[0]
324
+ ? r.throw || ((o = r.return) && o.call(r), 0)
325
+ : r.next) &&
326
+ !(o = o.call(r, c[1])).done)
327
+ )
328
+ return o;
329
+ switch (((r = 0), o && (c = [2 & c[0], o.value]), c[0])) {
330
+ case 0:
331
+ case 1:
332
+ o = c;
333
+ break;
334
+ case 4:
335
+ return a.label++, { value: c[1], done: !1 };
336
+ case 5:
337
+ a.label++, (r = c[1]), (c = [0]);
338
+ continue;
339
+ case 7:
340
+ (c = a.ops.pop()), a.trys.pop();
341
+ continue;
342
+ default:
343
+ if (
344
+ !(
345
+ (o =
346
+ (o = a.trys).length > 0 && o[o.length - 1]) ||
347
+ (6 !== c[0] && 2 !== c[0])
348
+ )
349
+ ) {
350
+ a = 0;
351
+ continue;
352
+ }
353
+ if (
354
+ 3 === c[0] &&
355
+ (!o || (c[1] > o[0] && c[1] < o[3]))
356
+ ) {
357
+ a.label = c[1];
358
+ break;
359
+ }
360
+ if (6 === c[0] && a.label < o[1]) {
361
+ (a.label = o[1]), (o = c);
362
+ break;
363
+ }
364
+ if (o && a.label < o[2]) {
365
+ (a.label = o[2]), a.ops.push(c);
366
+ break;
367
+ }
368
+ o[2] && a.ops.pop(), a.trys.pop();
369
+ continue;
370
+ }
371
+ c = t.call(e, a);
372
+ } catch (e) {
373
+ (c = [6, e]), (r = 0);
374
+ } finally {
375
+ n = o = 0;
376
+ }
377
+ if (5 & c[0]) throw c[1];
378
+ return { value: c[0] ? c[1] : void 0, done: !0 };
379
+ })([c, l]);
380
+ };
381
+ }
382
+ }
383
+ var g = Object.create
384
+ ? function (e, t, n, r) {
385
+ void 0 === r && (r = n);
386
+ var o = Object.getOwnPropertyDescriptor(t, n);
387
+ (o &&
388
+ !("get" in o
389
+ ? !t.__esModule
390
+ : o.writable || o.configurable)) ||
391
+ (o = {
392
+ enumerable: !0,
393
+ get: function () {
394
+ return t[n];
395
+ },
396
+ }),
397
+ Object.defineProperty(e, r, o);
398
+ }
399
+ : function (e, t, n, r) {
400
+ void 0 === r && (r = n), (e[r] = t[n]);
401
+ };
402
+ function b(e, t) {
403
+ for (var n in e)
404
+ "default" === n ||
405
+ Object.prototype.hasOwnProperty.call(t, n) ||
406
+ g(t, e, n);
407
+ }
408
+ function v(e) {
409
+ var t = "function" == typeof Symbol && Symbol.iterator,
410
+ n = t && e[t],
411
+ r = 0;
412
+ if (n) return n.call(e);
413
+ if (e && "number" == typeof e.length)
414
+ return {
415
+ next: function () {
416
+ return (
417
+ e && r >= e.length && (e = void 0),
418
+ { value: e && e[r++], done: !e }
419
+ );
420
+ },
421
+ };
422
+ throw new TypeError(
423
+ t ? "Object is not iterable." : "Symbol.iterator is not defined."
424
+ );
425
+ }
426
+ function m(e, t) {
427
+ var n = "function" == typeof Symbol && e[Symbol.iterator];
428
+ if (!n) return e;
429
+ var r,
430
+ o,
431
+ i = n.call(e),
432
+ a = [];
433
+ try {
434
+ for (; (void 0 === t || t-- > 0) && !(r = i.next()).done; )
435
+ a.push(r.value);
436
+ } catch (e) {
437
+ o = { error: e };
438
+ } finally {
439
+ try {
440
+ r && !r.done && (n = i.return) && n.call(i);
441
+ } finally {
442
+ if (o) throw o.error;
443
+ }
444
+ }
445
+ return a;
446
+ }
447
+ function w() {
448
+ for (var e = [], t = 0; t < arguments.length; t++)
449
+ e = e.concat(m(arguments[t]));
450
+ return e;
451
+ }
452
+ function _() {
453
+ for (var e = 0, t = 0, n = arguments.length; t < n; t++)
454
+ e += arguments[t].length;
455
+ var r = Array(e),
456
+ o = 0;
457
+ for (t = 0; t < n; t++)
458
+ for (var i = arguments[t], a = 0, c = i.length; a < c; a++, o++)
459
+ r[o] = i[a];
460
+ return r;
461
+ }
462
+ function P(e, t, n) {
463
+ if (n || 2 === arguments.length)
464
+ for (var r, o = 0, i = t.length; o < i; o++)
465
+ (!r && o in t) ||
466
+ (r || (r = Array.prototype.slice.call(t, 0, o)),
467
+ (r[o] = t[o]));
468
+ return e.concat(r || Array.prototype.slice.call(t));
469
+ }
470
+ function O(e) {
471
+ return this instanceof O ? ((this.v = e), this) : new O(e);
472
+ }
473
+ function x(e, t, n) {
474
+ if (!Symbol.asyncIterator)
475
+ throw new TypeError("Symbol.asyncIterator is not defined.");
476
+ var r,
477
+ o = n.apply(e, t || []),
478
+ i = [];
479
+ return (
480
+ (r = {}),
481
+ a("next"),
482
+ a("throw"),
483
+ a("return"),
484
+ (r[Symbol.asyncIterator] = function () {
485
+ return this;
486
+ }),
487
+ r
488
+ );
489
+ function a(e) {
490
+ o[e] &&
491
+ (r[e] = function (t) {
492
+ return new Promise(function (n, r) {
493
+ i.push([e, t, n, r]) > 1 || c(e, t);
494
+ });
495
+ });
496
+ }
497
+ function c(e, t) {
498
+ try {
499
+ (n = o[e](t)).value instanceof O
500
+ ? Promise.resolve(n.value.v).then(l, u)
501
+ : s(i[0][2], n);
502
+ } catch (e) {
503
+ s(i[0][3], e);
504
+ }
505
+ var n;
506
+ }
507
+ function l(e) {
508
+ c("next", e);
509
+ }
510
+ function u(e) {
511
+ c("throw", e);
512
+ }
513
+ function s(e, t) {
514
+ e(t), i.shift(), i.length && c(i[0][0], i[0][1]);
515
+ }
516
+ }
517
+ function E(e) {
518
+ var t, n;
519
+ return (
520
+ (t = {}),
521
+ r("next"),
522
+ r("throw", function (e) {
523
+ throw e;
524
+ }),
525
+ r("return"),
526
+ (t[Symbol.iterator] = function () {
527
+ return this;
528
+ }),
529
+ t
530
+ );
531
+ function r(r, o) {
532
+ t[r] = e[r]
533
+ ? function (t) {
534
+ return (n = !n)
535
+ ? { value: O(e[r](t)), done: !1 }
536
+ : o
537
+ ? o(t)
538
+ : t;
539
+ }
540
+ : o;
541
+ }
542
+ }
543
+ function S(e) {
544
+ if (!Symbol.asyncIterator)
545
+ throw new TypeError("Symbol.asyncIterator is not defined.");
546
+ var t,
547
+ n = e[Symbol.asyncIterator];
548
+ return n
549
+ ? n.call(e)
550
+ : ((e = v(e)),
551
+ (t = {}),
552
+ r("next"),
553
+ r("throw"),
554
+ r("return"),
555
+ (t[Symbol.asyncIterator] = function () {
556
+ return this;
557
+ }),
558
+ t);
559
+ function r(n) {
560
+ t[n] =
561
+ e[n] &&
562
+ function (t) {
563
+ return new Promise(function (r, o) {
564
+ !(function (e, t, n, r) {
565
+ Promise.resolve(r).then(function (t) {
566
+ e({ value: t, done: n });
567
+ }, t);
568
+ })(r, o, (t = e[n](t)).done, t.value);
569
+ });
570
+ };
571
+ }
572
+ }
573
+ function j(e, t) {
574
+ return (
575
+ Object.defineProperty
576
+ ? Object.defineProperty(e, "raw", { value: t })
577
+ : (e.raw = t),
578
+ e
579
+ );
580
+ }
581
+ var T = Object.create
582
+ ? function (e, t) {
583
+ Object.defineProperty(e, "default", {
584
+ enumerable: !0,
585
+ value: t,
586
+ });
587
+ }
588
+ : function (e, t) {
589
+ e.default = t;
590
+ };
591
+ function A(e) {
592
+ if (e && e.__esModule) return e;
593
+ var t = {};
594
+ if (null != e)
595
+ for (var n in e)
596
+ "default" !== n &&
597
+ Object.prototype.hasOwnProperty.call(e, n) &&
598
+ g(t, e, n);
599
+ return T(t, e), t;
600
+ }
601
+ function C(e) {
602
+ return e && e.__esModule ? e : { default: e };
603
+ }
604
+ function k(e, t, n, r) {
605
+ if ("a" === n && !r)
606
+ throw new TypeError(
607
+ "Private accessor was defined without a getter"
608
+ );
609
+ if ("function" == typeof t ? e !== t || !r : !t.has(e))
610
+ throw new TypeError(
611
+ "Cannot read private member from an object whose class did not declare it"
612
+ );
613
+ return "m" === n
614
+ ? r
615
+ : "a" === n
616
+ ? r.call(e)
617
+ : r
618
+ ? r.value
619
+ : t.get(e);
620
+ }
621
+ function M(e, t, n, r, o) {
622
+ if ("m" === r)
623
+ throw new TypeError("Private method is not writable");
624
+ if ("a" === r && !o)
625
+ throw new TypeError(
626
+ "Private accessor was defined without a setter"
627
+ );
628
+ if ("function" == typeof t ? e !== t || !o : !t.has(e))
629
+ throw new TypeError(
630
+ "Cannot write private member to an object whose class did not declare it"
631
+ );
632
+ return (
633
+ "a" === r ? o.call(e, n) : o ? (o.value = n) : t.set(e, n), n
634
+ );
635
+ }
636
+ function R(e, t) {
637
+ if (null === t || ("object" != typeof t && "function" != typeof t))
638
+ throw new TypeError("Cannot use 'in' operator on non-object");
639
+ return "function" == typeof e ? t === e : e.has(t);
640
+ }
641
+ },
642
+ 156: function (t) {
643
+ t.exports = e;
644
+ },
645
+ 111: function (e) {
646
+ e.exports = t;
647
+ },
648
+ },
649
+ r = {};
650
+ function o(e) {
651
+ var t = r[e];
652
+ if (void 0 !== t) return t.exports;
653
+ var i = (r[e] = { exports: {} });
654
+ return n[e](i, i.exports, o), i.exports;
655
+ }
656
+ (o.d = function (e, t) {
657
+ for (var n in t)
658
+ o.o(t, n) &&
659
+ !o.o(e, n) &&
660
+ Object.defineProperty(e, n, { enumerable: !0, get: t[n] });
661
+ }),
662
+ (o.o = function (e, t) {
663
+ return Object.prototype.hasOwnProperty.call(e, t);
664
+ }),
665
+ (o.r = function (e) {
666
+ "undefined" != typeof Symbol &&
667
+ Symbol.toStringTag &&
668
+ Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }),
669
+ Object.defineProperty(e, "__esModule", { value: !0 });
670
+ });
671
+ var i = {};
672
+ return (
673
+ (function () {
674
+ var e = i;
675
+ Object.defineProperty(e, "__esModule", { value: !0 }),
676
+ (e.useReactToPrint = e.PrintContextConsumer = void 0);
677
+ var t = o(655),
678
+ n = o(156),
679
+ r = o(111),
680
+ a = Object.prototype.hasOwnProperty.call(n, "createContext"),
681
+ c =
682
+ Object.prototype.hasOwnProperty.call(n, "useMemo") &&
683
+ Object.prototype.hasOwnProperty.call(n, "useCallback"),
684
+ l = a ? n.createContext({}) : null;
685
+ e.PrintContextConsumer = l
686
+ ? l.Consumer
687
+ : function () {
688
+ return null;
689
+ };
690
+ var u = {
691
+ copyStyles: !0,
692
+ pageStyle:
693
+ "\n @page {\n /* Remove browser default header (title) and footer (url) */\n padding: 10px;\n }\n @media print {\n body {\n /* Tell browsers to print background colors */\n -webkit-print-color-adjust: exact; /* Chrome/Safari/Edge/Opera */\n color-adjust: exact; /* Firefox */\n }\n }\n ",
694
+ removeAfterPrint: !1,
695
+ suppressErrors: !1,
696
+ },
697
+ s = (function (e) {
698
+ function o() {
699
+ var n = (null !== e && e.apply(this, arguments)) || this;
700
+ return (
701
+ (n.startPrint = function (e) {
702
+ var t = n.props,
703
+ r = t.onAfterPrint,
704
+ o = t.onPrintError,
705
+ i = t.print,
706
+ a = t.documentTitle;
707
+ setTimeout(function () {
708
+ var t, c;
709
+ if (e.contentWindow) {
710
+ if ((e.contentWindow.focus(), i))
711
+ i(e)
712
+ .then(n.handleRemoveIframe)
713
+ .catch(function (e) {
714
+ o
715
+ ? o("print", e)
716
+ : n.logMessages([
717
+ "An error was thrown by the specified `print` function",
718
+ ]);
719
+ });
720
+ else if (e.contentWindow.print) {
721
+ var l =
722
+ null !==
723
+ (c =
724
+ null === (t = e.contentDocument) || void 0 === t
725
+ ? void 0
726
+ : t.title) && void 0 !== c
727
+ ? c
728
+ : "",
729
+ u = e.ownerDocument.title;
730
+ a &&
731
+ ((e.ownerDocument.title = a),
732
+ e.contentDocument && (e.contentDocument.title = a)),
733
+ e.contentWindow.print(),
734
+ a &&
735
+ ((e.ownerDocument.title = u),
736
+ e.contentDocument && (e.contentDocument.title = l));
737
+ } else
738
+ n.logMessages([
739
+ "Printing for this browser is not currently possible: the browser does not have a `print` method available for iframes.",
740
+ ]);
741
+ r && r(), n.handleRemoveIframe();
742
+ } else n.logMessages(["Printing failed because the `contentWindow` of the print iframe did not load. This is possibly an error with `react-to-print`. Please file an issue: https://github.com/gregnb/react-to-print/issues/"]);
743
+ }, 500);
744
+ }),
745
+ (n.triggerPrint = function (e) {
746
+ var t = n.props,
747
+ r = t.onBeforePrint,
748
+ o = t.onPrintError;
749
+ if (r) {
750
+ var i = r();
751
+ i && "function" == typeof i.then
752
+ ? i
753
+ .then(function () {
754
+ n.startPrint(e);
755
+ })
756
+ .catch(function (e) {
757
+ o && o("onBeforePrint", e);
758
+ })
759
+ : n.startPrint(e);
760
+ } else n.startPrint(e);
761
+ }),
762
+ (n.handleClick = function () {
763
+ var e = n.props,
764
+ t = e.onBeforeGetContent,
765
+ r = e.onPrintError;
766
+ if (t) {
767
+ var o = t();
768
+ o && "function" == typeof o.then
769
+ ? o.then(n.handlePrint).catch(function (e) {
770
+ r && r("onBeforeGetContent", e);
771
+ })
772
+ : n.handlePrint();
773
+ } else n.handlePrint();
774
+ }),
775
+ (n.handlePrint = function () {
776
+ var e = n.props,
777
+ o = e.bodyClass,
778
+ i = e.content,
779
+ a = e.copyStyles,
780
+ c = e.fonts,
781
+ l = e.pageStyle,
782
+ u = e.nonce,
783
+ s = i();
784
+ if (void 0 !== s)
785
+ if (null !== s) {
786
+ var f = document.createElement("iframe");
787
+ (f.width = "".concat(
788
+ document.documentElement.clientWidth,
789
+ "px"
790
+ )),
791
+ (f.height = "".concat(
792
+ document.documentElement.clientHeight,
793
+ "px"
794
+ )),
795
+ (f.style.position = "absolute"),
796
+ (f.style.top = "-".concat(
797
+ document.documentElement.clientHeight + 100,
798
+ "px"
799
+ )),
800
+ (f.style.left = "-".concat(
801
+ document.documentElement.clientWidth + 100,
802
+ "px"
803
+ )),
804
+ (f.id = "printWindow"),
805
+ (f.srcdoc = "<!DOCTYPE html>");
806
+ var d = (0, r.findDOMNode)(s);
807
+ if (d) {
808
+ var p = d.cloneNode(!0),
809
+ h = p instanceof Text,
810
+ y = document.querySelectorAll(
811
+ "link[rel='stylesheet']"
812
+ ),
813
+ g = h ? [] : p.querySelectorAll("img"),
814
+ b = h ? [] : p.querySelectorAll("video"),
815
+ v = c ? c.length : 0;
816
+ (n.numResourcesToLoad =
817
+ y.length + g.length + b.length + v),
818
+ (n.resourcesLoaded = []),
819
+ (n.resourcesErrored = []);
820
+ var m = function (e, r) {
821
+ n.resourcesLoaded.includes(e)
822
+ ? n.logMessages(
823
+ [
824
+ "Tried to mark a resource that has already been handled",
825
+ e,
826
+ ],
827
+ "debug"
828
+ )
829
+ : (r
830
+ ? (n.logMessages(
831
+ t.__spreadArray(
832
+ [
833
+ '"react-to-print" was unable to load a resource but will continue attempting to print the page',
834
+ ],
835
+ t.__read(r),
836
+ !1
837
+ )
838
+ ),
839
+ n.resourcesErrored.push(e))
840
+ : n.resourcesLoaded.push(e),
841
+ n.resourcesLoaded.length +
842
+ n.resourcesErrored.length ===
843
+ n.numResourcesToLoad && n.triggerPrint(f));
844
+ };
845
+ (f.onload = function () {
846
+ var e, r, i, s;
847
+ f.onload = null;
848
+ var y =
849
+ f.contentDocument ||
850
+ (null === (r = f.contentWindow) || void 0 === r
851
+ ? void 0
852
+ : r.document);
853
+ if (y) {
854
+ y.body.appendChild(p),
855
+ c &&
856
+ ((null === (i = f.contentDocument) ||
857
+ void 0 === i
858
+ ? void 0
859
+ : i.fonts) &&
860
+ (null === (s = f.contentWindow) || void 0 === s
861
+ ? void 0
862
+ : s.FontFace)
863
+ ? c.forEach(function (e) {
864
+ var t = new FontFace(e.family, e.source, {
865
+ weight: e.weight,
866
+ style: e.style,
867
+ });
868
+ f.contentDocument.fonts.add(t),
869
+ t.loaded
870
+ .then(function () {
871
+ m(t);
872
+ })
873
+ .catch(function (e) {
874
+ m(t, [
875
+ "Failed loading the font:",
876
+ t,
877
+ "Load error:",
878
+ e,
879
+ ]);
880
+ });
881
+ })
882
+ : (c.forEach(function (e) {
883
+ return m(e);
884
+ }),
885
+ n.logMessages([
886
+ '"react-to-print" is not able to load custom fonts because the browser does not support the FontFace API but will continue attempting to print the page',
887
+ ])));
888
+ var v = "function" == typeof l ? l() : l;
889
+ if ("string" != typeof v)
890
+ n.logMessages([
891
+ '"react-to-print" expected a "string" from `pageStyle` but received "'.concat(
892
+ typeof v,
893
+ '". Styles from `pageStyle` will not be applied.'
894
+ ),
895
+ ]);
896
+ else {
897
+ var w = y.createElement("style");
898
+ u &&
899
+ (w.setAttribute("nonce", u),
900
+ y.head.setAttribute("nonce", u)),
901
+ w.appendChild(y.createTextNode(v)),
902
+ y.head.appendChild(w);
903
+ }
904
+ if (
905
+ (o &&
906
+ (e = y.body.classList).add.apply(
907
+ e,
908
+ t.__spreadArray(
909
+ [],
910
+ t.__read(o.split(" ")),
911
+ !1
912
+ )
913
+ ),
914
+ !h)
915
+ ) {
916
+ for (
917
+ var _ = h ? [] : d.querySelectorAll("canvas"),
918
+ P = y.querySelectorAll("canvas"),
919
+ O = 0;
920
+ O < _.length;
921
+ ++O
922
+ ) {
923
+ var x = _[O],
924
+ E = P[O].getContext("2d");
925
+ E && E.drawImage(x, 0, 0);
926
+ }
927
+ var S = function (e) {
928
+ var t = g[e],
929
+ n = t.getAttribute("src");
930
+ if (n) {
931
+ var r = new Image();
932
+ (r.onload = function () {
933
+ return m(t);
934
+ }),
935
+ (r.onerror = function (e, n, r, o, i) {
936
+ return m(t, [
937
+ "Error loading <img>",
938
+ t,
939
+ "Error",
940
+ i,
941
+ ]);
942
+ }),
943
+ (r.src = n);
944
+ } else
945
+ m(t, [
946
+ 'Found an <img> tag with an empty "src" attribute. This prevents pre-loading it. The <img> is:',
947
+ t,
948
+ ]);
949
+ };
950
+ for (O = 0; O < g.length; O++) S(O);
951
+ var j = function (e) {
952
+ var t = b[e];
953
+ t.preload = "auto";
954
+ var n = t.getAttribute("poster");
955
+ if (n) {
956
+ var r = new Image();
957
+ (r.onload = function () {
958
+ return m(t);
959
+ }),
960
+ (r.onerror = function (e, r, o, i, a) {
961
+ return m(t, [
962
+ "Error loading video poster",
963
+ n,
964
+ "for video",
965
+ t,
966
+ "Error:",
967
+ a,
968
+ ]);
969
+ }),
970
+ (r.src = n);
971
+ } else
972
+ t.readyState >= 2
973
+ ? m(t)
974
+ : ((t.onloadeddata = function () {
975
+ return m(t);
976
+ }),
977
+ (t.onerror = function (e, n, r, o, i) {
978
+ return m(t, [
979
+ "Error loading video",
980
+ t,
981
+ "Error",
982
+ i,
983
+ ]);
984
+ }),
985
+ (t.onstalled = function () {
986
+ return m(t, [
987
+ "Loading video stalled, skipping",
988
+ t,
989
+ ]);
990
+ }));
991
+ };
992
+ for (O = 0; O < b.length; O++) j(O);
993
+ var T = "input",
994
+ A = d.querySelectorAll(T),
995
+ C = y.querySelectorAll(T);
996
+ for (O = 0; O < A.length; O++)
997
+ C[O].value = A[O].value;
998
+ var k = "input[type=checkbox],input[type=radio]",
999
+ M = d.querySelectorAll(k),
1000
+ R = y.querySelectorAll(k);
1001
+ for (O = 0; O < M.length; O++)
1002
+ R[O].checked = M[O].checked;
1003
+ var D = "select",
1004
+ I = d.querySelectorAll(D),
1005
+ q = y.querySelectorAll(D);
1006
+ for (O = 0; O < I.length; O++)
1007
+ q[O].value = I[O].value;
1008
+ }
1009
+ if (a)
1010
+ for (
1011
+ var F = document.querySelectorAll(
1012
+ "style, link[rel='stylesheet']"
1013
+ ),
1014
+ L = function (e, t) {
1015
+ var r = F[e];
1016
+ if ("style" === r.tagName.toLowerCase()) {
1017
+ var o = y.createElement(r.tagName),
1018
+ i = r.sheet;
1019
+ if (i) {
1020
+ var a = "";
1021
+ try {
1022
+ for (
1023
+ var c = i.cssRules.length, l = 0;
1024
+ l < c;
1025
+ ++l
1026
+ )
1027
+ "string" ==
1028
+ typeof i.cssRules[l].cssText &&
1029
+ (a += "".concat(
1030
+ i.cssRules[l].cssText,
1031
+ "\r\n"
1032
+ ));
1033
+ } catch (e) {
1034
+ n.logMessages(
1035
+ [
1036
+ "A stylesheet could not be accessed. This is likely due to the stylesheet having cross-origin imports, and many browsers block script access to cross-origin stylesheets. See https://github.com/gregnb/react-to-print/issues/429 for details. You may be able to load the sheet by both marking the stylesheet with the cross `crossorigin` attribute, and setting the `Access-Control-Allow-Origin` header on the server serving the stylesheet. Alternatively, host the stylesheet on your domain to avoid this issue entirely.",
1037
+ r,
1038
+ ],
1039
+ "warning"
1040
+ );
1041
+ }
1042
+ o.setAttribute(
1043
+ "id",
1044
+ "react-to-print-".concat(e)
1045
+ ),
1046
+ u && o.setAttribute("nonce", u),
1047
+ o.appendChild(y.createTextNode(a)),
1048
+ y.head.appendChild(o);
1049
+ }
1050
+ } else if (r.getAttribute("href"))
1051
+ if (r.hasAttribute("disabled"))
1052
+ n.logMessages(
1053
+ [
1054
+ "`react-to-print` encountered a <link> tag with a `disabled` attribute and will ignore it. Note that the `disabled` attribute is deprecated, and some browsers ignore it. You should stop using it. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-disabled. The <link> is:",
1055
+ r,
1056
+ ],
1057
+ "warning"
1058
+ ),
1059
+ m(r);
1060
+ else {
1061
+ for (
1062
+ var s = y.createElement(r.tagName),
1063
+ f = ((l = 0), r.attributes.length);
1064
+ l < f;
1065
+ ++l
1066
+ ) {
1067
+ var d = r.attributes[l];
1068
+ d &&
1069
+ s.setAttribute(
1070
+ d.nodeName,
1071
+ d.nodeValue || ""
1072
+ );
1073
+ }
1074
+ (s.onload = function () {
1075
+ return m(s);
1076
+ }),
1077
+ (s.onerror = function (
1078
+ e,
1079
+ t,
1080
+ n,
1081
+ r,
1082
+ o
1083
+ ) {
1084
+ return m(s, [
1085
+ "Failed to load",
1086
+ s,
1087
+ "Error:",
1088
+ o,
1089
+ ]);
1090
+ }),
1091
+ u && s.setAttribute("nonce", u),
1092
+ y.head.appendChild(s);
1093
+ }
1094
+ else
1095
+ n.logMessages(
1096
+ [
1097
+ "`react-to-print` encountered a <link> tag with an empty `href` attribute. In addition to being invalid HTML, this can cause problems in many browsers, and so the <link> was not loaded. The <link> is:",
1098
+ r,
1099
+ ],
1100
+ "warning"
1101
+ ),
1102
+ m(r);
1103
+ },
1104
+ W = ((O = 0), F.length);
1105
+ O < W;
1106
+ ++O
1107
+ )
1108
+ L(O);
1109
+ }
1110
+ (0 !== n.numResourcesToLoad && a) ||
1111
+ n.triggerPrint(f);
1112
+ }),
1113
+ n.handleRemoveIframe(!0),
1114
+ document.body.appendChild(f);
1115
+ } else
1116
+ n.logMessages([
1117
+ '"react-to-print" could not locate the DOM node corresponding with the `content` prop',
1118
+ ]);
1119
+ } else
1120
+ n.logMessages([
1121
+ 'There is nothing to print because the "content" prop returned "null". Please ensure "content" is renderable before allowing "react-to-print" to be called.',
1122
+ ]);
1123
+ else
1124
+ n.logMessages([
1125
+ "To print a functional component ensure it is wrapped with `React.forwardRef`, and ensure the forwarded ref is used. See the README for an example: https://github.com/gregnb/react-to-print#examples",
1126
+ ]);
1127
+ }),
1128
+ (n.handleRemoveIframe = function (e) {
1129
+ var t = n.props.removeAfterPrint;
1130
+ if (e || t) {
1131
+ var r = document.getElementById("printWindow");
1132
+ r && document.body.removeChild(r);
1133
+ }
1134
+ }),
1135
+ (n.logMessages = function (e, t) {
1136
+ void 0 === t && (t = "error"),
1137
+ n.props.suppressErrors ||
1138
+ ("error" === t
1139
+ ? console.error(e)
1140
+ : "warning" === t
1141
+ ? console.warn(e)
1142
+ : "debug" === t && console.debug(e));
1143
+ }),
1144
+ n
1145
+ );
1146
+ }
1147
+ return (
1148
+ t.__extends(o, e),
1149
+ (o.prototype.render = function () {
1150
+ var e = this.props,
1151
+ t = e.children,
1152
+ r = e.trigger;
1153
+ if (r)
1154
+ return n.cloneElement(r(), { onClick: this.handleClick });
1155
+ if (!l)
1156
+ return (
1157
+ this.logMessages([
1158
+ '"react-to-print" requires React ^16.3.0 to be able to use "PrintContext"',
1159
+ ]),
1160
+ null
1161
+ );
1162
+ var o = { handlePrint: this.handleClick };
1163
+ return n.createElement(l.Provider, { value: o }, t);
1164
+ }),
1165
+ (o.defaultProps = u),
1166
+ o
1167
+ );
1168
+ })(n.Component);
1169
+ (e.default = s),
1170
+ (e.useReactToPrint = function (e) {
1171
+ if (!c)
1172
+ return (
1173
+ e.suppressErrors ||
1174
+ console.error(
1175
+ '"react-to-print" requires React ^16.8.0 to be able to use "useReactToPrint"'
1176
+ ),
1177
+ function () {
1178
+ throw new Error(
1179
+ '"react-to-print" requires React ^16.8.0 to be able to use "useReactToPrint"'
1180
+ );
1181
+ }
1182
+ );
1183
+ var r = n.useMemo(
1184
+ function () {
1185
+ return new s(t.__assign(t.__assign({}, u), e));
1186
+ },
1187
+ [e]
1188
+ );
1189
+ return n.useCallback(
1190
+ function () {
1191
+ return r.handleClick();
1192
+ },
1193
+ [r]
1194
+ );
1195
+ });
1196
+ })(),
1197
+ i
1198
+ );
1199
+ })();
1200
+ });
1201
+