@paprize/react 0.0.4 → 0.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.
@@ -1,911 +1,153 @@
1
- import { jsx as w, jsxs as X, Fragment as E } from "react/jsx-runtime";
2
- import me, { useInsertionEffect as Oe, useRef as x, createElement as We, createContext as ie, useReducer as Ve, useEffect as D, useDebugValue as Ue, useCallback as je, useContext as $, Children as Je, isValidElement as qe, useMemo as L, useState as we, useId as Se } from "react";
3
- import { paprize_isReady as Ge, getVisibleHeight as Z, logger as W, defaultPlugins as Ke, isDebugMode as be, Paginator as Ye, tempContainerClassName as Qe, pageBreakAttributeName as Xe, configToAttributeMap as Ze, paprize_readJsonDataFile as et } from "@paprize/core";
4
- import { createPortal as tt } from "react-dom";
5
- function re(e) {
6
- Oe(() => {
7
- const t = document.createElement("style");
8
- return t.textContent = e, document.head.appendChild(t), () => t.remove();
9
- }, [e]);
10
- }
11
- const B = "paprize-preview", nt = `
12
- :root {
13
- --paprize-page-background-color: #ffffff;
14
- --paprize-page-margin-bottom: 10px;
15
- --paprize-page-box-shadow: rgb(142 138 138) -1px 3px 5px 2px;
16
- --paprize-section-margin-bottom: 10px;
17
- --paprize-preview-background-color: rgb(218 220 224);
18
- --paprize-preview-padding: 30px 10px;
19
- }
20
-
21
- body {
22
- margin: 0;
23
- }
24
-
25
- @media screen {
26
- .${B} {
27
- min-height: 100vh;
28
- display: flex;
29
- flex-direction: column;
30
- align-items: center;
31
- background-color: var(--paprize-preview-background-color);
32
- padding: var(--paprize-preview-padding);
33
- }
34
-
35
- .paprize-page {
36
- box-shadow: var(--paprize-page-box-shadow);
37
- margin-bottom: var(--paprize-page-margin-bottom);
38
- background-color: var(--paprize-page-background-color);
39
- }
40
-
41
- .paprize-section {
42
- margin-bottom: var(--paprize-section-margin-bottom);
43
- }
44
- }
45
-
46
- @media print {
47
- html *:not(.${B}):not(.${B} *):not(:has(.${B})) {
48
- display: none !important;
49
- }
50
- }
51
- `;
52
- function on({ children: e }) {
53
- return re(nt), /* @__PURE__ */ w("div", { className: B, children: e });
54
- }
55
- const z = {};
56
- function ye(e, t) {
57
- return e.unstable_is ? e.unstable_is(t) : t === e;
58
- }
59
- function Ae(e) {
60
- return "init" in e;
61
- }
62
- function ee(e) {
63
- return !!e.write;
64
- }
65
- function de(e) {
66
- return "v" in e || "e" in e;
67
- }
68
- function U(e) {
69
- if ("e" in e)
70
- throw e.e;
71
- if ((z ? "production" : void 0) !== "production" && !("v" in e))
72
- throw new Error("[Bug] atom state is not initialized");
73
- return e.v;
74
- }
75
- const j = /* @__PURE__ */ new WeakMap();
76
- function Pe(e) {
77
- var t;
78
- return J(e) && !!((t = j.get(e)) != null && t[0]);
79
- }
80
- function ot(e) {
81
- const t = j.get(e);
82
- t?.[0] && (t[0] = !1, t[1].forEach((o) => o()));
83
- }
84
- function te(e, t) {
85
- let o = j.get(e);
86
- if (!o) {
87
- o = [!0, /* @__PURE__ */ new Set()], j.set(e, o);
88
- const n = () => {
89
- o[0] = !1;
90
- };
91
- e.then(n, n);
92
- }
93
- o[1].add(t);
94
- }
95
- function J(e) {
96
- return typeof e?.then == "function";
97
- }
98
- function _e(e, t, o) {
99
- if (!o.p.has(e)) {
100
- o.p.add(e);
101
- const n = () => o.p.delete(e);
102
- t.then(n, n);
103
- }
104
- }
105
- function ke(e, t, o) {
106
- var n;
107
- const i = /* @__PURE__ */ new Set();
108
- for (const r of ((n = o.get(e)) == null ? void 0 : n.t) || [])
109
- o.has(r) && i.add(r);
110
- for (const r of t.p)
111
- i.add(r);
112
- return i;
113
- }
114
- const it = (e, t, ...o) => t.read(...o), rt = (e, t, ...o) => t.write(...o), st = (e, t) => {
115
- var o;
116
- return (o = t.unstable_onInit) == null ? void 0 : o.call(t, e);
117
- }, at = (e, t, o) => {
118
- var n;
119
- return (n = t.onMount) == null ? void 0 : n.call(t, o);
120
- }, ct = (e, t) => {
121
- const o = _(e), n = o[0], i = o[9];
122
- if ((z ? "production" : void 0) !== "production" && !t)
123
- throw new Error("Atom is undefined or null");
124
- let r = n.get(t);
125
- return r || (r = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, n.set(t, r), i?.(e, t)), r;
126
- }, lt = (e) => {
127
- const t = _(e), o = t[1], n = t[3], i = t[4], r = t[5], s = t[6], f = t[13], p = [], c = (a) => {
128
- try {
129
- a();
130
- } catch (g) {
131
- p.push(g);
132
- }
133
- };
134
- do {
135
- s.f && c(s.f);
136
- const a = /* @__PURE__ */ new Set(), g = a.add.bind(a);
137
- n.forEach((h) => {
138
- var v;
139
- return (v = o.get(h)) == null ? void 0 : v.l.forEach(g);
140
- }), n.clear(), r.forEach(g), r.clear(), i.forEach(g), i.clear(), a.forEach(c), n.size && f(e);
141
- } while (n.size || r.size || i.size);
142
- if (p.length)
143
- throw new AggregateError(p);
144
- }, ut = (e) => {
145
- const t = _(e), o = t[1], n = t[2], i = t[3], r = t[11], s = t[14], f = t[17], p = [], c = /* @__PURE__ */ new WeakSet(), a = /* @__PURE__ */ new WeakSet(), g = Array.from(i);
146
- for (; g.length; ) {
147
- const h = g[g.length - 1], v = r(e, h);
148
- if (a.has(h)) {
149
- g.pop();
150
- continue;
151
- }
152
- if (c.has(h)) {
153
- if (n.get(h) === v.n)
154
- p.push([h, v]);
155
- else if ((z ? "production" : void 0) !== "production" && n.has(h))
156
- throw new Error("[Bug] invalidated atom exists");
157
- a.add(h), g.pop();
158
- continue;
159
- }
160
- c.add(h);
161
- for (const m of ke(h, v, o))
162
- c.has(m) || g.push(m);
163
- }
164
- for (let h = p.length - 1; h >= 0; --h) {
165
- const [v, m] = p[h];
166
- let l = !1;
167
- for (const d of m.d.keys())
168
- if (d !== v && i.has(d)) {
169
- l = !0;
170
- break;
171
- }
172
- l && (s(e, v), f(e, v)), n.delete(v);
173
- }
174
- }, dt = (e, t) => {
175
- var o;
176
- const n = _(e), i = n[1], r = n[2], s = n[3], f = n[6], p = n[7], c = n[11], a = n[12], g = n[13], h = n[14], v = n[16], m = n[17], l = c(e, t);
177
- if (de(l) && (i.has(t) && r.get(t) !== l.n || Array.from(l.d).every(
178
- ([b, R]) => (
179
- // Recursively, read the atom state of the dependency, and
180
- // check if the atom epoch number is unchanged
181
- h(e, b).n === R
182
- )
183
- )))
184
- return l;
185
- l.d.clear();
186
- let d = !0;
187
- function u() {
188
- i.has(t) && (m(e, t), g(e), a(e));
189
- }
190
- function y(b) {
191
- var R;
192
- if (ye(t, b)) {
193
- const T = c(e, b);
194
- if (!de(T))
195
- if (Ae(b))
196
- q(e, b, b.init);
197
- else
198
- throw new Error("no atom init");
199
- return U(T);
200
- }
201
- const C = h(e, b);
202
- try {
203
- return U(C);
204
- } finally {
205
- l.d.set(b, C.n), Pe(l.v) && _e(t, l.v, C), (R = i.get(b)) == null || R.t.add(t), d || u();
206
- }
207
- }
208
- let A, I;
209
- const k = {
210
- get signal() {
211
- return A || (A = new AbortController()), A.signal;
212
- },
213
- get setSelf() {
214
- return (z ? "production" : void 0) !== "production" && !ee(t) && console.warn("setSelf function cannot be used with read-only atom"), !I && ee(t) && (I = (...b) => {
215
- if ((z ? "production" : void 0) !== "production" && d && console.warn("setSelf function cannot be called in sync"), !d)
216
- try {
217
- return v(e, t, ...b);
218
- } finally {
219
- g(e), a(e);
220
- }
221
- }), I;
222
- }
223
- }, H = l.n;
224
- try {
225
- const b = p(e, t, y, k);
226
- return q(e, t, b), J(b) && (te(b, () => A?.abort()), b.then(u, u)), l;
227
- } catch (b) {
228
- return delete l.v, l.e = b, ++l.n, l;
229
- } finally {
230
- d = !1, H !== l.n && r.get(t) === H && (r.set(t, l.n), s.add(t), (o = f.c) == null || o.call(f, t));
231
- }
232
- }, ft = (e, t) => {
233
- const o = _(e), n = o[1], i = o[2], r = o[11], s = [t];
234
- for (; s.length; ) {
235
- const f = s.pop(), p = r(e, f);
236
- for (const c of ke(f, p, n)) {
237
- const a = r(e, c);
238
- i.set(c, a.n), s.push(c);
239
- }
240
- }
241
- }, Ie = (e, t, ...o) => {
242
- const n = _(e), i = n[3], r = n[6], s = n[8], f = n[11], p = n[12], c = n[13], a = n[14], g = n[15], h = n[17];
243
- let v = !0;
244
- const m = (d) => U(a(e, d)), l = (d, ...u) => {
245
- var y;
246
- const A = f(e, d);
247
- try {
248
- if (ye(t, d)) {
249
- if (!Ae(d))
250
- throw new Error("atom not writable");
251
- const I = A.n, k = u[0];
252
- q(e, d, k), h(e, d), I !== A.n && (i.add(d), (y = r.c) == null || y.call(r, d), g(e, d));
253
- return;
254
- } else
255
- return Ie(e, d, ...u);
256
- } finally {
257
- v || (c(e), p(e));
258
- }
259
- };
260
- try {
261
- return s(e, t, m, l, ...o);
262
- } finally {
263
- v = !1;
264
- }
265
- }, gt = (e, t) => {
266
- var o;
267
- const n = _(e), i = n[1], r = n[3], s = n[6], f = n[11], p = n[15], c = n[18], a = n[19], g = f(e, t), h = i.get(t);
268
- if (h && !Pe(g.v)) {
269
- for (const [v, m] of g.d)
270
- if (!h.d.has(v)) {
271
- const l = f(e, v);
272
- c(e, v).t.add(t), h.d.add(v), m !== l.n && (r.add(v), (o = s.c) == null || o.call(s, v), p(e, v));
273
- }
274
- for (const v of h.d || [])
275
- if (!g.d.has(v)) {
276
- h.d.delete(v);
277
- const m = a(e, v);
278
- m?.t.delete(t);
279
- }
280
- }
281
- }, Le = (e, t) => {
282
- var o;
283
- const n = _(e), i = n[1], r = n[4], s = n[6], f = n[10], p = n[11], c = n[12], a = n[13], g = n[14], h = n[16], v = p(e, t);
284
- let m = i.get(t);
285
- if (!m) {
286
- g(e, t);
287
- for (const l of v.d.keys())
288
- Le(e, l).t.add(t);
289
- if (m = {
290
- l: /* @__PURE__ */ new Set(),
291
- d: new Set(v.d.keys()),
292
- t: /* @__PURE__ */ new Set()
293
- }, i.set(t, m), (o = s.m) == null || o.call(s, t), ee(t)) {
294
- const l = () => {
295
- let d = !0;
296
- const u = (...y) => {
297
- try {
298
- return h(e, t, ...y);
299
- } finally {
300
- d || (a(e), c(e));
301
- }
302
- };
303
- try {
304
- const y = f(e, t, u);
305
- y && (m.u = () => {
306
- d = !0;
307
- try {
308
- y();
309
- } finally {
310
- d = !1;
311
- }
312
- });
313
- } finally {
314
- d = !1;
315
- }
316
- };
317
- r.add(l);
318
- }
319
- }
320
- return m;
321
- }, pt = (e, t) => {
322
- var o;
323
- const n = _(e), i = n[1], r = n[5], s = n[6], f = n[11], p = n[19], c = f(e, t);
324
- let a = i.get(t);
325
- if (a && !a.l.size && !Array.from(a.t).some((g) => {
326
- var h;
327
- return (h = i.get(g)) == null ? void 0 : h.d.has(t);
328
- })) {
329
- a.u && r.add(a.u), a = void 0, i.delete(t), (o = s.u) == null || o.call(s, t);
330
- for (const g of c.d.keys()) {
331
- const h = p(e, g);
332
- h?.t.delete(t);
333
- }
334
- return;
335
- }
336
- return a;
337
- }, q = (e, t, o) => {
338
- const n = _(e)[11], i = n(e, t), r = "v" in i, s = i.v;
339
- if (J(o))
340
- for (const f of i.d.keys())
341
- _e(
342
- t,
343
- o,
344
- n(e, f)
345
- );
346
- i.v = o, delete i.e, (!r || !Object.is(s, i.v)) && (++i.n, J(s) && ot(s));
347
- }, ht = (e, t) => {
348
- const o = _(e)[14];
349
- return U(o(e, t));
350
- }, vt = (e, t, ...o) => {
351
- const n = _(e), i = n[12], r = n[13], s = n[16];
352
- try {
353
- return s(e, t, ...o);
354
- } finally {
355
- r(e), i(e);
356
- }
357
- }, mt = (e, t, o) => {
358
- const n = _(e), i = n[12], r = n[18], s = n[19], p = r(e, t).l;
359
- return p.add(o), i(e), () => {
360
- p.delete(o), s(e, t), i(e);
361
- };
362
- }, Ce = /* @__PURE__ */ new WeakMap();
363
- function _(e) {
364
- const t = Ce.get(e);
365
- if ((z ? "production" : void 0) !== "production" && !t)
1
+ import { jsx as r, Fragment as d, jsxs as x } from "react/jsx-runtime";
2
+ import { previewClassName as O, ReportBuilder as J, reportStyles as a, pageClassName as V, pageMargin as A, adjustPageSize as M, sectionClassName as q, pageBreakAttributeName as G, layoutOptionsToAttributes as K, paprize_readJsonDataFile as R } from "@paprize/core";
3
+ import { createContext as C, useContext as p, useMemo as u, useEffect as g, useRef as c, Children as Q, isValidElement as U, useState as W, useSyncExternalStore as b } from "react";
4
+ import { createPortal as X } from "react-dom";
5
+ function pe({ children: e }) {
6
+ return /* @__PURE__ */ r("div", { className: O, children: e });
7
+ }
8
+ const H = C(null);
9
+ function h() {
10
+ const e = p(H);
11
+ if (!e)
366
12
  throw new Error(
367
- "Store must be created by buildStore to read its building blocks"
13
+ "ReportRoot is missing. Please wrap your component tree with ReportRoot component."
368
14
  );
369
- return t;
370
- }
371
- function wt(...e) {
372
- const t = {
373
- get(n) {
374
- const i = _(t)[21];
375
- return i(t, n);
376
- },
377
- set(n, ...i) {
378
- const r = _(t)[22];
379
- return r(t, n, ...i);
380
- },
381
- sub(n, i) {
382
- const r = _(t)[23];
383
- return r(t, n, i);
384
- }
385
- }, o = [
386
- // store state
387
- /* @__PURE__ */ new WeakMap(),
388
- // atomStateMap
389
- /* @__PURE__ */ new WeakMap(),
390
- // mountedMap
391
- /* @__PURE__ */ new WeakMap(),
392
- // invalidatedAtoms
393
- /* @__PURE__ */ new Set(),
394
- // changedAtoms
395
- /* @__PURE__ */ new Set(),
396
- // mountCallbacks
397
- /* @__PURE__ */ new Set(),
398
- // unmountCallbacks
399
- {},
400
- // storeHooks
401
- // atom interceptors
402
- it,
403
- rt,
404
- st,
405
- at,
406
- // building-block functions
407
- ct,
408
- lt,
409
- ut,
410
- dt,
411
- ft,
412
- Ie,
413
- gt,
414
- Le,
415
- pt,
416
- q,
417
- ht,
418
- vt,
419
- mt
420
- ].map((n, i) => e[i] || n);
421
- return Ce.set(t, Object.freeze(o)), t;
422
- }
423
- const Ee = {};
424
- let St = 0;
425
- function N(e, t) {
426
- const o = `atom${++St}`, n = {
427
- toString() {
428
- return (Ee ? "production" : void 0) !== "production" && this.debugLabel ? o + ":" + this.debugLabel : o;
429
- }
430
- };
431
- return typeof e == "function" ? n.read = e : (n.init = e, n.read = bt, n.write = yt), t && (n.write = t), n;
432
- }
433
- function bt(e) {
434
- return e(this);
435
- }
436
- function yt(e, t, o) {
437
- return t(
438
- this,
439
- typeof o == "function" ? o(e(this)) : o
440
- );
441
- }
442
- function se() {
443
- return wt();
444
- }
445
- let F;
446
- function At() {
447
- return F || (F = se(), (Ee ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = F), globalThis.__JOTAI_DEFAULT_STORE__ !== F && console.warn(
448
- "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
449
- ))), F;
450
- }
451
- const Pt = {}, Re = ie(
452
- void 0
453
- );
454
- function xe(e) {
455
- return $(Re) || At();
456
- }
457
- function _t({
458
- children: e,
459
- store: t
460
- }) {
461
- const o = x(void 0);
462
- return !t && !o.current && (o.current = se()), We(
463
- Re.Provider,
464
- {
465
- value: t || o.current
466
- },
467
- e
468
- );
469
- }
470
- const ne = (e) => typeof e?.then == "function", oe = (e) => {
471
- e.status || (e.status = "pending", e.then(
472
- (t) => {
473
- e.status = "fulfilled", e.value = t;
474
- },
475
- (t) => {
476
- e.status = "rejected", e.reason = t;
477
- }
478
- ));
479
- }, kt = me.use || // A shim for older React versions
480
- ((e) => {
481
- if (e.status === "pending")
482
- throw e;
483
- if (e.status === "fulfilled")
484
- return e.value;
485
- throw e.status === "rejected" ? e.reason : (oe(e), e);
486
- }), Y = /* @__PURE__ */ new WeakMap(), fe = (e, t) => {
487
- let o = Y.get(e);
488
- return o || (o = new Promise((n, i) => {
489
- let r = e;
490
- const s = (c) => (a) => {
491
- r === c && n(a);
492
- }, f = (c) => (a) => {
493
- r === c && i(a);
494
- }, p = () => {
495
- try {
496
- const c = t();
497
- ne(c) ? (Y.set(c, o), r = c, c.then(s(c), f(c)), te(c, p)) : n(c);
498
- } catch (c) {
499
- i(c);
500
- }
501
- };
502
- e.then(s(e), f(e)), te(e, p);
503
- }), Y.set(e, o)), o;
504
- };
505
- function G(e, t) {
506
- const { delay: o, unstable_promiseStatus: n = !me.use } = {}, i = xe(), [[r, s, f], p] = Ve(
507
- (a) => {
508
- const g = i.get(e);
509
- return Object.is(a[0], g) && a[1] === i && a[2] === e ? a : [g, i, e];
510
- },
511
- void 0,
512
- () => [i.get(e), i, e]
513
- );
514
- let c = r;
515
- if ((s !== i || f !== e) && (p(), c = i.get(e)), D(() => {
516
- const a = i.sub(e, () => {
517
- if (n)
518
- try {
519
- const g = i.get(e);
520
- ne(g) && oe(
521
- fe(g, () => i.get(e))
522
- );
523
- } catch {
524
- }
525
- if (typeof o == "number") {
526
- setTimeout(p, o);
527
- return;
15
+ return e;
16
+ }
17
+ function fe({ children: e }) {
18
+ const n = u(() => new J(), []);
19
+ return g(() => {
20
+ n.schedulePagination();
21
+ }, [n]), /* @__PURE__ */ r(H, { value: n, children: e });
22
+ }
23
+ function z({ children: e }) {
24
+ const n = h(), o = c(!1);
25
+ return g(() => {
26
+ const t = n.monitor.addEventListener(
27
+ "paginationCycleCompleted",
28
+ () => {
29
+ o.current = !0;
528
30
  }
529
- p();
530
- });
531
- return p(), a;
532
- }, [i, e, o, n]), Ue(c), ne(c)) {
533
- const a = fe(c, () => i.get(e));
534
- return n && oe(a), kt(a);
535
- }
536
- return c;
537
- }
538
- function ae(e, t) {
539
- const o = xe();
540
- return je(
541
- (...i) => {
542
- if ((Pt ? "production" : void 0) !== "production" && !("write" in e))
543
- throw new Error("not writable atom");
544
- return o.set(e, ...i);
545
- },
546
- [o, e]
547
- );
548
- }
549
- const It = se(), Lt = {
550
- totalPages: 0,
551
- isPaginated: !1,
552
- pendingSuspensions: /* @__PURE__ */ new Set()
553
- }, M = N(/* @__PURE__ */ new Map());
554
- M.debugLabel = "sectionsAtom";
555
- const ce = N({
556
- totalSections: 0,
557
- isPaginated: !1
558
- });
559
- ce.debugLabel = "reportAtom";
560
- function Ct() {
561
- const e = ae(ce), t = G(M);
562
- return D(() => {
563
- const o = t.size, n = Array.from(t.values()).every(
564
- (i) => i.isPaginated
565
31
  );
566
- window[Ge] = n, e({
567
- isPaginated: n && o > 0,
568
- totalSections: o
569
- });
570
- }, [t, e]), null;
571
- }
572
- const Et = `
573
- html {
574
- box-sizing: border-box;
575
- }
576
-
577
- *,
578
- *:before,
579
- *:after {
580
- box-sizing: inherit;
581
- }
582
-
583
- .paprize-page-component {
584
- display: flex;
585
- flex-direction: column;
586
- }
587
- `;
588
- function rn({ children: e }) {
589
- return re(Et), /* @__PURE__ */ X(_t, { store: It, children: [
590
- e,
591
- /* @__PURE__ */ w(Ct, {})
592
- ] });
32
+ return () => t();
33
+ }, [n.monitor]), g(() => {
34
+ o.current && n.schedulePagination();
35
+ }, [e, n]), /* @__PURE__ */ r(d, { children: e });
593
36
  }
594
- function ze({ children: e }) {
595
- return /* @__PURE__ */ w(E, { children: e });
37
+ function B({ children: e }) {
38
+ return /* @__PURE__ */ r(d, { children: e });
596
39
  }
597
- function Me({ children: e }) {
598
- return /* @__PURE__ */ w(E, { children: e });
40
+ function N({ children: e }) {
41
+ return /* @__PURE__ */ r(d, { children: e });
599
42
  }
600
- function Te({ children: e }) {
601
- return /* @__PURE__ */ w(E, { children: e });
43
+ function k({ children: e }) {
44
+ return /* @__PURE__ */ r(d, { children: e });
602
45
  }
603
- function Fe({ children: e }) {
604
- return /* @__PURE__ */ w(E, { children: e });
46
+ function T({ children: e }) {
47
+ return /* @__PURE__ */ r(d, { children: e });
605
48
  }
606
- function Be({ children: e }) {
607
- return /* @__PURE__ */ w(E, { children: e });
608
- }
609
- function De({ children: e }) {
610
- return /* @__PURE__ */ w(E, { children: e });
611
- }
612
- function Rt(e) {
613
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
614
- }
615
- var V = { exports: {} }, xt = V.exports, ge;
616
- function zt() {
617
- return ge || (ge = 1, (function(e) {
618
- (function(t, o) {
619
- e.exports ? e.exports = o() : t.log = o();
620
- })(xt, function() {
621
- var t = function() {
622
- }, o = "undefined", n = typeof window !== o && typeof window.navigator !== o && /Trident\/|MSIE /.test(window.navigator.userAgent), i = [
623
- "trace",
624
- "debug",
625
- "info",
626
- "warn",
627
- "error"
628
- ], r = {}, s = null;
629
- function f(l, d) {
630
- var u = l[d];
631
- if (typeof u.bind == "function")
632
- return u.bind(l);
633
- try {
634
- return Function.prototype.bind.call(u, l);
635
- } catch {
636
- return function() {
637
- return Function.prototype.apply.apply(u, [l, arguments]);
638
- };
639
- }
640
- }
641
- function p() {
642
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
643
- }
644
- function c(l) {
645
- return l === "debug" && (l = "log"), typeof console === o ? !1 : l === "trace" && n ? p : console[l] !== void 0 ? f(console, l) : console.log !== void 0 ? f(console, "log") : t;
646
- }
647
- function a() {
648
- for (var l = this.getLevel(), d = 0; d < i.length; d++) {
649
- var u = i[d];
650
- this[u] = d < l ? t : this.methodFactory(u, l, this.name);
651
- }
652
- if (this.log = this.debug, typeof console === o && l < this.levels.SILENT)
653
- return "No console available for logging";
654
- }
655
- function g(l) {
656
- return function() {
657
- typeof console !== o && (a.call(this), this[l].apply(this, arguments));
658
- };
659
- }
660
- function h(l, d, u) {
661
- return c(l) || g.apply(this, arguments);
662
- }
663
- function v(l, d) {
664
- var u = this, y, A, I, k = "loglevel";
665
- typeof l == "string" ? k += ":" + l : typeof l == "symbol" && (k = void 0);
666
- function H(S) {
667
- var P = (i[S] || "silent").toUpperCase();
668
- if (!(typeof window === o || !k)) {
669
- try {
670
- window.localStorage[k] = P;
671
- return;
672
- } catch {
673
- }
674
- try {
675
- window.document.cookie = encodeURIComponent(k) + "=" + P + ";";
676
- } catch {
677
- }
678
- }
679
- }
680
- function b() {
681
- var S;
682
- if (!(typeof window === o || !k)) {
683
- try {
684
- S = window.localStorage[k];
685
- } catch {
686
- }
687
- if (typeof S === o)
688
- try {
689
- var P = window.document.cookie, O = encodeURIComponent(k), ue = P.indexOf(O + "=");
690
- ue !== -1 && (S = /^([^;]+)/.exec(
691
- P.slice(ue + O.length + 1)
692
- )[1]);
693
- } catch {
694
- }
695
- return u.levels[S] === void 0 && (S = void 0), S;
696
- }
697
- }
698
- function R() {
699
- if (!(typeof window === o || !k)) {
700
- try {
701
- window.localStorage.removeItem(k);
702
- } catch {
703
- }
704
- try {
705
- window.document.cookie = encodeURIComponent(k) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
706
- } catch {
707
- }
708
- }
709
- }
710
- function C(S) {
711
- var P = S;
712
- if (typeof P == "string" && u.levels[P.toUpperCase()] !== void 0 && (P = u.levels[P.toUpperCase()]), typeof P == "number" && P >= 0 && P <= u.levels.SILENT)
713
- return P;
714
- throw new TypeError("log.setLevel() called with invalid level: " + S);
715
- }
716
- u.name = l, u.levels = {
717
- TRACE: 0,
718
- DEBUG: 1,
719
- INFO: 2,
720
- WARN: 3,
721
- ERROR: 4,
722
- SILENT: 5
723
- }, u.methodFactory = d || h, u.getLevel = function() {
724
- return I ?? A ?? y;
725
- }, u.setLevel = function(S, P) {
726
- return I = C(S), P !== !1 && H(I), a.call(u);
727
- }, u.setDefaultLevel = function(S) {
728
- A = C(S), b() || u.setLevel(S, !1);
729
- }, u.resetLevel = function() {
730
- I = null, R(), a.call(u);
731
- }, u.enableAll = function(S) {
732
- u.setLevel(u.levels.TRACE, S);
733
- }, u.disableAll = function(S) {
734
- u.setLevel(u.levels.SILENT, S);
735
- }, u.rebuild = function() {
736
- if (s !== u && (y = C(s.getLevel())), a.call(u), s === u)
737
- for (var S in r)
738
- r[S].rebuild();
739
- }, y = C(
740
- s ? s.getLevel() : "WARN"
741
- );
742
- var T = b();
743
- T != null && (I = C(T)), a.call(u);
744
- }
745
- s = new v(), s.getLogger = function(d) {
746
- if (typeof d != "symbol" && typeof d != "string" || d === "")
747
- throw new TypeError("You must supply a name when creating a logger.");
748
- var u = r[d];
749
- return u || (u = r[d] = new v(
750
- d,
751
- s.methodFactory
752
- )), u;
753
- };
754
- var m = typeof window !== o ? window.log : void 0;
755
- return s.noConflict = function() {
756
- return typeof window !== o && window.log === s && (window.log = m), s;
757
- }, s.getLoggers = function() {
758
- return r;
759
- }, s.default = s, s;
760
- });
761
- })(V)), V.exports;
49
+ function L({ children: e }) {
50
+ return /* @__PURE__ */ r(d, { children: e });
762
51
  }
763
- var Mt = zt();
764
- const Tt = /* @__PURE__ */ Rt(Mt), pe = [
765
- ze,
766
- Te,
767
- Me,
768
- De,
769
- Be,
770
- Fe
52
+ const E = [
53
+ z,
54
+ N,
55
+ B,
56
+ L,
57
+ T,
58
+ k
771
59
  ];
772
- function Ft(e) {
773
- let t = null;
60
+ function Y(e) {
61
+ let n = null;
774
62
  const o = {};
775
- if (Je.forEach(e, (n) => {
776
- if (!qe(n))
777
- throw Tt.error("Invalid React element found in children", { child: n }), new Error("Invalid React element found in children");
778
- const i = pe.find((r) => r === n.type);
779
- if (!i)
63
+ if (Q.forEach(e, (t) => {
64
+ if (!U(t))
65
+ throw new Error(
66
+ `Invalid React element found in children: ${t}`,
67
+ {
68
+ cause: { child: t }
69
+ }
70
+ );
71
+ const s = E.find((i) => i === t.type);
72
+ if (!s)
780
73
  throw Error(
781
- `Component "${n.type}" is not valid as a child for Section, Expected one of: ${pe.map((r) => r.name).join(",")}`
74
+ `Component "${t.type}" is not valid as a child for Section, Expected one of: ${E.map((i) => i.name).join(",")}`
782
75
  );
783
- switch (i) {
784
- case Be:
785
- o.sectionHeader = n;
76
+ switch (s) {
77
+ case T:
78
+ o.sectionHeader = t;
786
79
  break;
787
- case Fe:
788
- o.sectionFooter = n;
80
+ case k:
81
+ o.sectionFooter = t;
789
82
  break;
790
- case ze:
791
- t = n;
83
+ case z:
84
+ n = t;
792
85
  break;
793
- case Te:
794
- o.header = n;
86
+ case N:
87
+ o.header = t;
795
88
  break;
796
- case Me:
797
- o.footer = n;
89
+ case B:
90
+ o.footer = t;
798
91
  break;
799
- case De:
800
- o.overlay = n;
92
+ case L:
93
+ o.overlay = t;
801
94
  break;
802
95
  }
803
- }), !t)
96
+ }), !n)
804
97
  throw Error("PageContent component is a required child for Section");
805
- return { ...o, content: t };
806
- }
807
- function Bt(e, t) {
808
- return t === "landscape" ? { height: e.width, width: e.height } : e;
98
+ return { ...o, content: n };
809
99
  }
810
- function Dt(e, t) {
811
- return `@page section-${e} {
812
- margin: none;
813
- size:${t.width} ${t.height};
814
- width:${t.width};
815
- height:${t.height};
816
- }`;
817
- }
818
- const $e = ie({
819
- pageNumber: 0,
100
+ const I = C(""), _ = C({
101
+ pageIndex: 0,
820
102
  totalPages: 0
821
103
  });
822
- function $t(e) {
823
- return e ? `${e.top} ${e.right} ${e.bottom} ${e.left}` : "0";
824
- }
825
- function Nt(e) {
826
- const t = e.getBoundingClientRect(), o = getComputedStyle(e), n = parseFloat(o.marginLeft) || 0, i = parseFloat(o.marginRight) || 0;
827
- return {
828
- height: Z(e),
829
- width: t.width + n + i
830
- };
831
- }
832
- const K = ie("");
833
- function he({
104
+ function F({
834
105
  elements: e,
835
- dimensions: t,
106
+ size: n,
836
107
  margin: o,
837
- pageNumber: n,
838
- totalPages: i,
839
- ref: r,
840
- sectionHeaderRef: s,
841
- sectionFooterRef: f,
842
- contentRef: p
108
+ pageIndex: t,
109
+ totalPages: s,
110
+ ref: i,
111
+ sectionHeaderRef: w,
112
+ sectionFooterRef: m,
113
+ pageHeaderRef: S,
114
+ pageFooterRef: y,
115
+ contentRef: P
843
116
  }) {
844
- const c = $(K), a = L(
845
- () => ({ pageNumber: n, totalPages: i }),
846
- [n, i]
117
+ const f = p(I), v = u(
118
+ () => ({ pageIndex: t, totalPages: s }),
119
+ [t, s]
847
120
  );
848
- return /* @__PURE__ */ w($e, { value: a, children: /* @__PURE__ */ X(
121
+ return /* @__PURE__ */ r(_, { value: v, children: /* @__PURE__ */ x(
849
122
  "div",
850
123
  {
851
- id: `${c}-${n}`,
852
- className: "paprize-page paprize-page-component",
853
- ref: r,
854
- style: {
855
- width: t.width,
856
- height: t.height,
857
- maxHeight: t.height,
858
- position: "relative",
859
- padding: $t(o),
860
- zIndex: 1
861
- },
124
+ id: `${f}-${t}`,
125
+ className: V,
126
+ ref: i,
127
+ style: a.page(n, o ?? A.None),
862
128
  children: [
863
- e.sectionHeader && n == 1 && /* @__PURE__ */ w(
864
- "div",
865
- {
866
- className: "paprize-page-component",
867
- ref: s,
868
- children: e.sectionHeader
869
- }
870
- ),
871
- e.header && /* @__PURE__ */ w("div", { className: "paprize-page-component", children: e.header }),
872
- /* @__PURE__ */ w(
873
- "div",
874
- {
875
- style: {
876
- overflow: "hidden",
877
- width: "100%",
878
- height: "100%"
879
- },
880
- ref: p,
881
- children: e.content
882
- }
883
- ),
884
- e.overlay && /* @__PURE__ */ w(
129
+ e.sectionHeader && t === 0 && /* @__PURE__ */ r("div", { style: a.component, ref: w, children: e.sectionHeader }),
130
+ e.header && /* @__PURE__ */ r("div", { style: a.component, ref: S, children: e.header }),
131
+ /* @__PURE__ */ r("div", { style: a.pageContent, ref: P, children: e.content }),
132
+ e.overlay && /* @__PURE__ */ r("div", { style: a.overlay, children: e.overlay }),
133
+ (e.footer || e.sectionFooter) && /* @__PURE__ */ x(
885
134
  "div",
886
135
  {
887
- style: {
888
- position: "absolute",
889
- width: "100%",
890
- height: "100%",
891
- left: 0,
892
- top: 0
893
- },
894
- children: e.overlay
895
- }
896
- ),
897
- (e.footer || e.sectionFooter) && /* @__PURE__ */ X(
898
- "div",
899
- {
900
- className: "paprize-page-component",
901
- style: { marginTop: "auto" },
136
+ style: { ...a.component, marginTop: "auto" },
902
137
  children: [
903
- e.footer && /* @__PURE__ */ w("div", { className: "paprize-page-component", children: e.footer }),
904
- e.sectionFooter && n == i && /* @__PURE__ */ w(
138
+ e.footer && /* @__PURE__ */ r(
139
+ "div",
140
+ {
141
+ style: a.component,
142
+ ref: y,
143
+ children: e.footer
144
+ }
145
+ ),
146
+ e.sectionFooter && t === s - 1 && /* @__PURE__ */ r(
905
147
  "div",
906
148
  {
907
- className: "paprize-page-component",
908
- ref: f,
149
+ style: a.component,
150
+ ref: m,
909
151
  children: e.sectionFooter
910
152
  }
911
153
  )
@@ -916,354 +158,275 @@ function he({
916
158
  }
917
159
  ) });
918
160
  }
919
- function Ht(e, t, o) {
920
- const { height: n, width: i } = Nt(e), r = t ? Z(t) : 0, s = o ? Z(o) : 0;
921
- return { height: n, width: i, sectionHeaderHeight: r, sectionFooterHeight: s };
922
- }
923
- function Ot(e, t, o) {
924
- return {
925
- name: "sectionPageHeight",
926
- order: 1,
927
- afterVisitNode: (n, i, r) => {
928
- !i.completed || o <= 0 || r.hasEmptySpace(o) || r.nextPage();
929
- },
930
- onNewPage: (n, i) => {
931
- const r = i.getPageState();
932
- r.pageIndex === 0 ? r.pageHeight = e + o : r.pageHeight = e + t + o;
933
- }
934
- };
935
- }
936
- function Wt(e, t) {
937
- const o = L(
938
- () => N(null, (n, i, ...r) => e(n, i, ...r)),
939
- [e]
940
- );
941
- return ae(o);
942
- }
943
- const Vt = {
944
- totalPages: 0,
945
- isPaginated: !1,
946
- pendingSuspensions: 0
947
- }, Ne = () => {
948
- const e = $(K), t = L(
949
- () => N((n) => {
950
- const i = n(M).get(e);
951
- return i ? {
952
- totalPages: i.totalPages,
953
- isPaginated: i.isPaginated,
954
- pendingSuspensions: i.pendingSuspensions.size
955
- } : Vt;
161
+ const $ = C({
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 Z(e) {
170
+ const n = u(
171
+ () => ({
172
+ plugins: e ?? [],
173
+ suspense: []
956
174
  }),
957
175
  [e]
958
- ), o = G(t);
959
- return {
960
- sectionId: e,
961
- totalPages: o.totalPages
962
- };
963
- };
964
- function Ut(e) {
965
- return Ne(), Wt((o) => (o(M).get(e)?.pendingSuspensions?.size ?? 0) > 0);
966
- }
967
- const le = (e) => {
968
- const t = L(
969
- () => N(
970
- () => 0,
971
- (o, n, i) => {
972
- n(
973
- M,
974
- (r) => new Map(r).set(
975
- e,
976
- i(r.get(e) ?? Lt)
977
- )
978
- );
176
+ ), o = u(
177
+ () => ({
178
+ addPlugin: (t) => {
179
+ n.plugins.push(t);
180
+ },
181
+ addSuspense: (t) => {
182
+ n.suspense.push(t);
979
183
  }
980
- ),
981
- [e]
184
+ }),
185
+ [n]
982
186
  );
983
- return ae(t);
984
- }, Q = "\x1B[41mREACT\x1B[0m", ve = (e, t, o, n, i) => e?.dimensions === o && e?.margin === n && e?.elements === t && e?.config === i && e?.elements === t;
985
- function jt(e, t, o, n) {
986
- const i = $(K), r = Ut(i), s = le(i), f = x(null), [p, c] = we({
987
- results: null,
988
- isLoading: !0
989
- }), a = x(null), g = x(null), h = x(null), v = x(null);
990
- return D(() => {
991
- ve(
992
- f.current,
993
- e,
994
- t,
995
- o,
996
- n
997
- ) || c({
998
- results: null,
999
- isLoading: !0
1000
- });
1001
- }, [t, e, o, n]), D(() => {
1002
- if (!a.current || !v.current || ve(f.current, e, t, o, n))
1003
- return;
1004
- if (r()) {
1005
- W.info(Q, `Section "${i}" is suspended`);
1006
- return;
1007
- }
1008
- const { height: m, width: l, sectionFooterHeight: d, sectionHeaderHeight: u } = Ht(
1009
- v.current,
1010
- g.current,
1011
- h.current
1012
- ), y = [
1013
- ...n.plugins ?? Ke,
1014
- Ot(
1015
- m,
1016
- u,
1017
- d
1018
- )
1019
- ];
1020
- be() && (a.current.style.maxHeight = "none", a.current.style.height = "auto"), W.debug(Q, "Calling Paginator", {
1021
- sectionName: i,
1022
- height: m,
1023
- width: l,
1024
- sectionFooterHeight: d,
1025
- sectionHeaderHeight: u,
1026
- plugins: y
1027
- });
1028
- const A = Ye.paginate(
1029
- v.current,
1030
- { height: m, width: l },
1031
- { ...n, plugins: y }
1032
- );
1033
- W.debug(Q, "Paginator Result", {
1034
- sectionName: i,
1035
- paginatorResult: A
1036
- }), c({
1037
- results: A,
1038
- isLoading: !1
1039
- }), s((I) => ({
1040
- ...I,
1041
- totalPages: A.length,
1042
- isPaginated: !0
1043
- })), f.current = { elements: e, dimensions: t, margin: o, config: n };
1044
- }), {
1045
- ...p,
1046
- pageRef: a,
1047
- sectionHeaderRef: g,
1048
- sectionFooterRef: h,
1049
- contentRef: v
187
+ return {
188
+ controllerState: n,
189
+ controllerValue: o
1050
190
  };
1051
191
  }
1052
- function Jt({
1053
- elements: e,
1054
- dimensions: t,
1055
- margin: o,
1056
- config: n
1057
- }) {
1058
- const { results: i, pageRef: r, sectionHeaderRef: s, sectionFooterRef: f, contentRef: p } = jt(e, t, o, n);
1059
- if (i !== null)
1060
- return /* @__PURE__ */ w(E, { children: i.map((a, g) => /* @__PURE__ */ w(
1061
- he,
192
+ function ee({ elements: e, options: n }) {
193
+ const o = p(I), { controllerState: t, controllerValue: s } = Z(
194
+ n?.plugins
195
+ ), i = h(), w = c(null), m = c(null), S = c(null), y = c(null), P = c(null), f = c(null), v = u(
196
+ () => M(n.size, n.orientation),
197
+ [n.orientation, n.size]
198
+ ), [j, D] = W(
199
+ null
200
+ );
201
+ return g(() => {
202
+ if (f.current)
203
+ return i.tryAddSection(
204
+ {
205
+ ...n,
206
+ id: o,
207
+ plugins: t.plugins,
208
+ suspense: t.suspense
209
+ },
210
+ {
211
+ pageContent: f.current,
212
+ sectionHeader: m.current,
213
+ sectionFooter: S.current,
214
+ pageFooter: P.current,
215
+ pageHeader: y.current
216
+ },
217
+ (l) => {
218
+ D(l);
219
+ }
220
+ ), () => {
221
+ i.removeSection(o);
222
+ };
223
+ }, [
224
+ t.plugins,
225
+ t.suspense,
226
+ n,
227
+ i,
228
+ o
229
+ ]), /* @__PURE__ */ x($, { value: s, children: [
230
+ j?.map((l) => /* @__PURE__ */ r(
231
+ F,
1062
232
  {
1063
233
  elements: {
1064
234
  ...e,
1065
- content: /* @__PURE__ */ w(
235
+ content: /* @__PURE__ */ r(
1066
236
  "div",
1067
237
  {
1068
238
  style: { display: "contents" },
1069
239
  dangerouslySetInnerHTML: {
1070
- __html: a
240
+ __html: l.pageContentHtml
1071
241
  }
1072
242
  }
1073
243
  )
1074
244
  },
1075
- dimensions: t,
1076
- margin: o,
1077
- pageNumber: g + 1,
1078
- totalPages: i.length
245
+ size: v,
246
+ margin: n.margin,
247
+ pageIndex: l.pageIndex,
248
+ totalPages: l.totalPages
1079
249
  },
1080
- g
1081
- )) });
1082
- const c = be() ? void 0 : {
1083
- visibility: "hidden",
1084
- position: "absolute",
1085
- left: "-9999px",
1086
- top: "-9999px"
1087
- };
1088
- return tt(
1089
- /* @__PURE__ */ w("div", { className: Qe, style: c, children: /* @__PURE__ */ w(
1090
- he,
1091
- {
1092
- elements: e,
1093
- dimensions: t,
1094
- margin: o,
1095
- pageNumber: 1,
1096
- totalPages: 1,
1097
- ref: r,
1098
- sectionHeaderRef: s,
1099
- sectionFooterRef: f,
1100
- contentRef: p
1101
- }
1102
- ) }),
1103
- document.body
1104
- );
250
+ l.pageIndex
251
+ )),
252
+ X(
253
+ /* @__PURE__ */ r("div", { style: a.outOfScreen, children: /* @__PURE__ */ r(
254
+ F,
255
+ {
256
+ elements: e,
257
+ size: v,
258
+ margin: n.margin,
259
+ pageIndex: 0,
260
+ totalPages: 1,
261
+ ref: w,
262
+ sectionHeaderRef: m,
263
+ sectionFooterRef: S,
264
+ pageHeaderRef: y,
265
+ pageFooterRef: P,
266
+ contentRef: f
267
+ }
268
+ ) }),
269
+ document.body
270
+ )
271
+ ] });
1105
272
  }
1106
- function sn({
1107
- children: e,
1108
- dimension: t,
1109
- orientation: o = "portrait",
1110
- margin: n,
1111
- config: i
1112
- }) {
1113
- const r = Se(), s = L(
1114
- () => ({ ...i, id: i?.id ?? r }),
1115
- [i, r]
1116
- ), f = s.id, p = le(f);
1117
- L(() => {
1118
- p((a) => ({ ...a, isPaginated: !1 }));
1119
- }, [p]);
1120
- const c = L(
273
+ let ne = 1;
274
+ function ge({ children: e, id: n, ...o }) {
275
+ const t = u(() => n ?? `__000${ne++}`, [n]), s = u(() => Y(e), [e]), i = u(
1121
276
  () => ({
1122
- dimensions: Bt(t, o),
1123
- elements: Ft(e),
1124
- margin: n,
1125
- config: s
277
+ ...o,
278
+ id: t
1126
279
  }),
1127
- [e, t, n, s, o]
280
+ [o, t]
1128
281
  );
1129
- return re(Dt(f, c.dimensions)), /* @__PURE__ */ w(
282
+ return /* @__PURE__ */ r(
1130
283
  "section",
1131
284
  {
1132
- className: "paprize-section",
1133
- id: `section-${f}`,
1134
- style: { page: `section-${f}` },
1135
- children: /* @__PURE__ */ w(K, { value: f, children: /* @__PURE__ */ w(
1136
- Jt,
1137
- {
1138
- elements: c.elements,
1139
- dimensions: c.dimensions,
1140
- margin: c.margin,
1141
- config: c.config
1142
- }
1143
- ) })
285
+ className: q,
286
+ id: t,
287
+ style: a.section(t),
288
+ children: /* @__PURE__ */ r(I, { value: t, children: /* @__PURE__ */ r(ee, { elements: s, options: i }) })
1144
289
  }
1145
290
  );
1146
291
  }
1147
- function an() {
1148
- return /* @__PURE__ */ w("span", { [Xe]: "true" });
292
+ function me() {
293
+ return /* @__PURE__ */ r("span", { [G]: "true" });
1149
294
  }
1150
- function cn({ children: e, ...t }) {
1151
- return /* @__PURE__ */ w(
295
+ function Se({ children: e, ...n }) {
296
+ return /* @__PURE__ */ r(
1152
297
  "div",
1153
298
  {
1154
299
  style: { display: "contents" },
1155
- ...Ze(t),
300
+ ...K(n),
1156
301
  children: e
1157
302
  }
1158
303
  );
1159
304
  }
1160
- const ln = () => {
1161
- const e = $($e);
305
+ const ye = () => {
306
+ const e = p(_);
1162
307
  return {
1163
- pageNumber: e.pageNumber,
308
+ pageIndex: e.pageIndex,
1164
309
  totalPages: e.totalPages
1165
310
  };
1166
- };
1167
- function un() {
1168
- const e = G(M), t = G(ce);
1169
- return L(
1170
- () => ({
1171
- totalSections: t.totalSections,
1172
- isPaginated: t.isPaginated,
1173
- isFirstPaginationCompleted: t.totalSections > 0,
1174
- sections: Array.from(e.entries()).map(
1175
- ([o, { totalPages: n, isPaginated: i }]) => ({
1176
- sectionId: o,
1177
- totalPages: n,
1178
- isPaginated: i
1179
- })
1180
- )
1181
- }),
1182
- [t.isPaginated, t.totalSections, e]
311
+ }, Pe = () => {
312
+ const e = p(I), n = h(), o = c({
313
+ pages: [],
314
+ isPaginated: !1,
315
+ isSuspended: !1,
316
+ sectionIndex: -1,
317
+ sectionId: e
318
+ }), t = b(
319
+ (s) => n.monitor.addEventListener(
320
+ "sectionCompleted",
321
+ (i) => {
322
+ i.sectionId === e && (o.current = i, s());
323
+ }
324
+ ),
325
+ () => o.current
1183
326
  );
327
+ return {
328
+ sectionId: e,
329
+ sectionIndex: t.sectionIndex,
330
+ isSuspended: t.isSuspended,
331
+ isPaginated: t.isPaginated,
332
+ pages: t.pages.map((s) => ({
333
+ pageIndex: s.pageIndex,
334
+ totalPages: s.totalPages
335
+ }))
336
+ };
337
+ };
338
+ function te(e) {
339
+ return {
340
+ pageIndex: e.pageIndex,
341
+ totalPages: e.totalPages
342
+ };
1184
343
  }
1185
- function qt(e, t = !0) {
1186
- const o = Se(), n = le(e);
1187
- return L(() => {
1188
- t && n((i) => ({
1189
- ...i,
1190
- pendingSuspensions: new Set(i.pendingSuspensions).add(o)
1191
- }));
1192
- }, [o, n, t]), L(() => ({
1193
- release: () => {
1194
- n((i) => {
1195
- const r = new Set(i.pendingSuspensions);
1196
- return r.delete(o), {
1197
- ...i,
1198
- pendingSuspensions: r
1199
- };
1200
- });
1201
- }
1202
- }), [o, n]);
344
+ function oe(e) {
345
+ return {
346
+ sectionId: e.sectionId,
347
+ sectionIndex: e.sectionIndex,
348
+ isPaginated: e.isPaginated,
349
+ isSuspended: e.isSuspended,
350
+ pages: e.pages.map(te)
351
+ };
352
+ }
353
+ function re(e) {
354
+ return {
355
+ sections: e.sections.map(oe)
356
+ };
1203
357
  }
1204
- function Gt(e, t) {
1205
- const { sectionId: o } = Ne(), { release: n } = qt(o), [i, r] = we({
1206
- state: "loading",
1207
- value: t
1208
- });
1209
- return L(() => {
1210
- e.then((s) => r({ state: "hasData", value: s })).catch((s) => {
1211
- r({ state: "hasError", value: s }), W.error("Error in useSuspenseForPromise", s);
358
+ function ve() {
359
+ const e = h(), n = c({
360
+ sections: []
361
+ }), o = b(
362
+ (t) => e.monitor.addEventListener(
363
+ "paginationCycleCompleted",
364
+ (s) => {
365
+ n.current = s, t();
366
+ }
367
+ ),
368
+ () => n.current
369
+ );
370
+ return re(o);
371
+ }
372
+ function se(e) {
373
+ const n = c(null), { addSuspense: o } = p($);
374
+ return g(() => {
375
+ if (n.current)
376
+ return;
377
+ const t = e ?? new Promise((s) => {
378
+ n.current = s;
1212
379
  });
1213
- }, [e]), D(() => {
1214
- i.state !== "loading" && n();
1215
- }, [i, n]), i.value;
380
+ n.current ||= () => {
381
+ }, o(t);
382
+ }, [o, e]), u(
383
+ () => ({
384
+ reset: () => {
385
+ n.current || o(
386
+ new Promise((t) => {
387
+ n.current = t;
388
+ })
389
+ );
390
+ },
391
+ release: () => {
392
+ n.current?.(), n.current = null;
393
+ }
394
+ }),
395
+ [o]
396
+ );
1216
397
  }
1217
- function Kt(e) {
1218
- let t = null;
1219
- return () => (t || (t = e()), t);
398
+ function ie(e) {
399
+ let n = null;
400
+ return () => (n || (n = e()), n);
1220
401
  }
1221
- const Yt = Kt(async () => {
1222
- const e = await window[et]?.();
402
+ const ae = ie(async () => {
403
+ if (!(R in window))
404
+ throw new Error(
405
+ "The function paprize_readJsonDataFile is not available in the current environment."
406
+ );
407
+ const e = await window[R]?.();
1223
408
  return e ? JSON.parse(e) : null;
1224
409
  });
1225
- function dn(e) {
1226
- return Gt(Yt(), e);
410
+ function Ce(e) {
411
+ return se(ae().catch(() => e));
1227
412
  }
1228
- const Qt = {
1229
- A1: { height: "841mm", width: "594mm" },
1230
- A2: { height: "594mm", width: "420mm" },
1231
- A3: { height: "420mm", width: "297mm" },
1232
- A4: { height: "297mm", width: "210mm" },
1233
- A5: { height: "210mm", width: "148mm" },
1234
- A6: { height: "148mm", width: "105mm" },
1235
- B3: { height: "500mm", width: "353mm" },
1236
- B4: { height: "353mm", width: "250mm" },
1237
- B5: { height: "250mm", width: "176mm" },
1238
- Letter: { height: "8.5in", width: "11in" },
1239
- Legal: { height: "11in", width: "8.5in" },
1240
- Tabloid: { height: "11in", width: "17in" }
1241
- }, Xt = {
1242
- Normal: { top: "1in", right: "1in", bottom: "1in", left: "1in" },
1243
- Narrow: { top: "0.4in", right: "0.6in", bottom: "0.6in", left: "0.6in" },
1244
- Wide: { top: "0.5in", right: "2in", bottom: "0.5in", left: "2in" },
1245
- None: { top: "0in", right: "0in", bottom: "0in", left: "0in" }
1246
- }, fn = Qt, gn = Xt;
1247
413
  export {
1248
- cn as Layout,
1249
- an as PageBreak,
1250
- ze as PageContent,
1251
- Me as PageFooter,
1252
- Te as PageHeader,
1253
- De as PageOverlay,
1254
- on as ReportPreview,
1255
- rn as ReportRoot,
1256
- sn as Section,
1257
- Fe as SectionFooter,
1258
- Be as SectionHeader,
1259
- Yt as jsonData,
1260
- gn as pageMargin,
1261
- fn as pageSize,
1262
- dn as useJsonData,
1263
- ln as usePageInfo,
1264
- un as useReportInfo,
1265
- Ne as useSectionInfo,
1266
- qt as useSectionSuspension,
1267
- Gt as useSuspenseForPromise
414
+ Se as Layout,
415
+ me as PageBreak,
416
+ z as PageContent,
417
+ B as PageFooter,
418
+ N as PageHeader,
419
+ L as PageOverlay,
420
+ pe as ReportPreview,
421
+ fe as ReportRoot,
422
+ ge as Section,
423
+ k as SectionFooter,
424
+ T as SectionHeader,
425
+ ae as jsonData,
426
+ Ce as useJsonData,
427
+ ye as usePageInfo,
428
+ ve as useReportInfo,
429
+ Pe as useSectionInfo,
430
+ se as useSectionSuspension
1268
431
  };
1269
432
  //# sourceMappingURL=paprize-react.js.map