const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-font-COqyuVvS.js","assets/rolldown-runtime-hePW80VL.js","assets/index-CKr-jwvi.js","assets/index-DZaZnuRK.css","assets/ui-CuDKrJrQ.js","assets/dist-Bco699Hu.js","assets/dist-Di5CwiBI.js","assets/browser-module-DP4DadQ8.js","assets/dist-BH0IIbFD.js","assets/purify.es-CYRiAeUx.js"])))=>i.map(i=>d[i]);
import{n as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./index-CKr-jwvi.js";var n=e({createTextPdf:()=>a,fontBytes:()=>i,pngToPdf:()=>o}),r;function i(){return r??=fetch(`/tools-assets/fonts/NotoSans-Regular.ttf`).then(async e=>{if(!e.ok)throw Error(`PDF font unavailable`);return new Uint8Array(await e.arrayBuffer())}).catch(e=>{throw r=void 0,e})}async function a(e,n,r=`A4`){let{assertPdfTextSupported:i}=await t(async()=>{let{assertPdfTextSupported:e}=await import(`./pdf-font-COqyuVvS.js`).then(e=>e.n);return{assertPdfTextSupported:e}},__vite__mapDeps([0,1,2,3,4]));await i(e.map(e=>e.text),n.fontBytes);let[{generate:a},{text:o}]=await Promise.all([t(()=>import(`./dist-Bco699Hu.js`),__vite__mapDeps([5,6,1,7,8,2,3,4,9])),t(()=>import(`./dist-BH0IIbFD.js`),__vite__mapDeps([8,1,2,3,6,4,7,9]))]),s=r===`Letter`?215.9:210,c=r===`Letter`?279.4:297,l=e.map((e,t)=>({name:`block${t}`,type:`text`,position:{x:16,y:16+t*14},width:s-32,height:10,fontName:`NotoSans`,fontSize:e.size??10,lineHeight:1.35,fontColor:e.color??`#171717`,alignment:`left`,verticalAlignment:`top`,overflow:`expand`,required:!1})),u=Object.fromEntries(e.map((e,t)=>[`block${t}`,e.text]));return a({template:{basePdf:{width:s,height:c,padding:[16,16,16,16]},schemas:[l]},inputs:[u],plugins:{text:o},options:{font:{NotoSans:{data:new Uint8Array(n.fontBytes),fallback:!0}}}})}async function o(e,n,r){if(!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0||n*r>2e7)throw Error(`Image dimensions are outside the export limit`);let{PDFDocument:i}=await t(async()=>{let{PDFDocument:e}=await import(`./dist-Di5CwiBI.js`);return{PDFDocument:e}},__vite__mapDeps([6,1])),a=await i.create(),o=await a.embedPng(e),s=a.addPage(n>r?[841.89,595.28]:[595.28,841.89]),c=Math.min((s.getWidth()-40)/n,(s.getHeight()-40)/r);return s.drawImage(o,{x:(s.getWidth()-n*c)/2,y:(s.getHeight()-r*c)/2,width:n*c,height:r*c}),a.save()}export{o as i,i as n,n as r,a as t};