
/**
 * 由 Fantastic-admin 提供技术支持
 * Powered by Fantastic-admin
 * https://fantastic-admin.hurui.me
 */
  
import{pn as e}from"./src-CLMBPGj1.js";import{t}from"./rolldown-runtime-Dy4uBu1J-DK3Fl9T5.js";import{t as n}from"./dom-to-png-BbPRUKX6-CWMLafQI.js";var r=e({n:()=>i,t:()=>m}),i=t({default:()=>m}),a=`[data-dom-to-png-ignore-layout]`;function o(){return new Promise(e=>{typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(e,0)})}function s(e){let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function c(e,t){let n=e.parentElement;for(;n&&n!==t;){if(n.matches(a))return!0;n=n.parentElement}return!1}function l(e){return Array.from(e.querySelectorAll(a)).filter(t=>!c(t,e))}function u(e){let t=e.getBoundingClientRect(),n=window.getComputedStyle(e);return n.display===`none`||n.position===`absolute`||n.position===`fixed`?0:t.height+s(n.marginTop)+s(n.marginBottom)}function d(e,t,n,r=``){e.style.setProperty(t,n,r)}function f(e,t){t===null?e.removeAttribute(`style`):e.setAttribute(`style`,t)}async function p(e,t){let n=l(e);if(!n.length)return t();let r=e.getAttribute(`style`),i=e.getBoundingClientRect().height,a=n.reduce((e,t)=>e+u(t),0),s=n.map(e=>({element:e,inlineStyle:e.getAttribute(`style`)}));s.forEach(({element:e})=>{d(e,`display`,`none`,`important`)}),await o();let c=e.getBoundingClientRect().height;if(a>0&&c>=i-.5){let t=Math.max(0,i-a);d(e,`height`,`${t}px`,`important`),d(e,`max-height`,`${t}px`,`important`),d(e,`overflow`,`hidden`,`important`),await o()}try{return await t()}finally{f(e,r),s.forEach(({element:e,inlineStyle:t})=>{f(e,t)})}}async function m({domElement:e,fileName:t,format:r=`png`,scale:i=2,base64:a=!1,img:o=!1}){if(!e)return Promise.reject(`No element provided`);let s=typeof navigator<`u`&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent);return await new Promise(e=>setTimeout(e,200)),p(e,async()=>{if(s)try{await n({container:e,scale:i}),await n({container:e,scale:i}),await n({container:e,scale:i}),await n({container:e,scale:i}),a&&(await n({container:e,scale:i,base64:a}),await n({container:e,scale:i,base64:a}),await n({container:e,scale:i,base64:a}),await n({container:e,scale:i,base64:a}))}catch{}if(a&&o)try{return{imageUri:await n({container:e,scale:i}).then(e=>e),base64:await n({container:e,scale:i,base64:a}).then(e=>e)}}catch(e){console.error(`Error generating image information for the chart`,e)}else if(a)try{return n({container:e,scale:i,base64:a}).then(e=>e)}catch(e){console.error(`Error generating the base64 string of the chart`,e)}else try{let a=await n({container:e,scale:i}),o=document.createElement(`a`);o.href=a,o.download=`${t}.${r}`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}catch(e){throw console.error(`Error generating image:`,e),e}})}export{r as n,m as t};