1 line
49 KiB
JavaScript
1 line
49 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ReadabilityBundle=t():e.ReadabilityBundle=t()}(this,()=>(()=>{var e={238:e=>{function t(e,t){if(t&&t.documentElement)e=t,t=arguments[2];else if(!e||!e.documentElement)throw new Error("First argument to Readability constructor should be a document object.");if(t=t||{},this._doc=e,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._metadata={},this._debug=!!t.debug,this._maxElemsToParse=t.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=t.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=t.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(t.classesToPreserve||[]),this._keepClasses=!!t.keepClasses,this._serializer=t.serializer||function(e){return e.innerHTML},this._disableJSONLD=!!t.disableJSONLD,this._allowedVideoRegex=t.allowedVideoRegex||this.REGEXPS.videos,this._linkDensityModifier=t.linkDensityModifier||0,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let e=function(e){if(e.nodeType==e.TEXT_NODE)return`${e.nodeName} ("${e.textContent}")`;let t=Array.from(e.attributes||[],function(e){return`${e.name}="${e.value}"`}).join(" ");return`<${e.localName} ${t}>`};this.log=function(){if("undefined"!=typeof console){let t=Array.from(arguments,t=>t&&t.nodeType==this.ELEMENT_NODE?e(t):t);t.unshift("Reader: (Readability)"),console.log(...t)}else if("undefined"!=typeof dump){var t=Array.prototype.map.call(arguments,function(t){return t&&t.nodeName?e(t):t}).join(" ");dump("Reader: (Readability) "+t+"\n")}}}else this.log=function(){}}t.prototype={FLAG_STRIP_UNLIKELYS:1,FLAG_WEIGHT_CLASSES:2,FLAG_CLEAN_CONDITIONALLY:4,ELEMENT_NODE:1,TEXT_NODE:3,DEFAULT_MAX_ELEMS_TO_PARSE:0,DEFAULT_N_TOP_CANDIDATES:5,DEFAULT_TAGS_TO_SCORE:"section,h2,h3,h4,h5,h6,p,td,pre".toUpperCase().split(","),DEFAULT_CHAR_THRESHOLD:500,REGEXPS:{unlikelyCandidates:/-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i,okMaybeItsACandidate:/and|article|body|column|content|main|shadow/i,positive:/article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i,negative:/-ad-|hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|footer|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|widget/i,extraneous:/print|archive|comment|discuss|e[\-]?mail|share|reply|all|login|sign|single|utility/i,byline:/byline|author|dateline|writtenby|p-author/i,replaceFonts:/<(\/?)font[^>]*>/gi,normalize:/\s{2,}/g,videos:/\/\/(www\.)?((dailymotion|youtube|youtube-nocookie|player\.vimeo|v\.qq)\.com|(archive|upload\.wikimedia)\.org|player\.twitch\.tv)/i,shareElements:/(\b|_)(share|sharedaddy)(\b|_)/i,nextLink:/(next|weiter|continue|>([^\|]|$)|»([^\|]|$))/i,prevLink:/(prev|earl|old|new|<|«)/i,tokenize:/\W+/g,whitespace:/^\s*$/,hasContent:/\S$/,hashUrl:/^#.+/,srcsetUrl:/(\S+)(\s+[\d.]+[xw])?(\s*(?:,|$))/g,b64DataUrl:/^data:\s*([^\s;,]+)\s*;\s*base64\s*,/i,commas:/\u002C|\u060C|\uFE50|\uFE10|\uFE11|\u2E41|\u2E34|\u2E32|\uFF0C/g,jsonLdArticleTypes:/^Article|AdvertiserContentArticle|NewsArticle|AnalysisNewsArticle|AskPublicNewsArticle|BackgroundNewsArticle|OpinionNewsArticle|ReportageNewsArticle|ReviewNewsArticle|Report|SatiricalArticle|ScholarlyArticle|MedicalScholarlyArticle|SocialMediaPosting|BlogPosting|LiveBlogPosting|DiscussionForumPosting|TechArticle|APIReference$/,adWords:/^(ad(vertising|vertisement)?|pub(licité)?|werb(ung)?|广告|Реклама|Anuncio)$/iu,loadingWords:/^((loading|正在加载|Загрузка|chargement|cargando)(…|\.\.\.)?)$/iu},UNLIKELY_ROLES:["menu","menubar","complementary","navigation","alert","alertdialog","dialog"],DIV_TO_P_ELEMS:new Set(["BLOCKQUOTE","DL","DIV","IMG","OL","P","PRE","TABLE","UL"]),ALTER_TO_DIV_EXCEPTIONS:["DIV","ARTICLE","SECTION","P","OL","UL"],PRESENTATIONAL_ATTRIBUTES:["align","background","bgcolor","border","cellpadding","cellspacing","frame","hspace","rules","style","valign","vspace"],DEPRECATED_SIZE_ATTRIBUTE_ELEMS:["TABLE","TH","TD","HR","PRE"],PHRASING_ELEMS:["ABBR","AUDIO","B","BDO","BR","BUTTON","CITE","CODE","DATA","DATALIST","DFN","EM","EMBED","I","IMG","INPUT","KBD","LABEL","MARK","MATH","METER","NOSCRIPT","OBJECT","OUTPUT","PROGRESS","Q","RUBY","SAMP","SCRIPT","SELECT","SMALL","SPAN","STRONG","SUB","SUP","TEXTAREA","TIME","VAR","WBR"],CLASSES_TO_PRESERVE:["page"],HTML_ESCAPE_MAP:{lt:"<",gt:">",amp:"&",quot:'"',apos:"'"},_postProcessContent(e){this._fixRelativeUris(e),this._simplifyNestedElements(e),this._keepClasses||this._cleanClasses(e)},_removeNodes(e,t){if(this._docJSDOMParser&&e._isLiveNodeList)throw new Error("Do not pass live node lists to _removeNodes");for(var i=e.length-1;i>=0;i--){var r=e[i],n=r.parentNode;n&&(t&&!t.call(this,r,i,e)||n.removeChild(r))}},_replaceNodeTags(e,t){if(this._docJSDOMParser&&e._isLiveNodeList)throw new Error("Do not pass live node lists to _replaceNodeTags");for(const i of e)this._setNodeTag(i,t)},_forEachNode(e,t){Array.prototype.forEach.call(e,t,this)},_findNode(e,t){return Array.prototype.find.call(e,t,this)},_someNode(e,t){return Array.prototype.some.call(e,t,this)},_everyNode(e,t){return Array.prototype.every.call(e,t,this)},_getAllNodesWithTag:(e,t)=>e.querySelectorAll?e.querySelectorAll(t.join(",")):[].concat.apply([],t.map(function(t){var i=e.getElementsByTagName(t);return Array.isArray(i)?i:Array.from(i)})),_cleanClasses(e){var t=this._classesToPreserve,i=(e.getAttribute("class")||"").split(/\s+/).filter(e=>t.includes(e)).join(" ");for(i?e.setAttribute("class",i):e.removeAttribute("class"),e=e.firstElementChild;e;e=e.nextElementSibling)this._cleanClasses(e)},_isUrl(e){try{return new URL(e),!0}catch{return!1}},_fixRelativeUris(e){var t=this._doc.baseURI,i=this._doc.documentURI;function r(e){if(t==i&&"#"==e.charAt(0))return e;try{return new URL(e,t).href}catch(e){}return e}var n=this._getAllNodesWithTag(e,["a"]);this._forEachNode(n,function(e){var t=e.getAttribute("href");if(t)if(0===t.indexOf("javascript:"))if(1===e.childNodes.length&&e.childNodes[0].nodeType===this.TEXT_NODE){var i=this._doc.createTextNode(e.textContent);e.parentNode.replaceChild(i,e)}else{for(var n=this._doc.createElement("span");e.firstChild;)n.appendChild(e.firstChild);e.parentNode.replaceChild(n,e)}else e.setAttribute("href",r(t))});var a=this._getAllNodesWithTag(e,["img","picture","figure","video","audio","source"]);this._forEachNode(a,function(e){var t=e.getAttribute("src"),i=e.getAttribute("poster"),n=e.getAttribute("srcset");if(t&&e.setAttribute("src",r(t)),i&&e.setAttribute("poster",r(i)),n){var a=n.replace(this.REGEXPS.srcsetUrl,function(e,t,i,n){return r(t)+(i||"")+n});e.setAttribute("srcset",a)}})},_simplifyNestedElements(e){for(var t=e;t;){if(t.parentNode&&["DIV","SECTION"].includes(t.tagName)&&(!t.id||!t.id.startsWith("readability"))){if(this._isElementWithoutContent(t)){t=this._removeAndGetNext(t);continue}if(this._hasSingleTagInsideElement(t,"DIV")||this._hasSingleTagInsideElement(t,"SECTION")){for(var i=t.children[0],r=0;r<t.attributes.length;r++)i.setAttributeNode(t.attributes[r].cloneNode());t.parentNode.replaceChild(i,t),t=i;continue}}t=this._getNextNode(t)}},_getArticleTitle(){var e=this._doc,t="",i="";try{"string"!=typeof(t=i=e.title.trim())&&(t=i=this._getInnerText(e.getElementsByTagName("title")[0]))}catch(e){}var r=!1;function n(e){return e.split(/\s+/).length}if(/ [\|\-\\\/>»] /.test(t)){r=/ [\\\/>»] /.test(t);let e=Array.from(i.matchAll(/ [\|\-\\\/>»] /gi));n(t=i.substring(0,e.pop().index))<3&&(t=i.replace(/^[^\|\-\\\/>»]*[\|\-\\\/>»]/gi,""))}else if(t.includes(": ")){var a=this._getAllNodesWithTag(e,["h1","h2"]),s=t.trim();this._someNode(a,function(e){return e.textContent.trim()===s})||(n(t=i.substring(i.lastIndexOf(":")+1))<3?t=i.substring(i.indexOf(":")+1):n(i.substr(0,i.indexOf(":")))>5&&(t=i))}else if(t.length>150||t.length<15){var o=e.getElementsByTagName("h1");1===o.length&&(t=this._getInnerText(o[0]))}var l=n(t=t.trim().replace(this.REGEXPS.normalize," "));return l<=4&&(!r||l!=n(i.replace(/[\|\-\\\/>»]+/g,""))-1)&&(t=i),t},_prepDocument(){var e=this._doc;this._removeNodes(this._getAllNodesWithTag(e,["style"])),e.body&&this._replaceBrs(e.body),this._replaceNodeTags(this._getAllNodesWithTag(e,["font"]),"SPAN")},_nextNode(e){for(var t=e;t&&t.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(t.textContent);)t=t.nextSibling;return t},_replaceBrs(e){this._forEachNode(this._getAllNodesWithTag(e,["br"]),function(e){for(var t=e.nextSibling,i=!1;(t=this._nextNode(t))&&"BR"==t.tagName;){i=!0;var r=t.nextSibling;t.remove(),t=r}if(i){var n=this._doc.createElement("p");for(e.parentNode.replaceChild(n,e),t=n.nextSibling;t;){if("BR"==t.tagName){var a=this._nextNode(t.nextSibling);if(a&&"BR"==a.tagName)break}if(!this._isPhrasingContent(t))break;var s=t.nextSibling;n.appendChild(t),t=s}for(;n.lastChild&&this._isWhitespace(n.lastChild);)n.lastChild.remove();"P"===n.parentNode.tagName&&this._setNodeTag(n.parentNode,"DIV")}})},_setNodeTag(e,t){if(this.log("_setNodeTag",e,t),this._docJSDOMParser)return e.localName=t.toLowerCase(),e.tagName=t.toUpperCase(),e;for(var i=e.ownerDocument.createElement(t);e.firstChild;)i.appendChild(e.firstChild);e.parentNode.replaceChild(i,e),e.readability&&(i.readability=e.readability);for(var r=0;r<e.attributes.length;r++)i.setAttributeNode(e.attributes[r].cloneNode());return i},_prepArticle(e){this._cleanStyles(e),this._markDataTables(e),this._fixLazyImages(e),this._cleanConditionally(e,"form"),this._cleanConditionally(e,"fieldset"),this._clean(e,"object"),this._clean(e,"embed"),this._clean(e,"footer"),this._clean(e,"link"),this._clean(e,"aside");var t=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(e.children,function(e){this._cleanMatchedNodes(e,function(e,i){return this.REGEXPS.shareElements.test(i)&&e.textContent.length<t})}),this._clean(e,"iframe"),this._clean(e,"input"),this._clean(e,"textarea"),this._clean(e,"select"),this._clean(e,"button"),this._cleanHeaders(e),this._cleanConditionally(e,"table"),this._cleanConditionally(e,"ul"),this._cleanConditionally(e,"div"),this._replaceNodeTags(this._getAllNodesWithTag(e,["h1"]),"h2"),this._removeNodes(this._getAllNodesWithTag(e,["p"]),function(e){return 0===this._getAllNodesWithTag(e,["img","embed","object","iframe"]).length&&!this._getInnerText(e,!1)}),this._forEachNode(this._getAllNodesWithTag(e,["br"]),function(e){var t=this._nextNode(e.nextSibling);t&&"P"==t.tagName&&e.remove()}),this._forEachNode(this._getAllNodesWithTag(e,["table"]),function(e){var t=this._hasSingleTagInsideElement(e,"TBODY")?e.firstElementChild:e;if(this._hasSingleTagInsideElement(t,"TR")){var i=t.firstElementChild;if(this._hasSingleTagInsideElement(i,"TD")){var r=i.firstElementChild;r=this._setNodeTag(r,this._everyNode(r.childNodes,this._isPhrasingContent)?"P":"DIV"),e.parentNode.replaceChild(r,e)}}})},_initializeNode(e){switch(e.readability={contentScore:0},e.tagName){case"DIV":e.readability.contentScore+=5;break;case"PRE":case"TD":case"BLOCKQUOTE":e.readability.contentScore+=3;break;case"ADDRESS":case"OL":case"UL":case"DL":case"DD":case"DT":case"LI":case"FORM":e.readability.contentScore-=3;break;case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":case"TH":e.readability.contentScore-=5}e.readability.contentScore+=this._getClassWeight(e)},_removeAndGetNext(e){var t=this._getNextNode(e,!0);return e.remove(),t},_getNextNode(e,t){if(!t&&e.firstElementChild)return e.firstElementChild;if(e.nextElementSibling)return e.nextElementSibling;do{e=e.parentNode}while(e&&!e.nextElementSibling);return e&&e.nextElementSibling},_textSimilarity(e,t){var i=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);return i.length&&r.length?1-r.filter(e=>!i.includes(e)).join(" ").length/r.join(" ").length:0},_isValidByline(e,t){var i=e.getAttribute("rel"),r=e.getAttribute("itemprop"),n=e.textContent.trim().length;return("author"===i||r&&r.includes("author")||this.REGEXPS.byline.test(t))&&!!n&&n<100},_getNodeAncestors(e,t){t=t||0;for(var i=0,r=[];e.parentNode&&(r.push(e.parentNode),!t||++i!==t);)e=e.parentNode;return r},_grabArticle(e){this.log("**** grabArticle ****");var t=this._doc,i=null!==e;if(!(e=e||this._doc.body))return this.log("No body found in document. Abort."),null;for(var r=e.innerHTML;;){this.log("Starting grabArticle loop");var n=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],s=this._doc.documentElement;let K=!0;for(;s;){"HTML"===s.tagName&&(this._articleLang=s.getAttribute("lang"));var o=s.className+" "+s.id;if(this._isProbablyVisible(s))if("true"!=s.getAttribute("aria-modal")||"dialog"!=s.getAttribute("role"))if(this._articleByline||this._metadata.byline||!this._isValidByline(s,o))if(K&&this._headerDuplicatesTitle(s))this.log("Removing header: ",s.textContent.trim(),this._articleTitle.trim()),K=!1,s=this._removeAndGetNext(s);else{if(n){if(this.REGEXPS.unlikelyCandidates.test(o)&&!this.REGEXPS.okMaybeItsACandidate.test(o)&&!this._hasAncestorTag(s,"table")&&!this._hasAncestorTag(s,"code")&&"BODY"!==s.tagName&&"A"!==s.tagName){this.log("Removing unlikely candidate - "+o),s=this._removeAndGetNext(s);continue}if(this.UNLIKELY_ROLES.includes(s.getAttribute("role"))){this.log("Removing content with role "+s.getAttribute("role")+" - "+o),s=this._removeAndGetNext(s);continue}}if("DIV"!==s.tagName&&"SECTION"!==s.tagName&&"HEADER"!==s.tagName&&"H1"!==s.tagName&&"H2"!==s.tagName&&"H3"!==s.tagName&&"H4"!==s.tagName&&"H5"!==s.tagName&&"H6"!==s.tagName||!this._isElementWithoutContent(s)){if(this.DEFAULT_TAGS_TO_SCORE.includes(s.tagName)&&a.push(s),"DIV"===s.tagName){for(var l=null,c=s.firstChild;c;){var h=c.nextSibling;if(this._isPhrasingContent(c))null!==l?l.appendChild(c):this._isWhitespace(c)||(l=t.createElement("p"),s.replaceChild(l,c),l.appendChild(c));else if(null!==l){for(;l.lastChild&&this._isWhitespace(l.lastChild);)l.lastChild.remove();l=null}c=h}if(this._hasSingleTagInsideElement(s,"P")&&this._getLinkDensity(s)<.25){var d=s.children[0];s.parentNode.replaceChild(d,s),s=d,a.push(s)}else this._hasChildBlockElement(s)||(s=this._setNodeTag(s,"P"),a.push(s))}s=this._getNextNode(s)}else s=this._removeAndGetNext(s)}else{for(var u=this._getNextNode(s,!0),g=this._getNextNode(s),p=null;g&&g!=u;){var m=g.getAttribute("itemprop");if(m&&m.includes("name")){p=g;break}g=this._getNextNode(g)}this._articleByline=(p??s).textContent.trim(),s=this._removeAndGetNext(s)}else s=this._removeAndGetNext(s);else this.log("Removing hidden node - "+o),s=this._removeAndGetNext(s)}var f=[];this._forEachNode(a,function(e){if(e.parentNode&&void 0!==e.parentNode.tagName){var t=this._getInnerText(e);if(!(t.length<25)){var i=this._getNodeAncestors(e,5);if(0!==i.length){var r=0;r+=1,r+=t.split(this.REGEXPS.commas).length,r+=Math.min(Math.floor(t.length/100),3),this._forEachNode(i,function(e,t){if(e.tagName&&e.parentNode&&void 0!==e.parentNode.tagName){if(void 0===e.readability&&(this._initializeNode(e),f.push(e)),0===t)var i=1;else i=1===t?2:3*t;e.readability.contentScore+=r/i}})}}}});for(var _=[],b=0,N=f.length;b<N;b+=1){var y=f[b],E=y.readability.contentScore*(1-this._getLinkDensity(y));y.readability.contentScore=E,this.log("Candidate:",y,"with score "+E);for(var v=0;v<this._nbTopCandidates;v++){var T=_[v];if(!T||E>T.readability.contentScore){_.splice(v,0,y),_.length>this._nbTopCandidates&&_.pop();break}}}var A,S=_[0]||null,C=!1;if(null===S||"BODY"===S.tagName){for(S=t.createElement("DIV"),C=!0;e.firstChild;)this.log("Moving child out:",e.firstChild),S.appendChild(e.firstChild);e.appendChild(S),this._initializeNode(S)}else if(S){for(var L=[],x=1;x<_.length;x++)_[x].readability.contentScore/S.readability.contentScore>=.75&&L.push(this._getNodeAncestors(_[x]));if(L.length>=3)for(A=S.parentNode;"BODY"!==A.tagName;){for(var D=0,R=0;R<L.length&&D<3;R++)D+=Number(L[R].includes(A));if(D>=3){S=A;break}A=A.parentNode}S.readability||this._initializeNode(S),A=S.parentNode;for(var w=S.readability.contentScore,O=w/3;"BODY"!==A.tagName;)if(A.readability){var I=A.readability.contentScore;if(I<O)break;if(I>w){S=A;break}w=A.readability.contentScore,A=A.parentNode}else A=A.parentNode;for(A=S.parentNode;"BODY"!=A.tagName&&1==A.children.length;)A=(S=A).parentNode;S.readability||this._initializeNode(S)}var P=t.createElement("DIV");i&&(P.id="readability-content");for(var k=Math.max(10,.2*S.readability.contentScore),B=(A=S.parentNode).children,M=0,$=B.length;M<$;M++){var H=B[M],U=!1;if(this.log("Looking at sibling node:",H,H.readability?"with score "+H.readability.contentScore:""),this.log("Sibling has score",H.readability?H.readability.contentScore:"Unknown"),H===S)U=!0;else{var G=0;if(H.className===S.className&&""!==S.className&&(G+=.2*S.readability.contentScore),H.readability&&H.readability.contentScore+G>=k)U=!0;else if("P"===H.nodeName){var j=this._getLinkDensity(H),F=this._getInnerText(H),W=F.length;(W>80&&j<.25||W<80&&W>0&&0===j&&-1!==F.search(/\.( |$)/))&&(U=!0)}}U&&(this.log("Appending node:",H),this.ALTER_TO_DIV_EXCEPTIONS.includes(H.nodeName)||(this.log("Altering sibling:",H,"to div."),H=this._setNodeTag(H,"DIV")),P.appendChild(H),B=A.children,M-=1,$-=1)}if(this._debug&&this.log("Article content pre-prep: "+P.innerHTML),this._prepArticle(P),this._debug&&this.log("Article content post-prep: "+P.innerHTML),C)S.id="readability-page-1",S.className="page";else{var V=t.createElement("DIV");for(V.id="readability-page-1",V.className="page";P.firstChild;)V.appendChild(P.firstChild);P.appendChild(V)}this._debug&&this.log("Article content after paging: "+P.innerHTML);var X=!0,Y=this._getInnerText(P,!0).length;if(Y<this._charThreshold)if(X=!1,e.innerHTML=r,this._attempts.push({articleContent:P,textLength:Y}),this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS);else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES);else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY);else{if(this._attempts.sort(function(e,t){return t.textLength-e.textLength}),!this._attempts[0].textLength)return null;P=this._attempts[0].articleContent,X=!0}if(X){var z=[A,S].concat(this._getNodeAncestors(A));return this._someNode(z,function(e){if(!e.tagName)return!1;var t=e.getAttribute("dir");return!!t&&(this._articleDir=t,!0)}),P}}},_unescapeHtmlEntities(e){if(!e)return e;var t=this.HTML_ESCAPE_MAP;return e.replace(/&(quot|amp|apos|lt|gt);/g,function(e,i){return t[i]}).replace(/&#(?:x([0-9a-f]+)|([0-9]+));/gi,function(e,t,i){var r=parseInt(t||i,t?16:10);return(0==r||r>1114111||r>=55296&&r<=57343)&&(r=65533),String.fromCodePoint(r)})},_getJSONLD(e){var t,i=this._getAllNodesWithTag(e,["script"]);return this._forEachNode(i,function(e){if(!t&&"application/ld+json"===e.getAttribute("type"))try{var i=e.textContent.replace(/^\s*<!\[CDATA\[|\]\]>\s*$/g,""),r=JSON.parse(i);if(Array.isArray(r)&&!(r=r.find(e=>e["@type"]&&e["@type"].match(this.REGEXPS.jsonLdArticleTypes))))return;var n=/^https?\:\/\/schema\.org\/?$/;if(!("string"==typeof r["@context"]&&r["@context"].match(n)||"object"==typeof r["@context"]&&"string"==typeof r["@context"]["@vocab"]&&r["@context"]["@vocab"].match(n)))return;if(!r["@type"]&&Array.isArray(r["@graph"])&&(r=r["@graph"].find(e=>(e["@type"]||"").match(this.REGEXPS.jsonLdArticleTypes))),!r||!r["@type"]||!r["@type"].match(this.REGEXPS.jsonLdArticleTypes))return;if(t={},"string"==typeof r.name&&"string"==typeof r.headline&&r.name!==r.headline){var a=this._getArticleTitle(),s=this._textSimilarity(r.name,a)>.75,o=this._textSimilarity(r.headline,a)>.75;t.title=o&&!s?r.headline:r.name}else"string"==typeof r.name?t.title=r.name.trim():"string"==typeof r.headline&&(t.title=r.headline.trim());r.author&&("string"==typeof r.author.name?t.byline=r.author.name.trim():Array.isArray(r.author)&&r.author[0]&&"string"==typeof r.author[0].name&&(t.byline=r.author.filter(function(e){return e&&"string"==typeof e.name}).map(function(e){return e.name.trim()}).join(", "))),"string"==typeof r.description&&(t.excerpt=r.description.trim()),r.publisher&&"string"==typeof r.publisher.name&&(t.siteName=r.publisher.name.trim()),"string"==typeof r.datePublished&&(t.datePublished=r.datePublished.trim())}catch(e){this.log(e.message)}}),t||{}},_getArticleMetadata(e){var t={},i={},r=this._doc.getElementsByTagName("meta"),n=/\s*(article|dc|dcterm|og|twitter)\s*:\s*(author|creator|description|published_time|title|site_name)\s*/gi,a=/^\s*(?:(dc|dcterm|og|twitter|parsely|weibo:(article|webpage))\s*[-\.:]\s*)?(author|creator|pub-date|description|title|site_name)\s*$/i;this._forEachNode(r,function(e){var t=e.getAttribute("name"),r=e.getAttribute("property"),s=e.getAttribute("content");if(s){var o=null,l=null;r&&(o=r.match(n))&&(l=o[0].toLowerCase().replace(/\s/g,""),i[l]=s.trim()),!o&&t&&a.test(t)&&(l=t,s&&(l=l.toLowerCase().replace(/\s/g,"").replace(/\./g,":"),i[l]=s.trim()))}}),t.title=e.title||i["dc:title"]||i["dcterm:title"]||i["og:title"]||i["weibo:article:title"]||i["weibo:webpage:title"]||i.title||i["twitter:title"]||i["parsely-title"],t.title||(t.title=this._getArticleTitle());const s="string"!=typeof i["article:author"]||this._isUrl(i["article:author"])?void 0:i["article:author"];return t.byline=e.byline||i["dc:creator"]||i["dcterm:creator"]||i.author||i["parsely-author"]||s,t.excerpt=e.excerpt||i["dc:description"]||i["dcterm:description"]||i["og:description"]||i["weibo:article:description"]||i["weibo:webpage:description"]||i.description||i["twitter:description"],t.siteName=e.siteName||i["og:site_name"],t.publishedTime=e.datePublished||i["article:published_time"]||i["parsely-pub-date"]||null,t.title=this._unescapeHtmlEntities(t.title),t.byline=this._unescapeHtmlEntities(t.byline),t.excerpt=this._unescapeHtmlEntities(t.excerpt),t.siteName=this._unescapeHtmlEntities(t.siteName),t.publishedTime=this._unescapeHtmlEntities(t.publishedTime),t},_isSingleImage(e){for(;e;){if("IMG"===e.tagName)return!0;if(1!==e.children.length||""!==e.textContent.trim())return!1;e=e.children[0]}return!1},_unwrapNoscriptImages(e){var t=Array.from(e.getElementsByTagName("img"));this._forEachNode(t,function(e){for(var t=0;t<e.attributes.length;t++){var i=e.attributes[t];switch(i.name){case"src":case"srcset":case"data-src":case"data-srcset":return}if(/\.(jpg|jpeg|png|webp)/i.test(i.value))return}e.remove()});var i=Array.from(e.getElementsByTagName("noscript"));this._forEachNode(i,function(t){if(this._isSingleImage(t)){var i=e.createElement("div");i.innerHTML=t.innerHTML;var r=t.previousElementSibling;if(r&&this._isSingleImage(r)){var n=r;"IMG"!==n.tagName&&(n=r.getElementsByTagName("img")[0]);for(var a=i.getElementsByTagName("img")[0],s=0;s<n.attributes.length;s++){var o=n.attributes[s];if(""!==o.value&&("src"===o.name||"srcset"===o.name||/\.(jpg|jpeg|png|webp)/i.test(o.value))){if(a.getAttribute(o.name)===o.value)continue;var l=o.name;a.hasAttribute(l)&&(l="data-old-"+l),a.setAttribute(l,o.value)}}t.parentNode.replaceChild(i.firstElementChild,r)}}})},_removeScripts(e){this._removeNodes(this._getAllNodesWithTag(e,["script","noscript"]))},_hasSingleTagInsideElement(e,t){return 1==e.children.length&&e.children[0].tagName===t&&!this._someNode(e.childNodes,function(e){return e.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(e.textContent)})},_isElementWithoutContent(e){return!(e.nodeType!==this.ELEMENT_NODE||e.textContent.trim().length||e.children.length&&e.children.length!=e.getElementsByTagName("br").length+e.getElementsByTagName("hr").length)},_hasChildBlockElement(e){return this._someNode(e.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent(e){return e.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.includes(e.tagName)||("A"===e.tagName||"DEL"===e.tagName||"INS"===e.tagName)&&this._everyNode(e.childNodes,this._isPhrasingContent)},_isWhitespace(e){return e.nodeType===this.TEXT_NODE&&0===e.textContent.trim().length||e.nodeType===this.ELEMENT_NODE&&"BR"===e.tagName},_getInnerText(e,t){t=void 0===t||t;var i=e.textContent.trim();return t?i.replace(this.REGEXPS.normalize," "):i},_getCharCount(e,t){return t=t||",",this._getInnerText(e).split(t).length-1},_cleanStyles(e){if(e&&"svg"!==e.tagName.toLowerCase()){for(var t=0;t<this.PRESENTATIONAL_ATTRIBUTES.length;t++)e.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[t]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.includes(e.tagName)&&(e.removeAttribute("width"),e.removeAttribute("height"));for(var i=e.firstElementChild;null!==i;)this._cleanStyles(i),i=i.nextElementSibling}},_getLinkDensity(e){var t=this._getInnerText(e).length;if(0===t)return 0;var i=0;return this._forEachNode(e.getElementsByTagName("a"),function(e){var t=e.getAttribute("href"),r=t&&this.REGEXPS.hashUrl.test(t)?.3:1;i+=this._getInnerText(e).length*r}),i/t},_getClassWeight(e){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var t=0;return"string"==typeof e.className&&""!==e.className&&(this.REGEXPS.negative.test(e.className)&&(t-=25),this.REGEXPS.positive.test(e.className)&&(t+=25)),"string"==typeof e.id&&""!==e.id&&(this.REGEXPS.negative.test(e.id)&&(t-=25),this.REGEXPS.positive.test(e.id)&&(t+=25)),t},_clean(e,t){var i=["object","embed","iframe"].includes(t);this._removeNodes(this._getAllNodesWithTag(e,[t]),function(e){if(i){for(var t=0;t<e.attributes.length;t++)if(this._allowedVideoRegex.test(e.attributes[t].value))return!1;if("object"===e.tagName&&this._allowedVideoRegex.test(e.innerHTML))return!1}return!0})},_hasAncestorTag(e,t,i,r){i=i||3,t=t.toUpperCase();for(var n=0;e.parentNode;){if(i>0&&n>i)return!1;if(e.parentNode.tagName===t&&(!r||r(e.parentNode)))return!0;e=e.parentNode,n++}return!1},_getRowAndColumnCount(e){for(var t=0,i=0,r=e.getElementsByTagName("tr"),n=0;n<r.length;n++){var a=r[n].getAttribute("rowspan")||0;a&&(a=parseInt(a,10)),t+=a||1;for(var s=0,o=r[n].getElementsByTagName("td"),l=0;l<o.length;l++){var c=o[l].getAttribute("colspan")||0;c&&(c=parseInt(c,10)),s+=c||1}i=Math.max(i,s)}return{rows:t,columns:i}},_markDataTables(e){for(var t=e.getElementsByTagName("table"),i=0;i<t.length;i++){var r=t[i];if("presentation"!=r.getAttribute("role"))if("0"!=r.getAttribute("datatable"))if(r.getAttribute("summary"))r._readabilityDataTable=!0;else{var n=r.getElementsByTagName("caption")[0];if(n&&n.childNodes.length)r._readabilityDataTable=!0;else{if(["col","colgroup","tfoot","thead","th"].some(function(e){return!!r.getElementsByTagName(e)[0]}))this.log("Data table because found data-y descendant"),r._readabilityDataTable=!0;else if(r.getElementsByTagName("table")[0])r._readabilityDataTable=!1;else{var a=this._getRowAndColumnCount(r);1!=a.columns&&1!=a.rows?a.rows>=10||a.columns>4?r._readabilityDataTable=!0:r._readabilityDataTable=a.rows*a.columns>10:r._readabilityDataTable=!1}}}else r._readabilityDataTable=!1;else r._readabilityDataTable=!1}},_fixLazyImages(e){this._forEachNode(this._getAllNodesWithTag(e,["img","picture","figure"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var t=this.REGEXPS.b64DataUrl.exec(e.src);if("image/svg+xml"===t[1])return;for(var i=!1,r=0;r<e.attributes.length;r++){var n=e.attributes[r];if("src"!==n.name&&/\.(jpg|jpeg|png|webp)/i.test(n.value)){i=!0;break}}if(i){var a=t[0].length;e.src.length-a<133&&e.removeAttribute("src")}}if(!(e.src||e.srcset&&"null"!=e.srcset)||e.className.toLowerCase().includes("lazy"))for(var s=0;s<e.attributes.length;s++)if("src"!==(n=e.attributes[s]).name&&"srcset"!==n.name&&"alt"!==n.name){var o=null;if(/\.(jpg|jpeg|png|webp)\s+\d/.test(n.value)?o="srcset":/^\s*\S+\.(jpg|jpeg|png|webp)\S*\s*$/.test(n.value)&&(o="src"),o)if("IMG"===e.tagName||"PICTURE"===e.tagName)e.setAttribute(o,n.value);else if("FIGURE"===e.tagName&&!this._getAllNodesWithTag(e,["img","picture"]).length){var l=this._doc.createElement("img");l.setAttribute(o,n.value),e.appendChild(l)}}})},_getTextDensity(e,t){var i=this._getInnerText(e,!0).length;if(0===i)return 0;var r=0,n=this._getAllNodesWithTag(e,t);return this._forEachNode(n,e=>r+=this._getInnerText(e,!0).length),r/i},_cleanConditionally(e,t){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(e,[t]),function(e){var i=function(e){return e._readabilityDataTable},r="ul"===t||"ol"===t;if(!r){var n=0,a=this._getAllNodesWithTag(e,["ul","ol"]);this._forEachNode(a,e=>n+=this._getInnerText(e).length),r=n/this._getInnerText(e).length>.9}if("table"===t&&i(e))return!1;if(this._hasAncestorTag(e,"table",-1,i))return!1;if(this._hasAncestorTag(e,"code"))return!1;if([...e.getElementsByTagName("table")].some(e=>e._readabilityDataTable))return!1;var s=this._getClassWeight(e);this.log("Cleaning Conditionally",e);if(s+0<0)return!0;if(this._getCharCount(e,",")<10){for(var o=e.getElementsByTagName("p").length,l=e.getElementsByTagName("img").length,c=e.getElementsByTagName("li").length-100,h=e.getElementsByTagName("input").length,d=this._getTextDensity(e,["h1","h2","h3","h4","h5","h6"]),u=0,g=this._getAllNodesWithTag(e,["object","embed","iframe"]),p=0;p<g.length;p++){for(var m=0;m<g[p].attributes.length;m++)if(this._allowedVideoRegex.test(g[p].attributes[m].value))return!1;if("object"===g[p].tagName&&this._allowedVideoRegex.test(g[p].innerHTML))return!1;u++}var f=this._getInnerText(e);if(this.REGEXPS.adWords.test(f)||this.REGEXPS.loadingWords.test(f))return!0;var _=f.length,b=this._getLinkDensity(e),N=["SPAN","LI","TD"].concat(Array.from(this.DIV_TO_P_ELEMS)),y=this._getTextDensity(e,N),E=this._hasAncestorTag(e,"figure");var v=(()=>{const e=[];return!E&&l>1&&o/l<.5&&e.push(`Bad p to img ratio (img=${l}, p=${o})`),!r&&c>o&&e.push(`Too many li's outside of a list. (li=${c} > p=${o})`),h>Math.floor(o/3)&&e.push(`Too many inputs per p. (input=${h}, p=${o})`),!r&&!E&&d<.9&&_<25&&(0===l||l>2)&&b>0&&e.push(`Suspiciously short. (headingDensity=${d}, img=${l}, linkDensity=${b})`),!r&&s<25&&b>.2+this._linkDensityModifier&&e.push(`Low weight and a little linky. (linkDensity=${b})`),s>=25&&b>.5+this._linkDensityModifier&&e.push(`High weight and mostly links. (linkDensity=${b})`),(1===u&&_<75||u>1)&&e.push(`Suspicious embed. (embedCount=${u}, contentLength=${_})`),0===l&&0===y&&e.push(`No useful content. (img=${l}, textDensity=${y})`),!!e.length&&(this.log("Checks failed",e),!0)})();if(r&&v){for(var T=0;T<e.children.length;T++){if(e.children[T].children.length>1)return v}let t=e.getElementsByTagName("li").length;if(l==t)return!1}return v}return!1})},_cleanMatchedNodes(e,t){for(var i=this._getNextNode(e,!0),r=this._getNextNode(e);r&&r!=i;)r=t.call(this,r,r.className+" "+r.id)?this._removeAndGetNext(r):this._getNextNode(r)},_cleanHeaders(e){let t=this._getAllNodesWithTag(e,["h1","h2"]);this._removeNodes(t,function(e){let t=this._getClassWeight(e)<0;return t&&this.log("Removing header with low class weight:",e),t})},_headerDuplicatesTitle(e){if("H1"!=e.tagName&&"H2"!=e.tagName)return!1;var t=this._getInnerText(e,!1);return this.log("Evaluating similarity of header:",t,this._articleTitle),this._textSimilarity(this._articleTitle,t)>.75},_flagIsActive(e){return(this._flags&e)>0},_removeFlag(e){this._flags=this._flags&~e},_isProbablyVisible:e=>(!e.style||"none"!=e.style.display)&&(!e.style||"hidden"!=e.style.visibility)&&!e.hasAttribute("hidden")&&(!e.hasAttribute("aria-hidden")||"true"!=e.getAttribute("aria-hidden")||e.className&&e.className.includes&&e.className.includes("fallback-image")),parse(){if(this._maxElemsToParse>0){var e=this._doc.getElementsByTagName("*").length;if(e>this._maxElemsToParse)throw new Error("Aborting parsing document; "+e+" elements found")}this._unwrapNoscriptImages(this._doc);var t=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(t);this._metadata=i,this._articleTitle=i.title;var r=this._grabArticle();if(!r)return null;if(this.log("Grabbed: "+r.innerHTML),this._postProcessContent(r),!i.excerpt){var n=r.getElementsByTagName("p");n.length&&(i.excerpt=n[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName,publishedTime:i.publishedTime}}},e.exports=t},396:(e,t,i)=>{var r=i(238),n=i(804);e.exports={Readability:r,isProbablyReaderable:n}},481:e=>{e.exports=function(e,t){(t=t||{}).listUnicodeChar=!!t.hasOwnProperty("listUnicodeChar")&&t.listUnicodeChar,t.stripListLeaders=!t.hasOwnProperty("stripListLeaders")||t.stripListLeaders,t.gfm=!t.hasOwnProperty("gfm")||t.gfm,t.useImgAltText=!t.hasOwnProperty("useImgAltText")||t.useImgAltText,t.abbr=!!t.hasOwnProperty("abbr")&&t.abbr,t.replaceLinksWithURL=!!t.hasOwnProperty("replaceLinksWithURL")&&t.replaceLinksWithURL,t.htmlTagsToSkip=t.hasOwnProperty("htmlTagsToSkip")?t.htmlTagsToSkip:[],t.throwError=!!t.hasOwnProperty("throwError")&&t.throwError;var i=e||"";i=i.replace(/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/gm,"");try{t.stripListLeaders&&(i=t.listUnicodeChar?i.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,t.listUnicodeChar+" $1"):i.replace(/^([\s\t]*)([\*\-\+]|\d+\.)\s+/gm,"$1")),t.gfm&&(i=i.replace(/\n={2,}/g,"\n").replace(/~{3}.*\n/g,"").replace(/~~/g,"").replace(/```(?:.*)\n([\s\S]*?)```/g,(e,t)=>t.trim())),t.abbr&&(i=i.replace(/\*\[.*\]:.*\n/,""));let e=/<[^>]*>/g;if(t.htmlTagsToSkip&&t.htmlTagsToSkip.length>0){const i=t.htmlTagsToSkip.join("|");e=new RegExp(`<(?!/?(${i})(?=>|s[^>]*>))[^>]*>`,"g")}i=i.replace(e,"").replace(/^[=\-]{2,}\s*$/g,"").replace(/\[\^.+?\](\: .*?$)?/g,"").replace(/\s{0,2}\[.*?\]: .*?$/g,"").replace(/\!\[(.*?)\][\[\(].*?[\]\)]/g,t.useImgAltText?"$1":"").replace(/\[([\s\S]*?)\]\s*[\(\[].*?[\)\]]/g,t.replaceLinksWithURL?"$2":"$1").replace(/^(\n)?\s{0,3}>\s?/gm,"$1").replace(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/g,"").replace(/^(\n)?\s{0,}#{1,6}\s*( (.+))? +#+$|^(\n)?\s{0,}#{1,6}\s*( (.+))?$/gm,"$1$3$4$6").replace(/([\*]+)(\S)(.*?\S)??\1/g,"$2$3").replace(/(^|\W)([_]+)(\S)(.*?\S)??\2($|\W)/g,"$1$3$4$5").replace(/(`{3,})(.*?)\1/gm,"$2").replace(/`(.+?)`/g,"$1").replace(/~(.*?)~/g,"$1")}catch(i){if(t.throwError)throw i;return console.error("remove-markdown encountered error: %s",i),e}return i}},804:e=>{var t={unlikelyCandidates:/-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i,okMaybeItsACandidate:/and|article|body|column|content|main|shadow/i};function i(e){return(!e.style||"none"!=e.style.display)&&!e.hasAttribute("hidden")&&(!e.hasAttribute("aria-hidden")||"true"!=e.getAttribute("aria-hidden")||e.className&&e.className.includes&&e.className.includes("fallback-image"))}e.exports=function(e,r={}){"function"==typeof r&&(r={visibilityChecker:r});var n={minScore:20,minContentLength:140,visibilityChecker:i};r=Object.assign(n,r);var a=e.querySelectorAll("p, pre, article"),s=e.querySelectorAll("div > br");if(s.length){var o=new Set(a);[].forEach.call(s,function(e){o.add(e.parentNode)}),a=Array.from(o)}var l=0;return[].some.call(a,function(e){if(!r.visibilityChecker(e))return!1;var i=e.className+" "+e.id;if(t.unlikelyCandidates.test(i)&&!t.okMaybeItsACandidate.test(i))return!1;if(e.matches("li p"))return!1;var n=e.textContent.trim().length;return!(n<r.minContentLength)&&(l+=Math.sqrt(n-r.minContentLength))>r.minScore})}}},t={};function i(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";i.r(r),i.d(r,{parseFullMarkdown:()=>W,parseReaderable:()=>V});var e=i(396);function t(e,t){return Array(t+1).join(e)}function n(e){return e.replace(/^\n*/,"")}function a(e){for(var t=e.length;t>0&&"\n"===e[t-1];)t--;return e.substring(0,t)}function s(e){return a(n(e))}var o=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function l(e){return u(e,o)}var c=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function h(e){return u(e,c)}var d=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function u(e,t){return t.indexOf(e.nodeName)>=0}function g(e,t){return e.getElementsByTagName&&t.some(function(t){return e.getElementsByTagName(t).length})}var p={};function m(e){return e?e.replace(/(\n+\s*)+/g,"\n"):""}function f(e){for(var t in this.options=e,this._keep=[],this._remove=[],this.blankRule={replacement:e.blankReplacement},this.keepReplacement=e.keepReplacement,this.defaultRule={replacement:e.defaultReplacement},this.array=[],e.rules)this.array.push(e.rules[t])}function _(e,t,i){for(var r=0;r<e.length;r++){var n=e[r];if(b(n,t,i))return n}}function b(e,t,i){var r=e.filter;if("string"==typeof r){if(r===t.nodeName.toLowerCase())return!0}else if(Array.isArray(r)){if(r.indexOf(t.nodeName.toLowerCase())>-1)return!0}else{if("function"!=typeof r)throw new TypeError("`filter` needs to be a string, array, or function");if(r.call(e,t,i))return!0}}function N(e){var t=e.nextSibling||e.parentNode;return e.parentNode.removeChild(e),t}function y(e,t,i){return e&&e.parentNode===t||i(t)?t.nextSibling||t.parentNode:t.firstChild||t.nextSibling||t.parentNode}p.paragraph={filter:"p",replacement:function(e){return"\n\n"+e+"\n\n"}},p.lineBreak={filter:"br",replacement:function(e,t,i){return i.br+"\n"}},p.heading={filter:["h1","h2","h3","h4","h5","h6"],replacement:function(e,i,r){var n=Number(i.nodeName.charAt(1));return"setext"===r.headingStyle&&n<3?"\n\n"+e+"\n"+t(1===n?"=":"-",e.length)+"\n\n":"\n\n"+t("#",n)+" "+e+"\n\n"}},p.blockquote={filter:"blockquote",replacement:function(e){return"\n\n"+(e=s(e).replace(/^/gm,"> "))+"\n\n"}},p.list={filter:["ul","ol"],replacement:function(e,t){var i=t.parentNode;return"LI"===i.nodeName&&i.lastElementChild===t?"\n"+e:"\n\n"+e+"\n\n"}},p.listItem={filter:"li",replacement:function(e,t,i){var r=i.bulletListMarker+" ",n=t.parentNode;if("OL"===n.nodeName){var a=n.getAttribute("start"),o=Array.prototype.indexOf.call(n.children,t);r=(a?Number(a)+o:o+1)+". "}var l=/\n$/.test(e);return r+(e=(e=s(e)+(l?"\n":"")).replace(/\n/gm,"\n"+" ".repeat(r.length)))+(t.nextSibling?"\n":"")}},p.indentedCodeBlock={filter:function(e,t){return"indented"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,t,i){return"\n\n "+t.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},p.fencedCodeBlock={filter:function(e,t){return"fenced"===t.codeBlockStyle&&"PRE"===e.nodeName&&e.firstChild&&"CODE"===e.firstChild.nodeName},replacement:function(e,i,r){for(var n,a=((i.firstChild.getAttribute("class")||"").match(/language-(\S+)/)||[null,""])[1],s=i.firstChild.textContent,o=r.fence.charAt(0),l=3,c=new RegExp("^"+o+"{3,}","gm");n=c.exec(s);)n[0].length>=l&&(l=n[0].length+1);var h=t(o,l);return"\n\n"+h+a+"\n"+s.replace(/\n$/,"")+"\n"+h+"\n\n"}},p.horizontalRule={filter:"hr",replacement:function(e,t,i){return"\n\n"+i.hr+"\n\n"}},p.inlineLink={filter:function(e,t){return"inlined"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t){var i=t.getAttribute("href");i&&(i=i.replace(/([()])/g,"\\$1"));var r=m(t.getAttribute("title"));return r&&(r=' "'+r.replace(/"/g,'\\"')+'"'),"["+e+"]("+i+r+")"}},p.referenceLink={filter:function(e,t){return"referenced"===t.linkStyle&&"A"===e.nodeName&&e.getAttribute("href")},replacement:function(e,t,i){var r,n,a=t.getAttribute("href"),s=m(t.getAttribute("title"));switch(s&&(s=' "'+s+'"'),i.linkReferenceStyle){case"collapsed":r="["+e+"][]",n="["+e+"]: "+a+s;break;case"shortcut":r="["+e+"]",n="["+e+"]: "+a+s;break;default:var o=this.references.length+1;r="["+e+"]["+o+"]",n="["+o+"]: "+a+s}return this.references.push(n),r},references:[],append:function(e){var t="";return this.references.length&&(t="\n\n"+this.references.join("\n")+"\n\n",this.references=[]),t}},p.emphasis={filter:["em","i"],replacement:function(e,t,i){return e.trim()?i.emDelimiter+e+i.emDelimiter:""}},p.strong={filter:["strong","b"],replacement:function(e,t,i){return e.trim()?i.strongDelimiter+e+i.strongDelimiter:""}},p.code={filter:function(e){var t=e.previousSibling||e.nextSibling,i="PRE"===e.parentNode.nodeName&&!t;return"CODE"===e.nodeName&&!i},replacement:function(e){if(!e)return"";e=e.replace(/\r?\n|\r/g," ");for(var t=/^`|^ .*?[^ ].* $|`$/.test(e)?" ":"",i="`",r=e.match(/`+/gm)||[];-1!==r.indexOf(i);)i+="`";return i+t+e+t+i}},p.image={filter:"img",replacement:function(e,t){var i=m(t.getAttribute("alt")),r=t.getAttribute("src")||"",n=m(t.getAttribute("title"));return r?"+")":""}},f.prototype={add:function(e,t){this.array.unshift(t)},keep:function(e){this._keep.unshift({filter:e,replacement:this.keepReplacement})},remove:function(e){this._remove.unshift({filter:e,replacement:function(){return""}})},forNode:function(e){return e.isBlank?this.blankRule:(t=_(this.array,e,this.options))||(t=_(this._keep,e,this.options))||(t=_(this._remove,e,this.options))?t:this.defaultRule;var t},forEach:function(e){for(var t=0;t<this.array.length;t++)e(this.array[t],t)}};var E="undefined"!=typeof window?window:{};var v,T,A=function(){var e=E.DOMParser,t=!1;try{(new e).parseFromString("","text/html")&&(t=!0)}catch(e){}return t}()?E.DOMParser:(v=function(){},function(){var e=!1;try{document.implementation.createHTMLDocument("").open()}catch(t){E.ActiveXObject&&(e=!0)}return e}()?v.prototype.parseFromString=function(e){var t=new window.ActiveXObject("htmlfile");return t.designMode="on",t.open(),t.write(e),t.close(),t}:v.prototype.parseFromString=function(e){var t=document.implementation.createHTMLDocument("");return t.open(),t.write(e),t.close(),t},v);function S(e,t){var i;"string"==typeof e?i=(T=T||new A).parseFromString('<x-turndown id="turndown-root">'+e+"</x-turndown>","text/html").getElementById("turndown-root"):i=e.cloneNode(!0);return function(e){var t=e.element,i=e.isBlock,r=e.isVoid,n=e.isPre||function(e){return"PRE"===e.nodeName};if(t.firstChild&&!n(t)){for(var a=null,s=!1,o=null,l=y(o,t,n);l!==t;){if(3===l.nodeType||4===l.nodeType){var c=l.data.replace(/[ \r\n\t]+/g," ");if(a&&!/ $/.test(a.data)||s||" "!==c[0]||(c=c.substr(1)),!c){l=N(l);continue}l.data=c,a=l}else{if(1!==l.nodeType){l=N(l);continue}i(l)||"BR"===l.nodeName?(a&&(a.data=a.data.replace(/ $/,"")),a=null,s=!1):r(l)||n(l)?(a=null,s=!0):a&&(s=!1)}var h=y(o,l,n);o=l,l=h}a&&(a.data=a.data.replace(/ $/,""),a.data||N(a))}}({element:i,isBlock:l,isVoid:h,isPre:t.preformattedCode?C:null}),i}function C(e){return"PRE"===e.nodeName||"CODE"===e.nodeName}function L(e,t){return e.isBlock=l(e),e.isCode="CODE"===e.nodeName||e.parentNode.isCode,e.isBlank=function(e){return!h(e)&&!function(e){return u(e,d)}(e)&&/^\s*$/i.test(e.textContent)&&!function(e){return g(e,c)}(e)&&!function(e){return g(e,d)}(e)}(e),e.flankingWhitespace=function(e,t){if(e.isBlock||t.preformattedCode&&e.isCode)return{leading:"",trailing:""};var i=(r=e.textContent,n=r.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/),{leading:n[1],leadingAscii:n[2],leadingNonAscii:n[3],trailing:n[4],trailingNonAscii:n[5],trailingAscii:n[6]});var r,n;i.leadingAscii&&x("left",e,t)&&(i.leading=i.leadingNonAscii);i.trailingAscii&&x("right",e,t)&&(i.trailing=i.trailingNonAscii);return{leading:i.leading,trailing:i.trailing}}(e,t),e}function x(e,t,i){var r,n,a;return"left"===e?(r=t.previousSibling,n=/ $/):(r=t.nextSibling,n=/^ /),r&&(3===r.nodeType?a=n.test(r.nodeValue):i.preformattedCode&&"CODE"===r.nodeName?a=!1:1!==r.nodeType||l(r)||(a=n.test(r.textContent))),a}var D=Array.prototype.reduce,R=[[/\\/g,"\\\\"],[/\*/g,"\\*"],[/^-/g,"\\-"],[/^\+ /g,"\\+ "],[/^(=+)/g,"\\$1"],[/^(#{1,6}) /g,"\\$1 "],[/`/g,"\\`"],[/^~~~/g,"\\~~~"],[/\[/g,"\\["],[/\]/g,"\\]"],[/^>/g,"\\>"],[/_/g,"\\_"],[/^(\d+)\. /g,"$1\\. "]];function w(e){if(!(this instanceof w))return new w(e);var t={rules:p,headingStyle:"setext",hr:"* * *",bulletListMarker:"*",codeBlockStyle:"indented",fence:"```",emDelimiter:"_",strongDelimiter:"**",linkStyle:"inlined",linkReferenceStyle:"full",br:" ",preformattedCode:!1,blankReplacement:function(e,t){return t.isBlock?"\n\n":""},keepReplacement:function(e,t){return t.isBlock?"\n\n"+t.outerHTML+"\n\n":t.outerHTML},defaultReplacement:function(e,t){return t.isBlock?"\n\n"+e+"\n\n":e}};this.options=function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}({},t,e),this.rules=new f(this.options)}function O(e){var t=this;return D.call(e.childNodes,function(e,i){var r="";return 3===(i=new L(i,t.options)).nodeType?r=i.isCode?i.nodeValue:t.escape(i.nodeValue):1===i.nodeType&&(r=P.call(t,i)),k(e,r)},"")}function I(e){var t=this;return this.rules.forEach(function(i){"function"==typeof i.append&&(e=k(e,i.append(t.options)))}),e.replace(/^[\t\r\n]+/,"").replace(/[\t\r\n\s]+$/,"")}function P(e){var t=this.rules.forNode(e),i=O.call(this,e),r=e.flankingWhitespace;return(r.leading||r.trailing)&&(i=i.trim()),r.leading+t.replacement(i,e,this.options)+r.trailing}function k(e,t){var i=a(e),r=n(t),s=Math.max(e.length-i.length,t.length-r.length);return i+"\n\n".substring(0,s)+r}w.prototype={turndown:function(e){if(!function(e){return null!=e&&("string"==typeof e||e.nodeType&&(1===e.nodeType||9===e.nodeType||11===e.nodeType))}(e))throw new TypeError(e+" is not a string, or an element/document/fragment node.");if(""===e)return"";var t=O.call(this,new S(e,this.options));return I.call(this,t)},use:function(e){if(Array.isArray(e))for(var t=0;t<e.length;t++)this.use(e[t]);else{if("function"!=typeof e)throw new TypeError("plugin must be a Function or an Array of Functions");e(this)}return this},addRule:function(e,t){return this.rules.add(e,t),this},keep:function(e){return this.rules.keep(e),this},remove:function(e){return this.rules.remove(e),this},escape:function(e){return R.reduce(function(e,t){return e.replace(t[0],t[1])},e)}};const B=w;function M(e){return M="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},M(e)}function $(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,r)}return i}function H(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?$(Object(i),!0).forEach(function(t){U(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):$(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function U(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=M(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=M(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==M(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var G=i(481),j=new B;function F(e,t){return t.forEach(function(t){e.querySelectorAll(t).forEach(function(e){return e.remove()})}),e}function W(e){var t=e.cloneNode(!0);F(t,["nav","footer","header","aside","menu","toolbar","form","button",'[role="button"]','[type="button"]',"dialog","modal",'[aria-hidden="true"]',"[hidden]",'[style*="display: none"]','[style*="visibility: hidden"]',".hidden",".invisible",".ad",".advertisement",".banner",".sponsored",".promotion",".popup",".newsletter",".subscribe",".social-share",".social-media",".share-buttons",".follow-us",".likes",".comments",".cookie-notice",".cookie-banner",".modal",".overlay",".tooltip",".popup",".sidebar",".widget",".breadcrumb",".pagination",".menu",".navbar",".navigation",".related-posts",".recommended",".suggestions",".read-more",".search",".search-box",".login",".signup",".register",".print-only",'[media="print"]']);var i=j.turndown(t.body.innerHTML);return{fullContentMarkdown:i,fullContentPlain:G(i)}}function V(t,i){var r=t.cloneNode(!0);F(r,["script","style","noscript","iframe","svg","img","video","audio","canvas","object","embed"]);var n=W(r),a=(0,e.isProbablyReaderable)(r),s=new e.Readability(r,i).parse();if(null!=s){var o=j.turndown(s.content);n=H(H({},n),{},{isProbablyReaderable:a?1:0,extractedContentMarkdown:o,extractedContentPlain:G(o)})}return n}window.parseReaderable=V,window.parseFullMarkdown=W})(),r})()); |