single-file-cli 1.0.68 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/args.js CHANGED
@@ -57,6 +57,7 @@ const args = require("yargs")
57
57
  "browser-cookies-file": "",
58
58
  "browser-ignore-insecure-certs": false,
59
59
  "browser-freeze-prototypes": false,
60
+ "compress-content": false,
60
61
  "compress-CSS": false,
61
62
  "compress-HTML": true,
62
63
  "dump-content": false,
@@ -85,6 +86,7 @@ const args = require("yargs")
85
86
  "max-resource-size": 10,
86
87
  "move-styles-in-head": false,
87
88
  "output-directory": "",
89
+ "password": "",
88
90
  "remove-hidden-elements": true,
89
91
  "remove-unused-styles": true,
90
92
  "remove-unused-fonts": true,
@@ -107,7 +109,11 @@ const args = require("yargs")
107
109
  "crawl-max-depth": 1,
108
110
  "crawl-external-links-max-depth": 1,
109
111
  "crawl-replace-urls": false,
110
- "crawl-rewrite-rule": []
112
+ "crawl-rewrite-rule": [],
113
+ "insert-text-body": false,
114
+ "create-root-directory": false,
115
+ "self-extracting-archive": true,
116
+ "extract-data-from-page": true
111
117
  })
112
118
  .options("back-end", { description: "Back-end to use" })
113
119
  .choices("back-end", ["jsdom", "puppeteer", "webdriver-chromium", "webdriver-gecko", "puppeteer-firefox", "playwright-firefox", "playwright-chromium", "playwright-webkit"])
@@ -159,6 +165,8 @@ const args = require("yargs")
159
165
  .boolean("browser-ignore-insecure-certs")
160
166
  .options("browser-freeze-prototypes", { description: "Freeze prototypes of built-in objects in the page" })
161
167
  .boolean("browser-freeze-prototypes")
168
+ .options("compress-content", { description: "Compress the output file into a ZIP file" })
169
+ .boolean("compress-content")
162
170
  .options("compress-CSS", { description: "Compress CSS stylesheets" })
163
171
  .boolean("compress-CSS")
164
172
  .options("compress-HTML", { description: "Compress HTML content" })
@@ -239,6 +247,8 @@ const args = require("yargs")
239
247
  .number("max-resource-size")
240
248
  .options("move-styles-in-head", { description: "Move style elements outside the head element into the head element" })
241
249
  .boolean("move-styles-in-head")
250
+ .options("password", { description: "Password of the zip file" })
251
+ .string("password")
242
252
  .options("remove-frames", { description: "Remove frames (puppeteer, webdriver-gecko, webdriver-chromium)" })
243
253
  .boolean("remove-frames")
244
254
  .options("remove-hidden-elements", { description: "Remove HTML elements which are not displayed" })
@@ -248,7 +258,7 @@ const args = require("yargs")
248
258
  .options("remove-unused-fonts", { description: "Remove unused CSS font rules" })
249
259
  .boolean("remove-unused-fonts")
250
260
  .options("remove-saved-date", { description: "Remove saved date metadata in HTML header" })
251
- .boolean("remove-saved-date")
261
+ .boolean("remove-saved-date")
252
262
  .options("block-scripts", { description: "Block scripts" })
253
263
  .boolean("block-scripts")
254
264
  .options("block-audios", { description: "Block audio elements" })
@@ -273,6 +283,14 @@ const args = require("yargs")
273
283
  .boolean("user-script-enabled")
274
284
  .options("web-driver-executable-path", { description: "Path to Selenium WebDriver executable (webdriver-gecko, webdriver-chromium)" })
275
285
  .string("web-driver-executable-path")
286
+ .options("self-extracting-archive", { description: "Create a self extracting HTML file" })
287
+ .boolean("self-extracting-archive")
288
+ .options("insert-text-body", { description: "Insert the text of the page into the self-extracting HTML file" })
289
+ .boolean("insert-text-body")
290
+ .options("create-root-directory", { description: "Create a root directory based on the timestamp" })
291
+ .boolean("create-root-directory")
292
+ .options("extract-data-from-page", { description: "Extract compressed data from the page instead of fetching the page" })
293
+ .boolean("extract-data-from-page")
276
294
  .options("output-directory", { description: "Path to where to save files, this path must exist." })
277
295
  .string("output-directory")
278
296
  .argv;
@@ -28,7 +28,8 @@ const fs = require("fs");
28
28
  const SCRIPTS = [
29
29
  "lib/single-file.js",
30
30
  "lib/single-file-bootstrap.js",
31
- "lib/single-file-hooks-frames.js"
31
+ "lib/single-file-hooks-frames.js",
32
+ "lib/single-file-zip.min.js"
32
33
  ];
33
34
 
34
35
  const basePath = "./../../";
@@ -57,6 +57,11 @@ async function getPageData(win, options) {
57
57
  return iconv.decode(Buffer.from(buffer), this.utfLabel);
58
58
  }
59
59
  };
60
+ win.TextEncoder = class {
61
+ encode(value) {
62
+ return iconv.encode(value, "utf-8");
63
+ }
64
+ };
60
65
  win.crypto = {
61
66
  subtle: {
62
67
  digest: async function digestText(algo, text) {
@@ -79,6 +84,9 @@ async function getPageData(win, options) {
79
84
  await new Promise(resolve => setTimeout(resolve, options.browserWaitDelay));
80
85
  }
81
86
  const pageData = await win.singlefile.getPageData(options, undefined, doc, win);
87
+ if (options.compressContent) {
88
+ pageData.content = new Uint8Array(pageData.content);
89
+ }
82
90
  return pageData;
83
91
  }
84
92
 
@@ -118,7 +118,9 @@ async function getPageData(page, options) {
118
118
  if (options.browserWaitDelay) {
119
119
  await page.waitForTimeout(options.browserWaitDelay);
120
120
  }
121
- return await page.evaluate(async options => {
122
- return await singlefile.getPageData(options);
123
- }, options);
121
+ const pageData = await page.evaluate(async options => await singlefile.getPageData(options), options);
122
+ if (options.compressContent) {
123
+ pageData.content = new Uint8Array(pageData.content);
124
+ }
125
+ return pageData;
124
126
  }
@@ -107,7 +107,9 @@ async function getPageData(page, options) {
107
107
  if (options.browserWaitDelay) {
108
108
  await page.waitForTimeout(options.browserWaitDelay);
109
109
  }
110
- return await page.evaluate(async options => {
111
- return await singlefile.getPageData(options);
112
- }, options);
110
+ const pageData = await page.evaluate(async options => await singlefile.getPageData(options), options);
111
+ if (options.compressContent) {
112
+ pageData.content = new Uint8Array(pageData.content);
113
+ }
114
+ return pageData;
113
115
  }
@@ -118,7 +118,9 @@ async function getPageData(page, options) {
118
118
  if (options.browserWaitDelay) {
119
119
  await page.waitForTimeout(options.browserWaitDelay);
120
120
  }
121
- return await page.evaluate(async options => {
122
- return await singlefile.getPageData(options);
123
- }, options);
121
+ const pageData = await page.evaluate(async options => await singlefile.getPageData(options), options);
122
+ if (options.compressContent) {
123
+ pageData.content = new Uint8Array(pageData.content);
124
+ }
125
+ return pageData;
124
126
  }
@@ -116,9 +116,11 @@ async function getPageData(browser, page, options) {
116
116
  if (options.browserWaitDelay) {
117
117
  await page.waitForTimeout(options.browserWaitDelay);
118
118
  }
119
- return await page.evaluate(async options => {
120
- return await singlefile.getPageData(options);
121
- }, options);
119
+ const pageData = await page.evaluate(async options => await singlefile.getPageData(options), options);
120
+ if (options.compressContent) {
121
+ pageData.content = new Uint8Array(pageData.content);
122
+ }
123
+ return pageData;
122
124
  } catch (error) {
123
125
  if (error.message && error.message.includes(EXECUTION_CONTEXT_DESTROYED_ERROR)) {
124
126
  const pageData = await handleJSRedirect(browser, options);
@@ -150,9 +150,11 @@ async function getPageData(context, page, options) {
150
150
  if (options.browserWaitDelay) {
151
151
  await page.waitForTimeout(options.browserWaitDelay);
152
152
  }
153
- return await page.evaluate(async options => {
154
- return await singlefile.getPageData(options);
155
- }, options);
153
+ const pageData = await page.evaluate(async options => await singlefile.getPageData(options), options);
154
+ if (options.compressContent) {
155
+ pageData.content = new Uint8Array(pageData.content);
156
+ }
157
+ return pageData;
156
158
  } catch (error) {
157
159
  if (error.message && error.message.includes(EXECUTION_CONTEXT_DESTROYED_ERROR)) {
158
160
  const pageData = await handleJSRedirect(context, options);
@@ -196,4 +198,4 @@ async function pageGoto(page, options) {
196
198
  } else {
197
199
  await page.goto(options.url, loadOptions);
198
200
  }
199
- }
201
+ }
@@ -151,6 +151,9 @@ async function getPageData(driver, options) {
151
151
  if (result.error) {
152
152
  throw result.error;
153
153
  } else {
154
+ if (options.compressContent) {
155
+ result.pageData.content = new Uint8Array(result.pageData.content);
156
+ }
154
157
  return result.pageData;
155
158
  }
156
159
  }
@@ -152,6 +152,9 @@ async function getPageData(driver, options) {
152
152
  if (result.error) {
153
153
  throw result.error;
154
154
  } else {
155
+ if (options.compressContent) {
156
+ result.pageData.content = new Uint8Array(result.pageData.content);
157
+ }
155
158
  return result.pageData;
156
159
  }
157
160
  }
@@ -1 +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-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",a="single-file-block-cookies-start",i="single-file-block-cookies-end",r="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",m="single-file-load-image",u="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),p=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},h=globalThis.CustomEvent,f=globalThis.document,E=globalThis.Document,T=globalThis.JSON;let b;b=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,f instanceof E&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.set(T.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.delete(T.stringify(s))})),g("single-file-clear-fonts",(()=>b=new Map)));const y="[\\x20\\t\\r\\n\\f]",I=new RegExp("\\\\([\\da-f]{1,6}"+y+"?|("+y+")|.)","ig");const w="single-file-",A="_singleFile_waitForUserScript",v="__frameTree__::",S=w+"on-before-capture",R=w+"on-after-capture",N=w+"request-get-adopted-stylesheets",_=w+"response-get-adopted-stylesheets",P=w+"unregister-request-get-adopted-stylesheets",C=w+"user-script-init",M="data-"+w+"removed-content",O="data-"+w+"hidden-content",D="data-"+w+"kept-content",F="data-"+w+"hidden-frame",L="data-"+w+"preserved-space-element",x="data-"+w+"shadow-root-element",U="data-"+w+"win-id",q="data-"+w+"image",k="data-"+w+"poster",H="data-"+w+"video",B="data-"+w+"canvas",V="data-"+w+"movable-style",W="data-"+w+"input-value",z="data-"+w+"lazy-loaded-src",Y="data-"+w+"stylesheet",j="data-"+w+"disabled-noscript",G="data-"+w+"invalid-element",K="data-"+w+"async-script",X="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",Z=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],J=/^'(.*?)'$/,$=/^"(.*?)"$/,Q={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},ee="single-file-ui-element",te="data:,",se=(e,t,s)=>globalThis.addEventListener(e,t,s),oe=globalThis.JSON;function ne(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(X).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+X+", html > body > "+X);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(G,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=ae(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=pe(t,e);s&&ce(e,s)&&(e.setAttribute(V,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(b.values()),stylesheets:ue(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:ie(e.adoptedStyleSheets)}}function ae(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},a){if(s.childNodes){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=pe(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(a||s.closest("html > head"))&&Z.includes(s.tagName.toUpperCase())||s.closest("details"),r||(i=a||ce(s,l),i&&(s.setAttribute(O,""),n.markedElements.push(s)))),!i)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(L,""),n.markedElements.push(s))}o.removeUnusedFonts&&(re(l,o,n.usedFonts),re(pe(e,s,":first-letter"),o,n.usedFonts),re(pe(e,s,":before"),o,n.usedFonts),re(pe(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,a,i){const r=s.tagName&&s.tagName.toUpperCase();if("CANVAS"==r)try{n.canvases.push({dataURI:s.toDataURL("image/png",""),backgroundColor:i.getPropertyValue("background-color")}),s.setAttribute(B,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==r){const t={currentSrc:a?te:o.loadDeferredImages&&s.getAttribute(z)||s.currentSrc};if(n.images.push(t),s.setAttribute(q,n.images.length-1),n.markedElements.push(s),s.removeAttribute(z),i=i||pe(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const a=null==t.getAttribute("style");if(s=s||pe(e,t)){let e,i,r,l,d,c,m,u,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=ge("padding-left",s),i=ge("padding-right",s),r=ge("padding-top",s),l=ge("padding-bottom",s),g?(d=ge("border-left-width",s),c=ge("border-right-width",s),m=ge("border-top-width",s),u=ge("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-e-i-d-c),n=Math.max(0,t.clientHeight-r-l-m-u),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"==r){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=pe(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(H,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(k,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==r&&a&&o.removeHiddenElements&&(s.setAttribute(F,""),n.markedElements.push(s));"INPUT"==r&&("password"!=s.type&&(s.setAttribute(W,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(W,s.checked),n.markedElements.push(s)));"TEXTAREA"==r&&(s.setAttribute(W,s.value),n.markedElements.push(s));"SELECT"==r&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(W,""),n.markedElements.push(e))}));"SCRIPT"==r&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(K,""),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)&&le(s);if(d&&!s.classList.contains(ee)){const a={};s.setAttribute(x,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(a);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)a.adoptedStyleSheets=ie(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>a.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(_,e),s.dispatchEvent(new CustomEvent(N,{bubbles:!0})),s.removeEventListener(_,e)}}catch(e){}ae(e,t,d,o,n,i),a.content=d.innerHTML,a.mode=d.mode;try{d.adoptedStyleSheets&&void 0===d.adoptedStyleSheets.length&&s.dispatchEvent(new CustomEvent(P,{bubbles:!0}))}catch(e){}}ae(e,t,s,o,n,i),!o.autoSaveExternalSave&&o.removeHiddenElements&&a&&(r||""==s.getAttribute(D)?s.parentElement&&(s.parentElement.setAttribute(D,""),n.markedElements.push(s.parentElement)):i&&(s.setAttribute(M,""),n.markedElements.push(s)))}))}return n}function ie(e){return e?Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))):[]}function re(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=de(n),!t.loadedFonts||t.loadedFonts.find((e=>de(e.family)==n&&e.style==o))){const t=(a=e.getPropertyValue("font-weight"),Q[a.toLowerCase().trim()]||a),i=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,i];s.set(oe.stringify(r),[n,t,o,i])}var a}))}}function le(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 de(e=""){return function(e){e=e.match(J)?e.replace(J,"$1"):e.replace($,"$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 ce(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 me(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=[M,F,O,L,q,k,H,B,W,x,Y,K];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(M),e.removeAttribute(O),e.removeAttribute(D),e.removeAttribute(F),e.removeAttribute(L),e.removeAttribute(q),e.removeAttribute(k),e.removeAttribute(H),e.removeAttribute(B),e.removeAttribute(W),e.removeAttribute(x),e.removeAttribute(Y),e.removeAttribute(K),e.removeAttribute(V)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))}function ue(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(Y,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function ge(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function pe(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const he={LAZY_SRC_ATTRIBUTE_NAME:z,SINGLE_FILE_UI_ELEMENT_CLASS:ee},fe=10,Ee="attributes",Te=globalThis.browser,be=globalThis.document,ye=globalThis.MutationObserver,Ie=(e,t,s)=>globalThis.addEventListener(e,t,s),we=(e,t,s)=>globalThis.removeEventListener(e,t,s),Ae=new Map;let ve;async function Se(e){if(be.documentElement){Ae.clear();const s=be.body?Math.max(be.body.scrollHeight,be.documentElement.scrollHeight):be.documentElement.scrollHeight,n=be.body?Math.max(be.body.scrollWidth,be.documentElement.scrollWidth):be.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const i=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<i||globalThis.scrollX<l)return function(e){return ve=0,new Promise((async s=>{let n;const i=new Set,l=new ye((async t=>{if((t=t.filter((e=>e.type==Ee))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(he.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(he.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ne(l,e,T),i.size||await Re(l,e,T))}}));async function c(t){await Pe("idleTimeout",(async()=>{n?ve<fe&&(ve++,Me("idleTimeout"),await c(Math.max(500,t/2))):(Me("loadTimeout"),Me("maxTimeout"),_e(l,e,T))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(he.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function f(t){n=!0,await Ne(l,e,T),await Re(l,e,T),t.detail&&i.add(t.detail)}async function E(t){await Ne(l,e,T),await Re(l,e,T),i.delete(t.detail),i.size||await Re(l,e,T)}function T(e){l.disconnect(),we(m,f),we(u,E),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Ne(l,e,T),l.observe(be,{subtree:!0,childList:!0,attributes:!0}),Ie(m,f),Ie(u,E),function(e){e.loadDeferredImagesBlockCookies&&p(new h(a)),e.loadDeferredImagesBlockStorage&&p(new h(d)),e.loadDeferredImagesDispatchScrollEvent&&p(new h(r)),e.loadDeferredImagesKeepZoomLevel?p(new h(o)):p(new h(t))}(e)}))}(e)}}}async function Re(e,t,s){await Pe("loadTimeout",(()=>_e(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ne(e,t,s){await Pe("maxTimeout",(async()=>{await Me("loadTimeout"),await _e(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function _e(e,t,o){await Me("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&p(new h(i)),e.loadDeferredImagesBlockStorage&&p(new h(c)),e.loadDeferredImagesDispatchScrollEvent&&p(new h(l)),e.loadDeferredImagesKeepZoomLevel?p(new h(n)):p(new h(s))}(t),await Pe("endTimeout",(async()=>{await Me("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function Pe(e,t,s,o){if(Te&&Te.runtime&&Te.runtime.sendMessage&&!o){if(!Ae.get(e)||!Ae.get(e).pending){const o={callback:t,pending:!0};Ae.set(e,o);try{await Te.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){Ce(e,t,s)}o.pending=!1}}else Ce(e,t,s)}function Ce(e,t,s){const o=Ae.get(e);o&&globalThis.clearTimeout(o),Ae.set(e,t),globalThis.setTimeout(t,s)}async function Me(e){if(Te&&Te.runtime&&Te.runtime.sendMessage)try{await Te.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Oe(e)}else Oe(e)}function Oe(e){const t=Ae.get(e);Ae.delete(e),t&&globalThis.clearTimeout(t)}Te&&Te.runtime&&Te.runtime.onMessage&&Te.runtime.onMessage.addListener&&Te.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Ae.get(e.type);if(t){Ae.delete(e.type);try{t.callback()}catch(t){Oe(e.type)}}}}));const De={ON_BEFORE_CAPTURE_EVENT_NAME:S,ON_AFTER_CAPTURE_EVENT_NAME:R,WIN_ID_ATTRIBUTE_NAME:U,WAIT_FOR_USERSCRIPT_PROPERTY_NAME:A,preProcessDoc:ne,serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:me,getShadowRoot:le},Fe='iframe, frame, object[type="text/html"][data]',Le="*",xe="singlefile.frameTree.initRequest",Ue="singlefile.frameTree.ackInitRequest",qe="singlefile.frameTree.cleanupRequest",ke="singlefile.frameTree.initResponse",He="*",Be=5e3,Ve=".",We=globalThis.window==globalThis.top,ze=globalThis.browser,Ye=globalThis.top,je=globalThis.MessageChannel,Ge=globalThis.document,Ke=globalThis.JSON;let Xe,Ze=globalThis.sessions;var Je,$e,Qe;function et(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function tt(e){const t=e.sessionId,s=globalThis[De.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,We||(Xe=globalThis.frameId=e.windowId),nt(Ge,e.options,Xe,t),We||(e.options.userScriptEnabled&&s&&await s(De.ON_BEFORE_CAPTURE_EVENT_NAME),lt({frames:[ct(Ge,globalThis,Xe,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ge.documentElement.dataset.requestedFrameId&&Xe}),e.options.userScriptEnabled&&s&&await s(De.ON_AFTER_CAPTURE_EVENT_NAME),delete Ge.documentElement.dataset.requestedFrameId)}function st(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;rt(mt(Ge),e.windowId,t)}}function ot(e){e.frames.forEach((t=>at("responseTimeouts",e.sessionId,t.windowId)));const t=Ze.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(Ve).length-e.windowId.split(Ve).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function nt(e,t,s,o){const n=mt(e);!function(e,t,s,o,n){const a=[];let i;Ze.get(n)?i=Ze.get(n).requestTimeouts:(i={},Ze.set(n,{requestTimeouts:i}));t.forEach(((e,t)=>{const s=o+Ve+t;e.setAttribute(De.WIN_ID_ATTRIBUTE_NAME,s),a.push({windowId:s})})),lt({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const a=o+Ve+t;try{dt(e.contentWindow,{method:xe,windowId:a,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}i[a]=globalThis.setTimeout((()=>lt({frames:[{windowId:a,processed:!0}],sessionId:n})),Be)})),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+Ve+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),at("requestTimeouts",n,i),nt(r,s,i,n),a.push(ct(r,t,i,s,e.scrolling))}catch(e){a.push({windowId:i,processed:!0})}})),lt({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function at(e,t,s){const o=Ze.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function it(e,t){const s=Ze.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>lt({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function rt(e,t,s){e.forEach(((e,o)=>{const n=t+Ve+o;e.removeAttribute(De.WIN_ID_ATTRIBUTE_NAME);try{dt(e.contentWindow,{method:qe,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Ve+o;let a;try{a=e.contentDocument}catch(e){}if(a)try{rt(mt(a),n,s)}catch(e){}}))}function lt(e){e.method=ke;try{Ye.singlefile.processors.frameTree.initResponse(e)}catch(t){dt(Ye,e,!0)}}function dt(e,t,s){if(e==Ye&&ze&&ze.runtime&&ze.runtime.sendMessage)ze.runtime.sendMessage(t);else if(s){const s=new je;e.postMessage(v+Ke.stringify({method:t.method,sessionId:t.sessionId}),He,[s.port2]),s.port1.postMessage(t)}else e.postMessage(v+Ke.stringify(t),He)}function ct(e,t,s,o,n){const a=De.preProcessDoc(e,t,o),i=De.serialize(e);De.postProcessDoc(e,a.markedElements,a.invalidElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],url:e.location.href,title:e.title,canvases:a.canvases,fonts:a.fonts,stylesheets:a.stylesheets,images:a.images,posters:a.posters,videos:a.videos,usedFonts:a.usedFonts,shadowRoots:a.shadowRoots,scrollPosition:a.scrollPosition,scrolling:n,adoptedStyleSheets:a.adoptedStyleSheets,processed:!0}}function mt(e){let t=Array.from(e.querySelectorAll(Fe));return e.querySelectorAll(Le).forEach((e=>{const s=De.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Fe)))})),t}Ze||(Ze=globalThis.sessions=new Map),We&&(Xe="0",ze&&ze.runtime&&ze.runtime.onMessage&&ze.runtime.onMessage.addListener&&ze.runtime.onMessage.addListener((e=>e.method==ke?(ot(e),Promise.resolve({})):e.method==Ue?(at("requestTimeouts",e.sessionId,e.windowId),it(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Je="message",$e=async e=>{if("string"==typeof e.data&&e.data.startsWith(v)){e.preventDefault(),e.stopPropagation();const t=Ke.parse(e.data.substring(v.length));t.method==xe?(e.source&&dt(e.source,{method:Ue,windowId:t.windowId,sessionId:t.sessionId}),We||(globalThis.stop(),t.options.loadDeferredImages&&Se(t.options),await tt(t))):t.method==Ue?(at("requestTimeouts",t.sessionId,t.windowId),it(t.sessionId,t.windowId)):t.method==qe?st(t):t.method==ke&&Ze.get(t.sessionId)&&(e.ports[0].onmessage=e=>ot(e.data))}},Qe=!0,globalThis.addEventListener(Je,$e,Qe);var ut=Object.freeze({__proto__:null,getAsync:function(e){const t=et();return e=Ke.parse(Ke.stringify(e)),new Promise((s=>{Ze.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),tt({windowId:Xe,sessionId:t,options:e})}))},getSync:function(e){const t=et();e=Ke.parse(Ke.stringify(e)),Ze.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis[De.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,We||(Xe=globalThis.frameId=e.windowId);nt(Ge,e.options,Xe,t),We||(e.options.userScriptEnabled&&s&&s(De.ON_BEFORE_CAPTURE_EVENT_NAME),lt({frames:[ct(Ge,globalThis,Xe,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ge.documentElement.dataset.requestedFrameId&&Xe}),e.options.userScriptEnabled&&s&&s(De.ON_AFTER_CAPTURE_EVENT_NAME),delete Ge.documentElement.dataset.requestedFrameId)}({windowId:Xe,sessionId:t,options:e});const s=Ze.get(t).frames;return s.sessionId=t,s},cleanup:function(e){Ze.delete(e),st({windowId:Xe,sessionId:e,options:{sessionId:e}})},initResponse:ot,TIMEOUT_INIT_REQUEST_MESSAGE:Be});const gt=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"],pt=1,ht=3,ft=8,Et=[{tagName:"HEAD",accept:e=>!e.childNodes.length||e.childNodes[0].nodeType==pt},{tagName:"BODY",accept:e=>!e.childNodes.length}],Tt=[{tagName:"HTML",accept:e=>!e||e.nodeType!=ft},{tagName:"HEAD",accept:e=>!e||e.nodeType!=ft&&(e.nodeType!=ht||!It(e.textContent))},{tagName:"BODY",accept:e=>!e||e.nodeType!=ft},{tagName:"LI",accept:(e,t)=>!e&&t.parentElement&&("UL"==wt(t.parentElement)||"OL"==wt(t.parentElement))||e&&["LI"].includes(wt(e))},{tagName:"DT",accept:e=>!e||["DT","DD"].includes(wt(e))},{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(wt(e))},{tagName:"DD",accept:e=>!e||["DT","DD"].includes(wt(e))},{tagName:"RT",accept:e=>!e||["RT","RP"].includes(wt(e))},{tagName:"RP",accept:e=>!e||["RT","RP"].includes(wt(e))},{tagName:"OPTGROUP",accept:e=>!e||["OPTGROUP"].includes(wt(e))},{tagName:"OPTION",accept:e=>!e||["OPTION","OPTGROUP"].includes(wt(e))},{tagName:"COLGROUP",accept:e=>!e||e.nodeType!=ft&&(e.nodeType!=ht||!It(e.textContent))},{tagName:"CAPTION",accept:e=>!e||e.nodeType!=ft&&(e.nodeType!=ht||!It(e.textContent))},{tagName:"THEAD",accept:e=>!e||["TBODY","TFOOT"].includes(wt(e))},{tagName:"TBODY",accept:e=>!e||["TBODY","TFOOT"].includes(wt(e))},{tagName:"TFOOT",accept:e=>!e},{tagName:"TR",accept:e=>!e||["TR"].includes(wt(e))},{tagName:"TD",accept:e=>!e||["TD","TH"].includes(wt(e))},{tagName:"TH",accept:e=>!e||["TD","TH"].includes(wt(e))}],bt=["STYLE","SCRIPT","XMP","IFRAME","NOEMBED","NOFRAMES","PLAINTEXT","NOSCRIPT"];function yt(e,t,s){return e.nodeType==ht?function(e){const t=e.parentNode;let s;t&&t.nodeType==pt&&(s=wt(t));return!s||bt.includes(s)?"SCRIPT"==s||"STYLE"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&amp;").replace(/\u00a0/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}(e):e.nodeType==ft?"\x3c!--"+e.textContent+"--\x3e":e.nodeType==pt?function(e,t,s){const o=wt(e),n=t&&Et.find((t=>o==wt(t)&&t.accept(e)));let a="";n&&!e.attributes.length||(a="<"+o.toLowerCase(),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,"&amp;").replace(/\u00a0/g,"&nbsp;"),i.includes('"')&&(i.includes("'")||!s?i=i.replace(/"/g,"&quot;"):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"!=o||e.childNodes.length?Array.from(e.childNodes).forEach((e=>a+=yt(e,t,s||"svg"==o))):a+=e.innerHTML;const i=t&&Tt.find((t=>o==wt(t)&&t.accept(e.nextSibling,e)));(s||!i&&!gt.includes(o))&&(a+="</"+o.toLowerCase()+">");return a}(e,t,s):void 0}function It(e){return Boolean(e.match(/^[ \t\n\f\r]/))}function wt(e){return e.tagName&&e.tagName.toUpperCase()}const At={frameTree:ut},vt={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:S,ON_AFTER_CAPTURE_EVENT_NAME:R,preProcessDoc:ne,postProcessDoc:me,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o="<!DOCTYPE "+s.nodeName,s.publicId?(o+=' PUBLIC "'+s.publicId+'"',s.systemId&&(o+=' "'+s.systemId+'"')):s.systemId&&(o+=' SYSTEM "'+s.systemId+'"'),s.internalSubset&&(o+=" ["+s.internalSubset+"]"),o+="> "),o+yt(e.documentElement,t)}(e,t),getShadowRoot:le};se(C,(()=>globalThis[A]=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>se(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await s})),e.helper=vt,e.processors=At,Object.defineProperty(e,"__esModule",{value:!0})}));
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-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",a="single-file-block-cookies-start",i="single-file-block-cookies-end",r="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",m="single-file-load-image",u="single-file-image-loaded",p="_singleFile_fontFaces",g=(e,t,s)=>globalThis.addEventListener(e,t,s),h=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},f=globalThis.CustomEvent,E=globalThis.document,T=globalThis.Document,b=globalThis.JSON;let y;y=window[p]?window[p]:window[p]=new Map,E instanceof T&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,y.set(b.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,y.delete(b.stringify(s))})),g("single-file-clear-fonts",(()=>y=new Map)));const I="[\\x20\\t\\r\\n\\f]",w=new RegExp("\\\\([\\da-f]{1,6}"+I+"?|("+I+")|.)","ig");const A="single-file-",v="_singleFile_waitForUserScript",S="__frameTree__::",R=A+"on-before-capture",N=A+"on-after-capture",P=A+"request-get-adopted-stylesheets",_=A+"response-get-adopted-stylesheets",C=A+"unregister-request-get-adopted-stylesheets",M=A+"user-script-init",O="data-"+A+"removed-content",D="data-"+A+"hidden-content",L="data-"+A+"kept-content",F="data-"+A+"hidden-frame",x="data-"+A+"preserved-space-element",U="data-"+A+"shadow-root-element",q="data-"+A+"win-id",k="data-"+A+"image",H="data-"+A+"poster",B="data-"+A+"video",V="data-"+A+"canvas",W="data-"+A+"movable-style",z="data-"+A+"input-value",Y="data-"+A+"lazy-loaded-src",j="data-"+A+"stylesheet",G="data-"+A+"disabled-noscript",K="data-"+A+"invalid-element",X="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"],$=/^'(.*?)'$/,Q=/^"(.*?)"$/,ee={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},te="single-file-ui-element",se="data:,",oe=(e,t,s)=>globalThis.addEventListener(e,t,s),ne=globalThis.JSON;function ae(e,t,s){e.querySelectorAll("noscript:not(["+G+"])").forEach((e=>{e.setAttribute(G,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(K,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=ie(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=he(t,e);s&&me(e,s)&&(e.setAttribute(W,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(y.values()),stylesheets:pe(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:re(e.adoptedStyleSheets)}}function ie(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},a){if(s.childNodes){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=he(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(a||s.closest("html > head"))&&J.includes(s.tagName.toUpperCase())||s.closest("details"),r||(i=a||me(s,l),i&&(s.setAttribute(D,""),n.markedElements.push(s)))),!i)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(x,""),n.markedElements.push(s))}o.removeUnusedFonts&&(le(l,o,n.usedFonts),le(he(e,s,":first-letter"),o,n.usedFonts),le(he(e,s,":before"),o,n.usedFonts),le(he(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,a,i){const r=s.tagName&&s.tagName.toUpperCase();if("CANVAS"==r)try{n.canvases.push({dataURI:s.toDataURL("image/png",""),backgroundColor:i.getPropertyValue("background-color")}),s.setAttribute(V,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==r){const t={currentSrc:a?se:o.loadDeferredImages&&s.getAttribute(Y)||s.currentSrc};if(n.images.push(t),s.setAttribute(k,n.images.length-1),n.markedElements.push(s),s.removeAttribute(Y),i=i||he(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const a=null==t.getAttribute("style");if(s=s||he(e,t)){let e,i,r,l,d,c,m,u,p=!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"),p=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=ge("padding-left",s),i=ge("padding-right",s),r=ge("padding-top",s),l=ge("padding-bottom",s),p?(d=ge("border-left-width",s),c=ge("border-right-width",s),m=ge("border-top-width",s),u=ge("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-e-i-d-c),n=Math.max(0,t.clientHeight-r-l-m-u),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"==r){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=he(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(B,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(H,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==r&&a&&o.removeHiddenElements&&(s.setAttribute(F,""),n.markedElements.push(s));"INPUT"==r&&("password"!=s.type&&(s.setAttribute(z,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(z,s.checked),n.markedElements.push(s)));"TEXTAREA"==r&&(s.setAttribute(z,s.value),n.markedElements.push(s));"SELECT"==r&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(z,""),n.markedElements.push(e))}));"SCRIPT"==r&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(X,""),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)&&de(s);if(d&&!s.classList.contains(te)){const a={};s.setAttribute(U,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(a);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)a.adoptedStyleSheets=re(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>a.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(_,e),s.dispatchEvent(new CustomEvent(P,{bubbles:!0})),s.removeEventListener(_,e)}}catch(e){}ie(e,t,d,o,n,i),a.content=d.innerHTML,a.mode=d.mode;try{d.adoptedStyleSheets&&void 0===d.adoptedStyleSheets.length&&s.dispatchEvent(new CustomEvent(C,{bubbles:!0}))}catch(e){}}ie(e,t,s,o,n,i),!o.autoSaveExternalSave&&o.removeHiddenElements&&a&&(r||""==s.getAttribute(L)?s.parentElement&&(s.parentElement.setAttribute(L,""),n.markedElements.push(s.parentElement)):i&&(s.setAttribute(O,""),n.markedElements.push(s)))}))}return n}function re(e){return e?Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))):[]}function le(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=ce(n),!t.loadedFonts||t.loadedFonts.find((e=>ce(e.family)==n&&e.style==o))){const t=(a=e.getPropertyValue("font-weight"),ee[a.toLowerCase().trim()]||a),i=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,i];s.set(ne.stringify(r),[n,t,o,i])}var a}))}}function de(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 ce(e=""){return function(e){e=e.match($)?e.replace($,"$1"):e.replace(Q,"$1");return e.trim()}((t=e.trim(),t.replace(w,((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 me(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 ue(e,t,s){if(e.querySelectorAll("["+G+"]").forEach((t=>{t.textContent=t.getAttribute(G),t.removeAttribute(G),e.body.firstChild?e.body.insertBefore(t,e.body.firstChild):e.body.appendChild(t)})),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=[O,F,D,x,k,H,B,V,z,U,j,X];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(O),e.removeAttribute(D),e.removeAttribute(L),e.removeAttribute(F),e.removeAttribute(x),e.removeAttribute(k),e.removeAttribute(H),e.removeAttribute(B),e.removeAttribute(V),e.removeAttribute(z),e.removeAttribute(U),e.removeAttribute(j),e.removeAttribute(X),e.removeAttribute(W)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))}function pe(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(j,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function ge(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function he(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const fe={LAZY_SRC_ATTRIBUTE_NAME:Y,SINGLE_FILE_UI_ELEMENT_CLASS:te},Ee=10,Te="attributes",be=globalThis.browser,ye=globalThis.document,Ie=globalThis.MutationObserver,we=(e,t,s)=>globalThis.addEventListener(e,t,s),Ae=(e,t,s)=>globalThis.removeEventListener(e,t,s),ve=new Map;let Se;async function Re(e){if(ye.documentElement){ve.clear();const s=ye.body?Math.max(ye.body.scrollHeight,ye.documentElement.scrollHeight):ye.documentElement.scrollHeight,n=ye.body?Math.max(ye.body.scrollWidth,ye.documentElement.scrollWidth):ye.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const i=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<i||globalThis.scrollX<l)return function(e){return Se=0,new Promise((async s=>{let n;const i=new Set,l=new Ie((async t=>{if((t=t.filter((e=>e.type==Te))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(fe.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",p)),"src"==e.attributeName||"srcset"==e.attributeName||e.target.tagName&&"SOURCE"==e.target.tagName.toUpperCase())return!e.target.classList||!e.target.classList.contains(fe.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Pe(l,e,T),i.size||await Ne(l,e,T))}}));async function c(t){await Ce("idleTimeout",(async()=>{n?Se<Ee&&(Se++,Oe("idleTimeout"),await c(Math.max(500,t/2))):(Oe("loadTimeout"),Oe("maxTimeout"),_e(l,e,T))}),t,e.loadDeferredImagesNativeTimeout)}function p(e){const t=e.target;t.removeAttribute(fe.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",p)}async function g(t){n=!0,await Pe(l,e,T),await Ne(l,e,T),t.detail&&i.add(t.detail)}async function E(t){await Pe(l,e,T),await Ne(l,e,T),i.delete(t.detail),i.size||await Ne(l,e,T)}function T(e){l.disconnect(),Ae(m,g),Ae(u,E),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Pe(l,e,T),l.observe(ye,{subtree:!0,childList:!0,attributes:!0}),we(m,g),we(u,E),function(e){e.loadDeferredImagesBlockCookies&&h(new f(a)),e.loadDeferredImagesBlockStorage&&h(new f(d)),e.loadDeferredImagesDispatchScrollEvent&&h(new f(r)),e.loadDeferredImagesKeepZoomLevel?h(new f(o)):h(new f(t))}(e)}))}(e)}}}async function Ne(e,t,s){await Ce("loadTimeout",(()=>_e(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Pe(e,t,s){await Ce("maxTimeout",(async()=>{await Oe("loadTimeout"),await _e(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function _e(e,t,o){await Oe("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&h(new f(i)),e.loadDeferredImagesBlockStorage&&h(new f(c)),e.loadDeferredImagesDispatchScrollEvent&&h(new f(l)),e.loadDeferredImagesKeepZoomLevel?h(new f(n)):h(new f(s))}(t),await Ce("endTimeout",(async()=>{await Oe("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function Ce(e,t,s,o){if(be&&be.runtime&&be.runtime.sendMessage&&!o){if(!ve.get(e)||!ve.get(e).pending){const o={callback:t,pending:!0};ve.set(e,o);try{await be.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){Me(e,t,s)}o.pending=!1}}else Me(e,t,s)}function Me(e,t,s){const o=ve.get(e);o&&globalThis.clearTimeout(o),ve.set(e,t),globalThis.setTimeout(t,s)}async function Oe(e){if(be&&be.runtime&&be.runtime.sendMessage)try{await be.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){De(e)}else De(e)}function De(e){const t=ve.get(e);ve.delete(e),t&&globalThis.clearTimeout(t)}be&&be.runtime&&be.runtime.onMessage&&be.runtime.onMessage.addListener&&be.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=ve.get(e.type);if(t){ve.delete(e.type);try{t.callback()}catch(t){De(e.type)}}}}));const Le={ON_BEFORE_CAPTURE_EVENT_NAME:R,ON_AFTER_CAPTURE_EVENT_NAME:N,WIN_ID_ATTRIBUTE_NAME:q,WAIT_FOR_USERSCRIPT_PROPERTY_NAME:v,preProcessDoc:ae,serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:ue,getShadowRoot:de},Fe='iframe, frame, object[type="text/html"][data]',xe="*",Ue="singlefile.frameTree.initRequest",qe="singlefile.frameTree.ackInitRequest",ke="singlefile.frameTree.cleanupRequest",He="singlefile.frameTree.initResponse",Be="*",Ve=5e3,We=".",ze=globalThis.window==globalThis.top,Ye=globalThis.browser,je=globalThis.top,Ge=globalThis.MessageChannel,Ke=globalThis.document,Xe=globalThis.JSON;let Ze,Je=globalThis.sessions;var $e,Qe,et;function tt(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function st(e){const t=e.sessionId,s=globalThis[Le.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,ze||(Ze=globalThis.frameId=e.windowId),at(Ke,e.options,Ze,t),ze||(e.options.userScriptEnabled&&s&&await s(Le.ON_BEFORE_CAPTURE_EVENT_NAME),dt({frames:[mt(Ke,globalThis,Ze,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ke.documentElement.dataset.requestedFrameId&&Ze}),e.options.userScriptEnabled&&s&&await s(Le.ON_AFTER_CAPTURE_EVENT_NAME),delete Ke.documentElement.dataset.requestedFrameId)}function ot(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;lt(ut(Ke),e.windowId,t)}}function nt(e){e.frames.forEach((t=>it("responseTimeouts",e.sessionId,t.windowId)));const t=Je.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(We).length-e.windowId.split(We).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function at(e,t,s,o){const n=ut(e);!function(e,t,s,o,n){const a=[];let i;Je.get(n)?i=Je.get(n).requestTimeouts:(i={},Je.set(n,{requestTimeouts:i}));t.forEach(((e,t)=>{const s=o+We+t;e.setAttribute(Le.WIN_ID_ATTRIBUTE_NAME,s),a.push({windowId:s})})),dt({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const a=o+We+t;try{ct(e.contentWindow,{method:Ue,windowId:a,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}i[a]=globalThis.setTimeout((()=>dt({frames:[{windowId:a,processed:!0}],sessionId:n})),Ve)})),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+We+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),it("requestTimeouts",n,i),at(r,s,i,n),a.push(mt(r,t,i,s,e.scrolling))}catch(e){a.push({windowId:i,processed:!0})}})),dt({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function it(e,t,s){const o=Je.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function rt(e,t){const s=Je.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>dt({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function lt(e,t,s){e.forEach(((e,o)=>{const n=t+We+o;e.removeAttribute(Le.WIN_ID_ATTRIBUTE_NAME);try{ct(e.contentWindow,{method:ke,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+We+o;let a;try{a=e.contentDocument}catch(e){}if(a)try{lt(ut(a),n,s)}catch(e){}}))}function dt(e){e.method=He;try{je.singlefile.processors.frameTree.initResponse(e)}catch(t){ct(je,e,!0)}}function ct(e,t,s){if(e==je&&Ye&&Ye.runtime&&Ye.runtime.sendMessage)Ye.runtime.sendMessage(t);else if(s){const s=new Ge;e.postMessage(S+Xe.stringify({method:t.method,sessionId:t.sessionId}),Be,[s.port2]),s.port1.postMessage(t)}else e.postMessage(S+Xe.stringify(t),Be)}function mt(e,t,s,o,n){const a=Le.preProcessDoc(e,t,o),i=Le.serialize(e);Le.postProcessDoc(e,a.markedElements,a.invalidElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],url:e.location.href,title:e.title,canvases:a.canvases,fonts:a.fonts,stylesheets:a.stylesheets,images:a.images,posters:a.posters,videos:a.videos,usedFonts:a.usedFonts,shadowRoots:a.shadowRoots,scrollPosition:a.scrollPosition,scrolling:n,adoptedStyleSheets:a.adoptedStyleSheets,processed:!0}}function ut(e){let t=Array.from(e.querySelectorAll(Fe));return e.querySelectorAll(xe).forEach((e=>{const s=Le.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Fe)))})),t}Je||(Je=globalThis.sessions=new Map),ze&&(Ze="0",Ye&&Ye.runtime&&Ye.runtime.onMessage&&Ye.runtime.onMessage.addListener&&Ye.runtime.onMessage.addListener((e=>e.method==He?(nt(e),Promise.resolve({})):e.method==qe?(it("requestTimeouts",e.sessionId,e.windowId),rt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),$e="message",Qe=async e=>{if("string"==typeof e.data&&e.data.startsWith(S)){e.preventDefault(),e.stopPropagation();const t=Xe.parse(e.data.substring(S.length));t.method==Ue?(e.source&&ct(e.source,{method:qe,windowId:t.windowId,sessionId:t.sessionId}),ze||(globalThis.stop(),t.options.loadDeferredImages&&Re(t.options),await st(t))):t.method==qe?(it("requestTimeouts",t.sessionId,t.windowId),rt(t.sessionId,t.windowId)):t.method==ke?ot(t):t.method==He&&Je.get(t.sessionId)&&(e.ports[0].onmessage=e=>nt(e.data))}},et=!0,globalThis.addEventListener($e,Qe,et);var pt=Object.freeze({__proto__:null,getAsync:function(e){const t=tt();return e=Xe.parse(Xe.stringify(e)),new Promise((s=>{Je.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),st({windowId:Ze,sessionId:t,options:e})}))},getSync:function(e){const t=tt();e=Xe.parse(Xe.stringify(e)),Je.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis[Le.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,ze||(Ze=globalThis.frameId=e.windowId);at(Ke,e.options,Ze,t),ze||(e.options.userScriptEnabled&&s&&s(Le.ON_BEFORE_CAPTURE_EVENT_NAME),dt({frames:[mt(Ke,globalThis,Ze,e.options,e.scrolling)],sessionId:t,requestedFrameId:Ke.documentElement.dataset.requestedFrameId&&Ze}),e.options.userScriptEnabled&&s&&s(Le.ON_AFTER_CAPTURE_EVENT_NAME),delete Ke.documentElement.dataset.requestedFrameId)}({windowId:Ze,sessionId:t,options:e});const s=Je.get(t).frames;return s.sessionId=t,s},cleanup:function(e){Je.delete(e),ot({windowId:Ze,sessionId:e,options:{sessionId:e}})},initResponse:nt,TIMEOUT_INIT_REQUEST_MESSAGE:Ve});const gt=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"],ht=1,ft=3,Et=8,Tt=[{tagName:"HEAD",accept:e=>!e.childNodes.length||e.childNodes[0].nodeType==ht},{tagName:"BODY",accept:e=>!e.childNodes.length}],bt=[{tagName:"HTML",accept:e=>!e||e.nodeType!=Et},{tagName:"HEAD",accept:e=>!e||e.nodeType!=Et&&(e.nodeType!=ft||!wt(e.textContent))},{tagName:"BODY",accept:e=>!e||e.nodeType!=Et},{tagName:"LI",accept:(e,t)=>!e&&t.parentElement&&("UL"==At(t.parentElement)||"OL"==At(t.parentElement))||e&&["LI"].includes(At(e))},{tagName:"DT",accept:e=>!e||["DT","DD"].includes(At(e))},{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(At(e))},{tagName:"DD",accept:e=>!e||["DT","DD"].includes(At(e))},{tagName:"RT",accept:e=>!e||["RT","RP"].includes(At(e))},{tagName:"RP",accept:e=>!e||["RT","RP"].includes(At(e))},{tagName:"OPTGROUP",accept:e=>!e||["OPTGROUP"].includes(At(e))},{tagName:"OPTION",accept:e=>!e||["OPTION","OPTGROUP"].includes(At(e))},{tagName:"COLGROUP",accept:e=>!e||e.nodeType!=Et&&(e.nodeType!=ft||!wt(e.textContent))},{tagName:"CAPTION",accept:e=>!e||e.nodeType!=Et&&(e.nodeType!=ft||!wt(e.textContent))},{tagName:"THEAD",accept:e=>!e||["TBODY","TFOOT"].includes(At(e))},{tagName:"TBODY",accept:e=>!e||["TBODY","TFOOT"].includes(At(e))},{tagName:"TFOOT",accept:e=>!e},{tagName:"TR",accept:e=>!e||["TR"].includes(At(e))},{tagName:"TD",accept:e=>!e||["TD","TH"].includes(At(e))},{tagName:"TH",accept:e=>!e||["TD","TH"].includes(At(e))}],yt=["STYLE","SCRIPT","XMP","IFRAME","NOEMBED","NOFRAMES","PLAINTEXT","NOSCRIPT"];function It(e,t,s){return e.nodeType==ft?function(e){const t=e.parentNode;let s;t&&t.nodeType==ht&&(s=At(t));return!s||yt.includes(s)?"SCRIPT"==s||"STYLE"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&amp;").replace(/\u00a0/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}(e):e.nodeType==Et?"\x3c!--"+e.textContent+"--\x3e":e.nodeType==ht?function(e,t,s){const o=At(e),n=t&&Tt.find((t=>o==At(t)&&t.accept(e)));let a="";n&&!e.attributes.length||(a="<"+o.toLowerCase(),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,"&amp;").replace(/\u00a0/g,"&nbsp;"),i.includes('"')&&(i.includes("'")||!s?i=i.replace(/"/g,"&quot;"):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"!=o||e.childNodes.length?Array.from(e.childNodes).forEach((e=>a+=It(e,t,s||"svg"==o))):a+=e.innerHTML;const i=t&&bt.find((t=>o==At(t)&&t.accept(e.nextSibling,e)));(s||!i&&!gt.includes(o))&&(a+="</"+o.toLowerCase()+">");return a}(e,t,s):void 0}function wt(e){return Boolean(e.match(/^[ \t\n\f\r]/))}function At(e){return e.tagName&&e.tagName.toUpperCase()}const vt={frameTree:pt},St={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:R,ON_AFTER_CAPTURE_EVENT_NAME:N,preProcessDoc:ae,postProcessDoc:ue,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o="<!DOCTYPE "+s.nodeName,s.publicId?(o+=' PUBLIC "'+s.publicId+'"',s.systemId&&(o+=' "'+s.systemId+'"')):s.systemId&&(o+=' SYSTEM "'+s.systemId+'"'),s.internalSubset&&(o+=" ["+s.internalSubset+"]"),o+="> "),o+It(e.documentElement,t)}(e,t),getShadowRoot:de};oe(M,(()=>globalThis[v]=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>oe(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await s})),e.helper=St,e.processors=vt,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1 +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-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=(e,t,s)=>globalThis.addEventListener(e,t,s),h=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},f=globalThis.CustomEvent,p=globalThis.document,b=globalThis.Document,E=globalThis.JSON;let y;y=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,p instanceof b&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,y.set(E.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,y.delete(E.stringify(s))})),g("single-file-clear-fonts",(()=>y=new Map)));const T="[\\x20\\t\\r\\n\\f]",w=new RegExp("\\\\([\\da-f]{1,6}"+T+"?|("+T+")|.)","ig");const I="single-file-",A="__frameTree__::",v=I+"on-before-capture",S=I+"on-after-capture",_=I+"request-get-adopted-stylesheets",R=I+"response-get-adopted-stylesheets",M=I+"unregister-request-get-adopted-stylesheets",P="data-"+I+"removed-content",N="data-"+I+"hidden-content",C="data-"+I+"kept-content",F="data-"+I+"hidden-frame",q="data-"+I+"preserved-space-element",x="data-"+I+"shadow-root-element",k="data-"+I+"win-id",L="data-"+I+"image",U="data-"+I+"poster",D="data-"+I+"video",O="data-"+I+"canvas",V="data-"+I+"movable-style",W="data-"+I+"input-value",H="data-"+I+"lazy-loaded-src",z="data-"+I+"stylesheet",B="data-"+I+"disabled-noscript",j="data-"+I+"invalid-element",Y="data-"+I+"async-script",G="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",Z=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],J=/^'(.*?)'$/,$=/^"(.*?)"$/,K={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},X="single-file-ui-element",Q="data:,",ee=globalThis.JSON;function te(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=de(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(a=(i||s.closest("html > head"))&&Z.includes(s.tagName.toUpperCase())||s.closest("details"),a||(r=i||re(s,l),r&&(s.setAttribute(N,""),n.markedElements.push(s)))),!r)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(q,""),n.markedElements.push(s))}o.removeUnusedFonts&&(oe(l,o,n.usedFonts),oe(de(e,s,":first-letter"),o,n.usedFonts),oe(de(e,s,":before"),o,n.usedFonts),oe(de(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(O,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==a){const t={currentSrc:i?Q:o.loadDeferredImages&&s.getAttribute(H)||s.currentSrc};if(n.images.push(t),s.setAttribute(L,n.images.length-1),n.markedElements.push(s),s.removeAttribute(H),r=r||de(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||de(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=le("padding-left",s),r=le("padding-right",s),a=le("padding-top",s),l=le("padding-bottom",s),g?(d=le("border-left-width",s),c=le("border-right-width",s),u=le("border-top-width",s),m=le("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=de(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(D,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(U,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==a&&i&&o.removeHiddenElements&&(s.setAttribute(F,""),n.markedElements.push(s));"INPUT"==a&&("password"!=s.type&&(s.setAttribute(W,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(W,s.checked),n.markedElements.push(s)));"TEXTAREA"==a&&(s.setAttribute(W,s.value),n.markedElements.push(s));"SELECT"==a&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(W,""),n.markedElements.push(e))}));"SCRIPT"==a&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(Y,""),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)&&ne(s);if(d&&!s.classList.contains(X)){const i={};s.setAttribute(x,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)i.adoptedStyleSheets=se(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>i.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(R,e),s.dispatchEvent(new CustomEvent(_,{bubbles:!0})),s.removeEventListener(R,e)}}catch(e){}te(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(M,{bubbles:!0}))}catch(e){}}te(e,t,s,o,n,r),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(a||""==s.getAttribute(C)?s.parentElement&&(s.parentElement.setAttribute(C,""),n.markedElements.push(s.parentElement)):r&&(s.setAttribute(P,""),n.markedElements.push(s)))}))}return n}function se(e){return e?Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))):[]}function oe(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=ie(n),!t.loadedFonts||t.loadedFonts.find((e=>ie(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),K[i.toLowerCase().trim()]||i),r=e.getPropertyValue("font-variant")||"normal",a=[n,t,o,r];s.set(ee.stringify(a),[n,t,o,r])}var i}))}}function ne(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 ie(e=""){return function(e){e=e.match(J)?e.replace(J,"$1"):e.replace($,"$1");return e.trim()}((t=e.trim(),t.replace(w,((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 re(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 ae(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(z,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function le(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function de(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const ce={LAZY_SRC_ATTRIBUTE_NAME:H,SINGLE_FILE_UI_ELEMENT_CLASS:X},ue=10,me="attributes",ge=globalThis.browser,he=globalThis.document,fe=globalThis.MutationObserver,pe=(e,t,s)=>globalThis.addEventListener(e,t,s),be=(e,t,s)=>globalThis.removeEventListener(e,t,s),Ee=new Map;let ye;async function Te(e){if(he.documentElement){Ee.clear();const s=he.body?Math.max(he.body.scrollHeight,he.documentElement.scrollHeight):he.documentElement.scrollHeight,n=he.body?Math.max(he.body.scrollWidth,he.documentElement.scrollWidth):he.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<r||globalThis.scrollX<l)return function(e){return ye=0,new Promise((async s=>{let n;const r=new Set,l=new fe((async t=>{if((t=t.filter((e=>e.type==me))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(ce.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(ce.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ie(l,e,E),r.size||await we(l,e,E))}}));async function c(t){await ve("idleTimeout",(async()=>{n?ye<ue&&(ye++,_e("idleTimeout"),await c(Math.max(500,t/2))):(_e("loadTimeout"),_e("maxTimeout"),Ae(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(ce.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function p(t){n=!0,await Ie(l,e,E),await we(l,e,E),t.detail&&r.add(t.detail)}async function b(t){await Ie(l,e,E),await we(l,e,E),r.delete(t.detail),r.size||await we(l,e,E)}function E(e){l.disconnect(),be(u,p),be(m,b),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Ie(l,e,E),l.observe(he,{subtree:!0,childList:!0,attributes:!0}),pe(u,p),pe(m,b),function(e){e.loadDeferredImagesBlockCookies&&h(new f(i)),e.loadDeferredImagesBlockStorage&&h(new f(d)),e.loadDeferredImagesDispatchScrollEvent&&h(new f(a)),e.loadDeferredImagesKeepZoomLevel?h(new f(o)):h(new f(t))}(e)}))}(e)}}}async function we(e,t,s){await ve("loadTimeout",(()=>Ae(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ie(e,t,s){await ve("maxTimeout",(async()=>{await _e("loadTimeout"),await Ae(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ae(e,t,o){await _e("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&h(new f(r)),e.loadDeferredImagesBlockStorage&&h(new f(c)),e.loadDeferredImagesDispatchScrollEvent&&h(new f(l)),e.loadDeferredImagesKeepZoomLevel?h(new f(n)):h(new f(s))}(t),await ve("endTimeout",(async()=>{await _e("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function ve(e,t,s,o){if(ge&&ge.runtime&&ge.runtime.sendMessage&&!o){if(!Ee.get(e)||!Ee.get(e).pending){const o={callback:t,pending:!0};Ee.set(e,o);try{await ge.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=Ee.get(e);o&&globalThis.clearTimeout(o),Ee.set(e,t),globalThis.setTimeout(t,s)}async function _e(e){if(ge&&ge.runtime&&ge.runtime.sendMessage)try{await ge.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Re(e)}else Re(e)}function Re(e){const t=Ee.get(e);Ee.delete(e),t&&globalThis.clearTimeout(t)}ge&&ge.runtime&&ge.runtime.onMessage&&ge.runtime.onMessage.addListener&&ge.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){Re(e.type)}}}}));const Me={ON_BEFORE_CAPTURE_EVENT_NAME:v,ON_AFTER_CAPTURE_EVENT_NAME:S,WIN_ID_ATTRIBUTE_NAME:k,WAIT_FOR_USERSCRIPT_PROPERTY_NAME:"_singleFile_waitForUserScript",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not(["+B+"])").forEach((e=>{e.setAttribute(B,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(G).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+G+", html > body > "+G);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(j,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=te(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=de(t,e);s&&re(e,s)&&(e.setAttribute(V,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(y.values()),stylesheets:ae(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:se(e.adoptedStyleSheets)}},serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("["+B+"]").forEach((e=>{e.textContent=e.getAttribute(B),e.removeAttribute(B)})),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=[P,F,N,q,L,U,D,O,W,x,z,Y];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(P),e.removeAttribute(N),e.removeAttribute(C),e.removeAttribute(F),e.removeAttribute(q),e.removeAttribute(L),e.removeAttribute(U),e.removeAttribute(D),e.removeAttribute(O),e.removeAttribute(W),e.removeAttribute(x),e.removeAttribute(z),e.removeAttribute(Y),e.removeAttribute(V)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))},getShadowRoot:ne},Pe='iframe, frame, object[type="text/html"][data]',Ne="*",Ce="singlefile.frameTree.initRequest",Fe="singlefile.frameTree.ackInitRequest",qe="singlefile.frameTree.cleanupRequest",xe="singlefile.frameTree.initResponse",ke="*",Le=5e3,Ue=".",De=globalThis.window==globalThis.top,Oe=globalThis.browser,Ve=globalThis.top,We=globalThis.MessageChannel,He=globalThis.document,ze=globalThis.JSON;let Be,je=globalThis.sessions;var Ye,Ge,Ze;function Je(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function $e(e){const t=e.sessionId,s=globalThis[Me.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,De||(Be=globalThis.frameId=e.windowId),Qe(He,e.options,Be,t),De||(e.options.userScriptEnabled&&s&&await s(Me.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(He,globalThis,Be,e.options,e.scrolling)],sessionId:t,requestedFrameId:He.documentElement.dataset.requestedFrameId&&Be}),e.options.userScriptEnabled&&s&&await s(Me.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;st(rt(He),e.windowId,t)}}function Xe(e){e.frames.forEach((t=>et("responseTimeouts",e.sessionId,t.windowId)));const t=je.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(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 Qe(e,t,s,o){const n=rt(e);!function(e,t,s,o,n){const i=[];let r;je.get(n)?r=je.get(n).requestTimeouts:(r={},je.set(n,{requestTimeouts:r}));t.forEach(((e,t)=>{const s=o+Ue+t;e.setAttribute(Me.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+Ue+t;try{nt(e.contentWindow,{method:Ce,windowId:i,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}r[i]=globalThis.setTimeout((()=>ot({frames:[{windowId:i,processed:!0}],sessionId:n})),Le)})),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+Ue+t;let a;try{a=e.contentDocument}catch(e){}if(a)try{const t=e.contentWindow;t.stop(),et("requestTimeouts",n,r),Qe(a,s,r,n),i.push(it(a,t,r,s,e.scrolling))}catch(e){i.push({windowId:r,processed:!0})}})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function et(e,t,s){const o=je.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function tt(e,t){const s=je.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>ot({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function st(e,t,s){e.forEach(((e,o)=>{const n=t+Ue+o;e.removeAttribute(Me.WIN_ID_ATTRIBUTE_NAME);try{nt(e.contentWindow,{method:qe,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{st(rt(i),n,s)}catch(e){}}))}function ot(e){e.method=xe;try{Ve.singlefile.processors.frameTree.initResponse(e)}catch(t){nt(Ve,e,!0)}}function nt(e,t,s){if(e==Ve&&Oe&&Oe.runtime&&Oe.runtime.sendMessage)Oe.runtime.sendMessage(t);else if(s){const s=new We;e.postMessage(A+ze.stringify({method:t.method,sessionId:t.sessionId}),ke,[s.port2]),s.port1.postMessage(t)}else e.postMessage(A+ze.stringify(t),ke)}function it(e,t,s,o,n){const i=Me.preProcessDoc(e,t,o),r=Me.serialize(e);Me.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 rt(e){let t=Array.from(e.querySelectorAll(Pe));return e.querySelectorAll(Ne).forEach((e=>{const s=Me.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Pe)))})),t}je||(je=globalThis.sessions=new Map),De&&(Be="0",Oe&&Oe.runtime&&Oe.runtime.onMessage&&Oe.runtime.onMessage.addListener&&Oe.runtime.onMessage.addListener((e=>e.method==xe?(Xe(e),Promise.resolve({})):e.method==Fe?(et("requestTimeouts",e.sessionId,e.windowId),tt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Ye="message",Ge=async e=>{if("string"==typeof e.data&&e.data.startsWith(A)){e.preventDefault(),e.stopPropagation();const t=ze.parse(e.data.substring(A.length));t.method==Ce?(e.source&&nt(e.source,{method:Fe,windowId:t.windowId,sessionId:t.sessionId}),De||(globalThis.stop(),t.options.loadDeferredImages&&Te(t.options),await $e(t))):t.method==Fe?(et("requestTimeouts",t.sessionId,t.windowId),tt(t.sessionId,t.windowId)):t.method==qe?Ke(t):t.method==xe&&je.get(t.sessionId)&&(e.ports[0].onmessage=e=>Xe(e.data))}},Ze=!0,globalThis.addEventListener(Ye,Ge,Ze),e.TIMEOUT_INIT_REQUEST_MESSAGE=Le,e.cleanup=function(e){je.delete(e),Ke({windowId:Be,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=Je();return e=ze.parse(ze.stringify(e)),new Promise((s=>{je.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),$e({windowId:Be,sessionId:t,options:e})}))},e.getSync=function(e){const t=Je();e=ze.parse(ze.stringify(e)),je.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis[Me.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,De||(Be=globalThis.frameId=e.windowId);Qe(He,e.options,Be,t),De||(e.options.userScriptEnabled&&s&&s(Me.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(He,globalThis,Be,e.options,e.scrolling)],sessionId:t,requestedFrameId:He.documentElement.dataset.requestedFrameId&&Be}),e.options.userScriptEnabled&&s&&s(Me.ON_AFTER_CAPTURE_EVENT_NAME),delete He.documentElement.dataset.requestedFrameId)}({windowId:Be,sessionId:t,options:e});const s=je.get(t).frames;return s.sessionId=t,s},e.initResponse=Xe,Object.defineProperty(e,"__esModule",{value:!0})}));
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-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",h="_singleFile_fontFaces",g=(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[h]?window[h]:window[h]=new Map,b instanceof E&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,T.set(y.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,T.delete(y.stringify(s))})),g("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",C="data-"+A+"removed-content",N="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(N,""),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,h=!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"),h=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),h?(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(C,""),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,he="attributes",ge=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<r||globalThis.scrollX<l)return function(e){return Te=0,new Promise((async s=>{let n;const r=new Set,l=new fe((async t=>{if((t=t.filter((e=>e.type==he))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(ue.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",h)),"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?Te<me&&(Te++,_e("idleTimeout"),await c(Math.max(500,t/2))):(_e("loadTimeout"),_e("maxTimeout"),ve(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function h(e){const t=e.target;t.removeAttribute(ue.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",h)}async function g(t){n=!0,await Ae(l,e,E),await Ie(l,e,E),t.detail&&r.add(t.detail)}async function b(t){await Ae(l,e,E),await Ie(l,e,E),r.delete(t.detail),r.size||await Ie(l,e,E)}function E(e){l.disconnect(),Ee(u,g),Ee(m,b),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Ae(l,e,E),l.observe(pe,{subtree:!0,childList:!0,attributes:!0}),be(u,g),be(m,b),function(e){e.loadDeferredImagesBlockCookies&&p(new f(i)),e.loadDeferredImagesBlockStorage&&p(new f(d)),e.loadDeferredImagesDispatchScrollEvent&&p(new f(a)),e.loadDeferredImagesKeepZoomLevel?p(new f(o)):p(new f(t))}(e)}))}(e)}}}async function Ie(e,t,s){await Se("loadTimeout",(()=>ve(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(ge&&ge.runtime&&ge.runtime.sendMessage&&!o){if(!ye.get(e)||!ye.get(e).pending){const o={callback:t,pending:!0};ye.set(e,o);try{await ge.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(ge&&ge.runtime&&ge.runtime.sendMessage)try{await ge.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)}ge&&ge.runtime&&ge.runtime.onMessage&&ge.runtime.onMessage.addListener&&ge.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="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("["+j+"]").forEach((t=>{t.textContent=t.getAttribute(j),t.removeAttribute(j),e.body.firstChild?e.body.insertBefore(t,e.body.firstChild):e.body.appendChild(t)})),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,q,N,x,U,D,O,V,H,k,B,G];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(C),e.removeAttribute(N),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},Ce='iframe, frame, object[type="text/html"][data]',Ne="*",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(Ce));return e.querySelectorAll(Ne).forEach((e=>{const s=Pe.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Ce)))})),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})}));
@@ -0,0 +1 @@
1
+ var e,t;e=this,t=function(e){const{Array:t,Object:n,String:r,Number:s,BigInt:a,Math:i,Date:o,Map:c,Set:l,Response:u,URL:f,Error:h,Uint8Array:d,Uint16Array:p,Uint32Array:w,DataView:g,Blob:m,Promise:y,TextEncoder:b,TextDecoder:v,document:k,crypto:S,btoa:_,TransformStream:z,ReadableStream:D,WritableStream:x,CompressionStream:R,DecompressionStream:F,navigator:T,Worker:C}="undefined"!=typeof globalThis?globalThis:this||self;var E=d,U=p,W=Int32Array,A=new E([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),O=new E([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),L=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),N=(e,t)=>{for(var n=new U(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var s=new W(n[30]);for(r=1;30>r;++r)for(var a=n[r];a<n[r+1];++a)s[a]=a-n[r]<<5|r;return{b:n,r:s}},I=N(A,2),P=I.b,M=I.r;P[28]=258,M[258]=28;for(var B=N(O,0),V=B.b,H=B.r,q=new U(32768),K=0;32768>K;++K){var Z=(43690&K)>>1|(21845&K)<<1;Z=(61680&(Z=(52428&Z)>>2|(13107&Z)<<2))>>4|(3855&Z)<<4,q[K]=((65280&Z)>>8|(255&Z)<<8)>>1}var j=(e,t,n)=>{for(var r=e.length,s=0,a=new U(t);r>s;++s)e[s]&&++a[e[s]-1];var i,o=new U(t);for(s=1;t>s;++s)o[s]=o[s-1]+a[s-1]<<1;if(n){i=new U(1<<t);var c=15-t;for(s=0;r>s;++s)if(e[s])for(var l=s<<4|e[s],u=t-e[s],f=o[e[s]-1]++<<u,h=f|(1<<u)-1;h>=f;++f)i[q[f]>>c]=l}else for(i=new U(r),s=0;r>s;++s)e[s]&&(i[s]=q[o[e[s]-1]++]>>15-e[s]);return i},G=new E(288);for(K=0;144>K;++K)G[K]=8;for(K=144;256>K;++K)G[K]=9;for(K=256;280>K;++K)G[K]=7;for(K=280;288>K;++K)G[K]=8;var Y=new E(32);for(K=0;32>K;++K)Y[K]=5;var X=j(G,9,0),J=j(G,9,1),Q=j(Y,5,0),$=j(Y,5,1),ee=e=>{for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},te=(e,t,n)=>{var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},ne=(e,t)=>{var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},re=e=>(e+7)/8|0,se=(e,t,n)=>{(null==t||0>t)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new E(n-t);return r.set(e.subarray(t,n)),r},ae=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ie=(e,t,n)=>{var r=new h(t||ae[e]);if(r.code=e,h.captureStackTrace&&h.captureStackTrace(r,ie),!n)throw r;return r},oe=(e,t,n)=>{n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},ce=(e,t,n)=>{n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},le=(e,t)=>{for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,a=n.slice();if(!s)return{t:ge,l:0};if(1==s){var i=new E(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(((e,t)=>e.f-t.f)),n.push({s:-1,f:25001});var o=n[0],c=n[1],l=0,u=1,f=2;for(n[0]={s:-1,f:o.f+c.f,l:o,r:c};u!=s-1;)o=n[n[l].f<n[f].f?l++:f++],c=n[l!=u&&n[l].f<n[f].f?l++:f++],n[u++]={s:-1,f:o.f+c.f,l:o,r:c};var h=a[0].s;for(r=1;s>r;++r)a[r].s>h&&(h=a[r].s);var d=new U(h+1),p=ue(n[u-1],d,0);if(p>t){r=0;var w=0,g=p-t,m=1<<g;for(a.sort(((e,t)=>d[t.s]-d[e.s]||e.f-t.f));s>r;++r){var y=a[r].s;if(d[y]<=t)break;w+=m-(1<<p-d[y]),d[y]=t}for(w>>=g;w>0;){var b=a[r].s;d[b]<t?w-=1<<t-d[b]++-1:++r}for(;r>=0&&w;--r){var v=a[r].s;d[v]==t&&(--d[v],++w)}p=t}return{t:new E(d),l:p}},ue=(e,t,n)=>-1==e.s?i.max(ue(e.l,t,n+1),ue(e.r,t,n+1)):t[e.s]=n,fe=e=>{for(var t=e.length;t&&!e[--t];);for(var n=new U(++t),r=0,s=e[0],a=1,i=e=>{n[r++]=e},o=1;t>=o;++o)if(e[o]==s&&o!=t)++a;else{if(!s&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(s),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(s);a=1,s=e[o]}return{c:n.subarray(0,r),n:t}},he=(e,t)=>{for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},de=(e,t,n)=>{var r=n.length,s=re(t+2);e[s]=255&r,e[s+1]=r>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var a=0;r>a;++a)e[s+a+4]=n[a];return 8*(s+4+r)},pe=(e,t,n,r,s,a,i,o,c,l,u)=>{oe(t,u++,n),++s[256];for(var f=le(s,15),h=f.t,d=f.l,p=le(a,15),w=p.t,g=p.l,m=fe(h),y=m.c,b=m.n,v=fe(w),k=v.c,S=v.n,_=new U(19),z=0;z<y.length;++z)++_[31&y[z]];for(z=0;z<k.length;++z)++_[31&k[z]];for(var D=le(_,7),x=D.t,R=D.l,F=19;F>4&&!x[L[F-1]];--F);var T,C,E,W,N=l+5<<3,I=he(s,G)+he(a,Y)+i,P=he(s,h)+he(a,w)+i+14+3*F+he(_,x)+2*_[16]+3*_[17]+7*_[18];if(c>=0&&I>=N&&P>=N)return de(t,u,e.subarray(c,c+l));if(oe(t,u,1+(I>P)),u+=2,I>P){T=j(h,d,0),C=h,E=j(w,g,0),W=w;var M=j(x,R,0);for(oe(t,u,b-257),oe(t,u+5,S-1),oe(t,u+10,F-4),u+=14,z=0;F>z;++z)oe(t,u+3*z,x[L[z]]);u+=3*F;for(var B=[y,k],V=0;2>V;++V){var H=B[V];for(z=0;z<H.length;++z){var q=31&H[z];oe(t,u,M[q]),u+=x[q],q>15&&(oe(t,u,H[z]>>5&127),u+=H[z]>>12)}}}else T=X,C=G,E=Q,W=Y;for(z=0;o>z;++z){var K=r[z];if(K>255){ce(t,u,T[257+(q=K>>18&31)]),u+=C[q+257],q>7&&(oe(t,u,K>>23&31),u+=A[q]);var Z=31&K;ce(t,u,E[Z]),u+=W[Z],Z>3&&(ce(t,u,K>>5&8191),u+=O[Z])}else ce(t,u,T[K]),u+=C[K]}return ce(t,u,T[256]),u+C[256]},we=new W([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ge=new E(0),me=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new E(98304),this.o.dictionary){var n=this.o.dictionary.subarray(-32768);this.b.set(n,32768-n.length),this.s.i=32768-n.length}}return e.prototype.p=function(e,t){this.ondata(((e,t,n,r,s)=>{if(!s&&(s={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new E(a.length+e.length);o.set(a),o.set(e,a.length),e=o,s.w=a.length}return((e,t,n,r,s,a)=>{var o=a.z||e.length,c=new E(0+o+5*(1+i.ceil(o/7e3))+0),l=c.subarray(0,c.length-0),u=a.l,f=7&(a.r||0);if(t){f&&(l[0]=a.r>>3);for(var h=we[t-1],d=h>>13,p=8191&h,w=(1<<n)-1,g=a.p||new U(32768),m=a.h||new U(w+1),y=i.ceil(n/3),b=2*y,v=t=>(e[t]^e[t+1]<<y^e[t+2]<<b)&w,k=new W(25e3),S=new U(288),_=new U(32),z=0,D=0,x=a.i||0,R=0,F=a.w||0,T=0;o>x+2;++x){var C=v(x),L=32767&x,N=m[C];if(g[L]=N,m[C]=L,x>=F){var I=o-x;if((z>7e3||R>24576)&&(I>423||!u)){f=pe(e,l,0,k,S,_,D,R,T,x-T,f),R=z=D=0,T=x;for(var P=0;286>P;++P)S[P]=0;for(P=0;30>P;++P)_[P]=0}var B=2,V=0,q=p,K=L-N&32767;if(I>2&&C==v(x-K))for(var Z=i.min(d,I)-1,j=i.min(32767,x),G=i.min(258,I);j>=K&&--q&&L!=N;){if(e[x+B]==e[x+B-K]){for(var Y=0;G>Y&&e[x+Y]==e[x+Y-K];++Y);if(Y>B){if(B=Y,V=K,Y>Z)break;var X=i.min(K,Y-2),J=0;for(P=0;X>P;++P){var Q=x-K+P&32767,$=Q-g[Q]&32767;$>J&&(J=$,N=Q)}}}K+=(L=N)-(N=g[L])&32767}if(V){k[R++]=268435456|M[B]<<18|H[V];var ee=31&M[B],te=31&H[V];D+=A[ee]+O[te],++S[257+ee],++_[te],F=x+B,++z}else k[R++]=e[x],++S[e[x]]}}for(x=i.max(x,F);o>x;++x)k[R++]=e[x],++S[e[x]];f=pe(e,l,u,k,S,_,D,R,T,x-T,f),u||(a.r=7&f|l[f/8|0]<<3,f-=7,a.h=m,a.p=g,a.i=x,a.w=F)}else{for(x=a.w||0;o+u>x;x+=65535){var ne=x+65535;o>ne||(l[f/8|0]=u,ne=o),f=de(l,f+1,e.subarray(x,ne))}a.i=o}return se(c,0,0+re(f)+0)})(e,null==t.level?6:t.level,null==t.mem?i.ceil(1.5*i.max(8,i.min(13,i.log(e.length)))):12+t.mem,0,0,s)})(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||ie(5),this.s.l&&ie(4);var n=e.length+this.s.z;if(n>this.b.length){if(n>2*this.b.length-32768){var r=new E(-32768&n);r.set(this.b.subarray(0,this.s.z)),this.b=r}var s=this.b.length-this.s.z;s&&(this.b.set(e.subarray(0,s),this.s.z),this.s.z=this.b.length,this.p(this.b,!1)),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(s),32768),this.s.z=e.length-s+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e}(),ye=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var n=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:n?n.length:0},this.o=new E(32768),this.p=new E(0),n&&this.o.set(n)}return e.prototype.e=function(e){if(this.ondata||ie(5),this.d&&ie(4),this.p.length){if(e.length){var t=new E(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,n=((e,t,n)=>{var r=e.length;if(!r||t.f&&!t.l)return n||new E(0);var s=!n||2!=t.i,a=t.i;n||(n=new E(3*r));var o=e=>{var t=n.length;if(e>t){var r=new E(i.max(2*t,e));r.set(n),n=r}},c=t.f||0,l=t.p||0,u=t.b||0,f=t.l,h=t.d,d=t.m,p=t.n,w=8*r;do{if(!f){c=te(e,l,1);var g=te(e,l+1,3);if(l+=3,!g){var m=e[(F=re(l)+4)-4]|e[F-3]<<8,y=F+m;if(y>r){a&&ie(0);break}s&&o(u+m),n.set(e.subarray(F,y),u),t.b=u+=m,t.p=l=8*y,t.f=c;continue}if(1==g)f=J,h=$,d=9,p=5;else if(2==g){var b=te(e,l,31)+257,v=te(e,l+10,15)+4,k=b+te(e,l+5,31)+1;l+=14;for(var S=new E(k),_=new E(19),z=0;v>z;++z)_[L[z]]=te(e,l+3*z,7);l+=3*v;var D=ee(_),x=(1<<D)-1,R=j(_,D,1);for(z=0;k>z;){var F,T=R[te(e,l,x)];if(l+=15&T,16>(F=T>>4))S[z++]=F;else{var C=0,U=0;for(16==F?(U=3+te(e,l,3),l+=2,C=S[z-1]):17==F?(U=3+te(e,l,7),l+=3):18==F&&(U=11+te(e,l,127),l+=7);U--;)S[z++]=C}}var W=S.subarray(0,b),N=S.subarray(b);d=ee(W),p=ee(N),f=j(W,d,1),h=j(N,p,1)}else ie(1);if(l>w){a&&ie(0);break}}s&&o(u+131072);for(var I=(1<<d)-1,M=(1<<p)-1,B=l;;B=l){var H=(C=f[ne(e,l)&I])>>4;if((l+=15&C)>w){a&&ie(0);break}if(C||ie(2),256>H)n[u++]=H;else{if(256==H){B=l,f=null;break}var q=H-254;if(H>264){var K=A[z=H-257];q=te(e,l,(1<<K)-1)+P[z],l+=K}var Z=h[ne(e,l)&M],G=Z>>4;if(Z||ie(3),l+=15&Z,N=V[G],G>3&&(K=O[G],N+=ne(e,l)&(1<<K)-1,l+=K),l>w){a&&ie(0);break}s&&o(u+131072);var Y=u+q;if(N>u){var X=0-N,Q=i.min(N,Y);for(0>X+u&&ie(3);Q>u;++u)n[u]=(void 0)[X+u]}for(;Y>u;u+=4)n[u]=n[u-N],n[u+1]=n[u+1-N],n[u+2]=n[u+2-N],n[u+3]=n[u+3-N];u=Y}}t.l=f,t.p=B,t.b=u,t.f=c,f&&(c=1,t.m=d,t.d=h,t.n=p)}while(!c);return u==n.length?n:se(n,0,u)})(this.p,this.s,this.o);this.ondata(se(n,t,this.s.b),this.d),this.o=se(n,this.s.b-32768),this.s.b=this.o.length,this.p=se(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),be=void 0!==v&&new v;try{be.decode(ge,{stream:!0})}catch(e){}function ve(e,t,r){return class{constructor(s){const a=this;var i,o;i=s,o="level",("function"==typeof n.hasOwn?n.hasOwn(i,o):i.hasOwnProperty(o))&&void 0===s.level&&delete s.level,a.codec=new e(n.assign({},t,s)),r(a.codec,(e=>{if(a.pendingData){const t=a.pendingData;a.pendingData=new d(t.length+e.length);const{pendingData:n}=a;n.set(t,0),n.set(e,t.length)}else a.pendingData=new d(e)}))}append(e){return this.codec.push(e),s(this)}flush(){return this.codec.push(new d,!0),s(this)}};function s(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new d}}const{Deflate:ke,Inflate:Se}=((e,t={},n)=>({Deflate:ve(e.Deflate,t.deflate,n),Inflate:ve(e.Inflate,t.inflate,n)}))({Deflate:me,Inflate:ye},void 0,((e,t)=>e.ondata=t)),_e=4294967295,ze=65535,De=33639248,xe=101075792,Re=void 0,Fe="undefined",Te="function";class Ce{constructor(e){return class extends z{constructor(t,n){const r=new e(n);super({transform(e,t){t.enqueue(r.append(e))},flush(e){const t=r.flush();t&&e.enqueue(t)}})}}}}let Ee=2;try{typeof T!=Fe&&T.hardwareConcurrency&&(Ee=T.hardwareConcurrency)}catch(e){}const Ue={chunkSize:524288,maxWorkers:Ee,terminateWorkerTimeout:5e3,useWebWorkers:!0,useCompressionStream:!0,workerScripts:Re,CompressionStreamNative:typeof R!=Fe&&R,DecompressionStreamNative:typeof F!=Fe&&F},We=n.assign({},Ue);function Ae(e){const{baseURL:n,chunkSize:r,maxWorkers:s,terminateWorkerTimeout:a,useCompressionStream:i,useWebWorkers:o,Deflate:c,Inflate:l,CompressionStream:u,DecompressionStream:f,workerScripts:d}=e;if(Oe("baseURL",n),Oe("chunkSize",r),Oe("maxWorkers",s),Oe("terminateWorkerTimeout",a),Oe("useCompressionStream",i),Oe("useWebWorkers",o),c&&(We.CompressionStream=new Ce(c)),l&&(We.DecompressionStream=new Ce(l)),Oe("CompressionStream",u),Oe("DecompressionStream",f),d!==Re){const{deflate:e,inflate:n}=d;if((e||n)&&(We.workerScripts||(We.workerScripts={})),e){if(!t.isArray(e))throw new h("workerScripts.deflate must be an array");We.workerScripts.deflate=e}if(n){if(!t.isArray(n))throw new h("workerScripts.inflate must be an array");We.workerScripts.inflate=n}}}function Oe(e,t){t!==Re&&(We[e]=t)}const Le=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;Le[e]=t}class Ne{constructor(e){this.crc=e||-1}append(e){let t=0|this.crc;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^Le[255&(t^e[n])];this.crc=t}get(){return~this.crc}}class Ie extends z{constructor(){let e;const t=new Ne;super({transform(e,n){t.append(e),n.enqueue(e)},flush(){const n=new d(4);new g(n.buffer).setUint32(0,t.get()),e.value=n}}),e=this}}const Pe={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=Pe.getPartial(n);return 32===r?e.concat(t):Pe._shiftRight(t,r,0|n,e.slice(0,e.length-1))},bitLength(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+Pe.getPartial(n)},clamp(e,t){if(32*e.length<t)return e;const n=(e=e.slice(0,i.ceil(t/32))).length;return t&=31,n>0&&t&&(e[n-1]=Pe.partial(t,e[n-1]&2147483648>>t-1,1)),e},partial:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,getPartial:e=>i.round(e/1099511627776)||32,_shiftRight(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s<e.length;s++)r.push(n|e[s]>>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,a=Pe.getPartial(s);return r.push(Pe.partial(t+a&31,t+a>32?n:r.pop(),1)),r}},Me={bytes:{fromBits(e){const t=Pe.bitLength(e)/8,n=new d(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},toBits(e){const t=[];let n,r=0;for(n=0;n<e.length;n++)r=r<<8|e[n],3==(3&n)&&(t.push(r),r=0);return 3&n&&t.push(Pe.partial(8*(3&n),r)),t}}},Be=class{constructor(e){const t=this;t.blockSize=512,t._init=[1732584193,4023233417,2562383102,271733878,3285377520],t._key=[1518500249,1859775393,2400959708,3395469782],e?(t._h=e._h.slice(0),t._buffer=e._buffer.slice(0),t._length=e._length):t.reset()}reset(){const e=this;return e._h=e._init.slice(0),e._buffer=[],e._length=0,e}update(e){const t=this;"string"==typeof e&&(e=Me.utf8String.toBits(e));const n=t._buffer=Pe.concat(t._buffer,e),r=t._length,s=t._length=r+Pe.bitLength(e);if(s>9007199254740991)throw new h("Cannot hash more than 2^53 - 1 bits");const a=new w(n);let i=0;for(let e=t.blockSize+r-(t.blockSize+r&t.blockSize-1);s>=e;e+=t.blockSize)t._block(a.subarray(16*i,16*(i+1))),i+=1;return n.splice(0,16*i),t}finalize(){const e=this;let t=e._buffer;const n=e._h;t=Pe.concat(t,[Pe.partial(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(i.floor(e._length/4294967296)),t.push(0|e._length);t.length;)e._block(t.splice(0,16));return e.reset(),n}_f(e,t,n,r){return e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r}_S(e,t){return t<<e|t>>>32-e}_block(e){const n=this,r=n._h,s=t(80);for(let t=0;16>t;t++)s[t]=e[t];let a=r[0],o=r[1],c=r[2],l=r[3],u=r[4];for(let e=0;79>=e;e++){16>e||(s[e]=n._S(1,s[e-3]^s[e-8]^s[e-14]^s[e-16]));const t=n._S(5,a)+n._f(e,o,c,l)+u+s[e]+n._key[i.floor(e/20)]|0;u=l,l=c,c=n._S(30,o),o=a,a=t}r[0]=r[0]+a|0,r[1]=r[1]+o|0,r[2]=r[2]+c|0,r[3]=r[3]+l|0,r[4]=r[4]+u|0}},Ve={getRandomValues(e){const t=new w(e.buffer),n=e=>{let t=987654321;const n=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&n,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&n)&n)/4294967296+.5)*(i.random()>.5?1:-1))};for(let r,s=0;s<e.length;s+=4){const e=n(4294967296*(r||i.random()));r=987654071*e(),t[s/4]=4294967296*e()|0}return e}},He={importKey:e=>new He.hmacSha1(Me.bytes.toBits(e)),pbkdf2(e,t,n,r){if(n=n||1e4,0>r||0>n)throw new h("invalid params to pbkdf2");const s=1+(r>>5)<<2;let a,i,o,c,l;const u=new ArrayBuffer(s),f=new g(u);let d=0;const p=Pe;for(t=Me.bytes.toBits(t),l=1;(s||1)>d;l++){for(a=i=e.encrypt(p.concat(t,[l])),o=1;n>o;o++)for(i=e.encrypt(i),c=0;c<i.length;c++)a[c]^=i[c];for(o=0;(s||1)>d&&o<a.length;o++)f.setInt32(d,a[o]),d+=4}return u.slice(0,r/8)},hmacSha1:class{constructor(e){const t=this,n=t._hash=Be,r=[[],[]];t._baseHash=[new n,new n];const s=t._baseHash[0].blockSize/32;e.length>s&&(e=(new n).update(e).finalize());for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t._baseHash[0].update(r[0]),t._baseHash[1].update(r[1]),t._resultHash=new n(t._baseHash[0])}reset(){const e=this;e._resultHash=new e._hash(e._baseHash[0]),e._updated=!1}update(e){this._updated=!0,this._resultHash.update(e)}digest(){const e=this,t=e._resultHash.finalize(),n=new e._hash(e._baseHash[1]).update(t).finalize();return e.reset(),n}encrypt(e){if(this._updated)throw new h("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},qe=void 0!==S&&"function"==typeof S.getRandomValues,Ke="Invalid password",Ze="Invalid signature",je="zipjs-abort-check-password";function Ge(e){return qe?S.getRandomValues(e):Ve.getRandomValues(e)}const Ye=16,Xe={name:"PBKDF2"},Je=n.assign({hash:{name:"HMAC"}},Xe),Qe=n.assign({iterations:1e3,hash:{name:"SHA-1"}},Xe),$e=["deriveBits"],et=[8,12,16],tt=[16,24,32],nt=10,rt=[0,0,0,0],st="undefined",at="function",it=typeof S!=st,ot=it&&S.subtle,ct=it&&typeof ot!=st,lt=Me.bytes,ut=class{constructor(e){const t=this;t._tables=[[[],[],[],[],[]],[[],[],[],[],[]]],t._tables[0][0][0]||t._precompute();const n=t._tables[0][4],r=t._tables[1],s=e.length;let a,i,o,c=1;if(4!==s&&6!==s&&8!==s)throw new h("invalid aes key size");for(t._key=[i=e.slice(0),o=[]],a=s;4*s+28>a;a++){let e=i[a-1];(a%s==0||8===s&&a%s==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],a%s==0&&(e=e<<8^e>>>24^c<<24,c=c<<1^283*(c>>7))),i[a]=i[a-s]^e}for(let e=0;a;e++,a--){const t=i[3&e?a:a-4];o[e]=4>=a||4>e?t:r[0][n[t>>>24]]^r[1][n[t>>16&255]]^r[2][n[t>>8&255]]^r[3][n[255&t]]}}encrypt(e){return this._crypt(e,0)}decrypt(e){return this._crypt(e,1)}_precompute(){const e=this._tables[0],t=this._tables[1],n=e[4],r=t[4],s=[],a=[];let i,o,c,l;for(let e=0;256>e;e++)a[(s[e]=e<<1^283*(e>>7))^e]=e;for(let u=i=0;!n[u];u^=o||1,i=a[i]||1){let a=i^i<<1^i<<2^i<<3^i<<4;a=a>>8^255&a^99,n[u]=a,r[a]=u,l=s[c=s[o=s[u]]];let f=16843009*l^65537*c^257*o^16843008*u,h=257*s[a]^16843008*a;for(let n=0;4>n;n++)e[n][u]=h=h<<24^h>>>8,t[n][a]=f=f<<24^f>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}_crypt(e,t){if(4!==e.length)throw new h("invalid aes block size");const n=this._key[t],r=n.length/4-2,s=[0,0,0,0],a=this._tables[t],i=a[0],o=a[1],c=a[2],l=a[3],u=a[4];let f,d,p,w=e[0]^n[0],g=e[t?3:1]^n[1],m=e[2]^n[2],y=e[t?1:3]^n[3],b=4;for(let e=0;r>e;e++)f=i[w>>>24]^o[g>>16&255]^c[m>>8&255]^l[255&y]^n[b],d=i[g>>>24]^o[m>>16&255]^c[y>>8&255]^l[255&w]^n[b+1],p=i[m>>>24]^o[y>>16&255]^c[w>>8&255]^l[255&g]^n[b+2],y=i[y>>>24]^o[w>>16&255]^c[g>>8&255]^l[255&m]^n[b+3],b+=4,w=f,g=d,m=p;for(let e=0;4>e;e++)s[t?3&-e:e]=u[w>>>24]<<24^u[g>>16&255]<<16^u[m>>8&255]<<8^u[255&y]^n[b++],f=w,w=g,g=m,m=y,y=f;return s}},ft=class{constructor(e,t){this._prf=e,this._initIv=t,this._iv=t}reset(){this._iv=this._initIv}update(e){return this.calculate(this._prf,e,this._iv)}incWord(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}incCounter(e){0===(e[0]=this.incWord(e[0]))&&(e[1]=this.incWord(e[1]))}calculate(e,t,n){let r;if(!(r=t.length))return[];const s=Pe.bitLength(t);for(let s=0;r>s;s+=4){this.incCounter(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return Pe.clamp(t,s)}},ht=He.hmacSha1;let dt=it&&ct&&typeof ot.importKey==at,pt=it&&ct&&typeof ot.deriveBits==at;class wt extends z{constructor({password:e,signed:t,encryptionStrength:r,checkPasswordOnly:s}){super({start(){n.assign(this,{ready:new y((e=>this.resolveReady=e)),password:e,signed:t,strength:r-1,pending:new d})},async transform(e,t){const n=this,{password:r,strength:a,resolveReady:i,ready:o}=n;r?(await(async(e,t,n,r)=>{const s=await yt(e,t,n,vt(r,0,et[t])),a=vt(r,et[t]);if(s[0]!=a[0]||s[1]!=a[1])throw new h(Ke)})(n,a,r,vt(e,0,et[a]+2)),e=vt(e,et[a]+2),s?t.error(new h(je)):i()):await o;const c=new d(e.length-nt-(e.length-nt)%Ye);t.enqueue(mt(n,e,c,0,nt,!0))},async flush(e){const{signed:t,ctr:n,hmac:r,pending:s,ready:a}=this;await a;const i=vt(s,0,s.length-nt),o=vt(s,s.length-nt);let c=new d;if(i.length){const e=St(lt,i);r.update(e);const t=n.update(e);c=kt(lt,t)}if(t){const e=vt(kt(lt,r.digest()),0,nt);for(let t=0;nt>t;t++)if(e[t]!=o[t])throw new h(Ze)}e.enqueue(c)}})}}class gt extends z{constructor({password:e,encryptionStrength:t}){let r;super({start(){n.assign(this,{ready:new y((e=>this.resolveReady=e)),password:e,strength:t-1,pending:new d})},async transform(e,t){const n=this,{password:r,strength:s,resolveReady:a,ready:i}=n;let o=new d;r?(o=await(async(e,t,n)=>{const r=Ge(new d(et[t]));return bt(r,await yt(e,t,n,r))})(n,s,r),a()):await i;const c=new d(o.length+e.length-e.length%Ye);c.set(o,0),t.enqueue(mt(n,e,c,o.length,0))},async flush(e){const{ctr:t,hmac:n,pending:s,ready:a}=this;await a;let i=new d;if(s.length){const e=t.update(St(lt,s));n.update(e),i=kt(lt,e)}r.signature=kt(lt,n.digest()).slice(0,nt),e.enqueue(bt(i,r.signature))}}),r=this}}function mt(e,t,n,r,s,a){const{ctr:i,hmac:o,pending:c}=e,l=t.length-s;let u;for(c.length&&(t=bt(c,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new d(t)).set(n,0)}return e})(n,l-l%Ye)),u=0;l-Ye>=u;u+=Ye){const e=St(lt,vt(t,u,u+Ye));a&&o.update(e);const s=i.update(e);a||o.update(s),n.set(kt(lt,s),u+r)}return e.pending=vt(t,u),n}async function yt(e,r,s,a){e.password=null;const i=(e=>{if(void 0===b){const t=new d((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new b).encode(e)})(s),o=await(async(e,t,n,r,s)=>{if(!dt)return He.importKey(t);try{return await ot.importKey("raw",t,n,!1,s)}catch(e){return dt=!1,He.importKey(t)}})(0,i,Je,0,$e),c=await(async(e,t,n)=>{if(!pt)return He.pbkdf2(t,e.salt,Qe.iterations,n);try{return await ot.deriveBits(e,t,n)}catch(r){return pt=!1,He.pbkdf2(t,e.salt,Qe.iterations,n)}})(n.assign({salt:a},Qe),o,8*(2*tt[r]+2)),l=new d(c),u=St(lt,vt(l,0,tt[r])),f=St(lt,vt(l,tt[r],2*tt[r])),h=vt(l,2*tt[r]);return n.assign(e,{keys:{key:u,authentication:f,passwordVerification:h},ctr:new ft(new ut(u),t.from(rt)),hmac:new ht(f)}),h}function bt(e,t){let n=e;return e.length+t.length&&(n=new d(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function vt(e,t,n){return e.subarray(t,n)}function kt(e,t){return e.fromBits(t)}function St(e,t){return e.toBits(t)}class _t extends z{constructor({password:e,passwordVerification:t,checkPasswordOnly:r}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Rt(this,e)},transform(e,t){const n=this;if(n.password){const t=Dt(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new h(Ke);e=e.subarray(12)}r?t.error(new h(je)):t.enqueue(Dt(n,e))}})}}class zt extends z{constructor({password:e,passwordVerification:t}){super({start(){n.assign(this,{password:e,passwordVerification:t}),Rt(this,e)},transform(e,t){const n=this;let r,s;if(n.password){n.password=null;const t=Ge(new d(12));t[11]=n.passwordVerification,r=new d(e.length+t.length),r.set(xt(n,t),0),s=12}else r=new d(e.length),s=0;r.set(xt(n,e),s),t.enqueue(r)}})}}function Dt(e,t){const n=new d(t.length);for(let r=0;r<t.length;r++)n[r]=Tt(e)^t[r],Ft(e,n[r]);return n}function xt(e,t){const n=new d(t.length);for(let r=0;r<t.length;r++)n[r]=Tt(e)^t[r],Ft(e,t[r]);return n}function Rt(e,t){const r=[305419896,591751049,878082192];n.assign(e,{keys:r,crcKey0:new Ne(r[0]),crcKey2:new Ne(r[2])});for(let n=0;n<t.length;n++)Ft(e,t.charCodeAt(n))}function Ft(e,t){let[n,r,s]=e.keys;e.crcKey0.append([t]),n=~e.crcKey0.get(),r=Et(i.imul(Et(r+Ct(n)),134775813)+1),e.crcKey2.append([r>>>24]),s=~e.crcKey2.get(),e.keys=[n,r,s]}function Tt(e){const t=2|e.keys[2];return Ct(i.imul(t,1^t)>>>8)}function Ct(e){return 255&e}function Et(e){return 4294967295&e}const Ut="deflate-raw";class Wt extends z{constructor(e,{chunkSize:t,CompressionStream:n,CompressionStreamNative:r}){super({});const{compressed:s,encrypted:a,useCompressionStream:i,zipCrypto:o,signed:c,level:l}=e,u=this;let f,h,d=Ot(super.readable);a&&!o||!c||(f=new Ie,d=It(d,f)),s&&(d=Nt(d,i,{level:l,chunkSize:t},r,n)),a&&(o?d=It(d,new zt(e)):(h=new gt(e),d=It(d,h))),Lt(u,d,(()=>{let e;a&&!o&&(e=h.signature),a&&!o||!c||(e=new g(f.value.buffer).getUint32(0)),u.signature=e}))}}class At extends z{constructor(e,{chunkSize:t,DecompressionStream:n,DecompressionStreamNative:r}){super({});const{zipCrypto:s,encrypted:a,signed:i,signature:o,compressed:c,useCompressionStream:l}=e;let u,f,d=Ot(super.readable);a&&(s?d=It(d,new _t(e)):(f=new wt(e),d=It(d,f))),c&&(d=Nt(d,l,{chunkSize:t},r,n)),a&&!s||!i||(u=new Ie,d=It(d,u)),Lt(this,d,(()=>{if((!a||s)&&i){const e=new g(u.value.buffer);if(o!=e.getUint32(0,!1))throw new h(Ze)}}))}}function Ot(e){return It(e,new z({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function Lt(e,t,r){t=It(t,new z({flush:r})),n.defineProperty(e,"readable",{get:()=>t})}function Nt(e,t,n,r,s){try{e=It(e,new(t&&r?r:s)(Ut,n))}catch(r){if(!t)throw r;e=It(e,new s(Ut,n))}return e}function It(e,t){return e.pipeThrough(t)}const Pt="data",Mt="inflate";class Bt extends z{constructor(e,t){super({});const r=this,{codecType:s}=e;let a;s.startsWith("deflate")?a=Wt:s.startsWith(Mt)&&(a=At);let i=0;const o=new a(e,t),c=super.readable,l=new z({transform(e,t){e&&e.length&&(i+=e.length,t.enqueue(e))},flush(){const{signature:e}=o;n.assign(r,{signature:e,size:i})}});n.defineProperty(r,"readable",{get:()=>c.pipeThrough(o).pipeThrough(l)})}}const Vt=typeof C!=Fe;class Ht{constructor(e,{readable:t,writable:r},{options:s,config:a,streamOptions:i,useWebWorkers:o,transferStreams:c,scripts:l},u){const{signal:f}=i;return n.assign(e,{busy:!0,readable:t.pipeThrough(new qt(t,i,a),{signal:f}),writable:r,options:n.assign({},s),scripts:l,transferStreams:c,terminate(){const{worker:t,busy:n}=e;t&&!n&&(t.terminate(),e.interface=null)},onTaskFinished(){e.busy=!1,u(e)}}),(o&&Vt?jt:Zt)(e,a)}}class qt extends z{constructor(e,{onstart:t,onprogress:n,size:r,onend:s},{chunkSize:a}){let i=0;super({start(){t&&Kt(t,r)},async transform(e,t){i+=e.length,n&&await Kt(n,i,r),t.enqueue(e)},flush(){e.size=i,s&&Kt(s,i)}},{highWaterMark:1,size:()=>a})}}async function Kt(e,...t){try{await e(...t)}catch(e){}}function Zt(e,t){return{run:()=>(async({options:e,readable:t,writable:n,onTaskFinished:r},s)=>{const a=new Bt(e,s);try{await t.pipeThrough(a).pipeTo(n,{preventClose:!0,preventAbort:!0});const{signature:e,size:r}=a;return{signature:e,size:r}}finally{r()}})(e,t)}}function jt(e,{baseURL:t,chunkSize:r}){return e.interface||n.assign(e,{worker:Xt(e.scripts[0],t,e),interface:{run:()=>(async(e,t)=>{let r,s;const a=new y(((e,t)=>{r=e,s=t}));n.assign(e,{reader:null,writer:null,resolveResult:r,rejectResult:s,result:a});const{readable:i,options:o,scripts:c}=e,{writable:l,closed:u}=(e=>{const t=e.getWriter();let n;const r=new y((e=>n=e));return{writable:new x({async write(e){await t.ready,await t.write(e)},close(){t.releaseLock(),n()},abort:e=>t.abort(e)}),closed:r}})(e.writable);Jt({type:"start",scripts:c.slice(1),options:o,config:t,readable:i,writable:l},e)||n.assign(e,{reader:i.getReader(),writer:l.getWriter()});const f=await a;try{await l.getWriter().close()}catch(e){}return await u,f})(e,{chunkSize:r})}}),e.interface}let Gt=!0,Yt=!0;function Xt(e,t,r){const s={type:"module"};let a,i;typeof e==Te&&(e=e());try{a=new f(e,t)}catch(t){a=e}if(Gt)try{i=new C(a)}catch(e){Gt=!1,i=new C(a,s)}else i=new C(a,s);return i.addEventListener("message",(e=>(async({data:e},t)=>{const{type:r,value:s,messageId:a,result:i,error:o}=e,{reader:c,writer:l,resolveResult:u,rejectResult:f,onTaskFinished:p}=t;try{if(o){const{message:e,stack:t,code:r,name:s}=o,a=new h(e);n.assign(a,{stack:t,code:r,name:s}),w(a)}else{if("pull"==r){const{value:e,done:n}=await c.read();Jt({type:Pt,value:e,done:n,messageId:a},t)}r==Pt&&(await l.ready,await l.write(new d(s)),Jt({type:"ack",messageId:a},t)),"close"==r&&w(null,i)}}catch(o){w(o)}function w(e,t){e?f(e):u(t),l&&l.releaseLock(),p()}})(e,r))),i}function Jt(e,{worker:t,writer:n,onTaskFinished:r,transferStreams:s}){try{let{value:r,readable:a,writable:i}=e;const o=[];if(r&&(e.value=r.buffer,o.push(e.value)),s&&Yt?(a&&o.push(a),i&&o.push(i)):e.readable=e.writable=null,o.length)try{return t.postMessage(e,o),!0}catch(n){Yt=!1,e.readable=e.writable=null,t.postMessage(e)}else t.postMessage(e)}catch(e){throw n&&n.releaseLock(),r(),e}}let Qt=[];const $t=[];let en=0;function tn(e){const{terminateTimeout:t}=e;t&&(clearTimeout(t),e.terminateTimeout=null)}const nn=65536,rn="writable";class sn{constructor(){this.size=0}init(){this.initialized=!0}}class an extends sn{get readable(){const e=this,{chunkSize:t=nn}=e,n=new D({start(){this.chunkOffset=0},async pull(r){const{offset:s=0,size:a,diskNumberStart:o}=n,{chunkOffset:c}=this;r.enqueue(await pn(e,s+c,i.min(t,a-c),o)),c+t>a?r.close():this.chunkOffset+=t}});return n}}class on extends sn{constructor(){super();const e=this,t=new x({write:t=>e.writeUint8Array(t)});n.defineProperty(e,rn,{get:()=>t})}writeUint8Array(){}}class cn extends an{constructor(e){super(),n.assign(this,{blob:e,size:e.size})}async readUint8Array(e,t){const n=this,r=e+t,s=e||r<n.size?n.blob.slice(e,r):n.blob;let a=await s.arrayBuffer();return a.byteLength>t&&(a=a.slice(e,r)),new d(a)}}class ln extends sn{constructor(e){super();const t=new z,r=[];e&&r.push(["Content-Type",e]),n.defineProperty(this,rn,{get:()=>t.writable}),this.blob=new u(t.readable,{headers:r}).blob()}getData(){return this.blob}}class un extends an{constructor(e){super(),this.readers=e}async init(){const e=this,{readers:t}=e;e.lastDiskNumber=0,e.lastDiskOffset=0,await y.all(t.map((async(n,r)=>{await n.init(),r!=t.length-1&&(e.lastDiskOffset+=n.size),e.size+=n.size}))),super.init()}async readUint8Array(e,t,n=0){const r=this,{readers:s}=this;let a,o=n;-1==o&&(o=s.length-1);let c=e;for(;c>=s[o].size;)c-=s[o].size,o++;const l=s[o],u=l.size;if(c+t>u){const s=u-c;a=new d(t),a.set(await pn(l,c,s)),a.set(await r.readUint8Array(e+s,t-s,n),s)}else a=await pn(l,c,t);return r.lastDiskNumber=i.max(o,r.lastDiskNumber),a}}class fn extends sn{constructor(e,t=4294967295){super();const r=this;let s,a,i;n.assign(r,{diskNumber:0,diskOffset:0,size:0,maxSize:t,availableSize:t});const o=new x({async write(t){const{availableSize:n}=r;if(i)t.length<n?await c(t):(await c(t.slice(0,n)),await l(),r.diskOffset+=s.size,r.diskNumber++,i=null,await this.write(t.slice(n)));else{const{value:n,done:o}=await e.next();if(o&&!n)throw new h("Writer iterator completed too soon");s=n,s.size=0,s.maxSize&&(r.maxSize=s.maxSize),r.availableSize=r.maxSize,await hn(s),a=n.writable,i=a.getWriter(),await this.write(t)}},async close(){await i.ready,await l()}});async function c(e){const t=e.length;t&&(await i.ready,await i.write(e),s.size+=t,r.size+=t,r.availableSize-=t)}async function l(){a.size=s.size,await i.close()}n.defineProperty(r,rn,{get:()=>o})}}async function hn(e,t){e.init&&!e.initialized&&await e.init(t)}function dn(e){return t.isArray(e)&&(e=new un(e)),e instanceof D&&(e={readable:e}),e}function pn(e,t,n,r){return e.readUint8Array(t,n,r)}const wn="\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");function gn(e,t){return t&&"cp437"==t.trim().toLowerCase()?(e=>{{let t="";for(let n=0;n<e.length;n++)t+=wn[e[n]];return t}})(e):new v(t).decode(e)}const mn="filename",yn="rawFilename",bn="comment",vn="rawComment",kn="uncompressedSize",Sn="compressedSize",_n="offset",zn="diskNumberStart",Dn="lastModDate",xn="rawLastModDate",Rn="lastAccessDate",Fn="creationDate",Tn=[mn,yn,Sn,kn,Dn,xn,bn,vn,Rn,Fn,_n,zn,zn,"internalFileAttribute","externalFileAttribute","msDosCompatible","zip64","directory","bitFlag","encrypted","signature","filenameUTF8","commentUTF8","compressionMethod","version","versionMadeBy","extraField","rawExtraField","extraFieldZip64","extraFieldUnicodePath","extraFieldUnicodeComment","extraFieldAES","extraFieldNTFS","extraFieldExtendedTimestamp"];class Cn{constructor(e){Tn.forEach((t=>this[t]=e[t]))}}const En="File format is not recognized",Un="End of central directory not found",Wn="End of Zip64 central directory not found",An="End of Zip64 central directory locator not found",On="Central directory header not found",Ln="Local file header not found",Nn="Zip64 extra field not found",In="File contains encrypted entry",Pn="Encryption method not supported",Mn="Compression method not supported",Bn="Split zip file",Vn="utf-8",Hn="cp437",qn=[[kn,_e],[Sn,_e],[_n,_e],[zn,ze]],Kn={[ze]:{getValue:tr,bytes:4},[_e]:{getValue:nr,bytes:8}};class Zn{constructor(e,t,r){n.assign(this,{reader:e,config:t,options:r})}async getData(e,t,r={}){const a=this,{reader:i,offset:o,diskNumberStart:c,extraFieldAES:l,compressionMethod:u,config:f,bitFlag:p,signature:w,rawLastModDate:g,uncompressedSize:m,compressedSize:b}=a,v=t.localDirectory={},k=rr(await pn(i,o,30,c));let S=Xn(a,r,"password");if(S=S&&S.length&&S,l&&99!=l.originalCompressionMethod)throw new h(Mn);if(0!=u&&8!=u)throw new h(Mn);if(67324752!=tr(k,0))throw new h(Ln);jn(v,k,4),v.rawExtraField=v.extraFieldLength?await pn(i,o+30+v.filenameLength,v.extraFieldLength,c):new d,await Gn(a,v,k,4,!0),n.assign(t,{lastAccessDate:v.lastAccessDate,creationDate:v.creationDate});const _=a.encrypted&&v.encrypted,z=_&&!l;if(_){if(!z&&l.strength===Re)throw new h(Pn);if(!S)throw new h(In)}const D=o+30+v.filenameLength+v.extraFieldLength,R=b,F=i.readable;n.assign(F,{diskNumberStart:c,offset:D,size:R});const T=Xn(a,r,"signal"),C=Xn(a,r,"checkPasswordOnly");C&&(e=new x),e=(e=>{e.writable===Re&&typeof e.next==Te&&(e=new fn(e)),e instanceof x&&(e={writable:e});const{writable:t}=e;return t.size===Re&&(t.size=0),e instanceof fn||n.assign(e,{diskNumber:0,diskOffset:0,availableSize:1/0,maxSize:1/0}),e})(e),await hn(e,m);const{writable:E}=e,{onstart:U,onprogress:W,onend:A}=r,O={options:{codecType:Mt,password:S,zipCrypto:z,encryptionStrength:l&&l.strength,signed:Xn(a,r,"checkSignature"),passwordVerification:z&&(p.dataDescriptor?g>>>8&255:w>>>24&255),signature:w,compressed:0!=u,encrypted:_,useWebWorkers:Xn(a,r,"useWebWorkers"),useCompressionStream:Xn(a,r,"useCompressionStream"),transferStreams:Xn(a,r,"transferStreams"),checkPasswordOnly:C},config:f,streamOptions:{signal:T,size:R,onstart:U,onprogress:W,onend:A}};let L=0;try{({outputSize:L}=await(async(e,t)=>{const{options:n,config:r}=t,{transferStreams:a,useWebWorkers:i,useCompressionStream:o,codecType:c,compressed:l,signed:u,encrypted:f}=n,{workerScripts:h,maxWorkers:d,terminateWorkerTimeout:p}=r;t.transferStreams=a||a===Re;const w=!(l||u||f||t.transferStreams);let g;t.useWebWorkers=!w&&(i||i===Re&&r.useWebWorkers),t.scripts=t.useWebWorkers&&h?h[c]:[],n.useCompressionStream=o||o===Re&&r.useCompressionStream;const m=Qt.find((e=>!e.busy));if(m)tn(m),g=new Ht(m,e,t,b);else if(Qt.length<d){const n={indexWorker:en};en++,Qt.push(n),g=new Ht(n,e,t,b)}else g=await new y((n=>$t.push({resolve:n,stream:e,workerOptions:t})));return g.run();function b(e){if($t.length){const[{resolve:t,stream:n,workerOptions:r}]=$t.splice(0,1);t(new Ht(e,n,r,b))}else e.worker?(tn(e),s.isFinite(p)&&p>=0&&(e.terminateTimeout=setTimeout((()=>{Qt=Qt.filter((t=>t!=e)),e.terminate()}),p))):Qt=Qt.filter((t=>t!=e))}})({readable:F,writable:E},O))}catch(e){if(!C||e.message!=je)throw e}finally{const e=Xn(a,r,"preventClose");E.size+=L,e||E.locked||await E.getWriter().close()}return C?void 0:e.getData?e.getData():E}}function jn(e,t,r){const s=e.rawBitFlag=er(t,r+2),a=1==(1&s),i=tr(t,r+6);n.assign(e,{encrypted:a,version:er(t,r),bitFlag:{level:(6&s)>>1,dataDescriptor:8==(8&s),languageEncodingFlag:2048==(2048&s)},rawLastModDate:i,lastModDate:Jn(i),filenameLength:er(t,r+22),extraFieldLength:er(t,r+24)})}async function Gn(e,t,r,s,a){const{rawExtraField:i}=t,l=t.extraField=new c,u=rr(new d(i));let f=0;try{for(;f<i.length;){const e=er(u,f),t=er(u,f+2);l.set(e,{type:e,data:i.slice(f+4,f+4+t)}),f+=4+t}}catch(e){}const p=er(r,s+4);n.assign(t,{signature:tr(r,s+10),uncompressedSize:tr(r,s+18),compressedSize:tr(r,s+14)});const w=l.get(1);w&&(((e,t)=>{t.zip64=!0;const n=rr(e.data),r=qn.filter((([e,n])=>t[e]==n));for(let s=0,a=0;s<r.length;s++){const[i,o]=r[s];if(t[i]==o){const r=Kn[o];t[i]=e[i]=r.getValue(n,a),a+=r.bytes}else if(e[i])throw new h(Nn)}})(w,t),t.extraFieldZip64=w);const g=l.get(28789);g&&(await Yn(g,mn,yn,t,e),t.extraFieldUnicodePath=g);const m=l.get(25461);m&&(await Yn(m,bn,vn,t,e),t.extraFieldUnicodeComment=m);const y=l.get(39169);y?(((e,t,r)=>{const s=rr(e.data),a=$n(s,4);n.assign(e,{vendorVersion:$n(s,0),vendorId:$n(s,2),strength:a,originalCompressionMethod:r,compressionMethod:er(s,5)}),t.compressionMethod=e.compressionMethod})(y,t,p),t.extraFieldAES=y):t.compressionMethod=p;const b=l.get(10);b&&(((e,t)=>{const r=rr(e.data);let s,a=4;try{for(;a<e.data.length&&!s;){const t=er(r,a),n=er(r,a+2);1==t&&(s=e.data.slice(a+4,a+4+n)),a+=4+n}}catch(e){}try{if(s&&24==s.length){const r=rr(s),a=r.getBigUint64(0,!0),i=r.getBigUint64(8,!0),o=r.getBigUint64(16,!0);n.assign(e,{rawLastModDate:a,rawLastAccessDate:i,rawCreationDate:o});const c={lastModDate:Qn(a),lastAccessDate:Qn(i),creationDate:Qn(o)};n.assign(e,c),n.assign(t,c)}}catch(e){}})(b,t),t.extraFieldNTFS=b);const v=l.get(21589);v&&(((e,t,n)=>{const r=rr(e.data),s=$n(r,0),a=[],i=[];n?(1==(1&s)&&(a.push(Dn),i.push(xn)),2==(2&s)&&(a.push(Rn),i.push("rawLastAccessDate")),4==(4&s)&&(a.push(Fn),i.push("rawCreationDate"))):5>e.data.length||(a.push(Dn),i.push(xn));let c=1;a.forEach(((n,s)=>{if(e.data.length>=c+4){const a=tr(r,c);t[n]=e[n]=new o(1e3*a);const l=i[s];e[l]=a}c+=4}))})(v,t,a),t.extraFieldExtendedTimestamp=v);const k=l.get(6534);k&&(t.extraFieldUSDZ=k)}async function Yn(e,t,r,s,a){const i=rr(e.data),o=new Ne;o.append(a[r]);const c=rr(new d(4));c.setUint32(0,o.get(),!0);const l=tr(i,1);n.assign(e,{version:$n(i,0),[t]:gn(e.data.subarray(5)),valid:!a.bitFlag.languageEncodingFlag&&l==tr(c,0)}),e.valid&&(s[t]=e[t],s[t+"UTF8"]=!0)}function Xn(e,t,n){return t[n]===Re?e.options[n]:t[n]}function Jn(e){const t=(4294901760&e)>>16,n=65535&e;try{return new o(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}function Qn(e){return new o(s(e/a(1e4)-a(116444736e5)))}function $n(e,t){return e.getUint8(t)}function er(e,t){return e.getUint16(t,!0)}function tr(e,t){return e.getUint32(t,!0)}function nr(e,t){return s(e.getBigUint64(t,!0))}function rr(e){return new g(e.buffer)}Ae({Inflate:Se}),e.BlobReader=cn,e.BlobWriter=ln,e.Data64URIWriter=class extends on{constructor(e){super(),n.assign(this,{data:"data:"+(e||"")+";base64,",pending:[]})}writeUint8Array(e){const t=this;let n=0,s=t.pending;const a=t.pending.length;for(t.pending="",n=0;n<3*i.floor((a+e.length)/3)-a;n++)s+=r.fromCharCode(e[n]);for(;n<e.length;n++)t.pending+=r.fromCharCode(e[n]);s.length>2?t.data+=_(s):t.pending=s}getData(){return this.data+_(this.pending)}},e.ERR_BAD_FORMAT=En,e.ERR_CENTRAL_DIRECTORY_NOT_FOUND=On,e.ERR_ENCRYPTED=In,e.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=An,e.ERR_EOCDR_NOT_FOUND=Un,e.ERR_EOCDR_ZIP64_NOT_FOUND=Wn,e.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=Nn,e.ERR_INVALID_PASSWORD=Ke,e.ERR_INVALID_SIGNATURE=Ze,e.ERR_LOCAL_FILE_HEADER_NOT_FOUND=Ln,e.ERR_SPLIT_ZIP_FILE=Bn,e.ERR_UNSUPPORTED_COMPRESSION=Mn,e.ERR_UNSUPPORTED_ENCRYPTION=Pn,e.TextWriter=class extends ln{constructor(e){super(e),n.assign(this,{encoding:e,utf8:!e||"utf-8"==e.toLowerCase()})}async getData(){const{encoding:e,utf8:t}=this,r=await super.getData();if(r.text&&t)return r.text();{const t=new FileReader;return new y(((s,a)=>{n.assign(t,{onload:({target:e})=>s(e.result),onerror:()=>a(t.error)}),t.readAsText(r,e)}))}}},e.ZipReader=class{constructor(e,t={}){n.assign(this,{reader:dn(e),options:t,config:We})}async*getEntriesGenerator(e={}){const t=this;let{reader:r}=t;const{config:s}=t;if(await hn(r),r.size!==Re&&r.readUint8Array||(r=new cn(await new u(r.readable).blob()),await hn(r)),22>r.size)throw new h(En);r.chunkSize=(e=>i.max(e.chunkSize,64))(s);const a=await(async(e,t,n)=>{const r=new d(4);return rr(r).setUint32(0,101010256,!0),await s(22)||await s(i.min(1048582,n));async function s(t){const s=n-t,a=await pn(e,s,t);for(let e=a.length-22;e>=0;e--)if(a[e]==r[0]&&a[e+1]==r[1]&&a[e+2]==r[2]&&a[e+3]==r[3])return{offset:s+e,buffer:a.slice(e,e+22).buffer}}})(r,0,r.size);if(!a)throw 134695760==tr(rr(await pn(r,0,4)))?new h(Bn):new h(Un);const o=rr(a);let c=tr(o,12),l=tr(o,16);const f=a.offset,p=er(o,20),w=f+22+p;let g=er(o,4);const m=r.lastDiskNumber||0;let b=er(o,6),v=er(o,8),k=0,S=0;if(l==_e||c==_e||v==ze||b==ze){const e=rr(await pn(r,a.offset-20,20));if(117853008!=tr(e,0))throw new h(Wn);l=nr(e,8);let t=await pn(r,l,56,-1),n=rr(t);const s=a.offset-20-56;if(tr(n,0)!=xe&&l!=s){const e=l;l=s,k=l-e,t=await pn(r,l,56,-1),n=rr(t)}if(tr(n,0)!=xe)throw new h(An);g==ze&&(g=tr(n,16)),b==ze&&(b=tr(n,20)),v==ze&&(v=nr(n,32)),c==_e&&(c=nr(n,40)),l-=c}if(m!=g)throw new h(Bn);if(0>l||l>=r.size)throw new h(En);let _=0,z=await pn(r,l,c,b),D=rr(z);if(c){const e=a.offset-c;if(tr(D,_)!=De&&l!=e){const t=l;l=e,k=l-t,z=await pn(r,l,c,b),D=rr(z)}}const x=a.offset-l-(r.lastDiskOffset||0);if(c==x||0>x||(c=x,z=await pn(r,l,c,b),D=rr(z)),0>l||l>=r.size)throw new h(En);const R=Xn(t,e,"filenameEncoding"),F=Xn(t,e,"commentEncoding");for(let a=0;v>a;a++){const o=new Zn(r,s,t.options);if(tr(D,_)!=De)throw new h(On);jn(o,D,_+6);const c=!!o.bitFlag.languageEncodingFlag,l=_+46,u=l+o.filenameLength,f=u+o.extraFieldLength,d=er(D,_+4),p=0==(0&d),w=z.subarray(l,u),g=er(D,_+32),m=f+g,b=z.subarray(f,m),x=c,T=c,C=p&&16==(16&$n(D,_+38)),E=tr(D,_+42)+k;n.assign(o,{versionMadeBy:d,msDosCompatible:p,compressedSize:0,uncompressedSize:0,commentLength:g,directory:C,offset:E,diskNumberStart:er(D,_+34),internalFileAttribute:er(D,_+36),externalFileAttribute:tr(D,_+38),rawFilename:w,filenameUTF8:x,commentUTF8:T,rawExtraField:z.subarray(u,f)});const[U,W]=await y.all([gn(w,x?Vn:R||Hn),gn(b,T?Vn:F||Hn)]);n.assign(o,{rawComment:b,filename:U,comment:W,directory:C||U.endsWith("/")}),S=i.max(E,S),await Gn(o,o,D,_+6);const A=new Cn(o);A.getData=(e,t)=>o.getData(e,A,t),_=m;const{onprogress:O}=e;if(O)try{await O(a+1,v,new Cn(o))}catch(e){}yield A}const T=Xn(t,e,"extractPrependedData"),C=Xn(t,e,"extractAppendedData");return T&&(t.prependedData=S>0?await pn(r,0,S):new d),t.comment=p?await pn(r,f+22,p):new d,C&&(t.appendedData=w<r.size?await pn(r,w,r.size-w):new d),!0}async getEntries(e={}){const t=[];for await(const n of this.getEntriesGenerator(e))t.push(n);return t}async close(){}},e.configure=Ae,e.getMimeType=()=>"application/octet-stream",e.terminateWorkers=()=>{Qt.forEach((e=>{tn(e),e.terminate()}))},n.defineProperty(e,"__esModule",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zip={});