1import{Y as v,Z as $,_ as p}from"./vendor-C_-SYowt.js";async function D(w,c){const m=await v.load(w),f=m.getPage(0);if(m.getPageCount()!==1)throw new Error("O modelo de cancelamento deve conter uma página.");const l=await m.embedFont($.TimesRoman);function e(r,o,t,n,a,i=11){const d=r.normalize("NFC").replace(/\s+/g," ").trim();if(!d)return;let s;try{s=l.widthOfTextAtSize(d,i)}catch{throw new Error(`O campo ${a} contém caracteres não suportados pelo PDF. Revise o preenchimento.`)}const h=Math.min(i,i*(n-2)/s);if(h<7)throw new Error(`O campo ${a} é muito longo para o espaço do modelo. Abrevie o conteúdo.`);f.drawText(d,{x:o+1,y:f.getHeight()-t+2,size:h,font:l,color:p(0,0,0)})}function u(r,o,t){r.tipo&&e("X",r.tipo==="PF"?82.3:170.5,258+o,7.5,`tipo do ${t}`,7),e(r.cpf_cnpj,347,258+o,180,`CPF/CNPJ do ${t}`),e(r.nome,83,278.64+o,448,`nome do ${t}`),e(r.email,88,299.4+o,180,`e-mail do ${t}`);const n=r.fone.replace(/\D/g,"");if(n){const a=n.length>=2?n.slice(0,2):n,i=n.length>=2?n.slice(2):"";a&&e(a,327,299.4+o,14,`DDD do ${t}`,10),i&&(i.length>=4?e(`${i.slice(0,-4)}-${i.slice(-4)}`,347,299.4+o,183,`telefone do ${t}`):e(i,347,299.4+o,183,`telefone do ${t}`))}}u(c.vendedor,0,"vendedor"),u(c.comprador,177,"comprador"),e(c.veiculo.placa.toUpperCase(),117,367.2,84,"placa"),e(c.veiculo.renavam,389,367.2,102,"Renavam"),e(c.adicionais.local,338,544.2,156,"municÃpio");const g=c.adicionais.data.trim();if(g){const r=/^(\d{2})\/(\d{2})\/(\d{4})$/.exec(g);if(!r)throw new Error("Informe a data no formato dd/mm/aaaa.");const[,o="",t="",n=""]=r,a=new Date(Number(n),Number(t)-1,Number(o));if(a.getFullYear()!==Number(n)||a.getMonth()!==Number(t)-1||a.getDate()!==Number(o))throw new Error("Informe uma data válida.");e(o,134,544.2,20,"dia"),e(t,162,544.2,19,"mês"),e(n,190,544.2,45,"ano")}return m.setTitle("Cancelamento de intenção e/ou comunicação de venda de veÃculo"),m.save()}export{D as gerarCancelamentoVendaPdf};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.