react-pdf-levelup 3.1.63 → 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/README.md ADDED
@@ -0,0 +1,340 @@
1
+ <p align="center">
2
+ <img src="https://genarogg.github.io/media/react-pdf-levelup/logo-de-react-pdf-levelup.png" alt="react-pdf-levelup logo" width="160" />
3
+ </p>
4
+
5
+ # react-pdf-levelup
6
+
7
+ Generador de PDFs dinámicos con React. Esta herramienta te permite crear plantillas PDF con componentes JSX personalizados y previsualizarlas en tiempo real dentro de una aplicación web. Ideal para etiquetas, facturas, reportes, certificados, tablas y más.
8
+
9
+ # 🌐 **Playground en vivo:**
10
+ [https://react-pdf-levelup.nimbux.cloud](https://react-pdf-levelup.nimbux.cloud)
11
+ or
12
+ [https://react-pdf-levelup.nimbux.cloud](https://react-pdf-levelup.nimbux.cloud)
13
+
14
+ ## 📦 Instalación
15
+
16
+ ```bash
17
+ npm install react-pdf-levelup
18
+ ```
19
+
20
+ ## 🚀 Características
21
+
22
+ - 🧱 Construye PDFs con componentes de React usando los componentes de `react-pdf-levelup` (LayoutPDF, texto, listas, QR, tablas, columnas, etc.)
23
+ - 🖼 Vista previa en tiempo real de los documentos generados
24
+ - 🎨 Editor en vivo con Monaco Editor para personalizar código JSX
25
+ - 📦 Plantillas predefinidas listas para usar
26
+ - 📄 Soporte para códigos QR, tablas, imágenes, listas, layout dinámico, etc.
27
+ - 🔄 Generación de PDFs desde templates de React
28
+ - 📥 Descarga automática y vista previa de PDFs generados
29
+
30
+ ## 📋 Funciones Principales
31
+
32
+ ### `generatePDF`
33
+
34
+ Genera un PDF en formato base64 a partir de un componente de React.
35
+
36
+ ```typescript
37
+ import { generatePDF } from 'react-pdf-levelup';
38
+
39
+ const pdfBase64 = await generatePDF({
40
+ template: MyPDFTemplate,
41
+ data: {
42
+ title: 'Mi Documento',
43
+ items: ['Item 1', 'Item 2', 'Item 3']
44
+ }
45
+ });
46
+ ```
47
+
48
+ **Parámetros:**
49
+ - `template`: Componente de React que define la estructura del PDF
50
+ - `data`: Datos opcionales que se pasarán al template
51
+
52
+ **Retorna:** Promise que resuelve a un string en base64 del PDF generado
53
+
54
+ ### `decodeBase64Pdf`
55
+
56
+ Decodifica un PDF en base64 y permite descargarlo o abrirlo en una nueva pestaña.
57
+
58
+ ```typescript
59
+ import { decodeBase64Pdf } from 'react-pdf-levelup';
60
+
61
+ // Después de generar el PDF
62
+ const pdfBase64 = await generatePDF({ template: MyTemplate });
63
+
64
+ // Descargar y abrir el PDF
65
+ decodeBase64Pdf(pdfBase64, 'mi-documento.pdf');
66
+ ```
67
+
68
+ **Parámetros:**
69
+ - `base64`: String del PDF en formato base64
70
+ - `fileName`: Nombre del archivo para la descarga
71
+
72
+ **Funcionalidad:**
73
+ - Descarga automática del archivo PDF
74
+ - Abre el PDF en una nueva pestaña del navegador
75
+ - Limpia automáticamente los recursos de memoria
76
+
77
+ ## 💡 Ejemplo de Uso con componentes levelup
78
+
79
+ ```typescript
80
+ import React from 'react';
81
+ import { generatePDF, decodeBase64Pdf, LayoutPDF, H1, P, Strong, Em, HR, Container, Row, Col6, UL, LI, QR, Table, Thead, Tbody, Tr, Th, Td } from 'react-pdf-levelup';
82
+
83
+ const MyPDFTemplate = ({ data }) => (
84
+ <LayoutPDF>
85
+ <H1>Documento de Presentación</H1>
86
+ <P>
87
+ Bienvenido a <Strong>react-pdf-levelup</Strong>. Construye PDFs con componentes de React de forma <Em>rápida</Em> y <Em>tipada</Em>.
88
+ </P>
89
+ <HR />
90
+ <Container>
91
+ <Row>
92
+ <Col6>
93
+ <UL>
94
+ <LI>Plantillas listas</LI>
95
+ <LI>Componentes composables</LI>
96
+ <LI>TypeScript</LI>
97
+ <LI>Integración moderna</LI>
98
+ </UL>
99
+ </Col6>
100
+ <Col6>
101
+ <QR value="https://react-pdf-levelup.nimbux.cloud" size={120} />
102
+ </Col6>
103
+ </Row>
104
+ </Container>
105
+ <Table cellHeight={24}>
106
+ <Thead>
107
+ <Tr>
108
+ <Th width="40%">Producto</Th>
109
+ <Th width="20%">Cantidad</Th>
110
+ <Th width="20%">Precio</Th>
111
+ <Th width="20%">Total</Th>
112
+ </Tr>
113
+ </Thead>
114
+ <Tbody>
115
+ <Tr>
116
+ <Td width="40%">Etiqueta Térmica 50x30</Td>
117
+ <Td width="20%">2</Td>
118
+ <Td width="20%">$5.00</Td>
119
+ <Td width="20%">$10.00</Td>
120
+ </Tr>
121
+ </Tbody>
122
+ </Table>
123
+ </LayoutPDF>
124
+ );
125
+
126
+ // Función para generar y descargar PDF
127
+ const handleGeneratePDF = async () => {
128
+ try {
129
+ const pdfBase64 = await generatePDF({
130
+ template: MyPDFTemplate,
131
+ data: {
132
+ title: 'Mi Lista de Tareas',
133
+ items: [
134
+ 'Revisar documentación',
135
+ 'Implementar nuevas funciones',
136
+ 'Realizar pruebas',
137
+ 'Desplegar a producción'
138
+ ]
139
+ }
140
+ });
141
+
142
+ // Descargar y abrir el PDF
143
+ decodeBase64Pdf(pdfBase64, 'lista-tareas.pdf');
144
+
145
+ } catch (error) {
146
+ console.error('Error generando PDF:', error);
147
+ }
148
+ };
149
+
150
+ // Componente React
151
+ const App = () => {
152
+ return (
153
+ <div>
154
+ <h1>Generador de PDF</h1>
155
+ <button onClick={handleGeneratePDF}>
156
+ Generar y Descargar PDF
157
+ </button>
158
+ </div>
159
+ );
160
+ };
161
+
162
+ export default App;
163
+ ```
164
+
165
+ ## 🎨 Templates Avanzados
166
+
167
+ ```typescript
168
+ import { StyleSheet, Font } from '@react-pdf/renderer';
169
+
170
+ // Ejemplo de template para factura
171
+ const InvoiceTemplate = ({ data }) => (
172
+ <Document>
173
+ <Page size="A4" style={styles.page}>
174
+ <View style={styles.header}>
175
+ <Text style={styles.companyName}>{data.company}</Text>
176
+ <Text>Factura #{data.invoiceNumber}</Text>
177
+ </View>
178
+
179
+ <View style={styles.customerInfo}>
180
+ <Text>Cliente: {data.customer.name}</Text>
181
+ <Text>Email: {data.customer.email}</Text>
182
+ </View>
183
+
184
+ <View style={styles.itemsTable}>
185
+ {data.items.map((item, index) => (
186
+ <View key={index} style={styles.tableRow}>
187
+ <Text style={styles.itemName}>{item.name}</Text>
188
+ <Text style={styles.itemQuantity}>{item.quantity}</Text>
189
+ <Text style={styles.itemPrice}>${item.price}</Text>
190
+ </View>
191
+ ))}
192
+ </View>
193
+
194
+ <View style={styles.total}>
195
+ <Text>Total: ${data.total}</Text>
196
+ </View>
197
+ </Page>
198
+ </Document>
199
+ );
200
+ ```
201
+
202
+ ## 🔧 Configuración Avanzada
203
+
204
+ ### Manejo de Errores
205
+
206
+ ```typescript
207
+ const handlePDFGeneration = async () => {
208
+ try {
209
+ const pdfBase64 = await generatePDF({
210
+ template: MyTemplate,
211
+ data: myData
212
+ });
213
+
214
+ decodeBase64Pdf(pdfBase64, 'documento.pdf');
215
+
216
+ } catch (error) {
217
+ if (error.message.includes('Template not provided')) {
218
+ console.error('Error: No se proporcionó un template válido');
219
+ } else {
220
+ console.error('Error inesperado:', error.message);
221
+ }
222
+ }
223
+ };
224
+ ```
225
+
226
+ ### Solo Generar Base64 (sin descargar)
227
+
228
+ ```typescript
229
+ const generatePDFOnly = async () => {
230
+ const pdfBase64 = await generatePDF({
231
+ template: MyTemplate,
232
+ data: myData
233
+ });
234
+
235
+ // Usar el base64 para otros propósitos (envío por API, almacenamiento, etc.)
236
+ console.log('PDF generado:', pdfBase64);
237
+ return pdfBase64;
238
+ };
239
+ ```
240
+
241
+ ## 🛠 Dependencias
242
+
243
+ Esta librería utiliza internamente:
244
+ - `@react-pdf/renderer` - Para la generación de PDFs
245
+ - `react` - Para los componentes JSX
246
+
247
+ ## 📝 Notas Importantes
248
+
249
+ - La función `decodeBase64Pdf` solo funciona en contexto de navegador (requiere `document`)
250
+ - Los templates deben usar los componentes de `react-pdf-levelup` y retornar JSX válido
251
+ - El PDF se genera de forma asíncrona, asegúrate de usar `await` o `.then()`
252
+ - Los recursos de memoria se limpian automáticamente después de la descarga
253
+
254
+ ## 🌐 API REST para generar PDFs
255
+
256
+ - Genera PDFs vía HTTP desde cualquier lenguaje usando un template TSX en base64 y un objeto de datos.
257
+ - Devuelve un JSON con `data.pdf` que es el PDF en base64.
258
+
259
+ ### Endpoints
260
+
261
+ - Cloud: [https://react-pdf-levelup.nimbux.cloud/api](https://react-pdf-levelup.nimbux.cloud/api)
262
+ - Auto‑hospedado ZIP: [https://genarogg.github.io/react-pdf-levelup/public/api.zip](https://genarogg.github.io/react-pdf-levelup/public/api.zip)
263
+
264
+ ```text
265
+ https://react-pdf-levelup.nimbux.cloud/api
266
+ ```
267
+
268
+ ```text
269
+ https://genarogg.github.io/react-pdf-levelup/public/api.zip
270
+ ```
271
+
272
+ ### Request
273
+
274
+ POST con `Content-Type: application/json`:
275
+
276
+ ```json
277
+ {
278
+ "template": "<TSX_EN_BASE64>",
279
+ "data": { "campo": "valor" }
280
+ }
281
+ ```
282
+
283
+ ### Response
284
+
285
+ ```json
286
+ {
287
+ "data": {
288
+ "pdf": "<PDF_EN_BASE64>"
289
+ }
290
+ }
291
+ ```
292
+
293
+ ### Ejemplo rápido con Node.js (fetch)
294
+
295
+ ```ts
296
+ import fs from "fs";
297
+ import path from "path";
298
+
299
+ type ApiResponse = { data?: { pdf?: string } };
300
+ const ENDPOINT_API = "https://react-pdf-levelup.nimbux.cloud/api";
301
+
302
+ const petition = async ({ template, data }: { template: string, data: any }): Promise<string> => {
303
+ const templatePath = path.join(process.cwd(), "src", "useExample", template);
304
+ const tsxCode = fs.readFileSync(templatePath, "utf-8");
305
+ const templateBase64 = Buffer.from(tsxCode, "utf-8").toString("base64");
306
+
307
+ const res = await fetch(ENDPOINT_API, {
308
+ method: "POST",
309
+ headers: { "Content-Type": "application/json" },
310
+ body: JSON.stringify({ template: templateBase64, data }),
311
+ });
312
+ if (!res.ok) throw new Error(`API error (${res.status}): ${await res.text()}`);
313
+ const json = await res.json() as ApiResponse;
314
+ return json?.data?.pdf ?? "";
315
+ }
316
+
317
+ const savePDF = (base64: string) => {
318
+ const buffer = Buffer.from(base64, "base64");
319
+ const outputPath = path.join(process.cwd(), "example.pdf");
320
+ fs.writeFileSync(outputPath, buffer);
321
+ console.log("PDF guardado:", outputPath);
322
+ }
323
+ ```
324
+
325
+ ### Self‑hosting propio
326
+
327
+ - Descarga el paquete ZIP y despliega en tu infraestructura (Node/Docker/PaaS).
328
+ - Expón el endpoint `/api/pdf` con el mismo contrato JSON.
329
+ - Usa el mismo cliente mostrado arriba apuntando a tu URL.
330
+
331
+ Más detalles y ejemplos en la documentación:
332
+ [Guía API REST (fetch)](https://react-pdf-levelup-docs.nimbux.cloud/docs/guides/api-rest)
333
+
334
+ ## 🤝 Contribuir
335
+
336
+ Las contribuciones son bienvenidas. Por favor, abre un issue o envía un pull request.
337
+
338
+ ## 📄 Licencia
339
+
340
+ MIT License
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var renderer=require('@react-pdf/renderer'),O=require('react'),jsxRuntime=require('react/jsx-runtime'),Et=require('qrcode');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var O__default=/*#__PURE__*/_interopDefault(O);var Et__default=/*#__PURE__*/_interopDefault(Et);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=O.createElement(e,{data:t}),r=await renderer.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=renderer.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(jsxRuntime.jsx(renderer.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(jsxRuntime.jsx(renderer.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 jsxRuntime.jsxs(renderer.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 jsxRuntime.jsx(renderer.Document,{children:jsxRuntime.jsxs(renderer.Page,{size:R,orientation:N,style:ht,wrap:true,children:[pt(),jsxRuntime.jsx(renderer.View,{style:{paddingBottom:u},children:e}),s?jsxRuntime.jsxs(renderer.View,{style:ae,fixed:true,children:[d,jsxRuntime.jsx(renderer.Text,{style:{fontSize:ae.fontSize},render:({pageNumber:y,totalPages:F})=>`${y} / ${F}`})]}):null]})})},se=Pt;var Lt=renderer.StyleSheet.create({image:{width:"100%",height:"auto",marginBottom:14}}),St=({src:e,style:t})=>jsxRuntime.jsx(renderer.Image,{src:e,style:[Lt.image,t]}),le=St;var Y=renderer.StyleSheet.create({left:{textAlign:"left"},right:{textAlign:"right"},center:{textAlign:"center"}}),ce=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[Y.left,t],children:e}),de=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[Y.right,t],children:e}),ge=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[Y.center,t],children:e});var f=renderer.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})=>jsxRuntime.jsx(renderer.Text,{style:[f.p,t],children:e}),pe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h1,t],children:e}),he=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h2,t],children:e}),fe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h3,t],children:e}),ue=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h4,t],children:e}),ye=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h5,t],children:e}),we=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h6,t],children:e}),Ce=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.strong,t],children:e}),Re=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.em,t],children:e}),be=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.u,t],children:e}),xe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.small,t],children:e}),Pe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.blockquote,t],children:e}),Te=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.mark,t],children:e}),Fe=({children:e,style:t,href:o})=>jsxRuntime.jsx(renderer.Link,{src:o,style:[f.A,t],children:e}),Le=({style:e})=>jsxRuntime.jsx(renderer.Text,{style:[f.br,e],children:`
2
- `}),Se=({style:e})=>jsxRuntime.jsx(renderer.View,{style:[f.hr,e]}),Ae=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[t],children:e}),Ve=({children:e,style:t,fixed:o=false})=>jsxRuntime.jsx(renderer.View,{style:[f.header,t],fixed:o,children:typeof e=="string"?jsxRuntime.jsx(renderer.Text,{children:e}):e}),Oe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:t,children:e});var E=O.createContext({cellHeight:22,textAlign:"left"}),V=renderer.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})=>jsxRuntime.jsx(E.Provider,{value:{cellHeight:o,textAlign:"left"},children:jsxRuntime.jsx(renderer.View,{style:[V.table,t],children:e})}),ve=({children:e,style:t,textAlign:o="left"})=>{let{cellHeight:r}=O.useContext(E);return jsxRuntime.jsx(E.Provider,{value:{cellHeight:r,textAlign:o},children:jsxRuntime.jsx(renderer.View,{style:[V.thead,t],children:e})})},ke=({children:e,style:t})=>{let o=O__default.default.Children.toArray(e),r=o.length;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:o.map((a,i)=>O__default.default.cloneElement(a,{isLastRow:i===r-1,isOdd:i%2===1}))})},De=({children:e,style:t,isLastRow:o=false,isOdd:r=false})=>{let a=O__default.default.Children.toArray(e),i=a.length;return jsxRuntime.jsx(renderer.View,{style:[V.tr,t],children:a.map((n,s)=>{let d=s===i-1,l=`${(100/i).toFixed(2)}%`;return O__default.default.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}=O.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 jsxRuntime.jsx(renderer.View,{style:[V.textBold,{width:g},u,t],children:jsxRuntime.jsx(renderer.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}=O.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 jsxRuntime.jsx(renderer.View,{style:[V.text,s&&V.zebraOdd,{width:p},P,t],children:jsxRuntime.jsx(renderer.Text,{style:{textAlign:g},children:e})})};var m=renderer.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})=>jsxRuntime.jsx(renderer.View,{style:[m.container,t],children:e}),Me=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.row,t],children:e}),Ue=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col1,t],children:e}),Ne=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col2,t],children:e}),qe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col3,t],children:e}),ze=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col4,t],children:e}),$e=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col5,t],children:e}),We=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col6,t],children:e}),Xe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col7,t],children:e}),Ge=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col8,t],children:e}),Je=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col9,t],children:e}),_e=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col10,t],children:e}),je=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[m.col,m.col11,t],children:e}),Ke=({children:e,style:t})=>jsxRuntime.jsx(renderer.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__default.default.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=renderer.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]=O.useState("");O.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 jsxRuntime.jsx(renderer.View,{style:[qt.qrContainer,o],children:jsxRuntime.jsx(renderer.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=renderer.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]=O.useState("");return O.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]),jsxRuntime.jsx(renderer.View,{style:[jt.qrContainer,o],children:jsxRuntime.jsx(renderer.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=renderer.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__default.default.Children.map(e,(a,i)=>O__default.default.isValidElement(a)?O__default.default.cloneElement(a,{bulletType:o,isOrdered:false,index:i+1}):a);return jsxRuntime.jsx(renderer.View,{style:[Q.ul,t],children:r})},it=({children:e,style:t,type:o="decimal",start:r=1})=>{let a=O__default.default.Children.map(e,(i,n)=>O__default.default.isValidElement(i)?O__default.default.cloneElement(i,{bulletType:o,isOrdered:true,index:n+1,start:r}):i);return jsxRuntime.jsx(renderer.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 jsxRuntime.jsxs(renderer.View,{style:[Q.li,t],children:[jsxRuntime.jsx(renderer.Text,{style:Q.bulletPoint,children:s}),jsxRuntime.jsx(renderer.View,{style:Q.itemContent,children:typeof e=="string"?jsxRuntime.jsx(renderer.Text,{children:e}):e})]})};var re=renderer.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"})=>jsxRuntime.jsxs(renderer.View,{style:[re.container,i],children:[jsxRuntime.jsx(renderer.Image,{src:e,style:[re.background,{width:t,height:o,opacity:r,objectFit:s,objectPosition:d}],fixed:n}),jsxRuntime.jsx(renderer.View,{style:re.content,children:a})]}),dt=no;
3
- Object.defineProperty(exports,"Font",{enumerable:true,get:function(){return renderer.Font}});Object.defineProperty(exports,"StyleSheet",{enumerable:true,get:function(){return renderer.StyleSheet}});Object.defineProperty(exports,"Text",{enumerable:true,get:function(){return renderer.Text}});Object.defineProperty(exports,"View",{enumerable:true,get:function(){return renderer.View}});Object.defineProperty(exports,"renderToStream",{enumerable:true,get:function(){return renderer.renderToStream}});exports.A=Fe;exports.BR=Le;exports.Blockquote=Pe;exports.Center=ge;exports.Col1=Ue;exports.Col10=_e;exports.Col11=je;exports.Col12=Ke;exports.Col2=Ne;exports.Col3=qe;exports.Col4=ze;exports.Col5=$e;exports.Col6=We;exports.Col7=Xe;exports.Col8=Ge;exports.Col9=Je;exports.Container=Qe;exports.Div=Oe;exports.Em=Re;exports.H1=pe;exports.H2=he;exports.H3=fe;exports.H4=ue;exports.H5=ye;exports.H6=we;exports.HR=Se;exports.Header=Ve;exports.Img=le;exports.ImgBg=dt;exports.LI=st;exports.LayoutPDF=se;exports.Left=ce;exports.Mark=Te;exports.OL=it;exports.P=me;exports.QR=et;exports.QRV2=ot;exports.Right=de;exports.Row=Me;exports.Small=xe;exports.Span=Ae;exports.Strong=Ce;exports.Table=Be;exports.Tbody=ke;exports.Td=He;exports.Th=Ee;exports.Thead=ve;exports.Tr=De;exports.U=be;exports.UL=at;exports.decodeBase64Pdf=J;exports.generatePDF=_;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var renderer=require('@react-pdf/renderer'),O=require('react'),jsxRuntime=require('react/jsx-runtime'),Dt=require('qrcode');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var O__default=/*#__PURE__*/_interopDefault(O);var Dt__default=/*#__PURE__*/_interopDefault(Dt);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=O.createElement(e,{data:t}),n=await renderer.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=renderer.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(jsxRuntime.jsx(renderer.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(jsxRuntime.jsx(renderer.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 jsxRuntime.jsxs(renderer.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 jsxRuntime.jsx(renderer.Document,{children:jsxRuntime.jsxs(renderer.Page,{size:T,orientation:z,style:mt,wrap:true,children:[pt(),jsxRuntime.jsx(renderer.View,{style:{paddingBottom:x},children:e}),jsxRuntime.jsxs(renderer.View,{style:oe,fixed:true,children:[a&&a,l&&jsxRuntime.jsx(renderer.Text,{style:{fontSize:oe.fontSize},render:({pageNumber:h,totalPages:P})=>`${h} / ${P}`})]})]})})},ne=xt;var Lt=renderer.StyleSheet.create({image:{width:"100%",height:"auto",marginBottom:14}}),Ft=({src:e,style:t})=>jsxRuntime.jsx(renderer.Image,{src:e,style:[Lt.image,t]}),ie=Ft;var J=renderer.StyleSheet.create({left:{textAlign:"left"},right:{textAlign:"right"},center:{textAlign:"center"}}),ae=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[J.left,t],children:e}),se=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[J.right,t],children:e}),le=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[J.center,t],children:e});var f=renderer.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})=>jsxRuntime.jsx(renderer.Text,{style:[f.p,t],children:e}),de=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h1,t],children:e}),ge=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h2,t],children:e}),pe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h3,t],children:e}),me=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h4,t],children:e}),he=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h5,t],children:e}),fe=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.h6,t],children:e}),ue=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.strong,t],children:e}),ye=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.em,t],children:e}),we=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.u,t],children:e}),Ce=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.small,t],children:e}),Re=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.blockquote,t],children:e}),be=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[f.mark,t],children:e}),xe=({children:e,style:t,href:o})=>jsxRuntime.jsx(renderer.Link,{src:o,style:[f.A,t],children:e}),Pe=({style:e})=>jsxRuntime.jsx(renderer.Text,{style:[f.br,e],children:`
2
+ `}),Te=({style:e})=>jsxRuntime.jsx(renderer.View,{style:[f.hr,e]}),Le=({children:e,style:t})=>jsxRuntime.jsx(renderer.Text,{style:[t],children:e}),Fe=({children:e,style:t,fixed:o=false})=>jsxRuntime.jsx(renderer.View,{style:[f.header,t],fixed:o,children:typeof e=="string"?jsxRuntime.jsx(renderer.Text,{children:e}):e}),Ae=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:t,children:e});var D=O.createContext({cellHeight:22,textAlign:"left"}),S=renderer.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})=>jsxRuntime.jsx(D.Provider,{value:{cellHeight:o,textAlign:"left"},children:jsxRuntime.jsx(renderer.View,{style:[S.table,t],children:e})}),Ve=({children:e,style:t,textAlign:o="left"})=>{let{cellHeight:n}=O.useContext(D);return jsxRuntime.jsx(D.Provider,{value:{cellHeight:n,textAlign:o},children:jsxRuntime.jsx(renderer.View,{style:[S.thead,t],children:e})})},ve=({children:e})=>{let t=O__default.default.Children.toArray(e),o=t.length;return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t.map((n,i)=>O__default.default.cloneElement(n,{isLastRow:i===o-1,isOdd:i%2===1}))})},Ie=({children:e,style:t,isLastRow:o=false,isOdd:n=false})=>{let i=O__default.default.Children.toArray(e),s=i.length;return jsxRuntime.jsx(renderer.View,{style:[S.tr,t],children:i.map((r,l)=>{let a=l===s-1,c=`${(100/s).toFixed(2)}%`;return O__default.default.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}=O.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 jsxRuntime.jsx(renderer.View,{style:[S.textBold,{width:g},x,t],children:jsxRuntime.jsx(renderer.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}=O.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 jsxRuntime.jsx(renderer.View,{style:[S.text,l&&S.zebraOdd,{width:y},L,t],children:jsxRuntime.jsx(renderer.Text,{style:{textAlign:g},children:e})})};var p=renderer.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})=>jsxRuntime.jsx(renderer.View,{style:[p.container,t],children:e}),He=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.row,t],children:e}),Ee=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col1,t],children:e}),Qe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col2,t],children:e}),Me=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col3,t],children:e}),ze=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col4,t],children:e}),Ue=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col5,t],children:e}),qe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col6,t],children:e}),Ne=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col7,t],children:e}),$e=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col8,t],children:e}),We=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col9,t],children:e}),Xe=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col10,t],children:e}),Ge=({children:e,style:t})=>jsxRuntime.jsx(renderer.View,{style:[p.col,p.col11,t],children:e}),_e=({children:e,style:t})=>jsxRuntime.jsx(renderer.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__default.default.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=renderer.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]=O.useState("");O.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 jsxRuntime.jsx(renderer.View,{style:[Ut.qrContainer,o],children:jsxRuntime.jsx(renderer.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=renderer.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})=>jsxRuntime.jsx(renderer.View,{style:[Gt.qrContainer,o],children:jsxRuntime.jsx(renderer.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=renderer.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__default.default.Children.map(e,(i,s)=>O__default.default.isValidElement(i)?O__default.default.cloneElement(i,{bulletType:o,isOrdered:false,index:s+1}):i);return jsxRuntime.jsx(renderer.View,{style:[E.ul,t],children:n})},nt=({children:e,style:t,type:o="decimal",start:n=1})=>{let i=O__default.default.Children.map(e,(s,r)=>O__default.default.isValidElement(s)?O__default.default.cloneElement(s,{bulletType:o,isOrdered:true,index:r+1,start:n}):s);return jsxRuntime.jsx(renderer.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 jsxRuntime.jsxs(renderer.View,{style:[E.li,t],children:[jsxRuntime.jsx(renderer.Text,{style:E.bulletPoint,children:l}),jsxRuntime.jsx(renderer.View,{style:E.itemContent,children:typeof e=="string"?jsxRuntime.jsx(renderer.Text,{children:e}):e})]})};var ee=renderer.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"})=>jsxRuntime.jsxs(renderer.View,{style:[ee.container,s],children:[jsxRuntime.jsx(renderer.Image,{src:e,style:[ee.background,{width:t,height:o,opacity:n,objectFit:l,objectPosition:a}],fixed:r}),jsxRuntime.jsx(renderer.View,{style:ee.content,children:i})]}),lt=to;
3
+ Object.defineProperty(exports,"Font",{enumerable:true,get:function(){return renderer.Font}});Object.defineProperty(exports,"StyleSheet",{enumerable:true,get:function(){return renderer.StyleSheet}});Object.defineProperty(exports,"Text",{enumerable:true,get:function(){return renderer.Text}});Object.defineProperty(exports,"View",{enumerable:true,get:function(){return renderer.View}});Object.defineProperty(exports,"renderToStream",{enumerable:true,get:function(){return renderer.renderToStream}});exports.A=xe;exports.BR=Pe;exports.Blockquote=Re;exports.Center=le;exports.Col1=Ee;exports.Col10=Xe;exports.Col11=Ge;exports.Col12=_e;exports.Col2=Qe;exports.Col3=Me;exports.Col4=ze;exports.Col5=Ue;exports.Col6=qe;exports.Col7=Ne;exports.Col8=$e;exports.Col9=We;exports.Container=De;exports.Div=Ae;exports.Em=ye;exports.H1=de;exports.H2=ge;exports.H3=pe;exports.H4=me;exports.H5=he;exports.H6=fe;exports.HR=Te;exports.Header=Fe;exports.Img=ie;exports.ImgBg=lt;exports.LI=it;exports.LayoutPDF=ne;exports.Left=ae;exports.Mark=be;exports.OL=nt;exports.P=ce;exports.QR=Ke;exports.QRV2=et;exports.Right=se;exports.Row=He;exports.Small=Ce;exports.Span=Le;exports.Strong=ue;exports.Table=Oe;exports.Tbody=ve;exports.Td=ke;exports.Th=Be;exports.Thead=Ve;exports.Tr=Ie;exports.U=we;exports.UL=rt;exports.decodeBase64Pdf=X;exports.generatePDF=G;//# sourceMappingURL=index.cjs.map
4
4
  //# sourceMappingURL=index.cjs.map