diff --git a/lib/single-file-bootstrap.js b/lib/single-file-bootstrap.js index ec3e42529..2e780968d 100644 --- a/lib/single-file-bootstrap.js +++ b/lib/single-file-bootstrap.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefileBootstrap={})}(this,(function(e){"use strict";const t="single-file-load-image",s="single-file-image-loaded",n=globalThis.browser,o=(e,t,s)=>globalThis.addEventListener(e,t,s),a=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},i=globalThis.CustomEvent,r=globalThis.document,l=globalThis.Document;let d;if(d=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,r instanceof l){o("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,d.set(JSON.stringify(s),t)})),o("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,d.delete(JSON.stringify(s))})),o("single-file-clear-fonts",(()=>d=new Map));let e=r.createElement("script");e.src="data:,("+function(){"undefined"==typeof globalThis&&(window.globalThis=window);const e=globalThis.document,t=globalThis.console,s=e=>globalThis.dispatchEvent(e),n=globalThis.CustomEvent,o=globalThis.FileReader,a=globalThis.Blob,i=t&&t.warn&&((...e)=>t.warn(...e))||(()=>{}),r="single-file-new-font-face",l="single-file-delete-font",d="single-file-clear-fonts",c={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"};if(globalThis.FontFace){const t=globalThis.FontFace;let o;globalThis.FontFace=function(){return o||(i("SingleFile is hooking the FontFace constructor, document.fonts.delete and document.fonts.clear to handle dynamically loaded fonts."),o=!0),m(...arguments).then((e=>s(new n(r,{detail:e})))),new t(...arguments)},globalThis.FontFace.toString=function(){return"function FontFace() { [native code] }"};const a=e.fonts.delete;e.fonts.delete=function(t){return m(t.family).then((e=>s(new n(l,{detail:e})))),a.call(e.fonts,t)},e.fonts.delete.toString=function(){return"function delete() { [native code] }"};const c=e.fonts.clear;e.fonts.clear=function(){return s(new n(d)),c.call(e.fonts)},e.fonts.clear.toString=function(){return"function clear() { [native code] }"}}async function m(e,t,s){const n={};return n["font-family"]=e,n.src=t,s&&Object.keys(s).forEach((e=>{c[e]&&(n[c[e]]=s[e])})),new Promise((e=>{if(n.src instanceof ArrayBuffer){const t=new o;t.readAsDataURL(new a([n.src])),t.addEventListener("load",(()=>{n.src="url("+t.result+")",e(n)}))}else e(n)}))}}.toString()+")()",(r.documentElement||r).appendChild(e),e.remove(),n&&n.runtime&&n.runtime.getURL&&(e=r.createElement("script"),e.src=n.runtime.getURL("/lib/single-file-hooks-frames.js"),e.async=!1,(r.documentElement||r).appendChild(e),e.remove())}const c=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig");const m="single-file-on-before-capture",u="single-file-on-after-capture",g="data-single-file-removed-content",f="data-single-file-hidden-content",p="data-single-file-kept-content",h="data-single-file-hidden-frame",b="data-single-file-preserved-space-element",y="data-single-file-shadow-root-element",E="data-single-file-image",T="data-single-file-poster",w="data-single-file-video",I="data-single-file-canvas",A="data-single-file-movable-style",v="data-single-file-input-value",N="data-single-file-lazy-loaded-src",S="data-single-file-stylesheet",R="data-single-file-disabled-noscript",F="data-single-file-async-script",C="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",_=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD"],P=/^'(.*?)'$/,x=/^"(.*?)"$/,M={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},O="single-file-ui-element",D="data:,",L=(e,t,s)=>globalThis.addEventListener(e,t,s);function k(e,t,s){e.querySelectorAll("noscript:not([data-single-file-disabled-noscript])").forEach((e=>{e.setAttribute(R,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(C).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+C+", html > body > "+C);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const n=new Map;let o;return t&&e.documentElement?(e.querySelectorAll("button button, a a, p div").forEach((t=>{const s=e.createElement("template");s.setAttribute("data-single-file-invalid-element",""),s.content.appendChild(t.cloneNode(!0)),n.set(t,s),t.replaceWith(s)})),o=q(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=t.getComputedStyle(e);s&&B(e,s)&&(e.setAttribute(A,""),o.markedElements.push(e))}))):o={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:o.canvases,fonts:Array.from(d.values()),stylesheets:W(e),images:o.images,posters:o.posters,videos:o.videos,usedFonts:Array.from(o.usedFonts.values()),shadowRoots:o.shadowRoots,referrer:e.referrer,markedElements:o.markedElements,invalidElements:n}}function q(e,t,s,n,o={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},a){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let i,r,l;if(!n.autoSaveExternalSave&&(n.removeHiddenElements||n.removeUnusedFonts||n.compressHTML)&&(l=e.getComputedStyle(s),s instanceof e.HTMLElement&&n.removeHiddenElements&&(r=(a||s.closest("html > head"))&&_.includes(s.tagName)||s.closest("details"),r||(i=a||B(s,l),i&&(s.setAttribute(f,""),o.markedElements.push(s)))),!i)){if(n.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(b,""),o.markedElements.push(s))}n.removeUnusedFonts&&(U(l,n,o.usedFonts),U(e.getComputedStyle(s,":first-letter"),n,o.usedFonts),U(e.getComputedStyle(s,":before"),n,o.usedFonts),U(e.getComputedStyle(s,":after"),n,o.usedFonts))}!function(e,t,s,n,o,a,i){if("CANVAS"==s.tagName)try{o.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(I,o.canvases.length-1),o.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:a?D:n.loadDeferredImages&&s.getAttribute(N)||s.currentSrc};o.images.push(t),s.setAttribute(E,o.images.length-1),o.markedElements.push(s),s.removeAttribute(N);try{i=i||e.getComputedStyle(s)}catch(e){}if(i){t.size=function(e,t,s){let n=t.naturalWidth,o=t.naturalHeight;if(!n&&!o){const a=null==t.getAttribute("style");let i,r,l,d,c,m,u,g,f=!1;if("content-box"==(s=s||e.getComputedStyle(t)).getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),n=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),f=t.clientWidth!=n,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}i=j("padding-left",s),r=j("padding-right",s),l=j("padding-top",s),d=j("padding-bottom",s),f?(c=j("border-left-width",s),m=j("border-right-width",s),u=j("border-top-width",s),g=j("border-bottom-width",s)):c=m=u=g=0,n=Math.max(0,t.clientWidth-i-r-c-m),o=Math.max(0,t.clientHeight-l-d-u-g),a&&t.removeAttribute("style")}return{pxWidth:n,pxHeight:o}}(e,s,i);const n=i.getPropertyValue("box-shadow"),o=i.getPropertyValue("background-image");n&&"none"!=n||o&&"none"!=o||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=i.getPropertyValue("background-color"),t.objectFit=i.getPropertyValue("object-fit"),t.boxSizing=i.getPropertyValue("box-sizing"),t.objectPosition=i.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const n=s.currentSrc;if(n&&!n.startsWith("blob:")&&!n.startsWith("data:")){const t=e.getComputedStyle(s.parentNode).getPropertyValue("position");o.videos.push({positionParent:t,src:n,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(w,o.videos.length-1)}if(!s.poster){const e=t.createElement("canvas"),n=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{n.drawImage(s,0,0,e.width,e.height),o.posters.push(e.toDataURL("image/png","")),s.setAttribute(T,o.posters.length-1),o.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&a&&n.removeHiddenElements&&(s.setAttribute(h,""),o.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(v,s.value),o.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(v,s.checked),o.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(v,s.value),o.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(v,""),o.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(F,""),o.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,n,o,i,l);const d=!(s instanceof e.SVGElement)&&H(s);if(d&&!s.classList.contains(O)){const a={};s.setAttribute(y,o.shadowRoots.length),o.markedElements.push(s),o.shadowRoots.push(a),q(e,t,d,n,o,i),a.content=d.innerHTML,a.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(a.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}q(e,t,s,n,o,i),!n.autoSaveExternalSave&&n.removeHiddenElements&&a&&(r||""==s.getAttribute(p)?s.parentElement&&(s.parentElement.setAttribute(p,""),o.markedElements.push(s.parentElement)):i&&(s.setAttribute(g,""),o.markedElements.push(s)))})),o}function U(e,t,s){if(e){const n=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((o=>{if(o=V(o),!t.loadedFonts||t.loadedFonts.find((e=>V(e.family)==o&&e.style==n))){const t=(a=e.getPropertyValue("font-weight"),M[a.toLowerCase().trim()]||a),i=e.getPropertyValue("font-variant")||"normal",r=[o,t,n,i];s.set(JSON.stringify(r),[o,t,n,i])}var a}))}}function H(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function V(e=""){return function(e){e=e.match(P)?e.replace(P,"$1"):e.replace(x,"$1");return e.trim()}((t=e.trim(),t.replace(c,((e,t,s)=>{const n="0x"+t-65536;return n!=n||s?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)})))).toLowerCase();var t}function B(e,t){let s=!1;if(t){const n=t.getPropertyValue("display"),o=t.getPropertyValue("opacity"),a=t.getPropertyValue("visibility");if(s="none"==n,!s&&("0"==o||"hidden"==a)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function z(e,t,s){if(e.querySelectorAll("[data-single-file-disabled-noscript]").forEach((e=>{e.textContent=e.getAttribute(R),e.removeAttribute(R)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[g,h,f,b,E,T,w,I,v,y,S,F];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(g),e.removeAttribute(f),e.removeAttribute(p),e.removeAttribute(h),e.removeAttribute(b),e.removeAttribute(E),e.removeAttribute(T),e.removeAttribute(w),e.removeAttribute(I),e.removeAttribute(v),e.removeAttribute(y),e.removeAttribute(S),e.removeAttribute(F),e.removeAttribute(A)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))}function W(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,n)=>{try{const o=e.createElement("style");o.textContent=s.textContent,e.body.appendChild(o);const a=o.sheet;o.remove(),a&&a.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(S,n),t[n]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function j(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}const J=N,G=O,Y="attributes",$=globalThis.browser,K=globalThis.document,X=globalThis.MutationObserver,Q=(e,t,s)=>globalThis.addEventListener(e,t,s),Z=(e,t,s)=>globalThis.removeEventListener(e,t,s),ee=new Map;let te;async function se(e){if(K.documentElement){ee.clear();const n=Math.max(K.documentElement.scrollHeight-1.5*K.documentElement.clientHeight,0),o=Math.max(K.documentElement.scrollWidth-1.5*K.documentElement.clientWidth,0);if(globalThis.scrollY<=n&&globalThis.scrollX<=o)return function(e){return te=0,new Promise((async n=>{let o;const r=new Set,l=new X((async t=>{if((t=t.filter((e=>e.type==Y))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(J,e.target.src),e.target.addEventListener("load",c)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(G)})).length&&(o=!0,await oe(l,e,g),r.size||await ne(l,e,g))}}));async function d(t){await ie("idleTimeout",(async()=>{o?te<10&&(te++,le("idleTimeout"),await d(Math.max(500,t/2))):(le("loadTimeout"),le("maxTimeout"),ae(l,e,g))}),t)}function c(e){const t=e.target;t.removeAttribute(J),t.removeEventListener("load",c)}async function m(t){o=!0,await oe(l,e,g),await ne(l,e,g),t.detail&&r.add(t.detail)}async function u(t){await oe(l,e,g),await ne(l,e,g),r.delete(t.detail),r.size||await ne(l,e,g)}function g(e){l.disconnect(),Z(t,m),Z(s,u),n(e)}await d(2*e.loadDeferredImagesMaxIdleTime),await oe(l,e,g),l.observe(K,{subtree:!0,childList:!0,attributes:!0}),Q(t,m),Q(s,u),function(e){e.loadDeferredImagesBlockCookies&&a(new i("single-file-block-cookies-start")),e.loadDeferredImagesBlockStorage&&a(new i("single-file-block-storage-start")),e.loadDeferredImagesDispatchScrollEvent&&a(new i("single-file-dispatch-scroll-event-start")),e.loadDeferredImagesKeepZoomLevel?a(new i("single-file-load-deferred-images-keep-zoom-level-start")):a(new i("single-file-load-deferred-images-start"))}(e)}))}(e)}}async function ne(e,t,s){await ie("loadTimeout",(()=>ae(e,t,s)),t.loadDeferredImagesMaxIdleTime)}async function oe(e,t,s){await ie("maxTimeout",(async()=>{await le("loadTimeout"),await ae(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime)}async function ae(e,t,s){await le("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&a(new i("single-file-block-cookies-end")),e.loadDeferredImagesBlockStorage&&a(new i("single-file-block-storage-end")),e.loadDeferredImagesDispatchScrollEvent&&a(new i("single-file-dispatch-scroll-event-end")),e.loadDeferredImagesKeepZoomLevel?a(new i("single-file-load-deferred-images-keep-zoom-level-end")):a(new i("single-file-load-deferred-images-end"))}(t),await ie("endTimeout",(async()=>{await le("maxTimeout"),s()}),t.loadDeferredImagesMaxIdleTime/2),e.disconnect()}async function ie(e,t,s){if($&&$.runtime&&$.runtime.sendMessage){if(!ee.get(e)||!ee.get(e).pending){const n={callback:t,pending:!0};ee.set(e,n);try{await $.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(n){re(e,t,s)}n.pending=!1}}else re(e,t,s)}function re(e,t,s){const n=ee.get(e);n&&globalThis.clearTimeout(n),ee.set(e,t),globalThis.setTimeout(t,s)}async function le(e){if($&&$.runtime&&$.runtime.sendMessage)try{await $.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){de(e)}else de(e)}function de(e){const t=ee.get(e);ee.delete(e),t&&globalThis.clearTimeout(t)}$&&$.runtime&&$.runtime.onMessage&&$.runtime.onMessage.addListener&&$.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=ee.get(e.type);if(t){ee.delete(e.type);try{t.callback()}catch(t){de(e.type)}}}}));const ce={ON_BEFORE_CAPTURE_EVENT_NAME:m,ON_AFTER_CAPTURE_EVENT_NAME:u,WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:k,serialize:function(e){const t=e.doctype;let s="";return t&&(s=" "),s+e.documentElement.outerHTML},postProcessDoc:z,getShadowRoot:H},me="__frameTree__::",ue='iframe, frame, object[type="text/html"][data]',ge="singlefile.frameTree.initRequest",fe="singlefile.frameTree.ackInitRequest",pe="singlefile.frameTree.cleanupRequest",he="singlefile.frameTree.initResponse",be=5e3,ye=".",Ee=globalThis.window==globalThis.top,Te=globalThis.browser,we=globalThis.top,Ie=globalThis.MessageChannel,Ae=globalThis.document;let ve,Ne=globalThis.sessions;var Se,Re,Fe;function Ce(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function _e(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Ee||(ve=globalThis.frameId=e.windowId),Me(Ae,e.options,ve,t),Ee||(e.options.userScriptEnabled&&s&&await s(ce.ON_BEFORE_CAPTURE_EVENT_NAME),ke({frames:[Ue(Ae,globalThis,ve,e.options)],sessionId:t,requestedFrameId:Ae.documentElement.dataset.requestedFrameId&&ve}),e.options.userScriptEnabled&&s&&await s(ce.ON_AFTER_CAPTURE_EVENT_NAME),delete Ae.documentElement.dataset.requestedFrameId)}function Pe(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;Le(He(Ae),e.windowId,t)}}function xe(e){e.frames.forEach((t=>Oe("responseTimeouts",e.sessionId,t.windowId)));const t=Ne.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(ye).length-e.windowId.split(ye).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Me(e,t,s,n){const o=He(e);!function(e,t,s,n,o){const a=[];let i;Ne.get(o)?i=Ne.get(o).requestTimeouts:(i={},Ne.set(o,{requestTimeouts:i}));t.forEach(((e,t)=>{const s=n+ye+t;e.setAttribute(ce.WIN_ID_ATTRIBUTE_NAME,s),a.push({windowId:s})})),ke({frames:a,sessionId:o,requestedFrameId:e.documentElement.dataset.requestedFrameId&&n}),t.forEach(((e,t)=>{const a=n+ye+t;try{qe(e.contentWindow,{method:ge,windowId:a,sessionId:o,options:s})}catch(e){}i[a]=globalThis.setTimeout((()=>ke({frames:[{windowId:a,processed:!0}],sessionId:o})),be)})),delete e.documentElement.dataset.requestedFrameId}(e,o,t,s,n),o.length&&function(e,t,s,n,o){const a=[];t.forEach(((e,t)=>{const i=n+ye+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Oe("requestTimeouts",o,i),Me(r,s,i,o),a.push(Ue(r,t,i,s))}catch(e){a.push({windowId:i,processed:!0})}})),ke({frames:a,sessionId:o,requestedFrameId:e.documentElement.dataset.requestedFrameId&&n}),delete e.documentElement.dataset.requestedFrameId}(e,o,t,s,n)}function Oe(e,t,s){const n=Ne.get(t);if(n&&n[e]){const t=n[e][s];t&&(globalThis.clearTimeout(t),delete n[e][s])}}function De(e,t){const s=Ne.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>ke({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function Le(e,t,s){e.forEach(((e,n)=>{const o=t+ye+n;e.removeAttribute(ce.WIN_ID_ATTRIBUTE_NAME);try{qe(e.contentWindow,{method:pe,windowId:o,sessionId:s})}catch(e){}})),e.forEach(((e,n)=>{const o=t+ye+n;let a;try{a=e.contentDocument}catch(e){}if(a)try{Le(He(a),o,s)}catch(e){}}))}function ke(e){e.method=he;try{we.singlefile.processors.frameTree.initResponse(e)}catch(t){qe(we,e,!0)}}function qe(e,t,s){if(e==we&&Te&&Te.runtime&&Te.runtime.sendMessage)Te.runtime.sendMessage(t);else if(s){const s=new Ie;e.postMessage(me+JSON.stringify({method:t.method,sessionId:t.sessionId}),"*",[s.port2]),s.port1.postMessage(t)}else e.postMessage(me+JSON.stringify(t),"*")}function Ue(e,t,s,n){const o=ce.preProcessDoc(e,t,n),a=ce.serialize(e);ce.postProcessDoc(e,o.markedElements,o.invalidElements);return{windowId:s,content:a,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:o.canvases,fonts:o.fonts,stylesheets:o.stylesheets,images:o.images,posters:o.posters,videos:o.videos,usedFonts:o.usedFonts,shadowRoots:o.shadowRoots,processed:!0}}function He(e){let t=Array.from(e.querySelectorAll(ue));return e.querySelectorAll("*").forEach((e=>{const s=ce.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(ue)))})),t}Ne||(Ne=globalThis.sessions=new Map),Ee&&(ve="0",Te&&Te.runtime&&Te.runtime.onMessage&&Te.runtime.onMessage.addListener&&Te.runtime.onMessage.addListener((e=>e.method==he?(xe(e),Promise.resolve({})):e.method==fe?(Oe("requestTimeouts",e.sessionId,e.windowId),De(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Se="message",Re=async e=>{if("string"==typeof e.data&&e.data.startsWith(me)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(me.length));t.method==ge?(e.source&&qe(e.source,{method:fe,windowId:t.windowId,sessionId:t.sessionId}),Ee||(globalThis.stop(),t.options.loadDeferredImages&&se(t.options),await _e(t))):t.method==fe?(Oe("requestTimeouts",t.sessionId,t.windowId),De(t.sessionId,t.windowId)):t.method==pe?Pe(t):t.method==he&&Ne.get(t.sessionId)&&(e.ports[0].onmessage=e=>xe(e.data))}},Fe=!0,globalThis.addEventListener(Se,Re,Fe);var Ve=Object.freeze({__proto__:null,getAsync:function(e){const t=Ce();return e=JSON.parse(JSON.stringify(e)),new Promise((s=>{Ne.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),_e({windowId:ve,sessionId:t,options:e})}))},getSync:function(e){const t=Ce();e=JSON.parse(JSON.stringify(e)),Ne.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Ee||(ve=globalThis.frameId=e.windowId);Me(Ae,e.options,ve,t),Ee||(e.options.userScriptEnabled&&s&&s(ce.ON_BEFORE_CAPTURE_EVENT_NAME),ke({frames:[Ue(Ae,globalThis,ve,e.options)],sessionId:t,requestedFrameId:Ae.documentElement.dataset.requestedFrameId&&ve}),e.options.userScriptEnabled&&s&&s(ce.ON_AFTER_CAPTURE_EVENT_NAME),delete Ae.documentElement.dataset.requestedFrameId)}({windowId:ve,sessionId:t,options:e});const s=Ne.get(t).frames;return s.sessionId=t,s},cleanup:function(e){Ne.delete(e),Pe({windowId:ve,sessionId:e,options:{sessionId:e}})},initResponse:xe,TIMEOUT_INIT_REQUEST_MESSAGE:be});const Be=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],ze=[{tagName:"head",accept:e=>!e.childNodes.length||1==e.childNodes[0].nodeType},{tagName:"body",accept:e=>!e.childNodes.length}],We=[{tagName:"html",accept:e=>!e||8!=e.nodeType},{tagName:"head",accept:e=>!e||8!=e.nodeType&&(3!=e.nodeType||!Ge(e.textContent))},{tagName:"body",accept:e=>!e||8!=e.nodeType},{tagName:"li",accept:(e,t)=>!e&&t.parentElement&&("UL"==t.parentElement.tagName||"OL"==t.parentElement.tagName)||e&&["LI"].includes(e.tagName)},{tagName:"dt",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"p",accept:e=>e&&["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"].includes(e.tagName)},{tagName:"dd",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"rt",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"rp",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"optgroup",accept:e=>!e||["OPTGROUP"].includes(e.tagName)},{tagName:"option",accept:e=>!e||["OPTION","OPTGROUP"].includes(e.tagName)},{tagName:"colgroup",accept:e=>!e||8!=e.nodeType&&(3!=e.nodeType||!Ge(e.textContent))},{tagName:"caption",accept:e=>!e||8!=e.nodeType&&(3!=e.nodeType||!Ge(e.textContent))},{tagName:"thead",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tbody",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tfoot",accept:e=>!e},{tagName:"tr",accept:e=>!e||["TR"].includes(e.tagName)},{tagName:"td",accept:e=>!e||["TD","TH"].includes(e.tagName)},{tagName:"th",accept:e=>!e||["TD","TH"].includes(e.tagName)}],je=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"];function Je(e,t,s){return 3==e.nodeType?function(e){const t=e.parentNode;let s;t&&1==t.nodeType&&(s=t.tagName.toLowerCase());return!s||je.includes(s)?"script"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&").replace(/\u00a0/g," ").replace(//g,">")}(e):8==e.nodeType?"\x3c!--"+e.textContent+"--\x3e":1==e.nodeType?function(e,t,s){const n=e.tagName.toLowerCase(),o=t&&ze.find((t=>n==t.tagName&&t.accept(e)));let a="";o&&!e.attributes.length||(a="<"+n,Array.from(e.attributes).forEach((s=>a+=function(e,t,s){const n=e.name;let o="";if(!n.match(/["'>/=]/)){let a,i=e.value;s&&"class"==n&&(i=Array.from(t.classList).map((e=>e.trim())).join(" ")),i=i.replace(/&/g,"&").replace(/\u00a0/g," "),i.includes('"')&&(i.includes("'")||!s?i=i.replace(/"/g,"""):a=!0);const r=!s||!i.match(/^[^ \t\n\f\r'"`=<>]+$/);o+=" ",e.namespace?"http://www.w3.org/XML/1998/namespace"==e.namespaceURI?o+="xml:"+n:"http://www.w3.org/2000/xmlns/"==e.namespaceURI?("xmlns"!==n&&(o+="xmlns:"),o+=n):"http://www.w3.org/1999/xlink"==e.namespaceURI?o+="xlink:"+n:o+=n:o+=n,""!=i&&(o+="=",r&&(o+=a?"'":'"'),o+=i,r&&(o+=a?"'":'"'))}return o}(s,e,t))),a+=">");"TEMPLATE"!=e.tagName||e.childNodes.length?Array.from(e.childNodes).forEach((e=>a+=Je(e,t,s||"svg"==n))):a+=e.innerHTML;const i=t&&We.find((t=>n==t.tagName&&t.accept(e.nextSibling,e)));(s||!i&&!Be.includes(n))&&(a+="");return a}(e,t,s):void 0}function Ge(e){return Boolean(e.match(/^[ \t\n\f\r]/))}const Ye={frameTree:Ve},$e={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:m,ON_AFTER_CAPTURE_EVENT_NAME:u,preProcessDoc:k,postProcessDoc:z,serialize:(e,t)=>function(e,t){const s=e.doctype;let n="";return s&&(n=" "),n+Je(e.documentElement,t)}(e,t),getShadowRoot:H};L("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>L(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await s})),e.helper=$e,e.processors=Ye,Object.defineProperty(e,"__esModule",{value:!0})})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefileBootstrap={})}(this,(function(e){"use strict";const t="single-file-load-image",s="single-file-image-loaded",o=(e,t,s)=>globalThis.addEventListener(e,t,s),n=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},a=globalThis.CustomEvent,i=globalThis.document,r=globalThis.Document;let l;l=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,i instanceof r&&(o("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,l.set(JSON.stringify(s),t)})),o("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,l.delete(JSON.stringify(s))})),o("single-file-clear-fonts",(()=>l=new Map)));const d=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig");const c="single-file-on-before-capture",m="single-file-on-after-capture",u="data-single-file-removed-content",g="data-single-file-hidden-content",p="data-single-file-kept-content",f="data-single-file-hidden-frame",h="data-single-file-preserved-space-element",b="data-single-file-shadow-root-element",E="data-single-file-image",y="data-single-file-poster",T="data-single-file-video",w="data-single-file-canvas",I="data-single-file-movable-style",A="data-single-file-input-value",v="data-single-file-lazy-loaded-src",N="data-single-file-stylesheet",S="data-single-file-disabled-noscript",R="data-single-file-async-script",_="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",C=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD"],F=/^'(.*?)'$/,P=/^"(.*?)"$/,x={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},M="single-file-ui-element",O="data:,",D=(e,t,s)=>globalThis.addEventListener(e,t,s);function q(e,t,s){e.querySelectorAll("noscript:not([data-single-file-disabled-noscript])").forEach((e=>{e.setAttribute(S,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(_).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+_+", html > body > "+_);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a, p div").forEach((t=>{const s=e.createElement("template");s.setAttribute("data-single-file-invalid-element",""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=L(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=t.getComputedStyle(e);s&&V(e,s)&&(e.setAttribute(I,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(l.values()),stylesheets:B(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}}function L(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},a){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let i,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=e.getComputedStyle(s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(a||s.closest("html > head"))&&C.includes(s.tagName)||s.closest("details"),r||(i=a||V(s,l),i&&(s.setAttribute(g,""),n.markedElements.push(s)))),!i)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(h,""),n.markedElements.push(s))}o.removeUnusedFonts&&(k(l,o,n.usedFonts),k(e.getComputedStyle(s,":first-letter"),o,n.usedFonts),k(e.getComputedStyle(s,":before"),o,n.usedFonts),k(e.getComputedStyle(s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,a,i){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(w,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:a?O:o.loadDeferredImages&&s.getAttribute(v)||s.currentSrc};n.images.push(t),s.setAttribute(E,n.images.length-1),n.markedElements.push(s),s.removeAttribute(v);try{i=i||e.getComputedStyle(s)}catch(e){}if(i){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const a=null==t.getAttribute("style");let i,r,l,d,c,m,u,g,p=!1;if("content-box"==(s=s||e.getComputedStyle(t)).getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),p=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}i=W("padding-left",s),r=W("padding-right",s),l=W("padding-top",s),d=W("padding-bottom",s),p?(c=W("border-left-width",s),m=W("border-right-width",s),u=W("border-top-width",s),g=W("border-bottom-width",s)):c=m=u=g=0,o=Math.max(0,t.clientWidth-i-r-c-m),n=Math.max(0,t.clientHeight-l-d-u-g),a&&t.removeAttribute("style")}return{pxWidth:o,pxHeight:n}}(e,s,i);const o=i.getPropertyValue("box-shadow"),n=i.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=i.getPropertyValue("background-color"),t.objectFit=i.getPropertyValue("object-fit"),t.boxSizing=i.getPropertyValue("box-sizing"),t.objectPosition=i.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=e.getComputedStyle(s.parentNode).getPropertyValue("position");n.videos.push({positionParent:t,src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(T,n.videos.length-1)}if(!s.poster){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(y,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&a&&o.removeHiddenElements&&(s.setAttribute(f,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(A,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(A,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(A,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(A,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(R,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,i,l);const d=!(s instanceof e.SVGElement)&&U(s);if(d&&!s.classList.contains(M)){const a={};s.setAttribute(b,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(a),L(e,t,d,o,n,i),a.content=d.innerHTML,a.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(a.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}L(e,t,s,o,n,i),!o.autoSaveExternalSave&&o.removeHiddenElements&&a&&(r||""==s.getAttribute(p)?s.parentElement&&(s.parentElement.setAttribute(p,""),n.markedElements.push(s.parentElement)):i&&(s.setAttribute(u,""),n.markedElements.push(s)))})),n}function k(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=H(n),!t.loadedFonts||t.loadedFonts.find((e=>H(e.family)==n&&e.style==o))){const t=(a=e.getPropertyValue("font-weight"),x[a.toLowerCase().trim()]||a),i=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,i];s.set(JSON.stringify(r),[n,t,o,i])}var a}))}}function U(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function H(e=""){return function(e){e=e.match(F)?e.replace(F,"$1"):e.replace(P,"$1");return e.trim()}((t=e.trim(),t.replace(d,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function V(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),a=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==a)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function z(e,t,s){if(e.querySelectorAll("[data-single-file-disabled-noscript]").forEach((e=>{e.textContent=e.getAttribute(S),e.removeAttribute(S)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[u,f,g,h,E,y,T,w,A,b,N,R];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(u),e.removeAttribute(g),e.removeAttribute(p),e.removeAttribute(f),e.removeAttribute(h),e.removeAttribute(E),e.removeAttribute(y),e.removeAttribute(T),e.removeAttribute(w),e.removeAttribute(A),e.removeAttribute(b),e.removeAttribute(N),e.removeAttribute(R),e.removeAttribute(I)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))}function B(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const a=n.sheet;n.remove(),a&&a.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(N,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function W(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}const j=v,J=M,G="attributes",Y=globalThis.browser,$=globalThis.document,K=globalThis.MutationObserver,X=(e,t,s)=>globalThis.addEventListener(e,t,s),Q=(e,t,s)=>globalThis.removeEventListener(e,t,s),Z=new Map;let ee;async function te(e){if($.documentElement){Z.clear();const o=Math.max($.documentElement.scrollHeight-1.5*$.documentElement.clientHeight,0),i=Math.max($.documentElement.scrollWidth-1.5*$.documentElement.clientWidth,0);if(globalThis.scrollY<=o&&globalThis.scrollX<=i)return function(e){return ee=0,new Promise((async o=>{let i;const r=new Set,l=new K((async t=>{if((t=t.filter((e=>e.type==G))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(j,e.target.src),e.target.addEventListener("load",c)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(J)})).length&&(i=!0,await oe(l,e,g),r.size||await se(l,e,g))}}));async function d(t){await ae("idleTimeout",(async()=>{i?ee<10&&(ee++,re("idleTimeout"),await d(Math.max(500,t/2))):(re("loadTimeout"),re("maxTimeout"),ne(l,e,g))}),t)}function c(e){const t=e.target;t.removeAttribute(j),t.removeEventListener("load",c)}async function m(t){i=!0,await oe(l,e,g),await se(l,e,g),t.detail&&r.add(t.detail)}async function u(t){await oe(l,e,g),await se(l,e,g),r.delete(t.detail),r.size||await se(l,e,g)}function g(e){l.disconnect(),Q(t,m),Q(s,u),o(e)}await d(2*e.loadDeferredImagesMaxIdleTime),await oe(l,e,g),l.observe($,{subtree:!0,childList:!0,attributes:!0}),X(t,m),X(s,u),function(e){e.loadDeferredImagesBlockCookies&&n(new a("single-file-block-cookies-start")),e.loadDeferredImagesBlockStorage&&n(new a("single-file-block-storage-start")),e.loadDeferredImagesDispatchScrollEvent&&n(new a("single-file-dispatch-scroll-event-start")),e.loadDeferredImagesKeepZoomLevel?n(new a("single-file-load-deferred-images-keep-zoom-level-start")):n(new a("single-file-load-deferred-images-start"))}(e)}))}(e)}}async function se(e,t,s){await ae("loadTimeout",(()=>ne(e,t,s)),t.loadDeferredImagesMaxIdleTime)}async function oe(e,t,s){await ae("maxTimeout",(async()=>{await re("loadTimeout"),await ne(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime)}async function ne(e,t,s){await re("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&n(new a("single-file-block-cookies-end")),e.loadDeferredImagesBlockStorage&&n(new a("single-file-block-storage-end")),e.loadDeferredImagesDispatchScrollEvent&&n(new a("single-file-dispatch-scroll-event-end")),e.loadDeferredImagesKeepZoomLevel?n(new a("single-file-load-deferred-images-keep-zoom-level-end")):n(new a("single-file-load-deferred-images-end"))}(t),await ae("endTimeout",(async()=>{await re("maxTimeout"),s()}),t.loadDeferredImagesMaxIdleTime/2),e.disconnect()}async function ae(e,t,s){if(Y&&Y.runtime&&Y.runtime.sendMessage){if(!Z.get(e)||!Z.get(e).pending){const o={callback:t,pending:!0};Z.set(e,o);try{await Y.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){ie(e,t,s)}o.pending=!1}}else ie(e,t,s)}function ie(e,t,s){const o=Z.get(e);o&&globalThis.clearTimeout(o),Z.set(e,t),globalThis.setTimeout(t,s)}async function re(e){if(Y&&Y.runtime&&Y.runtime.sendMessage)try{await Y.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){le(e)}else le(e)}function le(e){const t=Z.get(e);Z.delete(e),t&&globalThis.clearTimeout(t)}Y&&Y.runtime&&Y.runtime.onMessage&&Y.runtime.onMessage.addListener&&Y.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Z.get(e.type);if(t){Z.delete(e.type);try{t.callback()}catch(t){le(e.type)}}}}));const de={ON_BEFORE_CAPTURE_EVENT_NAME:c,ON_AFTER_CAPTURE_EVENT_NAME:m,WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:q,serialize:function(e){const t=e.doctype;let s="";return t&&(s=" "),s+e.documentElement.outerHTML},postProcessDoc:z,getShadowRoot:U},ce="__frameTree__::",me='iframe, frame, object[type="text/html"][data]',ue="singlefile.frameTree.initRequest",ge="singlefile.frameTree.ackInitRequest",pe="singlefile.frameTree.cleanupRequest",fe="singlefile.frameTree.initResponse",he=5e3,be=".",Ee=globalThis.window==globalThis.top,ye=globalThis.browser,Te=globalThis.top,we=globalThis.MessageChannel,Ie=globalThis.document;let Ae,ve=globalThis.sessions;var Ne,Se,Re;function _e(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ce(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Ee||(Ae=globalThis.frameId=e.windowId),xe(Ie,e.options,Ae,t),Ee||(e.options.userScriptEnabled&&s&&await s(de.ON_BEFORE_CAPTURE_EVENT_NAME),qe({frames:[ke(Ie,globalThis,Ae,e.options)],sessionId:t,requestedFrameId:Ie.documentElement.dataset.requestedFrameId&&Ae}),e.options.userScriptEnabled&&s&&await s(de.ON_AFTER_CAPTURE_EVENT_NAME),delete Ie.documentElement.dataset.requestedFrameId)}function Fe(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;De(Ue(Ie),e.windowId,t)}}function Pe(e){e.frames.forEach((t=>Me("responseTimeouts",e.sessionId,t.windowId)));const t=ve.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(be).length-e.windowId.split(be).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function xe(e,t,s,o){const n=Ue(e);!function(e,t,s,o,n){const a=[];let i;ve.get(n)?i=ve.get(n).requestTimeouts:(i={},ve.set(n,{requestTimeouts:i}));t.forEach(((e,t)=>{const s=o+be+t;e.setAttribute(de.WIN_ID_ATTRIBUTE_NAME,s),a.push({windowId:s})})),qe({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const a=o+be+t;try{Le(e.contentWindow,{method:ue,windowId:a,sessionId:n,options:s})}catch(e){}i[a]=globalThis.setTimeout((()=>qe({frames:[{windowId:a,processed:!0}],sessionId:n})),he)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const a=[];t.forEach(((e,t)=>{const i=o+be+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Me("requestTimeouts",n,i),xe(r,s,i,n),a.push(ke(r,t,i,s))}catch(e){a.push({windowId:i,processed:!0})}})),qe({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Me(e,t,s){const o=ve.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function Oe(e,t){const s=ve.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>qe({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function De(e,t,s){e.forEach(((e,o)=>{const n=t+be+o;e.removeAttribute(de.WIN_ID_ATTRIBUTE_NAME);try{Le(e.contentWindow,{method:pe,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+be+o;let a;try{a=e.contentDocument}catch(e){}if(a)try{De(Ue(a),n,s)}catch(e){}}))}function qe(e){e.method=fe;try{Te.singlefile.processors.frameTree.initResponse(e)}catch(t){Le(Te,e,!0)}}function Le(e,t,s){if(e==Te&&ye&&ye.runtime&&ye.runtime.sendMessage)ye.runtime.sendMessage(t);else if(s){const s=new we;e.postMessage(ce+JSON.stringify({method:t.method,sessionId:t.sessionId}),"*",[s.port2]),s.port1.postMessage(t)}else e.postMessage(ce+JSON.stringify(t),"*")}function ke(e,t,s,o){const n=de.preProcessDoc(e,t,o),a=de.serialize(e);de.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:a,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function Ue(e){let t=Array.from(e.querySelectorAll(me));return e.querySelectorAll("*").forEach((e=>{const s=de.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(me)))})),t}ve||(ve=globalThis.sessions=new Map),Ee&&(Ae="0",ye&&ye.runtime&&ye.runtime.onMessage&&ye.runtime.onMessage.addListener&&ye.runtime.onMessage.addListener((e=>e.method==fe?(Pe(e),Promise.resolve({})):e.method==ge?(Me("requestTimeouts",e.sessionId,e.windowId),Oe(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Ne="message",Se=async e=>{if("string"==typeof e.data&&e.data.startsWith(ce)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(ce.length));t.method==ue?(e.source&&Le(e.source,{method:ge,windowId:t.windowId,sessionId:t.sessionId}),Ee||(globalThis.stop(),t.options.loadDeferredImages&&te(t.options),await Ce(t))):t.method==ge?(Me("requestTimeouts",t.sessionId,t.windowId),Oe(t.sessionId,t.windowId)):t.method==pe?Fe(t):t.method==fe&&ve.get(t.sessionId)&&(e.ports[0].onmessage=e=>Pe(e.data))}},Re=!0,globalThis.addEventListener(Ne,Se,Re);var He=Object.freeze({__proto__:null,getAsync:function(e){const t=_e();return e=JSON.parse(JSON.stringify(e)),new Promise((s=>{ve.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ce({windowId:Ae,sessionId:t,options:e})}))},getSync:function(e){const t=_e();e=JSON.parse(JSON.stringify(e)),ve.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Ee||(Ae=globalThis.frameId=e.windowId);xe(Ie,e.options,Ae,t),Ee||(e.options.userScriptEnabled&&s&&s(de.ON_BEFORE_CAPTURE_EVENT_NAME),qe({frames:[ke(Ie,globalThis,Ae,e.options)],sessionId:t,requestedFrameId:Ie.documentElement.dataset.requestedFrameId&&Ae}),e.options.userScriptEnabled&&s&&s(de.ON_AFTER_CAPTURE_EVENT_NAME),delete Ie.documentElement.dataset.requestedFrameId)}({windowId:Ae,sessionId:t,options:e});const s=ve.get(t).frames;return s.sessionId=t,s},cleanup:function(e){ve.delete(e),Fe({windowId:Ae,sessionId:e,options:{sessionId:e}})},initResponse:Pe,TIMEOUT_INIT_REQUEST_MESSAGE:he});const Ve=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],ze=[{tagName:"head",accept:e=>!e.childNodes.length||1==e.childNodes[0].nodeType},{tagName:"body",accept:e=>!e.childNodes.length}],Be=[{tagName:"html",accept:e=>!e||8!=e.nodeType},{tagName:"head",accept:e=>!e||8!=e.nodeType&&(3!=e.nodeType||!Je(e.textContent))},{tagName:"body",accept:e=>!e||8!=e.nodeType},{tagName:"li",accept:(e,t)=>!e&&t.parentElement&&("UL"==t.parentElement.tagName||"OL"==t.parentElement.tagName)||e&&["LI"].includes(e.tagName)},{tagName:"dt",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"p",accept:e=>e&&["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"].includes(e.tagName)},{tagName:"dd",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"rt",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"rp",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"optgroup",accept:e=>!e||["OPTGROUP"].includes(e.tagName)},{tagName:"option",accept:e=>!e||["OPTION","OPTGROUP"].includes(e.tagName)},{tagName:"colgroup",accept:e=>!e||8!=e.nodeType&&(3!=e.nodeType||!Je(e.textContent))},{tagName:"caption",accept:e=>!e||8!=e.nodeType&&(3!=e.nodeType||!Je(e.textContent))},{tagName:"thead",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tbody",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tfoot",accept:e=>!e},{tagName:"tr",accept:e=>!e||["TR"].includes(e.tagName)},{tagName:"td",accept:e=>!e||["TD","TH"].includes(e.tagName)},{tagName:"th",accept:e=>!e||["TD","TH"].includes(e.tagName)}],We=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"];function je(e,t,s){return 3==e.nodeType?function(e){const t=e.parentNode;let s;t&&1==t.nodeType&&(s=t.tagName.toLowerCase());return!s||We.includes(s)?"script"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&").replace(/\u00a0/g," ").replace(//g,">")}(e):8==e.nodeType?"\x3c!--"+e.textContent+"--\x3e":1==e.nodeType?function(e,t,s){const o=e.tagName.toLowerCase(),n=t&&ze.find((t=>o==t.tagName&&t.accept(e)));let a="";n&&!e.attributes.length||(a="<"+o,Array.from(e.attributes).forEach((s=>a+=function(e,t,s){const o=e.name;let n="";if(!o.match(/["'>/=]/)){let a,i=e.value;s&&"class"==o&&(i=Array.from(t.classList).map((e=>e.trim())).join(" ")),i=i.replace(/&/g,"&").replace(/\u00a0/g," "),i.includes('"')&&(i.includes("'")||!s?i=i.replace(/"/g,"""):a=!0);const r=!s||!i.match(/^[^ \t\n\f\r'"`=<>]+$/);n+=" ",e.namespace?"http://www.w3.org/XML/1998/namespace"==e.namespaceURI?n+="xml:"+o:"http://www.w3.org/2000/xmlns/"==e.namespaceURI?("xmlns"!==o&&(n+="xmlns:"),n+=o):"http://www.w3.org/1999/xlink"==e.namespaceURI?n+="xlink:"+o:n+=o:n+=o,""!=i&&(n+="=",r&&(n+=a?"'":'"'),n+=i,r&&(n+=a?"'":'"'))}return n}(s,e,t))),a+=">");"TEMPLATE"!=e.tagName||e.childNodes.length?Array.from(e.childNodes).forEach((e=>a+=je(e,t,s||"svg"==o))):a+=e.innerHTML;const i=t&&Be.find((t=>o==t.tagName&&t.accept(e.nextSibling,e)));(s||!i&&!Ve.includes(o))&&(a+="");return a}(e,t,s):void 0}function Je(e){return Boolean(e.match(/^[ \t\n\f\r]/))}const Ge={frameTree:He},Ye={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:c,ON_AFTER_CAPTURE_EVENT_NAME:m,preProcessDoc:q,postProcessDoc:z,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o=" "),o+je(e.documentElement,t)}(e,t),getShadowRoot:U};D("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>D(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await s})),e.helper=Ye,e.processors=Ge,Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/lib/single-file-extension-frames.js b/lib/single-file-extension-frames.js index ec33b632e..7f38a3d3d 100644 --- a/lib/single-file-extension-frames.js +++ b/lib/single-file-extension-frames.js @@ -1 +1 @@ -!function(){"use strict";const e="single-file-response-fetch";let r=new Map;function a(r){return new Promise(((a,t)=>{var s,n,i,d;s=new CustomEvent("single-file-request-fetch",{detail:r}),window.dispatchEvent(s),n=e,i=function s(n){var i,d,o;n.detail?n.detail.url==r&&(i=e,d=s,o=!1,window.removeEventListener(i,d,o),n.detail.response?a({status:n.detail.status,headers:new Map(n.detail.headers),arrayBuffer:async()=>n.detail.response}):t(n.detail.error)):t()},d=!1,window.addEventListener(n,i,d)}))}browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{let s=await(r=e.url,t={cache:"force-cache",headers:e.headers},window.fetch(r,t));return 401!=s.status&&403!=s.status&&404!=s.status||(s=await Promise.race([a(e.url),new Promise(((e,r)=>setTimeout((()=>r()),5e3)))])),{status:s.status,headers:[...s.headers],array:Array.from(new Uint8Array(await s.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}var r,t}(e):"singlefile.fetchResponse"==e.method?async function(e){const a=r.get(e.requestId);a&&(e.error?(a.reject(new Error(e.error)),r.delete(e.requestId)):(e.truncated&&(a.array?a.array=a.array.concat(e.array):(a.array=e.array,r.set(e.requestId,a)),e.finished&&(e.array=a.array)),e.truncated&&!e.finished||(a.resolve({status:e.status,headers:{get:r=>e.headers&&e.headers[r]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),r.delete(e.requestId))));return{}}(e):void 0))}(); +!function(){"use strict";const e=globalThis.document;if(e instanceof globalThis.Document){let n=e.createElement("script");n.src="data:,("+t.toString()+")()",(e.documentElement||e).appendChild(n),n.remove(),n=e.createElement("script"),n.textContent="("+t.toString()+")()",(e.documentElement||e).appendChild(n),n.remove()}function t(){"undefined"==typeof globalThis&&(window.globalThis=window);const e=globalThis.document,t=globalThis.console,n=e=>globalThis.dispatchEvent(e),r=globalThis.CustomEvent,a=globalThis.FileReader,o=globalThis.Blob,s=t&&t.warn&&((...e)=>t.warn(...e))||(()=>{}),i="single-file-new-font-face",l={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"};if(globalThis.FontFace){const t=globalThis.FontFace;let a;globalThis.FontFace=function(){return a||(s("SingleFile is hooking the FontFace constructor, document.fonts.delete and document.fonts.clear to handle dynamically loaded fonts."),a=!0),c(...arguments).then((e=>n(new r(i,{detail:e})))),new t(...arguments)},globalThis.FontFace.toString=function(){return"function FontFace() { [native code] }"};const o=e.fonts.delete;e.fonts.delete=function(t){return c(t.family).then((e=>n(new r("single-file-delete-font",{detail:e})))),o.call(e.fonts,t)},e.fonts.delete.toString=function(){return"function delete() { [native code] }"};const l=e.fonts.clear;e.fonts.clear=function(){return n(new r("single-file-clear-fonts")),l.call(e.fonts)},e.fonts.clear.toString=function(){return"function clear() { [native code] }"}}async function c(e,t,n){const r={};return r["font-family"]=e,r.src=t,n&&Object.keys(n).forEach((e=>{l[e]&&(r[l[e]]=n[e])})),new Promise((e=>{if(r.src instanceof ArrayBuffer){const t=new a;t.readAsDataURL(new o([r.src])),t.addEventListener("load",(()=>{r.src="url("+t.result+")",e(r)}))}else e(r)}))}}const n=globalThis.browser,r=globalThis.document;if(r instanceof globalThis.Document&&n&&n.runtime&&n.runtime.getURL){const e=r.createElement("script");e.src=n.runtime.getURL("/lib/single-file-hooks-frames.js"),e.async=!1,(r.documentElement||r).appendChild(e),e.remove()}const a="single-file-response-fetch";let o=new Map;function s(e){return new Promise(((t,n)=>{var r,o,s,i;r=new CustomEvent("single-file-request-fetch",{detail:e}),window.dispatchEvent(r),o=a,s=function r(o){var s,i,l;o.detail?o.detail.url==e&&(s=a,i=r,l=!1,window.removeEventListener(s,i,l),o.detail.response?t({status:o.detail.status,headers:new Map(o.detail.headers),arrayBuffer:async()=>o.detail.response}):n(o.detail.error)):n()},i=!1,window.addEventListener(o,s,i)}))}browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{let r=await(t=e.url,n={cache:"force-cache",headers:e.headers},window.fetch(t,n));return 401!=r.status&&403!=r.status&&404!=r.status||(r=await Promise.race([s(e.url),new Promise(((e,t)=>setTimeout((()=>t()),5e3)))])),{status:r.status,headers:[...r.headers],array:Array.from(new Uint8Array(await r.arrayBuffer()))}}catch(e){return{error:e&&e.toString()}}var t,n}(e):"singlefile.fetchResponse"==e.method?async function(e){const t=o.get(e.requestId);t&&(e.error?(t.reject(new Error(e.error)),o.delete(e.requestId)):(e.truncated&&(t.array?t.array=t.array.concat(e.array):(t.array=e.array,o.set(e.requestId,t)),e.finished&&(e.array=t.array)),e.truncated&&!e.finished||(t.resolve({status:e.status,headers:{get:t=>e.headers&&e.headers[t]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),o.delete(e.requestId))));return{}}(e):void 0))}(); diff --git a/lib/single-file-frames.js b/lib/single-file-frames.js index dc9dac5c8..5eaa043bf 100644 --- a/lib/single-file-frames.js +++ b/lib/single-file-frames.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefile={})}(this,(function(e){"use strict";const t="single-file-load-image",s="single-file-image-loaded",o=globalThis.browser,n=(e,t,s)=>globalThis.addEventListener(e,t,s),i=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},a=globalThis.CustomEvent,r=globalThis.document,l=globalThis.Document;let d;if(d=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,r instanceof l){n("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,d.set(JSON.stringify(s),t)})),n("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,d.delete(JSON.stringify(s))})),n("single-file-clear-fonts",(()=>d=new Map));let e=r.createElement("script");e.src="data:,("+function(){"undefined"==typeof globalThis&&(window.globalThis=window);const e=globalThis.document,t=globalThis.console,s=e=>globalThis.dispatchEvent(e),o=globalThis.CustomEvent,n=globalThis.FileReader,i=globalThis.Blob,a=t&&t.warn&&((...e)=>t.warn(...e))||(()=>{}),r="single-file-new-font-face",l="single-file-delete-font",d="single-file-clear-fonts",c={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"};if(globalThis.FontFace){const t=globalThis.FontFace;let n;globalThis.FontFace=function(){return n||(a("SingleFile is hooking the FontFace constructor, document.fonts.delete and document.fonts.clear to handle dynamically loaded fonts."),n=!0),u(...arguments).then((e=>s(new o(r,{detail:e})))),new t(...arguments)},globalThis.FontFace.toString=function(){return"function FontFace() { [native code] }"};const i=e.fonts.delete;e.fonts.delete=function(t){return u(t.family).then((e=>s(new o(l,{detail:e})))),i.call(e.fonts,t)},e.fonts.delete.toString=function(){return"function delete() { [native code] }"};const c=e.fonts.clear;e.fonts.clear=function(){return s(new o(d)),c.call(e.fonts)},e.fonts.clear.toString=function(){return"function clear() { [native code] }"}}async function u(e,t,s){const o={};return o["font-family"]=e,o.src=t,s&&Object.keys(s).forEach((e=>{c[e]&&(o[c[e]]=s[e])})),new Promise((e=>{if(o.src instanceof ArrayBuffer){const t=new n;t.readAsDataURL(new i([o.src])),t.addEventListener("load",(()=>{o.src="url("+t.result+")",e(o)}))}else e(o)}))}}.toString()+")()",(r.documentElement||r).appendChild(e),e.remove(),o&&o.runtime&&o.runtime.getURL&&(e=r.createElement("script"),e.src=o.runtime.getURL("/lib/single-file-hooks-frames.js"),e.async=!1,(r.documentElement||r).appendChild(e),e.remove())}const c=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig");const u="data-single-file-removed-content",m="data-single-file-hidden-content",f="data-single-file-kept-content",g="data-single-file-hidden-frame",h="data-single-file-preserved-space-element",p="data-single-file-shadow-root-element",b="data-single-file-image",y="data-single-file-poster",w="data-single-file-video",E="data-single-file-canvas",T="data-single-file-movable-style",I="data-single-file-input-value",v="data-single-file-lazy-loaded-src",A="data-single-file-stylesheet",S="data-single-file-disabled-noscript",F="data-single-file-async-script",R="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",_=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD"],N=/^'(.*?)'$/,C=/^"(.*?)"$/,M={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},q="single-file-ui-element",x="data:,";function P(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=e.getComputedStyle(s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&_.includes(s.tagName)||s.closest("details"),r||(a=i||D(s,l),a&&(s.setAttribute(m,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(h,""),n.markedElements.push(s))}o.removeUnusedFonts&&(k(l,o,n.usedFonts),k(e.getComputedStyle(s,":first-letter"),o,n.usedFonts),k(e.getComputedStyle(s,":before"),o,n.usedFonts),k(e.getComputedStyle(s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(E,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:i?x:o.loadDeferredImages&&s.getAttribute(v)||s.currentSrc};n.images.push(t),s.setAttribute(b,n.images.length-1),n.markedElements.push(s),s.removeAttribute(v);try{a=a||e.getComputedStyle(s)}catch(e){}if(a){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");let a,r,l,d,c,u,m,f,g=!1;if("content-box"==(s=s||e.getComputedStyle(t)).getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}a=V("padding-left",s),r=V("padding-right",s),l=V("padding-top",s),d=V("padding-bottom",s),g?(c=V("border-left-width",s),u=V("border-right-width",s),m=V("border-top-width",s),f=V("border-bottom-width",s)):c=u=m=f=0,o=Math.max(0,t.clientWidth-a-r-c-u),n=Math.max(0,t.clientHeight-l-d-m-f),i&&t.removeAttribute("style")}return{pxWidth:o,pxHeight:n}}(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=e.getComputedStyle(s.parentNode).getPropertyValue("position");n.videos.push({positionParent:t,src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(w,n.videos.length-1)}if(!s.poster){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(y,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&i&&o.removeHiddenElements&&(s.setAttribute(g,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(I,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(I,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(I,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(I,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(F,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&L(s);if(d&&!s.classList.contains(q)){const i={};s.setAttribute(p,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i),P(e,t,d,o,n,a),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(i.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}P(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(f)?s.parentElement&&(s.parentElement.setAttribute(f,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(u,""),n.markedElements.push(s)))})),n}function k(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=O(n),!t.loadedFonts||t.loadedFonts.find((e=>O(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),M[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(JSON.stringify(r),[n,t,o,a])}var i}))}}function L(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function O(e=""){return function(e){e=e.match(N)?e.replace(N,"$1"):e.replace(C,"$1");return e.trim()}((t=e.trim(),t.replace(c,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function D(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function U(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(A,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function V(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}const W=v,z=q,H="attributes",B=globalThis.browser,j=globalThis.document,J=globalThis.MutationObserver,G=(e,t,s)=>globalThis.addEventListener(e,t,s),Y=(e,t,s)=>globalThis.removeEventListener(e,t,s),$=new Map;let K;async function X(e){if(j.documentElement){$.clear();const o=Math.max(j.documentElement.scrollHeight-1.5*j.documentElement.clientHeight,0),n=Math.max(j.documentElement.scrollWidth-1.5*j.documentElement.clientWidth,0);if(globalThis.scrollY<=o&&globalThis.scrollX<=n)return function(e){return K=0,new Promise((async o=>{let n;const r=new Set,l=new J((async t=>{if((t=t.filter((e=>e.type==H))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(W,e.target.src),e.target.addEventListener("load",c)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(z)})).length&&(n=!0,await Q(l,e,f),r.size||await Z(l,e,f))}}));async function d(t){await te("idleTimeout",(async()=>{n?K<10&&(K++,oe("idleTimeout"),await d(Math.max(500,t/2))):(oe("loadTimeout"),oe("maxTimeout"),ee(l,e,f))}),t)}function c(e){const t=e.target;t.removeAttribute(W),t.removeEventListener("load",c)}async function u(t){n=!0,await Q(l,e,f),await Z(l,e,f),t.detail&&r.add(t.detail)}async function m(t){await Q(l,e,f),await Z(l,e,f),r.delete(t.detail),r.size||await Z(l,e,f)}function f(e){l.disconnect(),Y(t,u),Y(s,m),o(e)}await d(2*e.loadDeferredImagesMaxIdleTime),await Q(l,e,f),l.observe(j,{subtree:!0,childList:!0,attributes:!0}),G(t,u),G(s,m),function(e){e.loadDeferredImagesBlockCookies&&i(new a("single-file-block-cookies-start")),e.loadDeferredImagesBlockStorage&&i(new a("single-file-block-storage-start")),e.loadDeferredImagesDispatchScrollEvent&&i(new a("single-file-dispatch-scroll-event-start")),e.loadDeferredImagesKeepZoomLevel?i(new a("single-file-load-deferred-images-keep-zoom-level-start")):i(new a("single-file-load-deferred-images-start"))}(e)}))}(e)}}async function Z(e,t,s){await te("loadTimeout",(()=>ee(e,t,s)),t.loadDeferredImagesMaxIdleTime)}async function Q(e,t,s){await te("maxTimeout",(async()=>{await oe("loadTimeout"),await ee(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime)}async function ee(e,t,s){await oe("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&i(new a("single-file-block-cookies-end")),e.loadDeferredImagesBlockStorage&&i(new a("single-file-block-storage-end")),e.loadDeferredImagesDispatchScrollEvent&&i(new a("single-file-dispatch-scroll-event-end")),e.loadDeferredImagesKeepZoomLevel?i(new a("single-file-load-deferred-images-keep-zoom-level-end")):i(new a("single-file-load-deferred-images-end"))}(t),await te("endTimeout",(async()=>{await oe("maxTimeout"),s()}),t.loadDeferredImagesMaxIdleTime/2),e.disconnect()}async function te(e,t,s){if(B&&B.runtime&&B.runtime.sendMessage){if(!$.get(e)||!$.get(e).pending){const o={callback:t,pending:!0};$.set(e,o);try{await B.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){se(e,t,s)}o.pending=!1}}else se(e,t,s)}function se(e,t,s){const o=$.get(e);o&&globalThis.clearTimeout(o),$.set(e,t),globalThis.setTimeout(t,s)}async function oe(e){if(B&&B.runtime&&B.runtime.sendMessage)try{await B.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){ne(e)}else ne(e)}function ne(e){const t=$.get(e);$.delete(e),t&&globalThis.clearTimeout(t)}B&&B.runtime&&B.runtime.onMessage&&B.runtime.onMessage.addListener&&B.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=$.get(e.type);if(t){$.delete(e.type);try{t.callback()}catch(t){ne(e.type)}}}}));const ie={ON_BEFORE_CAPTURE_EVENT_NAME:"single-file-on-before-capture",ON_AFTER_CAPTURE_EVENT_NAME:"single-file-on-after-capture",WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not([data-single-file-disabled-noscript])").forEach((e=>{e.setAttribute(S,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(R).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+R+", html > body > "+R);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a, p div").forEach((t=>{const s=e.createElement("template");s.setAttribute("data-single-file-invalid-element",""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=P(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=t.getComputedStyle(e);s&&D(e,s)&&(e.setAttribute(T,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(d.values()),stylesheets:U(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}},serialize:function(e){const t=e.doctype;let s="";return t&&(s=" "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("[data-single-file-disabled-noscript]").forEach((e=>{e.textContent=e.getAttribute(S),e.removeAttribute(S)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[u,g,m,h,b,y,w,E,I,p,A,F];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(u),e.removeAttribute(m),e.removeAttribute(f),e.removeAttribute(g),e.removeAttribute(h),e.removeAttribute(b),e.removeAttribute(y),e.removeAttribute(w),e.removeAttribute(E),e.removeAttribute(I),e.removeAttribute(p),e.removeAttribute(A),e.removeAttribute(F),e.removeAttribute(T)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))},getShadowRoot:L},ae="__frameTree__::",re='iframe, frame, object[type="text/html"][data]',le="singlefile.frameTree.initRequest",de="singlefile.frameTree.ackInitRequest",ce="singlefile.frameTree.cleanupRequest",ue="singlefile.frameTree.initResponse",me=5e3,fe=".",ge=globalThis.window==globalThis.top,he=globalThis.browser,pe=globalThis.top,be=globalThis.MessageChannel,ye=globalThis.document;let we,Ee=globalThis.sessions;var Te,Ie,ve;function Ae(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Se(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,ge||(we=globalThis.frameId=e.windowId),_e(ye,e.options,we,t),ge||(e.options.userScriptEnabled&&s&&await s(ie.ON_BEFORE_CAPTURE_EVENT_NAME),qe({frames:[Pe(ye,globalThis,we,e.options)],sessionId:t,requestedFrameId:ye.documentElement.dataset.requestedFrameId&&we}),e.options.userScriptEnabled&&s&&await s(ie.ON_AFTER_CAPTURE_EVENT_NAME),delete ye.documentElement.dataset.requestedFrameId)}function Fe(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;Me(ke(ye),e.windowId,t)}}function Re(e){e.frames.forEach((t=>Ne("responseTimeouts",e.sessionId,t.windowId)));const t=Ee.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(fe).length-e.windowId.split(fe).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function _e(e,t,s,o){const n=ke(e);!function(e,t,s,o,n){const i=[];let a;Ee.get(n)?a=Ee.get(n).requestTimeouts:(a={},Ee.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+fe+t;e.setAttribute(ie.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),qe({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+fe+t;try{xe(e.contentWindow,{method:le,windowId:i,sessionId:n,options:s})}catch(e){}a[i]=globalThis.setTimeout((()=>qe({frames:[{windowId:i,processed:!0}],sessionId:n})),me)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+fe+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Ne("requestTimeouts",n,a),_e(r,s,a,n),i.push(Pe(r,t,a,s))}catch(e){i.push({windowId:a,processed:!0})}})),qe({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Ne(e,t,s){const o=Ee.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function Ce(e,t){const s=Ee.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>qe({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function Me(e,t,s){e.forEach(((e,o)=>{const n=t+fe+o;e.removeAttribute(ie.WIN_ID_ATTRIBUTE_NAME);try{xe(e.contentWindow,{method:ce,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+fe+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{Me(ke(i),n,s)}catch(e){}}))}function qe(e){e.method=ue;try{pe.singlefile.processors.frameTree.initResponse(e)}catch(t){xe(pe,e,!0)}}function xe(e,t,s){if(e==pe&&he&&he.runtime&&he.runtime.sendMessage)he.runtime.sendMessage(t);else if(s){const s=new be;e.postMessage(ae+JSON.stringify({method:t.method,sessionId:t.sessionId}),"*",[s.port2]),s.port1.postMessage(t)}else e.postMessage(ae+JSON.stringify(t),"*")}function Pe(e,t,s,o){const n=ie.preProcessDoc(e,t,o),i=ie.serialize(e);ie.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function ke(e){let t=Array.from(e.querySelectorAll(re));return e.querySelectorAll("*").forEach((e=>{const s=ie.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(re)))})),t}Ee||(Ee=globalThis.sessions=new Map),ge&&(we="0",he&&he.runtime&&he.runtime.onMessage&&he.runtime.onMessage.addListener&&he.runtime.onMessage.addListener((e=>e.method==ue?(Re(e),Promise.resolve({})):e.method==de?(Ne("requestTimeouts",e.sessionId,e.windowId),Ce(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Te="message",Ie=async e=>{if("string"==typeof e.data&&e.data.startsWith(ae)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(ae.length));t.method==le?(e.source&&xe(e.source,{method:de,windowId:t.windowId,sessionId:t.sessionId}),ge||(globalThis.stop(),t.options.loadDeferredImages&&X(t.options),await Se(t))):t.method==de?(Ne("requestTimeouts",t.sessionId,t.windowId),Ce(t.sessionId,t.windowId)):t.method==ce?Fe(t):t.method==ue&&Ee.get(t.sessionId)&&(e.ports[0].onmessage=e=>Re(e.data))}},ve=!0,globalThis.addEventListener(Te,Ie,ve),e.TIMEOUT_INIT_REQUEST_MESSAGE=me,e.cleanup=function(e){Ee.delete(e),Fe({windowId:we,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=Ae();return e=JSON.parse(JSON.stringify(e)),new Promise((s=>{Ee.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Se({windowId:we,sessionId:t,options:e})}))},e.getSync=function(e){const t=Ae();e=JSON.parse(JSON.stringify(e)),Ee.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,ge||(we=globalThis.frameId=e.windowId);_e(ye,e.options,we,t),ge||(e.options.userScriptEnabled&&s&&s(ie.ON_BEFORE_CAPTURE_EVENT_NAME),qe({frames:[Pe(ye,globalThis,we,e.options)],sessionId:t,requestedFrameId:ye.documentElement.dataset.requestedFrameId&&we}),e.options.userScriptEnabled&&s&&s(ie.ON_AFTER_CAPTURE_EVENT_NAME),delete ye.documentElement.dataset.requestedFrameId)}({windowId:we,sessionId:t,options:e});const s=Ee.get(t).frames;return s.sessionId=t,s},e.initResponse=Re,Object.defineProperty(e,"__esModule",{value:!0})})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefile={})}(this,(function(e){"use strict";const t="single-file-load-image",s="single-file-image-loaded",o=(e,t,s)=>globalThis.addEventListener(e,t,s),n=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},i=globalThis.CustomEvent,a=globalThis.document,r=globalThis.Document;let l;l=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,a instanceof r&&(o("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,l.set(JSON.stringify(s),t)})),o("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,l.delete(JSON.stringify(s))})),o("single-file-clear-fonts",(()=>l=new Map)));const d=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig");const c="data-single-file-removed-content",m="data-single-file-hidden-content",u="data-single-file-kept-content",g="data-single-file-hidden-frame",f="data-single-file-preserved-space-element",h="data-single-file-shadow-root-element",p="data-single-file-image",b="data-single-file-poster",y="data-single-file-video",E="data-single-file-canvas",w="data-single-file-movable-style",T="data-single-file-input-value",I="data-single-file-lazy-loaded-src",v="data-single-file-stylesheet",A="data-single-file-disabled-noscript",S="data-single-file-async-script",R="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",_=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD"],N=/^'(.*?)'$/,F=/^"(.*?)"$/,M={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},C="single-file-ui-element",q="data:,";function x(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=e.getComputedStyle(s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&_.includes(s.tagName)||s.closest("details"),r||(a=i||D(s,l),a&&(s.setAttribute(m,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(f,""),n.markedElements.push(s))}o.removeUnusedFonts&&(P(l,o,n.usedFonts),P(e.getComputedStyle(s,":first-letter"),o,n.usedFonts),P(e.getComputedStyle(s,":before"),o,n.usedFonts),P(e.getComputedStyle(s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(E,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:i?q:o.loadDeferredImages&&s.getAttribute(I)||s.currentSrc};n.images.push(t),s.setAttribute(p,n.images.length-1),n.markedElements.push(s),s.removeAttribute(I);try{a=a||e.getComputedStyle(s)}catch(e){}if(a){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");let a,r,l,d,c,m,u,g,f=!1;if("content-box"==(s=s||e.getComputedStyle(t)).getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),f=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}a=U("padding-left",s),r=U("padding-right",s),l=U("padding-top",s),d=U("padding-bottom",s),f?(c=U("border-left-width",s),m=U("border-right-width",s),u=U("border-top-width",s),g=U("border-bottom-width",s)):c=m=u=g=0,o=Math.max(0,t.clientWidth-a-r-c-m),n=Math.max(0,t.clientHeight-l-d-u-g),i&&t.removeAttribute("style")}return{pxWidth:o,pxHeight:n}}(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=e.getComputedStyle(s.parentNode).getPropertyValue("position");n.videos.push({positionParent:t,src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(y,n.videos.length-1)}if(!s.poster){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(b,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&i&&o.removeHiddenElements&&(s.setAttribute(g,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(T,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(T,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(T,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(T,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(S,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&k(s);if(d&&!s.classList.contains(C)){const i={};s.setAttribute(h,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i),x(e,t,d,o,n,a),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(i.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}x(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(u)?s.parentElement&&(s.parentElement.setAttribute(u,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(c,""),n.markedElements.push(s)))})),n}function P(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=O(n),!t.loadedFonts||t.loadedFonts.find((e=>O(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),M[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(JSON.stringify(r),[n,t,o,a])}var i}))}}function k(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function O(e=""){return function(e){e=e.match(N)?e.replace(N,"$1"):e.replace(F,"$1");return e.trim()}((t=e.trim(),t.replace(d,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function D(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function L(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(v,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function U(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}const V=I,W=C,z="attributes",H=globalThis.browser,B=globalThis.document,j=globalThis.MutationObserver,J=(e,t,s)=>globalThis.addEventListener(e,t,s),G=(e,t,s)=>globalThis.removeEventListener(e,t,s),Y=new Map;let $;async function K(e){if(B.documentElement){Y.clear();const o=Math.max(B.documentElement.scrollHeight-1.5*B.documentElement.clientHeight,0),a=Math.max(B.documentElement.scrollWidth-1.5*B.documentElement.clientWidth,0);if(globalThis.scrollY<=o&&globalThis.scrollX<=a)return function(e){return $=0,new Promise((async o=>{let a;const r=new Set,l=new j((async t=>{if((t=t.filter((e=>e.type==z))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(V,e.target.src),e.target.addEventListener("load",c)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(W)})).length&&(a=!0,await Z(l,e,g),r.size||await X(l,e,g))}}));async function d(t){await ee("idleTimeout",(async()=>{a?$<10&&($++,se("idleTimeout"),await d(Math.max(500,t/2))):(se("loadTimeout"),se("maxTimeout"),Q(l,e,g))}),t)}function c(e){const t=e.target;t.removeAttribute(V),t.removeEventListener("load",c)}async function m(t){a=!0,await Z(l,e,g),await X(l,e,g),t.detail&&r.add(t.detail)}async function u(t){await Z(l,e,g),await X(l,e,g),r.delete(t.detail),r.size||await X(l,e,g)}function g(e){l.disconnect(),G(t,m),G(s,u),o(e)}await d(2*e.loadDeferredImagesMaxIdleTime),await Z(l,e,g),l.observe(B,{subtree:!0,childList:!0,attributes:!0}),J(t,m),J(s,u),function(e){e.loadDeferredImagesBlockCookies&&n(new i("single-file-block-cookies-start")),e.loadDeferredImagesBlockStorage&&n(new i("single-file-block-storage-start")),e.loadDeferredImagesDispatchScrollEvent&&n(new i("single-file-dispatch-scroll-event-start")),e.loadDeferredImagesKeepZoomLevel?n(new i("single-file-load-deferred-images-keep-zoom-level-start")):n(new i("single-file-load-deferred-images-start"))}(e)}))}(e)}}async function X(e,t,s){await ee("loadTimeout",(()=>Q(e,t,s)),t.loadDeferredImagesMaxIdleTime)}async function Z(e,t,s){await ee("maxTimeout",(async()=>{await se("loadTimeout"),await Q(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime)}async function Q(e,t,s){await se("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&n(new i("single-file-block-cookies-end")),e.loadDeferredImagesBlockStorage&&n(new i("single-file-block-storage-end")),e.loadDeferredImagesDispatchScrollEvent&&n(new i("single-file-dispatch-scroll-event-end")),e.loadDeferredImagesKeepZoomLevel?n(new i("single-file-load-deferred-images-keep-zoom-level-end")):n(new i("single-file-load-deferred-images-end"))}(t),await ee("endTimeout",(async()=>{await se("maxTimeout"),s()}),t.loadDeferredImagesMaxIdleTime/2),e.disconnect()}async function ee(e,t,s){if(H&&H.runtime&&H.runtime.sendMessage){if(!Y.get(e)||!Y.get(e).pending){const o={callback:t,pending:!0};Y.set(e,o);try{await H.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){te(e,t,s)}o.pending=!1}}else te(e,t,s)}function te(e,t,s){const o=Y.get(e);o&&globalThis.clearTimeout(o),Y.set(e,t),globalThis.setTimeout(t,s)}async function se(e){if(H&&H.runtime&&H.runtime.sendMessage)try{await H.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){oe(e)}else oe(e)}function oe(e){const t=Y.get(e);Y.delete(e),t&&globalThis.clearTimeout(t)}H&&H.runtime&&H.runtime.onMessage&&H.runtime.onMessage.addListener&&H.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Y.get(e.type);if(t){Y.delete(e.type);try{t.callback()}catch(t){oe(e.type)}}}}));const ne={ON_BEFORE_CAPTURE_EVENT_NAME:"single-file-on-before-capture",ON_AFTER_CAPTURE_EVENT_NAME:"single-file-on-after-capture",WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not([data-single-file-disabled-noscript])").forEach((e=>{e.setAttribute(A,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(R).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+R+", html > body > "+R);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a, p div").forEach((t=>{const s=e.createElement("template");s.setAttribute("data-single-file-invalid-element",""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=x(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=t.getComputedStyle(e);s&&D(e,s)&&(e.setAttribute(w,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(l.values()),stylesheets:L(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}},serialize:function(e){const t=e.doctype;let s="";return t&&(s=" "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("[data-single-file-disabled-noscript]").forEach((e=>{e.textContent=e.getAttribute(A),e.removeAttribute(A)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[c,g,m,f,p,b,y,E,T,h,v,S];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(c),e.removeAttribute(m),e.removeAttribute(u),e.removeAttribute(g),e.removeAttribute(f),e.removeAttribute(p),e.removeAttribute(b),e.removeAttribute(y),e.removeAttribute(E),e.removeAttribute(T),e.removeAttribute(h),e.removeAttribute(v),e.removeAttribute(S),e.removeAttribute(w)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))},getShadowRoot:k},ie="__frameTree__::",ae='iframe, frame, object[type="text/html"][data]',re="singlefile.frameTree.initRequest",le="singlefile.frameTree.ackInitRequest",de="singlefile.frameTree.cleanupRequest",ce="singlefile.frameTree.initResponse",me=5e3,ue=".",ge=globalThis.window==globalThis.top,fe=globalThis.browser,he=globalThis.top,pe=globalThis.MessageChannel,be=globalThis.document;let ye,Ee=globalThis.sessions;var we,Te,Ie;function ve(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ae(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,ge||(ye=globalThis.frameId=e.windowId),_e(be,e.options,ye,t),ge||(e.options.userScriptEnabled&&s&&await s(ne.ON_BEFORE_CAPTURE_EVENT_NAME),Ce({frames:[xe(be,globalThis,ye,e.options)],sessionId:t,requestedFrameId:be.documentElement.dataset.requestedFrameId&&ye}),e.options.userScriptEnabled&&s&&await s(ne.ON_AFTER_CAPTURE_EVENT_NAME),delete be.documentElement.dataset.requestedFrameId)}function Se(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;Me(Pe(be),e.windowId,t)}}function Re(e){e.frames.forEach((t=>Ne("responseTimeouts",e.sessionId,t.windowId)));const t=Ee.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(ue).length-e.windowId.split(ue).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function _e(e,t,s,o){const n=Pe(e);!function(e,t,s,o,n){const i=[];let a;Ee.get(n)?a=Ee.get(n).requestTimeouts:(a={},Ee.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+ue+t;e.setAttribute(ne.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),Ce({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+ue+t;try{qe(e.contentWindow,{method:re,windowId:i,sessionId:n,options:s})}catch(e){}a[i]=globalThis.setTimeout((()=>Ce({frames:[{windowId:i,processed:!0}],sessionId:n})),me)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+ue+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Ne("requestTimeouts",n,a),_e(r,s,a,n),i.push(xe(r,t,a,s))}catch(e){i.push({windowId:a,processed:!0})}})),Ce({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Ne(e,t,s){const o=Ee.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function Fe(e,t){const s=Ee.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>Ce({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function Me(e,t,s){e.forEach(((e,o)=>{const n=t+ue+o;e.removeAttribute(ne.WIN_ID_ATTRIBUTE_NAME);try{qe(e.contentWindow,{method:de,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+ue+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{Me(Pe(i),n,s)}catch(e){}}))}function Ce(e){e.method=ce;try{he.singlefile.processors.frameTree.initResponse(e)}catch(t){qe(he,e,!0)}}function qe(e,t,s){if(e==he&&fe&&fe.runtime&&fe.runtime.sendMessage)fe.runtime.sendMessage(t);else if(s){const s=new pe;e.postMessage(ie+JSON.stringify({method:t.method,sessionId:t.sessionId}),"*",[s.port2]),s.port1.postMessage(t)}else e.postMessage(ie+JSON.stringify(t),"*")}function xe(e,t,s,o){const n=ne.preProcessDoc(e,t,o),i=ne.serialize(e);ne.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function Pe(e){let t=Array.from(e.querySelectorAll(ae));return e.querySelectorAll("*").forEach((e=>{const s=ne.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(ae)))})),t}Ee||(Ee=globalThis.sessions=new Map),ge&&(ye="0",fe&&fe.runtime&&fe.runtime.onMessage&&fe.runtime.onMessage.addListener&&fe.runtime.onMessage.addListener((e=>e.method==ce?(Re(e),Promise.resolve({})):e.method==le?(Ne("requestTimeouts",e.sessionId,e.windowId),Fe(e.sessionId,e.windowId),Promise.resolve({})):void 0))),we="message",Te=async e=>{if("string"==typeof e.data&&e.data.startsWith(ie)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(ie.length));t.method==re?(e.source&&qe(e.source,{method:le,windowId:t.windowId,sessionId:t.sessionId}),ge||(globalThis.stop(),t.options.loadDeferredImages&&K(t.options),await Ae(t))):t.method==le?(Ne("requestTimeouts",t.sessionId,t.windowId),Fe(t.sessionId,t.windowId)):t.method==de?Se(t):t.method==ce&&Ee.get(t.sessionId)&&(e.ports[0].onmessage=e=>Re(e.data))}},Ie=!0,globalThis.addEventListener(we,Te,Ie),e.TIMEOUT_INIT_REQUEST_MESSAGE=me,e.cleanup=function(e){Ee.delete(e),Se({windowId:ye,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=ve();return e=JSON.parse(JSON.stringify(e)),new Promise((s=>{Ee.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ae({windowId:ye,sessionId:t,options:e})}))},e.getSync=function(e){const t=ve();e=JSON.parse(JSON.stringify(e)),Ee.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,ge||(ye=globalThis.frameId=e.windowId);_e(be,e.options,ye,t),ge||(e.options.userScriptEnabled&&s&&s(ne.ON_BEFORE_CAPTURE_EVENT_NAME),Ce({frames:[xe(be,globalThis,ye,e.options)],sessionId:t,requestedFrameId:be.documentElement.dataset.requestedFrameId&&ye}),e.options.userScriptEnabled&&s&&s(ne.ON_AFTER_CAPTURE_EVENT_NAME),delete be.documentElement.dataset.requestedFrameId)}({windowId:ye,sessionId:t,options:e});const s=Ee.get(t).frames;return s.sessionId=t,s},e.initResponse=Re,Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/lib/single-file.js b/lib/single-file.js index 55b41f217..30a5bf2ff 100644 --- a/lib/single-file.js +++ b/lib/single-file.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefile={})}(this,(function(e){"use strict";const t="single-file-load-image",r="single-file-image-loaded",n=globalThis.browser,o=(e,t,r)=>globalThis.addEventListener(e,t,r),i=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},a=globalThis.CustomEvent,s=globalThis.document,l=globalThis.Document;let c;if(c=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,s instanceof l){o("single-file-new-font-face",(e=>{const t=e.detail,r=Object.assign({},t);delete r.src,c.set(JSON.stringify(r),t)})),o("single-file-delete-font",(e=>{const t=e.detail,r=Object.assign({},t);delete r.src,c.delete(JSON.stringify(r))})),o("single-file-clear-fonts",(()=>c=new Map));let e=s.createElement("script");e.src="data:,("+function(){"undefined"==typeof globalThis&&(window.globalThis=window);const e=globalThis.document,t=globalThis.console,r=e=>globalThis.dispatchEvent(e),n=globalThis.CustomEvent,o=globalThis.FileReader,i=globalThis.Blob,a=t&&t.warn&&((...e)=>t.warn(...e))||(()=>{}),s="single-file-new-font-face",l="single-file-delete-font",c="single-file-clear-fonts",u={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"};if(globalThis.FontFace){const t=globalThis.FontFace;let o;globalThis.FontFace=function(){return o||(a("SingleFile is hooking the FontFace constructor, document.fonts.delete and document.fonts.clear to handle dynamically loaded fonts."),o=!0),h(...arguments).then((e=>r(new n(s,{detail:e})))),new t(...arguments)},globalThis.FontFace.toString=function(){return"function FontFace() { [native code] }"};const i=e.fonts.delete;e.fonts.delete=function(t){return h(t.family).then((e=>r(new n(l,{detail:e})))),i.call(e.fonts,t)},e.fonts.delete.toString=function(){return"function delete() { [native code] }"};const u=e.fonts.clear;e.fonts.clear=function(){return r(new n(c)),u.call(e.fonts)},e.fonts.clear.toString=function(){return"function clear() { [native code] }"}}async function h(e,t,r){const n={};return n["font-family"]=e,n.src=t,r&&Object.keys(r).forEach((e=>{u[e]&&(n[u[e]]=r[e])})),new Promise((e=>{if(n.src instanceof ArrayBuffer){const t=new o;t.readAsDataURL(new i([n.src])),t.addEventListener("load",(()=>{n.src="url("+t.result+")",e(n)}))}else e(n)}))}}.toString()+")()",(s.documentElement||s).appendChild(e),e.remove(),n&&n.runtime&&n.runtime.getURL&&(e=s.createElement("script"),e.src=n.runtime.getURL("/lib/single-file-hooks-frames.js"),e.async=!1,(s.documentElement||s).appendChild(e),e.remove())}function u(){return Array.from(c.values())}function h(e){e.loadDeferredImagesBlockCookies&&i(new a("single-file-block-cookies-start")),e.loadDeferredImagesBlockStorage&&i(new a("single-file-block-storage-start")),e.loadDeferredImagesDispatchScrollEvent&&i(new a("single-file-dispatch-scroll-event-start")),e.loadDeferredImagesKeepZoomLevel?i(new a("single-file-load-deferred-images-keep-zoom-level-start")):i(new a("single-file-load-deferred-images-start"))}function d(e){e.loadDeferredImagesBlockCookies&&i(new a("single-file-block-cookies-end")),e.loadDeferredImagesBlockStorage&&i(new a("single-file-block-storage-end")),e.loadDeferredImagesDispatchScrollEvent&&i(new a("single-file-dispatch-scroll-event-end")),e.loadDeferredImagesKeepZoomLevel?i(new a("single-file-load-deferred-images-keep-zoom-level-end")):i(new a("single-file-load-deferred-images-end"))}function p(e){e.loadDeferredImagesKeepZoomLevel?i(new a("single-file-load-deferred-images-keep-zoom-level-reset")):i(new a("single-file-load-deferred-images-reset"))}var m=Object.freeze({__proto__:null,getFontsData:u,loadDeferredImagesStart:h,loadDeferredImagesEnd:d,loadDeferredImagesResetZoomLevel:p,LOAD_IMAGE_EVENT:t,IMAGE_LOADED_EVENT:r});const f=new RegExp("\\\\([\\da-f]{1,6}[\\x20\\t\\r\\n\\f]?|([\\x20\\t\\r\\n\\f])|.)","ig");function g(e){return e.replace(f,((e,t,r)=>{const n="0x"+t-65536;return n!=n||r?t:n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320)}))}var y=Object.freeze({__proto__:null,process:g});const b="single-file-on-before-capture",k="single-file-on-after-capture",v="data-single-file-removed-content",w="data-single-file-hidden-content",x="data-single-file-kept-content",E="data-single-file-hidden-frame",A="data-single-file-preserved-space-element",S="data-single-file-shadow-root-element",T="data-single-file-win-id",C="data-single-file-image",R="data-single-file-poster",_="data-single-file-video",I="data-single-file-canvas",L="data-single-file-movable-style",N="data-single-file-input-value",z="data-single-file-lazy-loaded-src",P="data-single-file-stylesheet",M="data-single-file-disabled-noscript",O="data-single-file-selected-content",U="data-single-file-invalid-element",D="data-single-file-async-script",F="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",q=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD"],B=/^'(.*?)'$/,j=/^"(.*?)"$/,H={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},V="Page saved with SingleFile",W="Archive processed by SingleFile",$="single-file-ui-element",G="data:,",Y=(e,t,r)=>globalThis.addEventListener(e,t,r);function J(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}function Q(e,t,r){e.querySelectorAll("noscript:not([data-single-file-disabled-noscript])").forEach((e=>{e.setAttribute(M,e.textContent),e.textContent=""})),J(e),e.head&&e.head.querySelectorAll(F).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+F+", html > body > "+F);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const n=new Map;let o;return t&&e.documentElement?(e.querySelectorAll("button button, a a, p div").forEach((t=>{const r=e.createElement("template");r.setAttribute(U,""),r.content.appendChild(t.cloneNode(!0)),n.set(t,r),t.replaceWith(r)})),o=K(t,e,e.documentElement,r),r.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const r=t.getComputedStyle(e);r&&te(e,r)&&(e.setAttribute(L,""),o.markedElements.push(e))}))):o={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:o.canvases,fonts:u(),stylesheets:ne(e),images:o.images,posters:o.posters,videos:o.videos,usedFonts:Array.from(o.usedFonts.values()),shadowRoots:o.shadowRoots,referrer:e.referrer,markedElements:o.markedElements,invalidElements:n}}function K(e,t,r,n,o={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){return Array.from(r.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((r=>{let a,s,l;if(!n.autoSaveExternalSave&&(n.removeHiddenElements||n.removeUnusedFonts||n.compressHTML)&&(l=e.getComputedStyle(r),r instanceof e.HTMLElement&&n.removeHiddenElements&&(s=(i||r.closest("html > head"))&&q.includes(r.tagName)||r.closest("details"),s||(a=i||te(r,l),a&&(r.setAttribute(w,""),o.markedElements.push(r)))),!a)){if(n.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(r.setAttribute(A,""),o.markedElements.push(r))}n.removeUnusedFonts&&(Z(l,n,o.usedFonts),Z(e.getComputedStyle(r,":first-letter"),n,o.usedFonts),Z(e.getComputedStyle(r,":before"),n,o.usedFonts),Z(e.getComputedStyle(r,":after"),n,o.usedFonts))}!function(e,t,r,n,o,i,a){if("CANVAS"==r.tagName)try{o.canvases.push({dataURI:r.toDataURL("image/png","")}),r.setAttribute(I,o.canvases.length-1),o.markedElements.push(r)}catch(e){}if("IMG"==r.tagName){const t={currentSrc:i?G:n.loadDeferredImages&&r.getAttribute(z)||r.currentSrc};o.images.push(t),r.setAttribute(C,o.images.length-1),o.markedElements.push(r),r.removeAttribute(z);try{a=a||e.getComputedStyle(r)}catch(e){}if(a){t.size=function(e,t,r){let n=t.naturalWidth,o=t.naturalHeight;if(!n&&!o){const i=null==t.getAttribute("style");let a,s,l,c,u,h,d,p,m=!1;if("content-box"==(r=r||e.getComputedStyle(t)).getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),r=t.style.getPropertyPriority("box-sizing"),n=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),m=t.clientWidth!=n,e?t.style.setProperty("box-sizing",e,r):t.style.removeProperty("box-sizing")}a=oe("padding-left",r),s=oe("padding-right",r),l=oe("padding-top",r),c=oe("padding-bottom",r),m?(u=oe("border-left-width",r),h=oe("border-right-width",r),d=oe("border-top-width",r),p=oe("border-bottom-width",r)):u=h=d=p=0,n=Math.max(0,t.clientWidth-a-s-u-h),o=Math.max(0,t.clientHeight-l-c-d-p),i&&t.removeAttribute("style")}return{pxWidth:n,pxHeight:o}}(e,r,a);const n=a.getPropertyValue("box-shadow"),o=a.getPropertyValue("background-image");n&&"none"!=n||o&&"none"!=o||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==r.tagName){const n=r.currentSrc;if(n&&!n.startsWith("blob:")&&!n.startsWith("data:")){const t=e.getComputedStyle(r.parentNode).getPropertyValue("position");o.videos.push({positionParent:t,src:n,size:{pxWidth:r.clientWidth,pxHeight:r.clientHeight},currentTime:r.currentTime}),r.setAttribute(_,o.videos.length-1)}if(!r.poster){const e=t.createElement("canvas"),n=e.getContext("2d");e.width=r.clientWidth,e.height=r.clientHeight;try{n.drawImage(r,0,0,e.width,e.height),o.posters.push(e.toDataURL("image/png","")),r.setAttribute(R,o.posters.length-1),o.markedElements.push(r)}catch(e){}}}"IFRAME"==r.tagName&&i&&n.removeHiddenElements&&(r.setAttribute(E,""),o.markedElements.push(r));"INPUT"==r.tagName&&("password"!=r.type&&(r.setAttribute(N,r.value),o.markedElements.push(r)),"radio"!=r.type&&"checkbox"!=r.type||(r.setAttribute(N,r.checked),o.markedElements.push(r)));"TEXTAREA"==r.tagName&&(r.setAttribute(N,r.value),o.markedElements.push(r));"SELECT"==r.tagName&&r.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(N,""),o.markedElements.push(e))}));"SCRIPT"==r.tagName&&(r.async&&""!=r.getAttribute("async")&&"async"!=r.getAttribute("async")&&(r.setAttribute(D,""),o.markedElements.push(r)),r.textContent=r.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,r,n,o,a,l);const c=!(r instanceof e.SVGElement)&&X(r);if(c&&!r.classList.contains($)){const i={};r.setAttribute(S,o.shadowRoots.length),o.markedElements.push(r),o.shadowRoots.push(i),K(e,t,c,n,o,a),i.content=c.innerHTML,i.mode=c.mode;try{c.adoptedStyleSheets&&c.adoptedStyleSheets.length&&(i.adoptedStyleSheets=Array.from(c.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}K(e,t,r,n,o,a),!n.autoSaveExternalSave&&n.removeHiddenElements&&i&&(s||""==r.getAttribute(x)?r.parentElement&&(r.parentElement.setAttribute(x,""),o.markedElements.push(r.parentElement)):a&&(r.setAttribute(v,""),o.markedElements.push(r)))})),o}function Z(e,t,r){if(e){const n=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((o=>{if(o=ee(o),!t.loadedFonts||t.loadedFonts.find((e=>ee(e.family)==o&&e.style==n))){const t=se(e.getPropertyValue("font-weight")),i=e.getPropertyValue("font-variant")||"normal",a=[o,t,n,i];r.set(JSON.stringify(a),[o,t,n,i])}}))}}function X(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function ee(e=""){return ae(g(e.trim())).toLowerCase()}function te(e,t){let r=!1;if(t){const n=t.getPropertyValue("display"),o=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(r="none"==n,!r&&("0"==o||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();r=!t.width&&!t.height}}return Boolean(r)}function re(e,t,r){if(e.querySelectorAll("[data-single-file-disabled-noscript]").forEach((e=>{e.textContent=e.getAttribute(M),e.removeAttribute(M)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const r=[v,E,w,A,C,R,_,I,N,S,P,D];t=e.querySelectorAll(r.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(v),e.removeAttribute(w),e.removeAttribute(x),e.removeAttribute(E),e.removeAttribute(A),e.removeAttribute(C),e.removeAttribute(R),e.removeAttribute(_),e.removeAttribute(I),e.removeAttribute(N),e.removeAttribute(S),e.removeAttribute(P),e.removeAttribute(D),e.removeAttribute(L)})),r&&Array.from(r.entries()).forEach((([e,t])=>t.replaceWith(e)))}function ne(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((r,n)=>{try{const o=e.createElement("style");o.textContent=r.textContent,e.body.appendChild(o);const i=o.sheet;o.remove(),i&&i.cssRules.length==r.sheet.cssRules.length||(r.setAttribute(P,n),t[n]=Array.from(r.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function oe(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function ie(e){const t=e.doctype;let r="";return t&&(r=" "),r+e.documentElement.outerHTML}function ae(e){return(e=e.match(B)?e.replace(B,"$1"):e.replace(j,"$1")).trim()}function se(e){return H[e.toLowerCase().trim()]||e}function le(e){return e.flat?e.flat():e.reduce(((e,t)=>e.concat(Array.isArray(t)?le(t):t)),[])}var ce=Object.freeze({__proto__:null,initUserScriptHandler:function(){Y("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),r=new Promise((t=>Y(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await r}))},initDoc:J,preProcessDoc:Q,postProcessDoc:re,serialize:ie,removeQuotes:ae,flatten:le,getFontWeight:se,normalizeFontFamily:ee,getShadowRoot:X,ON_BEFORE_CAPTURE_EVENT_NAME:b,ON_AFTER_CAPTURE_EVENT_NAME:k,WIN_ID_ATTRIBUTE_NAME:T,PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME:A,REMOVED_CONTENT_ATTRIBUTE_NAME:v,HIDDEN_CONTENT_ATTRIBUTE_NAME:w,HIDDEN_FRAME_ATTRIBUTE_NAME:E,IMAGE_ATTRIBUTE_NAME:C,POSTER_ATTRIBUTE_NAME:R,VIDEO_ATTRIBUTE_NAME:_,CANVAS_ATTRIBUTE_NAME:I,INPUT_VALUE_ATTRIBUTE_NAME:N,SHADOW_ROOT_ATTRIBUTE_NAME:S,STYLE_ATTRIBUTE_NAME:L,LAZY_SRC_ATTRIBUTE_NAME:z,STYLESHEET_ATTRIBUTE_NAME:P,SELECTED_CONTENT_ATTRIBUTE_NAME:O,INVALID_ELEMENT_ATTRIBUTE_NAME:U,ASYNC_SCRIPT_ATTRIBUTE_NAME:D,COMMENT_HEADER:V,COMMENT_HEADER_LEGACY:W,SINGLE_FILE_UI_ELEMENT_CLASS:$,EMPTY_RESOURCE:G});const ue=z,he=$,de="attributes",pe=globalThis.browser,me=globalThis.document,fe=globalThis.MutationObserver,ge=(e,t,r)=>globalThis.addEventListener(e,t,r),ye=(e,t,r)=>globalThis.removeEventListener(e,t,r),be=new Map;let ke;async function ve(e){if(me.documentElement){be.clear();const n=Math.max(me.documentElement.scrollHeight-1.5*me.documentElement.clientHeight,0),o=Math.max(me.documentElement.scrollWidth-1.5*me.documentElement.clientWidth,0);if(globalThis.scrollY<=n&&globalThis.scrollX<=o)return function(e){return ke=0,new Promise((async n=>{let o;const i=new Set,a=new fe((async t=>{if((t=t.filter((e=>e.type==de))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(ue,e.target.src),e.target.addEventListener("load",l)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(he)})).length&&(o=!0,await Ee(a,e,d),i.size||await xe(a,e,d))}}));async function s(t){await Se("idleTimeout",(async()=>{o?ke<10&&(ke++,Ce("idleTimeout"),await s(Math.max(500,t/2))):(Ce("loadTimeout"),Ce("maxTimeout"),Ae(a,e,d))}),t)}function l(e){const t=e.target;t.removeAttribute(ue),t.removeEventListener("load",l)}async function c(t){o=!0,await Ee(a,e,d),await xe(a,e,d),t.detail&&i.add(t.detail)}async function u(t){await Ee(a,e,d),await xe(a,e,d),i.delete(t.detail),i.size||await xe(a,e,d)}function d(e){a.disconnect(),ye(t,c),ye(r,u),n(e)}await s(2*e.loadDeferredImagesMaxIdleTime),await Ee(a,e,d),a.observe(me,{subtree:!0,childList:!0,attributes:!0}),ge(t,c),ge(r,u),h(e)}))}(e)}}function we(e){p(e)}async function xe(e,t,r){await Se("loadTimeout",(()=>Ae(e,t,r)),t.loadDeferredImagesMaxIdleTime)}async function Ee(e,t,r){await Se("maxTimeout",(async()=>{await Ce("loadTimeout"),await Ae(e,t,r)}),10*t.loadDeferredImagesMaxIdleTime)}async function Ae(e,t,r){await Ce("idleTimeout"),d(t),await Se("endTimeout",(async()=>{await Ce("maxTimeout"),r()}),t.loadDeferredImagesMaxIdleTime/2),e.disconnect()}async function Se(e,t,r){if(pe&&pe.runtime&&pe.runtime.sendMessage){if(!be.get(e)||!be.get(e).pending){const n={callback:t,pending:!0};be.set(e,n);try{await pe.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:r})}catch(n){Te(e,t,r)}n.pending=!1}}else Te(e,t,r)}function Te(e,t,r){const n=be.get(e);n&&globalThis.clearTimeout(n),be.set(e,t),globalThis.setTimeout(t,r)}async function Ce(e){if(pe&&pe.runtime&&pe.runtime.sendMessage)try{await pe.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Re(e)}else Re(e)}function Re(e){const t=be.get(e);be.delete(e),t&&globalThis.clearTimeout(t)}pe&&pe.runtime&&pe.runtime.onMessage&&pe.runtime.onMessage.addListener&&pe.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=be.get(e.type);if(t){be.delete(e.type);try{t.callback()}catch(t){Re(e.type)}}}}));var _e=Object.freeze({__proto__:null,process:ve,resetZoomLevel:we});const Ie={ON_BEFORE_CAPTURE_EVENT_NAME:b,ON_AFTER_CAPTURE_EVENT_NAME:k,WIN_ID_ATTRIBUTE_NAME:T,preProcessDoc:Q,serialize:ie,postProcessDoc:re,getShadowRoot:X},Le="__frameTree__::",Ne='iframe, frame, object[type="text/html"][data]',ze="singlefile.frameTree.initRequest",Pe="singlefile.frameTree.ackInitRequest",Me="singlefile.frameTree.cleanupRequest",Oe="singlefile.frameTree.initResponse",Ue=5e3,De=".",Fe=globalThis.window==globalThis.top,qe=globalThis.browser,Be=globalThis.top,je=globalThis.MessageChannel,He=globalThis.document;let Ve,We=globalThis.sessions;var $e,Ge,Ye;function Je(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Qe(e){const t=e.sessionId,r=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Fe||(Ve=globalThis.frameId=e.windowId),Xe(He,e.options,Ve,t),Fe||(e.options.userScriptEnabled&&r&&await r(Ie.ON_BEFORE_CAPTURE_EVENT_NAME),nt({frames:[it(He,globalThis,Ve,e.options)],sessionId:t,requestedFrameId:He.documentElement.dataset.requestedFrameId&&Ve}),e.options.userScriptEnabled&&r&&await r(Ie.ON_AFTER_CAPTURE_EVENT_NAME),delete He.documentElement.dataset.requestedFrameId)}function Ke(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;rt(at(He),e.windowId,t)}}function Ze(e){e.frames.forEach((t=>et("responseTimeouts",e.sessionId,t.windowId)));const t=We.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let r=t.frames.find((t=>e.windowId==t.windowId));r||(r={windowId:e.windowId},t.frames.push(r)),r.processed||(r.content=e.content,r.baseURI=e.baseURI,r.title=e.title,r.canvases=e.canvases,r.fonts=e.fonts,r.stylesheets=e.stylesheets,r.images=e.images,r.posters=e.posters,r.videos=e.videos,r.usedFonts=e.usedFonts,r.shadowRoots=e.shadowRoots,r.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(De).length-e.windowId.split(De).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Xe(e,t,r,n){const o=at(e);!function(e,t,r,n,o){const i=[];let a;We.get(o)?a=We.get(o).requestTimeouts:(a={},We.set(o,{requestTimeouts:a}));t.forEach(((e,t)=>{const r=n+De+t;e.setAttribute(Ie.WIN_ID_ATTRIBUTE_NAME,r),i.push({windowId:r})})),nt({frames:i,sessionId:o,requestedFrameId:e.documentElement.dataset.requestedFrameId&&n}),t.forEach(((e,t)=>{const i=n+De+t;try{ot(e.contentWindow,{method:ze,windowId:i,sessionId:o,options:r})}catch(e){}a[i]=globalThis.setTimeout((()=>nt({frames:[{windowId:i,processed:!0}],sessionId:o})),Ue)})),delete e.documentElement.dataset.requestedFrameId}(e,o,t,r,n),o.length&&function(e,t,r,n,o){const i=[];t.forEach(((e,t)=>{const a=n+De+t;let s;try{s=e.contentDocument}catch(e){}if(s)try{const t=e.contentWindow;t.stop(),et("requestTimeouts",o,a),Xe(s,r,a,o),i.push(it(s,t,a,r))}catch(e){i.push({windowId:a,processed:!0})}})),nt({frames:i,sessionId:o,requestedFrameId:e.documentElement.dataset.requestedFrameId&&n}),delete e.documentElement.dataset.requestedFrameId}(e,o,t,r,n)}function et(e,t,r){const n=We.get(t);if(n&&n[e]){const t=n[e][r];t&&(globalThis.clearTimeout(t),delete n[e][r])}}function tt(e,t){const r=We.get(e);r&&r.responseTimeouts&&(r.responseTimeouts[t]=globalThis.setTimeout((()=>nt({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function rt(e,t,r){e.forEach(((e,n)=>{const o=t+De+n;e.removeAttribute(Ie.WIN_ID_ATTRIBUTE_NAME);try{ot(e.contentWindow,{method:Me,windowId:o,sessionId:r})}catch(e){}})),e.forEach(((e,n)=>{const o=t+De+n;let i;try{i=e.contentDocument}catch(e){}if(i)try{rt(at(i),o,r)}catch(e){}}))}function nt(e){e.method=Oe;try{Be.singlefile.processors.frameTree.initResponse(e)}catch(t){ot(Be,e,!0)}}function ot(e,t,r){if(e==Be&&qe&&qe.runtime&&qe.runtime.sendMessage)qe.runtime.sendMessage(t);else if(r){const r=new je;e.postMessage(Le+JSON.stringify({method:t.method,sessionId:t.sessionId}),"*",[r.port2]),r.port1.postMessage(t)}else e.postMessage(Le+JSON.stringify(t),"*")}function it(e,t,r,n){const o=Ie.preProcessDoc(e,t,n),i=Ie.serialize(e);Ie.postProcessDoc(e,o.markedElements,o.invalidElements);return{windowId:r,content:i,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:o.canvases,fonts:o.fonts,stylesheets:o.stylesheets,images:o.images,posters:o.posters,videos:o.videos,usedFonts:o.usedFonts,shadowRoots:o.shadowRoots,processed:!0}}function at(e){let t=Array.from(e.querySelectorAll(Ne));return e.querySelectorAll("*").forEach((e=>{const r=Ie.getShadowRoot(e);r&&(t=t.concat(...r.querySelectorAll(Ne)))})),t}We||(We=globalThis.sessions=new Map),Fe&&(Ve="0",qe&&qe.runtime&&qe.runtime.onMessage&&qe.runtime.onMessage.addListener&&qe.runtime.onMessage.addListener((e=>e.method==Oe?(Ze(e),Promise.resolve({})):e.method==Pe?(et("requestTimeouts",e.sessionId,e.windowId),tt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),$e="message",Ge=async e=>{if("string"==typeof e.data&&e.data.startsWith(Le)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(Le.length));t.method==ze?(e.source&&ot(e.source,{method:Pe,windowId:t.windowId,sessionId:t.sessionId}),Fe||(globalThis.stop(),t.options.loadDeferredImages&&ve(t.options),await Qe(t))):t.method==Pe?(et("requestTimeouts",t.sessionId,t.windowId),tt(t.sessionId,t.windowId)):t.method==Me?Ke(t):t.method==Oe&&We.get(t.sessionId)&&(e.ports[0].onmessage=e=>Ze(e.data))}},Ye=!0,globalThis.addEventListener($e,Ge,Ye);var st=Object.freeze({__proto__:null,getAsync:function(e){const t=Je();return e=JSON.parse(JSON.stringify(e)),new Promise((r=>{We.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,r(e)}}),Qe({windowId:Ve,sessionId:t,options:e})}))},getSync:function(e){const t=Je();e=JSON.parse(JSON.stringify(e)),We.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,r=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Fe||(Ve=globalThis.frameId=e.windowId);Xe(He,e.options,Ve,t),Fe||(e.options.userScriptEnabled&&r&&r(Ie.ON_BEFORE_CAPTURE_EVENT_NAME),nt({frames:[it(He,globalThis,Ve,e.options)],sessionId:t,requestedFrameId:He.documentElement.dataset.requestedFrameId&&Ve}),e.options.userScriptEnabled&&r&&r(Ie.ON_AFTER_CAPTURE_EVENT_NAME),delete He.documentElement.dataset.requestedFrameId)}({windowId:Ve,sessionId:t,options:e});const r=We.get(t).frames;return r.sessionId=t,r},cleanup:function(e){We.delete(e),Ke({windowId:Ve,sessionId:e,options:{sessionId:e}})},initResponse:Ze,TIMEOUT_INIT_REQUEST_MESSAGE:Ue});const lt=globalThis.browser,ct=globalThis.document;if(ct instanceof globalThis.Document){const e=ct.createElement("script");e.async=!1,lt&<.runtime&<.runtime.getURL&&(e.src=lt.runtime.getURL("/lib/single-file-hooks.js"),e.async=!1),(ct.documentElement||ct).appendChild(e),e.remove()}var ut=Object.freeze({__proto__:null}),ht=Object.freeze({__proto__:null,frameTree:st,hooks:ut,hooksFrames:m,lazy:_e}),dt=Object.create,pt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,ft=Object.getOwnPropertyNames,gt=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty,bt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kt=(e,t)=>{for(var r in t)pt(e,r,{get:t[r],enumerable:!0})},vt=bt((e=>{var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");e.encode=function(e){if(0<=e&&e{var t=vt();e.encode=function(e){var r,n,o="",i=(n=e)<0?1+(-n<<1):0+(n<<1);do{r=31&i,(i>>>=5)>0&&(r|=32),o+=t.encode(r)}while(i>0);return o},e.decode=function(e,r,n){var o,i,a=e.length,s=0,l=0;do{if(r>=a)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(i=t.decode(e.charCodeAt(r++))))throw new Error("Invalid base64 digit: "+e.charAt(r-1));o=!!(32&i),s+=(i&=31)<>1;return 1==(1&e)?-t:t}(s),n.rest=r}})),xt=bt((e=>{e.getArg=function(e,t,r){if(t in e)return e[t];if(3===arguments.length)return r;throw new Error('"'+t+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,r=/^data:.+\,.+$/;function n(e){var r=e.match(t);return r?{scheme:r[1],auth:r[2],host:r[3],port:r[4],path:r[5]}:null}function o(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}e.urlParse=n,e.urlGenerate=o;var i,a,s=(i=function(t){var r=t,i=n(t);if(i){if(!i.path)return t;r=i.path}for(var a=e.isAbsolute(r),s=[],l=0,c=0;;){if(l=c,-1===(c=r.indexOf("/",l))){s.push(r.slice(l));break}for(s.push(r.slice(l,c));c=0;c--)"."===(u=s[c])?s.splice(c,1):".."===u?h++:h>0&&(""===u?(s.splice(c+1,h),h=0):(s.splice(c,2),h--));return""===(r=s.join("/"))&&(r=a?"/":"."),i?(i.path=r,o(i)):r},a=[],function(e){for(var t=0;t32&&a.pop(),n});function l(e,t){""===e&&(e="."),""===t&&(t=".");var i=n(t),a=n(e);if(a&&(e=a.path||"/"),i&&!i.scheme)return a&&(i.scheme=a.scheme),o(i);if(i||t.match(r))return t;if(a&&!a.host&&!a.path)return a.host=t,o(a);var l="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return a?(a.path=l,o(a)):l}e.normalize=s,e.join=l,e.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},e.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==t.indexOf(e+"/");){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n)).match(/^([^\/]+:\/)?\/*$/))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)};var c=!("__proto__"in Object.create(null));function u(e){return e}function h(e){if(!e)return!1;var t=e.length;if(t<9||95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var r=t-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function d(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}e.toSetString=c?u:function(e){return h(e)?"$"+e:e},e.fromSetString=c?u:function(e){return h(e)?e.slice(1):e},e.compareByOriginalPositions=function(e,t,r){var n=d(e.source,t.source);return 0!==n||0!==(n=e.originalLine-t.originalLine)||(0!==(n=e.originalColumn-t.originalColumn)||r)||0!==(n=e.generatedColumn-t.generatedColumn)||0!==(n=e.generatedLine-t.generatedLine)?n:d(e.name,t.name)},e.compareByOriginalPositionsNoSource=function(e,t,r){var n;return 0!==(n=e.originalLine-t.originalLine)||(0!==(n=e.originalColumn-t.originalColumn)||r)||0!==(n=e.generatedColumn-t.generatedColumn)||0!==(n=e.generatedLine-t.generatedLine)?n:d(e.name,t.name)},e.compareByGeneratedPositionsDeflated=function(e,t,r){var n=e.generatedLine-t.generatedLine;return 0!==n||(0!==(n=e.generatedColumn-t.generatedColumn)||r)||0!==(n=d(e.source,t.source))||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)?n:d(e.name,t.name)},e.compareByGeneratedPositionsDeflatedNoLine=function(e,t,r){var n=e.generatedColumn-t.generatedColumn;return 0!==n||r||0!==(n=d(e.source,t.source))||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)?n:d(e.name,t.name)},e.compareByGeneratedPositionsInflated=function(e,t){var r=e.generatedLine-t.generatedLine;return 0!==r||0!==(r=e.generatedColumn-t.generatedColumn)||0!==(r=d(e.source,t.source))||0!==(r=e.originalLine-t.originalLine)||0!==(r=e.originalColumn-t.originalColumn)?r:d(e.name,t.name)},e.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},e.computeSourceURL=function(e,t,r){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),r){var i=n(r);if(!i)throw new Error("sourceMapURL could not be parsed");if(i.path){var a=i.path.lastIndexOf("/");a>=0&&(i.path=i.path.substring(0,a+1))}t=l(o(i),t)}return s(t)}})),Et=bt((e=>{var t=xt(),r=Object.prototype.hasOwnProperty,n=typeof Map<"u";function o(){this._array=[],this._set=n?new Map:Object.create(null)}o.fromArray=function(e,t){for(var r=new o,n=0,i=e.length;n=0)return o}else{var i=t.toSetString(e);if(r.call(this._set,i))return this._set[i]}throw new Error('"'+e+'" is not in the set.')},o.prototype.at=function(e){if(e>=0&&e{var t=xt();function r(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}r.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},r.prototype.add=function(e){!function(e,r){var n=e.generatedLine,o=r.generatedLine,i=e.generatedColumn,a=r.generatedColumn;return o>n||o==n&&a>=i||t.compareByGeneratedPositionsInflated(e,r)<=0}(this._last,e)?(this._sorted=!1,this._array.push(e)):(this._last=e,this._array.push(e))},r.prototype.toArray=function(){return this._sorted||(this._array.sort(t.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},e.MappingList=r})),St=bt((e=>{var t=wt(),r=xt(),n=Et().ArraySet,o=At().MappingList;function i(e){e||(e={}),this._file=r.getArg(e,"file",null),this._sourceRoot=r.getArg(e,"sourceRoot",null),this._skipValidation=r.getArg(e,"skipValidation",!1),this._sources=new n,this._names=new n,this._mappings=new o,this._sourcesContents=null}i.prototype._version=3,i.fromSourceMap=function(e){var t=e.sourceRoot,n=new i({file:e.file,sourceRoot:t});return e.eachMapping((function(e){var o={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(o.source=e.source,null!=t&&(o.source=r.relative(t,o.source)),o.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(o.name=e.name)),n.addMapping(o)})),e.sources.forEach((function(o){var i=o;null!==t&&(i=r.relative(t,o)),n._sources.has(i)||n._sources.add(i);var a=e.sourceContentFor(o);null!=a&&n.setSourceContent(o,a)})),n},i.prototype.addMapping=function(e){var t=r.getArg(e,"generated"),n=r.getArg(e,"original",null),o=r.getArg(e,"source",null),i=r.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,n,o,i),null!=o&&(o=String(o),this._sources.has(o)||this._sources.add(o)),null!=i&&(i=String(i),this._names.has(i)||this._names.add(i)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=n&&n.line,originalColumn:null!=n&&n.column,source:o,name:i})},i.prototype.setSourceContent=function(e,t){var n=e;null!=this._sourceRoot&&(n=r.relative(this._sourceRoot,n)),null!=t?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[r.toSetString(n)]=t):this._sourcesContents&&(delete this._sourcesContents[r.toSetString(n)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},i.prototype.applySourceMap=function(e,t,o){var i=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');i=e.file}var a=this._sourceRoot;null!=a&&(i=r.relative(a,i));var s=new n,l=new n;this._mappings.unsortedForEach((function(t){if(t.source===i&&null!=t.originalLine){var n=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=n.source&&(t.source=n.source,null!=o&&(t.source=r.join(o,t.source)),null!=a&&(t.source=r.relative(a,t.source)),t.originalLine=n.line,t.originalColumn=n.column,null!=n.name&&(t.name=n.name))}var c=t.source;null!=c&&!s.has(c)&&s.add(c);var u=t.name;null!=u&&!l.has(u)&&l.add(u)}),this),this._sources=s,this._names=l,e.sources.forEach((function(t){var n=e.sourceContentFor(t);null!=n&&(null!=o&&(t=r.join(o,t)),null!=a&&(t=r.relative(a,t)),this.setSourceContent(t,n))}),this)},i.prototype._validateMapping=function(e,t,r,n){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||r||n){if(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&r)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:t,name:n}))}},i.prototype._serializeMappings=function(){for(var e,n,o,i,a=0,s=1,l=0,c=0,u=0,h=0,d="",p=this._mappings.toArray(),m=0,f=p.length;m0){if(!r.compareByGeneratedPositionsInflated(n,p[m-1]))continue;e+=","}e+=t.encode(n.generatedColumn-a),a=n.generatedColumn,null!=n.source&&(i=this._sources.indexOf(n.source),e+=t.encode(i-h),h=i,e+=t.encode(n.originalLine-1-c),c=n.originalLine-1,e+=t.encode(n.originalColumn-l),l=n.originalColumn,null!=n.name&&(o=this._names.indexOf(n.name),e+=t.encode(o-u),u=o)),d+=e}return d},i.prototype._generateSourcesContent=function(e,t){return e.map((function(e){if(!this._sourcesContents)return null;null!=t&&(e=r.relative(t,e));var n=r.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,n)?this._sourcesContents[n]:null}),this)},i.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},i.prototype.toString=function(){return JSON.stringify(this.toJSON())},e.SourceMapGenerator=i})),Tt={};kt(Tt,{AtKeyword:()=>It,BadString:()=>zt,BadUrl:()=>Mt,CDC:()=>jt,CDO:()=>Bt,Colon:()=>Ht,Comma:()=>Wt,Comment:()=>Zt,Delim:()=>Ot,Dimension:()=>Ft,EOF:()=>Ct,Function:()=>_t,Hash:()=>Lt,Ident:()=>Rt,LeftCurlyBracket:()=>Qt,LeftParenthesis:()=>Yt,LeftSquareBracket:()=>$t,Number:()=>Ut,Percentage:()=>Dt,RightCurlyBracket:()=>Kt,RightParenthesis:()=>Jt,RightSquareBracket:()=>Gt,Semicolon:()=>Vt,String:()=>Nt,Url:()=>Pt,WhiteSpace:()=>qt});var Ct=0,Rt=1,_t=2,It=3,Lt=4,Nt=5,zt=6,Pt=7,Mt=8,Ot=9,Ut=10,Dt=11,Ft=12,qt=13,Bt=14,jt=15,Ht=16,Vt=17,Wt=18,$t=19,Gt=20,Yt=21,Jt=22,Qt=23,Kt=24,Zt=25;function Xt(e){return e>=48&&e<=57}function er(e){return Xt(e)||e>=65&&e<=70||e>=97&&e<=102}function tr(e){return e>=65&&e<=90}function rr(e){return function(e){return tr(e)||function(e){return e>=97&&e<=122}(e)}(e)||function(e){return e>=128}(e)||95===e}function nr(e){return rr(e)||Xt(e)||45===e}function or(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function ir(e){return 10===e||13===e||12===e}function ar(e){return ir(e)||32===e||9===e}function sr(e,t){return!(92!==e||ir(t)||0===t)}function lr(e,t,r){return 45===e?rr(t)||45===t||sr(t,r):!!rr(e)||92===e&&sr(e,t)}function cr(e,t,r){return 43===e||45===e?Xt(t)?2:46===t&&Xt(r)?3:0:46===e?Xt(t)?2:0:Xt(e)?1:0}function ur(e){return 65279===e||65534===e?1:0}var hr=new Array(128),dr=130;for(let e=0;ee.length)return!1;for(let o=t;o=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var Sr=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token"];function Tr(e=null,t){return null===e||e.length0?ur(t.charCodeAt(0)):0,o=Tr(e.lines,r),i=Tr(e.columns,r),a=e.startLine,s=e.startColumn;for(let e=n;e{})){let r=(e=String(e||"")).length,n=Tr(this.offsetAndType,e.length+1),o=Tr(this.balance,e.length+1),i=0,a=0,s=0,l=-1;for(this.offsetAndType=null,this.balance=null,t(e,((e,t,c)=>{switch(e){default:o[i]=r;break;case a:{let e=s&Rr;for(s=o[e],a=s>>_r,o[i]=e,o[e++]=i;e>_r:0}lookupOffset(e){return(e+=this.tokenIndex)0?e>_r,this.tokenEnd=t&Rr):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e>_r,this.tokenEnd=e&Rr):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;13===this.tokenType||25===this.tokenType;)this.next()}skipUntilBalanced(e,t){let r,n,o=e;e:for(;o0?this.offsetAndType[o-1]&Rr:this.firstCharOffset,t(this.source.charCodeAt(n))){case 1:break e;case 2:o++;break e;default:this.balance[r]===o&&(o=r)}this.skip(o-this.tokenIndex)}forEachToken(e){for(let t=0,r=this.firstCharOffset;t>_r,n,i,t)}}dump(){let e=new Array(this.tokenCount);return this.forEachToken(((t,r,n,o)=>{e[o]={idx:o,type:Sr[t],chunk:this.source.substring(r,n),balance:this.balance[o]}})),e}};function Nr(e,t){function r(t){return t=e.length?void(cString(e+r+1).padStart(l)+" |"+t)).join("\n")}let i=e.split(/\r\n?|\n|\f/),a=Math.max(1,t-n)-1,s=Math.min(t+n,i.length+1),l=Math.max(4,String(s).length)+1,c=0;(r+=(Or.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length)>100&&(c=r-60+3,r=58);for(let e=a;e<=s;e++)e>=0&&e0&&i[e].length>c?"…":"")+i[e].substr(c,98)+(i[e].length>c+100-1?"…":""));return[o(a,t),new Array(r+l+2).join("-")+"^",o(t,s)].filter(Boolean).join("\n")}function Dr(e,t,r,n,o){return Object.assign(Mr("SyntaxError",e),{source:t,offset:r,line:n,column:o,sourceFragment:e=>Ur({source:t,line:n,column:o},isNaN(e)?0:e),get formattedMessage(){return`Parse error: ${e}\n`+Ur({source:t,line:n,column:o},2)}})}function Fr(e){let t=this.createList(),r=!1,n={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:r=!0,this.next();continue}let o=e.getNode.call(this,n);if(void 0===o)break;r&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,o,t,n),r=!1),t.push(o)}return r&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,n),t}var qr=()=>{};function Br(e){return function(){return this[e]()}}function jr(e){let t=Object.create(null);for(let r in e){let n=e[r],o=n.parse||n;o&&(t[r]=o)}return t}function Hr(e){let t="",r="",n=!1,o=qr,i=!1,a=new class{constructor(){this.lines=null,this.columns=null,this.computed=!1}setSource(e,t=0,r=1,n=1){this.source=e,this.startOffset=t,this.startLine=r,this.startColumn=n,this.computed=!1}getLocation(e,t){return this.computed||Cr(this),{source:t,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,t,r){return this.computed||Cr(this),{source:r,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}}},s=Object.assign(new Lr,function(e){let t={context:Object.create(null),scope:Object.assign(Object.create(null),e.scope),atrule:jr(e.atrule),pseudo:jr(e.pseudo),node:jr(e.node)};for(let r in e.parseContext)switch(typeof e.parseContext[r]){case"function":t.context[r]=e.parseContext[r];break;case"string":t.context[r]=Br(e.parseContext[r])}return{config:t,...t,...t.node}}(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Fr,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket:e=>123===e?1:0,consumeUntilLeftCurlyBracketOrSemicolon:e=>123===e||59===e?1:0,consumeUntilExclamationMarkOrSemicolon:e=>33===e||59===e?1:0,consumeUntilSemicolonIncluded:e=>59===e?2:0,createList:()=>new Pr,createSingleNodeList:e=>(new Pr).appendData(e),getFirstListNode:e=>e&&e.first,getLastListNode:e=>e&&e.last,parseWithFallback(e,t){let r=this.tokenIndex;try{return e.call(this)}catch(e){if(i)throw e;let n=t.call(this,r);return i=!0,o(e,n),i=!1,n}},lookupNonWSType(e){let t;do{if(t=this.lookupType(e++),13!==t)return t}while(0!==t);return 0},charCodeAt:e=>e>=0&&et.substring(e,r),substrToCursor(e){return this.source.substring(e,this.tokenStart)},cmpChar:(e,r)=>gr(t,e,r),cmpStr:(e,r,n)=>yr(t,e,r,n),consume(e){let t=this.tokenStart;return this.eat(e),this.substrToCursor(t)},consumeFunctionName(){let e=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),e},consumeNumber(e){let r=t.substring(this.tokenStart,xr(t,this.tokenStart));return this.eat(e),r},eat(e){if(this.tokenType!==e){let t=Sr[e].slice(0,-6).replace(/-/g," ").replace(/^./,(e=>e.toUpperCase())),r=`${/[[\](){}]/.test(t)?`"${t}"`:t} is expected`,n=this.tokenStart;switch(e){case 1:2===this.tokenType||7===this.tokenType?(n=this.tokenEnd-1,r="Identifier is expected but function found"):r="Identifier is expected";break;case 4:this.isDelim(35)&&(this.next(),n++,r="Name is expected");break;case 11:10===this.tokenType&&(n=this.tokenEnd,r="Percent sign is expected")}this.error(r,n)}this.next()},eatIdent(e){(1!==this.tokenType||!1===this.lookupValue(0,e))&&this.error(`Identifier "${e}" is expected`),this.next()},eatDelim(e){this.isDelim(e)||this.error(`Delim "${String.fromCharCode(e)}" is expected`),this.next()},getLocation:(e,t)=>n?a.getLocationRange(e,t,r):null,getLocationFromList(e){if(n){let t=this.getFirstListNode(e),n=this.getLastListNode(e);return a.getLocationRange(null!==t?t.loc.start.offset-a.startOffset:this.tokenStart,null!==n?n.loc.end.offset-a.startOffset:this.tokenStart,r)}return null},error(e,r){let n=typeof r<"u"&&r=0&&ar(e.charCodeAt(t));t--);return t+1}(t,t.length-1)):a.getLocation(this.tokenStart);throw new Dr(e||"Unexpected input",t,n.offset,n.line,n.column)}});return Object.assign((function(e,l){t=e,l=l||{},s.setSource(t,Nr),a.setSource(t,l.offset,l.line,l.column),r=l.filename||"",n=Boolean(l.positions),o="function"==typeof l.onParseError?l.onParseError:qr,i=!1,s.parseAtrulePrelude=!("parseAtrulePrelude"in l)||Boolean(l.parseAtrulePrelude),s.parseRulePrelude=!("parseRulePrelude"in l)||Boolean(l.parseRulePrelude),s.parseValue=!("parseValue"in l)||Boolean(l.parseValue),s.parseCustomProperty="parseCustomProperty"in l&&Boolean(l.parseCustomProperty);let{context:c="default",onComment:u}=l;if(!(c in s.context))throw new Error("Unknown context `"+c+"`");"function"==typeof u&&s.forEachToken(((e,r,n)=>{if(25===e){let e=s.getLocation(r,n),o=yr(t,n-2,n,"*/")?t.slice(r+2,n-2):t.slice(r+2,n);u(o,e)}}));let h=s.context[c].call(s,l);return s.eof||s.error(),h}),{SyntaxError:Dr,config:s.config})}var Vr,Wr,$r=(Vr=St(),Wr=1,((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of ft(t))!yt.call(e,o)&&(r||"default"!==o)&&pt(e,o,{get:()=>t[o],enumerable:!(n=mt(t,o))||n.enumerable});return e})((e=>pt(e,"__esModule",{value:!0}))(pt(null!=Vr?dt(gt(Vr)):{},"default",!Wr&&Vr&&Vr.__esModule?{get:()=>Vr.default,enumerable:!0}:{value:Vr,enumerable:!0})),Vr)),Gr=new Set(["Atrule","Selector","Declaration"]);var Yr={};kt(Yr,{safe:()=>en,spec:()=>Xr});var Jr=(e,t)=>{if(9===e&&(e=t),"string"==typeof e){let t=e.charCodeAt(0);return t>127?32768:t<<8}return e},Qr=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],Kr=Qr.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function Zr(e){let t=new Set(e.map((([e,t])=>Jr(e)<<16|Jr(t))));return function(e,r,n){let o=Jr(r,n),i=n.charCodeAt(0);return(45===i&&1!==r&&2!==r&&15!==r||43===i?t.has(e<<16|i<<8):t.has(e<<16|o))&&this.emit(" ",13,!0),o}}var Xr=Zr(Qr),en=Zr(Kr);function tn(e,t){if("function"!=typeof t)e.children.forEach(this.node,this);else{let r=null;e.children.forEach((e=>{null!==r&&t.call(this,r),this.node(e),r=e}))}}function rn(e){Nr(e,((t,r,n)=>{this.token(t,e.slice(r,n))}))}function nn(e){let t=new Map;for(let r in e.node){let n=e.node[r];"function"==typeof(n.generate||n)&&t.set(r,n.generate||n)}return function(e,r){let n="",o=0,i={node(e){if(!t.has(e.type))throw new Error("Unknown node type: "+e.type);t.get(e.type).call(a,e)},tokenBefore:en,token(e,t){o=this.tokenBefore(o,e,t),this.emit(t,e,!1),9===e&&92===t.charCodeAt(0)&&this.emit("\n",13,!0)},emit(e){n+=e},result:()=>n};r&&("function"==typeof r.decorator&&(i=r.decorator(i)),r.sourceMap&&(i=function(e){let t=new $r.SourceMapGenerator,r={line:1,column:0},n={line:0,column:0},o={line:1,column:0},i={generated:o},a=1,s=0,l=!1,c=e.node;e.node=function(e){if(e.loc&&e.loc.start&&Gr.has(e.type)){let c=e.loc.start.line,u=e.loc.start.column-1;(n.line!==c||n.column!==u)&&(n.line=c,n.column=u,r.line=a,r.column=s,l&&(l=!1,(r.line!==o.line||r.column!==o.column)&&t.addMapping(i)),l=!0,t.addMapping({source:e.loc.source,original:n,generated:r}))}c.call(this,e),l&&Gr.has(e.type)&&(o.line=a,o.column=s)};let u=e.emit;e.emit=function(e,t,r){for(let t=0;ti.node(e),children:tn,token:(e,t)=>i.token(e,t),tokenize:rn};return i.node(e),i.result()}}var{hasOwnProperty:on}=Object.prototype,an=function(){};function sn(e){return"function"==typeof e?e:an}function ln(e,t){return function(r,n,o){r.type===t&&e.call(this,r,n,o)}}function cn(e,t){let r=t.structure,n=[];for(let e in r){if(!1===on.call(r,e))continue;let t=r[e],o={name:e,type:!1,nullable:!1};Array.isArray(t)||(t=[t]);for(let e of t)null===e?o.nullable=!0:"string"==typeof e?o.type="node":Array.isArray(e)&&(o.type="list");o.type&&n.push(o)}return n.length?{context:t.walkContext,fields:n}:null}function un(e,t){let r=e.fields.slice(),n=e.context,o="string"==typeof n;return t&&r.reverse(),function(e,i,a,s){let l;o&&(l=i[n],i[n]=e);for(let n of r){let r=e[n.name];if(!n.nullable||r)if("list"===n.type){if(t?r.reduceRight(s,!1):r.reduce(s,!1))return!0}else if(a(r))return!0}o&&(i[n]=l)}}function hn({StyleSheet:e,Atrule:t,Rule:r,Block:n,DeclarationList:o}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:r,Block:n},Rule:{StyleSheet:e,Atrule:t,Rule:r,Block:n},Declaration:{StyleSheet:e,Atrule:t,Rule:r,Block:n,DeclarationList:o}}}function dn(e){let t=function(e){let t={};for(let r in e.node)if(on.call(e.node,r)){let n=e.node[r];if(!n.structure)throw new Error("Missed `structure` field in `"+r+"` node type definition");t[r]=cn(0,n)}return t}(e),r={},n={},o=Symbol("break-walk"),i=Symbol("skip-node");for(let e in t)on.call(t,e)&&null!==t[e]&&(r[e]=un(t[e],!1),n[e]=un(t[e],!0));let a=hn(r),s=hn(n),l=function(e,l){function c(e,t,r){let n=u.call(m,e,t,r);return n===o||n!==i&&!!(d.hasOwnProperty(e.type)&&d[e.type](e,m,c,p)||h.call(m,e,t,r)===o)}let u=an,h=an,d=r,p=(e,t,r,n)=>e||c(t,r,n),m={break:o,skip:i,root:e,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if("function"==typeof l)u=l;else if(l&&(u=sn(l.enter),h=sn(l.leave),l.reverse&&(d=n),l.visit)){if(a.hasOwnProperty(l.visit))d=l.reverse?s[l.visit]:a[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");u=ln(u,l.visit),h=ln(h,l.visit)}if(u===an&&h===an)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");c(e)};return l.break=o,l.skip=i,l.find=function(e,t){let r=null;return l(e,(function(e,n,i){if(t.call(this,e,n,i))return r=e,o})),r},l.findLast=function(e,t){let r=null;return l(e,{reverse:!0,enter:function(e,n,i){if(t.call(this,e,n,i))return r=e,o}}),r},l.findAll=function(e,t){let r=[];return l(e,(function(e,n,o){t.call(this,e,n,o)&&r.push(e)})),r},l}function pn(e){return e}function mn(e,t,r,n){let o;switch(e.type){case"Group":o=function(e,t,r,n){let o=" "===e.combinator||n?e.combinator:" "+e.combinator+" ",i=e.terms.map((e=>mn(e,t,r,n))).join(o);return e.explicit||r?(n||","===i[0]?"[":"[ ")+i+(n?"]":" ]"):i}(e,t,r,n)+(e.disallowEmpty?"!":"");break;case"Multiplier":return mn(e.term,t,r,n)+t(function(e){let{min:t,max:r,comma:n}=e;return 0===t&&0===r?"*":0===t&&1===r?"?":1===t&&0===r?n?"#":"+":1===t&&1===r?"":(n?"#":"")+(t===r?"{"+t+"}":"{"+t+","+(0!==r?r:"")+"}")}(e),e);case"Type":o="<"+e.name+(e.opts?t(function(e){if("Range"===e.type)return" ["+(null===e.min?"-∞":e.min)+","+(null===e.max?"∞":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}(e.opts),e.opts):"")+">";break;case"Property":o="<'"+e.name+"'>";break;case"Keyword":o=e.name;break;case"AtKeyword":o="@"+e.name;break;case"Function":o=e.name+"(";break;case"String":case"Token":o=e.value;break;case"Comma":o=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(o,e)}function fn(e,t){let r=pn,n=!1,o=!1;return"function"==typeof t?r=t:t&&(n=Boolean(t.forceBraces),o=Boolean(t.compact),"function"==typeof t.decorate&&(r=t.decorate)),mn(e,r,n,o)}var gn={offset:0,line:1,column:1};function yn(e,t){let r=e&&e.loc&&e.loc[t];return r?"line"in r?bn(r):r:null}function bn({offset:e,line:t,column:r},n){let o={offset:e,line:t,column:r};if(n){let e=n.split(/\n|\r\n?|\f/);o.offset+=n.length,o.line+=e.length-1,o.column=1===e.length?o.column+n.length:e.pop().length+1}return o}var kn=function(e,t){let r=Mr("SyntaxReferenceError",e+(t?" `"+t+"`":""));return r.reference=t,r},vn=function(e,t,r,n){let o=Mr("SyntaxMatchError",e),{css:i,mismatchOffset:a,mismatchLength:s,start:l,end:c}=function(e,t){let r,n,o=e.tokens,i=e.longestMatch,a=i1?(r=yn(s||t,"end")||bn(gn,h),n=bn(r)):(r=yn(s,"start")||bn(yn(t,"start")||gn,h.slice(0,l)),n=yn(s,"end")||bn(r,h.substr(l,c))),{css:h,mismatchOffset:l,mismatchLength:c,start:r,end:n}}(n,r);return o.rawMessage=e,o.syntax=t?fn(t):"",o.css=i,o.mismatchOffset=a,o.mismatchLength=s,o.message=e+"\n syntax: "+o.syntax+"\n value: "+(i||"")+"\n --------"+new Array(o.mismatchOffset+1).join("-")+"^",Object.assign(o,l),o.loc={source:r&&r.loc&&r.loc.source||"",start:l,end:c},o},wn=new Map,xn=new Map,En=function(e){if(wn.has(e))return wn.get(e);let t=e.toLowerCase(),r=wn.get(t);if(void 0===r){let e=Tn(t,0),n=e?"":Cn(t,0);r=Object.freeze({basename:t.substr(n.length),name:t,prefix:n,vendor:n,custom:e})}return wn.set(e,r),r},An=function(e){if(xn.has(e))return xn.get(e);let t=e,r=e[0];"/"===r?r="/"===e[1]?"//":"/":"_"!==r&&"*"!==r&&"$"!==r&&"#"!==r&&"+"!==r&&"&"!==r&&(r="");let n=Tn(t,r.length);if(!n&&(t=t.toLowerCase(),xn.has(t))){let r=xn.get(t);return xn.set(e,r),r}let o=n?"":Cn(t,r.length),i=t.substr(0,r.length+o.length),a=Object.freeze({basename:t.substr(i.length),name:t.substr(r.length),hack:r,vendor:o,prefix:i,custom:n});return xn.set(e,a),a},Sn=Cn;function Tn(e,t){return t=t||0,e.length-t>=2&&45===e.charCodeAt(t)&&45===e.charCodeAt(t+1)}function Cn(e,t){if(t=t||0,e.length-t>=3&&45===e.charCodeAt(t)&&45!==e.charCodeAt(t+1)){let r=e.indexOf("-",t+2);if(-1!==r)return e.substring(t,r+1)}return""}var Rn=45,_n=!0;function In(e,t){return null!==e&&9===e.type&&e.value.charCodeAt(0)===t}function Ln(e,t,r){for(;null!==e&&(13===e.type||25===e.type);)e=r(++t);return t}function Nn(e,t,r,n){if(!e)return 0;let o=e.value.charCodeAt(t);if(43===o||o===Rn){if(r)return 0;t++}for(;t6)return 0}return n}function On(e,t,r){if(!e)return 0;for(;Pn(r(t),63);){if(++e>6)return 0;t++}return t}var Un=["unset","initial","inherit"],Dn=["calc(","-moz-calc(","-webkit-calc("],Fn=new Map([[2,22],[21,22],[19,20],[23,24]]);function qn(e,t){return te.max)return!0}return!1}function Wn(e,t){let r=0,n=[],o=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==r)break e;if(r=n.pop(),0===n.length){o++;break e}break;case 2:case 21:case 19:case 23:n.push(r),r=Fn.get(e.type)}o++}while(e=t(o));return o}function $n(e){return function(t,r,n){return null===t?0:2===t.type&&jn(t.value,Dn)?Wn(t,r):e(t,r,n)}}function Gn(e){return function(t){return null===t||t.type!==e?0:1}}function Yn(e){return e&&(e=new Set(e)),function(t,r,n){if(null===t||12!==t.type)return 0;let o=xr(t.value,0);if(null!==e){let r=t.value.indexOf("\\",o),n=-1!==r&&Hn(t.value,r)?t.value.substring(o,r):t.value.substr(o);if(!1===e.has(n.toLowerCase()))return 0}return Vn(n,t.value,o)?0:1}}function Jn(e){return"function"!=typeof e&&(e=function(){return 0}),function(t,r,n){return null!==t&&10===t.type&&0===Number(t.value)?1:e(t,r,n)}}var Qn={"ident-token":Gn(1),"function-token":Gn(2),"at-keyword-token":Gn(3),"hash-token":Gn(4),"string-token":Gn(5),"bad-string-token":Gn(6),"url-token":Gn(7),"bad-url-token":Gn(8),"delim-token":Gn(9),"number-token":Gn(10),"percentage-token":Gn(11),"dimension-token":Gn(12),"whitespace-token":Gn(13),"CDO-token":Gn(14),"CDC-token":Gn(15),"colon-token":Gn(16),"semicolon-token":Gn(17),"comma-token":Gn(18),"[-token":Gn(19),"]-token":Gn(20),"(-token":Gn(21),")-token":Gn(22),"{-token":Gn(23),"}-token":Gn(24),string:Gn(5),ident:Gn(1),"custom-ident":function(e){if(null===e||1!==e.type)return 0;let t=e.value.toLowerCase();return jn(t,Un)||Bn(t,"default")?0:1},"custom-property-name":function(e){return null===e||1!==e.type||45!==qn(e.value,0)||45!==qn(e.value,1)?0:1},"hex-color":function(e){if(null===e||4!==e.type)return 0;let t=e.value.length;if(4!==t&&5!==t&&7!==t&&9!==t)return 0;for(let r=1;rZn,generate:()=>fn,parse:()=>mo,walk:()=>yo});var Xn=123,eo=new Uint8Array(128).map(((e,t)=>/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0)),to={" ":1,"&&":2,"||":3,"|":4};function ro(e){return e.substringToPos(e.findWsEnd(e.pos))}function no(e){let t=e.pos;for(;t=128||0===eo[r])break}return e.pos===t&&e.error("Expect a keyword"),e.substringToPos(t)}function oo(e){let t=e.pos;for(;t57)break}return e.pos===t&&e.error("Expect a number"),e.substringToPos(t)}function io(e){let t=e.str.indexOf("'",e.pos+1);return-1===t&&(e.pos=e.str.length,e.error("Expect an apostrophe")),e.substringToPos(t+1)}function ao(e){let t=null,r=null;return e.eat(Xn),t=oo(e),44===e.charCode()?(e.pos++,125!==e.charCode()&&(r=oo(e))):r=t,e.eat(125),{min:Number(t),max:r?Number(r):0}}function so(e,t){let r=function(e){let t=null,r=!1;switch(e.charCode()){case 42:e.pos++,t={min:0,max:0};break;case 43:e.pos++,t={min:1,max:0};break;case 63:e.pos++,t={min:0,max:1};break;case 35:e.pos++,r=!0,t=e.charCode()===Xn?ao(e):{min:1,max:0};break;case Xn:t=ao(e);break;default:return null}return{type:"Multiplier",comma:r,min:t.min,max:t.max,term:null}}(e);return null!==r?(r.term=t,r):t}function lo(e){let t=e.peek();return""===t?null:{type:"Token",value:t}}function co(e){let t,r=null;return e.eat(60),t=no(e),40===e.charCode()&&41===e.nextCharCode()&&(e.pos+=2,t+="()"),91===e.charCodeAt(e.findWsEnd(e.pos))&&(ro(e),r=function(e){let t=null,r=null,n=1;return e.eat(91),45===e.charCode()&&(e.peek(),n=-1),-1==n&&8734===e.charCode()?e.peek():t=n*Number(oo(e)),ro(e),e.eat(44),ro(e),8734===e.charCode()?e.peek():(n=1,45===e.charCode()&&(e.peek(),n=-1),r=n*Number(oo(e))),e.eat(93),null===t&&null===r?null:{type:"Range",min:t,max:r}}(e)),e.eat(62),so(e,{type:"Type",name:t,opts:r})}function uo(e,t){function r(e,t){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:!1}}let n;for(t=Object.keys(t).sort(((e,t)=>to[e]-to[t]));t.length>0;){n=t.shift();let o=0,i=0;for(;o1&&(e.splice(i,o-i,r(e.slice(i,o),n)),o=i+1),i=-1))}-1!==i&&t.length&&e.splice(i,o-i,r(e.slice(i,o),n))}return n}function ho(e){let t,r=[],n={},o=null,i=e.pos;for(;t=po(e);)"Spaces"!==t.type&&("Combinator"===t.type?((null===o||"Combinator"===o.type)&&(e.pos=i,e.error("Unexpected combinator")),n[t.value]=!0):null!==o&&"Combinator"!==o.type&&(n[" "]=!0,r.push({type:"Combinator",value:" "})),r.push(t),o=t,i=e.pos);return null!==o&&"Combinator"===o.type&&(e.pos-=i,e.error("Unexpected combinator")),{type:"Group",terms:r,combinator:uo(r,n)||" ",disallowEmpty:!1,explicit:!1}}function po(e){let t=e.charCode();if(t<128&&1===eo[t])return function(e){let t=no(e);return 40===e.charCode()?(e.pos++,{type:"Function",name:t}):so(e,{type:"Keyword",name:t})}(e);switch(t){case 93:break;case 91:return so(e,function(e){let t;return e.eat(91),t=ho(e),e.eat(93),t.explicit=!0,33===e.charCode()&&(e.pos++,t.disallowEmpty=!0),t}(e));case 60:return 39===e.nextCharCode()?function(e){let t;return e.eat(60),e.eat(39),t=no(e),e.eat(39),e.eat(62),so(e,{type:"Property",name:t})}(e):co(e);case 124:return{type:"Combinator",value:e.substringToPos(e.pos+(124===e.nextCharCode()?2:1))};case 38:return e.pos++,e.eat(38),{type:"Combinator",value:"&&"};case 44:return e.pos++,{type:"Comma"};case 39:return so(e,{type:"String",value:io(e)});case 32:case 9:case 10:case 13:case 12:return{type:"Spaces",value:ro(e)};case 64:return t=e.nextCharCode(),t<128&&1===eo[t]?(e.pos++,{type:"AtKeyword",name:no(e)}):lo(e);case 42:case 43:case 63:case 35:case 33:break;case Xn:if(t=e.nextCharCode(),t<48||t>57)return lo(e);break;default:return lo(e)}}function mo(e){let t=new class{constructor(e){this.str=e,this.pos=0}charCodeAt(e){return et}}};function ko(e,t){return"string"==typeof e?function(e){let t=[];return Nr(e,((r,n,o)=>t.push({type:r,value:e.slice(n,o),node:null}))),t}(e):t.generate(e,bo)}var vo={type:"Match"},wo={type:"Mismatch"},xo={type:"DisallowEmpty"};function Eo(e,t,r){return t===vo&&r===wo||e===vo&&t===vo&&r===vo?e:("If"===e.type&&e.else===wo&&t===vo&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:r})}function Ao(e){return e.length>2&&40===e.charCodeAt(e.length-2)&&41===e.charCodeAt(e.length-1)}function So(e){return"Keyword"===e.type||"AtKeyword"===e.type||"Function"===e.type||"Type"===e.type&&Ao(e.name)}function To(e,t,r){switch(e){case" ":{let e=vo;for(let r=t.length-1;r>=0;r--){e=Eo(t[r],e,wo)}return e}case"|":{let e=wo,r=null;for(let n=t.length-1;n>=0;n--){let o=t[n];if(So(o)&&(null===r&&n>0&&So(t[n-1])&&(r=Object.create(null),e=Eo({type:"Enum",map:r},vo,e)),null!==r)){let e=(Ao(o.name)?o.name.slice(0,-1):o.name).toLowerCase();if(!(e in r)){r[e]=o;continue}}r=null,e=Eo(o,vo,e)}return e}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let r=wo;for(let n=t.length-1;n>=0;n--){let o,i=t[n];o=t.length>1?To(e,t.filter((function(e){return e!==i})),!1):vo,r=Eo(i,o,r)}return r}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let n=r?vo:wo;for(let r=t.length-1;r>=0;r--){let o,i=t[r];o=t.length>1?To(e,t.filter((function(e){return e!==i})),!0):vo,n=Eo(i,o,n)}return n}}}function Co(e){if("function"==typeof e)return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=To(e.combinator,e.terms.map(Co),!1);return e.disallowEmpty&&(t=Eo(t,xo,wo)),t}case"Multiplier":return function(e){let t=vo,r=Co(e.term);if(0===e.max)r=Eo(r,xo,wo),t=Eo(r,null,wo),t.then=Eo(vo,vo,t),e.comma&&(t.then.else=Eo({type:"Comma",syntax:e},t,wo));else for(let n=e.min||1;n<=e.max;n++)e.comma&&t!==vo&&(t=Eo({type:"Comma",syntax:e},t,wo)),t=Eo(r,Eo(vo,vo,t),wo);if(0===e.min)t=Eo(vo,vo,t);else for(let n=0;n=65&&o<=90&&(o|=32),o!==n)return!1}return!0}function No(e){return null===e||(18===e.type||2===e.type||21===e.type||19===e.type||23===e.type||function(e){return 9===e.type&&"?"!==e.value}(e))}function zo(e){return null===e||(22===e.type||20===e.type||24===e.type||9===e.type)}function Po(e,t,r){let n=function(e,t,r){function n(){do{y++,g=yb&&(b=y)}function c(){k=2===k.type?k.prev:{type:3,syntax:u.syntax,token:k.token,prev:k},u=u.prev}let u=null,h=null,d=null,p=null,m=0,f=null,g=null,y=-1,b=0,k={type:0,syntax:null,token:null,prev:null};for(n();null===f&&++m<15e3;)switch(t.type){case"Match":if(null===h){if(null!==g&&(y!==e.length-1||"\\0"!==g.value&&"\\9"!==g.value)){t=wo;break}f=Io;break}if((t=h.nextState)===xo){if(h.matchStack===k){t=wo;break}t=vo}for(;h.syntaxStack!==u;)c();h=h.prev;break;case"Mismatch":if(null!==p&&!1!==p)(null===d||y>d.tokenIndex)&&(d=p,p=!1);else if(null===d){f="Mismatch";break}t=d.nextState,h=d.thenStack,u=d.syntaxStack,k=d.matchStack,y=d.tokenIndex,g=yy){for(;y":"<'"+t.name+"'>"));if(!1!==p&&null!==g&&"Type"===t.type&&("custom-ident"===t.name&&1===g.type||"length"===t.name&&"0"===g.value)){null===p&&(p=i(t,d)),t=wo;break}u={syntax:t.syntax,opts:t.syntax.opts||null!==u&&u.opts||null,prev:u},k={type:2,syntax:t.syntax,token:k.token,prev:k},t=n.match;break}case"Keyword":{let e=t.name;if(null!==g){let r=g.value;if(-1!==r.indexOf("\\")&&(r=r.replace(/\\[09].*$/,"")),Lo(r,e)){l(),t=vo;break}}t=wo;break}case"AtKeyword":case"Function":if(null!==g&&Lo(g.value,t.name)){l(),t=vo;break}t=wo;break;case"Token":if(null!==g&&g.value===t.value){l(),t=vo;break}t=wo;break;case"Comma":null!==g&&18===g.type?No(k.token)?t=wo:(l(),t=zo(g)?wo:vo):t=No(k.token)||zo(g)?vo:wo;break;case"String":let n="",m=y;for(;m"Type"===e.type&&e.name===t))}function Do(e,t){return qo(this,e,(e=>"Property"===e.type&&e.name===t))}function Fo(e){return qo(this,e,(e=>"Keyword"===e.type))}function qo(e,t,r){let n=Oo.call(e,t);return null!==n&&n.some(r)}function Bo(e){return"node"in e?e.node:Bo(e.match[0])}function jo(e){return"node"in e?e.node:jo(e.match[e.match.length-1])}function Ho(e,t,r,n,o){let i=[];return null!==r.matched&&function r(a){if(null!==a.syntax&&a.syntax.type===n&&a.syntax.name===o){let r=Bo(a),n=jo(a);e.syntax.walk(t,(function(e,t,o){if(e===r){let e=new Pr;do{if(e.appendData(t.data),t.data===n)break;t=t.next}while(null!==t);i.push({parent:o,nodes:e})}}))}Array.isArray(a.match)&&a.match.forEach(r)}(r.matched),i}kt(Mo,{getTrace:()=>Oo,isKeyword:()=>Fo,isProperty:()=>Do,isType:()=>Uo});var{hasOwnProperty:Vo}=Object.prototype;function Wo(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}function $o(e){return Boolean(e)&&Wo(e.offset)&&Wo(e.line)&&Wo(e.column)}function Go(e,t){return function(r,n){if(!r||r.constructor!==Object)return n(r,"Type of node should be an Object");for(let o in r){let i=!0;if(!1!==Vo.call(r,o)){if("type"===o)r.type!==e&&n(r,"Wrong node type `"+r.type+"`, expected `"+e+"`");else if("loc"===o){if(null===r.loc)continue;if(r.loc&&r.loc.constructor===Object)if("string"!=typeof r.loc.source)o+=".source";else if($o(r.loc.start)){if($o(r.loc.end))continue;o+=".end"}else o+=".start";i=!1}else if(t.hasOwnProperty(o)){i=!1;for(let e=0;!i&&e");else{if(!Array.isArray(n))throw new Error("Wrong value `"+n+"` in `"+e+"."+t+"` structure definition");i.push("List")}}o[t]=i.join(" | ")}return{docs:o,check:Go(e,n)}}var Jo=Ro("inherit | initial | unset"),Qo=Ro("inherit | initial | unset | <-ms-legacy-expression>");function Ko(e,t,r){let n={};for(let o in e)e[o].syntax&&(n[o]=r?e[o].syntax:fn(e[o].syntax,{compact:t}));return n}function Zo(e,t,r){let n={};for(let[o,i]of Object.entries(e))n[o]={prelude:i.prelude&&(r?i.prelude.syntax:fn(i.prelude.syntax,{compact:t})),descriptors:i.descriptors&&Ko(i.descriptors,t,r)};return n}function Xo(e,t,r){return{matched:e,iterations:r,error:t,...Mo}}function ei(e,t,r,n){let o,i=ko(r,e.syntax);return function(e){for(let t=0;t(Object.defineProperty(i,"syntax",{value:mo(e)}),i.syntax)}):i.syntax=e,Object.defineProperty(i,"match",{get:()=>(Object.defineProperty(i,"match",{value:Ro(i.syntax,o)}),i.match)})),i}addAtrule_(e,t){!t||(this.atrules[e]={type:"Atrule",name:e,prelude:t.prelude?this.createDescriptor(t.prelude,"AtrulePrelude",e):null,descriptors:t.descriptors?Object.keys(t.descriptors).reduce(((r,n)=>(r[n]=this.createDescriptor(t.descriptors[n],"AtruleDescriptor",n,e),r)),Object.create(null)):null})}addProperty_(e,t){!t||(this.properties[e]=this.createDescriptor(t,"Property",e))}addType_(e,t){!t||(this.types[e]=this.createDescriptor(t,"Type",e),t===Qn["-ms-legacy-expression"]&&(this.valueCommonSyntax=Qo))}checkAtruleName(e){if(!this.getAtrule(e))return new kn("Unknown at-rule","@"+e)}checkAtrulePrelude(e,t){let r=this.checkAtruleName(e);if(r)return r;let n=this.getAtrule(e);return!n.prelude&&t?new SyntaxError("At-rule `@"+e+"` should not contain a prelude"):n.prelude&&!t?new SyntaxError("At-rule `@"+e+"` should contain a prelude"):void 0}checkAtruleDescriptorName(e,t){let r=this.checkAtruleName(e);if(r)return r;let n=this.getAtrule(e),o=En(t);return n.descriptors?n.descriptors[o.name]||n.descriptors[o.basename]?void 0:new kn("Unknown at-rule descriptor",t):new SyntaxError("At-rule `@"+e+"` has no known descriptors")}checkPropertyName(e){if(!this.getProperty(e))return new kn("Unknown property",e)}matchAtrulePrelude(e,t){let r=this.checkAtrulePrelude(e,t);return r?Xo(null,r):t?ei(this,this.getAtrule(e).prelude,t,!1):Xo(null,null)}matchAtruleDescriptor(e,t,r){let n=this.checkAtruleDescriptorName(e,t);if(n)return Xo(null,n);let o=this.getAtrule(e),i=En(t);return ei(this,o.descriptors[i.name]||o.descriptors[i.basename],r,!1)}matchDeclaration(e){return"Declaration"!==e.type?Xo(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)}matchProperty(e,t){if(An(e).custom)return Xo(null,new Error("Lexer matching doesn't applicable for custom properties"));let r=this.checkPropertyName(e);return r?Xo(null,r):ei(this,this.getProperty(e),t,!0)}matchType(e,t){let r=this.getType(e);return r?ei(this,r,t,!1):Xo(null,new kn("Unknown type",e))}match(e,t){return"string"==typeof e||e&&e.type?(("string"==typeof e||!e.match)&&(e=this.createDescriptor(e,"Type","anonymous")),ei(this,e,t,!1)):Xo(null,new kn("Bad syntax"))}findValueFragments(e,t,r,n){return Ho(this,t,this.matchProperty(e,t),r,n)}findDeclarationValueFragments(e,t,r){return Ho(this,e.value,this.matchDeclaration(e),t,r)}findAllFragments(e,t,r){let n=[];return this.syntax.walk(e,{visit:"Declaration",enter:e=>{n.push.apply(n,this.findDeclarationValueFragments(e,t,r))}}),n}getAtrule(e,t=!0){let r=En(e);return(r.vendor&&t?this.atrules[r.name]||this.atrules[r.basename]:this.atrules[r.name])||null}getAtrulePrelude(e,t=!0){let r=this.getAtrule(e,t);return r&&r.prelude||null}getAtruleDescriptor(e,t){return this.atrules.hasOwnProperty(e)&&this.atrules.declarators&&this.atrules[e].declarators[t]||null}getProperty(e,t=!0){let r=An(e);return(r.vendor&&t?this.properties[r.name]||this.properties[r.basename]:this.properties[r.name])||null}getType(e){return hasOwnProperty.call(this.types,e)?this.types[e]:null}validate(){function e(n,o,i,a){if(i.has(o))return i.get(o);i.set(o,!1),null!==a.syntax&&yo(a.syntax,(function(a){if("Type"!==a.type&&"Property"!==a.type)return;let s="Type"===a.type?n.types:n.properties,l="Type"===a.type?t:r;(!hasOwnProperty.call(s,a.name)||e(n,a.name,l,s[a.name]))&&i.set(o,!0)}),this)}let t=new Map,r=new Map;for(let r in this.types)e(this,r,t,this.types[r]);for(let t in this.properties)e(this,t,r,this.properties[t]);return t=[...t.keys()].filter((e=>t.get(e))),r=[...r.keys()].filter((e=>r.get(e))),t.length||r.length?{types:t,properties:r}:null}dump(e,t){return{generic:this.generic,types:Ko(this.types,!t,e),properties:Ko(this.properties,!t,e),atrules:Zo(this.atrules,!t,e)}}toString(){return JSON.stringify(this.dump())}},{hasOwnProperty:ri}=Object.prototype,ni={generic:!0,types:si,atrules:{prelude:li,descriptors:li},properties:si,parseContext:function(e,t){return Object.assign(e,t)},scope:function e(t,r){for(let n in r)ri.call(r,n)&&(oi(t[n])?e(t[n],ii(r[n])):t[n]=ii(r[n]));return t},atrule:["parse"],pseudo:["parse"],node:["name","structure","parse","generate","walkContext"]};function oi(e){return e&&e.constructor===Object}function ii(e){return oi(e)?{...e}:e}function ai(e,t){return"string"==typeof t&&/^\s*\|/.test(t)?"string"==typeof e?e+t:t.replace(/^\s*\|\s*/,""):t||null}function si(e,t){if("string"==typeof t)return ai(e,t);let r={...e};for(let n in t)ri.call(t,n)&&(r[n]=ai(ri.call(e,n)?e[n]:void 0,t[n]));return r}function li(e,t){let r=si(e,t);return!oi(r)||Object.keys(r).length?r:null}function ci(e,t,r){for(let n in r)if(!1!==ri.call(r,n))if(!0===r[n])n in t&&ri.call(t,n)&&(e[n]=ii(t[n]));else if(r[n])if("function"==typeof r[n]){let o=r[n];e[n]=o({},e[n]),e[n]=o(e[n]||{},t[n])}else if(oi(r[n])){let o={};for(let t in e[n])o[t]=ci({},e[n][t],r[n]);for(let e in t[n])o[e]=ci(o[e]||{},t[n][e],r[n]);e[n]=o}else if(Array.isArray(r[n])){let o={},i=r[n].reduce((function(e,t){return e[t]=!0,e}),{});for(let[t,r]of Object.entries(e[n]||{}))o[t]={},r&&ci(o[t],r,i);for(let e in t[n])ri.call(t[n],e)&&(o[e]||(o[e]={}),t[n]&&t[n][e]&&ci(o[e],t[n][e],i));e[n]=o}return e}var ui=(e,t)=>ci(e,t,ni);function hi(e){let t=Hr(e),r=dn(e),n=nn(e),{fromPlainObject:o,toPlainObject:i}=function(e){return{fromPlainObject:function(t){return e(t,{enter:function(e){e.children&&!(e.children instanceof Pr)&&(e.children=(new Pr).fromArray(e.children))}}),t},toPlainObject:function(t){return e(t,{leave:function(e){e.children&&e.children instanceof Pr&&(e.children=e.children.toArray())}}),t}}}(r),a={lexer:null,createLexer:e=>new ti(e,a,a.lexer.structure),tokenize:Nr,parse:t,generate:n,walk:r,find:r.find,findLast:r.findLast,findAll:r.findAll,fromPlainObject:o,toPlainObject:i,fork(t){let r=ui({},e);return hi("function"==typeof t?t(r,Object.assign):ui(r,t))}};return a.lexer=new ti({generic:!0,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},a),a}var di=e=>hi(ui({},e)),pi={};kt(pi,{AnPlusB:()=>mi,Atrule:()=>Ci,AtrulePrelude:()=>Mi,AttributeSelector:()=>Bi,Block:()=>Yi,Brackets:()=>oa,CDC:()=>ca,CDO:()=>ma,ClassSelector:()=>ka,Combinator:()=>Aa,Comment:()=>_a,Declaration:()=>Pa,DeclarationList:()=>Wa,Dimension:()=>Ka,Function:()=>rs,Hash:()=>ls,IdSelector:()=>ks,Identifier:()=>ms,MediaFeature:()=>As,MediaQuery:()=>_s,MediaQueryList:()=>Ps,Nth:()=>Fs,Number:()=>Vs,Operator:()=>Js,Parentheses:()=>el,Percentage:()=>il,PseudoClassSelector:()=>ul,PseudoElementSelector:()=>gl,Ratio:()=>xl,Raw:()=>Rl,Rule:()=>Pl,Selector:()=>jl,SelectorList:()=>Gl,String:()=>Xl,StyleSheet:()=>sc,TypeSelector:()=>mc,UnicodeRange:()=>vc,Url:()=>_c,Value:()=>Uc,WhiteSpace:()=>jc});var mi={};kt(mi,{generate:()=>Ti,name:()=>Ei,parse:()=>Si,structure:()=>Ai});var fi=43,gi=45,yi=110,bi=!0;function ki(e,t){let r=this.tokenStart+e,n=this.charCodeAt(r);for((n===fi||n===gi)&&(t&&this.error("Number sign is not allowed"),r++);r0&&this.skip(e),0===t&&(r=this.charCodeAt(this.tokenStart),r!==fi&&r!==gi&&this.error("Number sign is expected")),vi.call(this,0!==t),t===gi?"-"+this.consume(10):this.consume(10)}var Ei="AnPlusB",Ai={a:[String,null],b:[String,null]};function Si(){let e=this.tokenStart,t=null,r=null;if(10===this.tokenType)vi.call(this,false),r=this.consume(10);else if(1===this.tokenType&&this.cmpChar(this.tokenStart,gi))switch(t="-1",wi.call(this,1,yi),this.tokenEnd-this.tokenStart){case 2:this.next(),r=xi.call(this);break;case 3:wi.call(this,2,gi),this.next(),this.skipSC(),vi.call(this,bi),r="-"+this.consume(10);break;default:wi.call(this,2,gi),ki.call(this,3,bi),this.next(),r=this.substrToCursor(e+2)}else if(1===this.tokenType||this.isDelim(fi)&&1===this.lookupType(1)){let n=0;switch(t="1",this.isDelim(fi)&&(n=1,this.next()),wi.call(this,0,yi),this.tokenEnd-this.tokenStart){case 1:this.next(),r=xi.call(this);break;case 2:wi.call(this,1,gi),this.next(),this.skipSC(),vi.call(this,bi),r="-"+this.consume(10);break;default:wi.call(this,1,gi),ki.call(this,2,bi),this.next(),r=this.substrToCursor(e+n+1)}}else if(12===this.tokenType){let n=this.charCodeAt(this.tokenStart),o=n===fi||n===gi,i=this.tokenStart+o;for(;iPi,name:()=>Ii,parse:()=>zi,structure:()=>Ni,walkContext:()=>Li});var Ii="Atrule",Li="atrule",Ni={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function zi(){let e,t,r=this.tokenStart,n=null,o=null;switch(this.eat(3),e=this.substrToCursor(r+1),t=e.toLowerCase(),this.skipSC(),!1===this.eof&&23!==this.tokenType&&17!==this.tokenType&&(n=this.parseAtrulePrelude?this.parseWithFallback(this.AtrulePrelude.bind(this,e),Ri):Ri.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:o=hasOwnProperty.call(this.atrule,t)&&"function"==typeof this.atrule[t].block?this.atrule[t].block.call(this):this.Block(_i.call(this))}return{type:"Atrule",loc:this.getLocation(r,this.tokenStart),name:e,prelude:n,block:o}}function Pi(e){this.token(3,"@"+e.name),null!==e.prelude&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var Mi={};kt(Mi,{generate:()=>qi,name:()=>Oi,parse:()=>Fi,structure:()=>Di,walkContext:()=>Ui});var Oi="AtrulePrelude",Ui="atrulePrelude",Di={children:[[]]};function Fi(e){let t=null;return null!==e&&(e=e.toLowerCase()),this.skipSC(),t=hasOwnProperty.call(this.atrule,e)&&"function"==typeof this.atrule[e].prelude?this.atrule[e].prelude.call(this):this.readSequence(this.scope.AtrulePrelude),this.skipSC(),!0!==this.eof&&23!==this.tokenType&&17!==this.tokenType&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function qi(e){this.children(e)}var Bi={};kt(Bi,{generate:()=>Gi,name:()=>Vi,parse:()=>$i,structure:()=>Wi});function ji(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(42)?(t=!0,this.next()):this.isDelim(124)||this.eat(1),this.isDelim(124)?61!==this.charCodeAt(this.tokenStart+1)?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Hi(){let e=this.tokenStart,t=this.charCodeAt(e);return 61!==t&&126!==t&&94!==t&&36!==t&&42!==t&&124!==t&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),61!==t&&(this.isDelim(61)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}var Vi="AttributeSelector",Wi={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function $i(){let e,t=this.tokenStart,r=null,n=null,o=null;return this.eat(19),this.skipSC(),e=ji.call(this),this.skipSC(),20!==this.tokenType&&(1!==this.tokenType&&(r=Hi.call(this),this.skipSC(),n=5===this.tokenType?this.String():this.Identifier(),this.skipSC()),1===this.tokenType&&(o=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:r,value:n,flags:o}}function Gi(e){this.token(9,"["),this.node(e.name),null!==e.matcher&&(this.tokenize(e.matcher),this.node(e.value)),null!==e.flags&&this.token(1,e.flags),this.token(9,"]")}var Yi={};function Ji(e){return this.Raw(e,null,!0)}function Qi(){return this.parseWithFallback(this.Rule,Ji)}function Ki(e){return this.Raw(e,this.consumeUntilSemicolonIncluded,!0)}function Zi(){if(17===this.tokenType)return Ki.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,Ki);return 17===this.tokenType&&this.next(),e}kt(Yi,{generate:()=>na,name:()=>Xi,parse:()=>ra,structure:()=>ta,walkContext:()=>ea});var Xi="Block",ea="block",ta={children:[["Atrule","Rule","Declaration"]]};function ra(e){let t=e?Zi:Qi,r=this.tokenStart,n=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:n.push(this.parseWithFallback(this.Atrule,Ji));break;default:n.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(r,this.tokenStart),children:n}}function na(e){this.token(23,"{"),this.children(e,(e=>{"Declaration"===e.type&&this.token(17,";")})),this.token(24,"}")}var oa={};kt(oa,{generate:()=>la,name:()=>ia,parse:()=>sa,structure:()=>aa});var ia="Brackets",aa={children:[[]]};function sa(e,t){let r=this.tokenStart,n=null;return this.eat(19),n=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(r,this.tokenStart),children:n}}function la(e){this.token(9,"["),this.children(e),this.token(9,"]")}var ca={};kt(ca,{generate:()=>pa,name:()=>ua,parse:()=>da,structure:()=>ha});var ua="CDC",ha=[];function da(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function pa(){this.token(15,"--\x3e")}var ma={};kt(ma,{generate:()=>ba,name:()=>fa,parse:()=>ya,structure:()=>ga});var fa="CDO",ga=[];function ya(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function ba(){this.token(14,"\x3c!--")}var ka={};kt(ka,{generate:()=>Ea,name:()=>va,parse:()=>xa,structure:()=>wa});var va="ClassSelector",wa={name:String};function xa(){return this.eatDelim(46),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function Ea(e){this.token(9,"."),this.token(1,e.name)}var Aa={};kt(Aa,{generate:()=>Ra,name:()=>Sa,parse:()=>Ca,structure:()=>Ta});var Sa="Combinator",Ta={name:String};function Ca(){let e,t=this.tokenStart;switch(this.tokenType){case 13:e=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case 62:case 43:case 126:this.next();break;case 47:this.next(),this.eatIdent("deep"),this.eatDelim(47);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t)}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function Ra(e){this.tokenize(e.name)}var _a={};kt(_a,{generate:()=>za,name:()=>Ia,parse:()=>Na,structure:()=>La});var Ia="Comment",La={value:String};function Na(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&42===this.charCodeAt(t-2)&&47===this.charCodeAt(t-1)&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function za(e){this.token(25,"/*"+e.value+"*/")}var Pa={};kt(Pa,{generate:()=>ja,name:()=>Da,parse:()=>Ba,structure:()=>qa,walkContext:()=>Fa});function Ma(e){return this.Raw(e,this.consumeUntilExclamationMarkOrSemicolon,!0)}function Oa(e){return this.Raw(e,this.consumeUntilExclamationMarkOrSemicolon,!1)}function Ua(){let e=this.tokenIndex,t=this.Value();return"Raw"!==t.type&&!1===this.eof&&17!==this.tokenType&&!1===this.isDelim(33)&&!1===this.isBalanceEdge(e)&&this.error(),t}var Da="Declaration",Fa="declaration",qa={important:[Boolean,String],property:String,value:["Value","Raw"]};function Ba(){let e,t=this.tokenStart,r=this.tokenIndex,n=Ha.call(this),o=Tn(n),i=o?this.parseCustomProperty:this.parseValue,a=o?Oa:Ma,s=!1;this.skipSC(),this.eat(16);let l=this.tokenIndex;if(o||this.skipSC(),e=i?this.parseWithFallback(Ua,a):a.call(this,this.tokenIndex),o&&"Value"===e.type&&e.children.isEmpty)for(let t=l-this.tokenIndex;t<=0;t++)if(13===this.lookupType(t)){e.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}return this.isDelim(33)&&(s=Va.call(this),this.skipSC()),!1===this.eof&&17!==this.tokenType&&!1===this.isBalanceEdge(r)&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.tokenStart),important:s,property:n,value:e}}function ja(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,!0===e.important?"important":e.important))}function Ha(){let e=this.tokenStart;if(9===this.tokenType)switch(this.charCodeAt(this.tokenStart)){case 42:case 36:case 43:case 35:case 38:this.next();break;case 47:this.next(),this.isDelim(47)&&this.next()}return 4===this.tokenType?this.eat(4):this.eat(1),this.substrToCursor(e)}function Va(){this.eat(9),this.skipSC();let e=this.consume(1);return"important"===e||e}var Wa={};function $a(e){return this.Raw(e,this.consumeUntilSemicolonIncluded,!0)}kt(Wa,{generate:()=>Qa,name:()=>Ga,parse:()=>Ja,structure:()=>Ya});var Ga="DeclarationList",Ya={children:[["Declaration"]]};function Ja(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;default:e.push(this.parseWithFallback(this.Declaration,$a))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function Qa(e){this.children(e,(e=>{"Declaration"===e.type&&this.token(17,";")}))}var Ka={};kt(Ka,{generate:()=>ts,name:()=>Za,parse:()=>es,structure:()=>Xa});var Za="Dimension",Xa={value:String,unit:String};function es(){let e=this.tokenStart,t=this.consumeNumber(12);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function ts(e){this.token(12,e.value+e.unit)}var rs={};kt(rs,{generate:()=>ss,name:()=>ns,parse:()=>as,structure:()=>is,walkContext:()=>os});var ns="Function",os="function",is={name:String,children:[[]]};function as(e,t){let r,n=this.tokenStart,o=this.consumeFunctionName(),i=o.toLowerCase();return r=t.hasOwnProperty(i)?t[i].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:o,children:r}}function ss(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var ls={};kt(ls,{generate:()=>ps,name:()=>us,parse:()=>ds,structure:()=>hs,xxx:()=>cs});var cs="XXX",us="Hash",hs={value:String};function ds(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function ps(e){this.token(4,"#"+e.value)}var ms={};kt(ms,{generate:()=>bs,name:()=>fs,parse:()=>ys,structure:()=>gs});var fs="Identifier",gs={name:String};function ys(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function bs(e){this.token(1,e.name)}var ks={};kt(ks,{generate:()=>Es,name:()=>vs,parse:()=>xs,structure:()=>ws});var vs="IdSelector",ws={name:String};function xs(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function Es(e){this.token(9,"#"+e.name)}var As={};kt(As,{generate:()=>Rs,name:()=>Ss,parse:()=>Cs,structure:()=>Ts});var Ss="MediaFeature",Ts={name:String,value:["Identifier","Number","Dimension","Ratio",null]};function Cs(){let e,t=this.tokenStart,r=null;if(this.eat(21),this.skipSC(),e=this.consume(1),this.skipSC(),22!==this.tokenType){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:r=9===this.lookupNonWSType(1)?this.Ratio():this.Number();break;case 12:r=this.Dimension();break;case 1:r=this.Identifier();break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eat(22),{type:"MediaFeature",loc:this.getLocation(t,this.tokenStart),name:e,value:r}}function Rs(e){this.token(21,"("),this.token(1,e.name),null!==e.value&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var _s={};kt(_s,{generate:()=>zs,name:()=>Is,parse:()=>Ns,structure:()=>Ls});var Is="MediaQuery",Ls={children:[["Identifier","MediaFeature","WhiteSpace"]]};function Ns(){let e=this.createList(),t=null;this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t=this.Identifier();break;case 21:t=this.MediaFeature();break;default:break e}e.push(t)}return null===t&&this.error("Identifier or parenthesis is expected"),{type:"MediaQuery",loc:this.getLocationFromList(e),children:e}}function zs(e){this.children(e)}var Ps={};kt(Ps,{generate:()=>Ds,name:()=>Ms,parse:()=>Us,structure:()=>Os});var Ms="MediaQueryList",Os={children:[["MediaQuery"]]};function Us(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),18===this.tokenType);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function Ds(e){this.children(e,(()=>this.token(18,",")))}var Fs={};kt(Fs,{generate:()=>Hs,name:()=>qs,parse:()=>js,structure:()=>Bs});var qs="Nth",Bs={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function js(){this.skipSC();let e,t=this.tokenStart,r=t,n=null;return e=this.lookupValue(0,"odd")||this.lookupValue(0,"even")?this.Identifier():this.AnPlusB(),r=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),r=this.tokenStart),{type:"Nth",loc:this.getLocation(t,r),nth:e,selector:n}}function Hs(e){this.node(e.nth),null!==e.selector&&(this.token(1,"of"),this.node(e.selector))}var Vs={};kt(Vs,{generate:()=>Ys,name:()=>Ws,parse:()=>Gs,structure:()=>$s});var Ws="Number",$s={value:String};function Gs(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function Ys(e){this.token(10,e.value)}var Js={};kt(Js,{generate:()=>Xs,name:()=>Qs,parse:()=>Zs,structure:()=>Ks});var Qs="Operator",Ks={value:String};function Zs(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function Xs(e){this.tokenize(e.value)}var el={};kt(el,{generate:()=>ol,name:()=>tl,parse:()=>nl,structure:()=>rl});var tl="Parentheses",rl={children:[[]]};function nl(e,t){let r=this.tokenStart,n=null;return this.eat(21),n=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(r,this.tokenStart),children:n}}function ol(e){this.token(21,"("),this.children(e),this.token(22,")")}var il={};kt(il,{generate:()=>cl,name:()=>al,parse:()=>ll,structure:()=>sl});var al="Percentage",sl={value:String};function ll(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function cl(e){this.token(11,e.value+"%")}var ul={};kt(ul,{generate:()=>fl,name:()=>hl,parse:()=>ml,structure:()=>pl,walkContext:()=>dl});var hl="PseudoClassSelector",dl="function",pl={name:String,children:[["Raw"],null]};function ml(){let e,t,r=this.tokenStart,n=null;return this.eat(16),2===this.tokenType?(e=this.consumeFunctionName(),t=e.toLowerCase(),hasOwnProperty.call(this.pseudo,t)?(this.skipSC(),n=this.pseudo[t].call(this),this.skipSC()):(n=this.createList(),n.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):e=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(r,this.tokenStart),name:e,children:n}}function fl(e){this.token(16,":"),null===e.children?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var gl={};kt(gl,{generate:()=>wl,name:()=>yl,parse:()=>vl,structure:()=>kl,walkContext:()=>bl});var yl="PseudoElementSelector",bl="function",kl={name:String,children:[["Raw"],null]};function vl(){let e,t,r=this.tokenStart,n=null;return this.eat(16),this.eat(16),2===this.tokenType?(e=this.consumeFunctionName(),t=e.toLowerCase(),hasOwnProperty.call(this.pseudo,t)?(this.skipSC(),n=this.pseudo[t].call(this),this.skipSC()):(n=this.createList(),n.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):e=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(r,this.tokenStart),name:e,children:n}}function wl(e){this.token(16,":"),this.token(16,":"),null===e.children?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var xl={};kt(xl,{generate:()=>Cl,name:()=>Al,parse:()=>Tl,structure:()=>Sl});function El(){this.skipSC();let e=this.consume(10);for(let t=0;t0&&13===this.lookupType(-1)?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}kt(Rl,{generate:()=>zl,name:()=>Il,parse:()=>Nl,structure:()=>Ll});var Il="Raw",Ll={value:String};function Nl(e,t,r){let n,o=this.getTokenStart(e);return this.skipUntilBalanced(e,t||this.consumeUntilBalanceEnd),n=r&&this.tokenStart>o?_l.call(this):this.tokenStart,{type:"Raw",loc:this.getLocation(o,n),value:this.substring(o,n)}}function zl(e){this.tokenize(e.value)}var Pl={};function Ml(e){return this.Raw(e,this.consumeUntilLeftCurlyBracket,!0)}function Ol(){let e=this.SelectorList();return"Raw"!==e.type&&!1===this.eof&&23!==this.tokenType&&this.error(),e}kt(Pl,{generate:()=>Bl,name:()=>Ul,parse:()=>ql,structure:()=>Fl,walkContext:()=>Dl});var Ul="Rule",Dl="rule",Fl={prelude:["SelectorList","Raw"],block:["Block"]};function ql(){let e,t,r=this.tokenIndex,n=this.tokenStart;return e=this.parseRulePrelude?this.parseWithFallback(Ol,Ml):Ml.call(this,r),t=this.Block(!0),{type:"Rule",loc:this.getLocation(n,this.tokenStart),prelude:e,block:t}}function Bl(e){this.node(e.prelude),this.node(e.block)}var jl={};kt(jl,{generate:()=>$l,name:()=>Hl,parse:()=>Wl,structure:()=>Vl});var Hl="Selector",Vl={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator","WhiteSpace"]]};function Wl(){let e=this.readSequence(this.scope.Selector);return null===this.getFirstListNode(e)&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function $l(e){this.children(e)}var Gl={};kt(Gl,{generate:()=>Zl,name:()=>Yl,parse:()=>Kl,structure:()=>Ql,walkContext:()=>Jl});var Yl="SelectorList",Jl="selector",Ql={children:[["Selector","Raw"]]};function Kl(){let e=this.createList();for(;!this.eof&&(e.push(this.Selector()),18===this.tokenType);)this.next();return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function Zl(e){this.children(e,(()=>this.token(18,",")))}var Xl={};kt(Xl,{generate:()=>ac,name:()=>nc,parse:()=>ic,structure:()=>oc});var ec={};kt(ec,{decode:()=>tc,encode:()=>rc});function tc(e){let t=e.length,r=e.charCodeAt(0),n=34===r||39===r?1:0,o=1===n&&t>1&&e.charCodeAt(t-1)===r?t-2:t-1,i="";for(let r=n;r<=o;r++){let n=e.charCodeAt(r);if(92===n){if(r===o){r!==t-1&&(i=e.substr(r+1));break}if(n=e.charCodeAt(++r),sr(92,n)){let t=r-1,n=vr(e,t);r=n-1,i+=Ar(e.substring(t+1,n))}else 13===n&&10===e.charCodeAt(r+1)&&r++}else i+=e[r]}return i}function rc(e,t){let r=t?"'":'"',n=t?39:34,o="",i=!1;for(let t=0;tpc,name:()=>cc,parse:()=>dc,structure:()=>hc,walkContext:()=>uc});function lc(e){return this.Raw(e,null,!1)}var cc="StyleSheet",uc="stylesheet",hc={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function dc(){let e,t=this.tokenStart,r=this.createList();for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(33!==this.charCodeAt(this.tokenStart+2)){this.next();continue}e=this.Comment();break;case 14:e=this.CDO();break;case 15:e=this.CDC();break;case 3:e=this.parseWithFallback(this.Atrule,lc);break;default:e=this.parseWithFallback(this.Rule,lc)}r.push(e)}return{type:"StyleSheet",loc:this.getLocation(t,this.tokenStart),children:r}}function pc(e){this.children(e)}var mc={};kt(mc,{generate:()=>kc,name:()=>gc,parse:()=>bc,structure:()=>yc});function fc(){1!==this.tokenType&&!1===this.isDelim(42)&&this.error("Identifier or asterisk is expected"),this.next()}var gc="TypeSelector",yc={name:String};function bc(){let e=this.tokenStart;return this.isDelim(124)?(this.next(),fc.call(this)):(fc.call(this),this.isDelim(124)&&(this.next(),fc.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function kc(e){this.tokenize(e.name)}var vc={};kt(vc,{generate:()=>Rc,name:()=>Sc,parse:()=>Cc,structure:()=>Tc});function wc(e,t){let r=0;for(let n=this.tokenStart+e;n6&&this.error("Too many hex digits",n)}return this.next(),r}function xc(e){let t=0;for(;this.isDelim(63);)++t>e&&this.error("Too many question marks"),this.next()}function Ec(e){this.charCodeAt(this.tokenStart)!==e&&this.error((43===e?"Plus sign":"Hyphen minus")+" is expected")}function Ac(){let e=0;switch(this.tokenType){case 10:if(e=wc.call(this,1,!0),this.isDelim(63)){xc.call(this,6-e);break}if(12===this.tokenType||10===this.tokenType){Ec.call(this,45),wc.call(this,1,!1);break}break;case 12:e=wc.call(this,1,!0),e>0&&xc.call(this,6-e);break;default:if(this.eatDelim(43),1===this.tokenType){e=wc.call(this,0,!0),e>0&&xc.call(this,6-e);break}if(this.isDelim(63)){this.next(),xc.call(this,5);break}this.error("Hex digit or question mark is expected")}}var Sc="UnicodeRange",Tc={value:String};function Cc(){let e=this.tokenStart;return this.eatIdent("u"),Ac.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function Rc(e){this.tokenize(e.value)}var _c={};kt(_c,{generate:()=>Oc,name:()=>zc,parse:()=>Mc,structure:()=>Pc});var Ic={};kt(Ic,{decode:()=>Lc,encode:()=>Nc});function Lc(e){let t=e.length,r=4,n=41===e.charCodeAt(t-1)?t-2:t-1,o="";for(;rBc,name:()=>Dc,parse:()=>qc,structure:()=>Fc});var Dc="Value",Fc={children:[[]]};function qc(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function Bc(e){this.children(e)}var jc={};kt(jc,{generate:()=>Gc,name:()=>Vc,parse:()=>$c,structure:()=>Wc});var Hc=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),Vc="WhiteSpace",Wc={value:String};function $c(){return this.eat(13),Hc}function Gc(e){this.token(13,e.value)}var Yc={generic:!0,generic:!0,types:{"absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","alpha-value":"|","angle-percentage":"|","angular-color-hint":"","angular-color-stop":"&&?","angular-color-stop-list":"[ [, ]?]# , ","animateable-feature":"scroll-position|contents|",attachment:"scroll|fixed|local","attr()":"attr( ? [, ]? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attribute-selector":"'[' ']'|'[' [|] ? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [? ]+ ? )","auto-track-list":"[? [|]]* ? [? [|]]* ?","baseline-position":"[first|last]? baseline","basic-shape":"||||","bg-image":"none|","bg-layer":"|| [/ ]?||||||||","bg-position":"[[left|center|right|top|bottom|]|[left|center|right|] [top|center|bottom|]|[center|[left|right] ?]&&[center|[top|bottom] ?]]","bg-size":"[|auto]{1,2}|cover|contain","blur()":"blur( )","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity",box:"border-box|padding-box|content-box","brightness()":"brightness( )","calc()":"calc( )","calc-sum":" [['+'|'-'] ]*","calc-product":" ['*' |'/' ]*","calc-value":"|||( )","cf-final-image":"|","cf-mixing-image":"?&&","circle()":"circle( []? [at ]? )","clamp()":"clamp( #{3} )","class-selector":"'.' ","clip-source":"",color:"|||||||currentcolor|","color-stop":"|","color-stop-angle":"{1,2}","color-stop-length":"{1,2}","color-stop-list":"[ [, ]?]# , ",combinator:"'>'|'+'|'~'|['||']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|push-button|slider-horizontal|checkbox|radio|square-button|menulist|listbox|meter|progress-bar|button","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[? * [ *]*]!","compound-selector-list":"#","complex-selector":" [? ]*","complex-selector-list":"#","conic-gradient()":"conic-gradient( [from ]? [at ]? , )","contextual-alt-values":"[contextual|no-contextual]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[|contents|||||]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"","contrast()":"contrast( [] )",counter:"|","counter()":"counter( , ? )","counter-name":"","counter-style":"|symbols( )","counter-style-name":"","counters()":"counters( , , ? )","cross-fade()":"cross-fade( , ? )","cubic-bezier-timing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( , , , )","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( {2,3} ? )","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( , [first|start|last|first-except]? )|element( )","ellipse()":"ellipse( [{2}]? [at ]? )","ending-shape":"circle|ellipse","env()":"env( , ? )","explicit-track-list":"[? ]+ ?","family-name":"|+","feature-tag-value":" [|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":" '{' '}'","feature-value-block-list":"+","feature-value-declaration":" : + ;","feature-value-declaration-list":"","feature-value-name":"","fill-rule":"nonzero|evenodd","filter-function":"|||||||||","filter-function-list":"[|]+","final-bg-layer":"<'background-color'>|||| [/ ]?||||||||","fit-content()":"fit-content( [|] )","fixed-breadth":"","fixed-repeat":"repeat( [] , [? ]+ ? )","fixed-size":"|minmax( , )|minmax( , )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|","font-variant-css21":"[normal|small-caps]","font-weight-absolute":"normal|bold|","frequency-percentage":"|","general-enclosed":"[ )]|( )","generic-family":"serif|sans-serif|cursive|fantasy|monospace|-apple-system","generic-name":"serif|sans-serif|cursive|fantasy|monospace","geometry-box":"|fill-box|stroke-box|view-box",gradient:"|||||<-legacy-gradient>","grayscale()":"grayscale( )","grid-line":"auto||[&&?]|[span&&[||]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( [/ ]? )|hsl( , , , ? )","hsla()":"hsla( [/ ]? )|hsla( , , , ? )",hue:"|","hue-rotate()":"hue-rotate( )","hwb()":"hwb( [|none] [|none] [|none] [/ [|none]]? )",image:"||||||","image()":"image( ? [? , ?]! )","image-set()":"image-set( # )","image-set-option":"[|] [||type( )]","image-src":"|","image-tags":"ltr|rtl","inflexible-breadth":"||min-content|max-content|auto","inset()":"inset( {1,4} [round <'border-radius'>]? )","invert()":"invert( )","keyframes-name":"|","keyframe-block":"# { }","keyframe-block-list":"+","keyframe-selector":"from|to|","layer()":"layer( )","leader()":"leader( )","leader-type":"dotted|solid|space|","length-percentage":"|","line-names":"'[' * ']'","line-name-list":"[|]+","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"|thin|medium|thick","linear-color-hint":"","linear-color-stop":" ?","linear-gradient()":"linear-gradient( [|to ]? , )","mask-layer":"|| [/ ]?||||||[|no-clip]||||","mask-position":"[|left|center|right] [|top|center|bottom]?","mask-reference":"none||","mask-source":"","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( #{6} )","matrix3d()":"matrix3d( #{16} )","max()":"max( # )","media-and":" [and ]+","media-condition":"|||","media-condition-without-or":"||","media-feature":"( [||] )","media-in-parens":"( )||","media-not":"not ","media-or":" [or ]+","media-query":"|[not|only]? [and ]?","media-query-list":"#","media-type":"","mf-boolean":"","mf-name":"","mf-plain":" : ","mf-range":" ['<'|'>']? '='? | ['<'|'>']? '='? | '<' '='? '<' '='? | '>' '='? '>' '='? ","mf-value":"|||","min()":"min( # )","minmax()":"minmax( [||min-content|max-content|auto] , [|||min-content|max-content|auto] )","name-repeat":"repeat( [|auto-fill] , + )","named-color":"transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|<-non-standard-color>","namespace-prefix":"","ns-prefix":"[|'*']? '|'","number-percentage":"|","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]",nth:"|even|odd","opacity()":"opacity( [] )","overflow-position":"unsafe|safe","outline-radius":"|","page-body":"? [; ]?| ","page-margin-box":" '{' '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector-list":"[#]?","page-selector":"+| *","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger","path()":"path( [ ,]? )","paint()":"paint( , ? )","perspective()":"perspective( )","polygon()":"polygon( ? , [ ]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|] [top|center|bottom|]?|[[left|right] ]&&[[top|bottom] ]]","pseudo-class-selector":"':' |':' ')'","pseudo-element-selector":"':' ","pseudo-page":": [left|right|first|blank]",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-gradient()":"radial-gradient( [||]? [at ]? , )","relative-selector":"? ","relative-selector-list":"#","relative-size":"larger|smaller","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-linear-gradient()":"repeating-linear-gradient( [|to ]? , )","repeating-radial-gradient()":"repeating-radial-gradient( [||]? [at ]? , )","rgb()":"rgb( {3} [/ ]? )|rgb( {3} [/ ]? )|rgb( #{3} , ? )|rgb( #{3} , ? )","rgba()":"rgba( {3} [/ ]? )|rgba( {3} [/ ]? )|rgba( #{3} , ? )|rgba( #{3} , ? )","rotate()":"rotate( [|] )","rotate3d()":"rotate3d( , , , [|] )","rotateX()":"rotateX( [|] )","rotateY()":"rotateY( [|] )","rotateZ()":"rotateZ( [|] )","saturate()":"saturate( )","scale()":"scale( , ? )","scale3d()":"scale3d( , , )","scaleX()":"scaleX( )","scaleY()":"scaleY( )","scaleZ()":"scaleZ( )","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","shape-radius":"|closest-side|farthest-side","skew()":"skew( [|] , [|]? )","skewX()":"skewX( [|] )","skewY()":"skewY( [|] )","sepia()":"sepia( )",shadow:"inset?&&{2,4}&&?","shadow-t":"[{2,3}&&?]",shape:"rect( , , , )|rect( )","shape-box":"|margin-box","side-or-corner":"[left|right]||[top|bottom]","single-animation":"