Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

modern-screenshot

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modern-screenshot - npm Package Compare versions

Comparing version 4.4.37 to 4.4.38

8

dist/index.js

@@ -1,2 +0,2 @@

(function(h,C){typeof exports=="object"&&typeof module!="undefined"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(h=typeof globalThis!="undefined"?globalThis:h||self,C(h.modernScreenshot={}))})(this,function(h){var Ue;"use strict";var Kt=Object.defineProperty,Qt=Object.defineProperties;var Zt=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var Oe=Math.pow,Be=(h,C,T)=>C in h?Kt(h,C,{enumerable:!0,configurable:!0,writable:!0,value:T}):h[C]=T,x=(h,C)=>{for(var T in C||(C={}))Le.call(C,T)&&Be(h,T,C[T]);if(Z)for(var T of Z(C))Me.call(C,T)&&Be(h,T,C[T]);return h},L=(h,C)=>Qt(h,Zt(C));var We=(h,C)=>{var T={};for(var N in h)Le.call(h,N)&&C.indexOf(N)<0&&(T[N]=h[N]);if(h!=null&&Z)for(var N of Z(h))C.indexOf(N)<0&&Me.call(h,N)&&(T[N]=h[N]);return T};var E=(h,C,T)=>new Promise((N,M)=>{var H=D=>{try{W(T.next(D))}catch(j){M(j)}},O=D=>{try{W(T.throw(D))}catch(j){M(j)}},W=D=>D.done?N(D.value):Promise.resolve(D.value).then(H,O);W((T=T.apply(h,C)).next())});function C(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}const T="p".charCodeAt(0),N="H".charCodeAt(0),M="Y".charCodeAt(0),H="s".charCodeAt(0);let O;function W(){const e=new Int32Array(256);for(let t=0;t<256;t++){let r=t;for(let n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e}function D(e){let t=-1;O||(O=W());for(let r=0;r<e.length;r++)t=O[(t^e[r])&255]^t>>>8;return t^-1}function j(e){const t=e.length-1;for(let r=t;r>=4;r--)if(e[r-4]===9&&e[r-3]===T&&e[r-2]===N&&e[r-1]===M&&e[r]===H)return r-3;return 0}function ae(e,t,r=!1){const n=new Uint8Array(13);t*=39.3701,n[0]=T,n[1]=N,n[2]=M,n[3]=H,n[4]=t>>>24,n[5]=t>>>16,n[6]=t>>>8,n[7]=t&255,n[8]=n[4],n[9]=n[5],n[10]=n[6],n[11]=n[7],n[12]=1;const a=D(n),s=new Uint8Array(4);if(s[0]=a>>>24,s[1]=a>>>16,s[2]=a>>>8,s[3]=a&255,r){const o=j(e);return e.set(n,o),e.set(s,o+13),e}else{const o=new Uint8Array(4);o[0]=0,o[1]=0,o[2]=0,o[3]=9;const c=new Uint8Array(54);return c.set(e,0),c.set(o,33),c.set(n,37),c.set(s,50),c}}const je="AAlwSFlz",qe="AAAJcEhZ",Ve="AAAACXBI";function He(e){let t=e.indexOf(je);return t===-1&&(t=e.indexOf(qe)),t===-1&&(t=e.indexOf(Ve)),t}const ee="[modern-screenshot]",P=typeof window!="undefined",ze=P&&"Worker"in window,se=P&&"atob"in window,Xe=P&&"btoa"in window,te=P?(Ue=window.navigator)==null?void 0:Ue.userAgent:"",ie=te.includes("Chrome"),z=te.includes("AppleWebKit")&&!ie,re=te.includes("Firefox"),Ge=e=>e&&"__CONTEXT__"in e,Ye=e=>e.constructor.name==="CSSFontFaceRule",Je=e=>e.constructor.name==="CSSImportRule",k=e=>e.nodeType===1,q=e=>typeof e.className=="object",ce=e=>e.tagName==="image",Ke=e=>e.tagName==="use",ne=e=>k(e)&&typeof e.style!="undefined"&&!q(e),Qe=e=>e.nodeType===8,Ze=e=>e.nodeType===3,_=e=>e.tagName==="IMG",X=e=>e.tagName==="VIDEO",et=e=>e.tagName==="CANVAS",le=e=>e.tagName==="TEXTAREA",tt=e=>e.tagName==="INPUT",rt=e=>e.tagName==="STYLE",nt=e=>e.tagName==="SCRIPT",ot=e=>e.tagName==="SELECT",at=e=>e.tagName==="SLOT",st=e=>e.tagName==="IFRAME",v=(...e)=>console.warn(ee,...e),it=e=>console.time(`${ee} ${e}`),ct=e=>console.timeEnd(`${ee} ${e}`),lt=e=>{var r;const t=(r=e==null?void 0:e.createElement)==null?void 0:r.call(e,"canvas");return t&&(t.height=t.width=1),t&&"toDataURL"in t&&Boolean(t.toDataURL("image/webp").includes("image/webp"))},oe=e=>e.startsWith("data:");function ue(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(P&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!P)return e;const r=G().implementation.createHTMLDocument(),n=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(a),t&&(n.href=t),a.href=e,a.href}function G(e){var t;return(t=e&&k(e)?e==null?void 0:e.ownerDocument:e)!=null?t:window.document}const Y="http://www.w3.org/2000/svg";function fe(e,t,r){const n=G(r).createElementNS(Y,"svg");return n.setAttributeNS(null,"width",e.toString()),n.setAttributeNS(null,"height",t.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),n}function de(e,t){let r=new XMLSerializer().serializeToString(e);return t&&(r=r.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/ug,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}function ut(e,t="image/png",r=1){return E(this,null,function*(){try{return yield new Promise((n,a)=>{e.toBlob(s=>{s?n(s):a(new Error("Blob is null"))},t,r)})}catch(n){if(se)return v("Failed canvas to blob",{type:t,quality:r},n),ft(e.toDataURL(t,r));throw n}})}function ft(e){var c,l;const[t,r]=e.split(","),n=(l=(c=t.match(/data:(.+);/))==null?void 0:c[1])!=null?l:void 0,a=window.atob(r),s=a.length,o=new Uint8Array(s);for(let u=0;u<s;u+=1)o[u]=a.charCodeAt(u);return new Blob([o],{type:n})}function me(e,t){return new Promise((r,n)=>{const a=new FileReader;a.onload=()=>r(a.result),a.onerror=()=>n(a.error),a.onabort=()=>n(new Error(`Failed read blob to ${t}`)),t==="dataUrl"?a.readAsDataURL(e):t==="arrayBuffer"&&a.readAsArrayBuffer(e)})}const dt=e=>me(e,"dataUrl"),mt=e=>me(e,"arrayBuffer");function U(e,t){const r=G(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function $(e,t){return new Promise(r=>{const{timeout:n,ownerDocument:a,onError:s}=t!=null?t:{},o=typeof e=="string"?U(e,G(a)):e;let c=null,l=null;function u(){r(o),c&&clearTimeout(c),l==null||l()}if(n&&(c=setTimeout(u,n)),X(o)){const i=o.currentSrc||o.src;if(!i)return o.poster?$(o.poster,t).then(r):u();if(o.readyState>=2)return u();const f=u,d=m=>{v("Failed video load",i,m),s==null||s(m),u()};l=()=>{o.removeEventListener("loadeddata",f),o.removeEventListener("error",d)},o.addEventListener("loadeddata",f,{once:!0}),o.addEventListener("error",d,{once:!0})}else{const i=ce(o)?o.href.baseVal:o.currentSrc||o.src;if(!i)return u();const f=()=>E(this,null,function*(){if(_(o)&&"decode"in o)try{yield o.decode()}catch(m){v("Failed to decode image, trying to render anyway",o.dataset.originalSrc||i,m)}u()}),d=m=>{v("Failed image load",o.dataset.originalSrc||i,m),u()};if(_(o)&&o.complete)return f();l=()=>{o.removeEventListener("load",f),o.removeEventListener("error",d)},o.addEventListener("load",f,{once:!0}),o.addEventListener("error",d,{once:!0})}})}function ge(e,t){return E(this,null,function*(){ne(e)&&(_(e)||X(e)?yield $(e,{timeout:t}):yield Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(n=>$(n,{timeout:t})))))})}const he=function(){let t=0;const r=()=>`0000${(Math.random()*Oe(36,4)<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${r()}${t}`)}();function we(e){return e==null?void 0:e.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}function gt(e){return{time:t=>e&&it(t),timeEnd:t=>e&&ct(t),warn:(...t)=>e&&v(...t)}}function ht(e){return{cache:e?"no-cache":"force-cache"}}function R(e,t){return E(this,null,function*(){return Ge(e)?e:pe(e,L(x({},t),{autoDestruct:!0}))})}function pe(e,t){return E(this,null,function*(){var m,w,p,b,g;const{scale:r=1,workerUrl:n,workerNumber:a=1}=t||{},s=Boolean(t==null?void 0:t.debug),o=(m=t==null?void 0:t.features)!=null?m:!0,c=(w=e.ownerDocument)!=null?w:P?window.document:void 0,l=(b=(p=e.ownerDocument)==null?void 0:p.defaultView)!=null?b:P?window:void 0,u=new Map,i=L(x({width:0,height:0,quality:1,type:"image/png",scale:r,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:x({requestInit:ht((g=t==null?void 0:t.fetch)==null?void 0:g.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1},t==null?void 0:t.fetch),fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:a,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1},t),{__CONTEXT__:!0,log:gt(s),node:e,ownerDocument:c,ownerWindow:l,dpi:r===1?null:96*r,svgStyleElement:ye(c),svgDefsElement:c==null?void 0:c.createElementNS(Y,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...new Array(ze&&n&&a?a:0)].map(()=>{try{const S=new Worker(n);return S.onmessage=y=>E(this,null,function*(){var F,_e,Q,$e;const{url:A,result:I}=y.data;I?(_e=(F=u.get(A))==null?void 0:F.resolve)==null||_e.call(F,I):($e=(Q=u.get(A))==null?void 0:Q.reject)==null||$e.call(Q,new Error(`Error receiving message from worker: ${A}`))}),S.onmessageerror=y=>{var I,F;const{url:A}=y.data;(F=(I=u.get(A))==null?void 0:I.reject)==null||F.call(I,new Error(`Error receiving message from worker: ${A}`))},S}catch(S){return v("Failed to new Worker",S),null}}).filter(Boolean),fontFamilies:new Set,fontCssTexts:new Map,acceptOfImage:`${[lt(c)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:u,drawImageCount:0,tasks:[],features:o,isEnable:S=>{var y;return typeof o=="boolean"?o:(y=o[S])!=null?y:!0}});i.log.time("wait until load"),yield ge(e,i.timeout),i.log.timeEnd("wait until load");const{width:f,height:d}=wt(e,i);return i.width=f,i.height=d,i})}function ye(e){if(!e)return;const t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
(function(h,C){typeof exports=="object"&&typeof module!="undefined"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(h=typeof globalThis!="undefined"?globalThis:h||self,C(h.modernScreenshot={}))})(this,function(h){var Ue;"use strict";var Kt=Object.defineProperty,Qt=Object.defineProperties;var Zt=Object.getOwnPropertyDescriptors;var Q=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable;var Oe=Math.pow,Be=(h,C,T)=>C in h?Kt(h,C,{enumerable:!0,configurable:!0,writable:!0,value:T}):h[C]=T,x=(h,C)=>{for(var T in C||(C={}))Le.call(C,T)&&Be(h,T,C[T]);if(Q)for(var T of Q(C))Me.call(C,T)&&Be(h,T,C[T]);return h},L=(h,C)=>Qt(h,Zt(C));var We=(h,C)=>{var T={};for(var N in h)Le.call(h,N)&&C.indexOf(N)<0&&(T[N]=h[N]);if(h!=null&&Q)for(var N of Q(h))C.indexOf(N)<0&&Me.call(h,N)&&(T[N]=h[N]);return T};var E=(h,C,T)=>new Promise((N,M)=>{var H=D=>{try{W(T.next(D))}catch(j){M(j)}},O=D=>{try{W(T.throw(D))}catch(j){M(j)}},W=D=>D.done?N(D.value):Promise.resolve(D.value).then(H,O);W((T=T.apply(h,C)).next())});function C(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}const T="p".charCodeAt(0),N="H".charCodeAt(0),M="Y".charCodeAt(0),H="s".charCodeAt(0);let O;function W(){const e=new Int32Array(256);for(let t=0;t<256;t++){let r=t;for(let n=0;n<8;n++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e}function D(e){let t=-1;O||(O=W());for(let r=0;r<e.length;r++)t=O[(t^e[r])&255]^t>>>8;return t^-1}function j(e){const t=e.length-1;for(let r=t;r>=4;r--)if(e[r-4]===9&&e[r-3]===T&&e[r-2]===N&&e[r-1]===M&&e[r]===H)return r-3;return 0}function ae(e,t,r=!1){const n=new Uint8Array(13);t*=39.3701,n[0]=T,n[1]=N,n[2]=M,n[3]=H,n[4]=t>>>24,n[5]=t>>>16,n[6]=t>>>8,n[7]=t&255,n[8]=n[4],n[9]=n[5],n[10]=n[6],n[11]=n[7],n[12]=1;const a=D(n),s=new Uint8Array(4);if(s[0]=a>>>24,s[1]=a>>>16,s[2]=a>>>8,s[3]=a&255,r){const o=j(e);return e.set(n,o),e.set(s,o+13),e}else{const o=new Uint8Array(4);o[0]=0,o[1]=0,o[2]=0,o[3]=9;const c=new Uint8Array(54);return c.set(e,0),c.set(o,33),c.set(n,37),c.set(s,50),c}}const je="AAlwSFlz",qe="AAAJcEhZ",Ve="AAAACXBI";function He(e){let t=e.indexOf(je);return t===-1&&(t=e.indexOf(qe)),t===-1&&(t=e.indexOf(Ve)),t}const Z="[modern-screenshot]",P=typeof window!="undefined",ze=P&&"Worker"in window,se=P&&"atob"in window,Xe=P&&"btoa"in window,ee=P?(Ue=window.navigator)==null?void 0:Ue.userAgent:"",ie=ee.includes("Chrome"),z=ee.includes("AppleWebKit")&&!ie,te=ee.includes("Firefox"),Ge=e=>e&&"__CONTEXT__"in e,Ye=e=>e.constructor.name==="CSSFontFaceRule",Je=e=>e.constructor.name==="CSSImportRule",k=e=>e.nodeType===1,q=e=>typeof e.className=="object",ce=e=>e.tagName==="image",Ke=e=>e.tagName==="use",re=e=>k(e)&&typeof e.style!="undefined"&&!q(e),Qe=e=>e.nodeType===8,Ze=e=>e.nodeType===3,_=e=>e.tagName==="IMG",X=e=>e.tagName==="VIDEO",et=e=>e.tagName==="CANVAS",le=e=>e.tagName==="TEXTAREA",tt=e=>e.tagName==="INPUT",rt=e=>e.tagName==="STYLE",nt=e=>e.tagName==="SCRIPT",ot=e=>e.tagName==="SELECT",at=e=>e.tagName==="SLOT",st=e=>e.tagName==="IFRAME",v=(...e)=>console.warn(Z,...e),it=e=>console.time(`${Z} ${e}`),ct=e=>console.timeEnd(`${Z} ${e}`),lt=e=>{var r;const t=(r=e==null?void 0:e.createElement)==null?void 0:r.call(e,"canvas");return t&&(t.height=t.width=1),t&&"toDataURL"in t&&Boolean(t.toDataURL("image/webp").includes("image/webp"))},ne=e=>e.startsWith("data:");function ue(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(P&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!P)return e;const r=G().implementation.createHTMLDocument(),n=r.createElement("base"),a=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(a),t&&(n.href=t),a.href=e,a.href}function G(e){var t;return(t=e&&k(e)?e==null?void 0:e.ownerDocument:e)!=null?t:window.document}const Y="http://www.w3.org/2000/svg";function fe(e,t,r){const n=G(r).createElementNS(Y,"svg");return n.setAttributeNS(null,"width",e.toString()),n.setAttributeNS(null,"height",t.toString()),n.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),n}function de(e,t){let r=new XMLSerializer().serializeToString(e);return t&&(r=r.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/ug,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}function ut(e,t="image/png",r=1){return E(this,null,function*(){try{return yield new Promise((n,a)=>{e.toBlob(s=>{s?n(s):a(new Error("Blob is null"))},t,r)})}catch(n){if(se)return v("Failed canvas to blob",{type:t,quality:r},n),ft(e.toDataURL(t,r));throw n}})}function ft(e){var c,l;const[t,r]=e.split(","),n=(l=(c=t.match(/data:(.+);/))==null?void 0:c[1])!=null?l:void 0,a=window.atob(r),s=a.length,o=new Uint8Array(s);for(let u=0;u<s;u+=1)o[u]=a.charCodeAt(u);return new Blob([o],{type:n})}function me(e,t){return new Promise((r,n)=>{const a=new FileReader;a.onload=()=>r(a.result),a.onerror=()=>n(a.error),a.onabort=()=>n(new Error(`Failed read blob to ${t}`)),t==="dataUrl"?a.readAsDataURL(e):t==="arrayBuffer"&&a.readAsArrayBuffer(e)})}const dt=e=>me(e,"dataUrl"),mt=e=>me(e,"arrayBuffer");function U(e,t){const r=G(t).createElement("img");return r.decoding="sync",r.loading="eager",r.src=e,r}function $(e,t){return new Promise(r=>{const{timeout:n,ownerDocument:a,onError:s}=t!=null?t:{},o=typeof e=="string"?U(e,G(a)):e;let c=null,l=null;function u(){r(o),c&&clearTimeout(c),l==null||l()}if(n&&(c=setTimeout(u,n)),X(o)){const i=o.currentSrc||o.src;if(!i)return o.poster?$(o.poster,t).then(r):u();if(o.readyState>=2)return u();const f=u,d=m=>{v("Failed video load",i,m),s==null||s(m),u()};l=()=>{o.removeEventListener("loadeddata",f),o.removeEventListener("error",d)},o.addEventListener("loadeddata",f,{once:!0}),o.addEventListener("error",d,{once:!0})}else{const i=ce(o)?o.href.baseVal:o.currentSrc||o.src;if(!i)return u();const f=()=>E(this,null,function*(){if(_(o)&&"decode"in o)try{yield o.decode()}catch(m){v("Failed to decode image, trying to render anyway",o.dataset.originalSrc||i,m)}u()}),d=m=>{v("Failed image load",o.dataset.originalSrc||i,m),u()};if(_(o)&&o.complete)return f();l=()=>{o.removeEventListener("load",f),o.removeEventListener("error",d)},o.addEventListener("load",f,{once:!0}),o.addEventListener("error",d,{once:!0})}})}function ge(e,t){return E(this,null,function*(){re(e)&&(_(e)||X(e)?yield $(e,{timeout:t}):yield Promise.all(["img","video"].flatMap(r=>Array.from(e.querySelectorAll(r)).map(n=>$(n,{timeout:t})))))})}const he=function(){let t=0;const r=()=>`0000${(Math.random()*Oe(36,4)<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${r()}${t}`)}();function we(e){return e==null?void 0:e.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}function gt(e){return{time:t=>e&&it(t),timeEnd:t=>e&&ct(t),warn:(...t)=>e&&v(...t)}}function ht(e){return{cache:e?"no-cache":"force-cache"}}function R(e,t){return E(this,null,function*(){return Ge(e)?e:pe(e,L(x({},t),{autoDestruct:!0}))})}function pe(e,t){return E(this,null,function*(){var m,w,p,b,g;const{scale:r=1,workerUrl:n,workerNumber:a=1}=t||{},s=Boolean(t==null?void 0:t.debug),o=(m=t==null?void 0:t.features)!=null?m:!0,c=(w=e.ownerDocument)!=null?w:P?window.document:void 0,l=(b=(p=e.ownerDocument)==null?void 0:p.defaultView)!=null?b:P?window:void 0,u=new Map,i=L(x({width:0,height:0,quality:1,type:"image/png",scale:r,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:x({requestInit:ht((g=t==null?void 0:t.fetch)==null?void 0:g.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1},t==null?void 0:t.fetch),fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:a,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1},t),{__CONTEXT__:!0,log:gt(s),node:e,ownerDocument:c,ownerWindow:l,dpi:r===1?null:96*r,svgStyleElement:ye(c),svgDefsElement:c==null?void 0:c.createElementNS(Y,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...new Array(ze&&n&&a?a:0)].map(()=>{try{const S=new Worker(n);return S.onmessage=y=>E(this,null,function*(){var F,_e,K,$e;const{url:A,result:I}=y.data;I?(_e=(F=u.get(A))==null?void 0:F.resolve)==null||_e.call(F,I):($e=(K=u.get(A))==null?void 0:K.reject)==null||$e.call(K,new Error(`Error receiving message from worker: ${A}`))}),S.onmessageerror=y=>{var I,F;const{url:A}=y.data;(F=(I=u.get(A))==null?void 0:I.reject)==null||F.call(I,new Error(`Error receiving message from worker: ${A}`))},S}catch(S){return v("Failed to new Worker",S),null}}).filter(Boolean),fontFamilies:new Set,fontCssTexts:new Map,acceptOfImage:`${[lt(c)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:u,drawImageCount:0,tasks:[],features:o,isEnable:S=>{var y;return typeof o=="boolean"?o:(y=o[S])!=null?y:!0}});i.log.time("wait until load"),yield ge(e,i.timeout),i.log.timeEnd("wait until load");const{width:f,height:d}=wt(e,i);return i.width=f,i.height=d,i})}function ye(e){if(!e)return;const t=e.createElement("style"),r=t.ownerDocument.createTextNode(`
.______background-clip--text {

@@ -7,9 +7,9 @@ background-clip: text;

`);return t.appendChild(r),t}function wt(e,t){let{width:r,height:n}=t;if(k(e)&&(!r||!n)){const a=e.getBoundingClientRect();r=r||a.width||Number(e.getAttribute("width"))||0,n=n||a.height||Number(e.getAttribute("height"))||0}return{width:r,height:n}}function pt(e,t){return E(this,null,function*(){const{log:r,timeout:n,drawImageCount:a,drawImageInterval:s}=t;r.time("image to canvas");const o=yield $(e,{timeout:n}),{canvas:c,context2d:l}=yt(e.ownerDocument,t),u=()=>{try{l==null||l.drawImage(o,0,0,c.width,c.height)}catch(i){v("Failed to drawImage",i)}};if(u(),t.isEnable("fixSvgXmlDecode"))for(let i=0;i<a;i++)yield new Promise(f=>{setTimeout(()=>{u(),f()},i+s)});return t.drawImageCount=0,r.timeEnd("image to canvas"),c})}function yt(e,t){const{width:r,height:n,scale:a,backgroundColor:s,maximumCanvasSize:o}=t,c=e.createElement("canvas");c.width=Math.floor(r*a),c.height=Math.floor(n*a),c.style.width=`${r}px`,c.style.height=`${n}px`,o&&(c.width>o||c.height>o)&&(c.width>o&&c.height>o?c.width>c.height?(c.height*=o/c.width,c.width=o):(c.width*=o/c.height,c.height=o):c.width>o?(c.height*=o/c.width,c.width=o):(c.width*=o/c.height,c.height=o));const l=c.getContext("2d");return l&&s&&(l.fillStyle=s,l.fillRect(0,0,c.width,c.height)),{canvas:c,context2d:l}}const bt=["width","height","-webkit-text-fill-color"],St=["stroke","fill"];function be(e,t,r){var b;const{defaultComputedStyles:n,ownerDocument:a}=r,s=e.nodeName.toLowerCase(),o=q(e)&&s!=="svg",c=o?St.map(g=>[g,e.getAttribute(g)]).filter(([,g])=>g!==null):[],l=[o&&"svg",s,c.map((g,S)=>`${g}=${S}`).join(","),t].filter(Boolean).join(":");if(n.has(l))return n.get(l);let u=r.sandbox;if(!u)try{a&&(u=a.createElement("iframe"),u.id=`__SANDBOX__-${he()}`,u.width="0",u.height="0",u.style.visibility="hidden",u.style.position="fixed",a.body.appendChild(u),(b=u.contentWindow)==null||b.document.write('<!DOCTYPE html><meta charset="UTF-8"><title></title><body>'),r.sandbox=u)}catch(g){v("Failed to create iframe sandbox",g)}if(!u)return new Map;const i=u.contentWindow;if(!i)return new Map;const f=i.document;let d,m;o?(d=f.createElementNS(Y,"svg"),m=d.ownerDocument.createElementNS(d.namespaceURI,s),c.forEach(([g,S])=>{m.setAttributeNS(null,g,S)}),d.appendChild(m)):d=m=f.createElement(s),m.textContent=" ",f.body.appendChild(d);const w=i.getComputedStyle(m,t),p=new Map;for(let g=w.length,S=0;S<g;S++){const y=w.item(S);bt.includes(y)||p.set(y,w.getPropertyValue(y))}return f.body.removeChild(d),n.set(l,p),p}function Se(e,t,r){var c;const n=new Map,a=[],s=new Map;if(r)for(const l of r)o(l);else for(let l=e.length,u=0;u<l;u++){const i=e.item(u);o(i)}for(let l=a.length,u=0;u<l;u++)(c=s.get(a[u]))==null||c.forEach((i,f)=>n.set(f,i));function o(l){const u=e.getPropertyValue(l),i=e.getPropertyPriority(l),f=l.lastIndexOf("-"),d=f>-1?l.substring(0,f):void 0;if(d){let m=s.get(d);m||(m=new Map,s.set(d,m)),m.set(l,[u,i])}t.get(l)===u&&!i||(d?a.push(d):n.set(l,[u,i]))}return n}const Et=[":before",":after"],Ct=[":-webkit-scrollbar",":-webkit-scrollbar-button",":-webkit-scrollbar-thumb",":-webkit-scrollbar-track",":-webkit-scrollbar-track-piece",":-webkit-scrollbar-corner",":-webkit-resizer"];function Tt(e,t,r,n){const{ownerWindow:a,svgStyleElement:s,svgStyles:o,currentNodeStyle:c}=n;if(!s||!a)return;function l(u){var S;const i=a.getComputedStyle(e,u);let f=i.getPropertyValue("content");if(!f||f==="none")return;f=f.replace(/(')|(")|(counter\(.+\))/g,"");const d=[he()],m=be(e,u,n);c==null||c.forEach((y,A)=>{m.delete(A)});const w=Se(i,m,n.includeStyleProperties);w.delete("content"),w.delete("-webkit-locale"),((S=w.get("background-clip"))==null?void 0:S[0])==="text"&&t.classList.add("______background-clip--text");const p=[`content: '${f}';`];if(w.forEach(([y,A],I)=>{p.push(`${I}: ${y}${A?" !important":""};`)}),p.length===1)return;try{t.className=[t.className,...d].join(" ")}catch(y){return}const b=p.join(`
`);let g=o.get(b);g||(g=[],o.set(b,g)),g.push(`.${d[0]}:${u}`)}Et.forEach(l),r&&Ct.forEach(l)}function vt(e,t){le(e)&&(t.innerHTML=e.value),(le(e)||tt(e)||ot(e))&&t.setAttribute("value",e.value)}function At(e,t,r,n){var f,d,m,w;const{ownerWindow:a,includeStyleProperties:s,currentParentNodeStyle:o}=n,c=t.style,l=a.getComputedStyle(e),u=be(e,null,n);o==null||o.forEach((p,b)=>{u.delete(b)});const i=Se(l,u,s);return i.delete("transition-property"),i.delete("all"),i.delete("d"),i.delete("content"),r&&(i.delete("margin-top"),i.delete("margin-right"),i.delete("margin-bottom"),i.delete("margin-left"),i.delete("margin-block-start"),i.delete("margin-block-end"),i.delete("margin-inline-start"),i.delete("margin-inline-end"),i.set("box-sizing",["border-box",""])),((f=i.get("background-clip"))==null?void 0:f[0])==="text"&&t.classList.add("______background-clip--text"),ie&&(i.has("font-kerning")||i.set("font-kerning",["normal",""]),(((d=i.get("overflow-x"))==null?void 0:d[0])==="hidden"||((m=i.get("overflow-y"))==null?void 0:m[0])==="hidden")&&((w=i.get("text-overflow"))==null?void 0:w[0])==="ellipsis"&&e.scrollWidth===e.clientWidth&&i.set("text-overflow",["clip",""])),i.forEach(([p,b],g)=>{c.setProperty(g,p,b)}),i}function Nt(e,t){var r;try{if((r=e==null?void 0:e.contentDocument)!=null&&r.body)return J(e.contentDocument.body,t)}catch(n){v("Failed to clone iframe",n)}return e.cloneNode(!1)}function Ee(e){if(e.ownerDocument)try{const a=e.toDataURL();if(a!=="data:,")return U(a,e.ownerDocument)}catch(a){}const t=e.cloneNode(!1),r=e.getContext("2d"),n=t.getContext("2d");try{return r&&n&&n.putImageData(r.getImageData(0,0,e.width,e.height),0,0),t}catch(a){v("Failed to clone canvas",a)}return t}function It(e){return E(this,null,function*(){if(e.ownerDocument&&!e.currentSrc&&e.poster)return U(e.poster,e.ownerDocument);const t=e.cloneNode(!1);t.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc);const r=t.ownerDocument;if(r){let n=!0;if(yield $(t,{onError:()=>n=!1}),!n)return e.poster?U(e.poster,e.ownerDocument):t;t.currentTime=e.currentTime,yield new Promise(s=>{t.addEventListener("seeked",s,{once:!0})});const a=r.createElement("canvas");a.width=e.offsetWidth,a.height=e.offsetHeight;try{const s=a.getContext("2d");s&&s.drawImage(t,0,0,a.width,a.height)}catch(s){return v("Failed to clone video",s),e.poster?U(e.poster,e.ownerDocument):t}return Ee(a)}return t})}function kt(e){const t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}function Rt(e,t){return et(e)?Ee(e):st(e)?Nt(e,t):_(e)?kt(e):X(e)?It(e):e.cloneNode(!1)}const Ce=new Set(["symbol"]);function Te(e,t,r){return E(this,null,function*(){k(t)&&(rt(t)||nt(t))||r.filter&&!r.filter(t)||(Ce.has(e.nodeName)||Ce.has(t.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle,e.appendChild(yield J(t,r)))})}function ve(e,t,r){return E(this,null,function*(){var a,s;const n=(s=k(e)?(a=e.shadowRoot)==null?void 0:a.firstChild:void 0)!=null?s:e.firstChild;for(let o=n;o;o=o.nextSibling)if(!Qe(o))if(k(o)&&at(o)&&typeof o.assignedNodes=="function"){const c=o.assignedNodes();for(let l=0;l<c.length;l++)yield Te(t,c[l],r)}else yield Te(t,o,r)})}function xt(e,t){const{backgroundColor:r,width:n,height:a,style:s}=t,o=e.style;if(r&&o.setProperty("background-color",r,"important"),n&&o.setProperty("width",`${n}px`,"important"),a&&o.setProperty("height",`${a}px`,"important"),s)for(const c in s)o[c]=s[c]}const Dt=/^[\w-:]+$/;function J(e,t,r=!1){return E(this,null,function*(){var c,l,u,i;const{ownerDocument:n,ownerWindow:a,fontFamilies:s}=t;if(n&&Ze(e))return n.createTextNode(e.data);if(n&&a&&k(e)&&(ne(e)||q(e))){const f=yield Rt(e,t);if(t.isEnable("removeAbnormalAttributes")){const w=f.getAttributeNames();for(let p=w.length,b=0;b<p;b++){const g=w[b];Dt.test(g)||f.removeAttribute(g)}}const d=t.currentNodeStyle=At(e,f,r,t);r&&xt(f,t);let m=!1;if(t.isEnable("copyScrollbar")){const w=[(c=d.get("overflow-x"))==null?void 0:c[0],(l=d.get("overflow-y"))==null?void 0:l[1]];m=w.includes("scroll")||(w.includes("auto")||w.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}return Tt(e,f,m,t),vt(e,f),(i=we((u=d.get("font-family"))==null?void 0:u[0]))==null||i.forEach(w=>s.add(w)),X(e)||(yield ve(e,f,t)),f}const o=e.cloneNode(!1);return yield ve(e,o,t),o})}function Ae(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[]}function Ft(e){const c=e,{url:t,timeout:r,responseType:n}=c,a=We(c,["url","timeout","responseType"]),s=new AbortController,o=r?setTimeout(()=>s.abort(),r):void 0;return fetch(t,x({signal:s.signal},a)).then(l=>{if(!l.ok)throw new Error("Failed fetch, not 2xx response",{cause:l});switch(n){case"dataUrl":return l.blob().then(dt);case"text":default:return l.text()}}).finally(()=>clearTimeout(o))}function V(e,t){const{url:r,requestType:n="text",responseType:a="text",imageDom:s}=t;let o=r;const{timeout:c,acceptOfImage:l,requests:u,fetchFn:i,fetch:{requestInit:f,bypassingCache:d,placeholderImage:m},workers:w}=e;n==="image"&&(z||re)&&e.drawImageCount++;let p=u.get(r);if(!p){d&&d instanceof RegExp&&d.test(o)&&(o+=(/\?/.test(o)?"&":"?")+new Date().getTime());const b=x({url:o,timeout:c,responseType:a,headers:n==="image"?{accept:l}:void 0},f);p={type:n,resolve:void 0,reject:void 0,response:null},p.response=(()=>E(this,null,function*(){if(i&&n==="image"){const g=yield i(r);if(g)return g}return!z&&r.startsWith("http")&&w.length?new Promise((g,S)=>{w[u.size&w.length-1].postMessage(x({rawUrl:r},b)),p.resolve=g,p.reject=S}):Ft(b)}))().catch(g=>{if(u.delete(r),n==="image"&&m)return v("Failed to fetch image base64, trying to use placeholder image",o),typeof m=="string"?m:m(s);throw g}),u.set(r,p)}return p.response}function Ne(e,t,r,n){return E(this,null,function*(){if(!Ie(e))return e;for(const[a,s]of Pt(e,t))try{const o=yield V(r,{url:s,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(Ut(a),`$1${o}$3`)}catch(o){v("Failed to fetch css data url",a,o)}return e})}function Ie(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const ke=/url\((['"]?)([^'"]+?)\1\)/g;function Pt(e,t){const r=[];return e.replace(ke,(n,a,s)=>(r.push([s,ue(s,t)]),n)),r.filter(([n])=>!oe(n))}function Ut(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function _t(e,t){return E(this,null,function*(){const{ownerDocument:r,svgStyleElement:n,fontFamilies:a,fontCssTexts:s,tasks:o,font:c}=t;if(!(!r||!n||!a.size))if(c&&c.cssText){const l=xe(c.cssText,t);n.appendChild(r.createTextNode(`${l}
`);let g=o.get(b);g||(g=[],o.set(b,g)),g.push(`.${d[0]}:${u}`)}Et.forEach(l),r&&Ct.forEach(l)}function vt(e,t){le(e)&&(t.innerHTML=e.value),(le(e)||tt(e)||ot(e))&&t.setAttribute("value",e.value)}function At(e,t,r,n){var f,d,m,w;const{ownerWindow:a,includeStyleProperties:s,currentParentNodeStyle:o}=n,c=t.style,l=a.getComputedStyle(e),u=be(e,null,n);o==null||o.forEach((p,b)=>{u.delete(b)});const i=Se(l,u,s);return i.delete("transition-property"),i.delete("all"),i.delete("d"),i.delete("content"),r&&(i.delete("margin-top"),i.delete("margin-right"),i.delete("margin-bottom"),i.delete("margin-left"),i.delete("margin-block-start"),i.delete("margin-block-end"),i.delete("margin-inline-start"),i.delete("margin-inline-end"),i.set("box-sizing",["border-box",""])),((f=i.get("background-clip"))==null?void 0:f[0])==="text"&&t.classList.add("______background-clip--text"),ie&&(i.has("font-kerning")||i.set("font-kerning",["normal",""]),(((d=i.get("overflow-x"))==null?void 0:d[0])==="hidden"||((m=i.get("overflow-y"))==null?void 0:m[0])==="hidden")&&((w=i.get("text-overflow"))==null?void 0:w[0])==="ellipsis"&&e.scrollWidth===e.clientWidth&&i.set("text-overflow",["clip",""])),i.forEach(([p,b],g)=>{c.setProperty(g,p,b)}),i}function Nt(e,t){var r;try{if((r=e==null?void 0:e.contentDocument)!=null&&r.body)return oe(e.contentDocument.body,t)}catch(n){v("Failed to clone iframe",n)}return e.cloneNode(!1)}function Ee(e){if(e.ownerDocument)try{const a=e.toDataURL();if(a!=="data:,")return U(a,e.ownerDocument)}catch(a){}const t=e.cloneNode(!1),r=e.getContext("2d"),n=t.getContext("2d");try{return r&&n&&n.putImageData(r.getImageData(0,0,e.width,e.height),0,0),t}catch(a){v("Failed to clone canvas",a)}return t}function It(e){return E(this,null,function*(){if(e.ownerDocument&&!e.currentSrc&&e.poster)return U(e.poster,e.ownerDocument);const t=e.cloneNode(!1);t.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc);const r=t.ownerDocument;if(r){let n=!0;if(yield $(t,{onError:()=>n=!1}),!n)return e.poster?U(e.poster,e.ownerDocument):t;t.currentTime=e.currentTime,yield new Promise(s=>{t.addEventListener("seeked",s,{once:!0})});const a=r.createElement("canvas");a.width=e.offsetWidth,a.height=e.offsetHeight;try{const s=a.getContext("2d");s&&s.drawImage(t,0,0,a.width,a.height)}catch(s){return v("Failed to clone video",s),e.poster?U(e.poster,e.ownerDocument):t}return Ee(a)}return t})}function kt(e){const t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}function Rt(e,t){return et(e)?Ee(e):st(e)?Nt(e,t):_(e)?kt(e):X(e)?It(e):e.cloneNode(!1)}const Ce=new Set(["symbol"]);function Te(e,t,r){return E(this,null,function*(){k(t)&&(rt(t)||nt(t))||r.filter&&!r.filter(t)||(Ce.has(e.nodeName)||Ce.has(t.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle,e.appendChild(yield oe(t,r)))})}function ve(e,t,r){return E(this,null,function*(){var a,s;const n=(s=k(e)?(a=e.shadowRoot)==null?void 0:a.firstChild:void 0)!=null?s:e.firstChild;for(let o=n;o;o=o.nextSibling)if(!Qe(o))if(k(o)&&at(o)&&typeof o.assignedNodes=="function"){const c=o.assignedNodes();for(let l=0;l<c.length;l++)yield Te(t,c[l],r)}else yield Te(t,o,r)})}function xt(e,t){const{backgroundColor:r,width:n,height:a,style:s}=t,o=e.style;if(r&&o.setProperty("background-color",r,"important"),n&&o.setProperty("width",`${n}px`,"important"),a&&o.setProperty("height",`${a}px`,"important"),s)for(const c in s)o[c]=s[c]}const Dt=/^[\w-:]+$/;function oe(e,t,r=!1){return E(this,null,function*(){var c,l,u,i;const{ownerDocument:n,ownerWindow:a,fontFamilies:s}=t;if(n&&Ze(e))return n.createTextNode(e.data);if(n&&a&&k(e)&&(re(e)||q(e))){const f=yield Rt(e,t);if(t.isEnable("removeAbnormalAttributes")){const w=f.getAttributeNames();for(let p=w.length,b=0;b<p;b++){const g=w[b];Dt.test(g)||f.removeAttribute(g)}}const d=t.currentNodeStyle=At(e,f,r,t);r&&xt(f,t);let m=!1;if(t.isEnable("copyScrollbar")){const w=[(c=d.get("overflow-x"))==null?void 0:c[0],(l=d.get("overflow-y"))==null?void 0:l[1]];m=w.includes("scroll")||(w.includes("auto")||w.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}return Tt(e,f,m,t),vt(e,f),(i=we((u=d.get("font-family"))==null?void 0:u[0]))==null||i.forEach(w=>s.add(w)),X(e)||(yield ve(e,f,t)),f}const o=e.cloneNode(!1);return yield ve(e,o,t),o})}function Ae(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[]}function Ft(e){const c=e,{url:t,timeout:r,responseType:n}=c,a=We(c,["url","timeout","responseType"]),s=new AbortController,o=r?setTimeout(()=>s.abort(),r):void 0;return fetch(t,x({signal:s.signal},a)).then(l=>{if(!l.ok)throw new Error("Failed fetch, not 2xx response",{cause:l});switch(n){case"dataUrl":return l.blob().then(dt);case"text":default:return l.text()}}).finally(()=>clearTimeout(o))}function V(e,t){const{url:r,requestType:n="text",responseType:a="text",imageDom:s}=t;let o=r;const{timeout:c,acceptOfImage:l,requests:u,fetchFn:i,fetch:{requestInit:f,bypassingCache:d,placeholderImage:m},workers:w}=e;n==="image"&&(z||te)&&e.drawImageCount++;let p=u.get(r);if(!p){d&&d instanceof RegExp&&d.test(o)&&(o+=(/\?/.test(o)?"&":"?")+new Date().getTime());const b=x({url:o,timeout:c,responseType:a,headers:n==="image"?{accept:l}:void 0},f);p={type:n,resolve:void 0,reject:void 0,response:null},p.response=(()=>E(this,null,function*(){if(i&&n==="image"){const g=yield i(r);if(g)return g}return!z&&r.startsWith("http")&&w.length?new Promise((g,S)=>{w[u.size&w.length-1].postMessage(x({rawUrl:r},b)),p.resolve=g,p.reject=S}):Ft(b)}))().catch(g=>{if(u.delete(r),n==="image"&&m)return v("Failed to fetch image base64, trying to use placeholder image",o),typeof m=="string"?m:m(s);throw g}),u.set(r,p)}return p.response}function Ne(e,t,r,n){return E(this,null,function*(){if(!Ie(e))return e;for(const[a,s]of Pt(e,t))try{const o=yield V(r,{url:s,requestType:n?"image":"text",responseType:"dataUrl"});e=e.replace(Ut(a),`$1${o}$3`)}catch(o){v("Failed to fetch css data url",a,o)}return e})}function Ie(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}const ke=/url\((['"]?)([^'"]+?)\1\)/g;function Pt(e,t){const r=[];return e.replace(ke,(n,a,s)=>(r.push([s,ue(s,t)]),n)),r.filter(([n])=>!ne(n))}function Ut(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function _t(e,t){return E(this,null,function*(){const{ownerDocument:r,svgStyleElement:n,fontFamilies:a,fontCssTexts:s,tasks:o,font:c}=t;if(!(!r||!n||!a.size))if(c&&c.cssText){const l=xe(c.cssText,t);n.appendChild(r.createTextNode(`${l}
`))}else{const l=Array.from(r.styleSheets).filter(i=>{try{return"cssRules"in i&&Boolean(i.cssRules.length)}catch(f){return v(`Error while reading CSS rules from ${i.href}`,f),!1}});yield Promise.all(l.flatMap(i=>Array.from(i.cssRules).map((f,d)=>E(this,null,function*(){if(Je(f)){let m=d+1;const w=f.href;let p="";try{p=yield V(t,{url:w,requestType:"text",responseType:"text"})}catch(g){v(`Error fetch remote css import from ${w}`,g)}const b=p.replace(ke,(g,S,y)=>g.replace(y,ue(y,w)));for(const g of Bt(b))try{i.insertRule(g,g.startsWith("@import")?m+=1:i.cssRules.length)}catch(S){v("Error inserting rule from remote css import",{rule:g,error:S})}}})))),l.flatMap(i=>Array.from(i.cssRules)).filter(i=>{var f;return Ye(i)&&Ie(i.style.getPropertyValue("src"))&&((f=we(i.style.getPropertyValue("font-family")))==null?void 0:f.some(d=>a.has(d)))}).forEach(i=>{const f=i,d=s.get(f.cssText);d?n.appendChild(r.createTextNode(`${d}
`)):o.push(Ne(f.cssText,f.parentStyleSheet?f.parentStyleSheet.href:null,t).then(m=>{m=xe(m,t),s.set(f.cssText,m),n.appendChild(r.createTextNode(`${m}
`))}))})}})}const $t=/(\/\*[\s\S]*?\*\/)/gi,Re=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Bt(e){if(e==null)return[];const t=[];let r=e.replace($t,"");for(;;){const s=Re.exec(r);if(!s)break;t.push(s[0])}r=r.replace(Re,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let s=n.exec(r);if(s)a.lastIndex=n.lastIndex;else if(s=a.exec(r),s)n.lastIndex=a.lastIndex;else break;t.push(s[0])}return t}const Lt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Mt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function xe(e,t){const{font:r}=t,n=r?r==null?void 0:r.preferredFormat:void 0;return n?e.replace(Mt,a=>{for(;;){const[s,,o]=Lt.exec(a)||[];if(!o)return"";if(o===n)return`src: ${s};`}}):e}function Ot(e,t){if(_(e)){const r=e.currentSrc||e.src;if(!oe(r))return[V(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.srcset="",e.dataset.originalSrc=r,e.src=n||"")})];(z||re)&&t.drawImageCount++}else if(q(e)&&!oe(e.href.baseVal)){const r=e.href.baseVal;return[V(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.dataset.originalSrc=r,e.href.baseVal=n||"")})]}return[]}const Wt=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function jt(e,t){return Wt.map(r=>{const n=e.getPropertyValue(r);return!n||n==="none"?null:((z||re)&&t.drawImageCount++,Ne(n,null,t,!0).then(a=>{!a||n===a||e.setProperty(r,a,e.getPropertyPriority(r))}))}).filter(Boolean)}function qt(e,t){var c;const{ownerDocument:r,svgDefsElement:n}=t,a=(c=e.getAttribute("href"))!=null?c:e.getAttribute("xlink:href");if(!a)return[];const[s,o]=a.split("#");if(o){const l=`#${o}`,u=r==null?void 0:r.querySelector(`svg ${l}`);if(s&&e.setAttribute("href",l),n!=null&&n.querySelector(l))return[];if(u)return[J(u,t).then(i=>{n!=null&&n.querySelector(l)||n==null||n.appendChild(i)})];if(s)return[V(t,{url:s,responseType:"text"}).then(i=>{n==null||n.insertAdjacentHTML("beforeend",i)})]}return[]}function De(e,t){const{tasks:r}=t;k(e)&&((_(e)||ce(e))&&r.push(...Ot(e,t)),Ke(e)&&r.push(...qt(e,t))),ne(e)&&r.push(...jt(e.style,t)),e.childNodes.forEach(n=>{De(n,t)})}function Fe(e,t){return E(this,null,function*(){const r=yield R(e,t);if(k(r.node)&&q(r.node))return r.node;const{ownerDocument:n,log:a,tasks:s,svgStyleElement:o,svgDefsElement:c,svgStyles:l,font:u,progress:i,autoDestruct:f,onCloneNode:d,onEmbedNode:m,onCreateForeignObjectSvg:w}=r;a.time("clone node");const p=yield J(r.node,r,!0);if(o&&n){let A="";l.forEach((I,F)=>{A+=`${I.join(`,
`))}))})}})}const $t=/(\/\*[\s\S]*?\*\/)/gi,Re=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function Bt(e){if(e==null)return[];const t=[];let r=e.replace($t,"");for(;;){const s=Re.exec(r);if(!s)break;t.push(s[0])}r=r.replace(Re,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let s=n.exec(r);if(s)a.lastIndex=n.lastIndex;else if(s=a.exec(r),s)n.lastIndex=a.lastIndex;else break;t.push(s[0])}return t}const Lt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Mt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function xe(e,t){const{font:r}=t,n=r?r==null?void 0:r.preferredFormat:void 0;return n?e.replace(Mt,a=>{for(;;){const[s,,o]=Lt.exec(a)||[];if(!o)return"";if(o===n)return`src: ${s};`}}):e}function Ot(e,t){if(_(e)){const r=e.currentSrc||e.src;if(!ne(r))return[V(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.srcset="",e.dataset.originalSrc=r,e.src=n||"")})];(z||te)&&t.drawImageCount++}else if(q(e)&&!ne(e.href.baseVal)){const r=e.href.baseVal;return[V(t,{url:r,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(n=>{n&&(e.dataset.originalSrc=r,e.href.baseVal=n||"")})]}return[]}const Wt=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function jt(e,t){return Wt.map(r=>{const n=e.getPropertyValue(r);return!n||n==="none"?null:((z||te)&&t.drawImageCount++,Ne(n,null,t,!0).then(a=>{!a||n===a||e.setProperty(r,a,e.getPropertyPriority(r))}))}).filter(Boolean)}function qt(e,t){var c;const{ownerDocument:r,svgDefsElement:n}=t,a=(c=e.getAttribute("href"))!=null?c:e.getAttribute("xlink:href");if(!a)return[];const[s,o]=a.split("#");if(o){const l=`#${o}`,u=r==null?void 0:r.querySelector(`svg ${l}`);if(s&&e.setAttribute("href",l),n!=null&&n.querySelector(l))return[];if(u)return n==null||n.appendChild(u.cloneNode(!0)),[];if(s)return[V(t,{url:s,responseType:"text"}).then(i=>{n==null||n.insertAdjacentHTML("beforeend",i)})]}return[]}function De(e,t){const{tasks:r}=t;k(e)&&((_(e)||ce(e))&&r.push(...Ot(e,t)),Ke(e)&&r.push(...qt(e,t))),re(e)&&r.push(...jt(e.style,t)),e.childNodes.forEach(n=>{De(n,t)})}function Fe(e,t){return E(this,null,function*(){const r=yield R(e,t);if(k(r.node)&&q(r.node))return r.node;const{ownerDocument:n,log:a,tasks:s,svgStyleElement:o,svgDefsElement:c,svgStyles:l,font:u,progress:i,autoDestruct:f,onCloneNode:d,onEmbedNode:m,onCreateForeignObjectSvg:w}=r;a.time("clone node");const p=yield oe(r.node,r,!0);if(o&&n){let A="";l.forEach((I,F)=>{A+=`${I.join(`,
`)} {
${F}
}
`}),o.appendChild(n.createTextNode(A))}a.timeEnd("clone node"),d==null||d(p),u!==!1&&k(p)&&(a.time("embed web font"),yield _t(p,r),a.timeEnd("embed web font")),a.time("embed node"),De(p,r);const b=s.length;let g=0;const S=()=>E(this,null,function*(){for(;;){const A=s.pop();if(!A)break;try{yield A}catch(I){v("Failed to run task",I)}i==null||i(++g,b)}});i==null||i(g,b),yield Promise.all([...Array(4)].map(S)),a.timeEnd("embed node"),m==null||m(p);const y=Vt(p,r);return c&&y.insertBefore(c,y.children[0]),o&&y.insertBefore(o,y.children[0]),f&&Ae(r),w==null||w(y),y})}function Vt(e,t){const{width:r,height:n}=t,a=fe(r,n,e.ownerDocument),s=a.ownerDocument.createElementNS(a.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(e),a.appendChild(s),a}function K(e,t){return E(this,null,function*(){var o;const r=yield R(e,t),n=yield Fe(r),a=de(n,r.isEnable("removeControlCharacter"));r.autoDestruct||(r.svgStyleElement=ye(r.ownerDocument),r.svgDefsElement=(o=r.ownerDocument)==null?void 0:o.createElementNS(Y,"defs"),r.svgStyles.clear());const s=U(a,n.ownerDocument);return yield pt(s,r)})}function Ht(e,t){return E(this,null,function*(){const r=yield R(e,t),{log:n,type:a,quality:s,dpi:o}=r,c=yield K(r);n.time("canvas to blob");const l=yield ut(c,a,s);if(["image/png","image/jpeg"].includes(a)&&o){const u=yield mt(l.slice(0,33));let i=new Uint8Array(u);return a==="image/png"?i=ae(i,o):a==="image/jpeg"&&(i=C(i,o)),n.timeEnd("canvas to blob"),new Blob([i,l.slice(33)],{type:a})}return n.timeEnd("canvas to blob"),l})}function B(e,t){return E(this,null,function*(){const r=yield R(e,t),{log:n,quality:a,type:s,dpi:o}=r,c=yield K(r);n.time("canvas to data url");let l=c.toDataURL(s,a);if(["image/png","image/jpeg"].includes(s)&&o&&se&&Xe){const[u,i]=l.split(",");let f=0,d=!1;if(s==="image/png"){const y=He(i);y>=0?(f=Math.ceil((y+28)/3)*4,d=!0):f=33/3*4}else s==="image/jpeg"&&(f=18/3*4);const m=i.substring(0,f),w=i.substring(f),p=window.atob(m),b=new Uint8Array(p.length);for(let y=0;y<b.length;y++)b[y]=p.charCodeAt(y);const g=s==="image/png"?ae(b,o,d):C(b,o),S=window.btoa(String.fromCharCode(...g));l=[u,",",S,w].join("")}return n.timeEnd("canvas to data url"),l})}function Pe(e,t){return E(this,null,function*(){const r=yield R(e,t),{width:n,height:a,ownerDocument:s}=r,o=yield B(r),c=fe(n,a,s),l=c.ownerDocument.createElementNS(c.namespaceURI,"image");return l.setAttributeNS(null,"href",o),l.setAttributeNS(null,"height","100%"),l.setAttributeNS(null,"width","100%"),c.appendChild(l),de(c,r.isEnable("removeControlCharacter"))})}function zt(e,t){return E(this,null,function*(){const r=yield R(e,t),{ownerDocument:n,width:a,height:s,scale:o,type:c}=r,l=c==="image/svg+xml"?yield Pe(r):yield B(r),u=U(l,n);return u.width=Math.floor(a*o),u.height=Math.floor(s*o),u.style.width=`${a}px`,u.style.height=`${s}px`,u})}function Xt(e,t){return E(this,null,function*(){return B(yield R(e,L(x({},t),{type:"image/jpeg"})))})}function Gt(e,t){return E(this,null,function*(){const r=yield R(e,t),n=yield K(r);return n.getContext("2d").getImageData(0,0,n.width,n.height).data})}function Yt(e,t){return E(this,null,function*(){return B(yield R(e,L(x({},t),{type:"image/png"})))})}function Jt(e,t){return E(this,null,function*(){return B(yield R(e,L(x({},t),{type:"image/webp"})))})}h.createContext=pe,h.destroyContext=Ae,h.domToBlob=Ht,h.domToCanvas=K,h.domToDataUrl=B,h.domToForeignObjectSvg=Fe,h.domToImage=zt,h.domToJpeg=Xt,h.domToPixel=Gt,h.domToPng=Yt,h.domToSvg=Pe,h.domToWebp=Jt,h.loadMedia=$,h.waitUntilLoad=ge,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
`}),o.appendChild(n.createTextNode(A))}a.timeEnd("clone node"),d==null||d(p),u!==!1&&k(p)&&(a.time("embed web font"),yield _t(p,r),a.timeEnd("embed web font")),a.time("embed node"),De(p,r);const b=s.length;let g=0;const S=()=>E(this,null,function*(){for(;;){const A=s.pop();if(!A)break;try{yield A}catch(I){v("Failed to run task",I)}i==null||i(++g,b)}});i==null||i(g,b),yield Promise.all([...Array(4)].map(S)),a.timeEnd("embed node"),m==null||m(p);const y=Vt(p,r);return c&&y.insertBefore(c,y.children[0]),o&&y.insertBefore(o,y.children[0]),f&&Ae(r),w==null||w(y),y})}function Vt(e,t){const{width:r,height:n}=t,a=fe(r,n,e.ownerDocument),s=a.ownerDocument.createElementNS(a.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(e),a.appendChild(s),a}function J(e,t){return E(this,null,function*(){var o;const r=yield R(e,t),n=yield Fe(r),a=de(n,r.isEnable("removeControlCharacter"));r.autoDestruct||(r.svgStyleElement=ye(r.ownerDocument),r.svgDefsElement=(o=r.ownerDocument)==null?void 0:o.createElementNS(Y,"defs"),r.svgStyles.clear());const s=U(a,n.ownerDocument);return yield pt(s,r)})}function Ht(e,t){return E(this,null,function*(){const r=yield R(e,t),{log:n,type:a,quality:s,dpi:o}=r,c=yield J(r);n.time("canvas to blob");const l=yield ut(c,a,s);if(["image/png","image/jpeg"].includes(a)&&o){const u=yield mt(l.slice(0,33));let i=new Uint8Array(u);return a==="image/png"?i=ae(i,o):a==="image/jpeg"&&(i=C(i,o)),n.timeEnd("canvas to blob"),new Blob([i,l.slice(33)],{type:a})}return n.timeEnd("canvas to blob"),l})}function B(e,t){return E(this,null,function*(){const r=yield R(e,t),{log:n,quality:a,type:s,dpi:o}=r,c=yield J(r);n.time("canvas to data url");let l=c.toDataURL(s,a);if(["image/png","image/jpeg"].includes(s)&&o&&se&&Xe){const[u,i]=l.split(",");let f=0,d=!1;if(s==="image/png"){const y=He(i);y>=0?(f=Math.ceil((y+28)/3)*4,d=!0):f=33/3*4}else s==="image/jpeg"&&(f=18/3*4);const m=i.substring(0,f),w=i.substring(f),p=window.atob(m),b=new Uint8Array(p.length);for(let y=0;y<b.length;y++)b[y]=p.charCodeAt(y);const g=s==="image/png"?ae(b,o,d):C(b,o),S=window.btoa(String.fromCharCode(...g));l=[u,",",S,w].join("")}return n.timeEnd("canvas to data url"),l})}function Pe(e,t){return E(this,null,function*(){const r=yield R(e,t),{width:n,height:a,ownerDocument:s}=r,o=yield B(r),c=fe(n,a,s),l=c.ownerDocument.createElementNS(c.namespaceURI,"image");return l.setAttributeNS(null,"href",o),l.setAttributeNS(null,"height","100%"),l.setAttributeNS(null,"width","100%"),c.appendChild(l),de(c,r.isEnable("removeControlCharacter"))})}function zt(e,t){return E(this,null,function*(){const r=yield R(e,t),{ownerDocument:n,width:a,height:s,scale:o,type:c}=r,l=c==="image/svg+xml"?yield Pe(r):yield B(r),u=U(l,n);return u.width=Math.floor(a*o),u.height=Math.floor(s*o),u.style.width=`${a}px`,u.style.height=`${s}px`,u})}function Xt(e,t){return E(this,null,function*(){return B(yield R(e,L(x({},t),{type:"image/jpeg"})))})}function Gt(e,t){return E(this,null,function*(){const r=yield R(e,t),n=yield J(r);return n.getContext("2d").getImageData(0,0,n.width,n.height).data})}function Yt(e,t){return E(this,null,function*(){return B(yield R(e,L(x({},t),{type:"image/png"})))})}function Jt(e,t){return E(this,null,function*(){return B(yield R(e,L(x({},t),{type:"image/webp"})))})}h.createContext=pe,h.destroyContext=Ae,h.domToBlob=Ht,h.domToCanvas=J,h.domToDataUrl=B,h.domToForeignObjectSvg=Fe,h.domToImage=zt,h.domToJpeg=Xt,h.domToPixel=Gt,h.domToPng=Yt,h.domToSvg=Pe,h.domToWebp=Jt,h.loadMedia=$,h.waitUntilLoad=ge,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
{
"name": "modern-screenshot",
"type": "module",
"version": "4.4.37",
"version": "4.4.38",
"packageManager": "pnpm@8.7.6",

@@ -6,0 +6,0 @@ "description": "Quickly generate image from DOM node using HTML5 canvas and SVG",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc