diff --git a/lib/single-file-extension.js b/lib/single-file-extension.js index 60c04b720..196a80467 100644 --- a/lib/single-file-extension.js +++ b/lib/single-file-extension.js @@ -1 +1 @@ -!function(){"use strict";const t=33554432;async function e(e,n){if(n.includeBOM&&(e.content="\ufeff"+e.content),n.includeInfobar&&(e.content+=await infobar.getScript()),n.backgroundSave||n.openEditor||n.saveToGDrive||n.saveToGitHub||n.saveWithCompanion||n.saveWithWebDAV)for(let o=0;o*tt,r.truncated?(r.finished=(o+1)*t>e.content.length,r.content=e.content.substring(o*t,(o+1)*t)):r.content=e.content,await browser.runtime.sendMessage(r)}else n.saveToClipboard?function(t){const e="copy";function n(e){e.clipboardData.setData("text/html",t.content),e.clipboardData.setData("text/plain",t.content),e.preventDefault()}document.addEventListener(e,n),document.execCommand(e),document.removeEventListener(e,n)}(e):await async function(t){if(t.filename&&t.filename.length){const e=document.createElement("a");e.download=t.filename,e.href=URL.createObjectURL(new Blob([t.content],{type:"text/html"})),e.dispatchEvent(new MouseEvent("click")),setTimeout((()=>URL.revokeObjectURL(e.href)),1e3)}return new Promise((t=>setTimeout(t,1)))}(e),n.openSavedPage&&open(URL.createObjectURL(new Blob([e.content],{type:"text/html"}))),browser.runtime.sendMessage({method:"ui.processEnd"});await browser.runtime.sendMessage({method:"downloads.end",taskId:n.taskId,hash:e.hash,woleetKey:n.woleetKey})}const n="single-file-request-fetch",o="single-file-ack-fetch",r="single-file-response-fetch",a="Host fetch error (SingleFile)",i=2500,s=Boolean(window.wrappedJSObject),l=(t,e,n)=>window.addEventListener(t,e,n),c=t=>window.dispatchEvent(t),d=(t,e,n)=>window.removeEventListener(t,e,n),p=(t,e)=>window.fetch(t,e);let u=0,m=new Map;async function f(t){const e=await browser.runtime.sendMessage(t);if(!e||e.error)throw new Error(e&&e.error&&e.error.toString());return e}browser.runtime.onMessage.addListener((t=>"singlefile.fetchFrame"==t.method&&window.frameId&&window.frameId==t.frameId?async function(t){try{const e=await p(t.url,{cache:"force-cache",headers:t.headers});return{status:e.status,headers:[...e.headers],array:Array.from(new Uint8Array(await e.arrayBuffer()))}}catch(t){return{error:t&&t.toString()}}}(t):"singlefile.fetchResponse"==t.method?async function(t){const e=m.get(t.requestId);e&&(t.error?(e.reject(new Error(t.error)),m.delete(t.requestId)):(t.truncated&&(e.array?e.array=e.array.concat(t.array):(e.array=t.array,m.set(t.requestId,e)),t.finished&&(t.array=e.array)),t.truncated&&!t.finished||(e.resolve({status:t.status,headers:{get:e=>t.headers&&t.headers[e]},arrayBuffer:async()=>new Uint8Array(t.array).buffer}),m.delete(t.requestId))));return{}}(t):void 0));const h=globalThis.singlefile,g=h.helper.SELECTED_CONTENT_ATTRIBUTE_NAME,y="singlefile-mask",w="singlefile-mask-content",b="singlefile-progress-bar",A="singlefile-progress-bar-content",E="single-file-selection-zone",v="singlefile-logs-window",S="singlefile-logs",C="singlefile-logs-line",x="singlefile-logs-line-text",I="singlefile-logs-line-icon",D=h.helper.SINGLE_FILE_UI_ELEMENT_CLASS,L=8,P=browser.i18n.getMessage("logPanelDeferredImages"),T=browser.i18n.getMessage("logPanelFrameContents"),k=browser.i18n.getMessage("logPanelStep"),R=browser.i18n.getMessage("logPanelWidth"),N=new Set(Array.from(getComputedStyle(document.documentElement)));let B,U;function M(t,e){return prompt(t,e)}function O(t){if(!document.querySelector(y)&&(t.logsEnabled&&document.documentElement.appendChild(U),t.shadowEnabled)){const e=function(){try{let t=document.querySelector(y);if(!t){t=J(y,document.documentElement);const e=t.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=`\n\t\t\t\t@keyframes single-file-progress { \n\t\t\t\t\t0% { \n\t\t\t\t\t\tleft: -50px;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\tleft: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t.${b} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 0;\n\t\t\t\t\theight: 8px;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: .5;\n\t\t\t\t\toverflow: hidden;\t\t\t\t\t\n\t\t\t\t\ttransition: width 200ms ease-in-out;\n\t\t\t\t}\n\t\t\t\t.${A} {\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\tanimation: single-file-progress 3s linear infinite reverse;\n\t\t\t\t\tbackground: \n\t\t\t\t\t\twhite \n\t\t\t\t\t\tlinear-gradient(-45deg, rgba(0, 0, 0, 0.075) 25%, \n\t\t\t\t\t\t\ttransparent 25%, \n\t\t\t\t\t\t\ttransparent 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 75%, \n\t\t\t\t\t\t\ttransparent 75%, transparent)\n\t\t\t\t\t\trepeat scroll 0% 0% / 50px 50px padding-box border-box;\n\t\t\t\t\twidth: calc(100% + 50px);\n\t\t\t\t\theight: 100%;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.${w} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\theight: 100%;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: 0;\n\t\t\t\t\tbackground-color: black;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t}\n\t\t\t`,e.appendChild(n);let o=document.createElement("div");o.classList.add(w),e.appendChild(o),t.offsetWidth,o.style.setProperty("opacity",.3),t.offsetWidth}return t}catch(t){}}();t.progressBarEnabled&&function(t){try{if(!t.shadowRoot.querySelector("."+b)){let e=document.createElement("div");e.classList.add(b),t.shadowRoot.appendChild(e);const n=document.createElement("div");n.classList.add(A),e.appendChild(n)}}catch(t){}}(e)}}function W(){const t=document.querySelector(y);t&&t.remove(),U.remove(),X()}function q(t,e,n){n.shadowEnabled&&n.progressBarEnabled&&function(t,e){try{const n=document.querySelector(y);if(n){const o=n.shadowRoot.querySelector("."+b);if(o&&e){const n=Math.floor(t/e*100)+"%";o.style.getPropertyValue("width")!=n&&(o.style.setProperty("width",n),o.offsetWidth)}}}catch(t){}}(t,e)}function F(){let t;const e=[],n=getSelection();for(let o=0;o{"A"==t.tagName&&t.href&&e.push(n.currentNode.href)}))}}return Array.from(new Set(e))}async function H(t){let e=G();return e||t?e:(e=await new Promise((t=>{let e=[];function n(t){e=[],s(),t.preventDefault()}function o(t){const e=function(t){let e,n=t.target,o=n.getBoundingClientRect();for(e=Z("floor",n,t.clientX-o.left,Q(n,"left")),e==n&&(e=Z("ceil",n,o.left+o.width-t.clientX,Q(n,"right"))),e==n&&(e=Z("floor",n,t.clientY-o.top,Q(n,"top"))),e==n&&(e=Z("ceil",n,o.top+o.height-t.clientY,Q(n,"bottom"))),n=e;n&&n.clientWidth<=L&&n.clientHeight<=L;)n=n.parentElement;return n}(t);var n;e&&(B=e,n=e,requestAnimationFrame((()=>{const t=z(),e=n.getBoundingClientRect(),o=document.scrollingElement||document.documentElement;t.style.setProperty("top",o.scrollTop+e.top-10+"px"),t.style.setProperty("left",o.scrollLeft+e.left-10+"px"),t.style.setProperty("width",e.width+20+"px"),t.style.setProperty("height",e.height+20+"px")})))}function r(t){t.preventDefault(),t.stopPropagation(),0==t.button?s(B,t.ctrlKey):i()}function a(t){"Escape"==t.key&&i()}function i(){e.length&&getSelection().removeAllRanges(),e=[],c()}function s(t,e){if(t){e||d();const n=document.createRange();n.selectNodeContents(t),l(),getSelection().addRange(n),p(),e||c()}else c()}function l(){const t=getSelection();for(let e=t.rangeCount-1;e>=0;e--){const n=t.getRangeAt(e);n.startOffset==n.endOffset&&(t.removeRange(n),e--)}}function c(){z().remove(),removeEventListener("mousemove",o,!0),removeEventListener("click",r,!0),removeEventListener("keyup",a,!0),B=null,t(Boolean(e.length)),setTimeout((()=>document.removeEventListener("contextmenu",n,!0)),0)}function d(){getSelection().removeAllRanges(),e.forEach((t=>getSelection().addRange(t)))}function p(){e=[];for(let t=0;tV(t)))}}return e}function V(t){(t.nodeType==Node.ELEMENT_NODE?t:t.parentElement).setAttribute(g,"")}function _(t){t.parentElement&&(V(t),_(t.parentElement))}function z(){let t=document.querySelector(E);return t||(t=J(E,document.body),t.style.setProperty("box-sizing","border-box","important"),t.style.setProperty("background-color","#3ea9d7","important"),t.style.setProperty("border","10px solid #0b4892","important"),t.style.setProperty("border-radius","2px","important"),t.style.setProperty("opacity",".25","important"),t.style.setProperty("pointer-events","none","important"),t.style.setProperty("position","absolute","important"),t.style.setProperty("transition","all 100ms","important"),t.style.setProperty("cursor","pointer","important"),t.style.setProperty("z-index","2147483647","important"),t.style.removeProperty("border-inline-end"),t.style.removeProperty("border-inline-start"),t.style.removeProperty("inline-size"),t.style.removeProperty("block-size"),t.style.removeProperty("inset-block-start"),t.style.removeProperty("inset-inline-end"),t.style.removeProperty("inset-block-end"),t.style.removeProperty("inset-inline-start")),t}function X(){try{if(U=document.querySelector(v),!U){U=J(v);const t=U.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=`\n\t\t\t\t@keyframes single-file-pulse { \n\t\t\t\t\t0% { \n\t\t\t\t\t\topacity: .25;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\topacity: 1;\n\t\t\t\t\t} \n\t\t\t\t}\n\t\t\t\t.${S} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\tbottom: 24px;\n\t\t\t\t\tleft: 8px;\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\topacity: 0.9;\n\t\t\t\t\tpadding: 4px;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t\tmin-width: ${R}px;\n\t\t\t\t\tmin-height: 16px;\n\t\t\t\t\ttransition: height 100ms;\n\t\t\t\t}\n\t\t\t\t.${C} {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tjustify-content: space-between;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: arial, sans-serif;\n\t\t\t\t\tcolor: black;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t}\n\t\t\t\t.${x} {\n\t\t\t\t\tfont-size: 13px;\n\t\t\t\t\topacity: 1;\n\t\t\t\t\ttransition: opacity 200ms;\n\t\t\t\t}\n\t\t\t\t.${I} {\n\t\t\t\t\tfont-size: 11px;\n\t\t\t\t\tmin-width: 15px;\n\t\t\t\t\ttext-align: center;\n\t\t\t\t\tposition: relative;\n\t\t\t\t\ttop: 1px;\n\t\t\t\t}\n\t\t\t`,t.appendChild(e);const n=document.createElement("div");n.classList.add(S),t.appendChild(n)}}catch(t){}}function j(t,e,n,o){try{if(o.logsEnabled){const o=U.shadowRoot.querySelector("."+S);let r=o.querySelector("[data-id='"+t+"']");if(!r){r=document.createElement("div"),r.classList.add(C),o.appendChild(r),r.setAttribute("data-id",t);const n=document.createElement("div");n.classList.add(x),r.appendChild(n),n.textContent=e;const a=document.createElement("div");a.classList.add(I),r.appendChild(a)}!function(t,e,n){const o=t.childNodes[0],r=t.childNodes[1];o.textContent=e,r.style.setProperty("color","✓"==n?"#055000":"black"),"✓"==n?(o.style.setProperty("opacity",".5"),r.style.setProperty("opacity",".5"),r.style.setProperty("animation","none")):r.style.setProperty("animation","1s ease-in-out 0s infinite alternate none running single-file-pulse");r.textContent=n}(r,e,n)}}catch(t){}}function Q(t,e){let n,o=t,r=[];do{const t=o.getBoundingClientRect();if(o.parentElement){const a=o.parentElement.getBoundingClientRect();n=Math.abs(a[e]-t[e])<=L,n&&(o.parentElement.clientWidth>L&&o.parentElement.clientHeight>L&&(o.parentElement.clientWidth-o.clientWidth>L||o.parentElement.clientHeight-o.clientHeight>L)&&r.push(o.parentElement),o=o.parentElement)}else n=!1}while(n&&o);return r}function Z(t,e,n,o){return Math[t](n/L)<=o.length&&(e=o[o.length-Math[t](n/L)-1]),e}function J(t,e){const n=document.createElement(t);return n.className=D,e&&e.appendChild(n),N.forEach((t=>n.style.setProperty(t,"initial","important"))),n}X();const K=globalThis.singlefile,Y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mSlUqHewg4hChOogFURFHqWIRLJS2QqsOJpf+CE0akhQXR8G14ODPYtXBxVlXB1dBEPwBcXNzUnSREr9LCi1ivOO4h/e+9+XuO0Col5lqdowDqmYZqXhMzOZWxMAruhGiOYohiZl6Ir2Qgef4uoeP73dRnuVd9+foVfImA3wi8SzTDYt4nXh609I57xOHWUlSiM+Jxwy6IPEj12WX3zgXHRZ4ZtjIpOaIw8RisY3lNmYlQyWeIo4oqkb5QtZlhfMWZ7VcZc178hcG89pymuu0BhHHIhJIQoSMKjZQhoUo7RopJlJ0HvPwDzj+JLlkcm2AkWMeFaiQHD/4H/zurVmYnHCTgjGg88W2P4aBwC7QqNn297FtN04A/zNwpbX8lTow80l6raVFjoDQNnBx3dLkPeByB+h/0iVDciQ/LaFQAN7P6JtyQN8t0LPq9q15jtMHIEO9WroBDg6BkSJlr3m8u6u9b//WNPv3A6mTcr3f/E/sAAAABmJLR0QAigCKAIrj2uckAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QkPDysvCdPVuwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAELSURBVHja7ZpLFsIwDAPj3v/OsGHDe1BIa8tKO7Mnlkw+dpoxAAAAAGCfx4ur6Yx/B337UUS4mp/VuWUEcjSfOgO+BXCZCWe0hSqQo/npBLglIUNLdAV2MH84Ad1JyIwdLkK6YoabIHWscBWmihHuAqvHtv+XqmdXOK9TxdKy3axUm2vZkXXGgPJksTuz1bVFeeU2Y6ijsLIpXbtKa1kDs2ews69o7+A+ihJ2lvI+/lcS1G21zUVG18XKNm4OS4BNkGOQQohSmGaIdpgLESvzyiRwKepsXjE2H0ZWMF8Zi4+jK5mviM0DiRXNZ2rhkdTK5jO0xermz2o8dCnq+FS2XNNVH0sDAAAA3JYnre9cH8BZmhEAAAAASUVORK5CYII=",$=K.helper.SINGLE_FILE_UI_ELEMENT_CLASS,tt="singlefile-error-bar",et=new Set(Array.from(getComputedStyle(document.documentElement)));let nt;function ot(t,e){try{if(console.error("SingleFile",t,e),nt=document.querySelector(tt),!nt){nt=function(t,e){const n=document.createElement(t);n.className=$,e&&e.appendChild(n);return et.forEach((t=>n.style.setProperty(t,"initial","important"))),n}(tt);const n=nt.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent="\n\t\t\t\t.container {\n\t\t\t\t\tbackground-color: #ff6c00;\n\t\t\t\t\tcolor: white;\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0px;\n\t\t\t\t\tleft: 0px;\n\t\t\t\t\tright: 0px;\n\t\t\t\t\theight: auto;\n\t\t\t\t\twidth: auto;\n\t\t\t\t\tmin-height: 24px;\n\t\t\t\t\tmin-width: 24px;\t\t\t\t\t\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: Arial;\n\t\t\t\t}\n\t\t\t\t.text {\n\t\t\t\t\tflex: 1;\n\t\t\t\t\tpadding-top: 4px;\n\t\t\t\t\tpadding-bottom: 4px;\n\t\t\t\t\tpadding-left: 8px;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.close-button {\n\t\t\t\t\topacity: .7;\n\t\t\t\t\tpadding-top: 4px;\n\t\t\t\t\tpadding-left: 8px;\n\t\t\t\t\tpadding-right: 8px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t\theight: 16px;\n\t\t\t\t}\n\t\t\t\ta {\n\t\t\t\t\tcolor: #303036;\n\t\t\t\t}\n\t\t\t\t.close-button:hover {\n\t\t\t\t\topacity: 1;\n\t\t\t\t}\n\t\t\t",n.appendChild(o);const r=document.createElement("div");r.className="container";const a=document.createElement("span");a.classList.add("text");const i=t.split("__DOC_LINK__");if(a.textContent="SingleFile error: "+i[0],e&&2==i.length){const t=document.createElement("a");t.textContent=e,t.href=e,t.target="_blank",a.appendChild(t),a.appendChild(document.createTextNode(i[1]))}r.appendChild(a);const s=document.createElement("img");s.classList.add("close-button"),r.appendChild(s),n.appendChild(r),s.src=Y,s.onclick=t=>{0===t.button&&nt.remove()},document.body.appendChild(nt)}}catch(t){}}const rt=globalThis.singlefile,at=globalThis.singlefileBootstrap,it="moz-extension:";let st,lt;rt.init({fetch:async function(t,e={}){try{const u={cache:"force-cache",headers:e.headers};return await(e.referrer&&s?async function(t,e){const s=new Promise(((s,p)=>{c(new CustomEvent(n,{detail:JSON.stringify({url:t,options:e})})),l(o,f,!1),l(r,m,!1);const u=setTimeout((()=>{h(),p(new Error(a))}),i);function m(e){e.detail?e.detail.url==t&&(h(),e.detail.response?s({status:e.detail.status,headers:new Map(e.detail.headers),arrayBuffer:async()=>e.detail.response}):p(e.detail.error)):p()}function f(){clearTimeout(u)}function h(){d(r,m,!1),d(o,f,!1)}}));try{return await s}catch(n){if(n&&n.message==a)return p(t,e);throw n}}(t,u):p(t,u))}catch(n){u++;const o=new Promise(((t,e)=>m.set(u,{resolve:t,reject:e})));return await f({method:"singlefile.fetch",url:t,requestId:u,referrer:e.referrer,headers:e.headers}),o}},frameFetch:async function(t,e){const n=await f({method:"singlefile.fetchFrame",url:t,frameId:e.frameId,referrer:e.referrer,headers:e.headers});return{status:n.status,headers:new Map(n.headers),arrayBuffer:async()=>new Uint8Array(n.array).buffer}}}),browser.runtime.onMessage.addListener((t=>{if("content.save"==t.method||"content.cancelSave"==t.method||"content.getSelectedLinks"==t.method||"content.error"==t.method)return async function(t){if(!location.href.startsWith(it)){if("content.save"==t.method)return await async function(t){const n=t.options;let o;(n.selected||n.optionallySelected)&&(o=await H(n.optionallySelected));if(!(lt||at&&at.pageInfo.processing)){if(n.updatedResources=at?at.pageInfo.updatedResources:{},n.visitDate=at?at.pageInfo.visitDate:new Date,Object.keys(n.updatedResources).forEach((t=>n.updatedResources[t].retrieved=!1)),n.optionallySelected&&o&&(n.selected=!0),!n.selected||o){at&&(at.pageInfo.processing=!0),lt=!0;try{const t=await async function(t){const e=rt.processors.frameTree;let n;t.keepFilename=t.saveToGDrive||t.saveToGitHub||t.saveWithWebDAV,rt.helper.initDoc(document),O(t),st=new rt.SingleFile(t);const o=[];t.insertCanonicalLink=!0;let r=0,a=0;t.onprogress=e=>{st.cancelled||(e.type==e.RESOURCES_INITIALIZED&&(a=e.detail.max,t.loadDeferredImages&&rt.processors.lazy.resetZoomLevel(t)),e.type==e.RESOURCES_INITIALIZED||e.type==e.RESOURCE_LOADED?(e.type==e.RESOURCE_LOADED&&r++,browser.runtime.sendMessage({method:"ui.processProgress",index:r,maxIndex:a}),q(r,a,t)):e.detail.frame||e.type==e.PAGE_LOADING||e.type==e.PAGE_LOADED||(e.type==e.STAGE_STARTED?e.detail.step<3&&function(t,e){j("step-"+t,`${k} ${t+1} / 3`,"…",e)}(e.detail.step,t):e.type==e.STAGE_ENDED?e.detail.step<3&&function(t,e){j("step-"+t,`${k} ${t+1} / 3`,"✓",e)}(e.detail.step,t):(e.type==e.STAGE_TASK_STARTED||e.type==e.STAGE_TASK_ENDED)&&(e.detail.step,e.detail.task)))};const i=st.cancel.bind(st);if(!t.saveRawPage){if(!t.removeFrames&&e&&globalThis.frames){let n;n=t.loadDeferredImages?new Promise((n=>globalThis.setTimeout((()=>n(e.getAsync(t))),t.loadDeferredImagesBeforeFrames?0:.75*t.loadDeferredImagesMaxIdleTime))):e.getAsync(t),function(t){j("load-frames",T,"…",t)}(t),n.then((()=>{st.cancelled||function(t){j("load-frames",T,"✓",t)}(t)})),t.loadDeferredImagesBeforeFrames?t.frames=await new Promise((t=>{st.cancel=function(){i(),t([])},n.then(t)})):o.push(n)}if(t.loadDeferredImages){const e=rt.processors.lazy.process(t);!function(t){j("load-deferred-images",P,"…",t)}(t),e.then((()=>{st.cancelled||function(t){j("load-deferred-images",P,"✓",t)}(t)})),t.loadDeferredImagesBeforeFrames?await e:o.push(e)}}t.loadDeferredImagesBeforeFrames||([t.frames]=await new Promise((t=>{const e=Promise.all(o);st.cancel=function(){i(),t([[]])},e.then((()=>t(e)))})));n=t.frames&&t.frames.sessionId;const s=t.frames&&t.frames.find((t=>t.requestedFrame));t.win=globalThis,s?(t.content=s.content,t.url=s.baseURI,t.canvases=s.canvases,t.fonts=s.fonts,t.stylesheets=s.stylesheets,t.images=s.images,t.posters=s.posters,t.videos=s.videos,t.usedFonts=s.usedFonts,t.shadowRoots=s.shadowRoots):t.doc=document;st.cancelled||await st.run();n&&e.cleanup(n);let l;st.cancelled||(t.confirmInfobarContent&&(t.infobarContent=M("Infobar content",t.infobarContent)||""),l=await st.getPageData(),(t.selected||t.optionallySelected)&&document.querySelectorAll("["+g+"]").forEach((t=>t.removeAttribute(g))),W(),t.displayStats&&(console.log("SingleFile stats"),console.table(l.stats)));return l}(n);t&&((!n.backgroundSave&&!n.saveToClipboard||n.saveToGDrive||n.saveToGitHub||n.saveWithCompanion||n.saveWithWebDAV)&&n.confirmFilename&&(t.filename=M("Save as",t.filename)||t.filename),await e(t,n))}catch(t){st.cancelled||(console.error(t),browser.runtime.sendMessage({method:"ui.processError",error:t}))}}else browser.runtime.sendMessage({method:"ui.processCancelled"});lt=!1,at&&(at.pageInfo.processing=!1)}}(t),{};if("content.cancelSave"==t.method)return st&&(st.cancel(),W(),browser.runtime.sendMessage({method:"ui.processCancelled"})),t.options.loadDeferredImages&&rt.processors.lazy.resetZoomLevel(t.options),{};if("content.getSelectedLinks"==t.method)return{urls:F()};"content.error"==t.method&&ot(t.error,t.link)}}(t)}))}(); +!function(){"use strict";const t=33554432;async function e(e,n){if(n.includeBOM&&(e.content="\ufeff"+e.content),n.includeInfobar&&(e.content+=await infobar.getScript()),n.backgroundSave||n.openEditor||n.saveToGDrive||n.saveToGitHub||n.saveWithCompanion||n.saveWithWebDAV)for(let o=0;o*tt,r.truncated?(r.finished=(o+1)*t>e.content.length,r.content=e.content.substring(o*t,(o+1)*t)):r.content=e.content,await browser.runtime.sendMessage(r)}else n.saveToClipboard?function(t){const e="copy";function n(e){e.clipboardData.setData("text/html",t.content),e.clipboardData.setData("text/plain",t.content),e.preventDefault()}document.addEventListener(e,n),document.execCommand(e),document.removeEventListener(e,n)}(e):await async function(t){if(t.filename&&t.filename.length){const e=document.createElement("a");e.download=t.filename,e.href=URL.createObjectURL(new Blob([t.content],{type:"text/html"})),e.dispatchEvent(new MouseEvent("click")),setTimeout((()=>URL.revokeObjectURL(e.href)),1e3)}return new Promise((t=>setTimeout(t,1)))}(e),n.openSavedPage&&open(URL.createObjectURL(new Blob([e.content],{type:"text/html"}))),browser.runtime.sendMessage({method:"ui.processEnd"});await browser.runtime.sendMessage({method:"downloads.end",taskId:n.taskId,hash:e.hash,woleetKey:n.woleetKey})}const n="single-file-request-fetch",o="single-file-ack-fetch",r="single-file-response-fetch",a="Host fetch error (SingleFile)",s=2500,i=Boolean(window.wrappedJSObject),l=(t,e,n)=>window.addEventListener(t,e,n),c=t=>window.dispatchEvent(t),d=(t,e,n)=>window.removeEventListener(t,e,n),m=(t,e)=>window.fetch(t,e);let p=0,u=new Map;async function f(t){const e=await browser.runtime.sendMessage(t);if(!e||e.error)throw new Error(e&&e.error&&e.error.toString());return e}browser.runtime.onMessage.addListener((t=>"singlefile.fetchFrame"==t.method&&window.frameId&&window.frameId==t.frameId?async function(t){try{const e=await m(t.url,{cache:"force-cache",headers:t.headers});return{status:e.status,headers:[...e.headers],array:Array.from(new Uint8Array(await e.arrayBuffer()))}}catch(t){return{error:t&&t.toString()}}}(t):"singlefile.fetchResponse"==t.method?async function(t){const e=u.get(t.requestId);e&&(t.error?(e.reject(new Error(t.error)),u.delete(t.requestId)):(t.truncated&&(e.array?e.array=e.array.concat(t.array):(e.array=t.array,u.set(t.requestId,e)),t.finished&&(t.array=e.array)),t.truncated&&!t.finished||(e.resolve({status:t.status,headers:{get:e=>t.headers&&t.headers[e]},arrayBuffer:async()=>new Uint8Array(t.array).buffer}),u.delete(t.requestId))));return{}}(t):void 0));const h=globalThis.singlefile,g=h.helper.SELECTED_CONTENT_ATTRIBUTE_NAME,y="singlefile-mask",w="singlefile-mask-content",b="singlefile-progress-bar",A="singlefile-progress-bar-content",E="single-file-selection-zone",v="singlefile-logs-window",S="singlefile-logs",C="singlefile-logs-line",x="singlefile-logs-line-text",I="singlefile-logs-line-icon",D=h.helper.SINGLE_FILE_UI_ELEMENT_CLASS,L=8,P=browser.i18n.getMessage("logPanelDeferredImages"),T=browser.i18n.getMessage("logPanelFrameContents"),k=browser.i18n.getMessage("logPanelStep"),R=browser.i18n.getMessage("logPanelWidth"),N=new Set(Array.from(getComputedStyle(document.documentElement)));let B,U;function M(t,e){return prompt(t,e)}function O(t){if(!document.querySelector(y)&&(t.logsEnabled&&document.documentElement.appendChild(U),t.shadowEnabled)){const e=function(){try{let t=document.querySelector(y);if(!t){t=J(y,document.documentElement);const e=t.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=`\n\t\t\t\t@keyframes single-file-progress { \n\t\t\t\t\t0% { \n\t\t\t\t\t\tleft: -50px;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\tleft: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t.${b} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 0;\n\t\t\t\t\theight: 8px;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: .5;\n\t\t\t\t\toverflow: hidden;\t\t\t\t\t\n\t\t\t\t\ttransition: width 200ms ease-in-out;\n\t\t\t\t}\n\t\t\t\t.${A} {\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\tanimation: single-file-progress 3s linear infinite reverse;\n\t\t\t\t\tbackground: \n\t\t\t\t\t\twhite \n\t\t\t\t\t\tlinear-gradient(-45deg, rgba(0, 0, 0, 0.075) 25%, \n\t\t\t\t\t\t\ttransparent 25%, \n\t\t\t\t\t\t\ttransparent 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 75%, \n\t\t\t\t\t\t\ttransparent 75%, transparent)\n\t\t\t\t\t\trepeat scroll 0% 0% / 50px 50px padding-box border-box;\n\t\t\t\t\twidth: calc(100% + 50px);\n\t\t\t\t\theight: 100%;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.${w} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\theight: 100%;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: 0;\n\t\t\t\t\tbackground-color: black;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t}\n\t\t\t`,e.appendChild(n);let o=document.createElement("div");o.classList.add(w),e.appendChild(o),t.offsetWidth,o.style.setProperty("opacity",.3),t.offsetWidth}return t}catch(t){}}();t.progressBarEnabled&&function(t){try{if(!t.shadowRoot.querySelector("."+b)){let e=document.createElement("div");e.classList.add(b),t.shadowRoot.appendChild(e);const n=document.createElement("div");n.classList.add(A),e.appendChild(n)}}catch(t){}}(e)}}function W(){const t=document.querySelector(y);t&&t.remove(),U.remove(),X()}function F(t,e,n){n.shadowEnabled&&n.progressBarEnabled&&function(t,e){try{const n=document.querySelector(y);if(n){const o=n.shadowRoot.querySelector("."+b);if(o&&e){const n=Math.floor(t/e*100)+"%";o.style.getPropertyValue("width")!=n&&(o.style.setProperty("width",n),o.offsetWidth)}}}catch(t){}}(t,e)}function q(){let t;const e=[],n=getSelection();for(let o=0;o{"A"==t.tagName&&t.href&&e.push(n.currentNode.href)}))}}return Array.from(new Set(e))}async function H(t){let e=G();return e||t?e:(e=await new Promise((t=>{let e=[];function n(t){e=[],i(),t.preventDefault()}function o(t){const e=function(t){let e,n=t.target,o=n.getBoundingClientRect();for(e=Z("floor",n,t.clientX-o.left,Q(n,"left")),e==n&&(e=Z("ceil",n,o.left+o.width-t.clientX,Q(n,"right"))),e==n&&(e=Z("floor",n,t.clientY-o.top,Q(n,"top"))),e==n&&(e=Z("ceil",n,o.top+o.height-t.clientY,Q(n,"bottom"))),n=e;n&&n.clientWidth<=L&&n.clientHeight<=L;)n=n.parentElement;return n}(t);var n;e&&(B=e,n=e,requestAnimationFrame((()=>{const t=z(),e=n.getBoundingClientRect(),o=document.scrollingElement||document.documentElement;t.style.setProperty("top",o.scrollTop+e.top-10+"px"),t.style.setProperty("left",o.scrollLeft+e.left-10+"px"),t.style.setProperty("width",e.width+20+"px"),t.style.setProperty("height",e.height+20+"px")})))}function r(t){t.preventDefault(),t.stopPropagation(),0==t.button?i(B,t.ctrlKey):s()}function a(t){"Escape"==t.key&&s()}function s(){e.length&&getSelection().removeAllRanges(),e=[],c()}function i(t,e){if(t){e||d();const n=document.createRange();n.selectNodeContents(t),l(),getSelection().addRange(n),m(),e||c()}else c()}function l(){const t=getSelection();for(let e=t.rangeCount-1;e>=0;e--){const n=t.getRangeAt(e);n.startOffset==n.endOffset&&(t.removeRange(n),e--)}}function c(){z().remove(),removeEventListener("mousemove",o,!0),removeEventListener("click",r,!0),removeEventListener("keyup",a,!0),B=null,t(Boolean(e.length)),setTimeout((()=>document.removeEventListener("contextmenu",n,!0)),0)}function d(){getSelection().removeAllRanges(),e.forEach((t=>getSelection().addRange(t)))}function m(){e=[];for(let t=0;tV(t)))}}return e}function V(t){(t.nodeType==Node.ELEMENT_NODE?t:t.parentElement).setAttribute(g,"")}function _(t){t.parentElement&&(V(t),_(t.parentElement))}function z(){let t=document.querySelector(E);return t||(t=J(E,document.body),t.style.setProperty("box-sizing","border-box","important"),t.style.setProperty("background-color","#3ea9d7","important"),t.style.setProperty("border","10px solid #0b4892","important"),t.style.setProperty("border-radius","2px","important"),t.style.setProperty("opacity",".25","important"),t.style.setProperty("pointer-events","none","important"),t.style.setProperty("position","absolute","important"),t.style.setProperty("transition","all 100ms","important"),t.style.setProperty("cursor","pointer","important"),t.style.setProperty("z-index","2147483647","important"),t.style.removeProperty("border-inline-end"),t.style.removeProperty("border-inline-start"),t.style.removeProperty("inline-size"),t.style.removeProperty("block-size"),t.style.removeProperty("inset-block-start"),t.style.removeProperty("inset-inline-end"),t.style.removeProperty("inset-block-end"),t.style.removeProperty("inset-inline-start")),t}function X(){try{if(U=document.querySelector(v),!U){U=J(v);const t=U.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=`\n\t\t\t\t@keyframes single-file-pulse { \n\t\t\t\t\t0% { \n\t\t\t\t\t\topacity: .25;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\topacity: 1;\n\t\t\t\t\t} \n\t\t\t\t}\n\t\t\t\t.${S} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\tbottom: 24px;\n\t\t\t\t\tleft: 8px;\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\topacity: 0.9;\n\t\t\t\t\tpadding: 4px;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t\tmin-width: ${R}px;\n\t\t\t\t\tmin-height: 16px;\n\t\t\t\t\ttransition: height 100ms;\n\t\t\t\t}\n\t\t\t\t.${C} {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tjustify-content: space-between;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: arial, sans-serif;\n\t\t\t\t\tcolor: black;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t}\n\t\t\t\t.${x} {\n\t\t\t\t\tfont-size: 13px;\n\t\t\t\t\topacity: 1;\n\t\t\t\t\ttransition: opacity 200ms;\n\t\t\t\t}\n\t\t\t\t.${I} {\n\t\t\t\t\tfont-size: 11px;\n\t\t\t\t\tmin-width: 15px;\n\t\t\t\t\ttext-align: center;\n\t\t\t\t\tposition: relative;\n\t\t\t\t\ttop: 1px;\n\t\t\t\t}\n\t\t\t`,t.appendChild(e);const n=document.createElement("div");n.classList.add(S),t.appendChild(n)}}catch(t){}}function j(t,e,n,o){try{if(o.logsEnabled){const o=U.shadowRoot.querySelector("."+S);let r=o.querySelector("[data-id='"+t+"']");if(!r){r=document.createElement("div"),r.classList.add(C),o.appendChild(r),r.setAttribute("data-id",t);const n=document.createElement("div");n.classList.add(x),r.appendChild(n),n.textContent=e;const a=document.createElement("div");a.classList.add(I),r.appendChild(a)}!function(t,e,n){const o=t.childNodes[0],r=t.childNodes[1];o.textContent=e,r.style.setProperty("color","✓"==n?"#055000":"black"),"✓"==n?(o.style.setProperty("opacity",".5"),r.style.setProperty("opacity",".5"),r.style.setProperty("animation","none")):r.style.setProperty("animation","1s ease-in-out 0s infinite alternate none running single-file-pulse");r.textContent=n}(r,e,n)}}catch(t){}}function Q(t,e){let n,o=t,r=[];do{const t=o.getBoundingClientRect();if(o.parentElement){const a=o.parentElement.getBoundingClientRect();n=Math.abs(a[e]-t[e])<=L,n&&(o.parentElement.clientWidth>L&&o.parentElement.clientHeight>L&&(o.parentElement.clientWidth-o.clientWidth>L||o.parentElement.clientHeight-o.clientHeight>L)&&r.push(o.parentElement),o=o.parentElement)}else n=!1}while(n&&o);return r}function Z(t,e,n,o){return Math[t](n/L)<=o.length&&(e=o[o.length-Math[t](n/L)-1]),e}function J(t,e){const n=document.createElement(t);return n.className=D,e&&e.appendChild(n),N.forEach((t=>n.style.setProperty(t,"initial","important"))),n}X();const K=globalThis.singlefile,Y="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mSlUqHewg4hChOogFURFHqWIRLJS2QqsOJpf+CE0akhQXR8G14ODPYtXBxVlXB1dBEPwBcXNzUnSREr9LCi1ivOO4h/e+9+XuO0Col5lqdowDqmYZqXhMzOZWxMAruhGiOYohiZl6Ir2Qgef4uoeP73dRnuVd9+foVfImA3wi8SzTDYt4nXh609I57xOHWUlSiM+Jxwy6IPEj12WX3zgXHRZ4ZtjIpOaIw8RisY3lNmYlQyWeIo4oqkb5QtZlhfMWZ7VcZc178hcG89pymuu0BhHHIhJIQoSMKjZQhoUo7RopJlJ0HvPwDzj+JLlkcm2AkWMeFaiQHD/4H/zurVmYnHCTgjGg88W2P4aBwC7QqNn297FtN04A/zNwpbX8lTow80l6raVFjoDQNnBx3dLkPeByB+h/0iVDciQ/LaFQAN7P6JtyQN8t0LPq9q15jtMHIEO9WroBDg6BkSJlr3m8u6u9b//WNPv3A6mTcr3f/E/sAAAABmJLR0QAigCKAIrj2uckAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QkPDysvCdPVuwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAELSURBVHja7ZpLFsIwDAPj3v/OsGHDe1BIa8tKO7Mnlkw+dpoxAAAAAGCfx4ur6Yx/B337UUS4mp/VuWUEcjSfOgO+BXCZCWe0hSqQo/npBLglIUNLdAV2MH84Ad1JyIwdLkK6YoabIHWscBWmihHuAqvHtv+XqmdXOK9TxdKy3axUm2vZkXXGgPJksTuz1bVFeeU2Y6ijsLIpXbtKa1kDs2ews69o7+A+ihJ2lvI+/lcS1G21zUVG18XKNm4OS4BNkGOQQohSmGaIdpgLESvzyiRwKepsXjE2H0ZWMF8Zi4+jK5mviM0DiRXNZ2rhkdTK5jO0xermz2o8dCnq+FS2XNNVH0sDAAAA3JYnre9cH8BZmhEAAAAASUVORK5CYII=",$=K.helper.SINGLE_FILE_UI_ELEMENT_CLASS,tt="singlefile-error-bar",et=new Set(Array.from(getComputedStyle(document.documentElement)));let nt;function ot(t,e){try{if(console.error("SingleFile",t,e),nt=document.querySelector(tt),!nt){nt=function(t,e){const n=document.createElement(t);n.className=$,e&&e.appendChild(n);return et.forEach((t=>n.style.setProperty(t,"initial","important"))),n}(tt);const n=nt.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent="\n\t\t\t\t.container {\n\t\t\t\t\tbackground-color: #ff6c00;\n\t\t\t\t\tcolor: white;\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0px;\n\t\t\t\t\tleft: 0px;\n\t\t\t\t\tright: 0px;\n\t\t\t\t\theight: auto;\n\t\t\t\t\twidth: auto;\n\t\t\t\t\tmin-height: 24px;\n\t\t\t\t\tmin-width: 24px;\t\t\t\t\t\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: Arial;\n\t\t\t\t}\n\t\t\t\t.text {\n\t\t\t\t\tflex: 1;\n\t\t\t\t\tpadding-top: 4px;\n\t\t\t\t\tpadding-bottom: 4px;\n\t\t\t\t\tpadding-left: 8px;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.close-button {\n\t\t\t\t\topacity: .7;\n\t\t\t\t\tpadding-top: 4px;\n\t\t\t\t\tpadding-left: 8px;\n\t\t\t\t\tpadding-right: 8px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t\theight: 16px;\n\t\t\t\t}\n\t\t\t\ta {\n\t\t\t\t\tcolor: #303036;\n\t\t\t\t}\n\t\t\t\t.close-button:hover {\n\t\t\t\t\topacity: 1;\n\t\t\t\t}\n\t\t\t",n.appendChild(o);const r=document.createElement("div");r.className="container";const a=document.createElement("span");a.classList.add("text");const s=t.split("__DOC_LINK__");if(a.textContent="SingleFile error: "+s[0],e&&2==s.length){const t=document.createElement("a");t.textContent=e,t.href=e,t.target="_blank",a.appendChild(t),a.appendChild(document.createTextNode(s[1]))}r.appendChild(a);const i=document.createElement("img");i.classList.add("close-button"),r.appendChild(i),n.appendChild(r),i.src=Y,i.onclick=t=>{0===t.button&&nt.remove()},document.body.appendChild(nt)}}catch(t){}}const rt=globalThis.singlefile,at=globalThis.singlefileBootstrap,st="moz-extension:";let it,lt;rt.init({fetch:async function(t,e={}){try{const p={cache:"force-cache",headers:e.headers};return await(e.referrer&&i?async function(t,e){const i=new Promise(((i,m)=>{c(new CustomEvent(n,{detail:JSON.stringify({url:t,options:e})})),l(o,f,!1),l(r,u,!1);const p=setTimeout((()=>{h(),m(new Error(a))}),s);function u(e){e.detail?e.detail.url==t&&(h(),e.detail.response?i({status:e.detail.status,headers:new Map(e.detail.headers),arrayBuffer:async()=>e.detail.response}):m(e.detail.error)):m()}function f(){clearTimeout(p)}function h(){d(r,u,!1),d(o,f,!1)}}));try{return await i}catch(n){if(n&&n.message==a)return m(t,e);throw n}}(t,p):m(t,p))}catch(n){p++;const o=new Promise(((t,e)=>u.set(p,{resolve:t,reject:e})));return await f({method:"singlefile.fetch",url:t,requestId:p,referrer:e.referrer,headers:e.headers}),o}},frameFetch:async function(t,e){const n=await f({method:"singlefile.fetchFrame",url:t,frameId:e.frameId,referrer:e.referrer,headers:e.headers});return{status:n.status,headers:new Map(n.headers),arrayBuffer:async()=>new Uint8Array(n.array).buffer}}}),browser.runtime.onMessage.addListener((t=>{if("content.save"==t.method||"content.cancelSave"==t.method||"content.getSelectedLinks"==t.method||"content.error"==t.method)return async function(t){if(!location.href.startsWith(st)){if("content.save"==t.method)return await async function(t){const n=t.options;let o;(n.selected||n.optionallySelected)&&(o=await H(n.optionallySelected));if(!(lt||at&&at.pageInfo.processing)){if(n.updatedResources=at?at.pageInfo.updatedResources:{},n.visitDate=at?at.pageInfo.visitDate:new Date,Object.keys(n.updatedResources).forEach((t=>n.updatedResources[t].retrieved=!1)),n.optionallySelected&&o&&(n.selected=!0),!n.selected||o){at&&(at.pageInfo.processing=!0),lt=!0;try{const t=await async function(t){const e=rt.processors.frameTree;let n;t.keepFilename=t.saveToGDrive||t.saveToGitHub||t.saveWithWebDAV,rt.helper.initDoc(document),O(t),it=new rt.SingleFile(t);const o=[];t.insertCanonicalLink=!0;let r=0,a=0;t.onprogress=e=>{it.cancelled||(e.type==e.RESOURCES_INITIALIZED&&(a=e.detail.max,t.loadDeferredImages&&rt.processors.lazy.resetZoomLevel(t)),e.type==e.RESOURCES_INITIALIZED||e.type==e.RESOURCE_LOADED?(e.type==e.RESOURCE_LOADED&&r++,browser.runtime.sendMessage({method:"ui.processProgress",index:r,maxIndex:a}),F(r,a,t)):e.detail.frame||e.type==e.PAGE_LOADING||e.type==e.PAGE_LOADED||(e.type==e.STAGE_STARTED?e.detail.step<3&&function(t,e){j("step-"+t,`${k} ${t+1} / 3`,"…",e)}(e.detail.step,t):e.type==e.STAGE_ENDED?e.detail.step<3&&function(t,e){j("step-"+t,`${k} ${t+1} / 3`,"✓",e)}(e.detail.step,t):(e.type==e.STAGE_TASK_STARTED||e.type==e.STAGE_TASK_ENDED)&&(e.detail.step,e.detail.task)))};const s=it.cancel.bind(it);if(!t.saveRawPage){let n;if(t.loadDeferredImages&&(n=rt.processors.lazy.process(t),function(t){j("load-deferred-images",P,"…",t)}(t),n.then((()=>{it.cancelled||function(t){j("load-deferred-images",P,"✓",t)}(t)})),t.loadDeferredImagesBeforeFrames&&await n),!t.removeFrames&&e&&globalThis.frames){let n;n=t.loadDeferredImages?new Promise((n=>globalThis.setTimeout((()=>n(e.getAsync(t))),t.loadDeferredImagesBeforeFrames?0:t.loadDeferredImagesMaxIdleTime))):e.getAsync(t),function(t){j("load-frames",T,"…",t)}(t),n.then((()=>{it.cancelled||function(t){j("load-frames",T,"✓",t)}(t)})),t.loadDeferredImagesBeforeFrames?t.frames=await new Promise((t=>{it.cancel=function(){s(),t([])},n.then(t)})):o.push(n)}t.loadDeferredImages&&!t.loadDeferredImagesBeforeFrames&&o.push(n)}t.loadDeferredImagesBeforeFrames||([t.frames]=await new Promise((t=>{const e=Promise.all(o);it.cancel=function(){s(),t([[]])},e.then((()=>t(e)))})));n=t.frames&&t.frames.sessionId;const i=t.frames&&t.frames.find((t=>t.requestedFrame));t.win=globalThis,i?(t.content=i.content,t.url=i.baseURI,t.canvases=i.canvases,t.fonts=i.fonts,t.stylesheets=i.stylesheets,t.images=i.images,t.posters=i.posters,t.videos=i.videos,t.usedFonts=i.usedFonts,t.shadowRoots=i.shadowRoots):t.doc=document;it.cancelled||await it.run();n&&e.cleanup(n);let l;it.cancelled||(t.confirmInfobarContent&&(t.infobarContent=M("Infobar content",t.infobarContent)||""),l=await it.getPageData(),(t.selected||t.optionallySelected)&&document.querySelectorAll("["+g+"]").forEach((t=>t.removeAttribute(g))),W(),t.displayStats&&(console.log("SingleFile stats"),console.table(l.stats)));return l}(n);t&&((!n.backgroundSave&&!n.saveToClipboard||n.saveToGDrive||n.saveToGitHub||n.saveWithCompanion||n.saveWithWebDAV)&&n.confirmFilename&&(t.filename=M("Save as",t.filename)||t.filename),await e(t,n))}catch(t){it.cancelled||(console.error(t),browser.runtime.sendMessage({method:"ui.processError",error:t}))}}else browser.runtime.sendMessage({method:"ui.processCancelled"});lt=!1,at&&(at.pageInfo.processing=!1)}}(t),{};if("content.cancelSave"==t.method)return it&&(it.cancel(),W(),browser.runtime.sendMessage({method:"ui.processCancelled"})),t.options.loadDeferredImages&&rt.processors.lazy.resetZoomLevel(t.options),{};if("content.getSelectedLinks"==t.method)return{urls:q()};"content.error"==t.method&&ot(t.error,t.link)}}(t)}))}(); diff --git a/lib/single-file.js b/lib/single-file.js index e4edf9cbb..2e9980d4a 100644 --- a/lib/single-file.js +++ b/lib/single-file.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefile={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",n="single-file-load-deferred-images-end",r="single-file-load-deferred-images-keep-zoom-level-start",a="single-file-load-deferred-images-keep-zoom-level-end",o="single-file-load-deferred-images-keep-zoom-level-reset",i="single-file-load-deferred-images-reset",s="single-file-block-cookies-start",l="single-file-block-cookies-end",c="single-file-dispatch-scroll-event-start",u="single-file-dispatch-scroll-event-end",h="single-file-block-storage-start",d="single-file-block-storage-end",p="single-file-load-image",m="single-file-image-loaded",g=(e,t,n)=>globalThis.addEventListener(e,t,n),f=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},b=globalThis.CustomEvent,y=globalThis.document,w=globalThis.Document,k=globalThis.JSON;let v;function x(){return Array.from(v.values())}function A(e){e.loadDeferredImagesBlockCookies&&f(new b(s)),e.loadDeferredImagesBlockStorage&&f(new b(h)),e.loadDeferredImagesDispatchScrollEvent&&f(new b(c)),e.loadDeferredImagesKeepZoomLevel?f(new b(r)):f(new b(t))}function E(e){e.loadDeferredImagesBlockCookies&&f(new b(l)),e.loadDeferredImagesBlockStorage&&f(new b(d)),e.loadDeferredImagesDispatchScrollEvent&&f(new b(u)),e.loadDeferredImagesKeepZoomLevel?f(new b(a)):f(new b(n))}function S(e){e.loadDeferredImagesKeepZoomLevel?f(new b(o)):f(new b(i))}v=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,y instanceof w&&(g("single-file-new-font-face",(e=>{const t=e.detail,n=Object.assign({},t);delete n.src,v.set(k.stringify(n),t)})),g("single-file-delete-font",(e=>{const t=e.detail,n=Object.assign({},t);delete n.src,v.delete(k.stringify(n))})),g("single-file-clear-fonts",(()=>v=new Map)));var T=Object.freeze({__proto__:null,getFontsData:x,loadDeferredImagesStart:A,loadDeferredImagesEnd:E,loadDeferredImagesResetZoomLevel:S,LOAD_IMAGE_EVENT:p,IMAGE_LOADED_EVENT:m});const C="[\\x20\\t\\r\\n\\f]",R=new RegExp("\\\\([\\da-f]{1,6}"+C+"?|("+C+")|.)","ig");function _(e){return e.replace(R,((e,t,n)=>{const r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)}))}var I=Object.freeze({__proto__:null,process:_});const L="single-file-on-before-capture",z="single-file-on-after-capture",N="data-single-file-removed-content",P="data-single-file-hidden-content",M="data-single-file-kept-content",O="data-single-file-hidden-frame",U="data-single-file-preserved-space-element",D="data-single-file-shadow-root-element",q="data-single-file-win-id",F="data-single-file-image",j="data-single-file-poster",B="data-single-file-video",H="data-single-file-canvas",V="data-single-file-movable-style",W="data-single-file-input-value",$="data-single-file-lazy-loaded-src",G="data-single-file-stylesheet",Y="data-single-file-disabled-noscript",K="data-single-file-selected-content",Q="data-single-file-invalid-element",J="data-single-file-async-script",Z="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",X=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],ee=/^'(.*?)'$/,te=/^"(.*?)"$/,ne={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},re="Page saved with SingleFile",ae="Archive processed by SingleFile",oe="single-file-ui-element",ie="data:,",se=(e,t,n)=>globalThis.addEventListener(e,t,n),le=globalThis.JSON;function ce(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}function ue(e,t,n){e.querySelectorAll("noscript:not(["+Y+"])").forEach((e=>{e.setAttribute(Y,e.textContent),e.textContent=""})),ce(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 r=new Map;let a;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const n=e.createElement("template");n.setAttribute(Q,""),n.content.appendChild(t.cloneNode(!0)),r.set(t,n),t.replaceWith(n)})),a=he(t,e,e.documentElement,n),n.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const n=Ae(t,e);n&&ge(e,n)&&(e.setAttribute(V,""),a.markedElements.push(e))}))):a={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:a.canvases,fonts:x(),stylesheets:be(e),images:a.images,posters:a.posters,videos:a.videos,usedFonts:Array.from(a.usedFonts.values()),shadowRoots:a.shadowRoots,referrer:e.referrer,markedElements:a.markedElements,invalidElements:r}}function he(e,t,n,r,a={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},o){if(n.childNodes){Array.from(n.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((n=>{let i,s,l;if(!r.autoSaveExternalSave&&(r.removeHiddenElements||r.removeUnusedFonts||r.compressHTML)&&(l=Ae(e,n),n instanceof e.HTMLElement&&r.removeHiddenElements&&(s=(o||n.closest("html > head"))&&X.includes(n.tagName.toUpperCase())||n.closest("details"),s||(i=o||ge(n,l),i&&(n.setAttribute(P,""),a.markedElements.push(n)))),!i)){if(r.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(n.setAttribute(U,""),a.markedElements.push(n))}r.removeUnusedFonts&&(de(l,r,a.usedFonts),de(Ae(e,n,":first-letter"),r,a.usedFonts),de(Ae(e,n,":before"),r,a.usedFonts),de(Ae(e,n,":after"),r,a.usedFonts))}!function(e,t,n,r,a,o,i){const s=n.tagName&&n.tagName.toUpperCase();if("CANVAS"==s)try{a.canvases.push({dataURI:n.toDataURL("image/png","")}),n.setAttribute(H,a.canvases.length-1),a.markedElements.push(n)}catch(e){}if("IMG"==s){const t={currentSrc:o?ie:r.loadDeferredImages&&n.getAttribute($)||n.currentSrc};if(a.images.push(t),n.setAttribute(F,a.images.length-1),a.markedElements.push(n),n.removeAttribute($),i=i||Ae(e,n)){t.size=function(e,t,n){let r=t.naturalWidth,a=t.naturalHeight;if(!r&&!a){const o=null==t.getAttribute("style");if(n=n||Ae(e,t)){let e,i,s,l,c,u,h,d,p=!1;if("content-box"==n.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),n=t.style.getPropertyPriority("box-sizing"),r=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),p=t.clientWidth!=r,e?t.style.setProperty("box-sizing",e,n):t.style.removeProperty("box-sizing")}e=ye("padding-left",n),i=ye("padding-right",n),s=ye("padding-top",n),l=ye("padding-bottom",n),p?(c=ye("border-left-width",n),u=ye("border-right-width",n),h=ye("border-top-width",n),d=ye("border-bottom-width",n)):c=u=h=d=0,r=Math.max(0,t.clientWidth-e-i-c-u),a=Math.max(0,t.clientHeight-s-l-h-d),o&&t.removeAttribute("style")}}return{pxWidth:r,pxHeight:a}}(e,n,i);const r=i.getPropertyValue("box-shadow"),a=i.getPropertyValue("background-image");r&&"none"!=r||a&&"none"!=a||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=i.getPropertyValue("background-color"),t.objectFit=i.getPropertyValue("object-fit"),t.boxSizing=i.getPropertyValue("box-sizing"),t.objectPosition=i.getPropertyValue("object-position"))}}if("VIDEO"==s){const r=n.currentSrc;if(r&&!r.startsWith("blob:")&&!r.startsWith("data:")){const t=Ae(e,n.parentNode);a.videos.push({positionParent:t&&t.getPropertyValue("position"),src:r,size:{pxWidth:n.clientWidth,pxHeight:n.clientHeight},currentTime:n.currentTime}),n.setAttribute(B,a.videos.length-1)}if(!n.getAttribute("poster")){const e=t.createElement("canvas"),r=e.getContext("2d");e.width=n.clientWidth,e.height=n.clientHeight;try{r.drawImage(n,0,0,e.width,e.height),a.posters.push(e.toDataURL("image/png","")),n.setAttribute(j,a.posters.length-1),a.markedElements.push(n)}catch(e){}}}"IFRAME"==s&&o&&r.removeHiddenElements&&(n.setAttribute(O,""),a.markedElements.push(n));"INPUT"==s&&("password"!=n.type&&(n.setAttribute(W,n.value),a.markedElements.push(n)),"radio"!=n.type&&"checkbox"!=n.type||(n.setAttribute(W,n.checked),a.markedElements.push(n)));"TEXTAREA"==s&&(n.setAttribute(W,n.value),a.markedElements.push(n));"SELECT"==s&&n.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(W,""),a.markedElements.push(e))}));"SCRIPT"==s&&(n.async&&""!=n.getAttribute("async")&&"async"!=n.getAttribute("async")&&(n.setAttribute(J,""),a.markedElements.push(n)),n.textContent=n.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,n,r,a,i,l);const c=!(n instanceof e.SVGElement)&&pe(n);if(c&&!n.classList.contains(oe)){const o={};n.setAttribute(D,a.shadowRoots.length),a.markedElements.push(n),a.shadowRoots.push(o),he(e,t,c,r,a,i),o.content=c.innerHTML,o.mode=c.mode;try{c.adoptedStyleSheets&&c.adoptedStyleSheets.length&&(o.adoptedStyleSheets=Array.from(c.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}he(e,t,n,r,a,i),!r.autoSaveExternalSave&&r.removeHiddenElements&&o&&(s||""==n.getAttribute(M)?n.parentElement&&(n.parentElement.setAttribute(M,""),a.markedElements.push(n.parentElement)):i&&(n.setAttribute(N,""),a.markedElements.push(n)))}))}return a}function de(e,t,n){if(e){const r=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((a=>{if(a=me(a),!t.loadedFonts||t.loadedFonts.find((e=>me(e.family)==a&&e.style==r))){const t=ve(e.getPropertyValue("font-weight")),o=e.getPropertyValue("font-variant")||"normal",i=[a,t,r,o];n.set(le.stringify(i),[a,t,r,o])}}))}}function pe(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 me(e=""){return ke(_(e.trim())).toLowerCase()}function ge(e,t){let n=!1;if(t){const r=t.getPropertyValue("display"),a=t.getPropertyValue("opacity"),o=t.getPropertyValue("visibility");if(n="none"==r,!n&&("0"==a||"hidden"==o)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();n=!t.width&&!t.height}}return Boolean(n)}function fe(e,t,n){if(e.querySelectorAll("["+Y+"]").forEach((e=>{e.textContent=e.getAttribute(Y),e.removeAttribute(Y)})),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 n=[N,O,P,U,F,j,B,H,W,D,G,J];t=e.querySelectorAll(n.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(N),e.removeAttribute(P),e.removeAttribute(M),e.removeAttribute(O),e.removeAttribute(U),e.removeAttribute(F),e.removeAttribute(j),e.removeAttribute(B),e.removeAttribute(H),e.removeAttribute(W),e.removeAttribute(D),e.removeAttribute(G),e.removeAttribute(J),e.removeAttribute(V)})),n&&n.forEach(((e,t)=>e.replaceWith(t)))}function be(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((n,r)=>{try{const a=e.createElement("style");a.textContent=n.textContent,e.body.appendChild(a);const o=a.sheet;a.remove(),o&&o.cssRules.length==n.sheet.cssRules.length||(n.setAttribute(G,r),t[r]=Array.from(n.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function ye(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function we(e){const t=e.doctype;let n="";return t&&(n=" "),n+e.documentElement.outerHTML}function ke(e){return(e=e.match(ee)?e.replace(ee,"$1"):e.replace(te,"$1")).trim()}function ve(e){return ne[e.toLowerCase().trim()]||e}function xe(e){return e.flat?e.flat():e.reduce(((e,t)=>e.concat(Array.isArray(t)?xe(t):t)),[])}function Ae(e,t,n){try{return e.getComputedStyle(t,n)}catch(e){}}var Ee=Object.freeze({__proto__:null,initUserScriptHandler:function(){se("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),n=new Promise((t=>se(e+"-response",t)));(e=>{try{globalThis.dispatchEvent(e)}catch(e){}})(t),t.defaultPrevented&&await n}))},initDoc:ce,preProcessDoc:ue,postProcessDoc:fe,serialize:we,removeQuotes:ke,flatten:xe,getFontWeight:ve,normalizeFontFamily:me,getShadowRoot:pe,ON_BEFORE_CAPTURE_EVENT_NAME:L,ON_AFTER_CAPTURE_EVENT_NAME:z,WIN_ID_ATTRIBUTE_NAME:q,PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME:U,REMOVED_CONTENT_ATTRIBUTE_NAME:N,HIDDEN_CONTENT_ATTRIBUTE_NAME:P,HIDDEN_FRAME_ATTRIBUTE_NAME:O,IMAGE_ATTRIBUTE_NAME:F,POSTER_ATTRIBUTE_NAME:j,VIDEO_ATTRIBUTE_NAME:B,CANVAS_ATTRIBUTE_NAME:H,INPUT_VALUE_ATTRIBUTE_NAME:W,SHADOW_ROOT_ATTRIBUTE_NAME:D,STYLE_ATTRIBUTE_NAME:V,LAZY_SRC_ATTRIBUTE_NAME:$,STYLESHEET_ATTRIBUTE_NAME:G,SELECTED_CONTENT_ATTRIBUTE_NAME:K,INVALID_ELEMENT_ATTRIBUTE_NAME:Q,ASYNC_SCRIPT_ATTRIBUTE_NAME:J,COMMENT_HEADER:re,COMMENT_HEADER_LEGACY:ae,SINGLE_FILE_UI_ELEMENT_CLASS:oe,EMPTY_RESOURCE:ie});const Se={LAZY_SRC_ATTRIBUTE_NAME:$,SINGLE_FILE_UI_ELEMENT_CLASS:oe},Te=10,Ce="attributes",Re=globalThis.browser,_e=globalThis.document,Ie=globalThis.MutationObserver,Le=(e,t,n)=>globalThis.addEventListener(e,t,n),ze=(e,t,n)=>globalThis.removeEventListener(e,t,n),Ne=new Map;let Pe;async function Me(e){if(_e.documentElement){Ne.clear();const t=_e.body&&_e.body.scrollHeight||_e.documentElement.scrollHeight,n=_e.body&&_e.body.scrollWidth||_e.documentElement.scrollWidth;if(t>globalThis.innerHeight||n>globalThis.innerWidth){const r=Math.max(t-1.5*globalThis.innerHeight,0),a=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY{let n;const r=new Set,a=new Ie((async t=>{if((t=t.filter((e=>e.type==Ce))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(Se.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",i)),"src"==e.attributeName||"srcset"==e.attributeName||e.target.tagName&&"SOURCE"==e.target.tagName.toUpperCase())return!e.target.classList||!e.target.classList.contains(Se.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await De(a,e,c),r.size||await Ue(a,e,c))}}));async function o(t){await Fe("idleTimeout",(async()=>{n?Peqe(e,t,n)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function De(e,t,n){await Fe("maxTimeout",(async()=>{await Be("loadTimeout"),await qe(e,t,n)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function qe(e,t,n){await Be("idleTimeout"),E(t),await Fe("endTimeout",(async()=>{await Be("maxTimeout"),n()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function Fe(e,t,n,r){if(Re&&Re.runtime&&Re.runtime.sendMessage&&!r){if(!Ne.get(e)||!Ne.get(e).pending){const r={callback:t,pending:!0};Ne.set(e,r);try{await Re.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:n})}catch(r){je(e,t,n)}r.pending=!1}}else je(e,t,n)}function je(e,t,n){const r=Ne.get(e);r&&globalThis.clearTimeout(r),Ne.set(e,t),globalThis.setTimeout(t,n)}async function Be(e){if(Re&&Re.runtime&&Re.runtime.sendMessage)try{await Re.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){He(e)}else He(e)}function He(e){const t=Ne.get(e);Ne.delete(e),t&&globalThis.clearTimeout(t)}Re&&Re.runtime&&Re.runtime.onMessage&&Re.runtime.onMessage.addListener&&Re.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Ne.get(e.type);if(t){Ne.delete(e.type);try{t.callback()}catch(t){He(e.type)}}}}));var Ve=Object.freeze({__proto__:null,process:Me,resetZoomLevel:Oe});const We={ON_BEFORE_CAPTURE_EVENT_NAME:L,ON_AFTER_CAPTURE_EVENT_NAME:z,WIN_ID_ATTRIBUTE_NAME:q,preProcessDoc:ue,serialize:we,postProcessDoc:fe,getShadowRoot:pe},$e="__frameTree__::",Ge='iframe, frame, object[type="text/html"][data]',Ye="*",Ke="singlefile.frameTree.initRequest",Qe="singlefile.frameTree.ackInitRequest",Je="singlefile.frameTree.cleanupRequest",Ze="singlefile.frameTree.initResponse",Xe="*",et=5e3,tt=".",nt=globalThis.window==globalThis.top,rt=globalThis.browser,at=globalThis.top,ot=globalThis.MessageChannel,it=globalThis.document,st=globalThis.JSON;let lt,ct=globalThis.sessions;var ut,ht,dt;function pt(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function mt(e){const t=e.sessionId,n=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,nt||(lt=globalThis.frameId=e.windowId),bt(it,e.options,lt,t),nt||(e.options.userScriptEnabled&&n&&await n(We.ON_BEFORE_CAPTURE_EVENT_NAME),vt({frames:[At(it,globalThis,lt,e.options)],sessionId:t,requestedFrameId:it.documentElement.dataset.requestedFrameId&<}),e.options.userScriptEnabled&&n&&await n(We.ON_AFTER_CAPTURE_EVENT_NAME),delete it.documentElement.dataset.requestedFrameId)}function gt(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;kt(Et(it),e.windowId,t)}}function ft(e){e.frames.forEach((t=>yt("responseTimeouts",e.sessionId,t.windowId)));const t=ct.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let n=t.frames.find((t=>e.windowId==t.windowId));n||(n={windowId:e.windowId},t.frames.push(n)),n.processed||(n.content=e.content,n.baseURI=e.baseURI,n.title=e.title,n.url=e.url,n.canvases=e.canvases,n.fonts=e.fonts,n.stylesheets=e.stylesheets,n.images=e.images,n.posters=e.posters,n.videos=e.videos,n.usedFonts=e.usedFonts,n.shadowRoots=e.shadowRoots,n.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(tt).length-e.windowId.split(tt).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function bt(e,t,n,r){const a=Et(e);!function(e,t,n,r,a){const o=[];let i;ct.get(a)?i=ct.get(a).requestTimeouts:(i={},ct.set(a,{requestTimeouts:i}));t.forEach(((e,t)=>{const n=r+tt+t;e.setAttribute(We.WIN_ID_ATTRIBUTE_NAME,n),o.push({windowId:n})})),vt({frames:o,sessionId:a,requestedFrameId:e.documentElement.dataset.requestedFrameId&&r}),t.forEach(((e,t)=>{const o=r+tt+t;try{xt(e.contentWindow,{method:Ke,windowId:o,sessionId:a,options:n})}catch(e){}i[o]=globalThis.setTimeout((()=>vt({frames:[{windowId:o,processed:!0}],sessionId:a})),et)})),delete e.documentElement.dataset.requestedFrameId}(e,a,t,n,r),a.length&&function(e,t,n,r,a){const o=[];t.forEach(((e,t)=>{const i=r+tt+t;let s;try{s=e.contentDocument}catch(e){}if(s)try{const t=e.contentWindow;t.stop(),yt("requestTimeouts",a,i),bt(s,n,i,a),o.push(At(s,t,i,n))}catch(e){o.push({windowId:i,processed:!0})}})),vt({frames:o,sessionId:a,requestedFrameId:e.documentElement.dataset.requestedFrameId&&r}),delete e.documentElement.dataset.requestedFrameId}(e,a,t,n,r)}function yt(e,t,n){const r=ct.get(t);if(r&&r[e]){const t=r[e][n];t&&(globalThis.clearTimeout(t),delete r[e][n])}}function wt(e,t){const n=ct.get(e);n&&n.responseTimeouts&&(n.responseTimeouts[t]=globalThis.setTimeout((()=>vt({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function kt(e,t,n){e.forEach(((e,r)=>{const a=t+tt+r;e.removeAttribute(We.WIN_ID_ATTRIBUTE_NAME);try{xt(e.contentWindow,{method:Je,windowId:a,sessionId:n})}catch(e){}})),e.forEach(((e,r)=>{const a=t+tt+r;let o;try{o=e.contentDocument}catch(e){}if(o)try{kt(Et(o),a,n)}catch(e){}}))}function vt(e){e.method=Ze;try{at.singlefile.processors.frameTree.initResponse(e)}catch(t){xt(at,e,!0)}}function xt(e,t,n){if(e==at&&rt&&rt.runtime&&rt.runtime.sendMessage)rt.runtime.sendMessage(t);else if(n){const n=new ot;e.postMessage($e+st.stringify({method:t.method,sessionId:t.sessionId}),Xe,[n.port2]),n.port1.postMessage(t)}else e.postMessage($e+st.stringify(t),Xe)}function At(e,t,n,r){const a=We.preProcessDoc(e,t,r),o=We.serialize(e);We.postProcessDoc(e,a.markedElements,a.invalidElements);return{windowId:n,content:o,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,processed:!0}}function Et(e){let t=Array.from(e.querySelectorAll(Ge));return e.querySelectorAll(Ye).forEach((e=>{const n=We.getShadowRoot(e);n&&(t=t.concat(...n.querySelectorAll(Ge)))})),t}ct||(ct=globalThis.sessions=new Map),nt&&(lt="0",rt&&rt.runtime&&rt.runtime.onMessage&&rt.runtime.onMessage.addListener&&rt.runtime.onMessage.addListener((e=>e.method==Ze?(ft(e),Promise.resolve({})):e.method==Qe?(yt("requestTimeouts",e.sessionId,e.windowId),wt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),ut="message",ht=async e=>{if("string"==typeof e.data&&e.data.startsWith($e)){e.preventDefault(),e.stopPropagation();const t=st.parse(e.data.substring($e.length));t.method==Ke?(e.source&&xt(e.source,{method:Qe,windowId:t.windowId,sessionId:t.sessionId}),nt||(globalThis.stop(),t.options.loadDeferredImages&&Me(t.options),await mt(t))):t.method==Qe?(yt("requestTimeouts",t.sessionId,t.windowId),wt(t.sessionId,t.windowId)):t.method==Je?gt(t):t.method==Ze&&ct.get(t.sessionId)&&(e.ports[0].onmessage=e=>ft(e.data))}},dt=!0,globalThis.addEventListener(ut,ht,dt);var St=Object.freeze({__proto__:null,getAsync:function(e){const t=pt();return e=st.parse(st.stringify(e)),new Promise((n=>{ct.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,n(e)}}),mt({windowId:lt,sessionId:t,options:e})}))},getSync:function(e){const t=pt();e=st.parse(st.stringify(e)),ct.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,n=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,nt||(lt=globalThis.frameId=e.windowId);bt(it,e.options,lt,t),nt||(e.options.userScriptEnabled&&n&&n(We.ON_BEFORE_CAPTURE_EVENT_NAME),vt({frames:[At(it,globalThis,lt,e.options)],sessionId:t,requestedFrameId:it.documentElement.dataset.requestedFrameId&<}),e.options.userScriptEnabled&&n&&n(We.ON_AFTER_CAPTURE_EVENT_NAME),delete it.documentElement.dataset.requestedFrameId)}({windowId:lt,sessionId:t,options:e});const n=ct.get(t).frames;return n.sessionId=t,n},cleanup:function(e){ct.delete(e),gt({windowId:lt,sessionId:e,options:{sessionId:e}})},initResponse:ft,TIMEOUT_INIT_REQUEST_MESSAGE:et}),Tt=Object.freeze({__proto__:null,frameTree:St,hooksFrames:T,lazy:Ve}),Ct=Object.create,Rt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,It=Object.getOwnPropertyNames,Lt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,Nt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Pt=(e,t)=>{for(var n in t)Rt(e,n,{get:t[n],enumerable:!0})},Mt=Nt((e=>{var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");e.encode=function(e){if(0<=e&&e{var t=Mt();e.encode=function(e){var n,r,a="",o=(r=e)<0?1+(-r<<1):0+(r<<1);do{n=31&o,(o>>>=5)>0&&(n|=32),a+=t.encode(n)}while(o>0);return a},e.decode=function(e,n,r){var a,o,i=e.length,s=0,l=0;do{if(n>=i)throw new Error("Expected more digits in base 64 VLQ value.");if(-1===(o=t.decode(e.charCodeAt(n++))))throw new Error("Invalid base64 digit: "+e.charAt(n-1));a=!!(32&o),s+=(o&=31)<>1;return 1==(1&e)?-t:t}(s),r.rest=n}})),Ut=Nt((e=>{e.getArg=function(e,t,n){if(t in e)return e[t];if(3===arguments.length)return n;throw new Error('"'+t+'" is a required argument.')};var t=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,n=/^data:.+\,.+$/;function r(e){var n=e.match(t);return n?{scheme:n[1],auth:n[2],host:n[3],port:n[4],path:n[5]}:null}function a(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}e.urlParse=r,e.urlGenerate=a;var o,i,s=(o=function(t){var n=t,o=r(t);if(o){if(!o.path)return t;n=o.path}for(var i=e.isAbsolute(n),s=[],l=0,c=0;;){if(l=c,-1===(c=n.indexOf("/",l))){s.push(n.slice(l));break}for(s.push(n.slice(l,c));c=0;c--)"."===(u=s[c])?s.splice(c,1):".."===u?h++:h>0&&(""===u?(s.splice(c+1,h),h=0):(s.splice(c,2),h--));return""===(n=s.join("/"))&&(n=i?"/":"."),o?(o.path=n,a(o)):n},i=[],function(e){for(var t=0;t32&&i.pop(),r});function l(e,t){""===e&&(e="."),""===t&&(t=".");var o=r(t),i=r(e);if(i&&(e=i.path||"/"),o&&!o.scheme)return i&&(o.scheme=i.scheme),a(o);if(o||t.match(n))return t;if(i&&!i.host&&!i.path)return i.host=t,a(i);var l="/"===t.charAt(0)?t:s(e.replace(/\/+$/,"")+"/"+t);return i?(i.path=l,a(i)):l}e.normalize=s,e.join=l,e.isAbsolute=function(e){return"/"===e.charAt(0)||t.test(e)},e.relative=function(e,t){""===e&&(e="."),e=e.replace(/\/$/,"");for(var n=0;0!==t.indexOf(e+"/");){var r=e.lastIndexOf("/");if(r<0||(e=e.slice(0,r)).match(/^([^\/]+:\/)?\/*$/))return t;++n}return Array(n+1).join("../")+t.substr(e.length+1)};var c=!("__proto__"in Object.create(null));function u(e){return e}function h(e){if(!e)return!1;var t=e.length;if(t<9||95!==e.charCodeAt(t-1)||95!==e.charCodeAt(t-2)||111!==e.charCodeAt(t-3)||116!==e.charCodeAt(t-4)||111!==e.charCodeAt(t-5)||114!==e.charCodeAt(t-6)||112!==e.charCodeAt(t-7)||95!==e.charCodeAt(t-8)||95!==e.charCodeAt(t-9))return!1;for(var n=t-10;n>=0;n--)if(36!==e.charCodeAt(n))return!1;return!0}function d(e,t){return e===t?0:null===e?1:null===t?-1:e>t?1:-1}e.toSetString=c?u:function(e){return h(e)?"$"+e:e},e.fromSetString=c?u:function(e){return h(e)?e.slice(1):e},e.compareByOriginalPositions=function(e,t,n){var r=d(e.source,t.source);return 0!==r||0!==(r=e.originalLine-t.originalLine)||(0!==(r=e.originalColumn-t.originalColumn)||n)||0!==(r=e.generatedColumn-t.generatedColumn)||0!==(r=e.generatedLine-t.generatedLine)?r:d(e.name,t.name)},e.compareByOriginalPositionsNoSource=function(e,t,n){var r;return 0!==(r=e.originalLine-t.originalLine)||(0!==(r=e.originalColumn-t.originalColumn)||n)||0!==(r=e.generatedColumn-t.generatedColumn)||0!==(r=e.generatedLine-t.generatedLine)?r:d(e.name,t.name)},e.compareByGeneratedPositionsDeflated=function(e,t,n){var r=e.generatedLine-t.generatedLine;return 0!==r||(0!==(r=e.generatedColumn-t.generatedColumn)||n)||0!==(r=d(e.source,t.source))||0!==(r=e.originalLine-t.originalLine)||0!==(r=e.originalColumn-t.originalColumn)?r:d(e.name,t.name)},e.compareByGeneratedPositionsDeflatedNoLine=function(e,t,n){var r=e.generatedColumn-t.generatedColumn;return 0!==r||n||0!==(r=d(e.source,t.source))||0!==(r=e.originalLine-t.originalLine)||0!==(r=e.originalColumn-t.originalColumn)?r:d(e.name,t.name)},e.compareByGeneratedPositionsInflated=function(e,t){var n=e.generatedLine-t.generatedLine;return 0!==n||0!==(n=e.generatedColumn-t.generatedColumn)||0!==(n=d(e.source,t.source))||0!==(n=e.originalLine-t.originalLine)||0!==(n=e.originalColumn-t.originalColumn)?n:d(e.name,t.name)},e.parseSourceMapInput=function(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))},e.computeSourceURL=function(e,t,n){if(t=t||"",e&&("/"!==e[e.length-1]&&"/"!==t[0]&&(e+="/"),t=e+t),n){var o=r(n);if(!o)throw new Error("sourceMapURL could not be parsed");if(o.path){var i=o.path.lastIndexOf("/");i>=0&&(o.path=o.path.substring(0,i+1))}t=l(a(o),t)}return s(t)}})),Dt=Nt((e=>{var t=Ut(),n=Object.prototype.hasOwnProperty,r=typeof Map<"u";function a(){this._array=[],this._set=r?new Map:Object.create(null)}a.fromArray=function(e,t){for(var n=new a,r=0,o=e.length;r=0)return a}else{var o=t.toSetString(e);if(n.call(this._set,o))return this._set[o]}throw new Error('"'+e+'" is not in the set.')},a.prototype.at=function(e){if(e>=0&&e{var t=Ut();function n(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}n.prototype.unsortedForEach=function(e,t){this._array.forEach(e,t)},n.prototype.add=function(e){!function(e,n){var r=e.generatedLine,a=n.generatedLine,o=e.generatedColumn,i=n.generatedColumn;return a>r||a==r&&i>=o||t.compareByGeneratedPositionsInflated(e,n)<=0}(this._last,e)?(this._sorted=!1,this._array.push(e)):(this._last=e,this._array.push(e))},n.prototype.toArray=function(){return this._sorted||(this._array.sort(t.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},e.MappingList=n})),Ft=Nt((e=>{var t=Ot(),n=Ut(),r=Dt().ArraySet,a=qt().MappingList;function o(e){e||(e={}),this._file=n.getArg(e,"file",null),this._sourceRoot=n.getArg(e,"sourceRoot",null),this._skipValidation=n.getArg(e,"skipValidation",!1),this._sources=new r,this._names=new r,this._mappings=new a,this._sourcesContents=null}o.prototype._version=3,o.fromSourceMap=function(e){var t=e.sourceRoot,r=new o({file:e.file,sourceRoot:t});return e.eachMapping((function(e){var a={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(a.source=e.source,null!=t&&(a.source=n.relative(t,a.source)),a.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(a.name=e.name)),r.addMapping(a)})),e.sources.forEach((function(a){var o=a;null!==t&&(o=n.relative(t,a)),r._sources.has(o)||r._sources.add(o);var i=e.sourceContentFor(a);null!=i&&r.setSourceContent(a,i)})),r},o.prototype.addMapping=function(e){var t=n.getArg(e,"generated"),r=n.getArg(e,"original",null),a=n.getArg(e,"source",null),o=n.getArg(e,"name",null);this._skipValidation||this._validateMapping(t,r,a,o),null!=a&&(a=String(a),this._sources.has(a)||this._sources.add(a)),null!=o&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:t.line,generatedColumn:t.column,originalLine:null!=r&&r.line,originalColumn:null!=r&&r.column,source:a,name:o})},o.prototype.setSourceContent=function(e,t){var r=e;null!=this._sourceRoot&&(r=n.relative(this._sourceRoot,r)),null!=t?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[n.toSetString(r)]=t):this._sourcesContents&&(delete this._sourcesContents[n.toSetString(r)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},o.prototype.applySourceMap=function(e,t,a){var o=t;if(null==t){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');o=e.file}var i=this._sourceRoot;null!=i&&(o=n.relative(i,o));var s=new r,l=new r;this._mappings.unsortedForEach((function(t){if(t.source===o&&null!=t.originalLine){var r=e.originalPositionFor({line:t.originalLine,column:t.originalColumn});null!=r.source&&(t.source=r.source,null!=a&&(t.source=n.join(a,t.source)),null!=i&&(t.source=n.relative(i,t.source)),t.originalLine=r.line,t.originalColumn=r.column,null!=r.name&&(t.name=r.name))}var c=t.source;null!=c&&!s.has(c)&&s.add(c);var u=t.name;null!=u&&!l.has(u)&&l.add(u)}),this),this._sources=s,this._names=l,e.sources.forEach((function(t){var r=e.sourceContentFor(t);null!=r&&(null!=a&&(t=n.join(a,t)),null!=i&&(t=n.relative(i,t)),this.setSourceContent(t,r))}),this)},o.prototype._validateMapping=function(e,t,n,r){if(t&&"number"!=typeof t.line&&"number"!=typeof t.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||t||n||r){if(e&&"line"in e&&"column"in e&&t&&"line"in t&&"column"in t&&e.line>0&&e.column>=0&&t.line>0&&t.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:n,original:t,name:r}))}},o.prototype._serializeMappings=function(){for(var e,r,a,o,i=0,s=1,l=0,c=0,u=0,h=0,d="",p=this._mappings.toArray(),m=0,g=p.length;m0){if(!n.compareByGeneratedPositionsInflated(r,p[m-1]))continue;e+=","}e+=t.encode(r.generatedColumn-i),i=r.generatedColumn,null!=r.source&&(o=this._sources.indexOf(r.source),e+=t.encode(o-h),h=o,e+=t.encode(r.originalLine-1-c),c=r.originalLine-1,e+=t.encode(r.originalColumn-l),l=r.originalColumn,null!=r.name&&(a=this._names.indexOf(r.name),e+=t.encode(a-u),u=a)),d+=e}return d},o.prototype._generateSourcesContent=function(e,t){return e.map((function(e){if(!this._sourcesContents)return null;null!=t&&(e=n.relative(t,e));var r=n.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,r)?this._sourcesContents[r]:null}),this)},o.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},o.prototype.toString=function(){return JSON.stringify(this.toJSON())},e.SourceMapGenerator=o})),jt={};Pt(jt,{AtKeyword:()=>Wt,BadString:()=>Yt,BadUrl:()=>Qt,CDC:()=>rn,CDO:()=>nn,Colon:()=>an,Comma:()=>sn,Comment:()=>mn,Delim:()=>Jt,Dimension:()=>en,EOF:()=>Bt,Function:()=>Vt,Hash:()=>$t,Ident:()=>Ht,LeftCurlyBracket:()=>dn,LeftParenthesis:()=>un,LeftSquareBracket:()=>ln,Number:()=>Zt,Percentage:()=>Xt,RightCurlyBracket:()=>pn,RightParenthesis:()=>hn,RightSquareBracket:()=>cn,Semicolon:()=>on,String:()=>Gt,Url:()=>Kt,WhiteSpace:()=>tn});var Bt=0,Ht=1,Vt=2,Wt=3,$t=4,Gt=5,Yt=6,Kt=7,Qt=8,Jt=9,Zt=10,Xt=11,en=12,tn=13,nn=14,rn=15,an=16,on=17,sn=18,ln=19,cn=20,un=21,hn=22,dn=23,pn=24,mn=25;function gn(e){return e>=48&&e<=57}function fn(e){return gn(e)||e>=65&&e<=70||e>=97&&e<=102}function bn(e){return e>=65&&e<=90}function yn(e){return function(e){return bn(e)||function(e){return e>=97&&e<=122}(e)}(e)||function(e){return e>=128}(e)||95===e}function wn(e){return yn(e)||gn(e)||45===e}function kn(e){return e>=0&&e<=8||11===e||e>=14&&e<=31||127===e}function vn(e){return 10===e||13===e||12===e}function xn(e){return vn(e)||32===e||9===e}function An(e,t){return!(92!==e||vn(t)||0===t)}function En(e,t,n){return 45===e?yn(t)||45===t||An(t,n):!!yn(e)||92===e&&An(e,t)}function Sn(e,t,n){return 43===e||45===e?gn(t)?2:46===t&&gn(n)?3:0:46===e?gn(t)?2:0:gn(e)?1:0}function Tn(e){return 65279===e||65534===e?1:0}var Cn=new Array(128),Rn=130,_n=131,In=132,Ln=133;for(let e=0;ee.length)return!1;for(let a=t;a=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var Vn=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"];function Wn(e=null,t){return null===e||e.length0?Tn(t.charCodeAt(0)):0,a=Wn(e.lines,n),o=Wn(e.columns,n),i=e.startLine,s=e.startColumn;for(let e=r;e{})){let n=(e=String(e||"")).length,r=Wn(this.offsetAndType,e.length+1),a=Wn(this.balance,e.length+1),o=0,i=0,s=0,l=-1;for(this.offsetAndType=null,this.balance=null,t(e,((e,t,c)=>{switch(e){default:a[o]=n;break;case i:{let e=s&Yn;for(s=a[e],i=s>>Kn,a[o]=e,a[e++]=o;e>Kn:0}lookupOffset(e){return(e+=this.tokenIndex)0?e>Kn,this.tokenEnd=t&Yn):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e>Kn,this.tokenEnd=e&Yn):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;13===this.tokenType||25===this.tokenType;)this.next()}skipUntilBalanced(e,t){let n,r,a=e;e:for(;a0?this.offsetAndType[a-1]&Yn:this.firstCharOffset,t(this.source.charCodeAt(r))){case 1:break e;case 2:a++;break e;default:this.balance[n]===a&&(a=n)}this.skip(a-this.tokenIndex)}forEachToken(e){for(let t=0,n=this.firstCharOffset;t>Kn,r,o,t)}}dump(){let e=new Array(this.tokenCount);return this.forEachToken(((t,n,r,a)=>{e[a]={idx:a,type:Vn[t],chunk:this.source.substring(n,r),balance:this.balance[a]}})),e}};function Zn(e,t){function n(t){return t=e.length?void(cString(e+n+1).padStart(l)+" |"+t)).join("\n")}let o=e.split(/\r\n?|\n|\f/),i=Math.max(1,t-r)-1,s=Math.min(t+r,o.length+1),l=Math.max(4,String(s).length)+1,c=0;(n+=(ar.length-1)*(o[t-1].substr(0,n-1).match(/\t/g)||[]).length)>nr&&(c=n-rr+3,n=rr-2);for(let e=i;e<=s;e++)e>=0&&e0&&o[e].length>c?"…":"")+o[e].substr(c,nr-2)+(o[e].length>c+nr-1?"…":""));return[a(i,t),new Array(n+l+2).join("-")+"^",a(t,s)].filter(Boolean).join("\n")}function ir(e,t,n,r,a){return Object.assign(tr("SyntaxError",e),{source:t,offset:n,line:r,column:a,sourceFragment:e=>or({source:t,line:r,column:a},isNaN(e)?0:e),get formattedMessage(){return`Parse error: ${e}\n`+or({source:t,line:r,column:a},2)}})}function sr(e){let t=this.createList(),n=!1,r={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:n=!0,this.next();continue}let a=e.getNode.call(this,r);if(void 0===a)break;n&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,a,t,r),n=!1),t.push(a)}return n&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,r),t}var lr=()=>{},cr=33,ur=35,hr=59,dr=123,pr=0;function mr(e){return function(){return this[e]()}}function gr(e){let t=Object.create(null);for(let n in e){let r=e[n],a=r.parse||r;a&&(t[n]=a)}return t}function fr(e){let t="",n="",r=!1,a=lr,o=!1,i=new Gn,s=Object.assign(new Jn,function(e){let t={context:Object.create(null),scope:Object.assign(Object.create(null),e.scope),atrule:gr(e.atrule),pseudo:gr(e.pseudo),node:gr(e.node)};for(let n in e.parseContext)switch(typeof e.parseContext[n]){case"function":t.context[n]=e.parseContext[n];break;case"string":t.context[n]=mr(e.parseContext[n])}return{config:t,...t,...t.node}}(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:sr,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket:e=>e===dr?1:0,consumeUntilLeftCurlyBracketOrSemicolon:e=>e===dr||e===hr?1:0,consumeUntilExclamationMarkOrSemicolon:e=>e===cr||e===hr?1:0,consumeUntilSemicolonIncluded:e=>e===hr?2:0,createList:()=>new er,createSingleNodeList:e=>(new er).appendData(e),getFirstListNode:e=>e&&e.first,getLastListNode:e=>e&&e.last,parseWithFallback(e,t){let n=this.tokenIndex;try{return e.call(this)}catch(e){if(o)throw e;let r=t.call(this,n);return o=!0,a(e,r),o=!1,r}},lookupNonWSType(e){let t;do{if(t=this.lookupType(e++),13!==t)return t}while(t!==pr);return pr},charCodeAt:e=>e>=0&&et.substring(e,n),substrToCursor(e){return this.source.substring(e,this.tokenStart)},cmpChar:(e,n)=>Mn(t,e,n),cmpStr:(e,n,r)=>On(t,e,n,r),consume(e){let t=this.tokenStart;return this.eat(e),this.substrToCursor(t)},consumeFunctionName(){let e=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),e},consumeNumber(e){let n=t.substring(this.tokenStart,jn(t,this.tokenStart));return this.eat(e),n},eat(e){if(this.tokenType!==e){let t=Vn[e].slice(0,-6).replace(/-/g," ").replace(/^./,(e=>e.toUpperCase())),n=`${/[[\](){}]/.test(t)?`"${t}"`:t} is expected`,r=this.tokenStart;switch(e){case 1:2===this.tokenType||7===this.tokenType?(r=this.tokenEnd-1,n="Identifier is expected but function found"):n="Identifier is expected";break;case 4:this.isDelim(ur)&&(this.next(),r++,n="Name is expected");break;case 11:10===this.tokenType&&(r=this.tokenEnd,n="Percent sign is expected")}this.error(n,r)}this.next()},eatIdent(e){(1!==this.tokenType||!1===this.lookupValue(0,e))&&this.error(`Identifier "${e}" is expected`),this.next()},eatDelim(e){this.isDelim(e)||this.error(`Delim "${String.fromCharCode(e)}" is expected`),this.next()},getLocation:(e,t)=>r?i.getLocationRange(e,t,n):null,getLocationFromList(e){if(r){let t=this.getFirstListNode(e),r=this.getLastListNode(e);return i.getLocationRange(null!==t?t.loc.start.offset-i.startOffset:this.tokenStart,null!==r?r.loc.end.offset-i.startOffset:this.tokenStart,n)}return null},error(e,n){let r=typeof n<"u"&&n=0&&xn(e.charCodeAt(t));t--);return t+1}(t,t.length-1)):i.getLocation(this.tokenStart);throw new ir(e||"Unexpected input",t,r.offset,r.line,r.column)}});return Object.assign((function(e,l){t=e,l=l||{},s.setSource(t,Zn),i.setSource(t,l.offset,l.line,l.column),n=l.filename||"",r=Boolean(l.positions),a="function"==typeof l.onParseError?l.onParseError:lr,o=!1,s.parseAtrulePrelude=!("parseAtrulePrelude"in l)||Boolean(l.parseAtrulePrelude),s.parseRulePrelude=!("parseRulePrelude"in l)||Boolean(l.parseRulePrelude),s.parseValue=!("parseValue"in l)||Boolean(l.parseValue),s.parseCustomProperty="parseCustomProperty"in l&&Boolean(l.parseCustomProperty);let{context:c="default",onComment:u}=l;if(!(c in s.context))throw new Error("Unknown context `"+c+"`");"function"==typeof u&&s.forEachToken(((e,n,r)=>{if(25===e){let e=s.getLocation(n,r),a=On(t,r-2,r,"*/")?t.slice(n+2,r-2):t.slice(n+2,r);u(a,e)}}));let h=s.context[c].call(s,l);return s.eof||s.error(),h}),{SyntaxError:ir,config:s.config})}var br,yr,wr,kr=(br=Ft(),yr=1,wr=null!=br?Ct(Lt(br)):{},((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of It(t))!zt.call(e,a)&&a!==n&&Rt(e,a,{get:()=>t[a],enumerable:!(r=_t(t,a))||r.enumerable});return e})(!yr&&br&&br.__esModule?wr:Rt(wr,"default",{value:br,enumerable:!0}),br)),vr=new Set(["Atrule","Selector","Declaration"]);var xr={};Pt(xr,{safe:()=>Rr,spec:()=>Cr});var Ar=(e,t)=>{if(9===e&&(e=t),"string"==typeof e){let t=e.charCodeAt(0);return t>127?32768:t<<8}return e},Er=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],Sr=Er.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function Tr(e){let t=new Set(e.map((([e,t])=>Ar(e)<<16|Ar(t))));return function(e,n,r){let a=Ar(n,r),o=r.charCodeAt(0);return(45===o&&1!==n&&2!==n&&15!==n||43===o?t.has(e<<16|o<<8):t.has(e<<16|a))&&this.emit(" ",13,!0),a}}var Cr=Tr(Er),Rr=Tr(Sr),_r=92;function Ir(e,t){if("function"!=typeof t)e.children.forEach(this.node,this);else{let n=null;e.children.forEach((e=>{null!==n&&t.call(this,n),this.node(e),n=e}))}}function Lr(e){Zn(e,((t,n,r)=>{this.token(t,e.slice(n,r))}))}function zr(e){let t=new Map;for(let n in e.node){let r=e.node[n];"function"==typeof(r.generate||r)&&t.set(n,r.generate||r)}return function(e,n){let r="",a=0,o={node(e){if(!t.has(e.type))throw new Error("Unknown node type: "+e.type);t.get(e.type).call(i,e)},tokenBefore:Rr,token(e,t){a=this.tokenBefore(a,e,t),this.emit(t,e,!1),9===e&&t.charCodeAt(0)===_r&&this.emit("\n",13,!0)},emit(e){r+=e},result:()=>r};n&&("function"==typeof n.decorator&&(o=n.decorator(o)),n.sourceMap&&(o=function(e){let t=new kr.SourceMapGenerator,n={line:1,column:0},r={line:0,column:0},a={line:1,column:0},o={generated:a},i=1,s=0,l=!1,c=e.node;e.node=function(e){if(e.loc&&e.loc.start&&vr.has(e.type)){let c=e.loc.start.line,u=e.loc.start.column-1;(r.line!==c||r.column!==u)&&(r.line=c,r.column=u,n.line=i,n.column=s,l&&(l=!1,(n.line!==a.line||n.column!==a.column)&&t.addMapping(o)),l=!0,t.addMapping({source:e.loc.source,original:r,generated:n}))}c.call(this,e),l&&vr.has(e.type)&&(a.line=i,a.column=s)};let u=e.emit;e.emit=function(e,t,n){for(let t=0;to.node(e),children:Ir,token:(e,t)=>o.token(e,t),tokenize:Lr};return o.node(e),o.result()}}var{hasOwnProperty:Nr}=Object.prototype,Pr=function(){};function Mr(e){return"function"==typeof e?e:Pr}function Or(e,t){return function(n,r,a){n.type===t&&e.call(this,n,r,a)}}function Ur(e,t){let n=t.structure,r=[];for(let e in n){if(!1===Nr.call(n,e))continue;let t=n[e],a={name:e,type:!1,nullable:!1};Array.isArray(t)||(t=[t]);for(let e of t)null===e?a.nullable=!0:"string"==typeof e?a.type="node":Array.isArray(e)&&(a.type="list");a.type&&r.push(a)}return r.length?{context:t.walkContext,fields:r}:null}function Dr(e,t){let n=e.fields.slice(),r=e.context,a="string"==typeof r;return t&&n.reverse(),function(e,o,i,s){let l;a&&(l=o[r],o[r]=e);for(let r of n){let n=e[r.name];if(!r.nullable||n)if("list"===r.type){if(t?n.reduceRight(s,!1):n.reduce(s,!1))return!0}else if(i(n))return!0}a&&(o[r]=l)}}function qr({StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:a}){return{Atrule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Rule:{StyleSheet:e,Atrule:t,Rule:n,Block:r},Declaration:{StyleSheet:e,Atrule:t,Rule:n,Block:r,DeclarationList:a}}}function Fr(e){let t=function(e){let t={};for(let n in e.node)if(Nr.call(e.node,n)){let r=e.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");t[n]=Ur(0,r)}return t}(e),n={},r={},a=Symbol("break-walk"),o=Symbol("skip-node");for(let e in t)Nr.call(t,e)&&null!==t[e]&&(n[e]=Dr(t[e],!1),r[e]=Dr(t[e],!0));let i=qr(n),s=qr(r),l=function(e,l){function c(e,t,n){let r=u.call(m,e,t,n);return r===a||r!==o&&!!(d.hasOwnProperty(e.type)&&d[e.type](e,m,c,p)||h.call(m,e,t,n)===a)}let u=Pr,h=Pr,d=n,p=(e,t,n,r)=>e||c(t,n,r),m={break:a,skip:o,root:e,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if("function"==typeof l)u=l;else if(l&&(u=Mr(l.enter),h=Mr(l.leave),l.reverse&&(d=r),l.visit)){if(i.hasOwnProperty(l.visit))d=l.reverse?s[l.visit]:i[l.visit];else if(!t.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(t).sort().join(", ")+")");u=Or(u,l.visit),h=Or(h,l.visit)}if(u===Pr&&h===Pr)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");c(e)};return l.break=a,l.skip=o,l.find=function(e,t){let n=null;return l(e,(function(e,r,o){if(t.call(this,e,r,o))return n=e,a})),n},l.findLast=function(e,t){let n=null;return l(e,{reverse:!0,enter(e,r,o){if(t.call(this,e,r,o))return n=e,a}}),n},l.findAll=function(e,t){let n=[];return l(e,(function(e,r,a){t.call(this,e,r,a)&&n.push(e)})),n},l}function jr(e){return e}function Br(e,t,n,r){let a;switch(e.type){case"Group":a=function(e,t,n,r){let a=" "===e.combinator||r?e.combinator:" "+e.combinator+" ",o=e.terms.map((e=>Br(e,t,n,r))).join(a);return e.explicit||n?(r||","===o[0]?"[":"[ ")+o+(r?"]":" ]"):o}(e,t,n,r)+(e.disallowEmpty?"!":"");break;case"Multiplier":return Br(e.term,t,n,r)+t(function(e){let{min:t,max:n,comma:r}=e;return 0===t&&0===n?r?"#?":"*":0===t&&1===n?"?":1===t&&0===n?r?"#":"+":1===t&&1===n?"":(r?"#":"")+(t===n?"{"+t+"}":"{"+t+","+(0!==n?n:"")+"}")}(e),e);case"Type":a="<"+e.name+(e.opts?t(function(e){if("Range"===e.type)return" ["+(null===e.min?"-∞":e.min)+","+(null===e.max?"∞":e.max)+"]";throw new Error("Unknown node type `"+e.type+"`")}(e.opts),e.opts):"")+">";break;case"Property":a="<'"+e.name+"'>";break;case"Keyword":a=e.name;break;case"AtKeyword":a="@"+e.name;break;case"Function":a=e.name+"(";break;case"String":case"Token":a=e.value;break;case"Comma":a=",";break;default:throw new Error("Unknown node type `"+e.type+"`")}return t(a,e)}function Hr(e,t){let n=jr,r=!1,a=!1;return"function"==typeof t?n=t:t&&(r=Boolean(t.forceBraces),a=Boolean(t.compact),"function"==typeof t.decorate&&(n=t.decorate)),Br(e,n,r,a)}var Vr={offset:0,line:1,column:1};function Wr(e,t){let n=e&&e.loc&&e.loc[t];return n?"line"in n?$r(n):n:null}function $r({offset:e,line:t,column:n},r){let a={offset:e,line:t,column:n};if(r){let e=r.split(/\n|\r\n?|\f/);a.offset+=r.length,a.line+=e.length-1,a.column=1===e.length?a.column+r.length:e.pop().length+1}return a}var Gr=function(e,t){let n=tr("SyntaxReferenceError",e+(t?" `"+t+"`":""));return n.reference=t,n},Yr=function(e,t,n,r){let a=tr("SyntaxMatchError",e),{css:o,mismatchOffset:i,mismatchLength:s,start:l,end:c}=function(e,t){let n,r,a=e.tokens,o=e.longestMatch,i=o1?(n=Wr(s||t,"end")||$r(Vr,h),r=$r(n)):(n=Wr(s,"start")||$r(Wr(t,"start")||Vr,h.slice(0,l)),r=Wr(s,"end")||$r(n,h.substr(l,c))),{css:h,mismatchOffset:l,mismatchLength:c,start:n,end:r}}(r,n);return a.rawMessage=e,a.syntax=t?Hr(t):"",a.css=o,a.mismatchOffset=i,a.mismatchLength=s,a.message=e+"\n syntax: "+a.syntax+"\n value: "+(o||"")+"\n --------"+new Array(a.mismatchOffset+1).join("-")+"^",Object.assign(a,l),a.loc={source:n&&n.loc&&n.loc.source||"",start:l,end:c},a},Kr=new Map,Qr=new Map,Jr=45,Zr=function(e){if(Kr.has(e))return Kr.get(e);let t=e.toLowerCase(),n=Kr.get(t);if(void 0===n){let e=ta(t,0),r=e?"":na(t,0);n=Object.freeze({basename:t.substr(r.length),name:t,prefix:r,vendor:r,custom:e})}return Kr.set(e,n),n},Xr=function(e){if(Qr.has(e))return Qr.get(e);let t=e,n=e[0];"/"===n?n="/"===e[1]?"//":"/":"_"!==n&&"*"!==n&&"$"!==n&&"#"!==n&&"+"!==n&&"&"!==n&&(n="");let r=ta(t,n.length);if(!r&&(t=t.toLowerCase(),Qr.has(t))){let n=Qr.get(t);return Qr.set(e,n),n}let a=r?"":na(t,n.length),o=t.substr(0,n.length+a.length),i=Object.freeze({basename:t.substr(o.length),name:t.substr(n.length),hack:n,vendor:a,prefix:o,custom:r});return Qr.set(e,i),i},ea=na;function ta(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===Jr&&e.charCodeAt(t+1)===Jr}function na(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===Jr&&e.charCodeAt(t+1)!==Jr){let n=e.indexOf("-",t+2);if(-1!==n)return e.substring(t,n+1)}return""}var ra=["initial","inherit","unset","revert","revert-layer"],aa=43,oa=45,ia=!0;function sa(e,t){return null!==e&&9===e.type&&e.value.charCodeAt(0)===t}function la(e,t,n){for(;null!==e&&(13===e.type||25===e.type);)e=n(++t);return t}function ca(e,t,n,r){if(!e)return 0;let a=e.value.charCodeAt(t);if(a===aa||a===oa){if(n)return 0;t++}for(;t6)return 0}return r}function ga(e,t,n){if(!e)return 0;for(;pa(n(t),da);){if(++e>6)return 0;t++}return t}var fa=["calc(","-moz-calc(","-webkit-calc("],ba=new Map([[2,22],[21,22],[19,20],[23,24]]);function ya(e,t){return te.max&&"string"!=typeof e.max)return!0}return!1}function Aa(e){return function(t,n,r){return null===t?0:2===t.type&&ka(t.value,fa)?function(e,t){let n=0,r=[],a=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==n)break e;if(n=r.pop(),0===r.length){a++;break e}break;case 2:case 21:case 19:case 23:r.push(n),n=ba.get(e.type)}a++}while(e=t(a));return a}(t,n):e(t,n,r)}}function Ea(e){return function(t){return null===t||t.type!==e?0:1}}function Sa(e){return e&&(e=new Set(e)),function(t,n,r){if(null===t||12!==t.type)return 0;let a=jn(t.value,0);if(null!==e){let n=t.value.indexOf("\\",a),r=-1!==n&&va(t.value,n)?t.value.substring(a,n):t.value.substr(a);if(!1===e.has(r.toLowerCase()))return 0}return xa(r,t.value,a)?0:1}}function Ta(e){return"function"!=typeof e&&(e=function(){return 0}),function(t,n,r){return null!==t&&10===t.type&&0===Number(t.value)?1:e(t,n,r)}}var Ca={"ident-token":Ea(1),"function-token":Ea(2),"at-keyword-token":Ea(3),"hash-token":Ea(4),"string-token":Ea(5),"bad-string-token":Ea(6),"url-token":Ea(7),"bad-url-token":Ea(8),"delim-token":Ea(9),"number-token":Ea(10),"percentage-token":Ea(11),"dimension-token":Ea(12),"whitespace-token":Ea(13),"CDO-token":Ea(14),"CDC-token":Ea(15),"colon-token":Ea(16),"semicolon-token":Ea(17),"comma-token":Ea(18),"[-token":Ea(19),"]-token":Ea(20),"(-token":Ea(21),")-token":Ea(22),"{-token":Ea(23),"}-token":Ea(24)},Ra={string:Ea(5),ident:Ea(1),percentage:Aa((function(e,t,n){return null===e||11!==e.type||xa(n,e.value,e.value.length-1)?0:1})),zero:Ta(),number:Aa((function(e,t,n){if(null===e)return 0;let r=jn(e.value,0);return r!==e.value.length&&!va(e.value,r)||xa(n,e.value,r)?0:1})),integer:Aa((function(e,t,n){if(null===e||10!==e.type)return 0;let r=43===ya(e.value,0)||45===ya(e.value,0)?1:0;for(;rza,decibel:()=>Ua,flex:()=>Oa,frequency:()=>Pa,length:()=>La,resolution:()=>Ma,semitones:()=>Da,time:()=>Na});var La=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],za=["deg","grad","rad","turn"],Na=["s","ms"],Pa=["hz","khz"],Ma=["dpi","dpcm","dppx","x"],Oa=["fr"],Ua=["db"],Da=["st"],qa={};function Fa(e,t,n){return Object.assign(tr("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+"\n "+t+"\n--"+new Array((n||t.length)+1).join("-")+"^"})}Pt(qa,{SyntaxError:()=>Fa,generate:()=>Hr,parse:()=>Co,walk:()=>Io});var ja=class{constructor(e){this.str=e,this.pos=0}charCodeAt(e){return e/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0)),go={" ":1,"&&":2,"||":3,"|":4};function fo(e){return e.substringToPos(e.findWsEnd(e.pos))}function bo(e){let t=e.pos;for(;t=128||0===mo[n])break}return e.pos===t&&e.error("Expect a keyword"),e.substringToPos(t)}function yo(e){let t=e.pos;for(;t57)break}return e.pos===t&&e.error("Expect a number"),e.substringToPos(t)}function wo(e){let t=e.str.indexOf("'",e.pos+1);return-1===t&&(e.pos=e.str.length,e.error("Expect an apostrophe")),e.substringToPos(t+1)}function ko(e){let t=null,n=null;return e.eat(co),t=yo(e),e.charCode()===to?(e.pos++,e.charCode()!==ho&&(n=yo(e))):n=t,e.eat(ho),{min:Number(t),max:n?Number(n):0}}function vo(e,t){let n=function(e){let t=null,n=!1;switch(e.charCode()){case Xa:e.pos++,t={min:0,max:0};break;case eo:e.pos++,t={min:1,max:0};break;case oo:e.pos++,t={min:0,max:1};break;case Ya:e.pos++,n=!0,e.charCode()===co?t=ko(e):e.charCode()===oo?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case co:t=ko(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}(e);return null!==n?(n.term=t,e.charCode()===Ya&&e.charCodeAt(e.pos-1)===eo?vo(e,n):n):t}function xo(e){let t=e.peek();return""===t?null:{type:"Token",value:t}}function Ao(e){let t,n=null;return e.eat(ro),t=bo(e),e.charCode()===Ja&&e.nextCharCode()===Za&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===so&&(fo(e),n=function(e){let t=null,n=null,r=1;return e.eat(so),e.charCode()===no&&(e.peek(),r=-1),-1==r&&e.charCode()===po?e.peek():(t=r*Number(yo(e)),0!==mo[e.charCode()]&&(t+=bo(e))),fo(e),e.eat(to),fo(e),e.charCode()===po?e.peek():(r=1,e.charCode()===no&&(e.peek(),r=-1),n=r*Number(yo(e)),0!==mo[e.charCode()]&&(n+=bo(e))),e.eat(lo),{type:"Range",min:t,max:n}}(e)),e.eat(ao),vo(e,{type:"Type",name:t,opts:n})}function Eo(e,t){function n(e,t){return{type:"Group",terms:e,combinator:t,disallowEmpty:!1,explicit:!1}}let r;for(t=Object.keys(t).sort(((e,t)=>go[e]-go[t]));t.length>0;){r=t.shift();let a=0,o=0;for(;a1&&(e.splice(o,a-o,n(e.slice(o,a),r)),a=o+1),o=-1))}-1!==o&&t.length&&e.splice(o,a-o,n(e.slice(o,a),r))}return r}function So(e){let t,n=[],r={},a=null,o=e.pos;for(;t=To(e);)"Spaces"!==t.type&&("Combinator"===t.type?((null===a||"Combinator"===a.type)&&(e.pos=o,e.error("Unexpected combinator")),r[t.value]=!0):null!==a&&"Combinator"!==a.type&&(r[" "]=!0,n.push({type:"Combinator",value:" "})),n.push(t),a=t,o=e.pos);return null!==a&&"Combinator"===a.type&&(e.pos-=o,e.error("Unexpected combinator")),{type:"Group",terms:n,combinator:Eo(n,r)||" ",disallowEmpty:!1,explicit:!1}}function To(e){let t=e.charCode();if(t<128&&1===mo[t])return function(e){let t=bo(e);return e.charCode()===Ja?(e.pos++,{type:"Function",name:t}):vo(e,{type:"Keyword",name:t})}(e);switch(t){case lo:break;case so:return vo(e,function(e){let t;return e.eat(so),t=So(e),e.eat(lo),t.explicit=!0,e.charCode()===Ga&&(e.pos++,t.disallowEmpty=!0),t}(e));case ro:return e.nextCharCode()===Qa?function(e){let t;return e.eat(ro),e.eat(Qa),t=bo(e),e.eat(Qa),e.eat(ao),vo(e,{type:"Property",name:t})}(e):Ao(e);case uo:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===uo?2:1))};case Ka:return e.pos++,e.eat(Ka),{type:"Combinator",value:"&&"};case to:return e.pos++,{type:"Comma"};case Qa:return vo(e,{type:"String",value:wo(e)});case $a:case Ba:case Ha:case Wa:case Va:return{type:"Spaces",value:fo(e)};case io:return t=e.nextCharCode(),t<128&&1===mo[t]?(e.pos++,{type:"AtKeyword",name:bo(e)}):xo(e);case Xa:case eo:case oo:case Ya:case Ga:break;case co:if(t=e.nextCharCode(),t<48||t>57)return xo(e);break;default:return xo(e)}}function Co(e){let t=new ja(e),n=So(t);return t.pos!==e.length&&t.error("Unexpected input"),1===n.terms.length&&"Group"===n.terms[0].type?n.terms[0]:n}var Ro=function(){};function _o(e){return"function"==typeof e?e:Ro}function Io(e,t,n){let r=Ro,a=Ro;if("function"==typeof t?r=t:t&&(r=_o(t.enter),a=_o(t.leave)),r===Ro&&a===Ro)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");!function e(t){switch(r.call(n,t),t.type){case"Group":t.terms.forEach(e);break;case"Multiplier":e(t.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+t.type)}a.call(n,t)}(e)}var Lo={decorator(e){let t=[],n=null;return{...e,node(t){let r=n;n=t,e.node.call(this,t),n=r},emit(e,r,a){t.push({type:r,value:e,node:a?null:n})},result:()=>t}}};function zo(e,t){return"string"==typeof e?function(e){let t=[];return Zn(e,((n,r,a)=>t.push({type:n,value:e.slice(r,a),node:null}))),t}(e):t.generate(e,Lo)}var No={type:"Match"},Po={type:"Mismatch"},Mo={type:"DisallowEmpty"},Oo=40,Uo=41;function Do(e,t,n){return t===No&&n===Po||e===No&&t===No&&n===No?e:("If"===e.type&&e.else===Po&&t===No&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function qo(e){return e.length>2&&e.charCodeAt(e.length-2)===Oo&&e.charCodeAt(e.length-1)===Uo}function Fo(e){return"Keyword"===e.type||"AtKeyword"===e.type||"Function"===e.type||"Type"===e.type&&qo(e.name)}function jo(e,t,n){switch(e){case" ":{let e=No;for(let n=t.length-1;n>=0;n--){e=Do(t[n],e,Po)}return e}case"|":{let e=Po,n=null;for(let r=t.length-1;r>=0;r--){let a=t[r];if(Fo(a)&&(null===n&&r>0&&Fo(t[r-1])&&(n=Object.create(null),e=Do({type:"Enum",map:n},No,e)),null!==n)){let e=(qo(a.name)?a.name.slice(0,-1):a.name).toLowerCase();if(!(e in n)){n[e]=a;continue}}n=null,e=Do(a,No,e)}return e}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let n=Po;for(let r=t.length-1;r>=0;r--){let a,o=t[r];a=t.length>1?jo(e,t.filter((function(e){return e!==o})),!1):No,n=Do(o,a,n)}return n}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let r=n?No:Po;for(let n=t.length-1;n>=0;n--){let a,o=t[n];a=t.length>1?jo(e,t.filter((function(e){return e!==o})),!0):No,r=Do(o,a,r)}return r}}}function Bo(e){if("function"==typeof e)return{type:"Generic",fn:e};switch(e.type){case"Group":{let t=jo(e.combinator,e.terms.map(Bo),!1);return e.disallowEmpty&&(t=Do(t,Mo,Po)),t}case"Multiplier":return function(e){let t=No,n=Bo(e.term);if(0===e.max)n=Do(n,Mo,Po),t=Do(n,null,Po),t.then=Do(No,No,t),e.comma&&(t.then.else=Do({type:"Comma",syntax:e},t,Po));else for(let r=e.min||1;r<=e.max;r++)e.comma&&t!==No&&(t=Do({type:"Comma",syntax:e},t,Po)),t=Do(n,Do(No,No,t),Po);if(0===e.min)t=Do(No,No,t);else for(let r=0;r=65&&a<=90&&(a|=32),a!==r)return!1}return!0}function ei(e){return null===e||(18===e.type||2===e.type||21===e.type||19===e.type||23===e.type||function(e){return 9===e.type&&"?"!==e.value}(e))}function ti(e){return null===e||(22===e.type||20===e.type||24===e.type||9===e.type&&"/"===e.value)}function ni(e,t,n){let r=function(e,t,n){function r(){do{b++,f=by&&(y=b)}function c(){w=w.type===Go?w.prev:{type:Yo,syntax:u.syntax,token:w.token,prev:w},u=u.prev}let u=null,h=null,d=null,p=null,m=0,g=null,f=null,b=-1,y=0,w={type:Wo,syntax:null,token:null,prev:null};for(r();null===g&&++md.tokenIndex)&&(d=p,p=!1);else if(null===d){g=Qo;break}t=d.nextState,h=d.thenStack,u=d.syntaxStack,w=d.matchStack,b=d.tokenIndex,f=bb){for(;b":"<'"+t.name+"'>"));if(!1!==p&&null!==f&&"Type"===t.type&&("custom-ident"===t.name&&1===f.type||"length"===t.name&&"0"===f.value)){null===p&&(p=o(t,d)),t=Po;break}u={syntax:t.syntax,opts:t.syntax.opts||null!==u&&u.opts||null,prev:u},w={type:Go,syntax:t.syntax,token:w.token,prev:w},t=r.match;break}case"Keyword":{let e=t.name;if(null!==f){let n=f.value;if(-1!==n.indexOf("\\")&&(n=n.replace(/\\[09].*$/,"")),Xo(n,e)){l(),t=No;break}}t=Po;break}case"AtKeyword":case"Function":if(null!==f&&Xo(f.value,t.name)){l(),t=No;break}t=Po;break;case"Token":if(null!==f&&f.value===t.value){l(),t=No;break}t=Po;break;case"Comma":null!==f&&18===f.type?ei(w.token)?t=Po:(l(),t=ti(f)?Po:No):t=ei(w.token)||ti(f)?No:Po;break;case"String":let r="",m=b;for(;m"Type"===e.type&&e.name===t))}function ii(e,t){return li(this,e,(e=>"Property"===e.type&&e.name===t))}function si(e){return li(this,e,(e=>"Keyword"===e.type))}function li(e,t,n){let r=ai.call(e,t);return null!==r&&r.some(n)}function ci(e){return"node"in e?e.node:ci(e.match[0])}function ui(e){return"node"in e?e.node:ui(e.match[e.match.length-1])}function hi(e,t,n,r,a){let o=[];return null!==n.matched&&function n(i){if(null!==i.syntax&&i.syntax.type===r&&i.syntax.name===a){let n=ci(i),r=ui(i);e.syntax.walk(t,(function(e,t,a){if(e===n){let e=new er;do{if(e.appendData(t.data),t.data===r)break;t=t.next}while(null!==t);o.push({parent:a,nodes:e})}}))}Array.isArray(i.match)&&i.match.forEach(n)}(n.matched),o}Pt(ri,{getTrace:()=>ai,isKeyword:()=>si,isProperty:()=>ii,isType:()=>oi});var{hasOwnProperty:di}=Object.prototype;function pi(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&e>=0}function mi(e){return Boolean(e)&&pi(e.offset)&&pi(e.line)&&pi(e.column)}function gi(e,t){return function(n,r){if(!n||n.constructor!==Object)return r(n,"Type of node should be an Object");for(let a in n){let o=!0;if(!1!==di.call(n,a)){if("type"===a)n.type!==e&&r(n,"Wrong node type `"+n.type+"`, expected `"+e+"`");else if("loc"===a){if(null===n.loc)continue;if(n.loc&&n.loc.constructor===Object)if("string"!=typeof n.loc.source)a+=".source";else if(mi(n.loc.start)){if(mi(n.loc.end))continue;a+=".end"}else a+=".start";o=!1}else if(t.hasOwnProperty(a)){o=!1;for(let e=0;!o&&e");else{if(!Array.isArray(r))throw new Error("Wrong value `"+r+"` in `"+e+"."+t+"` structure definition");o.push("List")}}a[t]=o.join(" | ")}return{docs:a,check:gi(e,r)}}var bi=Ho(ra.join(" | "));function yi(e,t,n){let r={};for(let a in e)e[a].syntax&&(r[a]=n?e[a].syntax:Hr(e[a].syntax,{compact:t}));return r}function wi(e,t,n){let r={};for(let[a,o]of Object.entries(e))r[a]={prelude:o.prelude&&(n?o.prelude.syntax:Hr(o.prelude.syntax,{compact:t})),descriptors:o.descriptors&&yi(o.descriptors,t,n)};return r}function ki(e,t,n){return{matched:e,iterations:n,error:t,...ri}}function vi(e,t,n,r){let a,o=zo(n,e.syntax);return function(e){for(let t=0;t(Object.defineProperty(o,"syntax",{value:Co(e)}),o.syntax)}):o.syntax=e,Object.defineProperty(o,"match",{get:()=>(Object.defineProperty(o,"match",{value:Ho(o.syntax,a)}),o.match)})),o}addAtrule_(e,t){!t||(this.atrules[e]={type:"Atrule",name:e,prelude:t.prelude?this.createDescriptor(t.prelude,"AtrulePrelude",e):null,descriptors:t.descriptors?Object.keys(t.descriptors).reduce(((n,r)=>(n[r]=this.createDescriptor(t.descriptors[r],"AtruleDescriptor",r,e),n)),Object.create(null)):null})}addProperty_(e,t){!t||(this.properties[e]=this.createDescriptor(t,"Property",e))}addType_(e,t){!t||(this.types[e]=this.createDescriptor(t,"Type",e))}checkAtruleName(e){if(!this.getAtrule(e))return new Gr("Unknown at-rule","@"+e)}checkAtrulePrelude(e,t){let n=this.checkAtruleName(e);if(n)return n;let r=this.getAtrule(e);return!r.prelude&&t?new SyntaxError("At-rule `@"+e+"` should not contain a prelude"):!r.prelude||t||vi(this,r.prelude,"",!1).matched?void 0:new SyntaxError("At-rule `@"+e+"` should contain a prelude")}checkAtruleDescriptorName(e,t){let n=this.checkAtruleName(e);if(n)return n;let r=this.getAtrule(e),a=Zr(t);return r.descriptors?r.descriptors[a.name]||r.descriptors[a.basename]?void 0:new Gr("Unknown at-rule descriptor",t):new SyntaxError("At-rule `@"+e+"` has no known descriptors")}checkPropertyName(e){if(!this.getProperty(e))return new Gr("Unknown property",e)}matchAtrulePrelude(e,t){let n=this.checkAtrulePrelude(e,t);if(n)return ki(null,n);let r=this.getAtrule(e);return r.prelude?vi(this,r.prelude,t||"",!1):ki(null,null)}matchAtruleDescriptor(e,t,n){let r=this.checkAtruleDescriptorName(e,t);if(r)return ki(null,r);let a=this.getAtrule(e),o=Zr(t);return vi(this,a.descriptors[o.name]||a.descriptors[o.basename],n,!1)}matchDeclaration(e){return"Declaration"!==e.type?ki(null,new Error("Not a Declaration node")):this.matchProperty(e.property,e.value)}matchProperty(e,t){if(Xr(e).custom)return ki(null,new Error("Lexer matching doesn't applicable for custom properties"));let n=this.checkPropertyName(e);return n?ki(null,n):vi(this,this.getProperty(e),t,!0)}matchType(e,t){let n=this.getType(e);return n?vi(this,n,t,!1):ki(null,new Gr("Unknown type",e))}match(e,t){return"string"==typeof e||e&&e.type?(("string"==typeof e||!e.match)&&(e=this.createDescriptor(e,"Type","anonymous")),vi(this,e,t,!1)):ki(null,new Gr("Bad syntax"))}findValueFragments(e,t,n,r){return hi(this,t,this.matchProperty(e,t),n,r)}findDeclarationValueFragments(e,t,n){return hi(this,e.value,this.matchDeclaration(e),t,n)}findAllFragments(e,t,n){let r=[];return this.syntax.walk(e,{visit:"Declaration",enter:e=>{r.push.apply(r,this.findDeclarationValueFragments(e,t,n))}}),r}getAtrule(e,t=!0){let n=Zr(e);return(n.vendor&&t?this.atrules[n.name]||this.atrules[n.basename]:this.atrules[n.name])||null}getAtrulePrelude(e,t=!0){let n=this.getAtrule(e,t);return n&&n.prelude||null}getAtruleDescriptor(e,t){return this.atrules.hasOwnProperty(e)&&this.atrules.declarators&&this.atrules[e].declarators[t]||null}getProperty(e,t=!0){let n=Xr(e);return(n.vendor&&t?this.properties[n.name]||this.properties[n.basename]:this.properties[n.name])||null}getType(e){return hasOwnProperty.call(this.types,e)?this.types[e]:null}validate(){function e(r,a,o,i){if(o.has(a))return o.get(a);o.set(a,!1),null!==i.syntax&&Io(i.syntax,(function(i){if("Type"!==i.type&&"Property"!==i.type)return;let s="Type"===i.type?r.types:r.properties,l="Type"===i.type?t:n;(!hasOwnProperty.call(s,i.name)||e(r,i.name,l,s[i.name]))&&o.set(a,!0)}),this)}let t=new Map,n=new Map;for(let n in this.types)e(this,n,t,this.types[n]);for(let t in this.properties)e(this,t,n,this.properties[t]);return t=[...t.keys()].filter((e=>t.get(e))),n=[...n.keys()].filter((e=>n.get(e))),t.length||n.length?{types:t,properties:n}:null}dump(e,t){return{generic:this.generic,units:this.units,types:yi(this.types,!t,e),properties:yi(this.properties,!t,e),atrules:wi(this.atrules,!t,e)}}toString(){return JSON.stringify(this.dump())}};function Ai(e,t){return"string"==typeof t&&/^\s*\|/.test(t)?"string"==typeof e?e+t:t.replace(/^\s*\|\s*/,""):t||null}function Ei(e,t){let n=Object.create(null);for(let[r,a]of Object.entries(e))if(a){n[r]={};for(let e of Object.keys(a))t.includes(e)&&(n[r][e]=a[e])}return n}function Si(e,t){let n={...e};for(let[r,a]of Object.entries(t))switch(r){case"generic":n[r]=Boolean(a);break;case"units":n[r]={...e[r]};for(let[e,t]of Object.entries(a))n[r][e]=Array.isArray(t)?t:[];break;case"atrules":n[r]={...e[r]};for(let[e,t]of Object.entries(a)){let a=n[r][e]||{},o=n[r][e]={prelude:a.prelude||null,descriptors:{...a.descriptors}};if(t){o.prelude=t.prelude?Ai(o.prelude,t.prelude):o.prelude||null;for(let[e,n]of Object.entries(t.descriptors||{}))o.descriptors[e]=n?Ai(o.descriptors[e],n):null;Object.keys(o.descriptors).length||(o.descriptors=null)}}break;case"types":case"properties":n[r]={...e[r]};for(let[e,t]of Object.entries(a))n[r][e]=Ai(n[r][e],t);break;case"scope":n[r]={...e[r]};for(let[e,t]of Object.entries(a))n[r][e]={...n[r][e],...t};break;case"parseContext":n[r]={...e[r],...a};break;case"atrule":case"pseudo":n[r]={...e[r],...Ei(a,["parse"])};break;case"node":n[r]={...e[r],...Ei(a,["name","structure","parse","generate","walkContext"])}}return n}function Ti(e){let t=fr(e),n=Fr(e),r=zr(e),{fromPlainObject:a,toPlainObject:o}=function(e){return{fromPlainObject:t=>(e(t,{enter(e){e.children&&!(e.children instanceof er)&&(e.children=(new er).fromArray(e.children))}}),t),toPlainObject:t=>(e(t,{leave(e){e.children&&e.children instanceof er&&(e.children=e.children.toArray())}}),t)}}(n),i={lexer:null,createLexer:e=>new xi(e,i,i.lexer.structure),tokenize:Zn,parse:t,generate:r,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:a,toPlainObject:o,fork(t){let n=Si({},e);return Ti("function"==typeof t?t(n,Object.assign):Si(n,t))}};return i.lexer=new xi({generic:!0,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},i),i}var Ci=e=>Ti(Si({},e)),Ri={};Pt(Ri,{AnPlusB:()=>_i,Atrule:()=>Hi,AtrulePrelude:()=>Ji,AttributeSelector:()=>rs,Block:()=>fs,Brackets:()=>Cs,CDC:()=>zs,CDO:()=>Us,ClassSelector:()=>Bs,Combinator:()=>Ys,Comment:()=>rl,Declaration:()=>ul,DeclarationList:()=>Rl,Dimension:()=>Ml,Function:()=>Fl,Hash:()=>$l,IdSelector:()=>rc,Identifier:()=>Zl,MediaFeature:()=>lc,MediaQuery:()=>pc,MediaQueryList:()=>yc,NestingSelector:()=>Ac,Nth:()=>_c,Number:()=>Pc,Operator:()=>qc,Parentheses:()=>Vc,Percentage:()=>Kc,PseudoClassSelector:()=>eu,PseudoElementSelector:()=>iu,Ratio:()=>du,Raw:()=>ku,Rule:()=>Tu,Selector:()=>Pu,SelectorList:()=>qu,String:()=>Wu,StyleSheet:()=>nh,TypeSelector:()=>uh,UnicodeRange:()=>yh,Url:()=>Ih,Value:()=>Vh,WhiteSpace:()=>Kh});var _i={};Pt(_i,{generate:()=>Bi,name:()=>qi,parse:()=>ji,structure:()=>Fi});var Ii=43,Li=45,zi=110,Ni=!0,Pi=!1;function Mi(e,t){let n=this.tokenStart+e,r=this.charCodeAt(n);for((r===Ii||r===Li)&&(t&&this.error("Number sign is not allowed"),n++);n0&&this.skip(e),0===t&&(n=this.charCodeAt(this.tokenStart),n!==Ii&&n!==Li&&this.error("Number sign is expected")),Oi.call(this,0!==t),t===Li?"-"+this.consume(10):this.consume(10)}var qi="AnPlusB",Fi={a:[String,null],b:[String,null]};function ji(){let e=this.tokenStart,t=null,n=null;if(10===this.tokenType)Oi.call(this,Pi),n=this.consume(10);else if(1===this.tokenType&&this.cmpChar(this.tokenStart,Li))switch(t="-1",Ui.call(this,1,zi),this.tokenEnd-this.tokenStart){case 2:this.next(),n=Di.call(this);break;case 3:Ui.call(this,2,Li),this.next(),this.skipSC(),Oi.call(this,Ni),n="-"+this.consume(10);break;default:Ui.call(this,2,Li),Mi.call(this,3,Ni),this.next(),n=this.substrToCursor(e+2)}else if(1===this.tokenType||this.isDelim(Ii)&&1===this.lookupType(1)){let r=0;switch(t="1",this.isDelim(Ii)&&(r=1,this.next()),Ui.call(this,0,zi),this.tokenEnd-this.tokenStart){case 1:this.next(),n=Di.call(this);break;case 2:Ui.call(this,1,Li),this.next(),this.skipSC(),Oi.call(this,Ni),n="-"+this.consume(10);break;default:Ui.call(this,1,Li),Mi.call(this,2,Ni),this.next(),n=this.substrToCursor(e+r+1)}}else if(12===this.tokenType){let r=this.charCodeAt(this.tokenStart),a=r===Ii||r===Li,o=this.tokenStart+a;for(;oQi,name:()=>$i,parse:()=>Ki,structure:()=>Yi,walkContext:()=>Gi});var $i="Atrule",Gi="atrule",Yi={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function Ki(e=!1){let t,n,r=this.tokenStart,a=null,o=null;switch(this.eat(3),t=this.substrToCursor(r+1),n=t.toLowerCase(),this.skipSC(),!1===this.eof&&23!==this.tokenType&&17!==this.tokenType&&(a=this.parseAtrulePrelude?this.parseWithFallback(this.AtrulePrelude.bind(this,t,e),Vi):Vi.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case 17:this.next();break;case 23:o=hasOwnProperty.call(this.atrule,n)&&"function"==typeof this.atrule[n].block?this.atrule[n].block.call(this,e):this.Block(Wi.call(this))}return{type:"Atrule",loc:this.getLocation(r,this.tokenStart),name:t,prelude:a,block:o}}function Qi(e){this.token(3,"@"+e.name),null!==e.prelude&&this.node(e.prelude),e.block?this.node(e.block):this.token(17,";")}var Ji={};Pt(Ji,{generate:()=>ns,name:()=>Zi,parse:()=>ts,structure:()=>es,walkContext:()=>Xi});var Zi="AtrulePrelude",Xi="atrulePrelude",es={children:[[]]};function ts(e){let t=null;return null!==e&&(e=e.toLowerCase()),this.skipSC(),t=hasOwnProperty.call(this.atrule,e)&&"function"==typeof this.atrule[e].prelude?this.atrule[e].prelude.call(this):this.readSequence(this.scope.AtrulePrelude),this.skipSC(),!0!==this.eof&&23!==this.tokenType&&17!==this.tokenType&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(t),children:t}}function ns(e){this.children(e)}var rs={};Pt(rs,{generate:()=>gs,name:()=>ds,parse:()=>ms,structure:()=>ps});var as=36,os=42,is=61,ss=94,ls=124,cs=126;function us(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(os)?(t=!0,this.next()):this.isDelim(ls)||this.eat(1),this.isDelim(ls)?this.charCodeAt(this.tokenStart+1)!==is?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function hs(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==is&&t!==cs&&t!==ss&&t!==as&&t!==os&&t!==ls&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==is&&(this.isDelim(is)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}var ds="AttributeSelector",ps={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function ms(){let e,t=this.tokenStart,n=null,r=null,a=null;return this.eat(19),this.skipSC(),e=us.call(this),this.skipSC(),20!==this.tokenType&&(1!==this.tokenType&&(n=hs.call(this),this.skipSC(),r=5===this.tokenType?this.String():this.Identifier(),this.skipSC()),1===this.tokenType&&(a=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:r,flags:a}}function gs(e){this.token(9,"["),this.node(e.name),null!==e.matcher&&(this.tokenize(e.matcher),this.node(e.value)),null!==e.flags&&this.token(1,e.flags),this.token(9,"]")}var fs={};Pt(fs,{generate:()=>Ts,name:()=>xs,parse:()=>Ss,structure:()=>Es,walkContext:()=>As});var bs=38;function ys(e){return this.Raw(e,null,!0)}function ws(){return this.parseWithFallback(this.Rule,ys)}function ks(e){return this.Raw(e,this.consumeUntilSemicolonIncluded,!0)}function vs(){if(17===this.tokenType)return ks.call(this,this.tokenIndex);let e=this.parseWithFallback(this.Declaration,ks);return 17===this.tokenType&&this.next(),e}var xs="Block",As="block",Es={children:[["Atrule","Rule","Declaration"]]};function Ss(e){let t=e?vs:ws,n=this.tokenStart,r=this.createList();this.eat(23);e:for(;!this.eof;)switch(this.tokenType){case 24:break e;case 13:case 25:this.next();break;case 3:r.push(this.parseWithFallback(this.Atrule.bind(this,e),ys));break;default:e&&this.isDelim(bs)?r.push(ws.call(this)):r.push(t.call(this))}return this.eof||this.eat(24),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function Ts(e){this.token(23,"{"),this.children(e,(e=>{"Declaration"===e.type&&this.token(17,";")})),this.token(24,"}")}var Cs={};Pt(Cs,{generate:()=>Ls,name:()=>Rs,parse:()=>Is,structure:()=>_s});var Rs="Brackets",_s={children:[[]]};function Is(e,t){let n=this.tokenStart,r=null;return this.eat(19),r=e.call(this,t),this.eof||this.eat(20),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function Ls(e){this.token(9,"["),this.children(e),this.token(9,"]")}var zs={};Pt(zs,{generate:()=>Os,name:()=>Ns,parse:()=>Ms,structure:()=>Ps});var Ns="CDC",Ps=[];function Ms(){let e=this.tokenStart;return this.eat(15),{type:"CDC",loc:this.getLocation(e,this.tokenStart)}}function Os(){this.token(15,"--\x3e")}var Us={};Pt(Us,{generate:()=>js,name:()=>Ds,parse:()=>Fs,structure:()=>qs});var Ds="CDO",qs=[];function Fs(){let e=this.tokenStart;return this.eat(14),{type:"CDO",loc:this.getLocation(e,this.tokenStart)}}function js(){this.token(14,"\x3c!--")}var Bs={};Pt(Bs,{generate:()=>Gs,name:()=>Vs,parse:()=>$s,structure:()=>Ws});var Hs=46,Vs="ClassSelector",Ws={name:String};function $s(){return this.eatDelim(Hs),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function Gs(e){this.token(9,"."),this.token(1,e.name)}var Ys={};Pt(Ys,{generate:()=>nl,name:()=>Xs,parse:()=>tl,structure:()=>el});var Ks=43,Qs=47,Js=62,Zs=126,Xs="Combinator",el={name:String};function tl(){let e,t=this.tokenStart;switch(this.tokenType){case 13:e=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case Js:case Ks:case Zs:this.next();break;case Qs:this.next(),this.eatIdent("deep"),this.eatDelim(Qs);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t)}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function nl(e){this.tokenize(e.name)}var rl={};Pt(rl,{generate:()=>cl,name:()=>il,parse:()=>ll,structure:()=>sl});var al=42,ol=47,il="Comment",sl={value:String};function ll(){let e=this.tokenStart,t=this.tokenEnd;return this.eat(25),t-e+2>=2&&this.charCodeAt(t-2)===al&&this.charCodeAt(t-1)===ol&&(t-=2),{type:"Comment",loc:this.getLocation(e,this.tokenStart),value:this.substring(e+2,t)}}function cl(e){this.token(25,"/*"+e.value+"*/")}var ul={};Pt(ul,{generate:()=>Sl,name:()=>vl,parse:()=>El,structure:()=>Al,walkContext:()=>xl});var hl=33,dl=35,pl=36,ml=38,gl=42,fl=43,bl=47;function yl(e){return this.Raw(e,this.consumeUntilExclamationMarkOrSemicolon,!0)}function wl(e){return this.Raw(e,this.consumeUntilExclamationMarkOrSemicolon,!1)}function kl(){let e=this.tokenIndex,t=this.Value();return"Raw"!==t.type&&!1===this.eof&&17!==this.tokenType&&!1===this.isDelim(hl)&&!1===this.isBalanceEdge(e)&&this.error(),t}var vl="Declaration",xl="declaration",Al={important:[Boolean,String],property:String,value:["Value","Raw"]};function El(){let e,t=this.tokenStart,n=this.tokenIndex,r=Tl.call(this),a=ta(r),o=a?this.parseCustomProperty:this.parseValue,i=a?wl:yl,s=!1;this.skipSC(),this.eat(16);let l=this.tokenIndex;if(a||this.skipSC(),e=o?this.parseWithFallback(kl,i):i.call(this,this.tokenIndex),a&&"Value"===e.type&&e.children.isEmpty)for(let t=l-this.tokenIndex;t<=0;t++)if(13===this.lookupType(t)){e.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}return this.isDelim(hl)&&(s=Cl.call(this),this.skipSC()),!1===this.eof&&17!==this.tokenType&&!1===this.isBalanceEdge(n)&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.tokenStart),important:s,property:r,value:e}}function Sl(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,!0===e.important?"important":e.important))}function Tl(){let e=this.tokenStart;if(9===this.tokenType)switch(this.charCodeAt(this.tokenStart)){case gl:case pl:case fl:case dl:case ml:this.next();break;case bl:this.next(),this.isDelim(bl)&&this.next()}return 4===this.tokenType?this.eat(4):this.eat(1),this.substrToCursor(e)}function Cl(){this.eat(9),this.skipSC();let e=this.consume(1);return"important"===e||e}var Rl={};Pt(Rl,{generate:()=>Pl,name:()=>Ll,parse:()=>Nl,structure:()=>zl});var _l=38;function Il(e){return this.Raw(e,this.consumeUntilSemicolonIncluded,!0)}var Ll="DeclarationList",zl={children:[["Declaration","Atrule","Rule"]]};function Nl(){let e=this.createList();for(;!this.eof;)switch(this.tokenType){case 13:case 25:case 17:this.next();break;case 3:e.push(this.parseWithFallback(this.Atrule.bind(this,!0),Il));break;default:this.isDelim(_l)?e.push(this.parseWithFallback(this.Rule,Il)):e.push(this.parseWithFallback(this.Declaration,Il))}return{type:"DeclarationList",loc:this.getLocationFromList(e),children:e}}function Pl(e){this.children(e,(e=>{"Declaration"===e.type&&this.token(17,";")}))}var Ml={};Pt(Ml,{generate:()=>ql,name:()=>Ol,parse:()=>Dl,structure:()=>Ul});var Ol="Dimension",Ul={value:String,unit:String};function Dl(){let e=this.tokenStart,t=this.consumeNumber(12);return{type:"Dimension",loc:this.getLocation(e,this.tokenStart),value:t,unit:this.substring(e+t.length,this.tokenStart)}}function ql(e){this.token(12,e.value+e.unit)}var Fl={};Pt(Fl,{generate:()=>Wl,name:()=>jl,parse:()=>Vl,structure:()=>Hl,walkContext:()=>Bl});var jl="Function",Bl="function",Hl={name:String,children:[[]]};function Vl(e,t){let n,r=this.tokenStart,a=this.consumeFunctionName(),o=a.toLowerCase();return n=t.hasOwnProperty(o)?t[o].call(this,t):e.call(this,t),this.eof||this.eat(22),{type:"Function",loc:this.getLocation(r,this.tokenStart),name:a,children:n}}function Wl(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}var $l={};Pt($l,{generate:()=>Jl,name:()=>Yl,parse:()=>Ql,structure:()=>Kl,xxx:()=>Gl});var Gl="XXX",Yl="Hash",Kl={value:String};function Ql(){let e=this.tokenStart;return this.eat(4),{type:"Hash",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e+1)}}function Jl(e){this.token(4,"#"+e.value)}var Zl={};Pt(Zl,{generate:()=>nc,name:()=>Xl,parse:()=>tc,structure:()=>ec});var Xl="Identifier",ec={name:String};function tc(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function nc(e){this.token(1,e.name)}var rc={};Pt(rc,{generate:()=>sc,name:()=>ac,parse:()=>ic,structure:()=>oc});var ac="IdSelector",oc={name:String};function ic(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function sc(e){this.token(9,"#"+e.name)}var lc={};Pt(lc,{generate:()=>dc,name:()=>cc,parse:()=>hc,structure:()=>uc});var cc="MediaFeature",uc={name:String,value:["Identifier","Number","Dimension","Ratio",null]};function hc(){let e,t=this.tokenStart,n=null;if(this.eat(21),this.skipSC(),e=this.consume(1),this.skipSC(),22!==this.tokenType){switch(this.eat(16),this.skipSC(),this.tokenType){case 10:n=9===this.lookupNonWSType(1)?this.Ratio():this.Number();break;case 12:n=this.Dimension();break;case 1:n=this.Identifier();break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eat(22),{type:"MediaFeature",loc:this.getLocation(t,this.tokenStart),name:e,value:n}}function dc(e){this.token(21,"("),this.token(1,e.name),null!==e.value&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}var pc={};Pt(pc,{generate:()=>bc,name:()=>mc,parse:()=>fc,structure:()=>gc});var mc="MediaQuery",gc={children:[["Identifier","MediaFeature","WhiteSpace"]]};function fc(){let e=this.createList(),t=null;this.skipSC();e:for(;!this.eof;){switch(this.tokenType){case 25:case 13:this.next();continue;case 1:t=this.Identifier();break;case 21:t=this.MediaFeature();break;default:break e}e.push(t)}return null===t&&this.error("Identifier or parenthesis is expected"),{type:"MediaQuery",loc:this.getLocationFromList(e),children:e}}function bc(e){this.children(e)}var yc={};Pt(yc,{generate:()=>xc,name:()=>wc,parse:()=>vc,structure:()=>kc});var wc="MediaQueryList",kc={children:[["MediaQuery"]]};function vc(){let e=this.createList();for(this.skipSC();!this.eof&&(e.push(this.MediaQuery()),18===this.tokenType);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(e),children:e}}function xc(e){this.children(e,(()=>this.token(18,",")))}var Ac={};Pt(Ac,{generate:()=>Rc,name:()=>Sc,parse:()=>Cc,structure:()=>Tc});var Ec=38,Sc="NestingSelector",Tc={};function Cc(){let e=this.tokenStart;return this.eatDelim(Ec),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function Rc(){this.token(9,"&")}var _c={};Pt(_c,{generate:()=>Nc,name:()=>Ic,parse:()=>zc,structure:()=>Lc});var Ic="Nth",Lc={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function zc(){this.skipSC();let e,t=this.tokenStart,n=t,r=null;return e=this.lookupValue(0,"odd")||this.lookupValue(0,"even")?this.Identifier():this.AnPlusB(),n=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),r=this.SelectorList(),n=this.tokenStart),{type:"Nth",loc:this.getLocation(t,n),nth:e,selector:r}}function Nc(e){this.node(e.nth),null!==e.selector&&(this.token(1,"of"),this.node(e.selector))}var Pc={};Pt(Pc,{generate:()=>Dc,name:()=>Mc,parse:()=>Uc,structure:()=>Oc});var Mc="Number",Oc={value:String};function Uc(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(10)}}function Dc(e){this.token(10,e.value)}var qc={};Pt(qc,{generate:()=>Hc,name:()=>Fc,parse:()=>Bc,structure:()=>jc});var Fc="Operator",jc={value:String};function Bc(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function Hc(e){this.tokenize(e.value)}var Vc={};Pt(Vc,{generate:()=>Yc,name:()=>Wc,parse:()=>Gc,structure:()=>$c});var Wc="Parentheses",$c={children:[[]]};function Gc(e,t){let n=this.tokenStart,r=null;return this.eat(21),r=e.call(this,t),this.eof||this.eat(22),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function Yc(e){this.token(21,"("),this.children(e),this.token(22,")")}var Kc={};Pt(Kc,{generate:()=>Xc,name:()=>Qc,parse:()=>Zc,structure:()=>Jc});var Qc="Percentage",Jc={value:String};function Zc(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function Xc(e){this.token(11,e.value+"%")}var eu={};Pt(eu,{generate:()=>ou,name:()=>tu,parse:()=>au,structure:()=>ru,walkContext:()=>nu});var tu="PseudoClassSelector",nu="function",ru={name:String,children:[["Raw"],null]};function au(){let e,t,n=this.tokenStart,r=null;return this.eat(16),2===this.tokenType?(e=this.consumeFunctionName(),t=e.toLowerCase(),22==this.lookupNonWSType(0)?r=this.createList():hasOwnProperty.call(this.pseudo,t)?(this.skipSC(),r=this.pseudo[t].call(this),this.skipSC()):(r=this.createList(),r.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):e=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(n,this.tokenStart),name:e,children:r}}function ou(e){this.token(16,":"),null===e.children?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var iu={};Pt(iu,{generate:()=>hu,name:()=>su,parse:()=>uu,structure:()=>cu,walkContext:()=>lu});var su="PseudoElementSelector",lu="function",cu={name:String,children:[["Raw"],null]};function uu(){let e,t,n=this.tokenStart,r=null;return this.eat(16),this.eat(16),2===this.tokenType?(e=this.consumeFunctionName(),t=e.toLowerCase(),22==this.lookupNonWSType(0)?r=this.createList():hasOwnProperty.call(this.pseudo,t)?(this.skipSC(),r=this.pseudo[t].call(this),this.skipSC()):(r=this.createList(),r.push(this.Raw(this.tokenIndex,null,!1))),this.eat(22)):e=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(n,this.tokenStart),name:e,children:r}}function hu(e){this.token(16,":"),this.token(16,":"),null===e.children?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}var du={};Pt(du,{generate:()=>wu,name:()=>fu,parse:()=>yu,structure:()=>bu});var pu=47,mu=46;function gu(){this.skipSC();let e=this.consume(10);for(let t=0;t0&&13===this.lookupType(-1)?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}Pt(ku,{generate:()=>Su,name:()=>xu,parse:()=>Eu,structure:()=>Au});var xu="Raw",Au={value:String};function Eu(e,t,n){let r,a=this.getTokenStart(e);return this.skipUntilBalanced(e,t||this.consumeUntilBalanceEnd),r=n&&this.tokenStart>a?vu.call(this):this.tokenStart,{type:"Raw",loc:this.getLocation(a,r),value:this.substring(a,r)}}function Su(e){this.tokenize(e.value)}var Tu={};function Cu(e){return this.Raw(e,this.consumeUntilLeftCurlyBracket,!0)}function Ru(){let e=this.SelectorList();return"Raw"!==e.type&&!1===this.eof&&23!==this.tokenType&&this.error(),e}Pt(Tu,{generate:()=>Nu,name:()=>_u,parse:()=>zu,structure:()=>Lu,walkContext:()=>Iu});var _u="Rule",Iu="rule",Lu={prelude:["SelectorList","Raw"],block:["Block"]};function zu(){let e,t,n=this.tokenIndex,r=this.tokenStart;return e=this.parseRulePrelude?this.parseWithFallback(Ru,Cu):Cu.call(this,n),t=this.Block(!0),{type:"Rule",loc:this.getLocation(r,this.tokenStart),prelude:e,block:t}}function Nu(e){this.node(e.prelude),this.node(e.block)}var Pu={};Pt(Pu,{generate:()=>Du,name:()=>Mu,parse:()=>Uu,structure:()=>Ou});var Mu="Selector",Ou={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator","WhiteSpace"]]};function Uu(){let e=this.readSequence(this.scope.Selector);return null===this.getFirstListNode(e)&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function Du(e){this.children(e)}var qu={};Pt(qu,{generate:()=>Vu,name:()=>Fu,parse:()=>Hu,structure:()=>Bu,walkContext:()=>ju});var Fu="SelectorList",ju="selector",Bu={children:[["Selector","Raw"]]};function Hu(){let e=this.createList();for(;!this.eof&&(e.push(this.Selector()),18===this.tokenType);)this.next();return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function Vu(e){this.children(e,(()=>this.token(18,",")))}var Wu={};Pt(Wu,{generate:()=>th,name:()=>Zu,parse:()=>eh,structure:()=>Xu});var $u={};Pt($u,{decode:()=>Qu,encode:()=>Ju});var Gu=92,Yu=34,Ku=39;function Qu(e){let t=e.length,n=e.charCodeAt(0),r=n===Yu||n===Ku?1:0,a=1===r&&t>1&&e.charCodeAt(t-1)===n?t-2:t-1,o="";for(let n=r;n<=a;n++){let r=e.charCodeAt(n);if(r===Gu){if(n===a){n!==t-1&&(o=e.substr(n+1));break}if(r=e.charCodeAt(++n),An(Gu,r)){let t=n-1,r=qn(e,t);n=r-1,o+=Hn(e.substring(t+1,r))}else 13===r&&10===e.charCodeAt(n+1)&&n++}else o+=e[n]}return o}function Ju(e,t){let n=t?"'":'"',r=t?Ku:Yu,a="",o=!1;for(let t=0;tch,name:()=>oh,parse:()=>lh,structure:()=>sh,walkContext:()=>ih});var rh=33;function ah(e){return this.Raw(e,null,!1)}var oh="StyleSheet",ih="stylesheet",sh={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function lh(){let e,t=this.tokenStart,n=this.createList();for(;!this.eof;){switch(this.tokenType){case 13:this.next();continue;case 25:if(this.charCodeAt(this.tokenStart+2)!==rh){this.next();continue}e=this.Comment();break;case 14:e=this.CDO();break;case 15:e=this.CDC();break;case 3:e=this.parseWithFallback(this.Atrule,ah);break;default:e=this.parseWithFallback(this.Rule,ah)}n.push(e)}return{type:"StyleSheet",loc:this.getLocation(t,this.tokenStart),children:n}}function ch(e){this.children(e)}var uh={};Pt(uh,{generate:()=>bh,name:()=>mh,parse:()=>fh,structure:()=>gh});var hh=42,dh=124;function ph(){1!==this.tokenType&&!1===this.isDelim(hh)&&this.error("Identifier or asterisk is expected"),this.next()}var mh="TypeSelector",gh={name:String};function fh(){let e=this.tokenStart;return this.isDelim(dh)?(this.next(),ph.call(this)):(ph.call(this),this.isDelim(dh)&&(this.next(),ph.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function bh(e){this.tokenize(e.name)}var yh={};Pt(yh,{generate:()=>_h,name:()=>Th,parse:()=>Rh,structure:()=>Ch});var wh=43,kh=45,vh=63;function xh(e,t){let n=0;for(let r=this.tokenStart+e;r6&&this.error("Too many hex digits",r)}return this.next(),n}function Ah(e){let t=0;for(;this.isDelim(vh);)++t>e&&this.error("Too many question marks"),this.next()}function Eh(e){this.charCodeAt(this.tokenStart)!==e&&this.error((e===wh?"Plus sign":"Hyphen minus")+" is expected")}function Sh(){let e=0;switch(this.tokenType){case 10:if(e=xh.call(this,1,!0),this.isDelim(vh)){Ah.call(this,6-e);break}if(12===this.tokenType||10===this.tokenType){Eh.call(this,kh),xh.call(this,1,!1);break}break;case 12:e=xh.call(this,1,!0),e>0&&Ah.call(this,6-e);break;default:if(this.eatDelim(wh),1===this.tokenType){e=xh.call(this,0,!0),e>0&&Ah.call(this,6-e);break}if(this.isDelim(vh)){this.next(),Ah.call(this,5);break}this.error("Hex digit or question mark is expected")}}var Th="UnicodeRange",Ch={value:String};function Rh(){let e=this.tokenStart;return this.eatIdent("u"),Sh.call(this),{type:"UnicodeRange",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function _h(e){this.tokenize(e.value)}var Ih={};Pt(Ih,{generate:()=>Hh,name:()=>Fh,parse:()=>Bh,structure:()=>jh});var Lh={};Pt(Lh,{decode:()=>Dh,encode:()=>qh});var zh=32,Nh=92,Ph=34,Mh=39,Oh=40,Uh=41;function Dh(e){let t=e.length,n=4,r=e.charCodeAt(t-1)===Uh?t-2:t-1,a="";for(;nYh,name:()=>Wh,parse:()=>Gh,structure:()=>$h});var Wh="Value",$h={children:[[]]};function Gh(){let e=this.tokenStart,t=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(e,this.tokenStart),children:t}}function Yh(e){this.children(e)}var Kh={};Pt(Kh,{generate:()=>ed,name:()=>Jh,parse:()=>Xh,structure:()=>Zh});var Qh=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),Jh="WhiteSpace",Zh={value:String};function Xh(){return this.eat(13),Qh}function ed(e){this.token(13,e.value)}var td={generic:!0,generic:!0,units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( )","alpha-value":"|","angle-percentage":"|","angular-color-hint":"","angular-color-stop":"&&?","angular-color-stop-list":"[ [, ]?]# , ","animateable-feature":"scroll-position|contents|","asin()":"asin( )","atan()":"atan( )","atan2()":"atan2( , )",attachment:"scroll|fixed|local","attr()":"attr( ? [, ]? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attribute-selector":"'[' ']'|'[' [|] ? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [? ]+ ? )","auto-track-list":"[? [|]]* ? [? [|]]* ?",axis:"block|inline|vertical|horizontal","baseline-position":"[first|last]? baseline","basic-shape":"||||","bg-image":"none|","bg-layer":"|| [/ ]?||||||||","bg-position":"[[left|center|right|top|bottom|]|[left|center|right|] [top|center|bottom|]|[center|[left|right] ?]&&[center|[top|bottom] ?]]","bg-size":"[|auto]{1,2}|cover|contain","blur()":"blur( )","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity",box:"border-box|padding-box|content-box","brightness()":"brightness( )","calc()":"calc( )","calc-sum":" [['+'|'-'] ]*","calc-product":" ['*' |'/' ]*","calc-value":"||||( )","calc-constant":"e|pi|infinity|-infinity|NaN","cf-final-image":"|","cf-mixing-image":"?&&","circle()":"circle( []? [at ]? )","clamp()":"clamp( #{3} )","class-selector":"'.' ","clip-source":"",color:"|||||||||currentcolor|","color-stop":"|","color-stop-angle":"{1,2}","color-stop-length":"{1,2}","color-stop-list":"[ [, ]?]# , ",combinator:"'>'|'+'|'~'|['||']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|push-button|slider-horizontal|checkbox|radio|square-button|menulist|listbox|meter|progress-bar|button","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[? * [ *]*]!","compound-selector-list":"#","complex-selector":" [? ]*","complex-selector-list":"#","conic-gradient()":"conic-gradient( [from ]? [at ]? , )","contextual-alt-values":"[contextual|no-contextual]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[|contents||||||]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"","contrast()":"contrast( [] )","cos()":"cos( )",counter:"|","counter()":"counter( , ? )","counter-name":"","counter-style":"|symbols( )","counter-style-name":"","counters()":"counters( , , ? )","cross-fade()":"cross-fade( , ? )","cubic-bezier-timing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( , , , )","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( {2,3} ? )","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( , [first|start|last|first-except]? )|element( )","ellipse()":"ellipse( [{2}]? [at ]? )","ending-shape":"circle|ellipse","env()":"env( , ? )","exp()":"exp( )","explicit-track-list":"[? ]+ ?","family-name":"|+","feature-tag-value":" [|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":" '{' '}'","feature-value-block-list":"+","feature-value-declaration":" : + ;","feature-value-declaration-list":"","feature-value-name":"","fill-rule":"nonzero|evenodd","filter-function":"|||||||||","filter-function-list":"[|]+","final-bg-layer":"<'background-color'>|||| [/ ]?||||||||","fixed-breadth":"","fixed-repeat":"repeat( [] , [? ]+ ? )","fixed-size":"|minmax( , )|minmax( , )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|","font-variant-css21":"[normal|small-caps]","font-weight-absolute":"normal|bold|","frequency-percentage":"|","general-enclosed":"[ )]|( )","generic-family":"serif|sans-serif|cursive|fantasy|monospace|-apple-system","generic-name":"serif|sans-serif|cursive|fantasy|monospace","geometry-box":"|fill-box|stroke-box|view-box",gradient:"||||||<-legacy-gradient>","grayscale()":"grayscale( )","grid-line":"auto||[&&?]|[span&&[||]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( [/ ]? )|hsl( , , , ? )","hsla()":"hsla( [/ ]? )|hsla( , , , ? )",hue:"|","hue-rotate()":"hue-rotate( )","hwb()":"hwb( [|none] [|none] [|none] [/ [|none]]? )","hypot()":"hypot( # )",image:"||||||","image()":"image( ? [? , ?]! )","image-set()":"image-set( # )","image-set-option":"[|] [||type( )]","image-src":"|","image-tags":"ltr|rtl","inflexible-breadth":"|min-content|max-content|auto","inset()":"inset( {1,4} [round <'border-radius'>]? )","invert()":"invert( )","keyframes-name":"|","keyframe-block":"# { }","keyframe-block-list":"+","keyframe-selector":"from|to|","lab()":"lab( [||none] [||none] [||none] [/ [|none]]? )","layer()":"layer( )","layer-name":" ['.' ]*","lch()":"lch( [||none] [||none] [|none] [/ [|none]]? )","leader()":"leader( )","leader-type":"dotted|solid|space|","length-percentage":"|","line-names":"'[' * ']'","line-name-list":"[|]+","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"|thin|medium|thick","linear-color-hint":"","linear-color-stop":" ?","linear-gradient()":"linear-gradient( [|to ]? , )","log()":"log( , ? )","mask-layer":"|| [/ ]?||||||[|no-clip]||||","mask-position":"[|left|center|right] [|top|center|bottom]?","mask-reference":"none||","mask-source":"","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( #{6} )","matrix3d()":"matrix3d( #{16} )","max()":"max( # )","media-and":" [and ]+","media-condition":"|||","media-condition-without-or":"||","media-feature":"( [||] )","media-in-parens":"( )||","media-not":"not ","media-or":" [or ]+","media-query":"|[not|only]? [and ]?","media-query-list":"#","media-type":"","mf-boolean":"","mf-name":"","mf-plain":" : ","mf-range":" ['<'|'>']? '='? | ['<'|'>']? '='? | '<' '='? '<' '='? | '>' '='? '>' '='? ","mf-value":"|||","min()":"min( # )","minmax()":"minmax( [|min-content|max-content|auto] , [||min-content|max-content|auto] )","mod()":"mod( , )","name-repeat":"repeat( [|auto-fill] , + )","named-color":"transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|<-non-standard-color>","namespace-prefix":"","ns-prefix":"[|'*']? '|'","number-percentage":"|","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]",nth:"|even|odd","opacity()":"opacity( [] )","overflow-position":"unsafe|safe","outline-radius":"|","page-body":"? [; ]?| ","page-margin-box":" '{' '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector-list":"[#]?","page-selector":"+| *","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger","path()":"path( [ ,]? )","paint()":"paint( , ? )","perspective()":"perspective( [|none] )","polygon()":"polygon( ? , [ ]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|] [top|center|bottom|]?|[[left|right] ]&&[[top|bottom] ]]","pow()":"pow( , )","pseudo-class-selector":"':' |':' ')'","pseudo-element-selector":"':' ","pseudo-page":": [left|right|first|blank]",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-gradient()":"radial-gradient( [||]? [at ]? , )",ratio:" [/ ]?","relative-selector":"? ","relative-selector-list":"#","relative-size":"larger|smaller","rem()":"rem( , )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [from ]? [at ]? , )","repeating-linear-gradient()":"repeating-linear-gradient( [|to ]? , )","repeating-radial-gradient()":"repeating-radial-gradient( [||]? [at ]? , )","reversed-counter-name":"reversed( )","rgb()":"rgb( {3} [/ ]? )|rgb( {3} [/ ]? )|rgb( #{3} , ? )|rgb( #{3} , ? )","rgba()":"rgba( {3} [/ ]? )|rgba( {3} [/ ]? )|rgba( #{3} , ? )|rgba( #{3} , ? )","rotate()":"rotate( [|] )","rotate3d()":"rotate3d( , , , [|] )","rotateX()":"rotateX( [|] )","rotateY()":"rotateY( [|] )","rotateZ()":"rotateZ( [|] )","round()":"round( ? , , )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( )","scale()":"scale( [|]#{1,2} )","scale3d()":"scale3d( [|]#{3} )","scaleX()":"scaleX( [|] )","scaleY()":"scaleY( [|] )","scaleZ()":"scaleZ( [|] )",scroller:"root|nearest","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","shape-radius":"|closest-side|farthest-side","sign()":"sign( )","skew()":"skew( [|] , [|]? )","skewX()":"skewX( [|] )","skewY()":"skewY( [|] )","sepia()":"sepia( )",shadow:"inset?&&{2,4}&&?","shadow-t":"[{2,3}&&?]",shape:"rect( , , , )|rect( )","shape-box":"|margin-box","side-or-corner":"[left|right]||[top|bottom]","sin()":"sin( )","single-animation":"