12 |
- var X=(D,I,R)=>new Promise((H,c)=>{var U=b=>{try{B(R.next(b))}catch(g){c(g)}},M=b=>{try{B(R.throw(b))}catch(g){c(g)}},B=b=>b.done?H(b.value):Promise.resolve(b.value).then(U,M);B((R=R.apply(D,I)).next())});import{bX as ne,__tla as re}from"./index-b5895273.js";let $,oe=Promise.all([(()=>{try{return re}catch(D){}})()]).then(()=>X(void 0,null,function*(){var D={exports:{}};(function(R){(function(H){var c=Y(),U=Z(),M=ee(),B=te(),b={imagePlaceholder:void 0,cacheBust:!1},g={toSvg:N,toPng:O,toJpeg:q,toBlob:z,toPixelData:G,impl:{fontFaces:M,images:B,util:c,inliner:U,options:{}}};R.exports=g;function N(n,t){return t=t||{},J(t),Promise.resolve(n).then(function(i){return F(i,t.filter,!0)}).then(W).then(K).then(r).then(function(i){return Q(i,t.width||c.width(n),t.height||c.height(n))});function r(i){return t.bgcolor&&(i.style.backgroundColor=t.bgcolor),t.width&&(i.style.width=t.width+"px"),t.height&&(i.style.height=t.height+"px"),t.style&&Object.keys(t.style).forEach(function(s){i.style[s]=t.style[s]}),i}}function G(n,t){return V(n,t||{}).then(function(r){return r.getContext("2d").getImageData(0,0,c.width(n),c.height(n)).data})}function O(n,t){return V(n,t||{}).then(function(r){return r.toDataURL()})}function q(n,t){return t=t||{},V(n,t).then(function(r){return r.toDataURL("image/jpeg",t.quality||1)})}function z(n,t){return V(n,t||{}).then(c.canvasToBlob)}function J(n){typeof n.imagePlaceholder>"u"?g.impl.options.imagePlaceholder=b.imagePlaceholder:g.impl.options.imagePlaceholder=n.imagePlaceholder,typeof n.cacheBust>"u"?g.impl.options.cacheBust=b.cacheBust:g.impl.options.cacheBust=n.cacheBust}function V(n,t){return N(n,t).then(c.makeImage).then(c.delay(100)).then(function(i){var s=r(n);return s.getContext("2d").drawImage(i,0,0),s});function r(i){var s=document.createElement("canvas");if(s.width=t.width||c.width(i),s.height=t.height||c.height(i),t.bgcolor){var a=s.getContext("2d");a.fillStyle=t.bgcolor,a.fillRect(0,0,s.width,s.height)}return s}}function F(n,t,r){if(!r&&t&&!t(n))return Promise.resolve();return Promise.resolve(n).then(i).then(function(o){return s(n,o,t)}).then(function(o){return a(n,o)});function i(o){return o instanceof HTMLCanvasElement?c.makeImage(o.toDataURL()):o.cloneNode(!1)}function s(o,l,v){var A=o.childNodes;if(A.length===0)return Promise.resolve(l);return m(l,c.asArray(A),v).then(function(){return l});function m(L,y,p){var w=Promise.resolve();return y.forEach(function(C){w=w.then(function(){return F(C,p)}).then(function(P){P&&L.appendChild(P)})}),w}}function a(o,l){if(!(l instanceof Element))return l;return Promise.resolve().then(v).then(A).then(m).then(L).then(function(){return l});function v(){y(window.getComputedStyle(o),l.style);function y(p,w){p.cssText?w.cssText=p.cssText:C(p,w);function C(P,x){c.asArray(P).forEach(function(e){x.setProperty(e,P.getPropertyValue(e),P.getPropertyPriority(e))})}}}function A(){[":before",":after"].forEach(function(p){y(p)});function y(p){var w=window.getComputedStyle(o,p),C=w.getPropertyValue("content");if(C===""||C==="none")return;var P=c.uid();l.className=l.className+" "+P;var x=document.createElement("style");x.appendChild(e(P,p,w)),l.appendChild(x);function e(u,h,f){var d="."+u+":"+h,E=f.cssText?_(f):k(f);return document.createTextNode(d+"{"+E+"}");function _(T){var S=T.getPropertyValue("content");return T.cssText+" content: "+S+";"}function k(T){return c.asArray(T).map(S).join("; ")+";";function S(j){return j+": "+T.getPropertyValue(j)+(T.getPropertyPriority(j)?" !important":"")}}}}}function m(){o instanceof HTMLTextAreaElement&&(l.innerHTML=o.value),o instanceof HTMLInputElement&&l.setAttribute("value",o.value)}function L(){l instanceof SVGElement&&(l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l instanceof SVGRectElement&&["width","height"].forEach(function(y){var p=l.getAttribute(y);p&&l.style.setProperty(y,p)}))}}}function W(n){return M.resolveAll().then(function(t){var r=document.createElement("style");return n.appendChild(r),r.appendChild(document.createTextNode(t)),n})}function K(n){return B.inlineAll(n).then(function(){return n})}function Q(n,t,r){return Promise.resolve(n).then(function(i){return i.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),new XMLSerializer().serializeToString(i)}).then(c.escapeXhtml).then(function(i){return'<foreignObject x="0" y="0" width="100%" height="100%">'+i+"</foreignObject>"}).then(function(i){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+r+'">'+i+"</svg>"}).then(function(i){return"data:image/svg+xml;charset=utf-8,"+i})}function Y(){return{escape:L,parseExtension:t,mimeType:r,dataAsUrl:m,isDataUrl:i,canvasToBlob:a,resolveUrl:o,getAndEncode:A,uid:l(),delay:y,asArray:p,escapeXhtml:w,makeImage:v,width:C,height:P};function n(){var e="application/font-woff",u="image/jpeg";return{woff:e,woff2:e,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 t(e){var u=/\.([^\.\/]*?)$/g.exec(e);return u?u[1]:""}function r(e){var u=t(e).toLowerCase();return n()[u]||""}function i(e){return e.search(/^(data:)/)!==-1}function s(e){return new Promise(function(u){for(var h=window.atob(e.toDataURL().split(",")[1]),f=h.length,d=new Uint8Array(f),E=0;E<f;E++)d[E]=h.charCodeAt(E);u(new Blob([d],{type:"image/png"}))})}function a(e){return e.toBlob?new Promise(function(u){e.toBlob(u)}):s(e)}function o(e,u){var h=document.implementation.createHTMLDocument(),f=h.createElement("base");h.head.appendChild(f);var d=h.createElement("a");return h.body.appendChild(d),f.href=u,d.href=e,d.href}function l(){var e=0;return function(){return"u"+u()+e++;function u(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)}}}function v(e){return new Promise(function(u,h){var f=new Image;f.onload=function(){u(f)},f.onerror=h,f.src=e})}function A(e){var u=3e4;return g.impl.options.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime()),new Promise(function(h){var f=new XMLHttpRequest;f.onreadystatechange=_,f.ontimeout=k,f.responseType="blob",f.timeout=u,f.open("GET",e,!0),f.send();var d;if(g.impl.options.imagePlaceholder){var E=g.impl.options.imagePlaceholder.split(/,/);E&&E[1]&&(d=E[1])}function _(){if(f.readyState===4){if(f.status!==200){d?h(d):T("cannot fetch resource: "+e+", status: "+f.status);return}var S=new FileReader;S.onloadend=function(){var j=S.result.split(/,/)[1];h(j)},S.readAsDataURL(f.response)}}function k(){d?h(d):T("timeout of "+u+"ms occured while fetching resource: "+e)}function T(S){h("")}})}function m(e,u){return"data:"+u+";base64,"+e}function L(e){return e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")}function y(e){return function(u){return new Promise(function(h){setTimeout(function(){h(u)},e)})}}function p(e){for(var u=[],h=e.length,f=0;f<h;f++)u.push(e[f]);return u}function w(e){return e.replace(/#/g,"%23").replace(/\n/g,"%0A")}function C(e){var u=x(e,"border-left-width"),h=x(e,"border-right-width");return e.scrollWidth+u+h}function P(e){var u=x(e,"border-top-width"),h=x(e,"border-bottom-width");return e.scrollHeight+u+h}function x(e,u){var h=window.getComputedStyle(e).getPropertyValue(u);return parseFloat(h.replace("px",""))}}function Z(){var n=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:s,shouldProcess:t,impl:{readUrls:r,inline:i}};function t(a){return a.search(n)!==-1}function r(a){for(var o=[],l;(l=n.exec(a))!==null;)o.push(l[1]);return o.filter(function(v){return!c.isDataUrl(v)})}function i(a,o,l,v){return Promise.resolve(o).then(function(m){return l?c.resolveUrl(m,l):m}).then(v||c.getAndEncode).then(function(m){return c.dataAsUrl(m,c.mimeType(o))}).then(function(m){return a.replace(A(o),"$1"+m+"$3")});function A(m){return new RegExp(`(url\\(['"]?)(`+c.escape(m)+`)(['"]?\\))`,"g")}}function s(a,o,l){if(v())return Promise.resolve(a);return Promise.resolve(a).then(r).then(function(A){var m=Promise.resolve(a);return A.forEach(function(L){m=m.then(function(y){return i(y,L,o,l)})}),m});function v(){return!t(a)}}}function ee(){return{resolveAll:n,impl:{readAll:t}};function n(){return t().then(function(r){return Promise.all(r.map(function(i){return i.resolve()}))}).then(function(r){return r.join(`
- `)})}function t(){return Promise.resolve(c.asArray(document.styleSheets)).then(i).then(r).then(function(a){return a.map(s)});function r(a){return a.filter(function(o){return o.type===CSSRule.FONT_FACE_RULE}).filter(function(o){return U.shouldProcess(o.style.getPropertyValue("src"))})}function i(a){var o=[];return a.forEach(function(l){try{c.asArray(l.cssRules||[]).forEach(o.push.bind(o))}catch(v){}}),o}function s(a){return{resolve:function(){var o=(a.parentStyleSheet||{}).href;return U.inlineAll(a.cssText,o)},src:function(){return a.style.getPropertyValue("src")}}}}}function te(){return{inlineAll:t,impl:{newImage:n}};function n(r){return{inline:i};function i(s){return c.isDataUrl(r.src)?Promise.resolve():Promise.resolve(r.src).then(s||c.getAndEncode).then(function(a){return c.dataAsUrl(a,c.mimeType(r.src))}).then(function(a){return new Promise(function(o,l){r.onload=o,r.onerror=l,r.src=a})})}}function t(r){if(!(r instanceof Element))return Promise.resolve(r);return i(r).then(function(){return r instanceof HTMLImageElement?n(r).inline():Promise.all(c.asArray(r.childNodes).map(function(s){return t(s)}))});function i(s){var a=s.style.getPropertyValue("background");return a?U.inlineAll(a).then(function(o){s.style.setProperty("background",o,s.style.getPropertyPriority("background"))}).then(function(){return s}):Promise.resolve(s)}}}})()})(D);var I=D.exports;$=ne(I)}));export{oe as __tla,$ as d};
|