UNPKG

dom-to-image-more

Version:

Generates an image from a DOM node using HTML5 canvas and SVG

3 lines 25.7 kB
/*! dom-to-image-more v3.10.2 2026-07-10 19:56:41 UTC */ (m=>{let g=(()=>{let e=0;return{escape:function(e){return e.replace(/([.*+?^${}()|[\]/\\])/g,"\\$1")},isDataUrl:function(e){return-1!==e.search(/^(data:)/)},canvasToBlob:function(t){return t.toBlob?new Promise(function(e){t.toBlob(e)}):(o=t,new Promise(function(e){var t=p(o.toDataURL().split(",")[1]),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);e(new Blob([r],{type:"image/png"}))}));var o},resolveUrl:function(e,t){var n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=(n.head.appendChild(r),n.createElement("a"));return Object.assign(o.style,y),n.body.appendChild(o),r.href=t,o.href=e,o.href},getAndEncode:function(e,t){return c(e,t,!0).then(s)},getResourceText:function(e,t,n){return c(e,t,n).then(a)},uid:function(){return"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+e++},asArray:function(e){return Array.from(e)},escapeXhtml:function(e){return e.replace(/%/g,"%25").replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(i){return"data:,"!==i?new Promise(function(t,n){let r=document.createElementNS(v,"svg"),o=new Image;w.impl.options.useCredentials&&(o.crossOrigin="use-credentials"),o.onload=function(){function e(){window&&window.requestAnimationFrame?window.requestAnimationFrame(function(){t(o)}):t(o)}r.remove(),"function"==typeof o.decode?o.decode().then(e,e):e()},o.onerror=e=>{r.remove();var t=String(i).split(",",1)[0],t=new Error("dom-to-image-more: failed to rasterize the generated image ("+t+", "+String(i).length+" bytes). The source may contain malformed markup, an unsupported element, or a tainted/cross-origin resource.");t.cause=e,n(t)},r.appendChild(o),Object.assign(r.style,y),o.src=i,document.body.appendChild(r)}):Promise.resolve()},width:function(e){var t,n,r=d(e,"width");return isNaN(r)?(t=f(e))?t.width:(t=d(e,"border-left-width"),n=d(e,"border-right-width"),e.scrollWidth+t+n):r},height:function(e){var t,n,r=d(e,"height");return isNaN(r)?(t=f(e))?t.height:(t=d(e,"border-top-width"),n=d(e,"border-bottom-width"),e.scrollHeight+t+n):r},getWindow:r,isElement:l,isElementHostForOpenShadowRoot:function(e){return l(e)&&null!==e.shadowRoot},isShadowRoot:n,isInShadowRoot:i,isHTMLElement:function(e){return t(e,"HTMLElement")},isHTMLCanvasElement:function(e){return t(e,"HTMLCanvasElement")},isHTMLInputElement:function(e){return t(e,"HTMLInputElement")},isHTMLImageElement:function(e){return t(e,"HTMLImageElement")},isHTMLLinkElement:function(e){return t(e,"HTMLLinkElement")},isHTMLScriptElement:function(e){return t(e,"HTMLScriptElement")},isHTMLStyleElement:function(e){return t(e,"HTMLStyleElement")},isHTMLTextAreaElement:function(e){return t(e,"HTMLTextAreaElement")},isShadowSlotElement:function(e){return i(e)&&t(e,"HTMLSlotElement")},isSVGElement:function(e){return t(e,"SVGElement")},isSVGImageElement:function(e){return t(e,"SVGImageElement")},isSVGSVGElement:function(e){return t(e,"SVGSVGElement")},isSVGRectElement:function(e){return t(e,"SVGRectElement")},isSVGUseElement:function(e){return t(e,"SVGUseElement")},isDimensionMissing:function(e){return isNaN(e)||e<=0},isInstanceOf:t};function r(e){e=e?e.ownerDocument:void 0;return(e?e.defaultView:void 0)||("undefined"!=typeof window?window:void 0)||(void 0!==m?m:void 0)||globalThis}function t(e,t){var n=r(e);return o(e,n,t)||o(e,n&&n.parent,t)}function o(e,t,n){try{var r=t&&t[n];return"function"==typeof r&&e instanceof r}catch(e){return!1}}function n(e){return t(e,"ShadowRoot")}function i(e){return null!=e&&void 0!==e.getRootNode&&n(e.getRootNode())}function l(e){return t(e,"Element")}function s(e){return null==e||""===e?"":"string"==typeof e?e:u(e,"readAsDataURL","")}function a(e){if(null==e||""===e)return null;if("string"!=typeof e)return u(e,"readAsText",null);{var r=e.indexOf(",");if(-1===r)return"";var o=e.slice(0,r),e=e.slice(r+1);if(!/;base64/i.test(o))return decodeURIComponent(e);let t=p(e),n="";for(let e=0;e<t.length;e+=1)n+="%"+("00"+t.charCodeAt(e).toString(16)).slice(-2);return decodeURIComponent(n)}}function u(n,r,o){return new Promise(function(t){let e=new FileReader;e.onloadend=function(){t(e.result)},e.onerror=function(){t(o)};try{e[r](n)}catch(e){t(o)}})}function c(u,c,t){let n=w.impl.urlCache.find(function(e){return e.url===u});if(n||(n={url:u,promise:null},w.impl.urlCache.push(n)),null===n.promise){let s=function(e){var t=w.impl.options.requestInterceptor;if("function"==typeof t)try{return t(u,{type:c,status:e})}catch(e){T("requestInterceptor threw:",e)}},a=function(e){return null!=e},e=s(void 0);if(a(e))return n.promise=Promise.resolve(e),n.promise;if(!1===t)return n.promise=Promise.resolve(null),n.promise;w.impl.options.cacheBust&&(u+=(/\?/.test(u)?"&":"?")+(new Date).getTime()),n.promise=new Promise(function(n){let o=new XMLHttpRequest;function i(e){l(e,!1),n(null)}function t(){r("Status:"+o.status+" while fetching resource: "+u)}function r(t){var e=s(o.status);a(e)?Promise.resolve(e).then(function(e){l(t,!0),n(e)},function(){T(t),i(t)}):(e=c===E.IMAGE||c===E.CSS_IMAGE?w.impl.options.imagePlaceholder:void 0)?(l(t,!0),n(e)):(T(t),i(t))}function l(e,t){var n=w.impl.options.onImageError;if("function"==typeof n)try{n({url:u,message:e,status:o.status,willUsePlaceholder:t})}catch(e){T("onImageError handler threw:",e)}}if(o.timeout=w.impl.options.httpTimeout,o.onerror=t,o.ontimeout=t,o.onloadend=function(){var e;o.readyState===XMLHttpRequest.DONE&&(0===(e=o.status)&&u.toLowerCase().startsWith("file://")||200<=e&&e<=300&&null!==o.response?(e=o.response)instanceof Blob?n(e):r("Response was not a Blob (got "+typeof e+") while fetching resource: "+u):t())},0<w.impl.options.useCredentialsFilters.length&&(w.impl.options.useCredentials=0<w.impl.options.useCredentialsFilters.filter(e=>0<=u.search(e)).length),w.impl.options.useCredentials&&(o.withCredentials=!0),w.impl.options.corsImg&&0===u.indexOf("http")&&-1===u.indexOf(window.location.origin)){var e="POST"===(w.impl.options.corsImg.method||"GET").toUpperCase()?"POST":"GET";o.open(e,(w.impl.options.corsImg.url||"").replace("#{cors}",u),!0);let t=!1,n=w.impl.options.corsImg.headers||{},r=(Object.keys(n).forEach(function(e){-1!==n[e].indexOf("application/json")&&(t=!0),o.setRequestHeader(e,n[e])}),(e=>{try{return JSON.parse(JSON.stringify(e))}catch(e){T("corsImg.data is missing or invalid",e),i("corsImg.data is missing or invalid")}})(w.impl.options.corsImg.data||""));Object.keys(r).forEach(function(e){"string"==typeof r[e]&&(r[e]=r[e].replace("#{cors}",u))}),o.responseType="blob",o.send(t?JSON.stringify(r):r)}else o.open("GET",u,!0),o.responseType="blob",o.send()})}return n.promise}function f(e){if(e.nodeType!==b||"function"!=typeof e.getBBox)return null;try{var t=e.getBBox();return t&&(t.width||t.height)?t:null}catch(e){return null}}function d(t,n){if(t.nodeType===b){let e=S(t).getPropertyValue(n);if("px"===e.slice(-2))return e=e.slice(0,-2),parseFloat(e)}return NaN}})(),c=(()=>{let r=/url\(\s*(["']?)((?:\\.|[^\\)])+)\1\s*\)/gm;return{inlineAll:function(t,r,o,i){return e(t)?Promise.resolve(t).then(n).then(function(e){return w.impl.options.filterUrls?e.filter(function(e){return w.impl.options.filterUrls(e,r)}):e}).then(function(e){let n=Promise.resolve(t);return e.forEach(function(t){n=n.then(function(e){return s(e,t,r,o,i)})}),n}):Promise.resolve(t)},shouldProcess:e,impl:{readUrls:n,inline:s,urlAsRegex:l}};function e(e){return-1!==e.search(r)}function n(e){for(var t,n=[];null!==(t=r.exec(e));)n.push(t[2]);return n.filter(function(e){return!g.isDataUrl(e)})}function l(e){return new RegExp(`url\\((["']?)(${g.escape(e)})\\1\\)`,"gm")}function s(n,r,t,o,i){return Promise.resolve(r).then(function(e){return t?g.resolveUrl(e,t):e}).then(function(e){return(i||g.getAndEncode)(e,o)}).then(function(e){var t=l(r);return n.replace(t,`url($1${e}$1)`)})}})(),e={resolveAll:function(){return t().then(function(e){return Promise.all(e.map(function(e){return e.resolve()}))}).then(function(e){return e.join("\n")})},impl:{readAll:t}};function t(){return Promise.resolve(g.asArray(document.styleSheets)).then(function(e){let r="function"==typeof w.impl.options.requestInterceptor,o={};return Promise.all(e.map(function(t){let n=t.href;if(!n||o[n])return t;o[n]=!0;var e=(e=>{try{return!e.cssRules}catch(e){return!0}})(t)&&(e=>{var t=w.impl.options.loadExternalStyleSheet;if("function"==typeof t)try{return!0===t(e)}catch(e){return T("domtoimage: loadExternalStyleSheet predicate threw:",e),!1}return!0===t})(n);return r||e?g.getResourceText(n,E.STYLESHEET,e).then(function(e){return e&&((e,t)=>{try{var n=document.implementation.createHTMLDocument(""),r=n.createElement("style");return r.appendChild(document.createTextNode((o=t,e.replace(/url\((['"]?)([^'")]+)\1\)/g,function(e,t,n){n=n.trim();return g.isDataUrl(n)||/^[a-z][a-z0-9+.-]*:/i.test(n)?e:`url(${t}${g.resolveUrl(n,o)}${t})`})))),n.body.appendChild(r),r.sheet}catch(e){return null}var o})(e,n)||t}):t}))}).then(function(e){let n=[];return e.forEach(function(t){var e=Object.getPrototypeOf(t);if(Object.prototype.hasOwnProperty.call(e,"cssRules"))try{g.asArray(t.cssRules||[]).forEach(n.push.bind(n))}catch(e){w.impl.options.ignoreCSSRuleErrors||T("domtoimage: Error while reading CSS rules from: "+t.href,e)}}),n}).then(function(e){return e.filter(function(e){return e.type===CSSRule.FONT_FACE_RULE}).filter(function(e){return c.shouldProcess(e.style.getPropertyValue("src"))})}).then(function(e){return e.map(t)});function t(t){return{resolve:function(){var e=(t.parentStyleSheet||{}).href;return c.inlineAll(t.cssText,e,E.FONT)},src:function(){return t.style.getPropertyValue("src")}}}}let n={inlineAll:function n(r){return g.isElement(r)?((o=r).style?(e=["background","background-image","mask","mask-image","-webkit-mask","-webkit-mask-image"].map(function(t){let e=o.style.getPropertyValue(t),n=o.style.getPropertyPriority(t);return e?c.inlineAll(e,void 0,E.CSS_IMAGE).then(function(e){o.style.setProperty(t,e,n)}):Promise.resolve()}),Promise.all(e).then(function(){return o})):Promise.resolve(o)).then(function(){return g.isHTMLImageElement(r)?i(r).inline():g.isSVGImageElement(r)?!(e=(t=r).getAttribute("href")||t.getAttributeNS(f,"href")||t.getAttribute("xlink:href"))||g.isDataUrl(e)?Promise.resolve(t):Promise.resolve(e).then(function(e){return(0,g.getAndEncode)(e,E.IMAGE)}).then(function(e){return e&&(t.setAttributeNS(f,"xlink:href",e),t.setAttribute("href",e)),t}):Promise.all(g.asArray(r.childNodes).map(n));var t,e}):Promise.resolve(r);var o,e},impl:{newImage:i}};function i(n){return{inline:function(t){return g.isDataUrl(n.src)?Promise.resolve():Promise.resolve(n.src).then(function(e){return(t||g.getAndEncode)(e,E.IMAGE)}).then(function(t){return new Promise(function(e){n.onload=e,n.onerror=e,n.src=t})})}}}let y={position:"fixed",left:"-9999px",visibility:"hidden"},v="http://www.w3.org/2000/svg",f="http://www.w3.org/1999/xlink",d="data:image/svg+xml;charset=utf-8,",r={warn:function(...e){console.warn(...e)},error:function(...e){console.error(...e)}},o={copyDefaultStyles:!0,imagePlaceholder:void 0,cacheBust:!1,useCredentials:!1,useCredentialsFilters:[],httpTimeout:3e4,styleCaching:"strict",corsImg:void 0,adjustClonedNode:void 0,filterStyles:void 0,filterUrls:void 0,adjustPseudoElement:void 0,onImageError:void 0,ensureShown:!1,pixelRatio:1,preserveScroll:!1,ignoreCSSRuleErrors:!1,requestInterceptor:void 0,loadExternalStyleSheet:!1,logger:r},E=Object.freeze({IMAGE:"image",CSS_IMAGE:"css-image",FONT:"font",STYLESHEET:"stylesheet"}),w={toSvg:a,toPng:function(e,t){return u(e,t).then(function(e){return e.toDataURL()})},toJpeg:function(e,t){return u(e,t).then(function(e){return e.toDataURL("image/jpeg",(t?t.quality:void 0)||1)})},toBlob:function(e,t){return u(e,t).then(g.canvasToBlob)},toPixelData:function(t,e){return u(t,e).then(function(e){return e.getContext("2d").getImageData(0,0,g.width(t),g.height(t)).data})},toCanvas:u,ResourceType:E,impl:{fontFaces:e,images:n,util:g,inliner:c,urlCache:[],options:{},copyOptions:function(t){Object.keys(o).forEach(function(e){w.impl.options[e]=(void 0===t[e]?o:t)[e]})},resetUrlCache:h}};function h(){w.impl.urlCache=[]}"object"==typeof exports&&"object"==typeof module?module.exports=w:m.domtoimage=w;let b=("undefined"!=typeof Node?Node.ELEMENT_NODE:void 0)||1,S=l("getComputedStyle"),p=l("atob");function l(e){return(void 0!==m?m[e]:void 0)||("undefined"!=typeof window?window[e]:void 0)||globalThis[e]}function P(...e){s("warn",e)}function T(...e){s("error",e)}function s(e,t){var n=w.impl.options.logger||r,e=n[e];"function"==typeof e&&e.apply(n,t)}function a(l,s){let i=w.impl.util.getWindow(l),o=(s=s||{},w.impl.copyOptions(s),[]);return C=[],i&&i.document?(()=>{var e=i.document;if(!e.fonts||!e.fonts.ready)return Promise.resolve();let t=w.impl.options.httpTimeout||3e4,n,r=Promise.resolve(e.fonts.ready).then(function(){return!1},function(){return!1}),o=new Promise(function(e){n=i.setTimeout(function(){e(!0)},t)});return Promise.race([r,o]).then(function(e){i.clearTimeout(n),e&&P("dom-to-image-more: timed out after "+t+"ms waiting for document fonts to finish loading (document.fonts.ready); rendering anyway — the output may have missing glyphs or fallback-font metrics.")})})().then(function(){var e=l;if(e.nodeType===b)return e;var t,n=e,r=e.parentNode;if(r)return t=document.createElement("span"),r.replaceChild(t,n),t.append(e),o.push({parent:r,child:n,wrapper:t}),t;throw new Error("Cannot render a non-element node that is not attached to a parent; wrap it in an element or attach it to the document first.")}).then(function(e){return function i(t,h,p,l){var e=h.filter;return t===A||g.isHTMLScriptElement(t)||g.isHTMLStyleElement(t)||g.isHTMLLinkElement(t)||null!==p&&e&&!e(t)?Promise.resolve():Promise.resolve(t).then(function(e){return g.isHTMLCanvasElement(e)?g.makeImage(e.toDataURL()):e.cloneNode(!1)}).then(function(e){return h.adjustClonedNode&&h.adjustClonedNode(t,e,!1),Promise.resolve(e)}).then(function(r){{var o=r,r=(r=t,g.isElementHostForOpenShadowRoot(r)?r.shadowRoot:r);let e=(e=>{if(g.isShadowSlotElement(e)){var t=e.assignedNodes();if(t&&0<t.length)return t}return e.childNodes})(r),n=Promise.resolve();if(0!==e.length){let t=S((r=r,g.isShadowRoot(r)?r.host:r));g.asArray(e).forEach(function(e){n=n.then(function(){return i(e,h,t,l).then(function(e){e&&o.appendChild(e)})})})}return n.then(function(){return o})}}).then(function(e){return h.adjustClonedNode&&h.adjustClonedNode(t,e,!0),Promise.resolve(e)}).then(function(e){return d=e,m=t,!g.isElement(d)||g.isShadowSlotElement(m)?Promise.resolve(d):Promise.resolve().then(function(){if(g.isHTMLImageElement(m)&&"function"==typeof m.decode&&!(m.complete&&0<m.naturalWidth))return m.decode().catch(function(){})}).then(function(){if(d.style){var e=m,t=d,r,l,n=S(e);if(n.cssText)t.style.cssText=n.cssText,(f=t.style).font=(o=n).font,f.fontFamily=o.fontFamily,f.fontFeatureSettings=o.fontFeatureSettings,f.fontKerning=o.fontKerning,f.fontSize=o.fontSize,f.fontStretch=o.fontStretch,f.fontStyle=o.fontStyle,f.fontVariant=o.fontVariant,f.fontVariantCaps=o.fontVariantCaps,f.fontVariantEastAsian=o.fontVariantEastAsian,f.fontVariantLigatures=o.fontVariantLigatures,f.fontVariantNumeric=o.fontVariantNumeric,f.fontVariationSettings=o.fontVariationSettings,f.fontWeight=o.fontWeight;else{{var s=h,a=e,u=n,c=p,f=t;let o=w.impl.options.copyDefaultStyles?((e,t)=>{var n,r=(e=>{var t=[];do{if(e.nodeType===b){var n=e.tagName;if(t.push(n),O.includes(n))break}}while(e=e.parentNode);return t})(t),e=("relaxed"!==e.styleCaching?r:r.filter((e,t,n)=>0===t||t===n.length-1)).join(">")+((n=t)&&n.hasAttribute?R.filter(function(e){return n.hasAttribute(e)}).map(function(e){return`[${e}]`}).join(""):"");if(N[e])return N[e];var o,i=r=((e,t)=>{let n=e.body;do{var r=t.pop(),r=e.createElement(r)}while(n.appendChild(r),n=r,0<t.length);return n.textContent="​",n})((o=(()=>{if(A)return A.contentWindow;t=document.characterSet||"UTF-8",e=(e=document.doctype)?(`<!DOCTYPE ${s(e.name)} ${s(e.publicId)} `+s(e.systemId)).trim()+">":"",(A=document.createElement("iframe")).id="domtoimage-sandbox-"+g.uid(),Object.assign(A.style,y),document.body.appendChild(A);var e,t,n=A,r="domtoimage-sandbox";try{return n.contentWindow.document.write(e+`<html><head><meta charset='${t}'><title>${r}</title></head><body></body></html>`),n.contentWindow}catch(e){}var o=document.createElement("meta");o.setAttribute("charset",t);try{var i=document.implementation.createHTMLDocument(r),l=(i.head.appendChild(o),e+i.documentElement.outerHTML);return n.setAttribute("srcdoc",l),n.contentWindow}catch(e){}return n.contentDocument.head.appendChild(o),n.contentDocument.title=r,n.contentWindow;function s(e){var t;return e?((t=document.createElement("div")).innerText=e,t.innerHTML):""}})()).document,r),l=t,s=(l&&l.hasAttribute&&R.forEach(function(e){l.hasAttribute(e)&&i.setAttribute(e,l.getAttribute(e))}),t=((e,t)=>{let n={},r=e.getComputedStyle(t),o=(g.asArray(r).forEach(function(e){n[e]="width"===e||"height"===e?"auto":r.getPropertyValue(e)}),t.parentElement),i;return o&&(i=e.getComputedStyle(o).getPropertyValue("font-size"),n[L]=n["font-size"]!==i),n})(o,r),r);do{var a=s.parentElement}while(null!==a&&a.removeChild(s),(s=a)&&"BODY"!==s.tagName);return N[e]=t})(s,a):{},i=f.style;g.asArray(u).forEach(function(e){var t,n,r;s.filterStyles&&!s.filterStyles(a,e)||(t=u.getPropertyValue(e),r=o[e],n=c?c.getPropertyValue(e):void 0,i.getPropertyValue(e))||(t!==r||c&&t!==n||"font-size"===e&&o[L])&&(r=u.getPropertyPriority(e),I(i,e,t,r))}),r=u,l=i,["top","right","bottom","left"].forEach(function(e){var t,n=`border-${e}-width`,e=r.getPropertyValue(`border-${e}-style`);e&&"none"!==e&&!l.getPropertyValue(n)&&(e=r.getPropertyValue(n))&&(t=r.getPropertyPriority(n),I(l,n,e,t))})}null===p&&(["inset-block","inset-block-start","inset-block-end"].forEach(e=>t.style.removeProperty(e)),["left","right","top","bottom"].forEach(e=>{t.style.getPropertyValue(e)&&t.style.setProperty(e,"0px")}))}o=S(m).getPropertyValue("visibility"),null===p?"visible"!==o&&d.style.setProperty("visibility","visible"):o===p.getPropertyValue("visibility")&&d.style.removeProperty("visibility")}var o}).then(function(){let a=g.uid();return Promise.all([":before",":after"].map(function(o){let i=S(m,o),l=i.getPropertyValue("content");if(""!==l&&"none"!==l){let t;if(h.adjustPseudoElement){var s=h.adjustPseudoElement(m,o,i);if(!1===s)return;s&&"object"==typeof s&&(t=s)}let e=d.getAttribute("class")||"",n=(d.setAttribute("class",e+" "+a),`.${a}:`+o),r=i.cssText?i.cssText+` content: ${l};`:g.asArray(i).map(function(e){return e+": "+i.getPropertyValue(e)+(i.getPropertyPriority(e)?" !important":"")}).join("; ")+";";return t&&(r+=Object.keys(t).map(function(e){return` ${e}: ${t[e]};`}).join("")),c.inlineAll(r,void 0,E.CSS_IMAGE).then(function(e){var t=document.createElement("style");t.appendChild(document.createTextNode(n+`{${e}}`)),d.appendChild(t)})}}))}).then(function(){g.isHTMLTextAreaElement(m)&&(d.innerHTML=m.value),g.isHTMLInputElement(m)&&d.setAttribute("value",m.value)}).then(function(){if(d.attributes&&d.removeAttribute){var t=[];for(let e=0;e<d.attributes.length;e+=1){var n=d.attributes[e].name;/["'=<>/\s]/.test(n)&&t.push(n)}t.forEach(function(e){d.removeAttribute(e)})}}).then(function(){if(h.preserveScroll&&d.style){var e=m.scrollLeft||0,t=m.scrollTop||0;if(0!==e||0!==t){d.style.overflow="hidden";let n=`translate(${-e}px, ${-t}px)`;g.asArray(d.children).forEach(function(e){var t;e.style&&(t=e.style.transform&&"none"!==e.style.transform?" "+e.style.transform:"",e.style.transform=n+t)})}}}).then(function(){if(g.isSVGElement(d)&&(d.setAttribute("xmlns",v),g.isSVGRectElement(d)&&["width","height"].forEach(function(e){var t=d.getAttribute(e);t&&d.style.setProperty(e,t)}),g.isSVGUseElement(d))){var e=m,n=e.getAttribute("href")||e.getAttributeNS(f,"href")||e.getAttribute("xlink:href");if(n&&"#"===n.charAt(0)){let t=n.slice(1);C.some(e=>e.id===t)||(n=e.ownerDocument.getElementById(t))&&((e=n.cloneNode(!0)).setAttribute("xmlns",v),C.push({id:t,node:e}))}}}).then(function(){var e;g.isElement(d)&&(()=>{var t=m.children||[];for(let e=0;e<t.length;e+=1)if("CAPTION"===t[e].tagName)return 1})()&&("table"!==(e=S(m).getPropertyValue("display"))&&"inline-table"!==e||(d.style.removeProperty("height"),d.style.removeProperty("block-size")))}).then(function(){g.isHTMLImageElement(d)&&(d.removeAttribute("loading"),m.srcset||m.sizes)&&(d.removeAttribute("srcset"),d.removeAttribute("sizes"),d.src=m.currentSrc||m.src)}).then(function(){return d});var d,m})}(e,s,null,i)}).then(function(e){if(0!==C.length){var o=document.createElementNS(v,"svg");o.setAttribute("xmlns",v),o.setAttribute("width","0"),o.setAttribute("height","0"),o.style.setProperty("position","absolute"),o.style.setProperty("width","0"),o.style.setProperty("height","0"),o.style.setProperty("overflow","hidden");let t=document.createElementNS(v,"defs"),n=(o.appendChild(t),new Set),r=(e.getAttribute("id")&&n.add(e.getAttribute("id")),e.querySelectorAll("[id]").forEach(function(e){n.add(e.getAttribute("id"))}),0);C.forEach(function(e){n.has(e.id)||(t.appendChild(e.node),r+=1)}),0<r&&e.insertBefore(o,e.firstChild)}return e}).then(s.disableEmbedFonts?Promise.resolve(l):x).then(s.disableInlineImages?Promise.resolve(l):M).then(function(e){e.style&&(e.style.margin="0"),s.bgcolor&&(e.style.backgroundColor=s.bgcolor),s.width&&(e.style.width=s.width+"px"),s.height&&(e.style.height=s.height+"px"),s.style&&Object.assign(e.style,s.style);let t=null;return"function"==typeof s.onclone&&(t=s.onclone(e)),Promise.resolve(t).then(function(){return e})}).then(function(n){if(g.isSVGElement(l)&&!g.isSVGSVGElement(l)){let e=n,t=u(e),r;try{r=l.getBBox()}catch(e){r={x:0,y:0,width:0,height:0}}finally{t()}e.removeAttribute("transform"),e.style.removeProperty("transform");let o=s.width||r.width,i=s.height||r.height;return Promise.resolve(e).then(function(e){return e.setAttribute("xmlns",v),(new XMLSerializer).serializeToString(e)}).then(a).then(g.escapeXhtml).then(function(e){var t=(g.isDimensionMissing(o)?"":` width="${o}"`)+(g.isDimensionMissing(i)?"":` height="${i}"`),n=`${r.x} ${r.y} ${r.width} `+r.height;return`<svg xmlns="${v}"${t} viewBox="${n}">${e}</svg>`}).then(function(e){return d+e})}{let e=u(n),r,o;try{r=s.width||g.width(l),o=s.height||g.height(l)}finally{e()}return Promise.resolve(n).then(function(e){return e.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),(new XMLSerializer).serializeToString(e)}).then(a).then(g.escapeXhtml).then(function(e){var t=(g.isDimensionMissing(r)?' width="100%"':` width="${r}"`)+(g.isDimensionMissing(o)?' height="100%"':` height="${o}"`),n=(g.isDimensionMissing(r)?"":` width="${r}"`)+(g.isDimensionMissing(o)?"":` height="${o}"`);return`<svg xmlns="${v}"${n}><foreignObject${t}>${e}</foreignObject></svg>`}).then(function(e){return d+e})}}).finally(function(){for(;0<o.length;){var e=o.pop();try{e.parent.replaceChild(e.child,e.wrapper)}catch(e){T("domtoimage: failed to restore wrapped node",e)}}h(),C=[],A&&(A.remove(),A=null),V&&clearTimeout(V),V=setTimeout(()=>{V=null,N={}},2e4)}):Promise.reject(new Error("dom-to-image-more: a browser DOM is required (SSR)"));function a(e){return e.replace(/url\(&quot;([^]*?)&quot;\)/g,function(e,t){return 0<=t.indexOf("'")?e:`url('${t}')`})}function u(t){function e(){}if(!s.ensureShown)return e;var n=S(l);if("0"===n.getPropertyValue("opacity")&&t.style.setProperty("opacity","1"),"none"!==n.getPropertyValue("display"))return e;let r=l.style.getPropertyValue("display"),o=l.style.getPropertyPriority("display");return l.style.removeProperty("display"),"none"===S(l).getPropertyValue("display")&&(n=r&&"none"!==r?r:"revert",l.style.setProperty("display",n,"important")),function(){var e=S(l).getPropertyValue("display");t.style.setProperty("display","none"===e?"block":e),r?l.style.setProperty("display",r,o):l.style.removeProperty("display")}}}function u(i,l){return a(i,l=l||{}).then(g.makeImage).then(function(e){var t=(e=>{let t=l.width||g.width(e),n=l.height||g.height(e);g.isDimensionMissing(t)&&(t=g.isDimensionMissing(n)?300:2*n),g.isDimensionMissing(n)&&(n=t/2);var r,e=("number"==typeof l.scale?l.scale:1)*("number"==typeof l.pixelRatio?l.pixelRatio:1),o=(o=t,i=n,e=e,!(0<o&&0<i&&0<e)||e<=(r=Math.min(16384/o,16384/i,Math.sqrt(268435456/(o*i))))?e:(P("dom-to-image-more: the requested "+Math.round(o*e)+"×"+Math.round(i*e)+" canvas exceeds the browser limit; clamping the effective scale from "+e+" to "+r+". Capture detail may be reduced — render a smaller region or lower scale/pixelRatio."),r)),i=document.createElement("canvas");return i.width=t*o,i.height=n*o,l.bgcolor&&((e=i.getContext("2d")).fillStyle=l.bgcolor,e.fillRect(0,0,i.width,i.height)),{canvas:i,scale:o,width:t,height:n}})(i),n=t.canvas,r=t.scale,o=n.getContext("2d");return o.msImageSmoothingEnabled=!1,o.imageSmoothingEnabled=!1,e&&(o.scale(r,r),o.drawImage(e,0,0,t.width,t.height)),n})}let A=null,C=[];function x(n){return e.resolveAll().then(function(e){var t;return""!==e&&(t=document.createElement("style"),n.appendChild(t),t.appendChild(document.createTextNode(e))),n})}function M(e){return n.inlineAll(e).then(function(){return e})}function I(e,t,n,r){var o=0<=["background-clip"].indexOf(t);r?(e.setProperty(t,n,r),o&&e.setProperty("-webkit-"+t,n,r)):(e.setProperty(t,n),o&&e.setProperty("-webkit-"+t,n))}let L=Symbol("dtim-ua-relative-font-size"),V=null,N={},O=["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIALOG","DD","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SVG","TABLE","UL","math","svg","BODY","HEAD","HTML"],R=["href"]})(this); //# sourceMappingURL=dom-to-image-more.min.js.map