react-pdf-levelup 3.1.59 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1040 +1,4 @@
1
- // src/components/core/LayoutPDF.tsx
2
- import React from "react";
3
- import { Page, Document, StyleSheet, Text, View } from "@react-pdf/renderer";
4
- var styles = StyleSheet.create({
5
- page: {
6
- backgroundColor: "white",
7
- padding: 30,
8
- fontFamily: "Helvetica",
9
- fontSize: 14
10
- },
11
- footer: {
12
- position: "absolute",
13
- left: 0,
14
- right: 0,
15
- textAlign: "center"
16
- }
17
- });
18
- var LayoutPDF = ({
19
- children,
20
- size = "A4",
21
- orientation = "vertical",
22
- backgroundColor = "white",
23
- padding = 30,
24
- margen = "normal",
25
- style = {},
26
- pagination = true,
27
- footer,
28
- lines = footer ? 2 : 1,
29
- rule = false
30
- }) => {
31
- const LINE_HEIGHT = 20;
32
- const FOOTER_PADDING = 10;
33
- const footerHeight = lines * LINE_HEIGHT + FOOTER_PADDING;
34
- const getMargins = (margen2, pageSize) => {
35
- const normalizedSize = pageSize.toUpperCase();
36
- switch (margen2) {
37
- case "apa":
38
- if (normalizedSize === "LETTER" || normalizedSize === "LEGAL") {
39
- return {
40
- paddingTop: 72,
41
- paddingRight: 72,
42
- paddingBottom: 72,
43
- paddingLeft: 72
44
- };
45
- }
46
- return {
47
- paddingTop: 72,
48
- paddingRight: 72,
49
- paddingBottom: 72,
50
- paddingLeft: 72
51
- };
52
- case "estrecho":
53
- return {
54
- paddingTop: 36,
55
- paddingRight: 36,
56
- paddingBottom: 36,
57
- paddingLeft: 36
58
- };
59
- case "ancho":
60
- return {
61
- paddingTop: 108,
62
- paddingRight: 108,
63
- paddingBottom: 108,
64
- paddingLeft: 108
65
- };
66
- case "normal":
67
- default:
68
- return {
69
- paddingTop: padding,
70
- paddingRight: padding,
71
- paddingBottom: padding,
72
- paddingLeft: padding
73
- };
74
- }
75
- };
76
- let safeSize = size;
77
- let safeOrientation = orientation;
78
- let safeBackgroundColor = backgroundColor;
79
- let safeLines = Math.max(1, Math.min(lines, 10));
80
- let safeMargen = margen;
81
- try {
82
- const validSizes = ["A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "LETTER", "LEGAL", "TABLOID"];
83
- if (typeof size === "string" && !validSizes.includes(size.toUpperCase())) {
84
- console.warn(`Invalid page size: ${size}. Using A4 as default.`);
85
- safeSize = "A4";
86
- }
87
- if (orientation !== "vertical" && orientation !== "horizontal") {
88
- console.warn(`Invalid orientation: ${orientation}. Using vertical as default.`);
89
- safeOrientation = "vertical";
90
- }
91
- if (typeof backgroundColor !== "string") {
92
- console.warn(`Invalid background color: ${backgroundColor}. Using white as default.`);
93
- safeBackgroundColor = "white";
94
- }
95
- const validMargins = ["apa", "normal", "estrecho", "ancho"];
96
- if (!validMargins.includes(margen)) {
97
- console.warn(`Invalid margin type: ${margen}. Using normal as default.`);
98
- safeMargen = "normal";
99
- }
100
- if (typeof lines !== "number" || lines < 1) {
101
- console.warn(`Invalid lines value: ${lines}. Using 1 as default.`);
102
- safeLines = 1;
103
- }
104
- } catch (e) {
105
- console.warn("Error processing props in LayoutPDF:", e);
106
- }
107
- const transformOrientation = (orientation2) => {
108
- switch (orientation2) {
109
- case "vertical":
110
- case "portrait":
111
- case "v":
112
- return "portrait";
113
- case "horizontal":
114
- case "landscape":
115
- case "h":
116
- return "landscape";
117
- default:
118
- console.warn(`Unrecognized orientation: ${orientation2}. Using portrait as default.`);
119
- return "portrait";
120
- }
121
- };
122
- const getFooterPosition = (pageSize, orientation2, footerHeight2) => {
123
- const pageDimensions = {
124
- A0: { width: 841, height: 1189 },
125
- A1: { width: 594, height: 841 },
126
- A2: { width: 420, height: 594 },
127
- A3: { width: 297, height: 420 },
128
- A4: { width: 210, height: 297 },
129
- A5: { width: 148, height: 210 },
130
- A6: { width: 105, height: 148 },
131
- A7: { width: 74, height: 105 },
132
- A8: { width: 52, height: 74 },
133
- A9: { width: 37, height: 52 },
134
- LETTER: { width: 216, height: 279 },
135
- LEGAL: { width: 216, height: 356 },
136
- TABLOID: { width: 279, height: 432 }
137
- };
138
- const mmToPoints = 2.834645669;
139
- const dimensions = pageDimensions[pageSize.toUpperCase()];
140
- if (!dimensions) {
141
- return orientation2 === "landscape" ? 595 - footerHeight2 - 10 : 842 - footerHeight2 - 10;
142
- }
143
- const heightInPoints = dimensions.height * mmToPoints;
144
- const widthInPoints = dimensions.width * mmToPoints;
145
- return orientation2 === "landscape" ? widthInPoints - footerHeight2 - 10 : heightInPoints - footerHeight2 - 10;
146
- };
147
- const pdfOrientation = transformOrientation(safeOrientation);
148
- const margins = getMargins(safeMargen, safeSize);
149
- const footerTop = getFooterPosition(safeSize, pdfOrientation, footerHeight);
150
- const renderGrid = () => {
151
- if (!rule) return null;
152
- const cmToPoints = 28.3465;
153
- const pageDimensions = {
154
- A0: { width: 841 * 2.834645669, height: 1189 * 2.834645669 },
155
- A1: { width: 594 * 2.834645669, height: 841 * 2.834645669 },
156
- A2: { width: 420 * 2.834645669, height: 594 * 2.834645669 },
157
- A3: { width: 297 * 2.834645669, height: 420 * 2.834645669 },
158
- A4: { width: 210 * 2.834645669, height: 297 * 2.834645669 },
159
- A5: { width: 148 * 2.834645669, height: 210 * 2.834645669 },
160
- A6: { width: 105 * 2.834645669, height: 148 * 2.834645669 },
161
- A7: { width: 74 * 2.834645669, height: 105 * 2.834645669 },
162
- A8: { width: 52 * 2.834645669, height: 74 * 2.834645669 },
163
- A9: { width: 37 * 2.834645669, height: 52 * 2.834645669 },
164
- LETTER: { width: 216 * 2.834645669, height: 279 * 2.834645669 },
165
- LEGAL: { width: 216 * 2.834645669, height: 356 * 2.834645669 },
166
- TABLOID: { width: 279 * 2.834645669, height: 432 * 2.834645669 }
167
- };
168
- const dimensions = pageDimensions[safeSize.toUpperCase()] || pageDimensions.A4;
169
- const pageWidth = pdfOrientation === "landscape" ? dimensions.height : dimensions.width;
170
- const pageHeight = pdfOrientation === "landscape" ? dimensions.width : dimensions.height;
171
- const horizontalLines = [];
172
- const verticalLines = [];
173
- for (let i = 0; i <= Math.ceil(pageHeight / cmToPoints); i++) {
174
- horizontalLines.push(
175
- /* @__PURE__ */ React.createElement(
176
- View,
177
- {
178
- key: `h-${i}`,
179
- style: {
180
- position: "absolute",
181
- top: i * cmToPoints,
182
- left: 0,
183
- right: 0,
184
- height: i % 5 === 0 ? 1 : 0.5,
185
- backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
186
- }
187
- }
188
- )
189
- );
190
- }
191
- for (let i = 0; i <= Math.ceil(pageWidth / cmToPoints); i++) {
192
- verticalLines.push(
193
- /* @__PURE__ */ React.createElement(
194
- View,
195
- {
196
- key: `v-${i}`,
197
- style: {
198
- position: "absolute",
199
- left: i * cmToPoints,
200
- top: 0,
201
- bottom: 0,
202
- width: i % 5 === 0 ? 1 : 0.5,
203
- backgroundColor: i % 5 === 0 ? "rgba(255, 0, 0, 0.8)" : "rgba(100, 100, 100, 0.5)"
204
- }
205
- }
206
- )
207
- );
208
- }
209
- return /* @__PURE__ */ React.createElement(View, { style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 }, fixed: true }, horizontalLines, verticalLines);
210
- };
211
- const pageStyle = {
212
- ...styles.page,
213
- backgroundColor: safeBackgroundColor,
214
- ...margins,
215
- paddingBottom: margins.paddingBottom + footerHeight,
216
- ...style
217
- };
218
- const footerStyle = {
219
- ...styles.footer,
220
- top: footerTop,
221
- height: footerHeight,
222
- display: "flex",
223
- flexDirection: "column",
224
- justifyContent: "center",
225
- alignItems: "center",
226
- fontSize: 10,
227
- color: "grey"
228
- };
229
- return /* @__PURE__ */ React.createElement(Document, null, /* @__PURE__ */ React.createElement(Page, { size: safeSize, orientation: pdfOrientation, style: pageStyle, wrap: true }, renderGrid(), /* @__PURE__ */ React.createElement(View, { style: { paddingBottom: footerHeight } }, children), pagination ? /* @__PURE__ */ React.createElement(View, { style: footerStyle, fixed: true }, footer, /* @__PURE__ */ React.createElement(Text, { style: { fontSize: footerStyle.fontSize }, render: ({ pageNumber, totalPages }) => `${pageNumber} / ${totalPages}` })) : null));
230
- };
231
- var LayoutPDF_default = LayoutPDF;
232
-
233
- // src/components/core/Img.tsx
234
- import React2 from "react";
235
- import { Image as Image2, StyleSheet as StyleSheet2 } from "@react-pdf/renderer";
236
- var styles2 = StyleSheet2.create({
237
- image: {
238
- width: "100%",
239
- height: "auto",
240
- marginBottom: 14
241
- }
242
- });
243
- var Img = ({ src, style }) => {
244
- return /* @__PURE__ */ React2.createElement(Image2, { src, style: [styles2.image, style] });
245
- };
246
- var Img_default = Img;
247
-
248
- // src/components/core/Position.tsx
249
- import React3 from "react";
250
- import { View as View2, StyleSheet as StyleSheet3 } from "@react-pdf/renderer";
251
- var styles3 = StyleSheet3.create({
252
- left: {
253
- textAlign: "left"
254
- },
255
- right: {
256
- textAlign: "right"
257
- },
258
- center: {
259
- textAlign: "center"
260
- }
261
- });
262
- var Left = ({ children, style }) => {
263
- return /* @__PURE__ */ React3.createElement(View2, { style: [styles3.left, style] }, children);
264
- };
265
- var Right = ({ children, style }) => {
266
- return /* @__PURE__ */ React3.createElement(View2, { style: [styles3.right, style] }, children);
267
- };
268
- var Center = ({ children, style }) => {
269
- return /* @__PURE__ */ React3.createElement(View2, { style: [styles3.center, style] }, children);
270
- };
271
-
272
- // src/components/core/Etiquetas.tsx
273
- import React4 from "react";
274
- import { Text as Text2, StyleSheet as StyleSheet4, Link, View as View3 } from "@react-pdf/renderer";
275
- var styles4 = StyleSheet4.create({
276
- p: {
277
- fontSize: 12,
278
- marginBottom: 5,
279
- lineHeight: 1.2
280
- },
281
- h1: {
282
- fontSize: 24,
283
- fontWeight: "bold",
284
- marginBottom: 12
285
- },
286
- h2: {
287
- fontSize: 20,
288
- fontWeight: "bold",
289
- marginBottom: 10
290
- },
291
- h3: {
292
- fontSize: 18,
293
- fontWeight: "bold",
294
- marginBottom: 8
295
- },
296
- h4: {
297
- fontSize: 16,
298
- fontWeight: "bold",
299
- marginBottom: 6
300
- },
301
- h5: {
302
- fontSize: 14,
303
- fontWeight: "bold",
304
- marginBottom: 4
305
- },
306
- h6: {
307
- fontSize: 12,
308
- fontWeight: "bold",
309
- marginBottom: 0
310
- },
311
- strong: {
312
- fontWeight: "bold"
313
- },
314
- em: {
315
- fontStyle: "italic"
316
- },
317
- u: {
318
- textDecoration: "underline"
319
- },
320
- small: {
321
- fontSize: 10
322
- },
323
- blockquote: {
324
- marginLeft: 20,
325
- marginRight: 20,
326
- fontStyle: "italic",
327
- borderLeft: "4px solid #ccc",
328
- paddingLeft: 10
329
- },
330
- mark: {
331
- backgroundColor: "yellow"
332
- },
333
- A: {
334
- color: "#3d65fd",
335
- textDecoration: "none"
336
- },
337
- br: {
338
- width: "100%",
339
- height: 1,
340
- marginTop: 7,
341
- marginBottom: 7
342
- },
343
- header: {
344
- position: "absolute",
345
- top: 20,
346
- left: 0,
347
- right: 0,
348
- textAlign: "center",
349
- fontSize: 10,
350
- color: "#666",
351
- paddingHorizontal: 40
352
- },
353
- hr: {
354
- width: "100%",
355
- borderTop: "1px solid #000",
356
- marginTop: 8,
357
- marginBottom: 8
358
- }
359
- });
360
- var P = ({ children, style }) => {
361
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.p, style] }, children);
362
- };
363
- var H1 = ({ children, style }) => {
364
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h1, style] }, children);
365
- };
366
- var H2 = ({ children, style }) => {
367
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h2, style] }, children);
368
- };
369
- var H3 = ({ children, style }) => {
370
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h3, style] }, children);
371
- };
372
- var H4 = ({ children, style }) => {
373
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h4, style] }, children);
374
- };
375
- var H5 = ({ children, style }) => {
376
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h5, style] }, children);
377
- };
378
- var H6 = ({ children, style }) => {
379
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.h6, style] }, children);
380
- };
381
- var Strong = ({ children, style }) => {
382
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.strong, style] }, children);
383
- };
384
- var Em = ({ children, style }) => {
385
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.em, style] }, children);
386
- };
387
- var U = ({ children, style }) => {
388
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.u, style] }, children);
389
- };
390
- var Small = ({ children, style }) => {
391
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.small, style] }, children);
392
- };
393
- var Blockquote = ({ children, style }) => {
394
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.blockquote, style] }, children);
395
- };
396
- var Mark = ({ children, style }) => {
397
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.mark, style] }, children);
398
- };
399
- var A = ({ children, style, href }) => {
400
- return /* @__PURE__ */ React4.createElement(Link, { src: href, style: [styles4.A, style] }, children);
401
- };
402
- var BR = ({ style }) => {
403
- return /* @__PURE__ */ React4.createElement(Text2, { style: [styles4.br, style] }, "\n");
404
- };
405
- var HR = ({ style }) => {
406
- return /* @__PURE__ */ React4.createElement(View3, { style: [styles4.hr, style] });
407
- };
408
- var Span = ({ children, style }) => {
409
- return /* @__PURE__ */ React4.createElement(Text2, { style: [style] }, children);
410
- };
411
- var Header = ({ children, style, fixed = false }) => {
412
- return /* @__PURE__ */ React4.createElement(View3, { style: [styles4.header, style], fixed }, typeof children === "string" ? /* @__PURE__ */ React4.createElement(Text2, null, children) : children);
413
- };
414
- var Div = ({ children, style }) => {
415
- return /* @__PURE__ */ React4.createElement(View3, { style }, children);
416
- };
417
-
418
- // src/components/core/Tablet.tsx
419
- import React5, { createContext, useContext } from "react";
420
- import { View as View4, Text as Text3, StyleSheet as StyleSheet5 } from "@react-pdf/renderer";
421
- var TableContext = createContext({
422
- cellHeight: 22,
423
- textAlign: "left"
424
- });
425
- var styles5 = StyleSheet5.create({
426
- table: {
427
- width: "100%",
428
- borderWidth: 1,
429
- borderColor: "#000",
430
- marginBottom: 20
431
- },
432
- thead: {
433
- backgroundColor: "#ccc"
434
- },
435
- tr: {
436
- flexDirection: "row"
437
- },
438
- textBold: {
439
- fontSize: 10,
440
- fontFamily: "Helvetica",
441
- fontWeight: "bold",
442
- paddingLeft: 8,
443
- paddingRight: 8,
444
- justifyContent: "center"
445
- },
446
- text: {
447
- fontSize: 10,
448
- fontFamily: "Helvetica",
449
- paddingLeft: 8,
450
- paddingRight: 8,
451
- justifyContent: "center"
452
- },
453
- zebraOdd: {
454
- backgroundColor: "#eeeeee"
455
- }
456
- });
457
- var Table = ({ children, style, cellHeight = 22 }) => /* @__PURE__ */ React5.createElement(TableContext.Provider, { value: { cellHeight, textAlign: "left" } }, /* @__PURE__ */ React5.createElement(View4, { style: [styles5.table, style] }, children));
458
- var Thead = ({
459
- children,
460
- style,
461
- textAlign = "left"
462
- }) => {
463
- const { cellHeight } = useContext(TableContext);
464
- return /* @__PURE__ */ React5.createElement(TableContext.Provider, { value: { cellHeight, textAlign } }, /* @__PURE__ */ React5.createElement(View4, { style: [styles5.thead, style] }, children));
465
- };
466
- var Tbody = ({ children, style }) => {
467
- const rows = React5.Children.toArray(children);
468
- const count = rows.length;
469
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, rows.map(
470
- (row, idx) => React5.cloneElement(row, {
471
- isLastRow: idx === count - 1,
472
- isOdd: idx % 2 === 1
473
- })
474
- ));
475
- };
476
- var Tr = ({
477
- children,
478
- style,
479
- isLastRow = false,
480
- isOdd = false
481
- }) => {
482
- const elements = React5.Children.toArray(
483
- children
484
- );
485
- const count = elements.length;
486
- return /* @__PURE__ */ React5.createElement(View4, { style: [styles5.tr, style] }, elements.map((child, idx) => {
487
- const isLast = idx === count - 1;
488
- const width = `${(100 / count).toFixed(2)}%`;
489
- return React5.cloneElement(child, { width, isLast, isLastRow, isOdd });
490
- }));
491
- };
492
- var Th = ({
493
- children,
494
- style,
495
- width,
496
- height,
497
- colSpan,
498
- isLast = false,
499
- isLastRow = false,
500
- textAlign: propTextAlign
501
- }) => {
502
- const { cellHeight, textAlign: contextTextAlign } = useContext(TableContext);
503
- const finalTextAlign = propTextAlign || contextTextAlign || "left";
504
- const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
505
- const cellHeightValue = height !== void 0 ? height : cellHeight;
506
- const borders = {
507
- borderRightWidth: isLast ? 0 : 1,
508
- borderBottomWidth: isLastRow ? 0 : 1,
509
- borderColor: "#000",
510
- minHeight: cellHeightValue
511
- };
512
- return /* @__PURE__ */ React5.createElement(
513
- View4,
514
- {
515
- style: [
516
- styles5.textBold,
517
- {
518
- width: baseWidth
519
- },
520
- borders,
521
- style
522
- ]
523
- },
524
- /* @__PURE__ */ React5.createElement(Text3, { style: { textAlign: finalTextAlign } }, children)
525
- );
526
- };
527
- var Td = ({
528
- children,
529
- style,
530
- width,
531
- height,
532
- colSpan,
533
- isLast = false,
534
- isLastRow = false,
535
- isOdd = false,
536
- textAlign: propTextAlign
537
- }) => {
538
- const { cellHeight, textAlign: contextTextAlign } = useContext(TableContext);
539
- const finalTextAlign = propTextAlign || contextTextAlign || "left";
540
- const baseWidth = typeof width === "string" && colSpan ? `${(parseFloat(width) * colSpan).toFixed(2)}%` : width;
541
- const cellHeightValue = height !== void 0 ? height : cellHeight;
542
- const borders = {
543
- borderRightWidth: isLast ? 0 : 1,
544
- borderBottomWidth: isLastRow ? 0 : 1,
545
- borderColor: "#000",
546
- minHeight: cellHeightValue
547
- };
548
- return /* @__PURE__ */ React5.createElement(
549
- View4,
550
- {
551
- style: [
552
- styles5.text,
553
- isOdd && styles5.zebraOdd,
554
- {
555
- width: baseWidth
556
- },
557
- borders,
558
- style
559
- ]
560
- },
561
- /* @__PURE__ */ React5.createElement(Text3, { style: { textAlign: finalTextAlign } }, children)
562
- );
563
- };
564
-
565
- // src/components/core/Grid.tsx
566
- import React6 from "react";
567
- import { View as View5, StyleSheet as StyleSheet6 } from "@react-pdf/renderer";
568
- var styles6 = StyleSheet6.create({
569
- container: {
570
- width: "100%",
571
- paddingHorizontal: 20
572
- },
573
- row: {
574
- flexDirection: "row",
575
- flexWrap: "wrap",
576
- marginHorizontal: -5
577
- },
578
- col: {
579
- paddingHorizontal: 5
580
- },
581
- col1: { width: "8.33%" },
582
- col2: { width: "16.66%" },
583
- col3: { width: "25%" },
584
- col4: { width: "33.33%" },
585
- col5: { width: "41.66%" },
586
- col6: { width: "50%" },
587
- col7: { width: "58.33%" },
588
- col8: { width: "66.66%" },
589
- col9: { width: "75%" },
590
- col10: { width: "83.33%" },
591
- col11: { width: "91.66%" },
592
- col12: { width: "100%" }
593
- });
594
- var Container = ({ children, style }) => {
595
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.container, style] }, children);
596
- };
597
- var Row = ({ children, style }) => {
598
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.row, style] }, children);
599
- };
600
- var Col1 = ({ children, style }) => {
601
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col1, style] }, children);
602
- };
603
- var Col2 = ({ children, style }) => {
604
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col2, style] }, children);
605
- };
606
- var Col3 = ({ children, style }) => {
607
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col3, style] }, children);
608
- };
609
- var Col4 = ({ children, style }) => {
610
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col4, style] }, children);
611
- };
612
- var Col5 = ({ children, style }) => {
613
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col5, style] }, children);
614
- };
615
- var Col6 = ({ children, style }) => {
616
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col6, style] }, children);
617
- };
618
- var Col7 = ({ children, style }) => {
619
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col7, style] }, children);
620
- };
621
- var Col8 = ({ children, style }) => {
622
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col8, style] }, children);
623
- };
624
- var Col9 = ({ children, style }) => {
625
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col9, style] }, children);
626
- };
627
- var Col10 = ({ children, style }) => {
628
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col10, style] }, children);
629
- };
630
- var Col11 = ({ children, style }) => {
631
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col11, style] }, children);
632
- };
633
- var Col12 = ({ children, style }) => {
634
- return /* @__PURE__ */ React6.createElement(View5, { style: [styles6.col, styles6.col12, style] }, children);
635
- };
636
-
637
- // src/components/core/QR.tsx
638
- import React7 from "react";
639
- import { Image as Image3, StyleSheet as StyleSheet7, View as View6 } from "@react-pdf/renderer";
640
- import { useEffect, useState } from "react";
641
-
642
- // src/components/core/QRGenerator.tsx
643
- import QRCode from "qrcode";
644
- var generateQRAsBase64 = async ({
645
- value,
646
- size = 150,
647
- colorDark = "#000000",
648
- colorLight = "#ffffff",
649
- margin = 0,
650
- errorCorrectionLevel = "M"
651
- }) => {
652
- try {
653
- const options = {
654
- errorCorrectionLevel,
655
- type: "image/png",
656
- quality: 0.92,
657
- margin,
658
- color: {
659
- dark: colorDark,
660
- light: colorLight
661
- },
662
- width: size
663
- };
664
- const qrDataUrl = QRCode.toDataURL(value, options);
665
- return qrDataUrl;
666
- } catch (error) {
667
- console.error("Error generando QR:", error);
668
- return "";
669
- }
670
- };
671
- var addLogoToQR = async (qrDataUrl, logoUrl, logoWidth, logoHeight) => {
672
- return new Promise((resolve) => {
673
- if (!qrDataUrl || !logoUrl) {
674
- resolve(qrDataUrl);
675
- return;
676
- }
677
- try {
678
- const canvas = document.createElement("canvas");
679
- const ctx = canvas.getContext("2d");
680
- if (!ctx) {
681
- resolve(qrDataUrl);
682
- return;
683
- }
684
- const qrImage = new Image();
685
- qrImage.crossOrigin = "anonymous";
686
- qrImage.onload = () => {
687
- canvas.width = qrImage.width;
688
- canvas.height = qrImage.height;
689
- ctx.drawImage(qrImage, 0, 0, canvas.width, canvas.height);
690
- const logoImage = new Image();
691
- logoImage.crossOrigin = "anonymous";
692
- logoImage.onload = () => {
693
- const x = (canvas.width - logoWidth) / 2;
694
- const y = (canvas.height - logoHeight) / 2;
695
- ctx.fillStyle = "#FFFFFF";
696
- ctx.fillRect(x - 5, y - 5, logoWidth + 10, logoHeight + 10);
697
- ctx.drawImage(logoImage, x, y, logoWidth, logoHeight);
698
- const finalQrDataUrl = canvas.toDataURL("image/png");
699
- resolve(finalQrDataUrl);
700
- };
701
- logoImage.onerror = () => {
702
- console.error("Error cargando el logo");
703
- resolve(qrDataUrl);
704
- };
705
- logoImage.src = logoUrl;
706
- };
707
- qrImage.onerror = () => {
708
- console.error("Error cargando el QR");
709
- resolve("");
710
- };
711
- qrImage.src = qrDataUrl;
712
- } catch (error) {
713
- console.error("Error procesando el QR con logo:", error);
714
- resolve(qrDataUrl);
715
- }
716
- });
717
- };
718
-
719
- // src/components/core/QR.tsx
720
- var styles7 = StyleSheet7.create({
721
- qrContainer: {
722
- display: "flex",
723
- alignItems: "center",
724
- justifyContent: "center",
725
- margin: 10
726
- }
727
- });
728
- var errorLevelMap = {
729
- 0: "L",
730
- 1: "M",
731
- 2: "Q",
732
- 3: "H"
733
- };
734
- var QR = ({
735
- value,
736
- size = 150,
737
- style,
738
- colorDark = "#000000",
739
- colorLight = "#ffffff",
740
- margin = 0,
741
- logo = "",
742
- logoWidth = 30,
743
- logoHeight = 30,
744
- errorCorrectionLevel = logo ? "H" : "M"
745
- }) => {
746
- const [qrDataUrl, setQrDataUrl] = useState("");
747
- useEffect(() => {
748
- const generateQR = async () => {
749
- try {
750
- const baseQrDataUrl = await generateQRAsBase64({
751
- value,
752
- size,
753
- colorDark,
754
- colorLight,
755
- margin,
756
- errorCorrectionLevel: typeof errorCorrectionLevel === "number" ? errorLevelMap[errorCorrectionLevel] || "M" : errorCorrectionLevel
757
- });
758
- if (logo && logoWidth && logoHeight) {
759
- const qrWithLogo = await addLogoToQR(baseQrDataUrl, logo, logoWidth, logoHeight);
760
- setQrDataUrl(qrWithLogo);
761
- } else {
762
- setQrDataUrl(baseQrDataUrl);
763
- }
764
- } catch (error) {
765
- console.error("Error generando QR:", error);
766
- const fallbackUrl2 = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
767
- value
768
- )}&size=${size}x${size}&color=${encodeURIComponent(colorDark.replace("#", ""))}&bgcolor=${encodeURIComponent(
769
- colorLight.replace("#", "")
770
- )}`;
771
- setQrDataUrl(fallbackUrl2);
772
- }
773
- };
774
- generateQR();
775
- }, [value, size, colorDark, colorLight, margin, logo, logoWidth, logoHeight, errorCorrectionLevel]);
776
- const fallbackUrl = `https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(
777
- value
778
- )}&size=${size}x${size}`;
779
- return /* @__PURE__ */ React7.createElement(View6, { style: [styles7.qrContainer, style] }, /* @__PURE__ */ React7.createElement(Image3, { src: qrDataUrl || fallbackUrl, style: { width: size, height: size } }));
780
- };
781
- var QR_default = QR;
782
-
783
- // src/components/core/Lista.tsx
784
- import React8 from "react";
785
- import { View as View7, Text as Text4, StyleSheet as StyleSheet8 } from "@react-pdf/renderer";
786
- var styles8 = StyleSheet8.create({
787
- ul: {
788
- marginBottom: 10,
789
- paddingLeft: 15
790
- },
791
- ol: {
792
- marginBottom: 10,
793
- paddingLeft: 15
794
- },
795
- li: {
796
- marginBottom: 5,
797
- flexDirection: "row"
798
- },
799
- bulletPoint: {
800
- width: 15,
801
- marginRight: 5,
802
- fontSize: 12
803
- },
804
- itemContent: {
805
- flex: 1
806
- }
807
- });
808
- var getBulletPoint = (type = "disc") => {
809
- switch (type) {
810
- case "circle":
811
- return "\u25CB";
812
- case "square":
813
- return "\u25A0";
814
- case "disc":
815
- default:
816
- return "\u2022";
817
- }
818
- };
819
- var getOrderedMarker = (index, type = "decimal", start = 1) => {
820
- const actualIndex = start + index - 1;
821
- switch (type) {
822
- case "lower-alpha":
823
- return String.fromCharCode(97 + actualIndex % 26) + ".";
824
- case "upper-alpha":
825
- return String.fromCharCode(65 + actualIndex % 26) + ".";
826
- case "lower-roman":
827
- return toRoman(actualIndex).toLowerCase() + ".";
828
- case "upper-roman":
829
- return toRoman(actualIndex) + ".";
830
- case "decimal":
831
- default:
832
- return actualIndex + ".";
833
- }
834
- };
835
- var toRoman = (num) => {
836
- if (num <= 0 || num > 3999) return String(num);
837
- const romanNumerals = [
838
- ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"],
839
- ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"],
840
- ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"],
841
- ["", "M", "MM", "MMM"]
842
- ];
843
- return romanNumerals[3][Math.floor(num / 1e3)] + romanNumerals[2][Math.floor(num % 1e3 / 100)] + romanNumerals[1][Math.floor(num % 100 / 10)] + romanNumerals[0][num % 10];
844
- };
845
- var UL = ({ children, style, type = "disc" }) => {
846
- const childrenWithBullets = React8.Children.map(children, (child, index) => {
847
- if (React8.isValidElement(child)) {
848
- return React8.cloneElement(child, {
849
- bulletType: type,
850
- isOrdered: false,
851
- index: index + 1
852
- });
853
- }
854
- return child;
855
- });
856
- return /* @__PURE__ */ React8.createElement(View7, { style: [styles8.ul, style] }, childrenWithBullets);
857
- };
858
- var OL = ({ children, style, type = "decimal", start = 1 }) => {
859
- const childrenWithNumbers = React8.Children.map(children, (child, index) => {
860
- if (React8.isValidElement(child)) {
861
- return React8.cloneElement(child, {
862
- bulletType: type,
863
- isOrdered: true,
864
- index: index + 1,
865
- start
866
- });
867
- }
868
- return child;
869
- });
870
- return /* @__PURE__ */ React8.createElement(View7, { style: [styles8.ol, style] }, childrenWithNumbers);
871
- };
872
- var LI = ({ children, style, bulletType = "disc", isOrdered = false, index = 1, start = 1, value }) => {
873
- let marker;
874
- if (isOrdered) {
875
- const actualIndex = value !== void 0 ? Number(value) : index;
876
- marker = getOrderedMarker(actualIndex, bulletType, start);
877
- } else {
878
- marker = getBulletPoint(bulletType);
879
- }
880
- return /* @__PURE__ */ React8.createElement(View7, { style: [styles8.li, style] }, /* @__PURE__ */ React8.createElement(Text4, { style: styles8.bulletPoint }, marker), /* @__PURE__ */ React8.createElement(View7, { style: styles8.itemContent }, typeof children === "string" ? /* @__PURE__ */ React8.createElement(Text4, null, children) : children));
881
- };
882
-
883
- // src/components/core/index.tsx
884
- import { View as View9, Text as Text5, StyleSheet as StyleSheet10, Font } from "@react-pdf/renderer";
885
-
886
- // src/functions/decodeBase64Pdf.ts
887
- var decodeBase64Pdf = (base64, fileName) => {
888
- const byteCharacters = atob(base64);
889
- const byteNumbers = new Array(byteCharacters.length);
890
- for (let i = 0; i < byteCharacters.length; i++) {
891
- byteNumbers[i] = byteCharacters.charCodeAt(i);
892
- }
893
- const byteArray = new Uint8Array(byteNumbers);
894
- const blob = new Blob([byteArray], { type: "application/pdf" });
895
- const blobUrl = URL.createObjectURL(blob);
896
- if (document === void 0) {
897
- console.error("document is undefined, only works in browser context");
898
- return;
899
- }
900
- const link = document.createElement("a");
901
- link.href = blobUrl;
902
- link.download = fileName;
903
- document.body.appendChild(link);
904
- link.click();
905
- document.body.removeChild(link);
906
- window.open(blobUrl, "_blank");
907
- setTimeout(() => {
908
- URL.revokeObjectURL(blobUrl);
909
- }, 100);
910
- };
911
- var decodeBase64Pdf_default = decodeBase64Pdf;
912
-
913
- // src/functions/generatePDF.ts
914
- import { renderToStream } from "@react-pdf/renderer";
915
- import { createElement } from "react";
916
- var generatePDF = async ({ template: Template, data }) => {
917
- try {
918
- if (!Template) {
919
- throw new Error("Template not provided");
920
- }
921
- const MyDocument = createElement(Template, { data });
922
- const stream = await renderToStream(MyDocument);
923
- const base64String = await new Promise((resolve, reject) => {
924
- const chunks = [];
925
- stream.on("data", (chunk) => chunks.push(chunk));
926
- stream.on("end", () => resolve(Buffer.concat(chunks).toString("base64")));
927
- stream.on("error", (error) => reject(error));
928
- });
929
- return base64String;
930
- } catch (error) {
931
- throw new Error("Error generating PDF: " + (error instanceof Error ? error.message : "Unknown error"));
932
- }
933
- };
934
- var generatePDF_default = generatePDF;
935
-
936
- // src/functions/index.ts
937
- import { renderToStream as renderToStream2 } from "@react-pdf/renderer";
938
-
939
- // src/components/core/ImgBg.tsx
940
- import React9 from "react";
941
- import { Image as Image4, StyleSheet as StyleSheet9, View as View8 } from "@react-pdf/renderer";
942
- var styles9 = StyleSheet9.create({
943
- container: {
944
- position: "relative",
945
- width: "100%",
946
- height: "100%"
947
- },
948
- background: {
949
- position: "absolute",
950
- top: 0,
951
- left: 0,
952
- right: 0,
953
- bottom: 0
954
- },
955
- content: {
956
- position: "relative"
957
- }
958
- });
959
- var ImgBg = ({
960
- src,
961
- width = "100%",
962
- height = "100%",
963
- opacity = 0.2,
964
- children,
965
- style,
966
- fixed = false,
967
- objectFit = "cover",
968
- objectPosition = "center"
969
- }) => {
970
- return /* @__PURE__ */ React9.createElement(View8, { style: [styles9.container, style] }, /* @__PURE__ */ React9.createElement(
971
- Image4,
972
- {
973
- src,
974
- style: [
975
- styles9.background,
976
- { width, height, opacity, objectFit, objectPosition }
977
- ],
978
- fixed
979
- }
980
- ), /* @__PURE__ */ React9.createElement(View8, { style: styles9.content }, children));
981
- };
982
- var ImgBg_default = ImgBg;
983
- export {
984
- A,
985
- BR,
986
- Blockquote,
987
- Center,
988
- Col1,
989
- Col10,
990
- Col11,
991
- Col12,
992
- Col2,
993
- Col3,
994
- Col4,
995
- Col5,
996
- Col6,
997
- Col7,
998
- Col8,
999
- Col9,
1000
- Container,
1001
- Div,
1002
- Em,
1003
- Font,
1004
- H1,
1005
- H2,
1006
- H3,
1007
- H4,
1008
- H5,
1009
- H6,
1010
- HR,
1011
- Header,
1012
- Img_default as Img,
1013
- ImgBg_default as ImgBg,
1014
- LI,
1015
- LayoutPDF_default as LayoutPDF,
1016
- Left,
1017
- Mark,
1018
- OL,
1019
- P,
1020
- QR_default as QR,
1021
- Right,
1022
- Row,
1023
- Small,
1024
- Span,
1025
- Strong,
1026
- StyleSheet10 as StyleSheet,
1027
- Table,
1028
- Tbody,
1029
- Td,
1030
- Text5 as Text,
1031
- Th,
1032
- Thead,
1033
- Tr,
1034
- U,
1035
- UL,
1036
- View9 as View,
1037
- decodeBase64Pdf_default as decodeBase64Pdf,
1038
- generatePDF_default as generatePDF,
1039
- renderToStream2 as renderToStream
1040
- };
1
+ import {StyleSheet,renderToStream,Document,Page,View,Text,Image,Link}from'@react-pdf/renderer';export{Font,StyleSheet,Text,View,renderToStream}from'@react-pdf/renderer';import O,{createContext,createElement,useContext,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Dt from'qrcode';var ht=(e,t)=>{let o=atob(e),n=new Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);let i=new Uint8Array(n),s=new Blob([i],{type:"application/pdf"}),r=URL.createObjectURL(s);if(document===void 0){console.error("document is undefined, only works in browser context");return}let l=document.createElement("a");l.href=r,l.download=t,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.open(r,"_blank"),setTimeout(()=>{URL.revokeObjectURL(r);},100);},X=ht;var yt=async({template:e,data:t})=>{try{if(!e)throw new Error("Template not provided");let o=createElement(e,{data:t}),n=await renderToStream(o);return await new Promise((s,r)=>{let l=[];n.on("data",a=>l.push(a)),n.on("end",()=>s(Buffer.concat(l).toString("base64"))),n.on("error",a=>r(a));})}catch(o){throw new Error("Error generating PDF: "+(o instanceof Error?o.message:"Unknown error"))}},G=yt;var re=StyleSheet.create({page:{backgroundColor:"white",padding:30,fontFamily:"Helvetica",fontSize:14},footer:{position:"absolute",left:0,right:0,textAlign:"center"}}),xt=({children:e,size:t="A4",orientation:o="vertical",backgroundColor:n="white",padding:i=30,margen:s="normal",style:r={},pagination:l=true,footer:a,lines:c=a?2:1,rule:d=false})=>{let x=c*20+10,L=(h,P)=>{let w=P.toUpperCase();switch(h){case "apa":return w==="LETTER"||w==="LEGAL"?{paddingTop:72,paddingRight:72,paddingBottom:72,paddingLeft:72}:{paddingTop:72,paddingRight:72,paddingBottom:72,paddingLeft:72};case "estrecho":return {paddingTop:36,paddingRight:36,paddingBottom:36,paddingLeft:36};case "ancho":return {paddingTop:108,paddingRight:108,paddingBottom:108,paddingLeft:108};default:return {paddingTop:i,paddingRight:i,paddingBottom:i,paddingLeft:i}}},T=t,V=o,M=n,te=s;try{typeof t=="string"&&!["A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","LETTER","LEGAL","TABLOID"].includes(t.toUpperCase())&&(console.warn(`Invalid page size: ${t}. Using A4 as default.`),T="A4");let P=["vertical","horizontal","portrait","landscape","h","v"],w=typeof o=="string"?o.toLowerCase():"vertical";P.includes(w)?V=o:(console.warn(`Invalid orientation: ${o}. Using vertical as default.`),V="vertical"),typeof n!="string"&&(console.warn(`Invalid background color: ${n}. Using white as default.`),M="white"),["apa","normal","estrecho","ancho"].includes(s)||(console.warn(`Invalid margin type: ${s}. Using normal as default.`),te="normal"),(typeof c!="number"||c<1)&&console.warn(`Invalid lines value: ${c}. Using 1 as default.`);}catch(h){console.warn("Error processing props in LayoutPDF:",h);}let ct=h=>{switch(h){case "vertical":case "portrait":case "v":return "portrait";case "horizontal":case "landscape":case "h":return "landscape";default:return console.warn(`Unrecognized orientation: ${h}. Using portrait as default.`),"portrait"}},dt=(h,P,w)=>{let v={A0:{width:841,height:1189},A1:{width:594,height:841},A2:{width:420,height:594},A3:{width:297,height:420},A4:{width:210,height:297},A5:{width:148,height:210},A6:{width:105,height:148},A7:{width:74,height:105},A8:{width:52,height:74},A9:{width:37,height:52},LETTER:{width:216,height:279},LEGAL:{width:216,height:356},TABLOID:{width:279,height:432}},I=2.834645669,A=v[h.toUpperCase()];if(!A)return P==="landscape"?595-w-10:842-w-10;let q=A.height*I,C=A.width*I;return P==="landscape"?C-w-10:q-w-10},z=ct(V),U=L(te,T),gt=dt(T,z,x),pt=()=>{if(!d)return null;let h=28.3465,P={A0:{width:841*2.834645669,height:1189*2.834645669},A1:{width:594*2.834645669,height:841*2.834645669},A2:{width:420*2.834645669,height:594*2.834645669},A3:{width:297*2.834645669,height:420*2.834645669},A4:{width:210*2.834645669,height:297*2.834645669},A5:{width:148*2.834645669,height:210*2.834645669},A6:{width:105*2.834645669,height:148*2.834645669},A7:{width:74*2.834645669,height:105*2.834645669},A8:{width:52*2.834645669,height:74*2.834645669},A9:{width:37*2.834645669,height:52*2.834645669},LETTER:{width:216*2.834645669,height:279*2.834645669},LEGAL:{width:216*2.834645669,height:356*2.834645669},TABLOID:{width:279*2.834645669,height:432*2.834645669}},w=P[T.toUpperCase()]||P.A4,v=z==="landscape"?w.height:w.width,I=z==="landscape"?w.width:w.height,A=[],q=[];for(let C=0;C<=Math.ceil(I/h);C++)A.push(jsx(View,{style:{position:"absolute",top:C*h,left:0,right:0,height:C%5===0?1:.5,backgroundColor:C%5===0?"rgba(255, 0, 0, 0.8)":"rgba(100, 100, 100, 0.5)"}},`h-${C}`));for(let C=0;C<=Math.ceil(v/h);C++)q.push(jsx(View,{style:{position:"absolute",left:C*h,top:0,bottom:0,width:C%5===0?1:.5,backgroundColor:C%5===0?"rgba(255, 0, 0, 0.8)":"rgba(100, 100, 100, 0.5)"}},`v-${C}`));return jsxs(View,{style:{position:"absolute",top:0,left:0,right:0,bottom:0},fixed:true,children:[A,q]})},mt={...re.page,backgroundColor:M,paddingTop:r?.paddingTop??r?.padding??U.paddingTop,paddingRight:r?.paddingRight??r?.padding??U.paddingRight,paddingLeft:r?.paddingLeft??r?.padding??U.paddingLeft,paddingBottom:(r?.paddingBottom??r?.padding??U.paddingBottom)+x,...(()=>{let{padding:h,paddingTop:P,paddingRight:w,paddingBottom:v,paddingLeft:I,...A}=r||{};return A})()},oe={...re.footer,top:gt,height:x,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",fontSize:10,color:"grey"};return jsx(Document,{children:jsxs(Page,{size:T,orientation:z,style:mt,wrap:true,children:[pt(),jsx(View,{style:{paddingBottom:x},children:e}),jsxs(View,{style:oe,fixed:true,children:[a&&a,l&&jsx(Text,{style:{fontSize:oe.fontSize},render:({pageNumber:h,totalPages:P})=>`${h} / ${P}`})]})]})})},ne=xt;var Lt=StyleSheet.create({image:{width:"100%",height:"auto",marginBottom:14}}),Ft=({src:e,style:t})=>jsx(Image,{src:e,style:[Lt.image,t]}),ie=Ft;var J=StyleSheet.create({left:{textAlign:"left"},right:{textAlign:"right"},center:{textAlign:"center"}}),ae=({children:e,style:t})=>jsx(View,{style:[J.left,t],children:e}),se=({children:e,style:t})=>jsx(View,{style:[J.right,t],children:e}),le=({children:e,style:t})=>jsx(View,{style:[J.center,t],children:e});var f=StyleSheet.create({p:{fontSize:12,marginBottom:5,lineHeight:1.2},h1:{fontSize:24,fontWeight:"bold",marginBottom:12},h2:{fontSize:20,fontWeight:"bold",marginBottom:10},h3:{fontSize:18,fontWeight:"bold",marginBottom:8},h4:{fontSize:16,fontWeight:"bold",marginBottom:6},h5:{fontSize:14,fontWeight:"bold",marginBottom:4},h6:{fontSize:12,fontWeight:"bold",marginBottom:0},strong:{fontWeight:"bold"},em:{fontStyle:"italic"},u:{textDecoration:"underline"},small:{fontSize:10},blockquote:{marginLeft:20,marginRight:20,fontStyle:"italic",borderLeft:"4px solid #ccc",paddingLeft:10},mark:{backgroundColor:"yellow"},A:{color:"#3d65fd",textDecoration:"none"},br:{width:"100%",height:1,marginTop:7,marginBottom:7},header:{position:"absolute",top:20,left:0,right:0,textAlign:"center",fontSize:10,color:"#666",paddingHorizontal:40},hr:{width:"100%",borderTop:"1px solid #000",marginTop:8,marginBottom:8}}),ce=({children:e,style:t})=>jsx(Text,{style:[f.p,t],children:e}),de=({children:e,style:t})=>jsx(Text,{style:[f.h1,t],children:e}),ge=({children:e,style:t})=>jsx(Text,{style:[f.h2,t],children:e}),pe=({children:e,style:t})=>jsx(Text,{style:[f.h3,t],children:e}),me=({children:e,style:t})=>jsx(Text,{style:[f.h4,t],children:e}),he=({children:e,style:t})=>jsx(Text,{style:[f.h5,t],children:e}),fe=({children:e,style:t})=>jsx(Text,{style:[f.h6,t],children:e}),ue=({children:e,style:t})=>jsx(Text,{style:[f.strong,t],children:e}),ye=({children:e,style:t})=>jsx(Text,{style:[f.em,t],children:e}),we=({children:e,style:t})=>jsx(Text,{style:[f.u,t],children:e}),Ce=({children:e,style:t})=>jsx(Text,{style:[f.small,t],children:e}),Re=({children:e,style:t})=>jsx(Text,{style:[f.blockquote,t],children:e}),be=({children:e,style:t})=>jsx(Text,{style:[f.mark,t],children:e}),xe=({children:e,style:t,href:o})=>jsx(Link,{src:o,style:[f.A,t],children:e}),Pe=({style:e})=>jsx(Text,{style:[f.br,e],children:`
2
+ `}),Te=({style:e})=>jsx(View,{style:[f.hr,e]}),Le=({children:e,style:t})=>jsx(Text,{style:[t],children:e}),Fe=({children:e,style:t,fixed:o=false})=>jsx(View,{style:[f.header,t],fixed:o,children:typeof e=="string"?jsx(Text,{children:e}):e}),Ae=({children:e,style:t})=>jsx(View,{style:t,children:e});var D=createContext({cellHeight:22,textAlign:"left"}),S=StyleSheet.create({table:{width:"100%",borderWidth:1,borderColor:"#000",marginBottom:20},thead:{backgroundColor:"#ccc"},tr:{flexDirection:"row"},textBold:{fontSize:10,fontFamily:"Helvetica",fontWeight:"bold",paddingLeft:8,paddingRight:8,justifyContent:"center"},text:{fontSize:10,fontFamily:"Helvetica",paddingLeft:8,paddingRight:8,justifyContent:"center"},zebraOdd:{backgroundColor:"#eeeeee"}}),Oe=({children:e,style:t,cellHeight:o=22})=>jsx(D.Provider,{value:{cellHeight:o,textAlign:"left"},children:jsx(View,{style:[S.table,t],children:e})}),Ve=({children:e,style:t,textAlign:o="left"})=>{let{cellHeight:n}=useContext(D);return jsx(D.Provider,{value:{cellHeight:n,textAlign:o},children:jsx(View,{style:[S.thead,t],children:e})})},ve=({children:e})=>{let t=O.Children.toArray(e),o=t.length;return jsx(Fragment,{children:t.map((n,i)=>O.cloneElement(n,{isLastRow:i===o-1,isOdd:i%2===1}))})},Ie=({children:e,style:t,isLastRow:o=false,isOdd:n=false})=>{let i=O.Children.toArray(e),s=i.length;return jsx(View,{style:[S.tr,t],children:i.map((r,l)=>{let a=l===s-1,c=`${(100/s).toFixed(2)}%`;return O.cloneElement(r,{width:c,isLast:a,isLastRow:o,isOdd:n})})})},Be=({children:e,style:t,width:o,height:n,colSpan:i,isLast:s=false,isLastRow:r=false,textAlign:l})=>{let{cellHeight:a,textAlign:c}=useContext(D),d=l||c||"left",g=typeof o=="string"&&i?`${(parseFloat(o)*i).toFixed(2)}%`:o,x={borderRightWidth:s?0:1,borderBottomWidth:r?0:1,borderColor:"#000",minHeight:n!==void 0?n:a};return jsx(View,{style:[S.textBold,{width:g},x,t],children:jsx(Text,{style:{textAlign:d},children:e})})},ke=({children:e,style:t,width:o,height:n,colSpan:i,isLast:s=false,isLastRow:r=false,isOdd:l=false,textAlign:a})=>{let{cellHeight:c,textAlign:d}=useContext(D),g=a||d||"left",y=typeof o=="string"&&i?`${(parseFloat(o)*i).toFixed(2)}%`:o,L={borderRightWidth:s?0:1,borderBottomWidth:r?0:1,borderColor:"#000",minHeight:n!==void 0?n:c};return jsx(View,{style:[S.text,l&&S.zebraOdd,{width:y},L,t],children:jsx(Text,{style:{textAlign:g},children:e})})};var p=StyleSheet.create({container:{width:"100%",paddingHorizontal:20},row:{flexDirection:"row",flexWrap:"wrap",marginHorizontal:-5},col:{paddingHorizontal:5},col1:{width:"8.33%"},col2:{width:"16.66%"},col3:{width:"25%"},col4:{width:"33.33%"},col5:{width:"41.66%"},col6:{width:"50%"},col7:{width:"58.33%"},col8:{width:"66.66%"},col9:{width:"75%"},col10:{width:"83.33%"},col11:{width:"91.66%"},col12:{width:"100%"}}),De=({children:e,style:t})=>jsx(View,{style:[p.container,t],children:e}),He=({children:e,style:t})=>jsx(View,{style:[p.row,t],children:e}),Ee=({children:e,style:t})=>jsx(View,{style:[p.col,p.col1,t],children:e}),Qe=({children:e,style:t})=>jsx(View,{style:[p.col,p.col2,t],children:e}),Me=({children:e,style:t})=>jsx(View,{style:[p.col,p.col3,t],children:e}),ze=({children:e,style:t})=>jsx(View,{style:[p.col,p.col4,t],children:e}),Ue=({children:e,style:t})=>jsx(View,{style:[p.col,p.col5,t],children:e}),qe=({children:e,style:t})=>jsx(View,{style:[p.col,p.col6,t],children:e}),Ne=({children:e,style:t})=>jsx(View,{style:[p.col,p.col7,t],children:e}),$e=({children:e,style:t})=>jsx(View,{style:[p.col,p.col8,t],children:e}),We=({children:e,style:t})=>jsx(View,{style:[p.col,p.col9,t],children:e}),Xe=({children:e,style:t})=>jsx(View,{style:[p.col,p.col10,t],children:e}),Ge=({children:e,style:t})=>jsx(View,{style:[p.col,p.col11,t],children:e}),_e=({children:e,style:t})=>jsx(View,{style:[p.col,p.col12,t],children:e});var $=async({value:e,size:t=150,colorDark:o="#000000",colorLight:n="#ffffff",margin:i=0,errorCorrectionLevel:s="M"})=>{try{let r={errorCorrectionLevel:s,type:"image/png",quality:.92,margin:i,color:{dark:o,light:n},width:t};return Dt.toDataURL(e,r)}catch(r){return console.error("Error generando QR:",r),""}},je=async(e,t,o,n)=>new Promise(async i=>{if(!e||!t){i(e);return}try{let s=typeof window<"u"&&typeof window.document<"u",r,l,a;if(s)r=document.createElement("canvas"),l=r.getContext("2d"),a=window.Image;else try{let{createCanvas:d,Image:g}=await import('canvas');r=d(100,100),l=r.getContext("2d"),a=g;}catch(d){console.error("Canvas not available in Node environment for addLogoToQR",d),i(e);return}if(!l){i(e);return}let c=new a;s&&(c.crossOrigin="anonymous"),c.onload=()=>{r.width=c.width,r.height=c.height,l.drawImage(c,0,0,r.width,r.height);let d=new a;s&&(d.crossOrigin="anonymous"),d.onload=()=>{let g=(r.width-o)/2,y=(r.height-n)/2;l.fillStyle="#FFFFFF",l.fillRect(g-5,y-5,o+10,n+10),l.drawImage(d,g,y,o,n);let x=r.toDataURL("image/png");i(x);},d.onerror=g=>{console.error("Error cargando el logo:",g),i(e);},d.src=t;},c.onerror=d=>{console.error("Error cargando el QR:",d),i("");},c.src=e;}catch(s){console.error("Error procesando el QR con logo:",s),i(e);}});var Ut=StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center",margin:10}}),qt={0:"L",1:"M",2:"Q",3:"H"},Nt=({value:e,size:t=150,style:o,colorDark:n="#000000",colorLight:i="#ffffff",margin:s=0,logo:r="",logoWidth:l=30,logoHeight:a=30,errorCorrectionLevel:c=r?"H":"M"})=>{let[d,g]=useState("");useEffect(()=>{(async()=>{try{let L=await $({value:e,size:t,colorDark:n,colorLight:i,margin:s,errorCorrectionLevel:typeof c=="number"?qt[c]||"M":c});if(r&&l&&a){let T=await je(L,r,l,a);g(T);}else g(L);}catch(L){console.error("Error generando QR:",L);let T=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}&color=${encodeURIComponent(n.replace("#",""))}&bgcolor=${encodeURIComponent(i.replace("#",""))}`;g(T);}})();},[e,t,n,i,s,r,l,a,c]);let y=`https://api.qrserver.com/v1/create-qr-code/?data=${encodeURIComponent(e)}&size=${t}x${t}`;return jsx(View,{style:[Ut.qrContainer,o],children:jsx(Image,{src:d||y,style:{width:t,height:t}})})},Ke=Nt;var Ye=async e=>{try{let t=typeof window<"u"&&typeof window.document<"u",o,n={};if(t)try{let c=await import('qr-code-styling');o=c.default||c;}catch(c){throw console.error("Failed to load qr-code-styling in browser",c),c}else {let c="jsdom",d="canvas",g="qr-code-styling/lib/qr-code-styling.common.js";try{let[y,x,L]=await Promise.all([import(c),import(d),import(g)]),{JSDOM:T}=y,V=x.default||x,{QRCodeStyling:M}=L;o=M,n={jsdom:T,nodeCanvas:V};}catch(y){throw console.error("Failed to load Node dependencies for QR generation",y),y}}let i=typeof e.width=="number"&&isFinite(e.width)?Math.round(e.width):300,s=typeof e.height=="number"&&isFinite(e.height)?Math.round(e.height):300,r={width:i,height:s,data:e.value,image:e.image,dotsOptions:e.dotsOptions,backgroundOptions:{color:e.backgroundOptions?.color||"#ffffff",...e.backgroundOptions},imageOptions:{crossOrigin:"anonymous",margin:typeof e.imageOptions?.margin=="number"&&isFinite(e.imageOptions.margin)?e.imageOptions.margin:0,saveAsBlob:!0,imageSize:typeof e.imageOptions?.imageSize=="number"&&isFinite(e.imageOptions.imageSize)?Math.max(0,Math.min(1,e.imageOptions.imageSize)):.4},cornersSquareOptions:e.cornersSquareOptions,cornersDotOptions:e.cornersDotOptions},a=await new o({type:"png",...n,...r}).getRawData("png");if(!a)throw new Error("Failed to generate raw data from qr-code-styling");if(t){if(a instanceof Blob)return new Promise((c,d)=>{let g=new FileReader;g.onloadend=()=>{typeof g.result=="string"?c(g.result):d(new Error("Failed to convert blob to base64"));},g.onerror=d,g.readAsDataURL(a);});console.warn("Unexpected rawData type in browser:",a);}if(typeof Buffer<"u"&&Buffer.isBuffer(a))return `data:image/png;base64,${a.toString("base64")}`;throw new Error(`Unexpected raw data type: ${typeof a}`)}catch(t){return console.error("Error generating QR V2, falling back to V1:",t),$({value:e.value,size:e.width,colorDark:e.fallbackColorDark||e.dotsOptions?.color,colorLight:e.fallbackColorLight||e.backgroundOptions?.color,margin:e.fallbackMargin||0,errorCorrectionLevel:e.fallbackErrorCorrectionLevel||"M"})}};var Gt=StyleSheet.create({qrContainer:{display:"flex",alignItems:"center",justifyContent:"center"}}),_t=({value:e,size:t=300,style:o,image:n,dotsOptions:i,backgroundOptions:s,imageOptions:r,cornersSquareOptions:l,cornersDotOptions:a,colorDark:c,colorLight:d,margin:g,errorCorrectionLevel:y})=>jsx(View,{style:[Gt.qrContainer,o],children:jsx(Image,{style:{width:t,height:t},src:Ye({value:e,width:t,height:t,image:n,dotsOptions:i||(c?{color:c}:void 0),backgroundOptions:s||(d?{color:d}:void 0),imageOptions:{...r,margin:r?.margin!==void 0?r.margin:g},cornersSquareOptions:l,cornersDotOptions:a,fallbackColorDark:c,fallbackColorLight:d,fallbackMargin:g,fallbackErrorCorrectionLevel:y})})}),et=_t;var E=StyleSheet.create({ul:{marginBottom:10,paddingLeft:15},ol:{marginBottom:10,paddingLeft:15},li:{marginBottom:5,flexDirection:"row"},bulletPoint:{width:15,marginRight:5,fontSize:12},itemContent:{flex:1}}),Jt=(e="disc")=>{switch(e){case "circle":return "\u25CB";case "square":return "\u25A0";default:return "\u2022"}},Kt=(e,t="decimal",o=1)=>{let n=o+e-1;switch(t){case "lower-alpha":return String.fromCharCode(97+n%26)+".";case "upper-alpha":return String.fromCharCode(65+n%26)+".";case "lower-roman":return ot(n).toLowerCase()+".";case "upper-roman":return ot(n)+".";default:return n+"."}},ot=e=>{if(e<=0||e>3999)return String(e);let t=[["","I","II","III","IV","V","VI","VII","VIII","IX"],["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"],["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"],["","M","MM","MMM"]];return t[3][Math.floor(e/1e3)]+t[2][Math.floor(e%1e3/100)]+t[1][Math.floor(e%100/10)]+t[0][e%10]},rt=({children:e,style:t,type:o="disc"})=>{let n=O.Children.map(e,(i,s)=>O.isValidElement(i)?O.cloneElement(i,{bulletType:o,isOrdered:false,index:s+1}):i);return jsx(View,{style:[E.ul,t],children:n})},nt=({children:e,style:t,type:o="decimal",start:n=1})=>{let i=O.Children.map(e,(s,r)=>O.isValidElement(s)?O.cloneElement(s,{bulletType:o,isOrdered:true,index:r+1,start:n}):s);return jsx(View,{style:[E.ol,t],children:i})},it=({children:e,style:t,bulletType:o="disc",isOrdered:n=false,index:i=1,start:s=1,value:r})=>{let l;if(n){let a=r!==void 0?Number(r):i;l=Kt(a,o,s);}else l=Jt(o);return jsxs(View,{style:[E.li,t],children:[jsx(Text,{style:E.bulletPoint,children:l}),jsx(View,{style:E.itemContent,children:typeof e=="string"?jsx(Text,{children:e}):e})]})};var ee=StyleSheet.create({container:{position:"relative",width:"100%",height:"100%"},background:{position:"absolute",top:0,left:0,right:0,bottom:0},content:{position:"relative"}}),to=({src:e,width:t="100%",height:o="100%",opacity:n=.2,children:i,style:s,fixed:r=false,objectFit:l="cover",objectPosition:a="center"})=>jsxs(View,{style:[ee.container,s],children:[jsx(Image,{src:e,style:[ee.background,{width:t,height:o,opacity:n,objectFit:l,objectPosition:a}],fixed:r}),jsx(View,{style:ee.content,children:i})]}),lt=to;
3
+ export{xe as A,Pe as BR,Re as Blockquote,le as Center,Ee as Col1,Xe as Col10,Ge as Col11,_e as Col12,Qe as Col2,Me as Col3,ze as Col4,Ue as Col5,qe as Col6,Ne as Col7,$e as Col8,We as Col9,De as Container,Ae as Div,ye as Em,de as H1,ge as H2,pe as H3,me as H4,he as H5,fe as H6,Te as HR,Fe as Header,ie as Img,lt as ImgBg,it as LI,ne as LayoutPDF,ae as Left,be as Mark,nt as OL,ce as P,Ke as QR,et as QRV2,se as Right,He as Row,Ce as Small,Le as Span,ue as Strong,Oe as Table,ve as Tbody,ke as Td,Be as Th,Ve as Thead,Ie as Tr,we as U,rt as UL,X as decodeBase64Pdf,G as generatePDF};//# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map