HTML to Image GM

HTML sanpshot to image with GM_xmlhttpRequest Support

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/415574-html-to-image-gm/code/HTML%20to%20Image%20GM.js?version=866717

// ==UserScript==
// @name         HTML to Image GM
// @description  try to take over the world!
// @grant        GM_xmlhttpRequest
// @connect      *
// ==/UserScript==

/*! For license information please see bundle.min.js.LICENSE.txt */
(()=>{var e={554:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.applyStyleWithOptions=void 0,t.applyStyleWithOptions=function(e,t){var n=e.style;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=t.width+"px"),t.height&&(n.height=t.height+"px");var r=t.style;return null!=r&&Object.keys(r).forEach((function(e){n[e]=r[e]})),e}},707:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.cloneNode=void 0;var i=n(815),u=n(502);function a(e){return r(this,void 0,void 0,(function(){var t;return o(this,(function(n){return e instanceof HTMLCanvasElement?"data:,"===(t=e.toDataURL())?[2,Promise.resolve(e.cloneNode(!1))]:[2,u.createImage(t)]:[2,Promise.resolve(e.cloneNode(!1))]}))}))}t.cloneNode=function e(t,n,c){return r(this,void 0,void 0,(function(){return o(this,(function(l){return c||!n||n(t)?[2,Promise.resolve(t).then(a).then((function(i){return function(t,n,i){return r(this,void 0,void 0,(function(){var r;return o(this,(function(o){return 0===(r=u.toArray(t.childNodes)).length?[2,Promise.resolve(n)]:[2,r.reduce((function(t,r){return t.then((function(){return e(r,i)})).then((function(e){e&&n.appendChild(e)}))}),Promise.resolve()).then((function(){return n}))]}))}))}(t,i,n)})).then((function(e){return function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return t instanceof Element?[2,Promise.resolve().then((function(){return function(e,t){var n=window.getComputedStyle(e),r=t.style;n.cssText?r.cssText=n.cssText:u.toArray(n).forEach((function(e){r.setProperty(e,n.getPropertyValue(e),n.getPropertyPriority(e))}))}(e,t)})).then((function(){return i.clonePseudoElements(e,t)})).then((function(){return function(e,t){e instanceof HTMLTextAreaElement&&(t.innerHTML=e.value),e instanceof HTMLInputElement&&t.setAttribute("value",e.value)}(e,t)})).then((function(){return t}))]:[2,t]}))}))}(t,e)}))]:[2,Promise.resolve(null)]}))}))}},815:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clonePseudoElements=void 0;var r,o=n(502);t.clonePseudoElements=function(e,t){[":before",":after"].forEach((function(n){return r.clonePseudoElement(e,t,n)}))},function(e){e.clonePseudoElement=function(e,t,n){var r=window.getComputedStyle(e,n),i=r.getPropertyValue("content");if(""!==i&&"none"!==i){var u=o.uuid();try{t.className=t.className+" "+u}catch(e){return}var a=document.createElement("style");a.appendChild(function(e,t,n){var r="."+e+":"+t,i=n.cssText?function(e){var t=e.getPropertyValue("content");return e.cssText+" content: "+t+";"}(n):function(e){return o.toArray(e).map((function(t){return t+": "+e.getPropertyValue(t)+(e.getPropertyPriority(t)?" !important":"")+";"})).join(" ")}(n);return document.createTextNode(r+"{"+i+"}")}(u,n,r)),t.appendChild(a)}}}(r||(r={}))},790:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createSvgDataURL=void 0;var r=n(502);t.createSvgDataURL=function(e,t,n){var o="http://www.w3.org/2000/svg",i=document.createElementNS(o,"svg"),u=document.createElementNS(o,"foreignObject");return i.setAttributeNS("","width",""+t),i.setAttributeNS("","height",""+n),u.setAttributeNS("","width","100%"),u.setAttributeNS("","height","100%"),u.setAttributeNS("","x","0"),u.setAttributeNS("","y","0"),u.setAttributeNS("","externalResourcesRequired","true"),i.appendChild(u),u.appendChild(e),r.svgToDataURL(i)}},928:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.embedImages=void 0;var i=n(505),u=n(120),a=n(502);t.embedImages=function e(t,n){return r(this,void 0,void 0,(function(){return o(this,(function(c){return t instanceof Element?[2,Promise.resolve(t).then((function(e){return function(e,t){return r(this,void 0,void 0,(function(){var n;return o(this,(function(r){return(n=e.style.getPropertyValue("background"))?[2,Promise.resolve(n).then((function(e){return u.embedResources(e,null,t)})).then((function(t){return e.style.setProperty("background",t,e.style.getPropertyPriority("background")),e}))]:[2,Promise.resolve(e)]}))}))}(e,n)})).then((function(e){return function(e,t){return e instanceof HTMLImageElement&&!a.isDataUrl(e.src)?Promise.resolve(e.src).then((function(e){return i.getBlobFromURL(e,t)})).then((function(t){return a.toDataURL(t,a.getMimeType(e.src))})).then((function(t){return new Promise((function(n,r){e.onload=n,e.onerror=r,e.src=t}))})).then((function(){return e}),(function(){return e})):Promise.resolve(e)}(e,n)})).then((function(t){return function(t,n){return r(this,void 0,void 0,(function(){var r,i;return o(this,(function(o){return r=a.toArray(t.childNodes),i=r.map((function(t){return e(t,n)})),[2,Promise.all(i).then((function(){return t}))]}))}))}(t,n)}))]:[2,Promise.resolve(t)]}))}))}},120:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.embed=t.parseURLs=t.embedResources=t.shouldEmbed=void 0;var r=n(505),o=n(502),i=/url\((['"]?)([^'"]+?)\1\)/g;function u(e){return-1!==e.search(i)}function a(e){var t=[];return e.replace(i,(function(e,n,r){return t.push(r),e})),t.filter((function(e){return!o.isDataUrl(e)}))}function c(e,t,n,i,u){var a=n?function(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;var n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}(t,n):t;return Promise.resolve(a).then((function(e){return u?u(e):r.getBlobFromURL(e,i)})).then((function(e){return o.toDataURL(e,o.getMimeType(t))})).then((function(n){return e.replace(new RegExp("(url\\(['\"]?)("+(t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")+")(['\"]?\\))"),"g"),"$1"+n+"$3")})).then((function(e){return e}),(function(){return a}))}t.shouldEmbed=u,t.embedResources=function(e,t,n){return u(e)?Promise.resolve(e).then(a).then((function(r){return r.reduce((function(e,r){return e.then((function(e){return c(e,r,t,n)}))}),Promise.resolve(e))})):Promise.resolve(e)},t.parseURLs=a,t.embed=c},882:function(e,t,n){"use strict";var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.getCssRules=t.embedWebFonts=t.parseWebFontRules=void 0;var i=n(502),u=n(120);function a(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,new Promise((function(t,n){e.ownerDocument||n(new Error("Provided element is not within a Document")),t(i.toArray(e.ownerDocument.styleSheets))})).then(c).then(l)]}))}))}function c(e){return r(this,void 0,void 0,(function(){var t,n;return o(this,(function(r){return t=[],n=[],e.forEach((function(t){if("cssRules"in t)try{i.toArray(t.cssRules).forEach((function(e){e.type===CSSRule.IMPORT_RULE&&n.push(f(e.href).then(h).then((function(e){s(e).forEach((function(e){t.insertRule(e,t.cssRules.length)}))})).catch((function(e){console.log("Error loading remote css",e.toString())})))}))}catch(o){var r=e.find((function(e){return null===e.href}))||document.styleSheets[0];null!=t.href&&n.push(f(t.href).then(h).then((function(e){s(e).forEach((function(e){r.insertRule(e,t.cssRules.length)}))})).catch((function(e){console.log("Error loading remote stylesheet",e.toString())}))),console.log("Error inlining remote css file",o.toString())}})),[2,Promise.all(n).then((function(){return e.forEach((function(e){if("cssRules"in e)try{i.toArray(e.cssRules).forEach((function(e){t.push(e)}))}catch(t){console.log("Error while reading CSS rules from "+e.href,t.toString())}})),t}))]}))}))}function l(e){return e.filter((function(e){return e.type===CSSRule.FONT_FACE_RULE})).filter((function(e){return u.shouldEmbed(e.style.getPropertyValue("src"))}))}function s(e){if(void 0===e)return[];var t=e,n=[],r=new RegExp("(\\/\\*[\\s\\S]*?\\*\\/)","gi");t=t.replace(r,"");for(var o,i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");null!==(o=i.exec(t));)n.push(o[0]);t=t.replace(i,"");for(var u=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");null!==(o=u.exec(t));)n.push(o[0]);return n}function f(e,t){return window.GM_xmlhttpRequest?new Promise((function(t){return window.GM_xmlhttpRequest({url:e,onload:function(n){return t({url:e,cssText:n.responseText})},onerror:function(e){return console.warn("ERROR FETCHING CSS: ",e.toString())}})})):fetch(e).then((function(t){return{url:e,cssText:t.text()}}),(function(e){console.warn("ERROR FETCHING CSS: ",e.toString())}))}function h(e){return r(this,void 0,void 0,(function(){return o(this,(function(t){return[2,e.cssText.then((function(t){var n=t,r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map((function(t){var o=t.replace(r,"$1");if(!o.startsWith("https://")){var i=e.url;o=new URL(o,i).href}return new Promise((function(e,r){fetch(o).then((function(e){return e.blob()})).then((function(r){var o=new FileReader;o.addEventListener("load",(function(r){n=n.replace(t,"url("+o.result+")"),e([t,o.result])})),o.readAsDataURL(r)})).catch(r)}))}));return Promise.all(o).then((function(){return n}))}))]}))}))}t.parseWebFontRules=a,t.embedWebFonts=function(e,t){return r(this,void 0,void 0,(function(){return o(this,(function(n){return[2,a(e).then((function(e){return Promise.all(e.map((function(e){var n=e.parentStyleSheet?e.parentStyleSheet.href:null;return u.embedResources(e.cssText,n,t)})))})).then((function(e){return e.join("\n")})).then((function(t){var n=document.createElement("style"),r=document.createTextNode(t);return n.appendChild(r),e.firstChild?e.insertBefore(n,e.firstChild):e.appendChild(n),e}))]}))}))},t.getCssRules=c},505:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getBlobFromURL=void 0;var r=n(502),o=[];t.getBlobFromURL=function(e,t){var n=e.split("?")[0],i=o.find((function(e){return e.url===n}));if(i)return i.promise;t.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+(new Date).getTime());var u=(window.GM_xmlhttpRequest?new Promise((function(t,n){window.GM_xmlhttpRequest({url:e,method:"GET",timeout:3e4,responseType:"blob",ontimeout:function(){n(new Error("Timeout of 30000ms occured while fetching resource: "+e))},onload:function(o){if(4===o.readyState)if(200===o.status){var i=new FileReader;i.onloadend=function(){t(r.getDataURLContent(i.result))},i.readAsDataURL(o.response)}else n(new Error("Failed to fetch resource: "+e+", status: "+o.status))}})})):window.fetch?window.fetch(e).then((function(e){return e.blob()})).then((function(e){return new Promise((function(t,n){var r=new FileReader;r.onloadend=function(){return t(r.result)},r.onerror=n,r.readAsDataURL(e)}))})).then(r.getDataURLContent).catch((function(){return new Promise((function(e,t){return t()}))})):new Promise((function(t,n){var o=new XMLHttpRequest;o.onreadystatechange=function(){if(4===o.readyState)if(200===o.status){var i=new FileReader;i.onloadend=function(){t(r.getDataURLContent(i.result))},i.readAsDataURL(o.response)}else n(new Error("Failed to fetch resource: "+e+", status: "+o.status))},o.ontimeout=function(){n(new Error("Timeout of 30000ms occured while fetching resource: "+e))},o.responseType="blob",o.timeout=3e4,o.open("GET",e,!0),o.send()}))).catch((function(n){var r="";if(t.imagePlaceholder){var o=t.imagePlaceholder.split(/,/);o&&o[1]&&(r=o[1])}var i="Failed to fetch resource: "+e;return n&&(i="string"==typeof n?n:n.message),i&&console.error(i),r}));return o.push({promise:u,url:n}),u}},8:(e,t,n)=>{var r,o;void 0===(o="function"==typeof(r=function(){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.toBlob=t.toJpeg=t.toPng=t.toPixelData=t.toCanvas=t.toSvgDataURL=t.toSvg=void 0;var e=n(655),r=n(707),o=n(928),i=n(882),u=n(790),a=n(554),c=n(502);function l(t,n){void 0===n&&(n={});var r=c.getNodeDimension(t),o=r.width,i=r.height;return e.__assign({width:o,height:i},n)}function s(t,n){return void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){var c,s,f;return e.__generator(this,(function(e){return c=l(t,n),s=c.width,f=c.height,[2,r.cloneNode(t,n.filter,!0).then((function(e){return i.embedWebFonts(e,n)})).then((function(e){return o.embedImages(e,n)})).then((function(e){return a.applyStyleWithOptions(e,n)})).then((function(e){return u.createSvgDataURL(e,s,f)}))]}))}))}function f(t,n){return void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,s(t,n).then(c.createImage).then(c.delay(100)).then((function(e){var r=document.createElement("canvas"),o=r.getContext("2d"),i=n.pixelRatio||c.getPixelRatio(),u=l(t,n),a=u.width,s=u.height;return r.width=a*i,r.height=s*i,r.style.width=""+a,r.style.height=""+s,n.backgroundColor&&(o.fillStyle=n.backgroundColor,o.fillRect(0,0,r.width,r.height)),o.drawImage(e,0,0),r}))]}))}))}t.toSvg=s,t.toSvgDataURL=s,t.toCanvas=f,t.toPixelData=function(t,n){return void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){var r,o,i;return e.__generator(this,(function(e){return r=l(t,n),o=r.width,i=r.height,[2,f(t,n).then((function(e){return e.getContext("2d").getImageData(0,0,o,i).data}))]}))}))},t.toPng=function(t,n){return void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,f(t,n).then((function(e){return e.toDataURL()}))]}))}))},t.toJpeg=function(t,n){return void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,f(t,n).then((function(e){return e.toDataURL("image/jpeg",n.quality||1)}))]}))}))},t.toBlob=function(t,n){return void 0===n&&(n={}),e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,f(t,n).then(c.canvasToBlob)]}))}))}})?r.call(t,n,t,e):r)||(e.exports=o)},502:function(e,t){"use strict";var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.getBlobFromImageURL=t.svgToBlobURL=t.svgToDataURL=t.createImage=t.getPixelRatio=t.getNodeDimension=t.getNodeHeight=t.getNodeWidth=t.toArray=t.canvasToBlob=t.getDataURLContent=t.toDataURL=t.isBlobUrl=t.isDataUrl=t.delay=t.getMimeType=t.getExtension=t.uuid=void 0;var o,i="application/font-woff",u="image/jpeg",a={woff:i,woff2:i,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:u,jpeg:u,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function c(e){var t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function l(e){var t=c(e).toLowerCase();return a[t]||""}function s(e){return e.split(/,/)[1]}function f(e,t){var n=window.getComputedStyle(e).getPropertyValue(t);return parseFloat(n.replace("px",""))}function h(){return window.devicePixelRatio||1}function d(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){return t(r)},r.onerror=n,r.crossOrigin="anonymous",r.src=e}))}t.uuid=(o=0,function(){return o+=1,"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+o}),t.getExtension=c,t.getMimeType=l,t.delay=function(e){return function(t){return new Promise((function(n){setTimeout((function(){n(t)}),e)}))}},t.isDataUrl=function(e){return/^data:/.test(e)},t.isBlobUrl=function(e){return/^blob:/.test(e)},t.toDataURL=function(e,t){return"data:"+t+";base64,"+e},t.getDataURLContent=s,t.canvasToBlob=function(e){return e.toBlob?new Promise((function(t){return e.toBlob(t)})):function(e){return new Promise((function(t){for(var n=window.atob(e.toDataURL().split(",")[1]),r=n.length,o=new Uint8Array(r),i=0;i<r;i+=1)o[i]=n.charCodeAt(i);t(new Blob([o],{type:"image/png"}))}))}(e)},t.toArray=function(e){for(var t=[],n=0,r=e.length;n<r;n+=1)t.push(e[n]);return t},t.getNodeWidth=function(e){var t=f(e,"border-left-width"),n=f(e,"border-right-width");return e.scrollWidth+t+n},t.getNodeHeight=function(e){var t=f(e,"border-top-width"),n=f(e,"border-bottom-width");return e.scrollHeight+t+n},t.getNodeDimension=function(e){var t=f(e,"border-top-width"),n=f(e,"border-right-width"),r=f(e,"border-bottom-width"),o=f(e,"border-left-width"),i=e.getBoundingClientRect();return{width:o+i.width+n,height:t+i.height+r}},t.getPixelRatio=h,t.createImage=d,t.svgToDataURL=function(e){return n(this,void 0,void 0,(function(){return r(this,(function(t){return[2,Promise.resolve().then((function(){return(new XMLSerializer).serializeToString(e)})).then(encodeURIComponent).then((function(e){return"data:image/svg+xml;charset=utf-8,"+e}))]}))}))},t.svgToBlobURL=function(e){return n(this,void 0,void 0,(function(){return r(this,(function(t){return[2,Promise.resolve().then((function(){return(new XMLSerializer).serializeToString(e)})).then((function(e){return new Blob([e],{type:"image/svg+xml"})})).then((function(e){return URL.createObjectURL(e)}))]}))}))},t.getBlobFromImageURL=function(e){return n(this,void 0,void 0,(function(){return r(this,(function(t){return[2,d(e).then((function(t){var n=t.width,r=t.height,o=document.createElement("canvas"),i=o.getContext("2d"),u=h();return o.width=n*u,o.height=r*u,o.style.width=""+n,o.style.height=""+r,i.scale(u,u),i.drawImage(t,0,0),s(o.toDataURL(l(e)))}))]}))}))}},655:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__extends:()=>o,__assign:()=>i,__rest:()=>u,__decorate:()=>a,__param:()=>c,__metadata:()=>l,__awaiter:()=>s,__generator:()=>f,__createBinding:()=>h,__exportStar:()=>d,__values:()=>p,__read:()=>v,__spread:()=>y,__spreadArrays:()=>g,__await:()=>m,__asyncGenerator:()=>b,__asyncDelegator:()=>w,__asyncValues:()=>_,__makeTemplateObject:()=>P,__importStar:()=>S,__importDefault:()=>x,__classPrivateFieldGet:()=>E,__classPrivateFieldSet:()=>T});var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function u(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function a(e,t,n,r){var o,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(u=(i<3?o(u):i>3?o(t,n,u):o(t,n))||u);return i>3&&u&&Object.defineProperty(t,n,u),u}function c(e,t){return function(n,r){t(n,r,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function s(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,a)}c((r=r.apply(e,t||[])).next())}))}function f(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=t.call(e,u)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}var h=Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]};function d(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||h(t,e,n)}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function v(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}function g(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],u=0,a=i.length;u<a;u++,o++)r[o]=i[u];return r}function m(e){return this instanceof m?(this.v=e,this):new m(e)}function b(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},u("next"),u("throw"),u("return"),r[Symbol.asyncIterator]=function(){return this},r;function u(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof m?Promise.resolve(n.value.v).then(c,l):s(i[0][2],n)}catch(e){s(i[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function s(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}}function w(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:m(e[r](t)),done:"return"===r}:o?o(t):t}:o}}function _(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=p(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,o,(t=e[n](t)).done,t.value)}))}}}function P(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var R=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function S(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&h(t,e,n);return R(t,e),t}function x(e){return e&&e.__esModule?e:{default:e}}function E(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function T(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}}},t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},window.htmlToImage=n(8)})();