import{t as e}from"./preload-helper-DzyYoeor.js";import{r as t}from"./norm-f7iXVy-b.js";var n=()=>e(()=>import(`./es-WhhX7WCs.js`),[]),r=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)},i=()=>new Promise(e=>requestAnimationFrame(()=>e())),a=(e,t)=>{let n=Array.from(e.querySelectorAll(`canvas`)),r=Array.from(t.querySelectorAll(`canvas`)),i=Math.min(n.length,r.length);for(let e=0;e<i;e++){let t=n[e],i=r[e];try{i.width=t.width,i.height=t.height;let e=i.getContext(`2d`);e&&e.drawImage(t,0,0)}catch{}}},o=async e=>{let o=e.element,s=t(e.fileName)||`export.png`,c=o.getBoundingClientRect(),l=Math.max(10,Math.ceil(c.width)),u=document.createElement(`div`);u.style.position=`fixed`,u.style.left=`-100000px`,u.style.top=`0`,u.style.background=t(e.backgroundColor)||`#ffffff`,u.style.width=`${l}px`,u.style.padding=`0`,u.style.margin=`0`,u.style.overflow=`visible`,u.style.zIndex=`2147483647`;let d=o.cloneNode(!0);d.style.width=`${l}px`,d.style.maxWidth=`${l}px`,d.style.overflow=`visible`,d.style.maxHeight=`none`,u.appendChild(d),document.body.appendChild(u);try{await i(),await i(),a(o,d);let c=Math.max(10,Math.ceil(Number(d.scrollHeight||d.getBoundingClientRect().height||0)));u.style.height=`${c}px`,d.style.height=`${c}px`;let f=Number.isFinite(e.pixelRatio)?Number(e.pixelRatio):2,p=c>=14e3?Math.min(1.6,f):c>=9e3?Math.min(1.8,f):f,{toBlob:m}=await n(),h=await m(d,{cacheBust:!0,backgroundColor:t(e.backgroundColor)||`#ffffff`,pixelRatio:Math.max(1,Math.min(3,p)),width:l,height:c,filter:t=>{try{let n=t;return n?.dataset?.exportIgnore===`1`?!1:typeof e.filter==`function`?e.filter(n):!0}catch{return!0}}});if(!h)throw Error(`导出失败`);r(h,s)}finally{try{u.remove()}catch{}}};export{o as t};