@paprize/react 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1497 +1,152 @@
1
- import { jsx as b, jsxs as de, Fragment as z } from "react/jsx-runtime";
2
- import Be, { useInsertionEffect as pt, useRef as B, createElement as ft, createContext as Se, useReducer as gt, useEffect as Y, useDebugValue as ht, useCallback as mt, useContext as Z, Children as vt, isValidElement as St, useMemo as T, useState as $e, useId as De } from "react";
3
- import { createPortal as _t } from "react-dom";
4
- function _e(e) {
5
- pt(() => {
6
- const t = document.createElement("style");
7
- return t.textContent = e, document.head.appendChild(t), () => t.remove();
8
- }, [e]);
9
- }
10
- const wt = `
11
- :root {
12
- --paprize-page-background-color: #ffffff;
13
- --paprize-page-margin-bottom: 10px;
14
- --paprize-page-box-shadow: rgb(142 138 138) -1px 3px 5px 2px;
15
- --paprize-section-margin-bottom: 10px;
16
- --paprize-preview-background-color: rgb(218 220 224);
17
- --paprize-preview-padding: 30px 10px;
18
- }
19
-
20
- body {
21
- margin: 0;
22
- }
23
-
24
- @media screen {
25
- .paprize-preview {
26
- min-height: 100vh;
27
- display: flex;
28
- flex-direction: column;
29
- align-items: center;
30
- background-color: var(--paprize-preview-background-color);
31
- padding: var(--paprize-preview-padding);
32
- }
33
-
34
- .paprize-page {
35
- box-shadow: var(--paprize-page-box-shadow);
36
- margin-bottom: var(--paprize-page-margin-bottom);
37
- background-color: var(--paprize-page-background-color);
38
- }
39
-
40
- .paprize-section {
41
- margin-bottom: var(--paprize-section-margin-bottom);
42
- }
43
- }
44
- `;
45
- function Gn({ children: e }) {
46
- return _e(wt), /* @__PURE__ */ b("div", { className: "paprize-preview", children: e });
47
- }
48
- const M = {};
49
- function He(e, t) {
50
- return e.unstable_is ? e.unstable_is(t) : t === e;
51
- }
52
- function Me(e) {
53
- return "init" in e;
54
- }
55
- function pe(e) {
56
- return !!e.write;
57
- }
58
- function Ae(e) {
59
- return "v" in e || "e" in e;
60
- }
61
- function Q(e) {
62
- if ("e" in e)
63
- throw e.e;
64
- if ((M ? "production" : void 0) !== "production" && !("v" in e))
65
- throw new Error("[Bug] atom state is not initialized");
66
- return e.v;
67
- }
68
- const ee = /* @__PURE__ */ new WeakMap();
69
- function We(e) {
70
- var t;
71
- return te(e) && !!((t = ee.get(e)) != null && t[0]);
72
- }
73
- function yt(e) {
74
- const t = ee.get(e);
75
- t?.[0] && (t[0] = !1, t[1].forEach((n) => n()));
76
- }
77
- function fe(e, t) {
78
- let n = ee.get(e);
79
- if (!n) {
80
- n = [!0, /* @__PURE__ */ new Set()], ee.set(e, n);
81
- const o = () => {
82
- n[0] = !1;
83
- };
84
- e.then(o, o);
85
- }
86
- n[1].add(t);
87
- }
88
- function te(e) {
89
- return typeof e?.then == "function";
90
- }
91
- function Ve(e, t, n) {
92
- if (!n.p.has(e)) {
93
- n.p.add(e);
94
- const o = () => n.p.delete(e);
95
- t.then(o, o);
96
- }
97
- }
98
- function Ue(e, t, n) {
99
- var o;
100
- const i = /* @__PURE__ */ new Set();
101
- for (const r of ((o = n.get(e)) == null ? void 0 : o.t) || [])
102
- n.has(r) && i.add(r);
103
- for (const r of t.p)
104
- i.add(r);
105
- return i;
106
- }
107
- const bt = (e, t, ...n) => t.read(...n), kt = (e, t, ...n) => t.write(...n), Et = (e, t) => {
108
- var n;
109
- return (n = t.unstable_onInit) == null ? void 0 : n.call(t, e);
110
- }, Ct = (e, t, n) => {
111
- var o;
112
- return (o = t.onMount) == null ? void 0 : o.call(t, n);
113
- }, Nt = (e, t) => {
114
- const n = A(e), o = n[0], i = n[9];
115
- if ((M ? "production" : void 0) !== "production" && !t)
116
- throw new Error("Atom is undefined or null");
117
- let r = o.get(t);
118
- return r || (r = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(t, r), i?.(e, t)), r;
119
- }, At = (e) => {
120
- const t = A(e), n = t[1], o = t[3], i = t[4], r = t[5], s = t[6], d = t[13], h = [], p = (l) => {
121
- try {
122
- l();
123
- } catch (g) {
124
- h.push(g);
125
- }
126
- };
127
- do {
128
- s.f && p(s.f);
129
- const l = /* @__PURE__ */ new Set(), g = l.add.bind(l);
130
- o.forEach((v) => {
131
- var m;
132
- return (m = n.get(v)) == null ? void 0 : m.l.forEach(g);
133
- }), o.clear(), r.forEach(g), r.clear(), i.forEach(g), i.clear(), l.forEach(p), o.size && d(e);
134
- } while (o.size || r.size || i.size);
135
- if (h.length)
136
- throw new AggregateError(h);
137
- }, Pt = (e) => {
138
- const t = A(e), n = t[1], o = t[2], i = t[3], r = t[11], s = t[14], d = t[17], h = [], p = /* @__PURE__ */ new WeakSet(), l = /* @__PURE__ */ new WeakSet(), g = Array.from(i);
139
- for (; g.length; ) {
140
- const v = g[g.length - 1], m = r(e, v);
141
- if (l.has(v)) {
142
- g.pop();
143
- continue;
144
- }
145
- if (p.has(v)) {
146
- if (o.get(v) === m.n)
147
- h.push([v, m]);
148
- else if ((M ? "production" : void 0) !== "production" && o.has(v))
149
- throw new Error("[Bug] invalidated atom exists");
150
- l.add(v), g.pop();
151
- continue;
152
- }
153
- p.add(v);
154
- for (const _ of Ue(v, m, n))
155
- p.has(_) || g.push(_);
156
- }
157
- for (let v = h.length - 1; v >= 0; --v) {
158
- const [m, _] = h[v];
159
- let a = !1;
160
- for (const u of _.d.keys())
161
- if (u !== m && i.has(u)) {
162
- a = !0;
163
- break;
164
- }
165
- a && (s(e, m), d(e, m)), o.delete(m);
166
- }
167
- }, xt = (e, t) => {
168
- var n;
169
- const o = A(e), i = o[1], r = o[2], s = o[3], d = o[6], h = o[7], p = o[11], l = o[12], g = o[13], v = o[14], m = o[16], _ = o[17], a = p(e, t);
170
- if (Ae(a) && (i.has(t) && r.get(t) !== a.n || Array.from(a.d).every(
171
- ([y, L]) => (
172
- // Recursively, read the atom state of the dependency, and
173
- // check if the atom epoch number is unchanged
174
- v(e, y).n === L
175
- )
176
- )))
177
- return a;
178
- a.d.clear();
179
- let u = !0;
180
- function c() {
181
- i.has(t) && (_(e, t), g(e), l(e));
182
- }
183
- function k(y) {
184
- var L;
185
- if (He(t, y)) {
186
- const I = p(e, y);
187
- if (!Ae(I))
188
- if (Me(y))
189
- ne(e, y, y.init);
190
- else
191
- throw new Error("no atom init");
192
- return Q(I);
193
- }
194
- const P = v(e, y);
195
- try {
196
- return Q(P);
197
- } finally {
198
- a.d.set(y, P.n), We(a.v) && Ve(t, a.v, P), (L = i.get(y)) == null || L.t.add(t), u || c();
199
- }
200
- }
201
- let C, E;
202
- const w = {
203
- get signal() {
204
- return C || (C = new AbortController()), C.signal;
205
- },
206
- get setSelf() {
207
- return (M ? "production" : void 0) !== "production" && !pe(t) && console.warn("setSelf function cannot be used with read-only atom"), !E && pe(t) && (E = (...y) => {
208
- if ((M ? "production" : void 0) !== "production" && u && console.warn("setSelf function cannot be called in sync"), !u)
209
- try {
210
- return m(e, t, ...y);
211
- } finally {
212
- g(e), l(e);
213
- }
214
- }), E;
215
- }
216
- }, O = a.n;
217
- try {
218
- const y = h(e, t, k, w);
219
- return ne(e, t, y), te(y) && (fe(y, () => C?.abort()), y.then(c, c)), a;
220
- } catch (y) {
221
- return delete a.v, a.e = y, ++a.n, a;
222
- } finally {
223
- u = !1, O !== a.n && r.get(t) === O && (r.set(t, a.n), s.add(t), (n = d.c) == null || n.call(d, t));
224
- }
225
- }, Tt = (e, t) => {
226
- const n = A(e), o = n[1], i = n[2], r = n[11], s = [t];
227
- for (; s.length; ) {
228
- const d = s.pop(), h = r(e, d);
229
- for (const p of Ue(d, h, o)) {
230
- const l = r(e, p);
231
- i.set(p, l.n), s.push(p);
232
- }
233
- }
234
- }, je = (e, t, ...n) => {
235
- const o = A(e), i = o[3], r = o[6], s = o[8], d = o[11], h = o[12], p = o[13], l = o[14], g = o[15], v = o[17];
236
- let m = !0;
237
- const _ = (u) => Q(l(e, u)), a = (u, ...c) => {
238
- var k;
239
- const C = d(e, u);
240
- try {
241
- if (He(t, u)) {
242
- if (!Me(u))
243
- throw new Error("atom not writable");
244
- const E = C.n, w = c[0];
245
- ne(e, u, w), v(e, u), E !== C.n && (i.add(u), (k = r.c) == null || k.call(r, u), g(e, u));
246
- return;
247
- } else
248
- return je(e, u, ...c);
249
- } finally {
250
- m || (p(e), h(e));
251
- }
252
- };
253
- try {
254
- return s(e, t, _, a, ...n);
255
- } finally {
256
- m = !1;
257
- }
258
- }, Lt = (e, t) => {
259
- var n;
260
- const o = A(e), i = o[1], r = o[3], s = o[6], d = o[11], h = o[15], p = o[18], l = o[19], g = d(e, t), v = i.get(t);
261
- if (v && !We(g.v)) {
262
- for (const [m, _] of g.d)
263
- if (!v.d.has(m)) {
264
- const a = d(e, m);
265
- p(e, m).t.add(t), v.d.add(m), _ !== a.n && (r.add(m), (n = s.c) == null || n.call(s, m), h(e, m));
266
- }
267
- for (const m of v.d || [])
268
- if (!g.d.has(m)) {
269
- v.d.delete(m);
270
- const _ = l(e, m);
271
- _?.t.delete(t);
272
- }
273
- }
274
- }, Je = (e, t) => {
275
- var n;
276
- const o = A(e), i = o[1], r = o[4], s = o[6], d = o[10], h = o[11], p = o[12], l = o[13], g = o[14], v = o[16], m = h(e, t);
277
- let _ = i.get(t);
278
- if (!_) {
279
- g(e, t);
280
- for (const a of m.d.keys())
281
- Je(e, a).t.add(t);
282
- if (_ = {
283
- l: /* @__PURE__ */ new Set(),
284
- d: new Set(m.d.keys()),
285
- t: /* @__PURE__ */ new Set()
286
- }, i.set(t, _), (n = s.m) == null || n.call(s, t), pe(t)) {
287
- const a = () => {
288
- let u = !0;
289
- const c = (...k) => {
290
- try {
291
- return v(e, t, ...k);
292
- } finally {
293
- u || (l(e), p(e));
294
- }
295
- };
296
- try {
297
- const k = d(e, t, c);
298
- k && (_.u = () => {
299
- u = !0;
300
- try {
301
- k();
302
- } finally {
303
- u = !1;
304
- }
305
- });
306
- } finally {
307
- u = !1;
308
- }
309
- };
310
- r.add(a);
311
- }
312
- }
313
- return _;
314
- }, It = (e, t) => {
315
- var n;
316
- const o = A(e), i = o[1], r = o[5], s = o[6], d = o[11], h = o[19], p = d(e, t);
317
- let l = i.get(t);
318
- if (l && !l.l.size && !Array.from(l.t).some((g) => {
319
- var v;
320
- return (v = i.get(g)) == null ? void 0 : v.d.has(t);
321
- })) {
322
- l.u && r.add(l.u), l = void 0, i.delete(t), (n = s.u) == null || n.call(s, t);
323
- for (const g of p.d.keys()) {
324
- const v = h(e, g);
325
- v?.t.delete(t);
326
- }
327
- return;
328
- }
329
- return l;
330
- }, ne = (e, t, n) => {
331
- const o = A(e)[11], i = o(e, t), r = "v" in i, s = i.v;
332
- if (te(n))
333
- for (const d of i.d.keys())
334
- Ve(
335
- t,
336
- n,
337
- o(e, d)
338
- );
339
- i.v = n, delete i.e, (!r || !Object.is(s, i.v)) && (++i.n, te(s) && yt(s));
340
- }, Rt = (e, t) => {
341
- const n = A(e)[14];
342
- return Q(n(e, t));
343
- }, Ft = (e, t, ...n) => {
344
- const o = A(e), i = o[12], r = o[13], s = o[16];
345
- try {
346
- return s(e, t, ...n);
347
- } finally {
348
- r(e), i(e);
349
- }
350
- }, zt = (e, t, n) => {
351
- const o = A(e), i = o[12], r = o[18], s = o[19], h = r(e, t).l;
352
- return h.add(n), i(e), () => {
353
- h.delete(n), s(e, t), i(e);
354
- };
355
- }, Ge = /* @__PURE__ */ new WeakMap();
356
- function A(e) {
357
- const t = Ge.get(e);
358
- if ((M ? "production" : void 0) !== "production" && !t)
1
+ import { jsx as r, Fragment as f, jsxs as R } from "react/jsx-runtime";
2
+ import { previewClassName as V, ReportBuilder as z, reportStyles as i, pageClassName as A, pageMargin as O, adjustDimension as q, sectionClassName as G, pageBreakAttributeName as K, configToAttributeMap as Q, paprize_readJsonDataFile as E } from "@paprize/core";
3
+ import { createContext as h, useContext as g, useMemo as u, useEffect as S, useRef as c, Children as U, isValidElement as W, useState as X, useSyncExternalStore as H } from "react";
4
+ import { createPortal as Y } from "react-dom";
5
+ function fe({ children: e }) {
6
+ return /* @__PURE__ */ r("div", { className: V, children: e });
7
+ }
8
+ const B = h(null);
9
+ function w() {
10
+ const e = g(B);
11
+ if (!e)
359
12
  throw new Error(
360
- "Store must be created by buildStore to read its building blocks"
13
+ "ReportRoot is missing. Please wrap your component tree with ReportRoot component."
361
14
  );
362
- return t;
363
- }
364
- function Ot(...e) {
365
- const t = {
366
- get(o) {
367
- const i = A(t)[21];
368
- return i(t, o);
369
- },
370
- set(o, ...i) {
371
- const r = A(t)[22];
372
- return r(t, o, ...i);
373
- },
374
- sub(o, i) {
375
- const r = A(t)[23];
376
- return r(t, o, i);
377
- }
378
- }, n = [
379
- // store state
380
- /* @__PURE__ */ new WeakMap(),
381
- // atomStateMap
382
- /* @__PURE__ */ new WeakMap(),
383
- // mountedMap
384
- /* @__PURE__ */ new WeakMap(),
385
- // invalidatedAtoms
386
- /* @__PURE__ */ new Set(),
387
- // changedAtoms
388
- /* @__PURE__ */ new Set(),
389
- // mountCallbacks
390
- /* @__PURE__ */ new Set(),
391
- // unmountCallbacks
392
- {},
393
- // storeHooks
394
- // atom interceptors
395
- bt,
396
- kt,
397
- Et,
398
- Ct,
399
- // building-block functions
400
- Nt,
401
- At,
402
- Pt,
403
- xt,
404
- Tt,
405
- je,
406
- Lt,
407
- Je,
408
- It,
409
- ne,
410
- Rt,
411
- Ft,
412
- zt
413
- ].map((o, i) => e[i] || o);
414
- return Ge.set(t, Object.freeze(n)), t;
415
- }
416
- const Ye = {};
417
- let Bt = 0;
418
- function X(e, t) {
419
- const n = `atom${++Bt}`, o = {
420
- toString() {
421
- return (Ye ? "production" : void 0) !== "production" && this.debugLabel ? n + ":" + this.debugLabel : n;
422
- }
423
- };
424
- return typeof e == "function" ? o.read = e : (o.init = e, o.read = $t, o.write = Dt), t && (o.write = t), o;
425
- }
426
- function $t(e) {
427
- return e(this);
428
- }
429
- function Dt(e, t, n) {
430
- return t(
431
- this,
432
- typeof n == "function" ? n(e(this)) : n
433
- );
434
- }
435
- function we() {
436
- return Ot();
437
- }
438
- let j;
439
- function Ht() {
440
- return j || (j = we(), (Ye ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = j), globalThis.__JOTAI_DEFAULT_STORE__ !== j && console.warn(
441
- "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
442
- ))), j;
443
- }
444
- const Mt = {}, qe = Se(
445
- void 0
446
- );
447
- function Ze(e) {
448
- return Z(qe) || Ht();
449
- }
450
- function Wt({
451
- children: e,
452
- store: t
453
- }) {
454
- const n = B(void 0);
455
- return !t && !n.current && (n.current = we()), ft(
456
- qe.Provider,
457
- {
458
- value: t || n.current
459
- },
460
- e
461
- );
462
- }
463
- const ge = (e) => typeof e?.then == "function", he = (e) => {
464
- e.status || (e.status = "pending", e.then(
465
- (t) => {
466
- e.status = "fulfilled", e.value = t;
467
- },
468
- (t) => {
469
- e.status = "rejected", e.reason = t;
470
- }
471
- ));
472
- }, Vt = Be.use || // A shim for older React versions
473
- ((e) => {
474
- if (e.status === "pending")
475
- throw e;
476
- if (e.status === "fulfilled")
477
- return e.value;
478
- throw e.status === "rejected" ? e.reason : (he(e), e);
479
- }), ce = /* @__PURE__ */ new WeakMap(), Pe = (e, t) => {
480
- let n = ce.get(e);
481
- return n || (n = new Promise((o, i) => {
482
- let r = e;
483
- const s = (p) => (l) => {
484
- r === p && o(l);
485
- }, d = (p) => (l) => {
486
- r === p && i(l);
487
- }, h = () => {
488
- try {
489
- const p = t();
490
- ge(p) ? (ce.set(p, n), r = p, p.then(s(p), d(p)), fe(p, h)) : o(p);
491
- } catch (p) {
492
- i(p);
493
- }
494
- };
495
- e.then(s(e), d(e)), fe(e, h);
496
- }), ce.set(e, n)), n;
497
- };
498
- function oe(e, t) {
499
- const { delay: n, unstable_promiseStatus: o = !Be.use } = {}, i = Ze(), [[r, s, d], h] = gt(
500
- (l) => {
501
- const g = i.get(e);
502
- return Object.is(l[0], g) && l[1] === i && l[2] === e ? l : [g, i, e];
503
- },
504
- void 0,
505
- () => [i.get(e), i, e]
506
- );
507
- let p = r;
508
- if ((s !== i || d !== e) && (h(), p = i.get(e)), Y(() => {
509
- const l = i.sub(e, () => {
510
- if (o)
511
- try {
512
- const g = i.get(e);
513
- ge(g) && he(
514
- Pe(g, () => i.get(e))
515
- );
516
- } catch {
517
- }
518
- if (typeof n == "number") {
519
- setTimeout(h, n);
520
- return;
15
+ return e;
16
+ }
17
+ function ge({ children: e }) {
18
+ const t = u(() => new z(), []);
19
+ return S(() => {
20
+ t.schedulePaginate();
21
+ }, [t]), /* @__PURE__ */ r(B, { value: t, children: e });
22
+ }
23
+ function N({ children: e }) {
24
+ const t = w(), o = c(!1);
25
+ return S(() => {
26
+ const n = t.monitor.addEventListener(
27
+ "paginationCycleCompleted",
28
+ () => {
29
+ o.current = !0;
521
30
  }
522
- h();
523
- });
524
- return h(), l;
525
- }, [i, e, n, o]), ht(p), ge(p)) {
526
- const l = Pe(p, () => i.get(e));
527
- return o && he(l), Vt(l);
528
- }
529
- return p;
530
- }
531
- function ye(e, t) {
532
- const n = Ze();
533
- return mt(
534
- (...i) => {
535
- if ((Mt ? "production" : void 0) !== "production" && !("write" in e))
536
- throw new Error("not writable atom");
537
- return n.set(e, ...i);
538
- },
539
- [n, e]
540
- );
541
- }
542
- const Ut = "__PAPRIZE_IS_READY", jt = "__PAPRIZE_READ_JSON_DATA_FILE", Jt = we(), Gt = {
543
- totalPages: 0,
544
- isPaginated: !1,
545
- pendingSuspensions: /* @__PURE__ */ new Set()
546
- }, V = X(/* @__PURE__ */ new Map());
547
- V.debugLabel = "sectionsAtom";
548
- const be = X({
549
- totalSections: 0,
550
- isPaginated: !1
551
- });
552
- be.debugLabel = "reportAtom";
553
- function Yt() {
554
- const e = ye(be), t = oe(V);
555
- return Y(() => {
556
- const n = t.size, o = Array.from(t.values()).every(
557
- (i) => i.isPaginated
558
31
  );
559
- window[Ut] = o, e({
560
- isPaginated: o && n > 0,
561
- totalSections: n
562
- });
563
- }, [t, e]), null;
564
- }
565
- const qt = `
566
- html {
567
- box-sizing: border-box;
568
- }
569
-
570
- *,
571
- *:before,
572
- *:after {
573
- box-sizing: inherit;
574
- }
575
-
576
- .paprize-page-component {
577
- display: flex;
578
- flex-direction: column;
579
- }
580
- `;
581
- function Yn({ children: e }) {
582
- return _e(qt), /* @__PURE__ */ de(Wt, { store: Jt, children: [
583
- e,
584
- /* @__PURE__ */ b(Yt, {})
585
- ] });
586
- }
587
- function Xe({ children: e }) {
588
- return /* @__PURE__ */ b(z, { children: e });
589
- }
590
- function Ke({ children: e }) {
591
- return /* @__PURE__ */ b(z, { children: e });
32
+ return () => n();
33
+ }, [t.monitor]), S(() => {
34
+ o.current && t.schedulePaginate();
35
+ }, [e, t]), /* @__PURE__ */ r(f, { children: e });
592
36
  }
593
- function Qe({ children: e }) {
594
- return /* @__PURE__ */ b(z, { children: e });
37
+ function k({ children: e }) {
38
+ return /* @__PURE__ */ r(f, { children: e });
595
39
  }
596
- function et({ children: e }) {
597
- return /* @__PURE__ */ b(z, { children: e });
40
+ function D({ children: e }) {
41
+ return /* @__PURE__ */ r(f, { children: e });
598
42
  }
599
- function tt({ children: e }) {
600
- return /* @__PURE__ */ b(z, { children: e });
43
+ function T({ children: e }) {
44
+ return /* @__PURE__ */ r(f, { children: e });
601
45
  }
602
- function nt({ children: e }) {
603
- return /* @__PURE__ */ b(z, { children: e });
46
+ function j({ children: e }) {
47
+ return /* @__PURE__ */ r(f, { children: e });
604
48
  }
605
- function Zt(e) {
606
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
49
+ function L({ children: e }) {
50
+ return /* @__PURE__ */ r(f, { children: e });
607
51
  }
608
- var K = { exports: {} }, Xt = K.exports, xe;
609
- function Kt() {
610
- return xe || (xe = 1, (function(e) {
611
- (function(t, n) {
612
- e.exports ? e.exports = n() : t.log = n();
613
- })(Xt, function() {
614
- var t = function() {
615
- }, n = "undefined", o = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), i = [
616
- "trace",
617
- "debug",
618
- "info",
619
- "warn",
620
- "error"
621
- ], r = {}, s = null;
622
- function d(a, u) {
623
- var c = a[u];
624
- if (typeof c.bind == "function")
625
- return c.bind(a);
626
- try {
627
- return Function.prototype.bind.call(c, a);
628
- } catch {
629
- return function() {
630
- return Function.prototype.apply.apply(c, [a, arguments]);
631
- };
632
- }
633
- }
634
- function h() {
635
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
636
- }
637
- function p(a) {
638
- return a === "debug" && (a = "log"), typeof console === n ? !1 : a === "trace" && o ? h : console[a] !== void 0 ? d(console, a) : console.log !== void 0 ? d(console, "log") : t;
639
- }
640
- function l() {
641
- for (var a = this.getLevel(), u = 0; u < i.length; u++) {
642
- var c = i[u];
643
- this[c] = u < a ? t : this.methodFactory(c, a, this.name);
644
- }
645
- if (this.log = this.debug, typeof console === n && a < this.levels.SILENT)
646
- return "No console available for logging";
647
- }
648
- function g(a) {
649
- return function() {
650
- typeof console !== n && (l.call(this), this[a].apply(this, arguments));
651
- };
652
- }
653
- function v(a, u, c) {
654
- return p(a) || g.apply(this, arguments);
655
- }
656
- function m(a, u) {
657
- var c = this, k, C, E, w = "loglevel";
658
- typeof a == "string" ? w += ":" + a : typeof a == "symbol" && (w = void 0);
659
- function O(f) {
660
- var S = (i[f] || "silent").toUpperCase();
661
- if (!(typeof window === n || !w)) {
662
- try {
663
- window.localStorage[w] = S;
664
- return;
665
- } catch {
666
- }
667
- try {
668
- window.document.cookie = encodeURIComponent(w) + "=" + S + ";";
669
- } catch {
670
- }
671
- }
672
- }
673
- function y() {
674
- var f;
675
- if (!(typeof window === n || !w)) {
676
- try {
677
- f = window.localStorage[w];
678
- } catch {
679
- }
680
- if (typeof f === n)
681
- try {
682
- var S = window.document.cookie, R = encodeURIComponent(w), U = S.indexOf(R + "=");
683
- U !== -1 && (f = /^([^;]+)/.exec(
684
- S.slice(U + R.length + 1)
685
- )[1]);
686
- } catch {
687
- }
688
- return c.levels[f] === void 0 && (f = void 0), f;
689
- }
690
- }
691
- function L() {
692
- if (!(typeof window === n || !w)) {
693
- try {
694
- window.localStorage.removeItem(w);
695
- } catch {
696
- }
697
- try {
698
- window.document.cookie = encodeURIComponent(w) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
699
- } catch {
700
- }
701
- }
702
- }
703
- function P(f) {
704
- var S = f;
705
- if (typeof S == "string" && c.levels[S.toUpperCase()] !== void 0 && (S = c.levels[S.toUpperCase()]), typeof S == "number" && S >= 0 && S <= c.levels.SILENT)
706
- return S;
707
- throw new TypeError("log.setLevel() called with invalid level: " + f);
708
- }
709
- c.name = a, c.levels = {
710
- TRACE: 0,
711
- DEBUG: 1,
712
- INFO: 2,
713
- WARN: 3,
714
- ERROR: 4,
715
- SILENT: 5
716
- }, c.methodFactory = u || v, c.getLevel = function() {
717
- return E ?? C ?? k;
718
- }, c.setLevel = function(f, S) {
719
- return E = P(f), S !== !1 && O(E), l.call(c);
720
- }, c.setDefaultLevel = function(f) {
721
- C = P(f), y() || c.setLevel(f, !1);
722
- }, c.resetLevel = function() {
723
- E = null, L(), l.call(c);
724
- }, c.enableAll = function(f) {
725
- c.setLevel(c.levels.TRACE, f);
726
- }, c.disableAll = function(f) {
727
- c.setLevel(c.levels.SILENT, f);
728
- }, c.rebuild = function() {
729
- if (s !== c && (k = P(s.getLevel())), l.call(c), s === c)
730
- for (var f in r)
731
- r[f].rebuild();
732
- }, k = P(
733
- s ? s.getLevel() : "WARN"
734
- );
735
- var I = y();
736
- I != null && (E = P(I)), l.call(c);
737
- }
738
- s = new m(), s.getLogger = function(u) {
739
- if (typeof u != "symbol" && typeof u != "string" || u === "")
740
- throw new TypeError("You must supply a name when creating a logger.");
741
- var c = r[u];
742
- return c || (c = r[u] = new m(
743
- u,
744
- s.methodFactory
745
- )), c;
746
- };
747
- var _ = typeof window !== n ? window.log : void 0;
748
- return s.noConflict = function() {
749
- return typeof window !== n && window.log === s && (window.log = _), s;
750
- }, s.getLoggers = function() {
751
- return r;
752
- }, s.default = s, s;
753
- });
754
- })(K)), K.exports;
755
- }
756
- var Qt = Kt();
757
- const F = /* @__PURE__ */ Zt(Qt), Te = [
758
- Xe,
759
- Qe,
760
- Ke,
761
- nt,
762
- tt,
763
- et
52
+ const F = [
53
+ N,
54
+ D,
55
+ k,
56
+ L,
57
+ j,
58
+ T
764
59
  ];
765
- function en(e) {
60
+ function Z(e) {
766
61
  let t = null;
767
- const n = {};
768
- if (vt.forEach(e, (o) => {
769
- if (!St(o))
770
- throw F.error("Invalid React element found in children", { child: o }), new Error("Invalid React element found in children");
771
- const i = Te.find((r) => r === o.type);
772
- if (!i)
62
+ const o = {};
63
+ if (U.forEach(e, (n) => {
64
+ if (!W(n))
65
+ throw new Error(
66
+ `Invalid React element found in children: ${n}`,
67
+ {
68
+ cause: { child: n }
69
+ }
70
+ );
71
+ const s = F.find((a) => a === n.type);
72
+ if (!s)
773
73
  throw Error(
774
- `Component "${o.type}" is not valid as a child for Section, Expected one of: ${Te.map((r) => r.name).join(",")}`
74
+ `Component "${n.type}" is not valid as a child for Section, Expected one of: ${F.map((a) => a.name).join(",")}`
775
75
  );
776
- switch (i) {
777
- case tt:
778
- n.sectionHeader = o;
76
+ switch (s) {
77
+ case j:
78
+ o.sectionHeader = n;
779
79
  break;
780
- case et:
781
- n.sectionFooter = o;
80
+ case T:
81
+ o.sectionFooter = n;
782
82
  break;
783
- case Xe:
784
- t = o;
83
+ case N:
84
+ t = n;
785
85
  break;
786
- case Qe:
787
- n.header = o;
86
+ case D:
87
+ o.header = n;
788
88
  break;
789
- case Ke:
790
- n.footer = o;
89
+ case k:
90
+ o.footer = n;
791
91
  break;
792
- case nt:
793
- n.overlay = o;
92
+ case L:
93
+ o.overlay = n;
794
94
  break;
795
95
  }
796
96
  }), !t)
797
97
  throw Error("PageContent component is a required child for Section");
798
- return { ...n, content: t };
799
- }
800
- function tn(e, t) {
801
- return t === "landscape" ? { height: e.width, width: e.height } : e;
802
- }
803
- function nn(e, t) {
804
- return `@page section-${e} {
805
- margin: none;
806
- size:${t.width} ${t.height};
807
- width:${t.width};
808
- height:${t.height};
809
- }`;
810
- }
811
- const on = "paprize", ot = "pz-temp-container", ke = "data-pz-";
812
- function it(e) {
813
- return e.nodeType === Node.ELEMENT_NODE;
814
- }
815
- function rn(e) {
816
- return e.nodeType === Node.TEXT_NODE;
817
- }
818
- function ie(e) {
819
- const t = e.getBoundingClientRect(), n = getComputedStyle(e), o = parseFloat(n.marginTop) || 0, i = parseFloat(n.marginBottom) || 0;
820
- return t.height + o + i;
821
- }
822
- function sn(e) {
823
- e.style.visibility = "hidden", e.style.position = "absolute", e.style.left = "-9999px", e.style.top = "-9999px";
824
- }
825
- class $ {
826
- name;
827
- defaultValue;
828
- _reader;
829
- constructor(t, n, o) {
830
- this.name = t, this._reader = n, this.defaultValue = o;
831
- }
832
- read(t) {
833
- return this._reader(t);
834
- }
835
- static createStr(t, n) {
836
- return new $(t, (o) => o, n);
837
- }
838
- static createBool(t, n) {
839
- return new $(
840
- t,
841
- (o) => o === "true",
842
- n
843
- );
844
- }
845
- }
846
- const re = {
847
- hyphen: $.createStr("hyphen", "-"),
848
- keepOnSamePage: $.createBool("keep-on-same-page", !1),
849
- hyphenationEnabled: $.createBool(
850
- "hyphenation-enabled",
851
- !0
852
- )
853
- };
854
- function an(e) {
855
- const t = {};
856
- for (const n in e) {
857
- const o = e[n];
858
- if (o !== void 0) {
859
- const i = re[n];
860
- t[`${ke}${i.name}`] = String(o);
861
- }
862
- }
863
- return t;
864
- }
865
- const cn = Object.fromEntries(
866
- Object.entries(re).map(([e, t]) => [
867
- e,
868
- t.defaultValue
869
- ])
870
- ), Le = /* @__PURE__ */ new WeakMap();
871
- function rt(e) {
872
- if (!e)
873
- return {};
874
- if (!(e instanceof Element))
875
- return rt(e?.parentNode);
876
- const t = {};
877
- for (const i in re) {
878
- const r = re[i], s = `${ke}${r.name}`, d = e.getAttribute(s);
879
- d !== null && (t[i] = r.read(d));
880
- }
881
- const o = { ...e.parentNode ? Le.get(e.parentNode) : void 0, ...t };
882
- return Le.set(e, o), o;
883
- }
884
- const st = {
885
- id: "default",
886
- plugins: [],
887
- ...cn
888
- };
889
- function ln(e, t) {
890
- const n = rt(e);
891
- return { ...st, ...t, ...n };
98
+ return { ...o, content: t };
892
99
  }
893
- const N = F.getLogger(on);
894
- N.setDefaultLevel("info");
895
- const le = "\x1B[46mPLUGIN\x1B[0m";
896
- function D(e, t, ...n) {
897
- e.sort((o, i) => o.order - i.order).forEach((o) => {
898
- const i = o[t];
899
- if (i) {
900
- N.debug(
901
- le,
902
- `executing plugin ${o.name}:${String(t)} ()`,
903
- n
904
- );
905
- try {
906
- i(...n), N.debug(
907
- le,
908
- `plugin ${o.name}:${String(t)} executed`,
909
- n
910
- );
911
- } catch (r) {
912
- N.debug(
913
- le,
914
- `plugin ${o.name}:${String(t)} failed`,
915
- r
916
- );
917
- }
918
- }
919
- });
920
- }
921
- const W = {
922
- Element: "element",
923
- Text: "text"
924
- };
925
- class Ee {
926
- _node;
927
- _transaction;
928
- type = W.Element;
929
- config;
930
- constructor(t, n, o) {
931
- this._node = t, this._transaction = n, this.config = o;
932
- }
933
- appendChild(t) {
934
- this._transaction.isActive && this._transaction.addRollbackCallback(() => {
935
- this._node.removeChild(t.getNode());
936
- }), this._node.appendChild(t.getNode());
937
- }
938
- clone(t) {
939
- const n = this._node.cloneNode(t), o = new Ee(
940
- n,
941
- this._transaction,
942
- this.config
943
- );
944
- return D(
945
- this.config.plugins,
946
- "onClone",
947
- this.config.id,
948
- this._node,
949
- o
950
- ), o;
951
- }
952
- getHeight() {
953
- return ie(this._node);
954
- }
955
- remove() {
956
- this._transaction.addCommitCallback(() => {
957
- this._node.remove();
958
- });
959
- }
960
- isEmpty() {
961
- return this._node.innerHTML === "";
962
- }
963
- getChildrenCount() {
964
- return this._node.childNodes.length;
965
- }
966
- getNode() {
967
- return this._node;
968
- }
969
- }
970
- class un {
971
- _node;
972
- _transaction;
973
- type = W.Text;
974
- config;
975
- constructor(t, n, o) {
976
- this._node = t, this._transaction = n, this.config = o;
977
- }
978
- get textContent() {
979
- return this._node.textContent ?? "";
980
- }
981
- set textContent(t) {
982
- this._node.textContent = t;
983
- }
984
- remove() {
985
- this._transaction.addCommitCallback(() => {
986
- this._node.remove();
987
- });
988
- }
989
- getNode() {
990
- return this._node;
991
- }
992
- }
993
- function me(e, t, n) {
994
- if (rn(e))
995
- return new un(e, t, n);
996
- if (it(e))
997
- return new Ee(e, t, n);
998
- throw new Error("Unsupported node type");
999
- }
1000
- const J = "\x1B[106mDOM\x1B[0m";
1001
- class dn {
1002
- _transaction;
1003
- _treeWalker;
1004
- _config;
1005
- _completed = !1;
1006
- _currentNode = null;
1007
- _previousNode = null;
1008
- constructor(t, n, o) {
1009
- this._transaction = n, this._config = o, this._treeWalker = document.createTreeWalker(
1010
- t,
1011
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
1012
- );
1013
- }
1014
- get completed() {
1015
- return this._completed;
1016
- }
1017
- get currentNode() {
1018
- return this._currentNode;
1019
- }
1020
- get previousNode() {
1021
- return this._previousNode;
1022
- }
1023
- nextNode() {
1024
- this._treeWalker.nextNode() || (this._completed = !0), N.debug(J, "moving to next node"), this.setState();
1025
- }
1026
- nextSiblingOrParentSibling() {
1027
- let t = 0;
1028
- if (this._treeWalker.nextSibling())
1029
- return N.debug(J, "moving to next sibling node"), this.setState(), { parentsTraversed: t };
1030
- for (; this._treeWalker.parentNode(); )
1031
- if (t++, this._treeWalker.nextSibling())
1032
- return N.debug(
1033
- J,
1034
- "moving to parent sibling node, traversed:",
1035
- t
1036
- ), this.setState(), { parentsTraversed: t };
1037
- return this._completed = !0, { parentsTraversed: t };
1038
- }
1039
- firstChildOrNextNode() {
1040
- return this._treeWalker.firstChild() ? (N.debug(J, "moving to first child node"), this.setState(), { parentsTraversed: 1 }) : (this.nextNode(), { parentsTraversed: 0 });
1041
- }
1042
- setState() {
1043
- this._previousNode = this._currentNode, this._currentNode = me(
1044
- this._treeWalker.currentNode,
1045
- this._transaction,
1046
- ln(this._treeWalker.currentNode, this._config)
1047
- ), this.currentNode, this.previousNode, N.debug(J, "moved to node", {
1048
- currentNode: this.currentNode,
1049
- previousNode: this.previousNode
1050
- });
1051
- }
1052
- }
1053
- class pn {
1054
- _onRollback;
1055
- _onCommit;
1056
- isActive;
1057
- constructor() {
1058
- this._onRollback = [], this._onCommit = [], this.isActive = !1;
1059
- }
1060
- start = () => {
1061
- if (this.isActive)
1062
- throw new Error("Transaction already in progress");
1063
- this.isActive = !0, this._onRollback = [], this._onCommit = [];
1064
- };
1065
- addRollbackCallback = (t) => {
1066
- this._onRollback.push(t);
1067
- };
1068
- addCommitCallback = (t) => {
1069
- if (!this.isActive) {
1070
- t();
1071
- return;
1072
- }
1073
- this._onCommit.push(t);
1074
- };
1075
- rollback = () => {
1076
- this.isActive && (this.isActive = !1, this._onRollback.forEach((t) => t()));
1077
- };
1078
- commit = () => {
1079
- this.isActive && (this.isActive = !1, this._onCommit.forEach((t) => t()));
1080
- };
1081
- }
1082
- const Ie = "\x1B[102mPAGE\x1B[0m";
1083
- class q {
1084
- currentPage;
1085
- activeElement;
1086
- currentElement;
1087
- parentStack;
1088
- pageIsFull;
1089
- pageIndex;
1090
- pageHeight;
1091
- constructor(t, n, o, i, r, s, d) {
1092
- this.currentPage = t, this.activeElement = n, this.currentElement = o, this.parentStack = i, this.pageIsFull = r, this.pageIndex = s, this.pageHeight = d;
1093
- }
1094
- static create(t, n, o, i) {
1095
- return new q(
1096
- t,
1097
- null,
1098
- t,
1099
- n,
1100
- !1,
1101
- o,
1102
- i
1103
- );
1104
- }
1105
- clone = () => new q(
1106
- this.currentPage,
1107
- this.activeElement,
1108
- this.currentElement,
1109
- [...this.parentStack],
1110
- this.pageIsFull,
1111
- this.pageIndex,
1112
- this.pageHeight
1113
- );
1114
- }
1115
- class Ce {
1116
- _pageState;
1117
- _transaction;
1118
- _tempContainer;
1119
- _config;
1120
- constructor(t, n, o, i) {
1121
- this._tempContainer = t, this._config = i, this._transaction = o;
1122
- const r = Ce.createPageHtmlElement(
1123
- n.width
1124
- ), s = this.createNewPage(r);
1125
- this._pageState = q.create(s, [], 0, n.height), D(this._config.plugins, "onNewPage", i.id, this);
1126
- }
1127
- nextPage() {
1128
- const t = this.createNewPage(
1129
- this._pageState.currentPage.getNode().cloneNode(!1)
1130
- ), n = q.create(
1131
- t,
1132
- [],
1133
- this._pageState.pageIndex + 1,
1134
- this._pageState.pageHeight
1135
- );
1136
- this.cloneParentStackToNewPage(n), this.cleanupEmptyParent(), this._pageState = n, D(
1137
- this._config.plugins,
1138
- "onNewPage",
1139
- this._config.id,
1140
- this
1141
- );
1142
- }
1143
- cloneParentStackToNewPage(t) {
1144
- for (const n of this._pageState.parentStack) {
1145
- const o = n.clone(!1);
1146
- t.currentElement.appendChild(o), t.currentElement = o, t.parentStack.push(o);
1147
- }
1148
- }
1149
- cleanupEmptyParent() {
1150
- const t = [...this._pageState.parentStack], n = () => {
1151
- for (let o = t.length - 1; o >= 0; o--) {
1152
- const i = t[o];
1153
- i.isEmpty() && i.remove();
1154
- }
1155
- };
1156
- this._transaction.addCommitCallback(n);
1157
- }
1158
- enterElement() {
1159
- if (!this._pageState.activeElement || this._pageState.activeElement.type !== W.Element)
1160
- throw new Error("Invalid state: activeElement is not an Element");
1161
- N.debug(
1162
- Ie,
1163
- "entering an element",
1164
- this._pageState.activeElement
1165
- ), this._pageState.currentElement = this._pageState.activeElement, this._pageState.parentStack.push(this._pageState.activeElement);
1166
- }
1167
- leaveElement() {
1168
- this._pageState.activeElement = null;
1169
- const t = this._pageState.parentStack.pop();
1170
- N.debug(Ie, "leaving a parent element", t);
1171
- const n = this._pageState.parentStack.at(-1);
1172
- this._pageState.currentElement = n ?? this._pageState.currentPage;
1173
- }
1174
- static createPageHtmlElement(t) {
1175
- const n = document.createElement("div");
1176
- return n.style.width = `${t}px`, n.style.maxWidth = `${t}px`, n;
1177
- }
1178
- createNewPage(t) {
1179
- return this._tempContainer.appendChild(t), this._transaction.isActive && this._transaction.addRollbackCallback(() => {
1180
- this._tempContainer.removeChild(t);
1181
- }), me(t, this._transaction, this._config);
1182
- }
1183
- startTransaction() {
1184
- this._transaction.start();
1185
- const t = this._pageState.clone();
1186
- return this._transaction.addRollbackCallback(() => {
1187
- this._pageState = t;
1188
- }), this._transaction;
1189
- }
1190
- hasEmptySpace(t) {
1191
- return !this._pageState.pageIsFull && this._pageState.currentPage.getHeight() + (t || 1e-4) <= this._pageState.pageHeight;
1192
- }
1193
- isOverFlow() {
1194
- return this._pageState.currentPage.getHeight() > this._pageState.pageHeight;
1195
- }
1196
- markPageAsFull() {
1197
- this._pageState.pageIsFull = !0;
1198
- }
1199
- appendChild(t, n) {
1200
- const o = t.clone(n);
1201
- return this._pageState.currentElement.appendChild(o), this._pageState.activeElement = o, o;
1202
- }
1203
- addTextNode(t) {
1204
- if (this._pageState.activeElement?.type === W.Text)
1205
- return this._pageState.activeElement;
1206
- const n = document.createTextNode(t), o = me(
1207
- n,
1208
- this._transaction,
1209
- this._config
1210
- );
1211
- return this._pageState.currentElement.appendChild(o), this._pageState.activeElement = o, o;
1212
- }
1213
- getPageState() {
1214
- return this._pageState;
1215
- }
1216
- }
1217
- const x = {
1218
- None: 0,
1219
- // The node fits completely on the page, no further splitting required.
1220
- FullNodePlaced: 1,
1221
- // The entire node was placed on the page, continue with the next sibling or element.
1222
- SplitChildren: 2
1223
- // The node is too large for the page, and its children must be paginated individually.
1224
- };
1225
- function fn(e, t) {
1226
- const n = Re(e, t);
1227
- if (n !== x.None)
1228
- return n;
1229
- const { rollback: o, commit: i } = t.startTransaction();
1230
- t.nextPage();
1231
- const r = Re(e, t);
1232
- return r !== x.None ? (i(), r) : (o(), N.debug("Element is too big to fit on a page", e), x.None);
1233
- }
1234
- function Re(e, t) {
1235
- if (t.hasEmptySpace(e.getHeight())) {
1236
- const o = t.appendChild(e, !0);
1237
- if (t.isOverFlow())
1238
- o.remove();
1239
- else
1240
- return x.FullNodePlaced;
1241
- }
1242
- if (e.config.keepOnSamePage || e.getChildrenCount() === 0)
1243
- return x.None;
1244
- const n = t.appendChild(e, !1);
1245
- return t.isOverFlow() ? (n.remove(), x.None) : x.SplitChildren;
1246
- }
1247
- function gn(e, t) {
1248
- let n = x.FullNodePlaced;
1249
- const o = e.textContent.split(/(\s+)/).filter((s) => s !== "");
1250
- let i, r = 0;
1251
- for (; i || r < o.length; ) {
1252
- const s = i ?? o[r], d = hn(s, t, e.config);
1253
- d.completed || (n = x.None), d.pendingToken ? i = d.pendingToken : (i = void 0, r++);
1254
- }
1255
- return n;
1256
- }
1257
- function hn(e, t, n) {
1258
- t.hasEmptySpace() || t.nextPage();
1259
- let o = t.addTextNode("");
1260
- const i = o.textContent;
1261
- if (o.textContent += e, !t.isOverFlow())
1262
- return {
1263
- completed: !0
1264
- };
1265
- o.textContent = i;
1266
- const r = mn(e, t, n);
1267
- return {
1268
- pendingToken: r.leftovers,
1269
- completed: r.completed
1270
- };
1271
- }
1272
- function mn(e, t, n) {
1273
- const { rollback: o, commit: i } = t.startTransaction();
1274
- if (t.nextPage(), t.addTextNode(e), !t.isOverFlow())
1275
- return i(), {
1276
- completed: !0
1277
- };
1278
- if (o(), !n.hyphenationEnabled)
1279
- return N.warn("Hyphenation disabled, skipping oversized token:", e), {
1280
- completed: !1
1281
- };
1282
- const r = vn(e, n.hyphen, t);
1283
- return {
1284
- completed: !0,
1285
- leftovers: r && r.length > 0 ? r : void 0
1286
- };
1287
- }
1288
- function vn(e, t, n) {
1289
- const o = n.addTextNode("");
1290
- let i = "";
1291
- for (let r = 0; r < e.length; r++) {
1292
- const s = e[r], d = i + s;
1293
- if (o.textContent = d + t, !n.hasEmptySpace())
1294
- return o.textContent = i ? i + t : "", n.markPageAsFull(), e.slice(r);
1295
- i = d;
1296
- }
1297
- return null;
1298
- }
1299
- const G = "\x1B[103mPAGINATOR\x1B[0m";
1300
- class se {
1301
- _domState;
1302
- _pageManager;
1303
- _transaction;
1304
- _tempContainer;
1305
- _config;
1306
- constructor(t, n, o) {
1307
- this._config = { ...st, ...o }, this._tempContainer = se.createTempContainer(this._config.id), this._transaction = new pn(), this._domState = new dn(t, this._transaction, this._config), this._pageManager = new Ce(
1308
- this._tempContainer,
1309
- n,
1310
- this._transaction,
1311
- this._config
1312
- );
1313
- }
1314
- static createTempContainer(t) {
1315
- const n = document.createElement("div");
1316
- return n.style.display = "flex", n.style.flexDirection = "column", n.style.gap = "20px", n.setAttribute(`${ke}-section-id`, t), n.classList.add(ot), sn(n), document.body.appendChild(n), n;
1317
- }
1318
- static paginate(t, n, o) {
1319
- const i = new se(t, n, o);
1320
- i.processAllNodes();
1321
- const r = Array.from(i._tempContainer.childNodes).filter((s) => it(s)).map((s) => s.innerHTML);
1322
- return i._tempContainer.remove(), r;
1323
- }
1324
- processAllNodes() {
1325
- this._domState.nextNode();
1326
- do {
1327
- switch (F.debug(
1328
- G,
1329
- "paginating node",
1330
- this._domState.currentNode
1331
- ), this.processCurrentNode()) {
1332
- case x.None:
1333
- this.handleNodeSkipped();
1334
- break;
1335
- case x.FullNodePlaced:
1336
- this.handleFullNodePlaced();
1337
- break;
1338
- case x.SplitChildren:
1339
- this.handleChildrenSplit();
1340
- break;
1341
- }
1342
- D(
1343
- this._config.plugins,
1344
- "afterVisitNode",
1345
- this._config.id,
1346
- this._domState,
1347
- this._pageManager
1348
- );
1349
- } while (this._domState.completed === !1);
1350
- F.debug(G, "pagination completed");
1351
- }
1352
- handleNodeSkipped() {
1353
- F.debug(G, "node skipped - couldn't paginate"), this._domState.currentNode, this._domState.nextNode();
1354
- }
1355
- handleFullNodePlaced() {
1356
- F.debug(G, "node fully paginated");
1357
- const { parentsTraversed: t } = this._domState.nextSiblingOrParentSibling();
1358
- for (let n = 0; n < t; n++)
1359
- this._pageManager.leaveElement();
1360
- }
1361
- handleChildrenSplit() {
1362
- F.debug(
1363
- G,
1364
- "node partially paginated - splitting children"
1365
- ), this._domState.firstChildOrNextNode().parentsTraversed === 1 && this._domState.previousNode?.type === W.Element && this._pageManager.enterElement();
1366
- }
1367
- processCurrentNode() {
1368
- if (!this._domState.currentNode)
1369
- return x.None;
1370
- if (this._domState.currentNode.type === W.Element) {
1371
- const t = {};
1372
- return D(
1373
- this._config.plugins,
1374
- "onVisitElement",
1375
- this._config.id,
1376
- this._domState,
1377
- this._pageManager,
1378
- t
1379
- ), t.result !== void 0 ? t.result : fn(
1380
- this._domState.currentNode,
1381
- this._pageManager
1382
- );
1383
- } else {
1384
- const t = {};
1385
- return D(
1386
- this._config.plugins,
1387
- "onVisitText",
1388
- this._config.id,
1389
- this._domState,
1390
- this._pageManager,
1391
- t
1392
- ), t.result !== void 0 ? t.result : gn(
1393
- this._domState.currentNode,
1394
- this._pageManager
1395
- );
1396
- }
1397
- }
1398
- }
1399
- const at = "data-pz-page-break", Sn = "pageBreak", _n = {
1400
- name: Sn,
1401
- order: 1,
1402
- onVisitElement: (e, t, n, o) => {
1403
- t.currentNode.getNode().getAttribute(at) === "true" && (n.markPageAsFull(), o.result = x.FullNodePlaced);
1404
- }
1405
- }, wn = [_n], ct = Se({
1406
- pageNumber: 0,
100
+ const x = h(""), _ = h({
101
+ pageIndex: 0,
1407
102
  totalPages: 0
1408
103
  });
1409
- function yn(e) {
1410
- return e ? `${e.top} ${e.right} ${e.bottom} ${e.left}` : "0";
1411
- }
1412
- function bn(e) {
1413
- const t = e.getBoundingClientRect(), n = getComputedStyle(e), o = parseFloat(n.marginLeft) || 0, i = parseFloat(n.marginRight) || 0;
1414
- return {
1415
- height: ie(e),
1416
- width: t.width + o + i
1417
- };
1418
- }
1419
- const ae = Se("");
1420
- function Fe({
104
+ function b({
1421
105
  elements: e,
1422
- dimensions: t,
1423
- margin: n,
1424
- pageNumber: o,
1425
- totalPages: i,
1426
- ref: r,
1427
- sectionHeaderRef: s,
106
+ dimension: t,
107
+ margin: o,
108
+ pageIndex: n,
109
+ totalPages: s,
110
+ ref: a,
111
+ sectionHeaderRef: l,
1428
112
  sectionFooterRef: d,
1429
- contentRef: h
113
+ pageHeaderRef: m,
114
+ pageFooterRef: y,
115
+ contentRef: P
1430
116
  }) {
1431
- const p = Z(ae), l = T(
1432
- () => ({ pageNumber: o, totalPages: i }),
1433
- [o, i]
117
+ const v = g(x), C = u(
118
+ () => ({ pageIndex: n, totalPages: s }),
119
+ [n, s]
1434
120
  );
1435
- return /* @__PURE__ */ b(ct, { value: l, children: /* @__PURE__ */ de(
121
+ return /* @__PURE__ */ r(_, { value: C, children: /* @__PURE__ */ R(
1436
122
  "div",
1437
123
  {
1438
- id: `${p}-${o}`,
1439
- className: "paprize-page paprize-page-component",
1440
- ref: r,
1441
- style: {
1442
- width: t.width,
1443
- height: t.height,
1444
- maxHeight: t.height,
1445
- position: "relative",
1446
- padding: yn(n),
1447
- zIndex: 1
1448
- },
124
+ id: `${v}-${n}`,
125
+ className: A,
126
+ ref: a,
127
+ style: i.page(t, o ?? O.None),
1449
128
  children: [
1450
- e.sectionHeader && o == 1 && /* @__PURE__ */ b(
1451
- "div",
1452
- {
1453
- className: "paprize-page-component",
1454
- ref: s,
1455
- children: e.sectionHeader
1456
- }
1457
- ),
1458
- e.header && /* @__PURE__ */ b("div", { className: "paprize-page-component", children: e.header }),
1459
- /* @__PURE__ */ b(
1460
- "div",
1461
- {
1462
- style: {
1463
- overflow: "hidden",
1464
- width: "100%",
1465
- height: "100%"
1466
- },
1467
- ref: h,
1468
- children: e.content
1469
- }
1470
- ),
1471
- e.overlay && /* @__PURE__ */ b(
1472
- "div",
1473
- {
1474
- style: {
1475
- position: "absolute",
1476
- width: "100%",
1477
- height: "100%",
1478
- left: 0,
1479
- top: 0
1480
- },
1481
- children: e.overlay
1482
- }
1483
- ),
1484
- (e.footer || e.sectionFooter) && /* @__PURE__ */ de(
129
+ e.sectionHeader && n === 0 && /* @__PURE__ */ r("div", { style: i.component, ref: l, children: e.sectionHeader }),
130
+ e.header && /* @__PURE__ */ r("div", { style: i.component, ref: m, children: e.header }),
131
+ /* @__PURE__ */ r("div", { style: i.pageContent, ref: P, children: e.content }),
132
+ e.overlay && /* @__PURE__ */ r("div", { style: i.overlay, children: e.overlay }),
133
+ (e.footer || e.sectionFooter) && /* @__PURE__ */ R(
1485
134
  "div",
1486
135
  {
1487
- className: "paprize-page-component",
1488
- style: { marginTop: "auto" },
136
+ style: { ...i.component, marginTop: "auto" },
1489
137
  children: [
1490
- e.footer && /* @__PURE__ */ b("div", { className: "paprize-page-component", children: e.footer }),
1491
- e.sectionFooter && o == i && /* @__PURE__ */ b(
138
+ e.footer && /* @__PURE__ */ r(
1492
139
  "div",
1493
140
  {
1494
- className: "paprize-page-component",
141
+ style: i.component,
142
+ ref: y,
143
+ children: e.footer
144
+ }
145
+ ),
146
+ e.sectionFooter && n === s - 1 && /* @__PURE__ */ r(
147
+ "div",
148
+ {
149
+ style: i.component,
1495
150
  ref: d,
1496
151
  children: e.sectionFooter
1497
152
  }
@@ -1503,542 +158,285 @@ function Fe({
1503
158
  }
1504
159
  ) });
1505
160
  }
1506
- function kn(e, t, n) {
1507
- const { height: o, width: i } = bn(e), r = t ? ie(t) : 0, s = n ? ie(n) : 0;
1508
- return { height: o, width: i, sectionHeaderHeight: r, sectionFooterHeight: s };
1509
- }
1510
- function En(e, t, n) {
1511
- return {
1512
- name: "sectionPageHeight",
1513
- order: 1,
1514
- afterVisitNode: (o, i, r) => {
1515
- !i.completed || n <= 0 || r.hasEmptySpace(n) || r.nextPage();
1516
- },
1517
- onNewPage: (o, i) => {
1518
- const r = i.getPageState();
1519
- r.pageIndex === 0 ? r.pageHeight = e + n : r.pageHeight = e + t + n;
1520
- }
1521
- };
1522
- }
1523
- function Cn(e, t) {
1524
- const n = T(
1525
- () => X(null, (o, i, ...r) => e(o, i, ...r)),
1526
- [e]
1527
- );
1528
- return ye(n);
1529
- }
1530
- const Nn = {
1531
- totalPages: 0,
1532
- isPaginated: !1,
1533
- pendingSuspensions: 0
1534
- }, lt = () => {
1535
- const e = Z(ae), t = T(
1536
- () => X((o) => {
1537
- const i = o(V).get(e);
1538
- return i ? {
1539
- totalPages: i.totalPages,
1540
- isPaginated: i.isPaginated,
1541
- pendingSuspensions: i.pendingSuspensions.size
1542
- } : Nn;
161
+ const $ = h({
162
+ addPlugin: () => {
163
+ throw new Error("addPlugin must be used within a Section");
164
+ },
165
+ addSuspense: () => {
166
+ throw new Error("addSuspense must be used within a Section");
167
+ }
168
+ });
169
+ function ee(e) {
170
+ const t = u(
171
+ () => ({
172
+ plugins: e ?? [],
173
+ suspense: []
1543
174
  }),
1544
175
  [e]
1545
- ), n = oe(t);
1546
- return {
1547
- sectionId: e,
1548
- totalPages: n.totalPages
1549
- };
1550
- };
1551
- function An(e) {
1552
- return lt(), Cn((n) => (n(V).get(e)?.pendingSuspensions?.size ?? 0) > 0);
1553
- }
1554
- const Ne = (e) => {
1555
- const t = T(
1556
- () => X(
1557
- () => 0,
1558
- (n, o, i) => {
1559
- o(
1560
- V,
1561
- (r) => new Map(r).set(
1562
- e,
1563
- i(r.get(e) ?? Gt)
1564
- )
1565
- );
176
+ ), o = u(
177
+ () => ({
178
+ addPlugin: (n) => {
179
+ t.plugins.push(n);
180
+ },
181
+ addSuspense: (n) => {
182
+ t.suspense.push(n);
1566
183
  }
1567
- ),
1568
- [e]
184
+ }),
185
+ [t]
1569
186
  );
1570
- return ye(t);
1571
- }, ue = "\x1B[41mREACT\x1B[0m", ze = (e, t, n, o, i) => e?.dimensions === n && e?.margin === o && e?.elements === t && e?.config === i && e?.elements === t;
1572
- function Pn(e, t, n, o) {
1573
- const i = Z(ae), r = An(i), s = Ne(i), d = B(null), [h, p] = $e({
1574
- results: null,
1575
- isLoading: !0
1576
- }), l = B(null), g = B(null), v = B(null), m = B(null);
1577
- return Y(() => {
1578
- ze(
1579
- d.current,
1580
- e,
1581
- t,
1582
- n,
1583
- o
1584
- ) || p({
1585
- results: null,
1586
- isLoading: !0
1587
- });
1588
- }, [t, e, n, o]), Y(() => {
1589
- if (!l.current || !m.current || ze(d.current, e, t, n, o))
1590
- return;
1591
- if (r()) {
1592
- N.info(ue, `Section "${i}" is suspended`);
1593
- return;
1594
- }
1595
- const { height: _, width: a, sectionFooterHeight: u, sectionHeaderHeight: c } = kn(
1596
- m.current,
1597
- g.current,
1598
- v.current
1599
- ), k = [
1600
- ...o.plugins ?? wn,
1601
- En(
1602
- _,
1603
- c,
1604
- u
1605
- )
1606
- ];
1607
- N.debug(ue, "Calling Paginator", {
1608
- sectionName: i,
1609
- height: _,
1610
- width: a,
1611
- sectionFooterHeight: u,
1612
- sectionHeaderHeight: c,
1613
- plugins: k
1614
- });
1615
- const C = se.paginate(
1616
- m.current,
1617
- { height: _, width: a },
1618
- { ...o, plugins: k }
1619
- );
1620
- N.debug(ue, "Paginator Result", {
1621
- sectionName: i,
1622
- paginatorResult: C
1623
- }), p({
1624
- results: C,
1625
- isLoading: !1
1626
- }), s((E) => ({
1627
- ...E,
1628
- totalPages: C.length,
1629
- isPaginated: !0
1630
- })), d.current = { elements: e, dimensions: t, margin: n, config: o };
1631
- }), {
1632
- ...h,
1633
- pageRef: l,
1634
- sectionHeaderRef: g,
1635
- sectionFooterRef: v,
1636
- contentRef: m
187
+ return {
188
+ controllerState: t,
189
+ controllerValue: o
1637
190
  };
1638
191
  }
1639
- function xn({
192
+ function te({
1640
193
  elements: e,
1641
- dimensions: t,
1642
- margin: n,
1643
- config: o
194
+ dimension: t,
195
+ margin: o,
196
+ config: n
1644
197
  }) {
1645
- const { results: i, pageRef: r, sectionHeaderRef: s, sectionFooterRef: d, contentRef: h } = Pn(e, t, n, o);
1646
- return i !== null ? /* @__PURE__ */ b(z, { children: i.map((l, g) => /* @__PURE__ */ b(
1647
- Fe,
1648
- {
1649
- elements: {
1650
- ...e,
1651
- content: /* @__PURE__ */ b(
1652
- "div",
1653
- {
1654
- style: { display: "contents" },
1655
- dangerouslySetInnerHTML: {
1656
- __html: l
198
+ const s = g(x), { controllerState: a, controllerValue: l } = ee(
199
+ n?.plugins
200
+ ), d = w(), m = c(null), y = c(null), P = c(null), v = c(null), C = c(null), I = c(null), [J, M] = X(
201
+ null
202
+ );
203
+ return S(() => {
204
+ if (I.current)
205
+ return d.tryAddSection(
206
+ {
207
+ ...n,
208
+ id: s,
209
+ dimension: t,
210
+ margin: o,
211
+ plugins: a.plugins,
212
+ suspense: a.suspense
213
+ },
214
+ {
215
+ pageContent: I.current,
216
+ sectionHeader: y.current,
217
+ sectionFooter: P.current,
218
+ pageFooter: C.current,
219
+ pageHeader: v.current
220
+ },
221
+ (p) => {
222
+ M(p);
223
+ }
224
+ ), () => {
225
+ d.removeSection(s);
226
+ };
227
+ }, [n, a, t, o, d, s]), /* @__PURE__ */ R($, { value: l, children: [
228
+ J?.map((p) => /* @__PURE__ */ r(
229
+ b,
230
+ {
231
+ elements: {
232
+ ...e,
233
+ content: /* @__PURE__ */ r(
234
+ "div",
235
+ {
236
+ style: { display: "contents" },
237
+ dangerouslySetInnerHTML: {
238
+ __html: p.pageContentHtml
239
+ }
1657
240
  }
1658
- }
1659
- )
241
+ )
242
+ },
243
+ dimension: t,
244
+ margin: o,
245
+ pageIndex: p.index,
246
+ totalPages: p.totalPages
1660
247
  },
1661
- dimensions: t,
1662
- margin: n,
1663
- pageNumber: g + 1,
1664
- totalPages: i.length
1665
- },
1666
- g
1667
- )) }) : _t(
1668
- /* @__PURE__ */ b("div", { className: ot, style: {
1669
- visibility: "hidden",
1670
- position: "absolute",
1671
- left: "-9999px",
1672
- top: "-9999px"
1673
- }, children: /* @__PURE__ */ b(
1674
- Fe,
1675
- {
1676
- elements: e,
1677
- dimensions: t,
1678
- margin: n,
1679
- pageNumber: 1,
1680
- totalPages: 1,
1681
- ref: r,
1682
- sectionHeaderRef: s,
1683
- sectionFooterRef: d,
1684
- contentRef: h
1685
- }
1686
- ) }),
1687
- document.body
1688
- );
248
+ p.index
249
+ )),
250
+ Y(
251
+ /* @__PURE__ */ r("div", { style: i.outOfScreen, children: /* @__PURE__ */ r(
252
+ b,
253
+ {
254
+ elements: e,
255
+ dimension: t,
256
+ margin: o,
257
+ pageIndex: 0,
258
+ totalPages: 1,
259
+ ref: m,
260
+ sectionHeaderRef: y,
261
+ sectionFooterRef: P,
262
+ pageHeaderRef: v,
263
+ pageFooterRef: C,
264
+ contentRef: I
265
+ }
266
+ ) }),
267
+ document.body
268
+ )
269
+ ] });
1689
270
  }
1690
- function qn({
271
+ let ne = 1;
272
+ function me({
1691
273
  children: e,
1692
- dimension: t,
274
+ id: t,
275
+ dimension: o,
1693
276
  orientation: n = "portrait",
1694
- margin: o,
1695
- config: i
277
+ margin: s,
278
+ config: a
1696
279
  }) {
1697
- const r = De(), s = T(
1698
- () => ({ ...i, id: i?.id ?? r }),
1699
- [i, r]
1700
- ), d = s.id, h = Ne(d);
1701
- T(() => {
1702
- h((l) => ({ ...l, isPaginated: !1 }));
1703
- }, [h]);
1704
- const p = T(
1705
- () => ({
1706
- dimensions: tn(t, n),
1707
- elements: en(e),
1708
- margin: o,
1709
- config: s
1710
- }),
1711
- [e, t, o, s, n]
280
+ const l = u(() => t ?? `__000${ne++}`, [t]), d = u(() => Z(e), [e]), m = u(
281
+ () => q(o, n),
282
+ [o, n]
1712
283
  );
1713
- return _e(nn(d, p.dimensions)), /* @__PURE__ */ b(
284
+ return /* @__PURE__ */ r(
1714
285
  "section",
1715
286
  {
1716
- className: "paprize-section",
1717
- id: `section-${d}`,
1718
- style: { page: `section-${d}` },
1719
- children: /* @__PURE__ */ b(ae, { value: d, children: /* @__PURE__ */ b(
1720
- xn,
287
+ className: G,
288
+ id: l,
289
+ style: i.section(l),
290
+ children: /* @__PURE__ */ r(x, { value: l, children: /* @__PURE__ */ r(
291
+ te,
1721
292
  {
1722
- elements: p.elements,
1723
- dimensions: p.dimensions,
1724
- margin: p.margin,
1725
- config: p.config
293
+ elements: d,
294
+ dimension: m,
295
+ margin: s,
296
+ config: a
1726
297
  }
1727
298
  ) })
1728
299
  }
1729
300
  );
1730
301
  }
1731
- function Zn() {
1732
- return /* @__PURE__ */ b("span", { [at]: "true" });
302
+ function Se() {
303
+ return /* @__PURE__ */ r("span", { [K]: "true" });
1733
304
  }
1734
- function Xn({ children: e, ...t }) {
1735
- return /* @__PURE__ */ b(
305
+ function ye({ children: e, ...t }) {
306
+ return /* @__PURE__ */ r(
1736
307
  "div",
1737
308
  {
1738
309
  style: { display: "contents" },
1739
- ...an(t),
310
+ ...Q(t),
1740
311
  children: e
1741
312
  }
1742
313
  );
1743
314
  }
1744
- const Kn = () => {
1745
- const e = Z(ct);
315
+ const Pe = () => {
316
+ const e = g(_);
1746
317
  return {
1747
- pageNumber: e.pageNumber,
318
+ pageIndex: e.pageIndex,
1748
319
  totalPages: e.totalPages
1749
320
  };
1750
- };
1751
- function Qn() {
1752
- const e = oe(V), t = oe(be);
1753
- return T(
1754
- () => ({
1755
- totalSections: t.totalSections,
1756
- isPaginated: t.isPaginated,
1757
- isFirstPaginationCompleted: t.totalSections > 0,
1758
- sections: Array.from(e.entries()).map(
1759
- ([n, { totalPages: o, isPaginated: i }]) => ({
1760
- sectionId: n,
1761
- totalPages: o,
1762
- isPaginated: i
1763
- })
1764
- )
1765
- }),
1766
- [t.isPaginated, t.totalSections, e]
321
+ }, ve = () => {
322
+ const e = g(x), t = w(), o = c({
323
+ pages: [],
324
+ isPaginated: !1,
325
+ isSuspended: !1,
326
+ index: -1,
327
+ sectionId: e
328
+ }), n = H(
329
+ (s) => t.monitor.addEventListener(
330
+ "sectionCompleted",
331
+ (a) => {
332
+ a.sectionId === e && (o.current = a, s());
333
+ }
334
+ ),
335
+ () => o.current
1767
336
  );
337
+ return {
338
+ sectionId: e,
339
+ sectionIndex: n.index,
340
+ isSuspended: n.isSuspended,
341
+ isPaginated: n.isPaginated,
342
+ pages: n.pages.map((s) => ({
343
+ pageIndex: s.index,
344
+ totalPages: s.totalPages
345
+ }))
346
+ };
347
+ };
348
+ function oe(e) {
349
+ return {
350
+ pageIndex: e.index,
351
+ totalPages: e.totalPages
352
+ };
1768
353
  }
1769
- function Tn(e, t = !0) {
1770
- const n = De(), o = Ne(e);
1771
- return T(() => {
1772
- t && o((i) => ({
1773
- ...i,
1774
- pendingSuspensions: new Set(i.pendingSuspensions).add(n)
1775
- }));
1776
- }, [n, o, t]), T(() => ({
1777
- release: () => {
1778
- o((i) => {
1779
- const r = new Set(i.pendingSuspensions);
1780
- return r.delete(n), {
1781
- ...i,
1782
- pendingSuspensions: r
1783
- };
1784
- });
1785
- }
1786
- }), [n, o]);
1787
- }
1788
- const Ln = "paprize";
1789
- class H {
1790
- name;
1791
- defaultValue;
1792
- _reader;
1793
- constructor(t, n, o) {
1794
- this.name = t, this._reader = n, this.defaultValue = o;
1795
- }
1796
- read(t) {
1797
- return this._reader(t);
1798
- }
1799
- static createStr(t, n) {
1800
- return new H(t, (o) => o, n);
1801
- }
1802
- static createBool(t, n) {
1803
- return new H(
1804
- t,
1805
- (o) => o === "true",
1806
- n
1807
- );
1808
- }
354
+ function re(e) {
355
+ return {
356
+ sectionId: e.sectionId,
357
+ sectionIndex: e.index,
358
+ isPaginated: e.isPaginated,
359
+ isSuspended: e.isSuspended,
360
+ pages: e.pages.map(oe)
361
+ };
1809
362
  }
1810
- const In = {
1811
- hyphen: H.createStr("hyphen", "-"),
1812
- keepOnSamePage: H.createBool("keep-on-same-page", !1),
1813
- hyphenationEnabled: H.createBool(
1814
- "hyphenation-enabled",
1815
- !0
1816
- )
1817
- }, Rn = Object.fromEntries(
1818
- Object.entries(In).map(([e, t]) => [
1819
- e,
1820
- t.defaultValue
1821
- ])
1822
- );
1823
- ({
1824
- ...Rn
1825
- });
1826
- function Fn(e) {
1827
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
363
+ function se(e) {
364
+ return {
365
+ sections: e.sections.map(re)
366
+ };
1828
367
  }
1829
- var ve = { exports: {} }, zn = ve.exports, Oe;
1830
- function On() {
1831
- return Oe || (Oe = 1, (function(e) {
1832
- (function(t, n) {
1833
- e.exports ? e.exports = n() : t.log = n();
1834
- })(zn, function() {
1835
- var t = function() {
1836
- }, n = "undefined", o = typeof window !== n && typeof window.navigator !== n && /Trident\/|MSIE /.test(window.navigator.userAgent), i = [
1837
- "trace",
1838
- "debug",
1839
- "info",
1840
- "warn",
1841
- "error"
1842
- ], r = {}, s = null;
1843
- function d(a, u) {
1844
- var c = a[u];
1845
- if (typeof c.bind == "function")
1846
- return c.bind(a);
1847
- try {
1848
- return Function.prototype.bind.call(c, a);
1849
- } catch {
1850
- return function() {
1851
- return Function.prototype.apply.apply(c, [a, arguments]);
1852
- };
1853
- }
368
+ function Ce() {
369
+ const e = w(), t = c({
370
+ sections: []
371
+ }), o = H(
372
+ (n) => e.monitor.addEventListener(
373
+ "paginationCycleCompleted",
374
+ (s) => {
375
+ t.current = s, n();
1854
376
  }
1855
- function h() {
1856
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
1857
- }
1858
- function p(a) {
1859
- return a === "debug" && (a = "log"), typeof console === n ? !1 : a === "trace" && o ? h : console[a] !== void 0 ? d(console, a) : console.log !== void 0 ? d(console, "log") : t;
1860
- }
1861
- function l() {
1862
- for (var a = this.getLevel(), u = 0; u < i.length; u++) {
1863
- var c = i[u];
1864
- this[c] = u < a ? t : this.methodFactory(c, a, this.name);
1865
- }
1866
- if (this.log = this.debug, typeof console === n && a < this.levels.SILENT)
1867
- return "No console available for logging";
1868
- }
1869
- function g(a) {
1870
- return function() {
1871
- typeof console !== n && (l.call(this), this[a].apply(this, arguments));
1872
- };
1873
- }
1874
- function v(a, u, c) {
1875
- return p(a) || g.apply(this, arguments);
1876
- }
1877
- function m(a, u) {
1878
- var c = this, k, C, E, w = "loglevel";
1879
- typeof a == "string" ? w += ":" + a : typeof a == "symbol" && (w = void 0);
1880
- function O(f) {
1881
- var S = (i[f] || "silent").toUpperCase();
1882
- if (!(typeof window === n || !w)) {
1883
- try {
1884
- window.localStorage[w] = S;
1885
- return;
1886
- } catch {
1887
- }
1888
- try {
1889
- window.document.cookie = encodeURIComponent(w) + "=" + S + ";";
1890
- } catch {
1891
- }
1892
- }
1893
- }
1894
- function y() {
1895
- var f;
1896
- if (!(typeof window === n || !w)) {
1897
- try {
1898
- f = window.localStorage[w];
1899
- } catch {
1900
- }
1901
- if (typeof f === n)
1902
- try {
1903
- var S = window.document.cookie, R = encodeURIComponent(w), U = S.indexOf(R + "=");
1904
- U !== -1 && (f = /^([^;]+)/.exec(
1905
- S.slice(U + R.length + 1)
1906
- )[1]);
1907
- } catch {
1908
- }
1909
- return c.levels[f] === void 0 && (f = void 0), f;
1910
- }
1911
- }
1912
- function L() {
1913
- if (!(typeof window === n || !w)) {
1914
- try {
1915
- window.localStorage.removeItem(w);
1916
- } catch {
1917
- }
1918
- try {
1919
- window.document.cookie = encodeURIComponent(w) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
1920
- } catch {
1921
- }
1922
- }
1923
- }
1924
- function P(f) {
1925
- var S = f;
1926
- if (typeof S == "string" && c.levels[S.toUpperCase()] !== void 0 && (S = c.levels[S.toUpperCase()]), typeof S == "number" && S >= 0 && S <= c.levels.SILENT)
1927
- return S;
1928
- throw new TypeError("log.setLevel() called with invalid level: " + f);
1929
- }
1930
- c.name = a, c.levels = {
1931
- TRACE: 0,
1932
- DEBUG: 1,
1933
- INFO: 2,
1934
- WARN: 3,
1935
- ERROR: 4,
1936
- SILENT: 5
1937
- }, c.methodFactory = u || v, c.getLevel = function() {
1938
- return E ?? C ?? k;
1939
- }, c.setLevel = function(f, S) {
1940
- return E = P(f), S !== !1 && O(E), l.call(c);
1941
- }, c.setDefaultLevel = function(f) {
1942
- C = P(f), y() || c.setLevel(f, !1);
1943
- }, c.resetLevel = function() {
1944
- E = null, L(), l.call(c);
1945
- }, c.enableAll = function(f) {
1946
- c.setLevel(c.levels.TRACE, f);
1947
- }, c.disableAll = function(f) {
1948
- c.setLevel(c.levels.SILENT, f);
1949
- }, c.rebuild = function() {
1950
- if (s !== c && (k = P(s.getLevel())), l.call(c), s === c)
1951
- for (var f in r)
1952
- r[f].rebuild();
1953
- }, k = P(
1954
- s ? s.getLevel() : "WARN"
1955
- );
1956
- var I = y();
1957
- I != null && (E = P(I)), l.call(c);
1958
- }
1959
- s = new m(), s.getLogger = function(a) {
1960
- if (typeof a != "symbol" && typeof a != "string" || a === "")
1961
- throw new TypeError("You must supply a name when creating a logger.");
1962
- var u = r[a];
1963
- return u || (u = r[a] = new m(
1964
- a,
1965
- s.methodFactory
1966
- )), u;
1967
- };
1968
- var _ = typeof window !== n ? window.log : void 0;
1969
- return s.noConflict = function() {
1970
- return typeof window !== n && window.log === s && (window.log = _), s;
1971
- }, s.getLoggers = function() {
1972
- return r;
1973
- }, s.default = s, s;
1974
- });
1975
- })(ve)), ve.exports;
377
+ ),
378
+ () => t.current
379
+ );
380
+ return se(o);
1976
381
  }
1977
- var Bn = On();
1978
- const $n = /* @__PURE__ */ Fn(Bn), ut = $n.getLogger(Ln);
1979
- ut.setDefaultLevel("info");
1980
- function Dn(e, t) {
1981
- const { sectionId: n } = lt(), { release: o } = Tn(n), [i, r] = $e({
1982
- state: "loading",
1983
- value: t
1984
- });
1985
- return T(() => {
1986
- e.then((s) => r({ state: "hasData", value: s })).catch((s) => {
1987
- r({ state: "hasError", value: s }), ut.error("Error in useSuspenseForPromise", s);
382
+ function ae(e) {
383
+ const t = c(null), { addSuspense: o } = g($);
384
+ return S(() => {
385
+ if (t.current)
386
+ return;
387
+ const n = e ?? new Promise((s) => {
388
+ t.current = s;
1988
389
  });
1989
- }, [e]), Y(() => {
1990
- i.state !== "loading" && o();
1991
- }, [i, o]), i.value;
390
+ t.current ||= () => {
391
+ }, o(n);
392
+ }, [o, e]), u(
393
+ () => ({
394
+ reset: () => {
395
+ t.current || o(
396
+ new Promise((n) => {
397
+ t.current = n;
398
+ })
399
+ );
400
+ },
401
+ release: () => {
402
+ t.current?.(), t.current = null;
403
+ }
404
+ }),
405
+ [o]
406
+ );
1992
407
  }
1993
- function Hn(e) {
408
+ function ie(e) {
1994
409
  let t = null;
1995
410
  return () => (t || (t = e()), t);
1996
411
  }
1997
- const Mn = Hn(async () => {
1998
- const e = await window[jt]?.();
412
+ const ce = ie(async () => {
413
+ if (!(E in window))
414
+ throw new Error(
415
+ "The function paprize_readJsonDataFile is not available in the current environment."
416
+ );
417
+ const e = await window[E]?.();
1999
418
  return e ? JSON.parse(e) : null;
2000
419
  });
2001
- function eo(e) {
2002
- return Dn(Mn(), e);
420
+ function he(e) {
421
+ return ae(ce().catch(() => e));
2003
422
  }
2004
- const Wn = {
2005
- A1: { height: "841mm", width: "594mm" },
2006
- A2: { height: "594mm", width: "420mm" },
2007
- A3: { height: "420mm", width: "297mm" },
2008
- A4: { height: "297mm", width: "210mm" },
2009
- A5: { height: "210mm", width: "148mm" },
2010
- A6: { height: "148mm", width: "105mm" },
2011
- B3: { height: "500mm", width: "353mm" },
2012
- B4: { height: "353mm", width: "250mm" },
2013
- B5: { height: "250mm", width: "176mm" },
2014
- Letter: { height: "8.5in", width: "11in" },
2015
- Legal: { height: "11in", width: "8.5in" },
2016
- Tabloid: { height: "11in", width: "17in" }
2017
- }, Vn = {
2018
- Normal: { top: "1in", right: "1in", bottom: "1in", left: "1in" },
2019
- Narrow: { top: "0.4in", right: "0.6in", bottom: "0.6in", left: "0.6in" },
2020
- Wide: { top: "0.5in", right: "2in", bottom: "0.5in", left: "2in" },
2021
- None: { top: "0in", right: "0in", bottom: "0in", left: "0in" }
2022
- }, to = Wn, no = Vn;
2023
423
  export {
2024
- Xn as Layout,
2025
- Zn as PageBreak,
2026
- Xe as PageContent,
2027
- Ke as PageFooter,
2028
- Qe as PageHeader,
2029
- nt as PageOverlay,
2030
- Gn as ReportPreview,
2031
- Yn as ReportRoot,
2032
- qn as Section,
2033
- et as SectionFooter,
2034
- tt as SectionHeader,
2035
- Mn as jsonData,
2036
- no as pageMargin,
2037
- to as pageSize,
2038
- eo as useJsonData,
2039
- Kn as usePageInfo,
2040
- Qn as useReportInfo,
2041
- lt as useSectionInfo,
2042
- Tn as useSectionSuspension,
2043
- Dn as useSuspenseForPromise
424
+ ye as Layout,
425
+ Se as PageBreak,
426
+ N as PageContent,
427
+ k as PageFooter,
428
+ D as PageHeader,
429
+ L as PageOverlay,
430
+ fe as ReportPreview,
431
+ ge as ReportRoot,
432
+ me as Section,
433
+ T as SectionFooter,
434
+ j as SectionHeader,
435
+ ce as jsonData,
436
+ he as useJsonData,
437
+ Pe as usePageInfo,
438
+ Ce as useReportInfo,
439
+ ve as useSectionInfo,
440
+ ae as useSectionSuspension
2044
441
  };
442
+ //# sourceMappingURL=paprize-react.js.map