!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-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",i="single-file-block-cookies-start",r="single-file-block-cookies-end",a="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",u="single-file-load-image",m="single-file-image-loaded",g="_singleFile_fontFaces",h=(e,t,s)=>globalThis.addEventListener(e,t,s),p=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},f=globalThis.CustomEvent,b=globalThis.document,E=globalThis.Document,y=globalThis.JSON;let T;T=window[g]?window[g]:window[g]=new Map,b instanceof E&&(h("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,T.set(y.stringify(s),t)})),h("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,T.delete(y.stringify(s))})),h("single-file-clear-fonts",(()=>T=new Map)));const w="[\\x20\\t\\r\\n\\f]",I=new RegExp("\\\\([\\da-f]{1,6}"+w+"?|("+w+")|.)","ig");const A="single-file-",v="__frameTree__::",S=A+"on-before-capture",R=A+"on-after-capture",_=A+"request-get-adopted-stylesheets",M=A+"response-get-adopted-stylesheets",P=A+"unregister-request-get-adopted-stylesheets",N="data-"+A+"removed-content",C="data-"+A+"hidden-content",F="data-"+A+"kept-content",q="data-"+A+"hidden-frame",x="data-"+A+"preserved-space-element",k="data-"+A+"shadow-root-element",L="data-"+A+"win-id",U="data-"+A+"image",D="data-"+A+"poster",O="data-"+A+"video",V="data-"+A+"canvas",W="data-"+A+"movable-style",H="data-"+A+"input-value",z="data-"+A+"lazy-loaded-src",B="data-"+A+"stylesheet",j="data-"+A+"disabled-noscript",Y="data-"+A+"invalid-element",G="data-"+A+"async-script",Z="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",J=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],$=/^'(.*?)'$/,K=/^"(.*?)"$/,X={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},Q="single-file-ui-element",ee="data:,",te=globalThis.JSON;function se(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){if(s.childNodes){Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let r,a,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=ce(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(a=(i||s.closest("html > head"))&&J.includes(s.tagName.toUpperCase())||s.closest("details"),a||(r=i||ae(s,l),r&&(s.setAttribute(C,""),n.markedElements.push(s)))),!r)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(x,""),n.markedElements.push(s))}o.removeUnusedFonts&&(ne(l,o,n.usedFonts),ne(ce(e,s,":first-letter"),o,n.usedFonts),ne(ce(e,s,":before"),o,n.usedFonts),ne(ce(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,r){const a=s.tagName&&s.tagName.toUpperCase();if("CANVAS"==a)try{n.canvases.push({dataURI:s.toDataURL("image/png",""),backgroundColor:r.getPropertyValue("background-color")}),s.setAttribute(V,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==a){const t={currentSrc:i?ee:o.loadDeferredImages&&s.getAttribute(z)||s.currentSrc};if(n.images.push(t),s.setAttribute(U,n.images.length-1),n.markedElements.push(s),s.removeAttribute(z),r=r||ce(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");if(s=s||ce(e,t)){let e,r,a,l,d,c,u,m,g=!1;if("content-box"==s.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")}e=de("padding-left",s),r=de("padding-right",s),a=de("padding-top",s),l=de("padding-bottom",s),g?(d=de("border-left-width",s),c=de("border-right-width",s),u=de("border-top-width",s),m=de("border-bottom-width",s)):d=c=u=m=0,o=Math.max(0,t.clientWidth-e-r-d-c),n=Math.max(0,t.clientHeight-a-l-u-m),i&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,r);const o=r.getPropertyValue("box-shadow"),n=r.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=r.getPropertyValue("background-color"),t.objectFit=r.getPropertyValue("object-fit"),t.boxSizing=r.getPropertyValue("box-sizing"),t.objectPosition=r.getPropertyValue("object-position"))}}if("VIDEO"==a){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=ce(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(O,n.videos.length-1)}if(!s.getAttribute("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(D,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==a&&i&&o.removeHiddenElements&&(s.setAttribute(q,""),n.markedElements.push(s));"INPUT"==a&&("password"!=s.type&&(s.setAttribute(H,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(H,s.checked),n.markedElements.push(s)));"TEXTAREA"==a&&(s.setAttribute(H,s.value),n.markedElements.push(s));"SELECT"==a&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(H,""),n.markedElements.push(e))}));"SCRIPT"==a&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(G,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,r,l);const d=!(s instanceof e.SVGElement)&&ie(s);if(d&&!s.classList.contains(Q)){const i={};s.setAttribute(k,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)i.adoptedStyleSheets=oe(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>i.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(M,e),s.dispatchEvent(new CustomEvent(_,{bubbles:!0})),s.removeEventListener(M,e)}}catch(e){}se(e,t,d,o,n,r),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&void 0===d.adoptedStyleSheets.length&&s.dispatchEvent(new CustomEvent(P,{bubbles:!0}))}catch(e){}}se(e,t,s,o,n,r),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(a||""==s.getAttribute(F)?s.parentElement&&(s.parentElement.setAttribute(F,""),n.markedElements.push(s.parentElement)):r&&(s.setAttribute(N,""),n.markedElements.push(s)))}))}return n}function oe(e){return e?Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))):[]}function ne(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=re(n),!t.loadedFonts||t.loadedFonts.find((e=>re(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),X[i.toLowerCase().trim()]||i),r=e.getPropertyValue("font-variant")||"normal",a=[n,t,o,r];s.set(te.stringify(a),[n,t,o,r])}var i}))}}function ie(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 re(e=""){return function(e){e=e.match($)?e.replace($,"$1"):e.replace(K,"$1");return e.trim()}((t=e.trim(),t.replace(I,((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 ae(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 le(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(B,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function de(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function ce(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const ue={LAZY_SRC_ATTRIBUTE_NAME:z,SINGLE_FILE_UI_ELEMENT_CLASS:Q},me=10,ge="attributes",he=globalThis.browser,pe=globalThis.document,fe=globalThis.MutationObserver,be=(e,t,s)=>globalThis.addEventListener(e,t,s),Ee=(e,t,s)=>globalThis.removeEventListener(e,t,s),ye=new Map;let Te;async function we(e){if(pe.documentElement){ye.clear();const s=pe.body?Math.max(pe.body.scrollHeight,pe.documentElement.scrollHeight):pe.documentElement.scrollHeight,n=pe.body?Math.max(pe.body.scrollWidth,pe.documentElement.scrollWidth):pe.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const r=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY{let n;const r=new Set,l=new fe((async t=>{if((t=t.filter((e=>e.type==ge))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(ue.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||e.target.tagName&&"SOURCE"==e.target.tagName.toUpperCase())return!e.target.classList||!e.target.classList.contains(ue.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ae(l,e,E),r.size||await Ie(l,e,E))}}));async function c(t){await Se("idleTimeout",(async()=>{n?Teve(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ae(e,t,s){await Se("maxTimeout",(async()=>{await _e("loadTimeout"),await ve(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function ve(e,t,o){await _e("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&p(new f(r)),e.loadDeferredImagesBlockStorage&&p(new f(c)),e.loadDeferredImagesDispatchScrollEvent&&p(new f(l)),e.loadDeferredImagesKeepZoomLevel?p(new f(n)):p(new f(s))}(t),await Se("endTimeout",(async()=>{await _e("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function Se(e,t,s,o){if(he&&he.runtime&&he.runtime.sendMessage&&!o){if(!ye.get(e)||!ye.get(e).pending){const o={callback:t,pending:!0};ye.set(e,o);try{await he.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){Re(e,t,s)}o.pending=!1}}else Re(e,t,s)}function Re(e,t,s){const o=ye.get(e);o&&globalThis.clearTimeout(o),ye.set(e,t),globalThis.setTimeout(t,s)}async function _e(e){if(he&&he.runtime&&he.runtime.sendMessage)try{await he.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Me(e)}else Me(e)}function Me(e){const t=ye.get(e);ye.delete(e),t&&globalThis.clearTimeout(t)}he&&he.runtime&&he.runtime.onMessage&&he.runtime.onMessage.addListener&&he.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=ye.get(e.type);if(t){ye.delete(e.type);try{t.callback()}catch(t){Me(e.type)}}}}));const Pe={ON_BEFORE_CAPTURE_EVENT_NAME:S,ON_AFTER_CAPTURE_EVENT_NAME:R,WIN_ID_ATTRIBUTE_NAME:L,WAIT_FOR_USERSCRIPT_PROPERTY_NAME:"_singleFile_waitForUserScript",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not(["+j+"])").forEach((e=>{e.setAttribute(j,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(Z).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+Z+", html > body > "+Z);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").forEach((t=>{const s=e.createElement("template");s.setAttribute(Y,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=se(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=ce(t,e);s&&ae(e,s)&&(e.setAttribute(W,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(T.values()),stylesheets:le(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,scrollPosition:{x:t.scrollX,y:t.scrollY},adoptedStyleSheets:oe(e.adoptedStyleSheets)}},serialize:function(e){const t=e.doctype;let s="";return t&&(s=" "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("["+j+"]").forEach((e=>{e.textContent=e.getAttribute(j),e.removeAttribute(j)})),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=[N,q,C,x,U,D,O,V,H,k,B,G];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(N),e.removeAttribute(C),e.removeAttribute(F),e.removeAttribute(q),e.removeAttribute(x),e.removeAttribute(U),e.removeAttribute(D),e.removeAttribute(O),e.removeAttribute(V),e.removeAttribute(H),e.removeAttribute(k),e.removeAttribute(B),e.removeAttribute(G),e.removeAttribute(W)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))},getShadowRoot:ie},Ne='iframe, frame, object[type="text/html"][data]',Ce="*",Fe="singlefile.frameTree.initRequest",qe="singlefile.frameTree.ackInitRequest",xe="singlefile.frameTree.cleanupRequest",ke="singlefile.frameTree.initResponse",Le="*",Ue=5e3,De=".",Oe=globalThis.window==globalThis.top,Ve=globalThis.browser,We=globalThis.top,He=globalThis.MessageChannel,ze=globalThis.document,Be=globalThis.JSON;let je,Ye=globalThis.sessions;var Ge,Ze,Je;function $e(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ke(e){const t=e.sessionId,s=globalThis[Pe.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,Oe||(je=globalThis.frameId=e.windowId),et(ze,e.options,je,t),Oe||(e.options.userScriptEnabled&&s&&await s(Pe.ON_BEFORE_CAPTURE_EVENT_NAME),nt({frames:[rt(ze,globalThis,je,e.options,e.scrolling)],sessionId:t,requestedFrameId:ze.documentElement.dataset.requestedFrameId&&je}),e.options.userScriptEnabled&&s&&await s(Pe.ON_AFTER_CAPTURE_EVENT_NAME),delete ze.documentElement.dataset.requestedFrameId)}function Xe(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;ot(at(ze),e.windowId,t)}}function Qe(e){e.frames.forEach((t=>tt("responseTimeouts",e.sessionId,t.windowId)));const t=Ye.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.url=e.url,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,s.scrollPosition=e.scrollPosition,s.scrolling=e.scrolling,s.adoptedStyleSheets=e.adoptedStyleSheets)}));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 et(e,t,s,o){const n=at(e);!function(e,t,s,o,n){const i=[];let r;Ye.get(n)?r=Ye.get(n).requestTimeouts:(r={},Ye.set(n,{requestTimeouts:r}));t.forEach(((e,t)=>{const s=o+De+t;e.setAttribute(Pe.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),nt({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+De+t;try{it(e.contentWindow,{method:Fe,windowId:i,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}r[i]=globalThis.setTimeout((()=>nt({frames:[{windowId:i,processed:!0}],sessionId:n})),Ue)})),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 r=o+De+t;let a;try{a=e.contentDocument}catch(e){}if(a)try{const t=e.contentWindow;t.stop(),tt("requestTimeouts",n,r),et(a,s,r,n),i.push(rt(a,t,r,s,e.scrolling))}catch(e){i.push({windowId:r,processed:!0})}})),nt({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function tt(e,t,s){const o=Ye.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function st(e,t){const s=Ye.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>nt({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function ot(e,t,s){e.forEach(((e,o)=>{const n=t+De+o;e.removeAttribute(Pe.WIN_ID_ATTRIBUTE_NAME);try{it(e.contentWindow,{method:xe,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+De+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{ot(at(i),n,s)}catch(e){}}))}function nt(e){e.method=ke;try{We.singlefile.processors.frameTree.initResponse(e)}catch(t){it(We,e,!0)}}function it(e,t,s){if(e==We&&Ve&&Ve.runtime&&Ve.runtime.sendMessage)Ve.runtime.sendMessage(t);else if(s){const s=new He;e.postMessage(v+Be.stringify({method:t.method,sessionId:t.sessionId}),Le,[s.port2]),s.port1.postMessage(t)}else e.postMessage(v+Be.stringify(t),Le)}function rt(e,t,s,o,n){const i=Pe.preProcessDoc(e,t,o),r=Pe.serialize(e);Pe.postProcessDoc(e,i.markedElements,i.invalidElements);return{windowId:s,content:r,baseURI:e.baseURI.split("#")[0],url:e.location.href,title:e.title,canvases:i.canvases,fonts:i.fonts,stylesheets:i.stylesheets,images:i.images,posters:i.posters,videos:i.videos,usedFonts:i.usedFonts,shadowRoots:i.shadowRoots,scrollPosition:i.scrollPosition,scrolling:n,adoptedStyleSheets:i.adoptedStyleSheets,processed:!0}}function at(e){let t=Array.from(e.querySelectorAll(Ne));return e.querySelectorAll(Ce).forEach((e=>{const s=Pe.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Ne)))})),t}Ye||(Ye=globalThis.sessions=new Map),Oe&&(je="0",Ve&&Ve.runtime&&Ve.runtime.onMessage&&Ve.runtime.onMessage.addListener&&Ve.runtime.onMessage.addListener((e=>e.method==ke?(Qe(e),Promise.resolve({})):e.method==qe?(tt("requestTimeouts",e.sessionId,e.windowId),st(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Ge="message",Ze=async e=>{if("string"==typeof e.data&&e.data.startsWith(v)){e.preventDefault(),e.stopPropagation();const t=Be.parse(e.data.substring(v.length));t.method==Fe?(e.source&&it(e.source,{method:qe,windowId:t.windowId,sessionId:t.sessionId}),Oe||(globalThis.stop(),t.options.loadDeferredImages&&we(t.options),await Ke(t))):t.method==qe?(tt("requestTimeouts",t.sessionId,t.windowId),st(t.sessionId,t.windowId)):t.method==xe?Xe(t):t.method==ke&&Ye.get(t.sessionId)&&(e.ports[0].onmessage=e=>Qe(e.data))}},Je=!0,globalThis.addEventListener(Ge,Ze,Je),e.TIMEOUT_INIT_REQUEST_MESSAGE=Ue,e.cleanup=function(e){Ye.delete(e),Xe({windowId:je,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=$e();return e=Be.parse(Be.stringify(e)),new Promise((s=>{Ye.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ke({windowId:je,sessionId:t,options:e})}))},e.getSync=function(e){const t=$e();e=Be.parse(Be.stringify(e)),Ye.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis[Pe.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,Oe||(je=globalThis.frameId=e.windowId);et(ze,e.options,je,t),Oe||(e.options.userScriptEnabled&&s&&s(Pe.ON_BEFORE_CAPTURE_EVENT_NAME),nt({frames:[rt(ze,globalThis,je,e.options,e.scrolling)],sessionId:t,requestedFrameId:ze.documentElement.dataset.requestedFrameId&&je}),e.options.userScriptEnabled&&s&&s(Pe.ON_AFTER_CAPTURE_EVENT_NAME),delete ze.documentElement.dataset.requestedFrameId)}({windowId:je,sessionId:t,options:e});const s=Ye.get(t).frames;return s.sessionId=t,s},e.initResponse=Qe,Object.defineProperty(e,"__esModule",{value:!0})}));