react-pdf-levelup 3.1.57 → 3.1.63

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