defuddle 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mathml-to-latex"),require("temml")):"function"==typeof define&&define.amd?define(["mathml-to-latex","temml"],e):"object"==typeof exports?exports.Defuddle=e(require("mathml-to-latex"),require("temml")):t.Defuddle=e(t["mathml-to-latex"],t.temml)}("undefined"!=typeof self?self:this,((t,e)=>(()=>{"use strict";var r={181:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ConversationExtractor=void 0;const o=r(279),n=r(628);class i extends o.BaseExtractor{getFootnotes(){return[]}extract(){var t;const e=this.extractMessages(),r=this.getMetadata(),o=this.getFootnotes(),i=this.createContentHtml(e,o),a=document.implementation.createHTMLDocument(),s=a.createElement("article");s.innerHTML=i,a.body.appendChild(s);const l=new n.Defuddle(a).parse(),c=l.content;return{content:c,contentHtml:c,extractedContent:{messageCount:e.length.toString()},variables:{title:r.title||"Conversation",site:r.site,description:r.description||`${r.site} conversation with ${e.length} messages`,wordCount:(null===(t=l.wordCount)||void 0===t?void 0:t.toString())||""}}}createContentHtml(t,e){return`${t.map(((e,r)=>{const o=e.timestamp?`<div class="message-timestamp">${e.timestamp}</div>`:"",n=/<p[^>]*>[\s\S]*?<\/p>/i.test(e.content)?e.content:`<p>${e.content}</p>`,i=e.metadata?Object.entries(e.metadata).map((([t,e])=>`data-${t}="${e}"`)).join(" "):"";return`\n\t\t\t<div class="message message-${e.author.toLowerCase()}" ${i}>\n\t\t\t\t<div class="message-header">\n\t\t\t\t\t<p class="message-author"><strong>${e.author}</strong></p>\n\t\t\t\t\t${o}\n\t\t\t\t</div>\n\t\t\t\t<div class="message-content">\n\t\t\t\t\t${n}\n\t\t\t\t</div>\n\t\t\t</div>${r<t.length-1?"\n<hr>":""}`})).join("\n").trim()}\n${e.length>0?`\n\t\t\t<div id="footnotes">\n\t\t\t\t<ol>\n\t\t\t\t\t${e.map(((t,e)=>`\n\t\t\t\t\t\t<li class="footnote" id="fn:${e+1}">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t<a href="${t.url}" target="_blank">${t.text}</a>&nbsp;<a href="#fnref:${e+1}" class="footnote-backref">\u21a9</a>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t`)).join("")}\n\t\t\t\t</ol>\n\t\t\t</div>`:""}`.trim()}}e.ConversationExtractor=i},248:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TwitterExtractor=void 0;const o=r(279);class n extends o.BaseExtractor{constructor(t,e){var r;super(t,e),this.mainTweet=null,this.threadTweets=[];const o=t.querySelector('[aria-label="Timeline: Conversation"]');if(!o){const e=t.querySelector('article[data-testid="tweet"]');return void(e&&(this.mainTweet=e))}const n=Array.from(o.querySelectorAll('article[data-testid="tweet"]')),i=null===(r=o.querySelector("section, h2"))||void 0===r?void 0:r.parentElement;i&&n.forEach(((t,e)=>{if(i.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)return n.splice(e),!1})),this.mainTweet=n[0]||null,this.threadTweets=n.slice(1)}canExtract(){return!!this.mainTweet}extract(){const t=this.extractTweet(this.mainTweet),e=this.threadTweets.map((t=>this.extractTweet(t))).join("\n<hr>\n"),r=`\n\t\t\t<div class="tweet-thread">\n\t\t\t\t<div class="main-tweet">\n\t\t\t\t\t${t}\n\t\t\t\t</div>\n\t\t\t\t${e?`\n\t\t\t\t\t<hr>\n\t\t\t\t\t<div class="thread-tweets">\n\t\t\t\t\t\t${e}\n\t\t\t\t\t</div>\n\t\t\t\t`:""}\n\t\t\t</div>\n\t\t`.trim(),o=this.getTweetId(),n=this.getTweetAuthor();return{content:r,contentHtml:r,extractedContent:{tweetId:o,tweetAuthor:n},variables:{title:`Thread by ${n}`,author:n,site:"X (Twitter)",description:this.createDescription(this.mainTweet)}}}formatTweetText(t){if(!t)return"";const e=document.createElement("div");e.innerHTML=t,e.querySelectorAll("a").forEach((t=>{var e;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";t.replaceWith(r)})),e.querySelectorAll("span, div").forEach((t=>{t.replaceWith(...Array.from(t.childNodes))}));return e.innerHTML.split("\n").map((t=>t.trim())).filter((t=>t)).map((t=>`<p>${t}</p>`)).join("\n")}extractTweet(t){var e,r,o;if(!t)return"";const n=t.cloneNode(!0);n.querySelectorAll('img[src*="/emoji/"]').forEach((t=>{if("img"===t.tagName.toLowerCase()&&t.getAttribute("alt")){const e=t.getAttribute("alt");e&&t.replaceWith(e)}}));const i=(null===(e=n.querySelector('[data-testid="tweetText"]'))||void 0===e?void 0:e.innerHTML)||"",a=this.formatTweetText(i),s=this.extractImages(t),l=this.extractUserInfo(t),c=null===(o=null===(r=t.querySelector('[aria-labelledby*="id__"]'))||void 0===r?void 0:r.querySelector('[data-testid="User-Name"]'))||void 0===o?void 0:o.closest('[aria-labelledby*="id__"]'),d=c?this.extractTweet(c):"";return`\n\t\t\t<div class="tweet">\n\t\t\t\t<div class="tweet-header">\n\t\t\t\t\t<span class="tweet-author"><strong>${l.fullName}</strong> <span class="tweet-handle">${l.handle}</span></span>\n\t\t\t\t\t${l.date?`<a href="${l.permalink}" class="tweet-date">${l.date}</a>`:""}\n\t\t\t\t</div>\n\t\t\t\t${a?`<div class="tweet-text">${a}</div>`:""}\n\t\t\t\t${s.length?`\n\t\t\t\t\t<div class="tweet-media">\n\t\t\t\t\t\t${s.join("\n")}\n\t\t\t\t\t</div>\n\t\t\t\t`:""}\n\t\t\t\t${d?`\n\t\t\t\t\t<blockquote class="quoted-tweet">\n\t\t\t\t\t\t${d}\n\t\t\t\t\t</blockquote>\n\t\t\t\t`:""}\n\t\t\t</div>\n\t\t`.trim()}extractUserInfo(t){var e,r,o,n,i,a,s,l,c;const d=t.querySelector('[data-testid="User-Name"]');if(!d)return{fullName:"",handle:"",date:"",permalink:""};const u=d.querySelectorAll("a");let m=(null===(r=null===(e=null==u?void 0:u[0])||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",h=(null===(n=null===(o=null==u?void 0:u[1])||void 0===o?void 0:o.textContent)||void 0===n?void 0:n.trim())||"";m&&h||(m=(null===(a=null===(i=d.querySelector('span[style*="color: rgb(15, 20, 25)"] span'))||void 0===i?void 0:i.textContent)||void 0===a?void 0:a.trim())||"",h=(null===(l=null===(s=d.querySelector('span[style*="color: rgb(83, 100, 113)"]'))||void 0===s?void 0:s.textContent)||void 0===l?void 0:l.trim())||"");const p=t.querySelector("time"),g=(null==p?void 0:p.getAttribute("datetime"))||"";return{fullName:m,handle:h,date:g?new Date(g).toISOString().split("T")[0]:"",permalink:(null===(c=null==p?void 0:p.closest("a"))||void 0===c?void 0:c.href)||""}}extractImages(t){var e,r;const o=['[data-testid="tweetPhoto"]','[data-testid="tweet-image"]','img[src*="media"]'],n=[],i=null===(r=null===(e=t.querySelector('[aria-labelledby*="id__"]'))||void 0===e?void 0:e.querySelector('[data-testid="User-Name"]'))||void 0===r?void 0:r.closest('[aria-labelledby*="id__"]');for(const e of o){t.querySelectorAll(e).forEach((t=>{var e,r;if(!(null==i?void 0:i.contains(t))&&"img"===t.tagName.toLowerCase()&&t.getAttribute("alt")){const o=(null===(e=t.getAttribute("src"))||void 0===e?void 0:e.replace(/&name=\w+$/,"&name=large"))||"",i=(null===(r=t.getAttribute("alt"))||void 0===r?void 0:r.replace(/\s+/g," ").trim())||"";n.push(`<img src="${o}" alt="${i}" />`)}}))}return n}getTweetId(){const t=this.url.match(/status\/(\d+)/);return(null==t?void 0:t[1])||""}getTweetAuthor(){var t,e,r;const o=null===(t=this.mainTweet)||void 0===t?void 0:t.querySelector('[data-testid="User-Name"]'),n=null==o?void 0:o.querySelectorAll("a"),i=(null===(r=null===(e=null==n?void 0:n[1])||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"";return i.startsWith("@")?i:`@${i}`}createDescription(t){var e;if(!t)return"";return((null===(e=t.querySelector('[data-testid="tweetText"]'))||void 0===e?void 0:e.textContent)||"").trim().slice(0,140).replace(/\s+/g," ")}}e.TwitterExtractor=n},258:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.YoutubeExtractor=void 0;const o=r(279);class n extends o.BaseExtractor{constructor(t,e,r){super(t,e,r),this.videoElement=t.querySelector("video"),this.schemaOrgData=r}canExtract(){return!0}extract(){const t=this.getVideoData(),e=t.description||"",r=this.formatDescription(e),o=`<iframe width="560" height="315" src="https://www.youtube.com/embed/${this.getVideoId()}?si=_m0qv33lAuJFoGNh" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br>${r}`;return{content:o,contentHtml:o,extractedContent:{videoId:this.getVideoId(),author:t.author||""},variables:{title:t.name||"",author:t.author||"",site:"YouTube",image:Array.isArray(t.thumbnailUrl)&&t.thumbnailUrl[0]||"",published:t.uploadDate,description:e.slice(0,200).trim()}}}formatDescription(t){return`<p>${t.replace(/\n/g,"<br>")}</p>`}getVideoData(){if(!this.schemaOrgData)return{};return(Array.isArray(this.schemaOrgData)?this.schemaOrgData.find((t=>"VideoObject"===t["@type"])):"VideoObject"===this.schemaOrgData["@type"]?this.schemaOrgData:null)||{}}getVideoId(){return new URLSearchParams(new URL(this.url).search).get("v")||""}}e.YoutubeExtractor=n},279:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseExtractor=void 0;e.BaseExtractor=class{constructor(t,e,r){this.document=t,this.url=e,this.schemaOrgData=r}}},282:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mathSelectors=e.isBlockDisplay=e.getBasicLatexFromElement=e.getMathMLFromElement=void 0;e.getMathMLFromElement=t=>{if("math"===t.tagName.toLowerCase()){const e="block"===t.getAttribute("display");return{mathml:t.outerHTML,latex:t.getAttribute("alttext")||null,isBlock:e}}const e=t.getAttribute("data-mathml");if(e){const t=document.createElement("div");t.innerHTML=e;const r=t.querySelector("math");if(r){const t="block"===r.getAttribute("display");return{mathml:r.outerHTML,latex:r.getAttribute("alttext")||null,isBlock:t}}}const r=t.querySelector(".MJX_Assistive_MathML, mjx-assistive-mml");if(r){const t=r.querySelector("math");if(t){const e=t.getAttribute("display"),o=r.getAttribute("display"),n="block"===e||"block"===o;return{mathml:t.outerHTML,latex:t.getAttribute("alttext")||null,isBlock:n}}}const o=t.querySelector(".katex-mathml math");return o?{mathml:o.outerHTML,latex:null,isBlock:!1}:null};e.getBasicLatexFromElement=t=>{var e,r,o;const n=t.getAttribute("data-latex");if(n)return n;if("img"===t.tagName.toLowerCase()&&t.classList.contains("latex")){const e=t.getAttribute("alt");if(e)return e;const r=t.getAttribute("src");if(r){const t=r.match(/latex\.php\?latex=([^&]+)/);if(t)return decodeURIComponent(t[1]).replace(/\+/g," ").replace(/%5C/g,"\\")}}const i=t.querySelector('annotation[encoding="application/x-tex"]');if(null==i?void 0:i.textContent)return i.textContent.trim();if(t.matches(".katex")){const e=t.querySelector('.katex-mathml annotation[encoding="application/x-tex"]');if(null==e?void 0:e.textContent)return e.textContent.trim()}if(t.matches('script[type="math/tex"]')||t.matches('script[type="math/tex; mode=display"]'))return(null===(e=t.textContent)||void 0===e?void 0:e.trim())||null;if(t.parentElement){const e=t.parentElement.querySelector('script[type="math/tex"], script[type="math/tex; mode=display"]');if(e)return(null===(r=e.textContent)||void 0===r?void 0:r.trim())||null}return t.getAttribute("alt")||(null===(o=t.textContent)||void 0===o?void 0:o.trim())||null};e.isBlockDisplay=t=>{if("block"===t.getAttribute("display"))return!0;const e=t.className.toLowerCase();if(e.includes("display")||e.includes("block"))return!0;if(t.closest('.katex-display, .MathJax_Display, [data-display="block"]'))return!0;const r=t.previousElementSibling;if("p"===(null==r?void 0:r.tagName.toLowerCase()))return!0;if(t.matches(".mwe-math-fallback-image-display"))return!0;if(t.matches(".katex"))return null!==t.closest(".katex-display");if(t.hasAttribute("display"))return"true"===t.getAttribute("display");if(t.matches('script[type="math/tex; mode=display"]'))return!0;if(t.hasAttribute("display"))return"true"===t.getAttribute("display");const o=t.closest("[display]");return!!o&&"true"===o.getAttribute("display")},e.mathSelectors=['img.latex[src*="latex.php"]',"span.MathJax","mjx-container",'script[type="math/tex"]','script[type="math/tex; mode=display"]','.MathJax_Preview + script[type="math/tex"]',".MathJax_Display",".MathJax_SVG",".MathJax_MathML",".mwe-math-element",".mwe-math-fallback-image-inline",".mwe-math-fallback-image-display",".mwe-math-mathml-inline",".mwe-math-mathml-display",".katex",".katex-display",".katex-mathml",".katex-html","[data-katex]",'script[type="math/katex"]',"math","[data-math]","[data-latex]","[data-tex]",'script[type^="math/"]','annotation[encoding="application/x-tex"]'].join(",")},397:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ClaudeExtractor=void 0;const o=r(181);class n extends o.ConversationExtractor{constructor(t,e){super(t,e),this.articles=t.querySelectorAll('div[data-testid="user-message"], div[data-testid="assistant-message"], div.font-claude-message')}canExtract(){return!!this.articles&&this.articles.length>0}extractMessages(){const t=[];return this.articles?(this.articles.forEach((e=>{let r,o;if(e.hasAttribute("data-testid")){if("user-message"!==e.getAttribute("data-testid"))return;r="you",o=e.innerHTML}else{if(!e.classList.contains("font-claude-message"))return;r="assistant",o=e.innerHTML}o&&t.push({author:"you"===r?"You":"Claude",content:o.trim(),metadata:{role:r}})})),t):t}getMetadata(){const t=this.getTitle(),e=this.extractMessages();return{title:t,site:"Claude",url:this.url,messageCount:e.length,description:`Claude conversation with ${e.length} messages`}}getTitle(){var t,e,r,o,n;const i=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(i&&"Claude"!==i)return i.replace(/ - Claude$/,"");const a=null===(r=null===(e=this.document.querySelector("header .font-tiempos"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim();if(a)return a;const s=null===(n=null===(o=this.articles)||void 0===o?void 0:o.item(0))||void 0===n?void 0:n.querySelector('[data-testid="user-message"]');if(s){const t=s.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"Claude Conversation"}}e.ClaudeExtractor=n},458:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HackerNewsExtractor=void 0;const o=r(279);class n extends o.BaseExtractor{constructor(t,e){super(t,e),this.mainPost=t.querySelector(".fatitem"),this.isCommentPage=this.detectCommentPage(),this.mainComment=this.isCommentPage?this.findMainComment():null}detectCommentPage(){var t;return!!(null===(t=this.mainPost)||void 0===t?void 0:t.querySelector('.navs a[href*="parent"]'))}findMainComment(){var t;return(null===(t=this.mainPost)||void 0===t?void 0:t.querySelector(".comment"))||null}canExtract(){return!!this.mainPost}extract(){const t=this.getPostContent(),e=this.extractComments(),r=this.createContentHtml(t,e),o=this.getPostTitle(),n=this.getPostAuthor(),i=this.createDescription(),a=this.getPostDate();return{content:r,contentHtml:r,extractedContent:{postId:this.getPostId(),postAuthor:n},variables:{title:o,author:n,site:"Hacker News",description:i,published:a}}}createContentHtml(t,e){return`\n\t\t\t<div class="hackernews-post">\n\t\t\t\t<div class="post-content">\n\t\t\t\t\t${t}\n\t\t\t\t</div>\n\t\t\t\t${e?`\n\t\t\t\t\t<hr>\n\t\t\t\t\t<h2>Comments</h2>\n\t\t\t\t\t<div class="hackernews-comments">\n\t\t\t\t\t\t${e}\n\t\t\t\t\t</div>\n\t\t\t\t`:""}\n\t\t\t</div>\n\t\t`.trim()}getPostContent(){var t,e,r,o,n,i;if(!this.mainPost)return"";if(this.isCommentPage&&this.mainComment){const i=(null===(t=this.mainComment.querySelector(".hnuser"))||void 0===t?void 0:t.textContent)||"[deleted]",a=(null===(e=this.mainComment.querySelector(".commtext"))||void 0===e?void 0:e.innerHTML)||"",s=this.mainComment.querySelector(".age"),l=((null==s?void 0:s.getAttribute("title"))||"").split("T")[0]||"",c=(null===(o=null===(r=this.mainComment.querySelector(".score"))||void 0===r?void 0:r.textContent)||void 0===o?void 0:o.trim())||"",d=(null===(n=this.mainPost.querySelector('.navs a[href*="parent"]'))||void 0===n?void 0:n.getAttribute("href"))||"";return`\n\t\t\t\t<div class="comment main-comment">\n\t\t\t\t\t<div class="comment-metadata">\n\t\t\t\t\t\t<span class="comment-author"><strong>${i}</strong></span> \u2022\n\t\t\t\t\t\t<span class="comment-date">${l}</span>\n\t\t\t\t\t\t${c?` \u2022 <span class="comment-points">${c}</span>`:""}\n\t\t\t\t\t\t${d?` \u2022 <a href="https://news.ycombinator.com/${d}" class="parent-link">parent</a>`:""}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="comment-content">${a}</div>\n\t\t\t\t</div>\n\t\t\t`.trim()}const a=this.mainPost.querySelector("tr.athing"),s=(null==a||a.nextElementSibling,(null===(i=null==a?void 0:a.querySelector(".titleline a"))||void 0===i?void 0:i.getAttribute("href"))||"");let l="";s&&(l+=`<p><a href="${s}" target="_blank">${s}</a></p>`);const c=this.mainPost.querySelector(".toptext");return c&&(l+=`<div class="post-text">${c.innerHTML}</div>`),l}extractComments(){const t=Array.from(this.document.querySelectorAll("tr.comtr"));return this.processComments(t)}processComments(t){var e,r,o,n;let i="";const a=new Set;let s=-1,l=[];for(const c of t){const t=c.getAttribute("id");if(!t||a.has(t))continue;a.add(t);const d=(null===(e=c.querySelector(".ind img"))||void 0===e?void 0:e.getAttribute("width"))||"0",u=parseInt(d)/40,m=c.querySelector(".commtext"),h=(null===(r=c.querySelector(".hnuser"))||void 0===r?void 0:r.textContent)||"[deleted]",p=c.querySelector(".age"),g=(null===(n=null===(o=c.querySelector(".score"))||void 0===o?void 0:o.textContent)||void 0===n?void 0:n.trim())||"";if(!m)continue;const f=`https://news.ycombinator.com/item?id=${t}`,v=((null==p?void 0:p.getAttribute("title"))||"").split("T")[0]||"";if(0===u){for(;l.length>0;)i+="</blockquote>",l.pop();i+="<blockquote>",l=[0],s=0}else if(u<s)for(;l.length>0&&l[l.length-1]>=u;)i+="</blockquote>",l.pop();else u>s&&(i+="<blockquote>",l.push(u));i+=`<div class="comment">\n\t<div class="comment-metadata">\n\t\t<span class="comment-author"><strong>${h}</strong></span> \u2022\n\t\t<a href="${f}" class="comment-link">${v}</a>\n\t\t${g?` \u2022 <span class="comment-points">${g}</span>`:""}\n\t</div>\n\t<div class="comment-content">${m.innerHTML}</div>\n</div>`,s=u}for(;l.length>0;)i+="</blockquote>",l.pop();return i}getPostId(){const t=this.url.match(/id=(\d+)/);return(null==t?void 0:t[1])||""}getPostTitle(){var t,e,r,o,n;if(this.isCommentPage&&this.mainComment){const r=(null===(t=this.mainComment.querySelector(".hnuser"))||void 0===t?void 0:t.textContent)||"[deleted]",o=(null===(e=this.mainComment.querySelector(".commtext"))||void 0===e?void 0:e.textContent)||"";return`Comment by ${r}: ${o.trim().slice(0,50)+(o.length>50?"...":"")}`}return(null===(n=null===(o=null===(r=this.mainPost)||void 0===r?void 0:r.querySelector(".titleline"))||void 0===o?void 0:o.textContent)||void 0===n?void 0:n.trim())||""}getPostAuthor(){var t,e,r;return(null===(r=null===(e=null===(t=this.mainPost)||void 0===t?void 0:t.querySelector(".hnuser"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||""}createDescription(){const t=this.getPostTitle(),e=this.getPostAuthor();return this.isCommentPage?`Comment by ${e} on Hacker News`:`${t} - by ${e} on Hacker News`}getPostDate(){if(!this.mainPost)return"";const t=this.mainPost.querySelector(".age");return((null==t?void 0:t.getAttribute("title"))||"").split("T")[0]||""}}e.HackerNewsExtractor=n},594:e=>{e.exports=t},608:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MetadataExtractor=void 0;e.MetadataExtractor=class{static extract(t,e){var r,o;let n="",i="";try{if(i=(null===(r=t.location)||void 0===r?void 0:r.href)||"",i||(i=this.getMetaContent(t,"property","og:url")||this.getMetaContent(t,"property","twitter:url")||this.getSchemaProperty(t,e,"url")||this.getSchemaProperty(t,e,"mainEntityOfPage.url")||this.getSchemaProperty(t,e,"mainEntity.url")||this.getSchemaProperty(t,e,"WebSite.url")||(null===(o=t.querySelector('link[rel="canonical"]'))||void 0===o?void 0:o.getAttribute("href"))||""),i)try{n=new URL(i).hostname.replace(/^www\./,"")}catch(t){console.warn("Failed to parse URL:",t)}}catch(e){const r=t.querySelector("base[href]");if(r)try{i=r.getAttribute("href")||"",n=new URL(i).hostname.replace(/^www\./,"")}catch(t){console.warn("Failed to parse base URL:",t)}}return{title:this.getTitle(t,e),description:this.getDescription(t,e),domain:n,favicon:this.getFavicon(t,i),image:this.getImage(t,e),published:this.getPublished(t,e),author:this.getAuthor(t,e),site:this.getSite(t,e),schemaOrgData:e,wordCount:0,parseTime:0}}static getAuthor(t,e){return this.getMetaContent(t,"name","sailthru.author")||this.getSchemaProperty(t,e,"author.name")||this.getMetaContent(t,"property","author")||this.getMetaContent(t,"name","byl")||this.getMetaContent(t,"name","author")||this.getMetaContent(t,"name","authorList")||this.getMetaContent(t,"name","copyright")||this.getSchemaProperty(t,e,"copyrightHolder.name")||this.getMetaContent(t,"property","og:site_name")||this.getSchemaProperty(t,e,"publisher.name")||this.getSchemaProperty(t,e,"sourceOrganization.name")||this.getSchemaProperty(t,e,"isPartOf.name")||this.getMetaContent(t,"name","twitter:creator")||this.getMetaContent(t,"name","application-name")||""}static getSite(t,e){return this.getSchemaProperty(t,e,"publisher.name")||this.getMetaContent(t,"property","og:site_name")||this.getSchemaProperty(t,e,"WebSite.name")||this.getSchemaProperty(t,e,"sourceOrganization.name")||this.getMetaContent(t,"name","copyright")||this.getSchemaProperty(t,e,"copyrightHolder.name")||this.getSchemaProperty(t,e,"isPartOf.name")||this.getMetaContent(t,"name","application-name")||this.getAuthor(t,e)||""}static getTitle(t,e){var r,o;const n=this.getMetaContent(t,"property","og:title")||this.getMetaContent(t,"name","twitter:title")||this.getSchemaProperty(t,e,"headline")||this.getMetaContent(t,"name","title")||this.getMetaContent(t,"name","sailthru.title")||(null===(o=null===(r=t.querySelector("title"))||void 0===r?void 0:r.textContent)||void 0===o?void 0:o.trim())||"";return this.cleanTitle(n,this.getSite(t,e))}static cleanTitle(t,e){if(!t||!e)return t;const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=[`\\s*[\\|\\-\u2013\u2014]\\s*${r}\\s*$`,`^\\s*${r}\\s*[\\|\\-\u2013\u2014]\\s*`];for(const e of o){const r=new RegExp(e,"i");if(r.test(t)){t=t.replace(r,"");break}}return t.trim()}static getDescription(t,e){return this.getMetaContent(t,"name","description")||this.getMetaContent(t,"property","description")||this.getMetaContent(t,"property","og:description")||this.getSchemaProperty(t,e,"description")||this.getMetaContent(t,"name","twitter:description")||this.getMetaContent(t,"name","sailthru.description")||""}static getImage(t,e){return this.getMetaContent(t,"property","og:image")||this.getMetaContent(t,"name","twitter:image")||this.getSchemaProperty(t,e,"image.url")||this.getMetaContent(t,"name","sailthru.image.full")||""}static getFavicon(t,e){var r,o;const n=this.getMetaContent(t,"property","og:image:favicon");if(n)return n;const i=null===(r=t.querySelector("link[rel='icon']"))||void 0===r?void 0:r.getAttribute("href");if(i)return i;const a=null===(o=t.querySelector("link[rel='shortcut icon']"))||void 0===o?void 0:o.getAttribute("href");if(a)return a;if(e)try{return new URL("/favicon.ico",e).href}catch(t){console.warn("Failed to construct favicon URL:",t)}return""}static getPublished(t,e){return this.getSchemaProperty(t,e,"datePublished")||this.getMetaContent(t,"name","publishDate")||this.getMetaContent(t,"property","article:published_time")||this.getTimeElement(t)||this.getMetaContent(t,"name","sailthru.date")||""}static getMetaContent(t,e,r){var o,n;const i=`meta[${e}]`,a=Array.from(t.querySelectorAll(i)).find((t=>{var o;return(null===(o=t.getAttribute(e))||void 0===o?void 0:o.toLowerCase())===r.toLowerCase()})),s=a&&null!==(n=null===(o=a.getAttribute("content"))||void 0===o?void 0:o.trim())&&void 0!==n?n:"";return this.decodeHTMLEntities(s,t)}static getTimeElement(t){var e,r,o,n;const i=Array.from(t.querySelectorAll("time"))[0],a=i&&null!==(n=null!==(r=null===(e=i.getAttribute("datetime"))||void 0===e?void 0:e.trim())&&void 0!==r?r:null===(o=i.textContent)||void 0===o?void 0:o.trim())&&void 0!==n?n:"";return this.decodeHTMLEntities(a,t)}static decodeHTMLEntities(t,e){const r=e.createElement("textarea");return r.innerHTML=t,r.value}static getSchemaProperty(t,e,r,o=""){if(!e)return o;const n=(t,e,r,o=!0)=>{if("string"==typeof t)return 0===e.length?[t]:[];if(!t||"object"!=typeof t)return[];if(Array.isArray(t)){const i=e[0];if(/^\[\d+\]$/.test(i)){const a=parseInt(i.slice(1,-1));return t[a]?n(t[a],e.slice(1),r,o):[]}return 0===e.length&&t.every((t=>"string"==typeof t||"number"==typeof t))?t.map(String):t.flatMap((t=>n(t,e,r,o)))}const[i,...a]=e;if(!i)return"string"==typeof t?[t]:"object"==typeof t&&t.name?[t.name]:[];if(t.hasOwnProperty(i))return n(t[i],a,r?`${r}.${i}`:i,!0);if(!o){const o=[];for(const i in t)if("object"==typeof t[i]){const a=n(t[i],e,r?`${r}.${i}`:i,!1);o.push(...a)}if(o.length>0)return o}return[]};try{let i=n(e,r.split("."),"",!0);0===i.length&&(i=n(e,r.split("."),"",!1));const a=i.length>0?i.filter(Boolean).join(", "):o;return this.decodeHTMLEntities(a,t)}catch(t){return console.error(`Error in getSchemaProperty for ${r}:`,t),o}}static extractSchemaOrgData(t){const e=t.querySelectorAll('script[type="application/ld+json"]'),r=[];return e.forEach((t=>{let e=t.textContent||"";try{e=e.replace(/\/\*[\s\S]*?\*\/|^\s*\/\/.*$/gm,"").replace(/^\s*<!\[CDATA\[([\s\S]*?)\]\]>\s*$/,"$1").replace(/^\s*(\*\/|\/\*)\s*|\s*(\*\/|\/\*)\s*$/g,"").trim();const t=JSON.parse(e);t["@graph"]&&Array.isArray(t["@graph"])?r.push(...t["@graph"]):r.push(t)}catch(t){console.error("Error parsing schema.org data:",t),console.error("Problematic JSON content:",e)}})),r}}},628:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Defuddle=void 0;const o=r(608),n=r(917),i=r(640),a=r(974),s=r(754),l=r(864),c=r(968),d=[...a.mathRules,...s.codeBlockRules,...l.headingRules,{selector:'div[data-testid^="paragraph"], div[role="paragraph"]',element:"p",transform:(t,e)=>{const r=e.createElement("p");return r.innerHTML=t.innerHTML,Array.from(t.attributes).forEach((t=>{i.ALLOWED_ATTRIBUTES.has(t.name)&&r.setAttribute(t.name,t.value)})),r}},{selector:'div[role="list"]',element:"ul",transform:(t,e)=>{var r;const o=t.querySelector('div[role="listitem"] .label'),n=((null===(r=null==o?void 0:o.textContent)||void 0===r?void 0:r.trim())||"").match(/^\d+\)/),i=e.createElement(n?"ol":"ul");return t.querySelectorAll('div[role="listitem"]').forEach((t=>{const r=e.createElement("li"),o=t.querySelector(".content");if(o){o.querySelectorAll('div[role="paragraph"]').forEach((t=>{const r=e.createElement("p");r.innerHTML=t.innerHTML,t.replaceWith(r)}));o.querySelectorAll('div[role="list"]').forEach((t=>{var r;const o=t.querySelector('div[role="listitem"] .label'),n=((null===(r=null==o?void 0:o.textContent)||void 0===r?void 0:r.trim())||"").match(/^\d+\)/),i=e.createElement(n?"ol":"ul");t.querySelectorAll('div[role="listitem"]').forEach((t=>{const r=e.createElement("li"),o=t.querySelector(".content");if(o){o.querySelectorAll('div[role="paragraph"]').forEach((t=>{const r=e.createElement("p");r.innerHTML=t.innerHTML,t.replaceWith(r)})),r.innerHTML=o.innerHTML}i.appendChild(r)})),t.replaceWith(i)})),r.innerHTML=o.innerHTML}i.appendChild(r)})),i}},{selector:'div[role="listitem"]',element:"li",transform:(t,e)=>{const r=t.querySelector(".content");if(!r)return t;return r.querySelectorAll('div[role="paragraph"]').forEach((t=>{const r=e.createElement("p");r.innerHTML=t.innerHTML,t.replaceWith(r)})),r}}];e.Defuddle=class{constructor(t,e={}){this.doc=t,this.options=e,this.debug=e.debug||!1}parse(){var t,e,r;const i=Date.now(),a=o.MetadataExtractor.extractSchemaOrgData(this.doc),s=o.MetadataExtractor.extract(this.doc,a);try{const o=this.options.url||this.doc.URL,l=n.ExtractorRegistry.findExtractor(this.doc,o,a);if(l&&l.canExtract()){const o=l.extract(),n=Date.now();return{content:o.contentHtml,title:(null===(t=o.variables)||void 0===t?void 0:t.title)||s.title,description:s.description,domain:s.domain,favicon:s.favicon,image:s.image,published:(null===(e=o.variables)||void 0===e?void 0:e.published)||s.published,author:(null===(r=o.variables)||void 0===r?void 0:r.author)||s.author,site:s.site,schemaOrgData:s.schemaOrgData,wordCount:this.countWords(o.contentHtml),parseTime:Math.round(n-i),extractorType:l.constructor.name.replace("Extractor","").toLowerCase()}}const c=this._evaluateMediaQueries(this.doc),d=this.findSmallImages(this.doc),u=this.doc.cloneNode(!0);this.applyMobileStyles(u,c);const m=this.findMainContent(u);if(!m){const t=Date.now();return Object.assign(Object.assign({content:this.doc.body.innerHTML},s),{wordCount:this.countWords(this.doc.body.innerHTML),parseTime:Math.round(t-i)})}this.removeSmallImages(u,d),this.removeHiddenElements(u),this.removeClutter(u),this.cleanContent(m,s);const h=m?m.outerHTML:this.doc.body.innerHTML,p=Date.now();return Object.assign(Object.assign({content:h},s),{wordCount:this.countWords(h),parseTime:Math.round(p-i)})}catch(t){console.error("Defuddle","Error processing document:",t);const e=Date.now();return Object.assign(Object.assign({content:this.doc.body.innerHTML},s),{wordCount:this.countWords(this.doc.body.innerHTML),parseTime:Math.round(e-i)})}}countWords(t){const e=this.doc.createElement("div");e.innerHTML=t;return(e.textContent||"").trim().replace(/\s+/g," ").split(" ").filter((t=>t.length>0)).length}_log(...t){this.debug&&console.log("Defuddle:",...t)}_evaluateMediaQueries(t){const e=[],r=/max-width[^:]*:\s*(\d+)/;try{const o=Array.from(t.styleSheets).filter((t=>{try{return t.cssRules,!0}catch(t){return t instanceof DOMException&&t.name,!1}}));o.flatMap((t=>{try{return"undefined"==typeof CSSMediaRule?[]:Array.from(t.cssRules).filter((t=>t instanceof CSSMediaRule&&t.conditionText.includes("max-width")))}catch(t){return this.debug&&console.warn("Defuddle: Failed to process stylesheet:",t),[]}})).forEach((t=>{const o=t.conditionText.match(r);if(o){const r=parseInt(o[1]);if(i.MOBILE_WIDTH<=r){Array.from(t.cssRules).filter((t=>t instanceof CSSStyleRule)).forEach((t=>{try{e.push({selector:t.selectorText,styles:t.style.cssText})}catch(t){this.debug&&console.warn("Defuddle: Failed to process CSS rule:",t)}}))}}}))}catch(t){console.error("Defuddle: Error evaluating media queries:",t)}return e}applyMobileStyles(t,e){e.forEach((({selector:e,styles:r})=>{try{t.querySelectorAll(e).forEach((t=>{t.setAttribute("style",(t.getAttribute("style")||"")+r)}))}catch(t){console.error("Defuddle","Error applying styles for selector:",e,t)}}))}getWindow(t){return t.defaultView?t.defaultView:t.ownerWindow?t.ownerWindow:t.window?t.window:null}getComputedStyle(t){const e=this.getWindow(t.ownerDocument);return e?e.getComputedStyle(t):null}removeHiddenElements(t){let e=0;const r=new Set,o=t.querySelectorAll(i.HIDDEN_ELEMENT_SELECTORS);o.forEach((t=>r.add(t))),e+=o.length;const n=Array.from(t.getElementsByTagName("*"));for(let o=0;o<n.length;o+=100){const i=n.slice(o,o+100),a=i.map((e=>{var r,o;try{return null===(r=e.ownerDocument.defaultView)||void 0===r?void 0:r.getComputedStyle(e)}catch(r){const n=e.getAttribute("style");if(!n)return null;const i=t.createElement("style");i.textContent=`* { ${n} }`,t.head.appendChild(i);const a=null===(o=e.ownerDocument.defaultView)||void 0===o?void 0:o.getComputedStyle(e);return t.head.removeChild(i),a}}));i.forEach(((t,o)=>{const n=a[o];!n||"none"!==n.display&&"hidden"!==n.visibility&&"0"!==n.opacity||(r.add(t),e++)}))}r.forEach((t=>t.remove())),this._log("Removed hidden elements:",e)}removeClutter(t){const e=Date.now();let r=0,o=0;const n=new Set;t.querySelectorAll(i.EXACT_SELECTORS.join(",")).forEach((t=>{(null==t?void 0:t.parentNode)&&(n.add(t),r++)}));const a=i.PARTIAL_SELECTORS.join("|"),s=new RegExp(a,"i"),l=i.TEST_ATTRIBUTES.map((t=>`[${t}]`)).join(",");t.querySelectorAll(l).forEach((t=>{if(n.has(t))return;const e=i.TEST_ATTRIBUTES.map((e=>"class"===e?t.className&&"string"==typeof t.className?t.className:"":"id"===e?t.id||"":t.getAttribute(e)||"")).join(" ").toLowerCase();e.trim()&&s.test(e)&&(n.add(t),o++)})),n.forEach((t=>t.remove()));const c=Date.now();this._log("Removed clutter elements:",{exactSelectors:r,partialSelectors:o,total:n.size,processingTime:`${(c-e).toFixed(2)}ms`})}flattenDivs(t){let e=0;const r=Date.now();let o=!0;function n(t){var e;for(const r of t.childNodes){if(r.nodeType===Node.TEXT_NODE&&(null===(e=r.textContent)||void 0===e?void 0:e.trim()))return!0;if(r.nodeType===Node.ELEMENT_NODE&&i.INLINE_ELEMENTS.has(r.nodeName.toLowerCase()))return!0}return!1}const a=t=>{const e=t.tagName.toLowerCase();if(i.PRESERVE_ELEMENTS.has(e))return!0;const r=t.getAttribute("role");if(r&&["article","main","navigation","banner","contentinfo"].includes(r))return!0;const o=t.className;if("string"==typeof o&&o.toLowerCase().match(/(?:article|main|content|footnote|reference|bibliography)/))return!0;if("div"===e){if(Array.from(t.children).some((t=>i.PRESERVE_ELEMENTS.has(t.tagName.toLowerCase())||"article"===t.getAttribute("role")||t.className&&"string"==typeof t.className&&t.className.toLowerCase().match(/(?:article|main|content|footnote|reference|bibliography)/))))return!0}return!1},s=t=>{var e;if(n(t))return!1;if(!(null===(e=t.textContent)||void 0===e?void 0:e.trim()))return!0;const r=Array.from(t.children);if(0===r.length)return!0;if(r.every((t=>{const e=t.tagName.toLowerCase();return"div"===e||"p"===e||"h1"===e||"h2"===e||"h3"===e||"h4"===e||"h5"===e||"h6"===e||"ul"===e||"ol"===e||"pre"===e||"blockquote"===e||"figure"===e})))return!0;const o=t.className.toLowerCase();if(/(?:wrapper|container|layout|row|col|grid|flex|outer|inner|content-area)/i.test(o))return!0;const a=Array.from(t.childNodes).filter((t=>{var e;return 3===t.nodeType&&(null===(e=t.textContent)||void 0===e?void 0:e.trim())}));if(0===a.length)return!0;return!(!(r.length>0)||r.some((t=>{const e=t.tagName.toLowerCase();return i.INLINE_ELEMENTS.has(e)})))},l=r=>{var o,l;if(!r.isConnected||a(r))return!1;if(!r.hasChildNodes()||!(null===(o=r.textContent)||void 0===o?void 0:o.trim()))return r.remove(),e++,!0;if(r.parentElement===t){const t=Array.from(r.children);if(t.length>0&&!t.some((t=>{const e=t.tagName.toLowerCase();return i.INLINE_ELEMENTS.has(e)}))){const t=this.doc.createDocumentFragment();for(;r.firstChild;)t.appendChild(r.firstChild);return r.replaceWith(t),e++,!0}}if(s(r)){if(!Array.from(r.children).some((t=>{const e=t.tagName.toLowerCase();return i.INLINE_ELEMENTS.has(e)}))){const t=this.doc.createDocumentFragment();for(;r.firstChild;)t.appendChild(r.firstChild);return r.replaceWith(t),e++,!0}const t=this.doc.createDocumentFragment();for(;r.firstChild;)t.appendChild(r.firstChild);return r.replaceWith(t),e++,!0}const c=Array.from(r.childNodes);if(c.length>0&&c.every((t=>t.nodeType===Node.TEXT_NODE||t.nodeType===Node.ELEMENT_NODE&&i.INLINE_ELEMENTS.has(t.nodeName.toLowerCase())))&&(null===(l=r.textContent)||void 0===l?void 0:l.trim())){const t=this.doc.createElement("p");for(;r.firstChild;)t.appendChild(r.firstChild);return r.replaceWith(t),e++,!0}if(1===r.children.length){const t=r.firstElementChild,o=t.tagName.toLowerCase();if(i.BLOCK_ELEMENTS.includes(o)&&!a(t))return r.replaceWith(t),e++,!0}let d=0,u=r.parentElement;for(;u;)"div"===u.tagName.toLowerCase()&&d++,u=u.parentElement;if(d>0&&!n(r)){const t=this.doc.createDocumentFragment();for(;r.firstChild;)t.appendChild(r.firstChild);return r.replaceWith(t),e++,!0}return!1},c=()=>{const e=Array.from(t.children).filter((t=>"div"===t.tagName.toLowerCase()));let r=!1;return e.forEach((t=>{l(t)&&(r=!0)})),r},d=()=>{const e=Array.from(t.getElementsByTagName("div")).sort(((t,e)=>{const r=t=>{let e=0,r=t.parentElement;for(;r;)"div"===r.tagName.toLowerCase()&&e++,r=r.parentElement;return e};return r(e)-r(t)}));let r=!1;return e.forEach((t=>{l(t)&&(r=!0)})),r},u=()=>{const r=Array.from(t.getElementsByTagName("div"));let o=!1;return r.forEach((t=>{if(t.isConnected&&!a(t)&&!n(t)){const r=Array.from(t.children);if(r.length>0&&r.every((t=>"p"===t.tagName.toLowerCase()))||s(t)){const r=this.doc.createDocumentFragment();for(;t.firstChild;)r.appendChild(t.firstChild);t.replaceWith(r),e++,o=!0}}})),o};do{o=!1,c()&&(o=!0),d()&&(o=!0),u()&&(o=!0)}while(o);const m=Date.now();this._log("Flattened divs:",{count:e,processingTime:`${(m-r).toFixed(2)}ms`})}cleanContent(t,e){this.standardizeSpaces(t),this.removeHtmlComments(t),this.standardizeHeadings(t,e.title),this.standardizeFootnotes(t),this.handleLazyImages(t),this.standardizeElements(t),this.debug?(this.stripUnwantedAttributes(t),this.removeEmptyElements(t),this.removeTrailingHeadings(t),this.stripExtraBrElements(t),this._log("Debug mode: Skipping div flattening to preserve structure")):(this.flattenDivs(t),this.stripUnwantedAttributes(t),this.removeEmptyElements(t),this.removeTrailingHeadings(t),this.flattenDivs(t),this.stripExtraBrElements(t),this.removeEmptyLines(t))}standardizeSpaces(t){const e=t=>{if(1===t.nodeType){const e=t.tagName.toLowerCase();if("pre"===e||"code"===e)return}if(3===t.nodeType){const e=t.textContent||"",r=e.replace(/\xA0+/g,(e=>{var r,o,n,i;if(1===e.length){const e=null===(o=null===(r=t.previousSibling)||void 0===r?void 0:r.textContent)||void 0===o?void 0:o.slice(-1),a=null===(i=null===(n=t.nextSibling)||void 0===n?void 0:n.textContent)||void 0===i?void 0:i.charAt(0);if((null==e?void 0:e.match(/\w/))&&(null==a?void 0:a.match(/\w/)))return"\xa0"}return" ".repeat(e.length)}));r!==e&&(t.textContent=r)}t.hasChildNodes()&&Array.from(t.childNodes).forEach(e)};e(t)}removeTrailingHeadings(t){let e=0;const r=e=>{let o="",n=e.nextSibling;for(;n;)(3===n.nodeType||1===n.nodeType)&&(o+=n.textContent||""),n=n.nextSibling;if(o.trim())return!0;const i=e.parentElement;return!(!i||i===t)&&r(i)};Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")).reverse().forEach((t=>{r(t)||(t.remove(),e++)})),e>0&&this._log("Removed trailing headings:",e)}standardizeHeadings(t,e){const r=t=>t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim().toLowerCase(),o=t.getElementsByTagName("h1");Array.from(o).forEach((t=>{var e;const r=this.doc.createElement("h2");r.innerHTML=t.innerHTML,Array.from(t.attributes).forEach((t=>{i.ALLOWED_ATTRIBUTES.has(t.name)&&r.setAttribute(t.name,t.value)})),null===(e=t.parentNode)||void 0===e||e.replaceChild(r,t)}));const n=t.getElementsByTagName("h2");if(n.length>0){const t=n[0],o=r(t.textContent||""),i=r(e);i&&i===o&&t.remove()}}removeHtmlComments(t){let e=0;Array.from(t.getElementsByTagName("*")).forEach((t=>{Array.from(t.childNodes).forEach((t=>{8===t.nodeType&&(t.remove(),e++)}))})),this._log("Removed HTML comments:",e)}stripUnwantedAttributes(t){let e=0;const r=t=>{if("svg"===t.tagName.toLowerCase()||"http://www.w3.org/2000/svg"===t.namespaceURI)return;const r=Array.from(t.attributes),o=t.tagName.toLowerCase();r.forEach((r=>{const n=r.name.toLowerCase(),a=r.value;"id"===n&&(a.startsWith("fnref:")||a.startsWith("fn:")||"footnotes"===a)||"class"===n&&("code"===o&&a.startsWith("language-")||"footnote-backref"===a)||(this.debug?i.ALLOWED_ATTRIBUTES.has(n)||i.ALLOWED_ATTRIBUTES_DEBUG.has(n)||n.startsWith("data-")||(t.removeAttribute(r.name),e++):i.ALLOWED_ATTRIBUTES.has(n)||(t.removeAttribute(r.name),e++))}))};r(t),t.querySelectorAll("*").forEach(r),this._log("Stripped attributes:",e)}removeEmptyElements(t){let e=0,r=0,o=!0;for(;o;){r++,o=!1;const n=Array.from(t.getElementsByTagName("*")).filter((t=>{if(i.ALLOWED_EMPTY_ELEMENTS.has(t.tagName.toLowerCase()))return!1;const e=t.textContent||"",r=0===e.trim().length,o=e.includes("\xa0"),n=!t.hasChildNodes()||Array.from(t.childNodes).every((t=>{if(3===t.nodeType){const e=t.textContent||"";return 0===e.trim().length&&!e.includes("\xa0")}return!1}));if("div"===t.tagName.toLowerCase()){const e=Array.from(t.children);if(e.length>0&&e.every((t=>{var e;if("span"!==t.tagName.toLowerCase())return!1;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";return","===r||""===r||" "===r})))return!0}return r&&!o&&n}));n.length>0&&(n.forEach((t=>{t.remove(),e++})),o=!0)}this._log("Removed empty elements:",e,"iterations:",r)}stripExtraBrElements(t){let e=0;const r=Date.now(),o=Array.from(t.getElementsByTagName("br"));let n=[];const i=()=>{if(n.length>2)for(let t=2;t<n.length;t++)n[t].remove(),e++;n=[]};o.forEach((t=>{var e;let r=!1;if(n.length>0){const o=n[n.length-1];let i=t.previousSibling;for(;i&&3===i.nodeType&&!(null===(e=i.textContent)||void 0===e?void 0:e.trim());)i=i.previousSibling;i===o&&(r=!0)}r?n.push(t):(i(),n=[t])})),i();const a=Date.now();this._log("Standardized br elements:",{removed:e,processingTime:`${(a-r).toFixed(2)}ms`})}removeEmptyLines(t){let e=0;const r=Date.now(),o=t=>{var r;if(t instanceof Element){const e=t.tagName.toLowerCase();if("pre"===e||"code"===e)return}if(Array.from(t.childNodes).forEach(o),t.nodeType===Node.TEXT_NODE){const o=t.textContent||"";if(!o||o.match(/^[\u200C\u200B\u200D\u200E\u200F\uFEFF\xA0\s]*$/))null===(r=t.parentNode)||void 0===r||r.removeChild(t),e++;else{const r=o.replace(/\n{3,}/g,"\n\n").replace(/^[\n\r\t]+/,"").replace(/[\n\r\t]+$/,"").replace(/[ \t]*\n[ \t]*/g,"\n").replace(/[ \t]{3,}/g," ").replace(/^[ ]+$/," ").replace(/\s+([,.!?:;])/g,"$1").replace(/[\u200C\u200B\u200D\u200E\u200F\uFEFF]+/g,"").replace(/(?:\xA0){2,}/g,"\xa0");r!==o&&(t.textContent=r,e+=o.length-r.length)}}},n=t=>{var r;if(!(t instanceof Element))return;const o=t.tagName.toLowerCase();if("pre"===o||"code"===o)return;Array.from(t.children).forEach(n),t.normalize();const i="block"===(null===(r=this.getComputedStyle(t))||void 0===r?void 0:r.display),a=i?/^[\n\r\t \u200C\u200B\u200D\u200E\u200F\uFEFF\xA0]*$/:/^[\n\r\t\u200C\u200B\u200D\u200E\u200F\uFEFF]*$/,s=i?/^[\n\r\t \u200C\u200B\u200D\u200E\u200F\uFEFF\xA0]*$/:/^[\n\r\t\u200C\u200B\u200D\u200E\u200F\uFEFF]*$/;for(;t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE&&(t.firstChild.textContent||"").match(a);)t.removeChild(t.firstChild),e++;for(;t.lastChild&&t.lastChild.nodeType===Node.TEXT_NODE&&(t.lastChild.textContent||"").match(s);)t.removeChild(t.lastChild),e++;if(!i){const e=Array.from(t.childNodes);for(let r=0;r<e.length-1;r++){const o=e[r],n=e[r+1];if(o instanceof Element||n instanceof Element){const e=n.textContent||"",r=o.textContent||"";if(!e.match(/^[,.!?:;]/)&&!r.match(/[,.!?:;]$/)){if(!(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").endsWith(" ")||n.nodeType===Node.TEXT_NODE&&(n.textContent||"").startsWith(" "))){const e=document.createTextNode(" ");t.insertBefore(e,n)}}}}}};o(t),n(t);const i=Date.now();this._log("Removed empty lines:",{charactersRemoved:e,processingTime:`${(i-r).toFixed(2)}ms`})}createFootnoteItem(t,e,r){const o=e instanceof Element?e.ownerDocument:this.doc,n=o.createElement("li");if(n.className="footnote",n.id=`fn:${t}`,"string"==typeof e){const t=o.createElement("p");t.innerHTML=e,n.appendChild(t)}else{const t=Array.from(e.querySelectorAll("p"));if(0===t.length){const t=o.createElement("p");t.innerHTML=e.innerHTML,n.appendChild(t)}else t.forEach((t=>{const e=o.createElement("p");e.innerHTML=t.innerHTML,n.appendChild(e)}))}const i=n.querySelector("p:last-of-type")||n;return r.forEach(((t,e)=>{const n=o.createElement("a");n.href=`#${t}`,n.title="return to article",n.className="footnote-backref",n.innerHTML="\u21a9",e<r.length-1&&(n.innerHTML+=" "),i.appendChild(n)})),n}collectFootnotes(t){const e={};let r=1;const o=new Set;return t.querySelectorAll(i.FOOTNOTE_LIST_SELECTORS).forEach((t=>{if(t.matches('div.footnote[data-component-name="FootnoteToDOM"]')){const n=t.querySelector("a.footnote-number"),i=t.querySelector(".footnote-content");if(n&&i){const t=n.id.replace("footnote-","").toLowerCase();t&&!o.has(t)&&(e[r]={content:i,originalId:t,refs:[]},o.add(t),r++)}return}t.querySelectorAll('li, div[role="listitem"]').forEach((t=>{var n,i,a,s;let l="",c=null;const d=t.querySelector(".citations");if(null===(n=null==d?void 0:d.id)||void 0===n?void 0:n.toLowerCase().startsWith("r")){l=d.id.toLowerCase();const t=d.querySelector(".citation-content");t&&(c=t)}else{if(t.id.toLowerCase().startsWith("bib.bib"))l=t.id.replace("bib.bib","").toLowerCase();else if(t.id.toLowerCase().startsWith("fn:"))l=t.id.replace("fn:","").toLowerCase();else if(t.id.toLowerCase().startsWith("fn"))l=t.id.replace("fn","").toLowerCase();else if(t.hasAttribute("data-counter"))l=(null===(a=null===(i=t.getAttribute("data-counter"))||void 0===i?void 0:i.replace(/\.$/,""))||void 0===a?void 0:a.toLowerCase())||"";else{const e=null===(s=t.id.split("/").pop())||void 0===s?void 0:s.match(/cite_note-(.+)/);l=e?e[1].toLowerCase():t.id.toLowerCase()}c=t}l&&!o.has(l)&&(e[r]={content:c||t,originalId:l,refs:[]},o.add(l),r++)}))})),e}findOuterFootnoteContainer(t){let e=t,r=t.parentElement;for(;r&&("span"===r.tagName.toLowerCase()||"sup"===r.tagName.toLowerCase());)e=r,r=r.parentElement;return e}createFootnoteReference(t,e){const r=this.doc.createElement("sup");r.id=e;const o=this.doc.createElement("a");return o.href=`#fn:${t}`,o.textContent=t,r.appendChild(o),r}standardizeFootnotes(t){const e=this.collectFootnotes(t),r=t.querySelectorAll(i.FOOTNOTE_INLINE_REFERENCES),o=new Map;r.forEach((t=>{var r,n,i,a;if(!(t instanceof HTMLElement))return;let s="",l="";if(t.matches('a[id^="ref-link"]'))s=(null===(r=t.textContent)||void 0===r?void 0:r.trim())||"";else if(t.matches('a[role="doc-biblioref"]')){const e=t.getAttribute("data-xml-rid");if(e)s=e;else{const e=t.getAttribute("href");(null==e?void 0:e.startsWith("#core-R"))&&(s=e.replace("#core-",""))}}else if(t.matches("a.footnote-anchor, span.footnote-hovercard-target a")){const e=(null===(n=t.id)||void 0===n?void 0:n.replace("footnote-anchor-",""))||"";e&&(s=e.toLowerCase())}else if(t.matches("cite.ltx_cite")){const e=t.querySelector("a");if(e){const t=e.getAttribute("href");if(t){const e=null===(i=t.split("/").pop())||void 0===i?void 0:i.match(/bib\.bib(\d+)/);e&&(s=e[1].toLowerCase())}}}else if(t.matches("sup.reference")){const e=t.querySelectorAll("a");Array.from(e).forEach((t=>{var e;const r=t.getAttribute("href");if(r){const t=null===(e=r.split("/").pop())||void 0===e?void 0:e.match(/(?:cite_note|cite_ref)-(.+)/);t&&(s=t[1].toLowerCase())}}))}else if(t.matches('sup[id^="fnref:"]'))s=t.id.replace("fnref:","").toLowerCase();else if(t.matches('sup[id^="fnr"]'))s=t.id.replace("fnr","").toLowerCase();else if(t.matches("span.footnote-reference"))s=t.getAttribute("data-footnote-id")||"";else if(t.matches("span.footnote-link"))s=t.getAttribute("data-footnote-id")||"",l=t.getAttribute("data-footnote-content")||"";else if(t.matches("a.citation"))s=(null===(a=t.textContent)||void 0===a?void 0:a.trim())||"",l=t.getAttribute("href")||"";else if(t.matches('a[id^="fnref"]'))s=t.id.replace("fnref","").toLowerCase();else{const e=t.getAttribute("href");if(e){const t=e.replace(/^[#]/,"");s=t.toLowerCase()}}if(s){const r=Object.entries(e).find((([t,e])=>e.originalId===s.toLowerCase()));if(r){const[e,n]=r,i=n.refs.length>0?`fnref:${e}-${n.refs.length+1}`:`fnref:${e}`;n.refs.push(i);const a=this.findOuterFootnoteContainer(t);if("sup"===a.tagName.toLowerCase()){o.has(a)||o.set(a,[]);o.get(a).push(this.createFootnoteReference(e,i))}else a.replaceWith(this.createFootnoteReference(e,i))}}})),o.forEach(((t,e)=>{if(t.length>0){const r=this.doc.createDocumentFragment();t.forEach(((t,e)=>{const o=t.querySelector("a");if(o){const e=this.doc.createElement("sup");e.id=t.id,e.appendChild(o.cloneNode(!0)),r.appendChild(e)}})),e.replaceWith(r)}}));const n=this.doc.createElement("div");n.id="footnotes";const a=this.doc.createElement("ol");Object.entries(e).forEach((([t,e])=>{const r=this.createFootnoteItem(parseInt(t),e.content,e.refs);a.appendChild(r)}));t.querySelectorAll(i.FOOTNOTE_LIST_SELECTORS).forEach((t=>t.remove())),a.children.length>0&&(n.appendChild(a),t.appendChild(n))}handleLazyImages(t){let e=0;t.querySelectorAll("img[data-src], img[data-srcset]").forEach((t=>{if("img"!==t.tagName.toLowerCase()||!("src"in t)||!("srcset"in t))return;const r=t.getAttribute("data-src");r&&!t.getAttribute("src")&&(t.setAttribute("src",r),e++);const o=t.getAttribute("data-srcset");o&&!t.getAttribute("srcset")&&(t.setAttribute("srcset",o),e++),t.classList.remove("lazy","lazyload"),t.removeAttribute("data-ll-status"),t.removeAttribute("data-src"),t.removeAttribute("data-srcset")})),this._log("Processed lazy images:",e)}standardizeElements(t){let e=0;d.forEach((r=>{t.querySelectorAll(r.selector).forEach((t=>{if(r.transform){const o=r.transform(t,this.doc);t.replaceWith(o),e++}}))}));t.querySelectorAll("lite-youtube").forEach((t=>{const r=t.getAttribute("videoid");if(!r)return;const o=this.doc.createElement("iframe");o.width="560",o.height="315",o.src=`https://www.youtube.com/embed/${r}`,o.title=t.getAttribute("videotitle")||"YouTube video player",o.frameBorder="0",o.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",o.setAttribute("allowfullscreen",""),t.replaceWith(o),e++})),this._log("Converted embedded elements:",e)}findSmallImages(t){const e=new Set,r=/scale\(([\d.]+)\)/,o=Date.now();let n=0;const i=[...Array.from(t.getElementsByTagName("img")),...Array.from(t.getElementsByTagName("svg"))].filter((t=>{if("img"===t.tagName.toLowerCase()){return!(t.classList.contains("lazy")||t.classList.contains("lazyload")||t.classList.contains("latex")||t.hasAttribute("decoding")||t.hasAttribute("data-src")||t.hasAttribute("data-srcset")||t.hasAttribute("loading"))}return!0}));if(0===i.length)return e;const a=i.map((t=>({element:t,naturalWidth:"img"===t.tagName.toLowerCase()&&parseInt(t.getAttribute("width")||"0")||0,naturalHeight:"img"===t.tagName.toLowerCase()&&parseInt(t.getAttribute("height")||"0")||0,attrWidth:parseInt(t.getAttribute("width")||"0"),attrHeight:parseInt(t.getAttribute("height")||"0")})));for(let t=0;t<a.length;t+=50){const o=a.slice(t,t+50);try{const t=o.map((({element:t})=>{var e;try{return null===(e=t.ownerDocument.defaultView)||void 0===e?void 0:e.getComputedStyle(t)}catch(t){return null}})),i=o.map((({element:t})=>{try{return t.getBoundingClientRect()}catch(t){return null}}));o.forEach(((o,a)=>{var s;try{const l=t[a],c=i[a];if(!l)return;const d=l.transform,u=d?parseFloat((null===(s=d.match(r))||void 0===s?void 0:s[1])||"1"):1,m=[o.naturalWidth,o.attrWidth,parseInt(l.width)||0,c?c.width*u:0].filter((t=>"number"==typeof t&&t>0)),h=[o.naturalHeight,o.attrHeight,parseInt(l.height)||0,c?c.height*u:0].filter((t=>"number"==typeof t&&t>0));if(m.length>0&&h.length>0){const t=Math.min(...m),r=Math.min(...h);if(t<33||r<33){const t=this.getElementIdentifier(o.element);t&&(e.add(t),n++)}}}catch(t){this.debug&&console.warn("Defuddle: Failed to process element dimensions:",t)}}))}catch(t){this.debug&&console.warn("Defuddle: Failed to process batch:",t)}}const s=Date.now();return this._log("Found small elements:",{count:n,processingTime:`${(s-o).toFixed(2)}ms`}),e}removeSmallImages(t,e){let r=0;["img","svg"].forEach((o=>{const n=t.getElementsByTagName(o);Array.from(n).forEach((t=>{const o=this.getElementIdentifier(t);o&&e.has(o)&&(t.remove(),r++)}))})),this._log("Removed small elements:",r)}getElementIdentifier(t){if("img"===t.tagName.toLowerCase()){const e=t.getAttribute("data-src");if(e)return`src:${e}`;const r=t.getAttribute("src")||"",o=t.getAttribute("srcset")||"",n=t.getAttribute("data-srcset");if(r)return`src:${r}`;if(o)return`srcset:${o}`;if(n)return`srcset:${n}`}const e=t.id||"",r=t.className||"",o="svg"===t.tagName.toLowerCase()&&t.getAttribute("viewBox")||"";return e?`id:${e}`:o?`viewBox:${o}`:r?`class:${r}`:null}findMainContent(t){const e=[];if(i.ENTRY_POINT_ELEMENTS.forEach(((r,o)=>{t.querySelectorAll(r).forEach((t=>{let r=10*(i.ENTRY_POINT_ELEMENTS.length-o);r+=c.ContentScorer.scoreElement(t),e.push({element:t,score:r})}))})),0===e.length)return this.findContentByScoring(t);if(e.sort(((t,e)=>e.score-t.score)),this.debug&&this._log("Content candidates:",e.map((t=>({element:t.element.tagName,selector:this.getElementSelector(t.element),score:t.score})))),1===e.length&&"body"===e[0].element.tagName.toLowerCase()){const e=this.findTableBasedContent(t);if(e)return e}return e[0].element}findTableBasedContent(t){if(!Array.from(t.getElementsByTagName("table")).some((t=>{const e=parseInt(t.getAttribute("width")||"0"),r=this.getComputedStyle(t);return e>400||(null==r?void 0:r.width.includes("px"))&&parseInt(r.width)>400||"center"===t.getAttribute("align")||t.className.toLowerCase().includes("content")||t.className.toLowerCase().includes("article")})))return null;const e=Array.from(t.getElementsByTagName("td"));return c.ContentScorer.findBestElement(e)}findContentByScoring(t){const e=[];return i.BLOCK_ELEMENTS.forEach((r=>{Array.from(t.getElementsByTagName(r)).forEach((t=>{const r=c.ContentScorer.scoreElement(t);r>0&&e.push({score:r,element:t})}))})),e.length>0?e.sort(((t,e)=>e.score-t.score))[0].element:null}getElementSelector(t){const e=[];let r=t;for(;r&&r!==this.doc.documentElement;){let t=r.tagName.toLowerCase();r.id?t+="#"+r.id:r.className&&"string"==typeof r.className&&(t+="."+r.className.trim().split(/\s+/).join(".")),e.unshift(t),r=r.parentElement}return e.join(" > ")}}},632:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ChatGPTExtractor=void 0;const o=r(181);class n extends o.ConversationExtractor{constructor(t,e){super(t,e),this.articles=t.querySelectorAll('article[data-testid^="conversation-turn-"]'),this.footnotes=[],this.footnoteCounter=0}canExtract(){return!!this.articles&&this.articles.length>0}extractMessages(){const t=[];return this.footnotes=[],this.footnoteCounter=0,this.articles?(this.articles.forEach((e=>{var r,o;const n=e.querySelector("h5.sr-only, h6.sr-only"),i=(null===(o=null===(r=null==n?void 0:n.textContent)||void 0===r?void 0:r.trim())||void 0===o?void 0:o.replace(/:\s*$/,""))||"";let a="";const s=e.getAttribute("data-message-author-role");s&&(a=s);let l=e.innerHTML||"";l=l.replace(/\u200B/g,"");const c=document.createElement("div");c.innerHTML=l,c.querySelectorAll('h5.sr-only, h6.sr-only, span[data-state="closed"]').forEach((t=>t.remove())),l=c.innerHTML;l=l.replace(/(?:<\/p>)?<div class="relative inline-flex[^>]*>.*?<\/div>|<span[^>]*>(?:<div class="relative inline-flex[^>]*>|<div[^>]*class="[^"]*relative inline-flex[^>]*>).*?<\/div><\/span>/g,(t=>{const e=t.match(/href="([^"]+)"/);if(!e)return t;const r=e[1];let o="",n="";try{o=new URL(r).hostname.replace(/^www\./,"");const t=r.split("#:~:text=");if(t.length>1){n=decodeURIComponent(t[1]),n=n.replace(/%2C/g,",");const e=n.split(",");n=e.length>1&&e[0].trim()?` \u2014 ${e[0].trim()}...`:e[0].trim()?` \u2014 ${n.trim()}`:""}}catch(t){o=r}let i=this.footnotes.findIndex((t=>t.url===r));return-1===i?(this.footnoteCounter++,i=this.footnoteCounter,this.footnotes.push({url:r,text:`<a href="${r}">${o}</a>${n}`})):i++,`<span class="" data-state="closed"><sup id="fnref:${i}"><a href="#fn:${i}">${i}</a></sup></span>`})),l=l.replace(/<span[^>]*>\s*<\/span>/g,"").replace(/<p[^>]*>\s*<\/p>/g,""),t.push({author:i,content:l.trim(),metadata:{role:a||"unknown"}})})),t):t}getFootnotes(){return this.footnotes}getMetadata(){const t=this.getTitle(),e=this.extractMessages();return{title:t,site:"ChatGPT",url:this.url,messageCount:e.length,description:`ChatGPT conversation with ${e.length} messages`}}getTitle(){var t,e,r;const o=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(o&&"ChatGPT"!==o)return o;const n=null===(r=null===(e=this.articles)||void 0===e?void 0:e.item(0))||void 0===r?void 0:r.querySelector(".text-message");if(n){const t=n.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"ChatGPT Conversation"}}e.ChatGPTExtractor=n},640:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ALLOWED_ATTRIBUTES_DEBUG=e.ALLOWED_ATTRIBUTES=e.ALLOWED_EMPTY_ELEMENTS=e.FOOTNOTE_LIST_SELECTORS=e.FOOTNOTE_INLINE_REFERENCES=e.PARTIAL_SELECTORS=e.TEST_ATTRIBUTES=e.EXACT_SELECTORS=e.HIDDEN_ELEMENT_SELECTORS=e.INLINE_ELEMENTS=e.PRESERVE_ELEMENTS=e.BLOCK_ELEMENTS=e.MOBILE_WIDTH=e.ENTRY_POINT_ELEMENTS=e.NODE_TYPE=void 0,e.NODE_TYPE={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12},e.ENTRY_POINT_ELEMENTS=["article",'[role="article"]',".post-content",".article-content","#article-content",".article_post",".entry-content",".content-article",".markdown-body","main",'[role="main"]',"body"],e.MOBILE_WIDTH=600,e.BLOCK_ELEMENTS=["div","section","article","main"],e.PRESERVE_ELEMENTS=new Set(["pre","code","table","thead","tbody","tr","td","th","ul","ol","li","dl","dt","dd","figure","figcaption","picture","details","summary","blockquote","form","fieldset"]),e.INLINE_ELEMENTS=new Set(["a","span","strong","em","i","b","u","code","br","small","sub","sup","mark","del","ins","q","abbr","cite","time","font"]),e.HIDDEN_ELEMENT_SELECTORS=["[hidden]",'[aria-hidden="true"]:not([class*="math"])','[style*="display: none"]:not([class*="math"])','[style*="display:none"]:not([class*="math"])','[style*="visibility: hidden"]','[style*="visibility:hidden"]',".hidden",".invisible"].join(","),e.EXACT_SELECTORS=["noscript",'script:not([type^="math/"])',"style","meta","link",'.ad:not([class*="gradient"])','[class^="ad-" i]','[class$="-ad" i]','[id^="ad-" i]','[id$="-ad" i]','[role="banner" i]',".promo",".Promo","#barrier-page",'[id="comments" i]',"header",".header:not(.banner)","#header","#Header","#banner","#Banner","nav",".navigation","#navigation",'[role="navigation" i]','[role="dialog" i]','[role*="complementary" i]','[class*="pagination" i]',".menu","#menu","#siteSub",".fixed",".author",".Author",".contributor",".date","[data-date]",".meta",".tags",".toc",".Toc","#toc","#title","#Title","#articleTag",'[href*="/category"]','[href*="/categories"]','[href*="/tag/"]','[href*="/tags/"]','[href*="/topics"]','[href*="author"]','[href*="#toc"]','[href="#top"]','[href="#Top"]','[href="#site-content"]','[href="#main-content"]','[href^="#main"]','[src*="author"]',"footer",".aside","aside","button","canvas","dialog","fieldset","form",'input:not([type="checkbox"])',"label","option","select","textarea","time","instaread-player",'iframe:not([src*="youtube"]):not([src*="youtu.be"]):not([src*="vimeo"]):not([src*="twitter"]):not([src*="x.com"]):not([src*="datawrapper"])','[class="logo" i]',"#logo","#Logo","#newsletter","#Newsletter",".noprint",'[data-link-name*="skip" i]','[data-print-layout="hide" i]','[data-block="donotprint" i]','[class*="clickable-icon" i]','li span[class*="ltx_tag" i][class*="ltx_tag_item" i]','a[href^="#"][class*="anchor" i]','a[href^="#"][class*="ref" i]','[data-container*="most-viewed" i]',".sidebar",".Sidebar","#sidebar","#Sidebar","#sitesub",".gutter","#primaryaudio","#NYT_ABOVE_MAIN_CONTENT_REGION",'[data-testid="photoviewer-children-figure"] > span',"table.infobox",".pencraft:not(.pc-display-contents)",'[data-optimizely="related-articles-section" i]'],e.TEST_ATTRIBUTES=["class","id","data-test","data-testid","data-test-id","data-qa","data-cy"],e.PARTIAL_SELECTORS=["a-statement","access-wall","activitypub","actioncall","after_main_article","appendix","avatar","advert","adlayout","ad-tldr","ad-placement","_ad_","allterms","alert-box","around-the-web","aroundpages","article-author","article-bottom-section","article-bottom","article-category","article-citation","article__copy","article_date","article-end ","article_header","article-header","article__header","article__hero","article__info","article-info","article-meta","article_meta","article__meta","article-subject","article_subject","article-snippet","article-separator","article--share","article--topics","articletags","article-tags","article_tags","article-title","article_title","articletopics","article-topics","article--lede","articlewell","associated-people","audio-card","author-bio","author-box","author-info","author-mini-bio","author-name","author-publish-info","authored-by","back-to-top","backlink_container","backlinks-section","bio-block","biobox","blog-pager","bookmark-","-bookmark","bottominfo","bottom-of-article","bottom-wrapper","brand-bar","breadcrumb","button-wrapper","buttons-container","btn-","-btn","byline","captcha","card-text","card-media","card-post","cat_header","catlinks","chapter-list","collections","comments","commentbox","comment-button","commentcomp","comment-content","comment-count","comment-form","comment-number","comment-respond","comment-thread","complementary","consent","content-card","content-topics","contentpromo","context-bar","context-widget","core-collateral","creative-commons_","_cta","-cta","cta-","cta_","current-issue","custom-list-number","dateline","dateheader","date-header","date_header-","disclaimer","disclosure","discussion","discuss_","disqus","donate","donation","dropdown","eletters","emailsignup","engagement-widget","entry-author-info","entry-categories","entry-date","entry-meta","entry-title","entry-utility","eyebrow","expand-reduce","externallinkembedwrapper","extra-services","extra-title","facebook","fancy-box","favorite","feedback","feed-links","field-site-sections","fixheader","floating-vid","footer","footnote-back","footnoteback","for-you","frontmatter","further-reading","fullbleedheader","gated-","gh-feed","gist-meta","goog-","graph-view","hamburger","header_logo","header-logo","header-pattern","headlines","hero-list","hide-for-print","hide-print","hide-when-no-script","hidden-print","hidden-sidenote","hidden-accessibility","infoline","instacartIntegration","interlude","interaction","itemendrow","jumplink","jump-to-","keepreading","keep-reading","keep_reading","keyword_wrap","kicker","labstab","-labels","language-name","latest-content","-ledes-","-license","lightbox-popup","like-button","link-box","links-grid","links-title","listing-dynamic-terms","list-tags","listinks","loading","loa-info","logo_container","ltx_role_refnum","ltx_tag_bibitem","ltx_error","masthead","marketing","media-inquiry","-menu","menu-","metadata","might-like","minibio","more-about","_modal","-modal","more-","morenews","morestories","most-read","move-helper","mw-editsection","mw-cite-backlink","mw-indicators","mw-jump-link","nav-","nav_","navbar","next-","newsgallery","news-story-title","newsletter_","newsletter-form","newsletter-signup","newslettersignup","newsletterwidget","newsletterwrapper","not-found","notessection","nomobile","noprint","open-slideshow","originally-published","outline-view","overlay","page-title","paywall_message","-partners","plea","popular","popup_links","pop-up","popover","post-author","post-bottom","post__category","postcomment","postdate","post-date","post_date","post-feeds","postinfo","post-info","post_info","post-inline-date","post-links","post_list","post_meta","post-meta","postmeta","post-navigation","postsnippet","post_snippet","post-snippet","post-subject","posttax","post-tax","post_tax","posttag","post_tag","post-tag","post_time","posttitle","post-title","post_title","post__title","post-ufi-button","prevnext","prev_next","prev-next","previousnext","press-inquiries","print-none","print-header","privacy-notice","privacy-settings","profile","promo_article","promo-box","pubdate","pub_date","pub-date","publication-date","publicationName","qr-code","qr_code","quick_up","_rail","ratingssection","read_also","readmore","read-next","read_next","read_time","read-time","reading_time","reading-time","reading-list","recent-","recent-articles","recentpost","recent_post","recent-post","recommend","redirectedfrom","recirc","register","related","relevant","reversefootnote","screen-reader-text","section-nav","share-box","sharedaddy","share-icons","sharelinks","share-print","share-section","sidebartitle","sidebar_","sidebar-content","similar-","similar_","similars-","sideitems","sidebar-author","sidebar-item","side-box","side-logo","site-index","site-header","site-logo","site-name","site-wordpress","skip-content","c-skip-link","_skip-link","-slider","slug-wrap","social","speechify-ignore","sponsor","springercitation","_stats","storyreadtime","storypublishdate","subject-label","subhead","submenu","_tags","tags__item","tag_list","taxonomy","table-content","table-of-contents","tabs-","terminaltout","time-rubric","timestamp","time-to-read","tip_off","tiptout","-tout-","-toc","toggle-caption","tooltip","topbar","topic-list","top-wrapper","tree-item","trending","trust-feat","trust-badge","twitter","u-hide","viewbottom","visually-hidden","welcomebox"],e.FOOTNOTE_INLINE_REFERENCES=["sup.reference","cite.ltx_cite",'sup[id^="fnr"]','sup[id^="fnref:"]',"span.footnote-link","a.citation",'a[id^="ref-link"]','a[href^="#fn"]','a[href^="#cite"]','a[href^="#reference"]','a[href^="#footnote"]','a[href^="#r"]','a[href^="#b"]','a[href*="cite_note"]','a[href*="cite_ref"]',"a.footnote-anchor","span.footnote-hovercard-target a",'a[role="doc-biblioref"]','a[id^="fnref"]','a[id^="ref-link"]'].join(","),e.FOOTNOTE_LIST_SELECTORS=["div.footnote ol","div.footnotes ol",'div[role="doc-endnotes"]','div[role="doc-footnotes"]',"ol.footnotes-list","ol.footnotes","ol.references",'ol[class*="article-references"]',"section.footnotes ol",'section[role="doc-endnotes"]','section[role="doc-footnotes"]','section[role="doc-bibliography"]',"ul.footnotes-list","ul.ltx_biblist",'div.footnote[data-component-name="FootnoteToDOM"]'].join(","),e.ALLOWED_EMPTY_ELEMENTS=new Set(["area","audio","base","br","circle","col","defs","ellipse","embed","figure","g","hr","iframe","img","input","line","link","mask","meta","object","param","path","pattern","picture","polygon","polyline","rect","source","stop","svg","td","th","track","use","video","wbr"]),e.ALLOWED_ATTRIBUTES=new Set(["alt","allow","allowfullscreen","aria-label","checked","colspan","controls","data-latex","data-src","data-srcset","data-lang","dir","display","frameborder","headers","height","href","lang","role","rowspan","src","srcset","title","type","width","accent","accentunder","align","columnalign","columnlines","columnspacing","columnspan","data-mjx-texclass","depth","displaystyle","fence","frame","framespacing","linethickness","lspace","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","rowalign","rowlines","rowspacing","rowspan","rspace","scriptlevel","separator","stretchy","symmetric","voffset","xmlns"]),e.ALLOWED_ATTRIBUTES_DEBUG=new Set(["class","id"])},732:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GeminiExtractor=void 0;const o=r(181);class n extends o.ConversationExtractor{constructor(t,e){super(t,e),this.messageCount=null,this.conversationContainers=t.querySelectorAll("div.conversation-container"),this.footnotes=[]}canExtract(){return!!this.conversationContainers&&this.conversationContainers.length>0}extractMessages(){this.messageCount=0;const t=[];return this.conversationContainers?(this.extractSources(),this.conversationContainers.forEach((e=>{const r=e.querySelector("user-query");if(r){const e=r.querySelector(".query-text");if(e){const r=e.innerHTML||"";t.push({author:"You",content:r.trim(),metadata:{role:"user"}})}}const o=e.querySelector("model-response");if(o){const e=o.querySelector(".model-response-text .markdown"),r=o.querySelector("#extended-response-markdown-content")||e;if(r){let e=r.innerHTML||"";const o=document.createElement("div");o.innerHTML=e,o.querySelectorAll(".table-content").forEach((t=>{t.classList.remove("table-content")})),e=o.innerHTML,t.push({author:"Gemini",content:e.trim(),metadata:{role:"assistant"}})}}})),this.messageCount=t.length,t):t}extractSources(){const t=this.document.querySelectorAll("browse-item");t&&t.length>0&&t.forEach((t=>{var e,r,o,n;const i=t.querySelector("a");if(i instanceof HTMLAnchorElement){const t=i.href,a=(null===(r=null===(e=i.querySelector(".domain"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",s=(null===(n=null===(o=i.querySelector(".title"))||void 0===o?void 0:o.textContent)||void 0===n?void 0:n.trim())||"";t&&(a||s)&&this.footnotes.push({url:t,text:s?`${a}: ${s}`:a})}}))}getFootnotes(){return this.footnotes}getMetadata(){var t;const e=this.getTitle(),r=null!==(t=this.messageCount)&&void 0!==t?t:this.extractMessages().length;return{title:e,site:"Gemini",url:this.url,messageCount:r,description:`Gemini conversation with ${r} messages`}}getTitle(){var t,e,r,o,n;const i=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(i&&"Gemini"!==i&&!i.includes("Gemini"))return i;const a=null===(r=null===(e=this.document.querySelector(".title-text"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim();if(a)return a;const s=null===(n=null===(o=this.conversationContainers)||void 0===o?void 0:o.item(0))||void 0===n?void 0:n.querySelector(".query-text");if(s){const t=s.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"Gemini Conversation"}}e.GeminiExtractor=n},754:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.codeBlockRules=void 0;const r=[/^language-(\w+)$/,/^lang-(\w+)$/,/^(\w+)-code$/,/^code-(\w+)$/,/^syntax-(\w+)$/,/^code-snippet__(\w+)$/,/^highlight-(\w+)$/,/^(\w+)-snippet$/,/(?:^|\s)(?:language|lang|brush|syntax)-(\w+)(?:\s|$)/i],o=new Set(["abap","actionscript","ada","adoc","agda","antlr4","applescript","arduino","armasm","asciidoc","aspnet","atom","bash","batch","c","clojure","cmake","cobol","coffeescript","cpp","c++","crystal","csharp","cs","dart","django","dockerfile","dotnet","elixir","elm","erlang","fortran","fsharp","gdscript","gitignore","glsl","golang","gradle","graphql","groovy","haskell","hs","haxe","hlsl","html","idris","java","javascript","js","jsx","jsdoc","json","jsonp","julia","kotlin","latex","lisp","elisp","livescript","lua","makefile","markdown","md","markup","masm","mathml","matlab","mongodb","mysql","nasm","nginx","nim","nix","objc","ocaml","pascal","perl","php","postgresql","powershell","prolog","puppet","python","regex","rss","ruby","rb","rust","scala","scheme","shell","sh","solidity","sparql","sql","ssml","svg","swift","tcl","terraform","tex","toml","typescript","ts","tsx","unrealscript","verilog","vhdl","webassembly","wasm","xml","yaml","yml","zig"]);e.codeBlockRules=[{selector:["pre",'div[class*="prismjs"]',".syntaxhighlighter",".highlight",".highlight-source",".wp-block-syntaxhighlighter-code",".wp-block-code",'div[class*="language-"]'].join(", "),element:"pre",transform:t=>{if(!(t instanceof HTMLElement))return t;const e=t=>{const e=t.getAttribute("data-lang")||t.getAttribute("data-language");if(e)return e.toLowerCase();const n=Array.from(t.classList);if(t.classList.contains("syntaxhighlighter")){const t=n.find((t=>!["syntaxhighlighter","nogutter"].includes(t)));if(t&&o.has(t.toLowerCase()))return t.toLowerCase()}for(const t of n)for(const e of r){const r=t.toLowerCase().match(e);if(r&&r[1]&&o.has(r[1].toLowerCase()))return r[1].toLowerCase()}for(const t of n)if(o.has(t.toLowerCase()))return t.toLowerCase();return""};let n="",i=t;for(;i&&!n;)n=e(i),!n&&i.querySelector("code")&&(n=e(i.querySelector("code"))),i=i.parentElement;const a=t=>{if(t.nodeType===Node.TEXT_NODE)return t.textContent||"";let e="";if(t instanceof HTMLElement){if("BR"===t.tagName)return"\n";if(t.matches('div[class*="line"], span[class*="line"], .ec-line, [data-line-number], [data-line]')){const e=t.querySelector('.code, .content, [class*="code-"], [class*="content-"]');if(e)return(e.textContent||"")+"\n";const r=t.querySelector('.line-number, .gutter, [class*="line-number"], [class*="gutter"]');if(r){return Array.from(t.childNodes).filter((t=>!r.contains(t))).map((t=>a(t))).join("")+"\n"}return t.textContent+"\n"}t.childNodes.forEach((t=>{e+=a(t)}))}return e};let s="";t.matches(".syntaxhighlighter, .wp-block-syntaxhighlighter-code")&&(s=(t=>{const e=t.querySelector(".syntaxhighlighter table .code .container");if(e)return Array.from(e.children).map((t=>{const e=Array.from(t.querySelectorAll("code")).map((t=>{let e=t.textContent||"";return t.classList.contains("spaces")&&(e=" ".repeat(e.length)),e})).join("");return e||t.textContent||""})).join("\n");const r=t.querySelectorAll(".code .line");return r.length>0?Array.from(r).map((t=>{const e=Array.from(t.querySelectorAll("code")).map((t=>t.textContent||"")).join("");return e||t.textContent||""})).join("\n"):""})(t)),s||(s=a(t)),s=s.replace(/^\s+|\s+$/g,"").replace(/\t/g," ").replace(/\n{3,}/g,"\n\n").replace(/\u00a0/g," ").replace(/^\n+/,"").replace(/\n+$/,"");const l=document.createElement("pre"),c=document.createElement("code");return n&&(c.setAttribute("data-lang",n),c.setAttribute("class",`language-${n}`)),c.textContent=s,l.appendChild(c),l}}]},759:t=>{t.exports=e},864:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.headingRules=void 0;const o=r(640);e.headingRules=[{selector:"h1, h2, h3, h4, h5, h6",element:"keep",transform:t=>{var e;const r=t.ownerDocument;if(!r)return console.warn("No document available"),t;const n=r.createElement(t.tagName);Array.from(t.attributes).forEach((t=>{o.ALLOWED_ATTRIBUTES.has(t.name)&&n.setAttribute(t.name,t.value)}));const i=t.cloneNode(!0),a=new Map;Array.from(i.querySelectorAll("*")).forEach((t=>{var e,r,o,n,s,l;let c=!1;if("a"===t.tagName.toLowerCase()){const r=t.getAttribute("href");((null==r?void 0:r.includes("#"))||(null==r?void 0:r.startsWith("#")))&&(a.set(t,(null===(e=t.textContent)||void 0===e?void 0:e.trim())||""),c=!0)}if(t.classList.contains("anchor")&&(a.set(t,(null===(r=t.textContent)||void 0===r?void 0:r.trim())||""),c=!0),"button"===t.tagName.toLowerCase()&&(c=!0),("span"===t.tagName.toLowerCase()||"div"===t.tagName.toLowerCase())&&t.querySelector('a[href^="#"]')){const e=t.querySelector('a[href^="#"]');e&&a.set(t,(null===(o=e.textContent)||void 0===o?void 0:o.trim())||""),c=!0}if(c){const e=t.parentElement;e&&e!==i&&(null===(n=e.textContent)||void 0===n?void 0:n.trim())===(null===(s=t.textContent)||void 0===s?void 0:s.trim())&&a.set(e,(null===(l=t.textContent)||void 0===l?void 0:l.trim())||"")}}));Array.from(i.querySelectorAll("*")).filter((t=>{if("a"===t.tagName.toLowerCase()){const e=t.getAttribute("href");return(null==e?void 0:e.includes("#"))||(null==e?void 0:e.startsWith("#"))}return!!t.classList.contains("anchor")||("button"===t.tagName.toLowerCase()||!("span"!==t.tagName.toLowerCase()&&"div"!==t.tagName.toLowerCase()||!t.querySelector('a[href^="#"]')))})).forEach((t=>t.remove()));let s=(null===(e=i.textContent)||void 0===e?void 0:e.trim())||"";return!s&&a.size>0&&(s=Array.from(a.values())[0]),n.textContent=s,n}}]},917:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExtractorRegistry=void 0;const o=r(959),n=r(248),i=r(258),a=r(458),s=r(632),l=r(397),c=r(732);class d{static initialize(){this.register({patterns:["twitter.com",/\/x\.com\/.*/],extractor:n.TwitterExtractor}),this.register({patterns:["reddit.com","old.reddit.com","new.reddit.com",/^https:\/\/[^\/]+\.reddit\.com/],extractor:o.RedditExtractor}),this.register({patterns:["youtube.com","youtu.be",/youtube\.com\/watch\?v=.*/,/youtu\.be\/.*/],extractor:i.YoutubeExtractor}),this.register({patterns:[/news\.ycombinator\.com\/item\?id=.*/],extractor:a.HackerNewsExtractor}),this.register({patterns:[/^https?:\/\/chatgpt\.com\/(c|share)\/.*/],extractor:s.ChatGPTExtractor}),this.register({patterns:[/^https?:\/\/claude\.ai\/(chat|share)\/.*/],extractor:l.ClaudeExtractor}),this.register({patterns:[/^https?:\/\/gemini\.google\.com\/app\/.*/],extractor:c.GeminiExtractor})}static register(t){this.mappings.push(t)}static findExtractor(t,e,r){try{const o=new URL(e).hostname;if(this.domainCache.has(o)){const n=this.domainCache.get(o);return n?new n(t,e,r):null}for(const{patterns:n,extractor:i}of this.mappings){if(n.some((t=>t instanceof RegExp?t.test(e):o.includes(t))))return this.domainCache.set(o,i),new i(t,e,r)}return this.domainCache.set(o,null),null}catch(t){return console.error("Error in findExtractor:",t),null}}static clearCache(){this.domainCache.clear()}}e.ExtractorRegistry=d,d.mappings=[],d.domainCache=new Map,d.initialize()},959:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RedditExtractor=void 0;const o=r(279);class n extends o.BaseExtractor{constructor(t,e){super(t,e),this.shredditPost=t.querySelector("shreddit-post")}canExtract(){return!!this.shredditPost}extract(){var t,e;const r=this.getPostContent(),o=this.extractComments(),n=this.createContentHtml(r,o),i=(null===(e=null===(t=this.document.querySelector("h1"))||void 0===t?void 0:t.textContent)||void 0===e?void 0:e.trim())||"",a=this.getSubreddit(),s=this.getPostAuthor(),l=this.createDescription(r);return{content:n,contentHtml:n,extractedContent:{postId:this.getPostId(),subreddit:a,postAuthor:s},variables:{title:i,author:s,site:`r/${a}`,description:l}}}getPostContent(){var t,e,r,o;return((null===(e=null===(t=this.shredditPost)||void 0===t?void 0:t.querySelector('[slot="text-body"]'))||void 0===e?void 0:e.innerHTML)||"")+((null===(o=null===(r=this.shredditPost)||void 0===r?void 0:r.querySelector("#post-image"))||void 0===o?void 0:o.outerHTML)||"")}createContentHtml(t,e){return`\n\t\t\t<div class="reddit-post">\n\t\t\t\t<div class="post-content">\n\t\t\t\t\t${t}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t${e?`\n\t\t\t\t<hr>\n\t\t\t\t<h2>Comments</h2>\n\t\t\t\t<div class="reddit-comments">\n\t\t\t\t\t${e}\n\t\t\t\t</div>\n\t\t\t`:""}\n\t\t`.trim()}extractComments(){const t=Array.from(this.document.querySelectorAll("shreddit-comment"));return this.processComments(t)}getPostId(){const t=this.url.match(/comments\/([a-zA-Z0-9]+)/);return(null==t?void 0:t[1])||""}getSubreddit(){const t=this.url.match(/\/r\/([^/]+)/);return(null==t?void 0:t[1])||""}getPostAuthor(){var t;return(null===(t=this.shredditPost)||void 0===t?void 0:t.getAttribute("author"))||""}createDescription(t){var e;if(!t)return"";const r=document.createElement("div");return r.innerHTML=t,(null===(e=r.textContent)||void 0===e?void 0:e.trim().slice(0,140).replace(/\s+/g," "))||""}processComments(t){var e;let r="",o=-1,n=[];for(const i of t){const t=parseInt(i.getAttribute("depth")||"0"),a=i.getAttribute("author")||"",s=i.getAttribute("score")||"0",l=i.getAttribute("permalink")||"",c=(null===(e=i.querySelector('[slot="comment"]'))||void 0===e?void 0:e.innerHTML)||"",d=i.querySelector("faceplate-timeago"),u=(null==d?void 0:d.getAttribute("ts"))||"",m=u?new Date(u).toISOString().split("T")[0]:"";if(0===t){for(;n.length>0;)r+="</blockquote>",n.pop();r+="<blockquote>",n=[0],o=0}else if(t<o)for(;n.length>0&&n[n.length-1]>=t;)r+="</blockquote>",n.pop();else t>o&&(r+="<blockquote>",n.push(t));r+=`<div class="comment">\n\t<div class="comment-metadata">\n\t\t<span class="comment-author"><strong>${a}</strong></span> \u2022\n\t\t<a href="https://reddit.com${l}" class="comment-link">${s} points</a> \u2022\n\t\t<span class="comment-date">${m}</span>\n\t</div>\n\t<div class="comment-content">${c}</div>\n</div>`,o=t}for(;n.length>0;)r+="</blockquote>",n.pop();return r}}e.RedditExtractor=n},968:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentScorer=void 0;const o=r(640);e.ContentScorer=class{static scoreElement(t){let e=0;const r=t.textContent||"",n=r.split(/\s+/).length;e+=n;e+=10*t.getElementsByTagName("p").length;e-=5*(t.getElementsByTagName("a").length/(n||1));e-=3*(t.getElementsByTagName("img").length/(n||1));try{const r=t.getAttribute("style")||"",o=t.getAttribute("align")||"";(r.includes("float: right")||r.includes("text-align: right")||"right"===o)&&(e+=5)}catch(t){}/\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\s+\d{1,2},?\s+\d{4}\b/i.test(r)&&(e+=10);/\b(?:by|written by|author:)\s+[A-Za-z\s]+\b/i.test(r)&&(e+=10);const i=t.className.toLowerCase();(i.includes("content")||i.includes("article")||i.includes("post"))&&(e+=15);t.querySelector(o.FOOTNOTE_INLINE_REFERENCES)&&(e+=10);if(e-=5*t.getElementsByTagName("table").length,"td"===t.tagName.toLowerCase()){const r=t.closest("table");if(r){const o=parseInt(r.getAttribute("width")||"0"),n=r.getAttribute("align")||"",i=r.className.toLowerCase();if(o>400||"center"===n||i.includes("content")||i.includes("article")){const o=Array.from(r.getElementsByTagName("td")),n=o.indexOf(t);n>0&&n<o.length-1&&(e+=10)}}}return e}static findBestElement(t,e=50){let r=null,o=0;return t.forEach((t=>{const e=this.scoreElement(t);e>o&&(o=e,r=t)})),o>e?r:null}}},974:function(t,e,r){var o,n=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,o,n)}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||(o=function(t){return o=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},o(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=o(t),a=0;a<r.length;a++)"default"!==r[a]&&n(e,t,r[a]);return i(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.mathRules=e.createCleanMathEl=e.getLatexFromElement=void 0;const s=r(594),l=a(r(759)),c=r(282);e.getLatexFromElement=t=>{const e=(0,c.getBasicLatexFromElement)(t);if(e)return e;const r=(0,c.getMathMLFromElement)(t);if(null==r?void 0:r.mathml)try{return s.MathMLToLaTeX.convert(r.mathml)}catch(t){console.warn("Failed to convert MathML to LaTeX:",t)}return null};e.createCleanMathEl=(t,e,r,o)=>{const n=o.createElement("math");if(n.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),n.setAttribute("display",r?"block":"inline"),n.setAttribute("data-latex",e||""),null==t?void 0:t.mathml){const e=o.createElement("div");e.innerHTML=t.mathml;const r=e.querySelector("math");r&&(n.innerHTML=r.innerHTML)}else if(e)try{const t=l.renderToString(e,{displayMode:r,throwOnError:!1}),i=o.createElement("div");i.innerHTML=t;const a=i.querySelector("math");a?n.innerHTML=a.innerHTML:n.textContent=e}catch(t){console.warn("Failed to convert LaTeX to MathML:",t),n.textContent=e}return n},e.mathRules=[{selector:c.mathSelectors,element:"math",transform:t=>{if(!("style"in t)||!("className"in t))return t;const r=(0,c.getMathMLFromElement)(t),o=(0,e.getLatexFromElement)(t),n=(0,c.isBlockDisplay)(t),i=(0,e.createCleanMathEl)(r,o,n,t.ownerDocument);if(t.parentElement){t.parentElement.querySelectorAll('script[type^="math/"], .MathJax_Preview, script[type="text/javascript"][src*="mathjax"], script[type="text/javascript"][src*="katex"]').forEach((t=>t.remove()))}return i}}]}},o={};function n(t){var e=o[t];if(void 0!==e)return e.exports;var i=o[t]={exports:{}};return r[t].call(i.exports,i,i.exports,n),i.exports}var i={};return(()=>{var t=i;const e=n(628);t.default=e.Defuddle})(),i=i.default})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("mathml-to-latex"),require("temml")):"function"==typeof define&&define.amd?define(["mathml-to-latex","temml"],e):"object"==typeof exports?exports.Defuddle=e(require("mathml-to-latex"),require("temml")):t.Defuddle=e(t["mathml-to-latex"],t.temml)}("undefined"!=typeof self?self:this,((t,e)=>(()=>{"use strict";var r={181:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ConversationExtractor=void 0;const n=r(279),o=r(628);class i extends n.BaseExtractor{getFootnotes(){return[]}extract(){var t;const e=this.extractMessages(),r=this.getMetadata(),n=this.getFootnotes(),i=this.createContentHtml(e,n),a=document.implementation.createHTMLDocument(),s=a.createElement("article");s.innerHTML=i,a.body.appendChild(s);const l=new o.Defuddle(a).parse(),c=l.content;return{content:c,contentHtml:c,extractedContent:{messageCount:e.length.toString()},variables:{title:r.title||"Conversation",site:r.site,description:r.description||`${r.site} conversation with ${e.length} messages`,wordCount:(null===(t=l.wordCount)||void 0===t?void 0:t.toString())||""}}}createContentHtml(t,e){return`${t.map(((e,r)=>{const n=e.timestamp?`<div class="message-timestamp">${e.timestamp}</div>`:"",o=/<p[^>]*>[\s\S]*?<\/p>/i.test(e.content)?e.content:`<p>${e.content}</p>`,i=e.metadata?Object.entries(e.metadata).map((([t,e])=>`data-${t}="${e}"`)).join(" "):"";return`\n\t\t\t<div class="message message-${e.author.toLowerCase()}" ${i}>\n\t\t\t\t<div class="message-header">\n\t\t\t\t\t<p class="message-author"><strong>${e.author}</strong></p>\n\t\t\t\t\t${n}\n\t\t\t\t</div>\n\t\t\t\t<div class="message-content">\n\t\t\t\t\t${o}\n\t\t\t\t</div>\n\t\t\t</div>${r<t.length-1?"\n<hr>":""}`})).join("\n").trim()}\n${e.length>0?`\n\t\t\t<div id="footnotes">\n\t\t\t\t<ol>\n\t\t\t\t\t${e.map(((t,e)=>`\n\t\t\t\t\t\t<li class="footnote" id="fn:${e+1}">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t<a href="${t.url}" target="_blank">${t.text}</a>&nbsp;<a href="#fnref:${e+1}" class="footnote-backref">\u21a9</a>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t`)).join("")}\n\t\t\t\t</ol>\n\t\t\t</div>`:""}`.trim()}}e.ConversationExtractor=i},248:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TwitterExtractor=void 0;const n=r(279);class o extends n.BaseExtractor{constructor(t,e){var r;super(t,e),this.mainTweet=null,this.threadTweets=[];const n=t.querySelector('[aria-label="Timeline: Conversation"]');if(!n){const e=t.querySelector('article[data-testid="tweet"]');return void(e&&(this.mainTweet=e))}const o=Array.from(n.querySelectorAll('article[data-testid="tweet"]')),i=null===(r=n.querySelector("section, h2"))||void 0===r?void 0:r.parentElement;i&&o.forEach(((t,e)=>{if(i.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)return o.splice(e),!1})),this.mainTweet=o[0]||null,this.threadTweets=o.slice(1)}canExtract(){return!!this.mainTweet}extract(){const t=this.extractTweet(this.mainTweet),e=this.threadTweets.map((t=>this.extractTweet(t))).join("\n<hr>\n"),r=`\n\t\t\t<div class="tweet-thread">\n\t\t\t\t<div class="main-tweet">\n\t\t\t\t\t${t}\n\t\t\t\t</div>\n\t\t\t\t${e?`\n\t\t\t\t\t<hr>\n\t\t\t\t\t<div class="thread-tweets">\n\t\t\t\t\t\t${e}\n\t\t\t\t\t</div>\n\t\t\t\t`:""}\n\t\t\t</div>\n\t\t`.trim(),n=this.getTweetId(),o=this.getTweetAuthor();return{content:r,contentHtml:r,extractedContent:{tweetId:n,tweetAuthor:o},variables:{title:`Thread by ${o}`,author:o,site:"X (Twitter)",description:this.createDescription(this.mainTweet)}}}formatTweetText(t){if(!t)return"";const e=document.createElement("div");e.innerHTML=t,e.querySelectorAll("a").forEach((t=>{var e;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";t.replaceWith(r)})),e.querySelectorAll("span, div").forEach((t=>{t.replaceWith(...Array.from(t.childNodes))}));return e.innerHTML.split("\n").map((t=>t.trim())).filter((t=>t)).map((t=>`<p>${t}</p>`)).join("\n")}extractTweet(t){var e,r,n;if(!t)return"";const o=t.cloneNode(!0);o.querySelectorAll('img[src*="/emoji/"]').forEach((t=>{if("img"===t.tagName.toLowerCase()&&t.getAttribute("alt")){const e=t.getAttribute("alt");e&&t.replaceWith(e)}}));const i=(null===(e=o.querySelector('[data-testid="tweetText"]'))||void 0===e?void 0:e.innerHTML)||"",a=this.formatTweetText(i),s=this.extractImages(t),l=this.extractUserInfo(t),c=null===(n=null===(r=t.querySelector('[aria-labelledby*="id__"]'))||void 0===r?void 0:r.querySelector('[data-testid="User-Name"]'))||void 0===n?void 0:n.closest('[aria-labelledby*="id__"]'),d=c?this.extractTweet(c):"";return`\n\t\t\t<div class="tweet">\n\t\t\t\t<div class="tweet-header">\n\t\t\t\t\t<span class="tweet-author"><strong>${l.fullName}</strong> <span class="tweet-handle">${l.handle}</span></span>\n\t\t\t\t\t${l.date?`<a href="${l.permalink}" class="tweet-date">${l.date}</a>`:""}\n\t\t\t\t</div>\n\t\t\t\t${a?`<div class="tweet-text">${a}</div>`:""}\n\t\t\t\t${s.length?`\n\t\t\t\t\t<div class="tweet-media">\n\t\t\t\t\t\t${s.join("\n")}\n\t\t\t\t\t</div>\n\t\t\t\t`:""}\n\t\t\t\t${d?`\n\t\t\t\t\t<blockquote class="quoted-tweet">\n\t\t\t\t\t\t${d}\n\t\t\t\t\t</blockquote>\n\t\t\t\t`:""}\n\t\t\t</div>\n\t\t`.trim()}extractUserInfo(t){var e,r,n,o,i,a,s,l,c;const d=t.querySelector('[data-testid="User-Name"]');if(!d)return{fullName:"",handle:"",date:"",permalink:""};const u=d.querySelectorAll("a");let m=(null===(r=null===(e=null==u?void 0:u[0])||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",h=(null===(o=null===(n=null==u?void 0:u[1])||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||"";m&&h||(m=(null===(a=null===(i=d.querySelector('span[style*="color: rgb(15, 20, 25)"] span'))||void 0===i?void 0:i.textContent)||void 0===a?void 0:a.trim())||"",h=(null===(l=null===(s=d.querySelector('span[style*="color: rgb(83, 100, 113)"]'))||void 0===s?void 0:s.textContent)||void 0===l?void 0:l.trim())||"");const p=t.querySelector("time"),g=(null==p?void 0:p.getAttribute("datetime"))||"";return{fullName:m,handle:h,date:g?new Date(g).toISOString().split("T")[0]:"",permalink:(null===(c=null==p?void 0:p.closest("a"))||void 0===c?void 0:c.href)||""}}extractImages(t){var e,r;const n=['[data-testid="tweetPhoto"]','[data-testid="tweet-image"]','img[src*="media"]'],o=[],i=null===(r=null===(e=t.querySelector('[aria-labelledby*="id__"]'))||void 0===e?void 0:e.querySelector('[data-testid="User-Name"]'))||void 0===r?void 0:r.closest('[aria-labelledby*="id__"]');for(const e of n){t.querySelectorAll(e).forEach((t=>{var e,r;if(!(null==i?void 0:i.contains(t))&&"img"===t.tagName.toLowerCase()&&t.getAttribute("alt")){const n=(null===(e=t.getAttribute("src"))||void 0===e?void 0:e.replace(/&name=\w+$/,"&name=large"))||"",i=(null===(r=t.getAttribute("alt"))||void 0===r?void 0:r.replace(/\s+/g," ").trim())||"";o.push(`<img src="${n}" alt="${i}" />`)}}))}return o}getTweetId(){const t=this.url.match(/status\/(\d+)/);return(null==t?void 0:t[1])||""}getTweetAuthor(){var t,e,r;const n=null===(t=this.mainTweet)||void 0===t?void 0:t.querySelector('[data-testid="User-Name"]'),o=null==n?void 0:n.querySelectorAll("a"),i=(null===(r=null===(e=null==o?void 0:o[1])||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"";return i.startsWith("@")?i:`@${i}`}createDescription(t){var e;if(!t)return"";return((null===(e=t.querySelector('[data-testid="tweetText"]'))||void 0===e?void 0:e.textContent)||"").trim().slice(0,140).replace(/\s+/g," ")}}e.TwitterExtractor=o},258:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.YoutubeExtractor=void 0;const n=r(279);class o extends n.BaseExtractor{constructor(t,e,r){super(t,e,r),this.videoElement=t.querySelector("video"),this.schemaOrgData=r}canExtract(){return!0}extract(){const t=this.getVideoData(),e=t.description||"",r=this.formatDescription(e),n=`<iframe width="560" height="315" src="https://www.youtube.com/embed/${this.getVideoId()}?si=_m0qv33lAuJFoGNh" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br>${r}`;return{content:n,contentHtml:n,extractedContent:{videoId:this.getVideoId(),author:t.author||""},variables:{title:t.name||"",author:t.author||"",site:"YouTube",image:Array.isArray(t.thumbnailUrl)&&t.thumbnailUrl[0]||"",published:t.uploadDate,description:e.slice(0,200).trim()}}}formatDescription(t){return`<p>${t.replace(/\n/g,"<br>")}</p>`}getVideoData(){if(!this.schemaOrgData)return{};return(Array.isArray(this.schemaOrgData)?this.schemaOrgData.find((t=>"VideoObject"===t["@type"])):"VideoObject"===this.schemaOrgData["@type"]?this.schemaOrgData:null)||{}}getVideoId(){return new URLSearchParams(new URL(this.url).search).get("v")||""}}e.YoutubeExtractor=o},279:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseExtractor=void 0;e.BaseExtractor=class{constructor(t,e,r){this.document=t,this.url=e,this.schemaOrgData=r}}},282:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.mathSelectors=e.isBlockDisplay=e.getBasicLatexFromElement=e.getMathMLFromElement=void 0;e.getMathMLFromElement=t=>{if("math"===t.tagName.toLowerCase()){const e="block"===t.getAttribute("display");return{mathml:t.outerHTML,latex:t.getAttribute("alttext")||null,isBlock:e}}const e=t.getAttribute("data-mathml");if(e){const t=document.createElement("div");t.innerHTML=e;const r=t.querySelector("math");if(r){const t="block"===r.getAttribute("display");return{mathml:r.outerHTML,latex:r.getAttribute("alttext")||null,isBlock:t}}}const r=t.querySelector(".MJX_Assistive_MathML, mjx-assistive-mml");if(r){const t=r.querySelector("math");if(t){const e=t.getAttribute("display"),n=r.getAttribute("display"),o="block"===e||"block"===n;return{mathml:t.outerHTML,latex:t.getAttribute("alttext")||null,isBlock:o}}}const n=t.querySelector(".katex-mathml math");return n?{mathml:n.outerHTML,latex:null,isBlock:!1}:null};e.getBasicLatexFromElement=t=>{var e,r,n;const o=t.getAttribute("data-latex");if(o)return o;if("img"===t.tagName.toLowerCase()&&t.classList.contains("latex")){const e=t.getAttribute("alt");if(e)return e;const r=t.getAttribute("src");if(r){const t=r.match(/latex\.php\?latex=([^&]+)/);if(t)return decodeURIComponent(t[1]).replace(/\+/g," ").replace(/%5C/g,"\\")}}const i=t.querySelector('annotation[encoding="application/x-tex"]');if(null==i?void 0:i.textContent)return i.textContent.trim();if(t.matches(".katex")){const e=t.querySelector('.katex-mathml annotation[encoding="application/x-tex"]');if(null==e?void 0:e.textContent)return e.textContent.trim()}if(t.matches('script[type="math/tex"]')||t.matches('script[type="math/tex; mode=display"]'))return(null===(e=t.textContent)||void 0===e?void 0:e.trim())||null;if(t.parentElement){const e=t.parentElement.querySelector('script[type="math/tex"], script[type="math/tex; mode=display"]');if(e)return(null===(r=e.textContent)||void 0===r?void 0:r.trim())||null}return t.getAttribute("alt")||(null===(n=t.textContent)||void 0===n?void 0:n.trim())||null};e.isBlockDisplay=t=>{if("block"===t.getAttribute("display"))return!0;const e=t.className.toLowerCase();if(e.includes("display")||e.includes("block"))return!0;if(t.closest('.katex-display, .MathJax_Display, [data-display="block"]'))return!0;const r=t.previousElementSibling;if("p"===(null==r?void 0:r.tagName.toLowerCase()))return!0;if(t.matches(".mwe-math-fallback-image-display"))return!0;if(t.matches(".katex"))return null!==t.closest(".katex-display");if(t.hasAttribute("display"))return"true"===t.getAttribute("display");if(t.matches('script[type="math/tex; mode=display"]'))return!0;if(t.hasAttribute("display"))return"true"===t.getAttribute("display");const n=t.closest("[display]");return!!n&&"true"===n.getAttribute("display")},e.mathSelectors=['img.latex[src*="latex.php"]',"span.MathJax","mjx-container",'script[type="math/tex"]','script[type="math/tex; mode=display"]','.MathJax_Preview + script[type="math/tex"]',".MathJax_Display",".MathJax_SVG",".MathJax_MathML",".mwe-math-element",".mwe-math-fallback-image-inline",".mwe-math-fallback-image-display",".mwe-math-mathml-inline",".mwe-math-mathml-display",".katex",".katex-display",".katex-mathml",".katex-html","[data-katex]",'script[type="math/katex"]',"math","[data-math]","[data-latex]","[data-tex]",'script[type^="math/"]','annotation[encoding="application/x-tex"]'].join(",")},397:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ClaudeExtractor=void 0;const n=r(181);class o extends n.ConversationExtractor{constructor(t,e){super(t,e),this.articles=t.querySelectorAll('div[data-testid="user-message"], div[data-testid="assistant-message"], div.font-claude-message')}canExtract(){return!!this.articles&&this.articles.length>0}extractMessages(){const t=[];return this.articles?(this.articles.forEach((e=>{let r,n;if(e.hasAttribute("data-testid")){if("user-message"!==e.getAttribute("data-testid"))return;r="you",n=e.innerHTML}else{if(!e.classList.contains("font-claude-message"))return;r="assistant",n=e.innerHTML}n&&t.push({author:"you"===r?"You":"Claude",content:n.trim(),metadata:{role:r}})})),t):t}getMetadata(){const t=this.getTitle(),e=this.extractMessages();return{title:t,site:"Claude",url:this.url,messageCount:e.length,description:`Claude conversation with ${e.length} messages`}}getTitle(){var t,e,r,n,o;const i=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(i&&"Claude"!==i)return i.replace(/ - Claude$/,"");const a=null===(r=null===(e=this.document.querySelector("header .font-tiempos"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim();if(a)return a;const s=null===(o=null===(n=this.articles)||void 0===n?void 0:n.item(0))||void 0===o?void 0:o.querySelector('[data-testid="user-message"]');if(s){const t=s.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"Claude Conversation"}}e.ClaudeExtractor=o},458:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HackerNewsExtractor=void 0;const n=r(279);class o extends n.BaseExtractor{constructor(t,e){super(t,e),this.mainPost=t.querySelector(".fatitem"),this.isCommentPage=this.detectCommentPage(),this.mainComment=this.isCommentPage?this.findMainComment():null}detectCommentPage(){var t;return!!(null===(t=this.mainPost)||void 0===t?void 0:t.querySelector('.navs a[href*="parent"]'))}findMainComment(){var t;return(null===(t=this.mainPost)||void 0===t?void 0:t.querySelector(".comment"))||null}canExtract(){return!!this.mainPost}extract(){const t=this.getPostContent(),e=this.extractComments(),r=this.createContentHtml(t,e),n=this.getPostTitle(),o=this.getPostAuthor(),i=this.createDescription(),a=this.getPostDate();return{content:r,contentHtml:r,extractedContent:{postId:this.getPostId(),postAuthor:o},variables:{title:n,author:o,site:"Hacker News",description:i,published:a}}}createContentHtml(t,e){return`\n\t\t\t<div class="hackernews-post">\n\t\t\t\t<div class="post-content">\n\t\t\t\t\t${t}\n\t\t\t\t</div>\n\t\t\t\t${e?`\n\t\t\t\t\t<hr>\n\t\t\t\t\t<h2>Comments</h2>\n\t\t\t\t\t<div class="hackernews-comments">\n\t\t\t\t\t\t${e}\n\t\t\t\t\t</div>\n\t\t\t\t`:""}\n\t\t\t</div>\n\t\t`.trim()}getPostContent(){var t,e,r,n,o,i;if(!this.mainPost)return"";if(this.isCommentPage&&this.mainComment){const i=(null===(t=this.mainComment.querySelector(".hnuser"))||void 0===t?void 0:t.textContent)||"[deleted]",a=(null===(e=this.mainComment.querySelector(".commtext"))||void 0===e?void 0:e.innerHTML)||"",s=this.mainComment.querySelector(".age"),l=((null==s?void 0:s.getAttribute("title"))||"").split("T")[0]||"",c=(null===(n=null===(r=this.mainComment.querySelector(".score"))||void 0===r?void 0:r.textContent)||void 0===n?void 0:n.trim())||"",d=(null===(o=this.mainPost.querySelector('.navs a[href*="parent"]'))||void 0===o?void 0:o.getAttribute("href"))||"";return`\n\t\t\t\t<div class="comment main-comment">\n\t\t\t\t\t<div class="comment-metadata">\n\t\t\t\t\t\t<span class="comment-author"><strong>${i}</strong></span> \u2022\n\t\t\t\t\t\t<span class="comment-date">${l}</span>\n\t\t\t\t\t\t${c?` \u2022 <span class="comment-points">${c}</span>`:""}\n\t\t\t\t\t\t${d?` \u2022 <a href="https://news.ycombinator.com/${d}" class="parent-link">parent</a>`:""}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class="comment-content">${a}</div>\n\t\t\t\t</div>\n\t\t\t`.trim()}const a=this.mainPost.querySelector("tr.athing"),s=(null==a||a.nextElementSibling,(null===(i=null==a?void 0:a.querySelector(".titleline a"))||void 0===i?void 0:i.getAttribute("href"))||"");let l="";s&&(l+=`<p><a href="${s}" target="_blank">${s}</a></p>`);const c=this.mainPost.querySelector(".toptext");return c&&(l+=`<div class="post-text">${c.innerHTML}</div>`),l}extractComments(){const t=Array.from(this.document.querySelectorAll("tr.comtr"));return this.processComments(t)}processComments(t){var e,r,n,o;let i="";const a=new Set;let s=-1,l=[];for(const c of t){const t=c.getAttribute("id");if(!t||a.has(t))continue;a.add(t);const d=(null===(e=c.querySelector(".ind img"))||void 0===e?void 0:e.getAttribute("width"))||"0",u=parseInt(d)/40,m=c.querySelector(".commtext"),h=(null===(r=c.querySelector(".hnuser"))||void 0===r?void 0:r.textContent)||"[deleted]",p=c.querySelector(".age"),g=(null===(o=null===(n=c.querySelector(".score"))||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||"";if(!m)continue;const f=`https://news.ycombinator.com/item?id=${t}`,v=((null==p?void 0:p.getAttribute("title"))||"").split("T")[0]||"";if(0===u){for(;l.length>0;)i+="</blockquote>",l.pop();i+="<blockquote>",l=[0],s=0}else if(u<s)for(;l.length>0&&l[l.length-1]>=u;)i+="</blockquote>",l.pop();else u>s&&(i+="<blockquote>",l.push(u));i+=`<div class="comment">\n\t<div class="comment-metadata">\n\t\t<span class="comment-author"><strong>${h}</strong></span> \u2022\n\t\t<a href="${f}" class="comment-link">${v}</a>\n\t\t${g?` \u2022 <span class="comment-points">${g}</span>`:""}\n\t</div>\n\t<div class="comment-content">${m.innerHTML}</div>\n</div>`,s=u}for(;l.length>0;)i+="</blockquote>",l.pop();return i}getPostId(){const t=this.url.match(/id=(\d+)/);return(null==t?void 0:t[1])||""}getPostTitle(){var t,e,r,n,o;if(this.isCommentPage&&this.mainComment){const r=(null===(t=this.mainComment.querySelector(".hnuser"))||void 0===t?void 0:t.textContent)||"[deleted]",n=(null===(e=this.mainComment.querySelector(".commtext"))||void 0===e?void 0:e.textContent)||"";return`Comment by ${r}: ${n.trim().slice(0,50)+(n.length>50?"...":"")}`}return(null===(o=null===(n=null===(r=this.mainPost)||void 0===r?void 0:r.querySelector(".titleline"))||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||""}getPostAuthor(){var t,e,r;return(null===(r=null===(e=null===(t=this.mainPost)||void 0===t?void 0:t.querySelector(".hnuser"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||""}createDescription(){const t=this.getPostTitle(),e=this.getPostAuthor();return this.isCommentPage?`Comment by ${e} on Hacker News`:`${t} - by ${e} on Hacker News`}getPostDate(){if(!this.mainPost)return"";const t=this.mainPost.querySelector(".age");return((null==t?void 0:t.getAttribute("title"))||"").split("T")[0]||""}}e.HackerNewsExtractor=o},552:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isElement=function(t){return t.nodeType===n.NODE_TYPE.ELEMENT_NODE},e.getComputedStyle=function(t){const e=o(t.ownerDocument);return e?e.getComputedStyle(t):null},e.getWindow=o,e.logDebug=function(t,...e){"undefined"!=typeof window&&window.defuddleDebug&&console.log("Defuddle:",t,...e)};const n=r(640);function o(t){return t.defaultView?t.defaultView:t.ownerWindow?t.ownerWindow:t.window?t.window:null}},594:e=>{e.exports=t},608:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MetadataExtractor=void 0;e.MetadataExtractor=class{static extract(t,e){var r,n;let o="",i="";try{if(i=(null===(r=t.location)||void 0===r?void 0:r.href)||"",i||(i=this.getMetaContent(t,"property","og:url")||this.getMetaContent(t,"property","twitter:url")||this.getSchemaProperty(t,e,"url")||this.getSchemaProperty(t,e,"mainEntityOfPage.url")||this.getSchemaProperty(t,e,"mainEntity.url")||this.getSchemaProperty(t,e,"WebSite.url")||(null===(n=t.querySelector('link[rel="canonical"]'))||void 0===n?void 0:n.getAttribute("href"))||""),i)try{o=new URL(i).hostname.replace(/^www\./,"")}catch(t){console.warn("Failed to parse URL:",t)}}catch(e){const r=t.querySelector("base[href]");if(r)try{i=r.getAttribute("href")||"",o=new URL(i).hostname.replace(/^www\./,"")}catch(t){console.warn("Failed to parse base URL:",t)}}return{title:this.getTitle(t,e),description:this.getDescription(t,e),domain:o,favicon:this.getFavicon(t,i),image:this.getImage(t,e),published:this.getPublished(t,e),author:this.getAuthor(t,e),site:this.getSite(t,e),schemaOrgData:e,wordCount:0,parseTime:0}}static getAuthor(t,e){return this.getMetaContent(t,"name","sailthru.author")||this.getSchemaProperty(t,e,"author.name")||this.getMetaContent(t,"property","author")||this.getMetaContent(t,"name","byl")||this.getMetaContent(t,"name","author")||this.getMetaContent(t,"name","authorList")||this.getMetaContent(t,"name","copyright")||this.getSchemaProperty(t,e,"copyrightHolder.name")||this.getMetaContent(t,"property","og:site_name")||this.getSchemaProperty(t,e,"publisher.name")||this.getSchemaProperty(t,e,"sourceOrganization.name")||this.getSchemaProperty(t,e,"isPartOf.name")||this.getMetaContent(t,"name","twitter:creator")||this.getMetaContent(t,"name","application-name")||""}static getSite(t,e){return this.getSchemaProperty(t,e,"publisher.name")||this.getMetaContent(t,"property","og:site_name")||this.getSchemaProperty(t,e,"WebSite.name")||this.getSchemaProperty(t,e,"sourceOrganization.name")||this.getMetaContent(t,"name","copyright")||this.getSchemaProperty(t,e,"copyrightHolder.name")||this.getSchemaProperty(t,e,"isPartOf.name")||this.getMetaContent(t,"name","application-name")||this.getAuthor(t,e)||""}static getTitle(t,e){var r,n;const o=this.getMetaContent(t,"property","og:title")||this.getMetaContent(t,"name","twitter:title")||this.getSchemaProperty(t,e,"headline")||this.getMetaContent(t,"name","title")||this.getMetaContent(t,"name","sailthru.title")||(null===(n=null===(r=t.querySelector("title"))||void 0===r?void 0:r.textContent)||void 0===n?void 0:n.trim())||"";return this.cleanTitle(o,this.getSite(t,e))}static cleanTitle(t,e){if(!t||!e)return t;const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=[`\\s*[\\|\\-\u2013\u2014]\\s*${r}\\s*$`,`^\\s*${r}\\s*[\\|\\-\u2013\u2014]\\s*`];for(const e of n){const r=new RegExp(e,"i");if(r.test(t)){t=t.replace(r,"");break}}return t.trim()}static getDescription(t,e){return this.getMetaContent(t,"name","description")||this.getMetaContent(t,"property","description")||this.getMetaContent(t,"property","og:description")||this.getSchemaProperty(t,e,"description")||this.getMetaContent(t,"name","twitter:description")||this.getMetaContent(t,"name","sailthru.description")||""}static getImage(t,e){return this.getMetaContent(t,"property","og:image")||this.getMetaContent(t,"name","twitter:image")||this.getSchemaProperty(t,e,"image.url")||this.getMetaContent(t,"name","sailthru.image.full")||""}static getFavicon(t,e){var r,n;const o=this.getMetaContent(t,"property","og:image:favicon");if(o)return o;const i=null===(r=t.querySelector("link[rel='icon']"))||void 0===r?void 0:r.getAttribute("href");if(i)return i;const a=null===(n=t.querySelector("link[rel='shortcut icon']"))||void 0===n?void 0:n.getAttribute("href");if(a)return a;if(e)try{return new URL("/favicon.ico",e).href}catch(t){console.warn("Failed to construct favicon URL:",t)}return""}static getPublished(t,e){return this.getSchemaProperty(t,e,"datePublished")||this.getMetaContent(t,"name","publishDate")||this.getMetaContent(t,"property","article:published_time")||this.getTimeElement(t)||this.getMetaContent(t,"name","sailthru.date")||""}static getMetaContent(t,e,r){var n,o;const i=`meta[${e}]`,a=Array.from(t.querySelectorAll(i)).find((t=>{var n;return(null===(n=t.getAttribute(e))||void 0===n?void 0:n.toLowerCase())===r.toLowerCase()})),s=a&&null!==(o=null===(n=a.getAttribute("content"))||void 0===n?void 0:n.trim())&&void 0!==o?o:"";return this.decodeHTMLEntities(s,t)}static getTimeElement(t){var e,r,n,o;const i=Array.from(t.querySelectorAll("time"))[0],a=i&&null!==(o=null!==(r=null===(e=i.getAttribute("datetime"))||void 0===e?void 0:e.trim())&&void 0!==r?r:null===(n=i.textContent)||void 0===n?void 0:n.trim())&&void 0!==o?o:"";return this.decodeHTMLEntities(a,t)}static decodeHTMLEntities(t,e){const r=e.createElement("textarea");return r.innerHTML=t,r.value}static getSchemaProperty(t,e,r,n=""){if(!e)return n;const o=(t,e,r,n=!0)=>{if("string"==typeof t)return 0===e.length?[t]:[];if(!t||"object"!=typeof t)return[];if(Array.isArray(t)){const i=e[0];if(/^\[\d+\]$/.test(i)){const a=parseInt(i.slice(1,-1));return t[a]?o(t[a],e.slice(1),r,n):[]}return 0===e.length&&t.every((t=>"string"==typeof t||"number"==typeof t))?t.map(String):t.flatMap((t=>o(t,e,r,n)))}const[i,...a]=e;if(!i)return"string"==typeof t?[t]:"object"==typeof t&&t.name?[t.name]:[];if(t.hasOwnProperty(i))return o(t[i],a,r?`${r}.${i}`:i,!0);if(!n){const n=[];for(const i in t)if("object"==typeof t[i]){const a=o(t[i],e,r?`${r}.${i}`:i,!1);n.push(...a)}if(n.length>0)return n}return[]};try{let i=o(e,r.split("."),"",!0);0===i.length&&(i=o(e,r.split("."),"",!1));const a=i.length>0?i.filter(Boolean).join(", "):n;return this.decodeHTMLEntities(a,t)}catch(t){return console.error(`Error in getSchemaProperty for ${r}:`,t),n}}static extractSchemaOrgData(t){const e=t.querySelectorAll('script[type="application/ld+json"]'),r=[];return e.forEach((t=>{let e=t.textContent||"";try{e=e.replace(/\/\*[\s\S]*?\*\/|^\s*\/\/.*$/gm,"").replace(/^\s*<!\[CDATA\[([\s\S]*?)\]\]>\s*$/,"$1").replace(/^\s*(\*\/|\/\*)\s*|\s*(\*\/|\/\*)\s*$/g,"").trim();const t=JSON.parse(e);t["@graph"]&&Array.isArray(t["@graph"])?r.push(...t["@graph"]):r.push(t)}catch(t){console.error("Error parsing schema.org data:",t),console.error("Problematic JSON content:",e)}})),r}}},610:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.standardizeFootnotes=function(t){const e=t.ownerDocument;if(!e)return void console.warn("standardizeFootnotes: No document available");new o(e).standardizeFootnotes(t)};const n=r(640);class o{constructor(t){this.doc=t}createFootnoteItem(t,e,r){const n="string"==typeof e?this.doc:e.ownerDocument,o=n.createElement("li");if(o.className="footnote",o.id=`fn:${t}`,"string"==typeof e){const t=n.createElement("p");t.innerHTML=e,o.appendChild(t)}else{const t=Array.from(e.querySelectorAll("p"));if(0===t.length){const t=n.createElement("p");t.innerHTML=e.innerHTML,o.appendChild(t)}else t.forEach((t=>{const e=n.createElement("p");e.innerHTML=t.innerHTML,o.appendChild(e)}))}const i=o.querySelector("p:last-of-type")||o;return r.forEach(((t,e)=>{const o=n.createElement("a");o.href=`#${t}`,o.title="return to article",o.className="footnote-backref",o.innerHTML="\u21a9",e<r.length-1&&(o.innerHTML+=" "),i.appendChild(o)})),o}collectFootnotes(t){const e={};let r=1;const o=new Set;return t.querySelectorAll(n.FOOTNOTE_LIST_SELECTORS).forEach((t=>{if(t.matches('div.footnote[data-component-name="FootnoteToDOM"]')){const n=t.querySelector("a.footnote-number"),i=t.querySelector(".footnote-content");if(n&&i){const t=n.id.replace("footnote-","").toLowerCase();t&&!o.has(t)&&(e[r]={content:i,originalId:t,refs:[]},o.add(t),r++)}return}t.querySelectorAll('li, div[role="listitem"]').forEach((t=>{var n,i,a,s;let l="",c=null;const d=t.querySelector(".citations");if(null===(n=null==d?void 0:d.id)||void 0===n?void 0:n.toLowerCase().startsWith("r")){l=d.id.toLowerCase();const t=d.querySelector(".citation-content");t&&(c=t)}else{if(t.id.toLowerCase().startsWith("bib.bib"))l=t.id.replace("bib.bib","").toLowerCase();else if(t.id.toLowerCase().startsWith("fn:"))l=t.id.replace("fn:","").toLowerCase();else if(t.id.toLowerCase().startsWith("fn"))l=t.id.replace("fn","").toLowerCase();else if(t.hasAttribute("data-counter"))l=(null===(a=null===(i=t.getAttribute("data-counter"))||void 0===i?void 0:i.replace(/\.$/,""))||void 0===a?void 0:a.toLowerCase())||"";else{const e=null===(s=t.id.split("/").pop())||void 0===s?void 0:s.match(/cite_note-(.+)/);l=e?e[1].toLowerCase():t.id.toLowerCase()}c=t}l&&!o.has(l)&&(e[r]={content:c||t,originalId:l,refs:[]},o.add(l),r++)}))})),e}findOuterFootnoteContainer(t){let e=t,r=t.parentElement;for(;r&&("span"===r.tagName.toLowerCase()||"sup"===r.tagName.toLowerCase());)e=r,r=r.parentElement;return e}createFootnoteReference(t,e){const r=this.doc.createElement("sup");r.id=e;const n=this.doc.createElement("a");return n.href=`#fn:${t}`,n.textContent=t,r.appendChild(n),r}standardizeFootnotes(t){const e=this.collectFootnotes(t),r=t.querySelectorAll(n.FOOTNOTE_INLINE_REFERENCES),o=new Map;r.forEach((t=>{var r,n,i,a;if(!t)return;let s="",l="";if(t.matches('a[id^="ref-link"]'))s=(null===(r=t.textContent)||void 0===r?void 0:r.trim())||"";else if(t.matches('a[role="doc-biblioref"]')){const e=t.getAttribute("data-xml-rid");if(e)s=e;else{const e=t.getAttribute("href");(null==e?void 0:e.startsWith("#core-R"))&&(s=e.replace("#core-",""))}}else if(t.matches("a.footnote-anchor, span.footnote-hovercard-target a")){const e=(null===(n=t.id)||void 0===n?void 0:n.replace("footnote-anchor-",""))||"";e&&(s=e.toLowerCase())}else if(t.matches("cite.ltx_cite")){const e=t.querySelector("a");if(e){const t=e.getAttribute("href");if(t){const e=null===(i=t.split("/").pop())||void 0===i?void 0:i.match(/bib\.bib(\d+)/);e&&(s=e[1].toLowerCase())}}}else if(t.matches("sup.reference")){const e=t.querySelectorAll("a");Array.from(e).forEach((t=>{var e;const r=t.getAttribute("href");if(r){const t=null===(e=r.split("/").pop())||void 0===e?void 0:e.match(/(?:cite_note|cite_ref)-(.+)/);t&&(s=t[1].toLowerCase())}}))}else if(t.matches('sup[id^="fnref:"]'))s=t.id.replace("fnref:","").toLowerCase();else if(t.matches('sup[id^="fnr"]'))s=t.id.replace("fnr","").toLowerCase();else if(t.matches("span.footnote-reference"))s=t.getAttribute("data-footnote-id")||"";else if(t.matches("span.footnote-link"))s=t.getAttribute("data-footnote-id")||"",l=t.getAttribute("data-footnote-content")||"";else if(t.matches("a.citation"))s=(null===(a=t.textContent)||void 0===a?void 0:a.trim())||"",l=t.getAttribute("href")||"";else if(t.matches('a[id^="fnref"]'))s=t.id.replace("fnref","").toLowerCase();else{const e=t.getAttribute("href");if(e){const t=e.replace(/^[#]/,"");s=t.toLowerCase()}}if(s){const r=Object.entries(e).find((([t,e])=>e.originalId===s.toLowerCase()));if(r){const[e,n]=r,i=n.refs.length>0?`fnref:${e}-${n.refs.length+1}`:`fnref:${e}`;n.refs.push(i);const a=this.findOuterFootnoteContainer(t);if("sup"===a.tagName.toLowerCase()){o.has(a)||o.set(a,[]);o.get(a).push(this.createFootnoteReference(e,i))}else a.replaceWith(this.createFootnoteReference(e,i))}}})),o.forEach(((t,e)=>{if(t.length>0){const r=this.doc.createDocumentFragment();t.forEach((t=>{const e=t.querySelector("a");if(e){const n=this.doc.createElement("sup");n.id=t.id,n.appendChild(e.cloneNode(!0)),r.appendChild(n)}})),e.replaceWith(r)}}));const i=this.doc.createElement("div");i.id="footnotes";const a=this.doc.createElement("ol");Object.entries(e).forEach((([t,e])=>{const r=this.createFootnoteItem(parseInt(t),e.content,e.refs);a.appendChild(r)}));t.querySelectorAll(n.FOOTNOTE_LIST_SELECTORS).forEach((t=>t.remove())),a.children.length>0&&(i.appendChild(a),t.appendChild(i))}}},628:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Defuddle=void 0;const n=r(608),o=r(917),i=r(640),a=r(840),s=r(968),l=r(552);e.Defuddle=class{constructor(t,e={}){this.doc=t,this.options=e,this.debug=e.debug||!1}parse(){var t,e,r;const i=Date.now(),l=n.MetadataExtractor.extractSchemaOrgData(this.doc),c=n.MetadataExtractor.extract(this.doc,l);try{const n=this.options.url||this.doc.URL,d=o.ExtractorRegistry.findExtractor(this.doc,n,l);if(d&&d.canExtract()){const n=d.extract(),o=Date.now();return{content:n.contentHtml,title:(null===(t=n.variables)||void 0===t?void 0:t.title)||c.title,description:c.description,domain:c.domain,favicon:c.favicon,image:c.image,published:(null===(e=n.variables)||void 0===e?void 0:e.published)||c.published,author:(null===(r=n.variables)||void 0===r?void 0:r.author)||c.author,site:c.site,schemaOrgData:c.schemaOrgData,wordCount:this.countWords(n.contentHtml),parseTime:Math.round(o-i),extractorType:d.constructor.name.replace("Extractor","").toLowerCase()}}const u=this._evaluateMediaQueries(this.doc),m=this.findSmallImages(this.doc),h=this.doc.cloneNode(!0);this.applyMobileStyles(h,u);const p=this.findMainContent(h);if(!p){const t=Date.now();return Object.assign(Object.assign({content:this.doc.body.innerHTML},c),{wordCount:this.countWords(this.doc.body.innerHTML),parseTime:Math.round(t-i)})}this.removeSmallImages(h,m),this.removeHiddenElements(h),s.ContentScorer.scoreAndRemove(h,this.debug),this.removeClutter(h),(0,a.standardizeContent)(p,c,this.doc,this.debug);const g=p.outerHTML,f=Date.now();return Object.assign(Object.assign({content:g},c),{wordCount:this.countWords(g),parseTime:Math.round(f-i)})}catch(t){console.error("Defuddle","Error processing document:",t);const e=Date.now();return Object.assign(Object.assign({content:this.doc.body.innerHTML},c),{wordCount:this.countWords(this.doc.body.innerHTML),parseTime:Math.round(e-i)})}}countWords(t){const e=this.doc.createElement("div");e.innerHTML=t;return(e.textContent||"").trim().replace(/\s+/g," ").split(" ").filter((t=>t.length>0)).length}_log(...t){this.debug&&console.log("Defuddle:",...t)}_evaluateMediaQueries(t){const e=[],r=/max-width[^:]*:\s*(\d+)/;try{const n=Array.from(t.styleSheets).filter((t=>{try{return t.cssRules,!0}catch(t){return t instanceof DOMException&&t.name,!1}}));n.flatMap((t=>{try{return"undefined"==typeof CSSMediaRule?[]:Array.from(t.cssRules).filter((t=>t instanceof CSSMediaRule&&t.conditionText.includes("max-width")))}catch(t){return this.debug&&console.warn("Defuddle: Failed to process stylesheet:",t),[]}})).forEach((t=>{const n=t.conditionText.match(r);if(n){const r=parseInt(n[1]);if(i.MOBILE_WIDTH<=r){Array.from(t.cssRules).filter((t=>t instanceof CSSStyleRule)).forEach((t=>{try{e.push({selector:t.selectorText,styles:t.style.cssText})}catch(t){this.debug&&console.warn("Defuddle: Failed to process CSS rule:",t)}}))}}}))}catch(t){console.error("Defuddle: Error evaluating media queries:",t)}return e}applyMobileStyles(t,e){e.forEach((({selector:e,styles:r})=>{try{t.querySelectorAll(e).forEach((t=>{t.setAttribute("style",(t.getAttribute("style")||"")+r)}))}catch(t){console.error("Defuddle","Error applying styles for selector:",e,t)}}))}removeHiddenElements(t){let e=0;const r=new Set,n=Array.from(t.getElementsByTagName("*"));for(let o=0;o<n.length;o+=100){const i=n.slice(o,o+100),a=i.map((e=>{var r,n;try{return null===(r=e.ownerDocument.defaultView)||void 0===r?void 0:r.getComputedStyle(e)}catch(r){const o=e.getAttribute("style");if(!o)return null;const i=t.createElement("style");i.textContent=`* { ${o} }`,t.head.appendChild(i);const a=null===(n=e.ownerDocument.defaultView)||void 0===n?void 0:n.getComputedStyle(e);return t.head.removeChild(i),a}}));i.forEach(((t,n)=>{const o=a[n];!o||"none"!==o.display&&"hidden"!==o.visibility&&"0"!==o.opacity||(r.add(t),e++)}))}this._log("Removed hidden elements:",e)}removeClutter(t){const e=Date.now();let r=0,n=0;const o=new Set;t.querySelectorAll(i.EXACT_SELECTORS.join(",")).forEach((t=>{(null==t?void 0:t.parentNode)&&(o.add(t),r++)}));const a=i.PARTIAL_SELECTORS.join("|"),s=new RegExp(a,"i"),l=i.TEST_ATTRIBUTES.map((t=>`[${t}]`)).join(",");t.querySelectorAll(l).forEach((t=>{if(o.has(t))return;const e=i.TEST_ATTRIBUTES.map((e=>"class"===e?t.className&&"string"==typeof t.className?t.className:"":"id"===e?t.id||"":t.getAttribute(e)||"")).join(" ").toLowerCase();e.trim()&&s.test(e)&&(o.add(t),n++)})),o.forEach((t=>t.remove()));const c=Date.now();this._log("Removed clutter elements:",{exactSelectors:r,partialSelectors:n,total:o.size,processingTime:`${(c-e).toFixed(2)}ms`})}findSmallImages(t){const e=new Set,r=/scale\(([\d.]+)\)/,n=Date.now();let o=0;const i=[...Array.from(t.getElementsByTagName("img")),...Array.from(t.getElementsByTagName("svg"))];if(0===i.length)return e;const a=i.map((t=>({element:t,naturalWidth:"img"===t.tagName.toLowerCase()&&parseInt(t.getAttribute("width")||"0")||0,naturalHeight:"img"===t.tagName.toLowerCase()&&parseInt(t.getAttribute("height")||"0")||0,attrWidth:parseInt(t.getAttribute("width")||"0"),attrHeight:parseInt(t.getAttribute("height")||"0")})));for(let t=0;t<a.length;t+=50){const n=a.slice(t,t+50);try{const t=n.map((({element:t})=>{var e;try{return null===(e=t.ownerDocument.defaultView)||void 0===e?void 0:e.getComputedStyle(t)}catch(t){return null}})),i=n.map((({element:t})=>{try{return t.getBoundingClientRect()}catch(t){return null}}));n.forEach(((n,a)=>{var s;try{const l=t[a],c=i[a];if(!l)return;const d=l.transform,u=d?parseFloat((null===(s=d.match(r))||void 0===s?void 0:s[1])||"1"):1,m=[n.naturalWidth,n.attrWidth,parseInt(l.width)||0,c?c.width*u:0].filter((t=>"number"==typeof t&&t>0)),h=[n.naturalHeight,n.attrHeight,parseInt(l.height)||0,c?c.height*u:0].filter((t=>"number"==typeof t&&t>0));if(m.length>0&&h.length>0){const t=Math.min(...m),r=Math.min(...h);if(t<33||r<33){const t=this.getElementIdentifier(n.element);t&&(e.add(t),o++)}}}catch(t){this.debug&&console.warn("Defuddle: Failed to process element dimensions:",t)}}))}catch(t){this.debug&&console.warn("Defuddle: Failed to process batch:",t)}}const s=Date.now();return this._log("Found small elements:",{count:o,processingTime:`${(s-n).toFixed(2)}ms`}),e}removeSmallImages(t,e){let r=0;["img","svg"].forEach((n=>{const o=t.getElementsByTagName(n);Array.from(o).forEach((t=>{const n=this.getElementIdentifier(t);n&&e.has(n)&&(t.remove(),r++)}))})),this._log("Removed small elements:",r)}getElementIdentifier(t){if("img"===t.tagName.toLowerCase()){const e=t.getAttribute("data-src");if(e)return`src:${e}`;const r=t.getAttribute("src")||"",n=t.getAttribute("srcset")||"",o=t.getAttribute("data-srcset");if(r)return`src:${r}`;if(n)return`srcset:${n}`;if(o)return`srcset:${o}`}const e=t.id||"",r=t.className||"",n="svg"===t.tagName.toLowerCase()&&t.getAttribute("viewBox")||"";return e?`id:${e}`:n?`viewBox:${n}`:r?`class:${r}`:null}findMainContent(t){const e=[];if(i.ENTRY_POINT_ELEMENTS.forEach(((r,n)=>{t.querySelectorAll(r).forEach((t=>{let r=40*(i.ENTRY_POINT_ELEMENTS.length-n);r+=s.ContentScorer.scoreElement(t),e.push({element:t,score:r})}))})),0===e.length)return this.findContentByScoring(t);if(e.sort(((t,e)=>e.score-t.score)),this.debug&&this._log("Content candidates:",e.map((t=>({element:t.element.tagName,selector:this.getElementSelector(t.element),score:t.score})))),1===e.length&&"body"===e[0].element.tagName.toLowerCase()){const e=this.findTableBasedContent(t);if(e)return e}return e[0].element}findTableBasedContent(t){if(!Array.from(t.getElementsByTagName("table")).some((t=>{const e=parseInt(t.getAttribute("width")||"0"),r=this.getComputedStyle(t);return e>400||(null==r?void 0:r.width.includes("px"))&&parseInt(r.width)>400||"center"===t.getAttribute("align")||t.className.toLowerCase().includes("content")||t.className.toLowerCase().includes("article")})))return null;const e=Array.from(t.getElementsByTagName("td"));return s.ContentScorer.findBestElement(e)}findContentByScoring(t){const e=[];return i.BLOCK_ELEMENTS.forEach((r=>{Array.from(t.getElementsByTagName(r)).forEach((t=>{const r=s.ContentScorer.scoreElement(t);r>0&&e.push({score:r,element:t})}))})),e.length>0?e.sort(((t,e)=>e.score-t.score))[0].element:null}getElementSelector(t){const e=[];let r=t;for(;r&&r!==this.doc.documentElement;){let t=r.tagName.toLowerCase();r.id?t+="#"+r.id:r.className&&"string"==typeof r.className&&(t+="."+r.className.trim().split(/\s+/).join(".")),e.unshift(t),r=r.parentElement}return e.join(" > ")}getComputedStyle(t){return(0,l.getComputedStyle)(t)}}},632:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ChatGPTExtractor=void 0;const n=r(181);class o extends n.ConversationExtractor{constructor(t,e){super(t,e),this.articles=t.querySelectorAll('article[data-testid^="conversation-turn-"]'),this.footnotes=[],this.footnoteCounter=0}canExtract(){return!!this.articles&&this.articles.length>0}extractMessages(){const t=[];return this.footnotes=[],this.footnoteCounter=0,this.articles?(this.articles.forEach((e=>{var r,n;const o=e.querySelector("h5.sr-only, h6.sr-only"),i=(null===(n=null===(r=null==o?void 0:o.textContent)||void 0===r?void 0:r.trim())||void 0===n?void 0:n.replace(/:\s*$/,""))||"";let a="";const s=e.getAttribute("data-message-author-role");s&&(a=s);let l=e.innerHTML||"";l=l.replace(/\u200B/g,"");const c=document.createElement("div");c.innerHTML=l,c.querySelectorAll('h5.sr-only, h6.sr-only, span[data-state="closed"]').forEach((t=>t.remove())),l=c.innerHTML;l=l.replace(/(?:<\/p>)?<div class="relative inline-flex[^>]*>.*?<\/div>|<span[^>]*>(?:<div class="relative inline-flex[^>]*>|<div[^>]*class="[^"]*relative inline-flex[^>]*>).*?<\/div><\/span>/g,(t=>{const e=t.match(/href="([^"]+)"/);if(!e)return t;const r=e[1];let n="",o="";try{n=new URL(r).hostname.replace(/^www\./,"");const t=r.split("#:~:text=");if(t.length>1){o=decodeURIComponent(t[1]),o=o.replace(/%2C/g,",");const e=o.split(",");o=e.length>1&&e[0].trim()?` \u2014 ${e[0].trim()}...`:e[0].trim()?` \u2014 ${o.trim()}`:""}}catch(t){n=r}let i=this.footnotes.findIndex((t=>t.url===r));return-1===i?(this.footnoteCounter++,i=this.footnoteCounter,this.footnotes.push({url:r,text:`<a href="${r}">${n}</a>${o}`})):i++,`<span class="" data-state="closed"><sup id="fnref:${i}"><a href="#fn:${i}">${i}</a></sup></span>`})),l=l.replace(/<span[^>]*>\s*<\/span>/g,"").replace(/<p[^>]*>\s*<\/p>/g,""),t.push({author:i,content:l.trim(),metadata:{role:a||"unknown"}})})),t):t}getFootnotes(){return this.footnotes}getMetadata(){const t=this.getTitle(),e=this.extractMessages();return{title:t,site:"ChatGPT",url:this.url,messageCount:e.length,description:`ChatGPT conversation with ${e.length} messages`}}getTitle(){var t,e,r;const n=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(n&&"ChatGPT"!==n)return n;const o=null===(r=null===(e=this.articles)||void 0===e?void 0:e.item(0))||void 0===r?void 0:r.querySelector(".text-message");if(o){const t=o.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"ChatGPT Conversation"}}e.ChatGPTExtractor=o},640:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ALLOWED_ATTRIBUTES_DEBUG=e.ALLOWED_ATTRIBUTES=e.ALLOWED_EMPTY_ELEMENTS=e.FOOTNOTE_LIST_SELECTORS=e.FOOTNOTE_INLINE_REFERENCES=e.PARTIAL_SELECTORS=e.TEST_ATTRIBUTES=e.EXACT_SELECTORS=e.INLINE_ELEMENTS=e.PRESERVE_ELEMENTS=e.BLOCK_ELEMENTS=e.MOBILE_WIDTH=e.ENTRY_POINT_ELEMENTS=e.NODE_TYPE=void 0,e.NODE_TYPE={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12},e.ENTRY_POINT_ELEMENTS=["#post",".post-content",".article-content","#article-content",".article_post",".article-wrapper",".entry-content",".content-article",".markdown-body","article",'[role="article"]',"main",'[role="main"]',"body"],e.MOBILE_WIDTH=600,e.BLOCK_ELEMENTS=["div","section","article","main","aside","header","footer","nav","content"],e.PRESERVE_ELEMENTS=new Set(["pre","code","table","thead","tbody","tr","td","th","ul","ol","li","dl","dt","dd","figure","figcaption","picture","details","summary","blockquote","form","fieldset"]),e.INLINE_ELEMENTS=new Set(["a","span","strong","em","i","b","u","code","br","small","sub","sup","mark","date","del","ins","q","abbr","cite","relative-time","time","font"]),e.EXACT_SELECTORS=["noscript",'script:not([type^="math/"])',"style","meta","link",'.ad:not([class*="gradient"])','[class^="ad-" i]','[class$="-ad" i]','[id^="ad-" i]','[id$="-ad" i]','[role="banner" i]','[alt*="advert" i]',".promo",".Promo","#barrier-page",".alert",'[id="comments" i]','[id="comment" i]',"header",".header:not(.banner)","#header","#Header","#banner","#Banner","nav",".navigation","#navigation",'[role="navigation" i]','[role="dialog" i]','[role*="complementary" i]','[class*="pagination" i]',".menu","#menu","#siteSub",".fixed",".previous",".author",".Author",'[class$="_bio"]',"#categories",".contributor",".date","[data-date]",".entry-meta",".meta",".tags","#tags",".toc",".Toc","#toc",".headline","#headline","#title","#Title","#articleTag",'[href*="/category"]','[href*="/categories"]','[href*="/tag/"]','[href*="/tags/"]','[href*="/topics"]','[href*="author"]','[href*="#toc"]','[href="#top"]','[href="#Top"]','[href="#page-header"]','[href="#content"]','[href="#site-content"]','[href="#main-content"]','[href^="#main"]','[src*="author"]',"footer",".aside","aside","button","canvas","date","dialog","fieldset","form",'input:not([type="checkbox"])',"label","option","select","textarea","time","relative-time","[hidden]",'[aria-hidden="true"]:not([class*="math"])','[style*="display: none"]:not([class*="math"])','[style*="display:none"]:not([class*="math"])','[style*="visibility: hidden"]','[style*="visibility:hidden"]',".hidden",".invisible","instaread-player",'iframe:not([src*="youtube"]):not([src*="youtu.be"]):not([src*="vimeo"]):not([src*="twitter"]):not([src*="x.com"]):not([src*="datawrapper"])','[class="logo" i]',"#logo","#Logo","#newsletter","#Newsletter",".subscribe",".noprint",'[data-print-layout="hide" i]','[data-block="donotprint" i]','[class*="clickable-icon" i]','li span[class*="ltx_tag" i][class*="ltx_tag_item" i]','a[href^="#"][class*="anchor" i]','a[href^="#"][class*="ref" i]','[data-container*="most-viewed" i]',".sidebar",".Sidebar","#sidebar","#Sidebar","#sitesub",'[data-link-name*="skip" i]',"#skip-link",".copyright","#copyright","#rss","#feed",".gutter","#primaryaudio","#NYT_ABOVE_MAIN_CONTENT_REGION",'[data-testid="photoviewer-children-figure"] > span',"table.infobox",".pencraft:not(.pc-display-contents)",'[data-optimizely="related-articles-section" i]','[data-orientation="vertical"]'],e.TEST_ATTRIBUTES=["class","id","data-test","data-testid","data-test-id","data-qa","data-cy"],e.PARTIAL_SELECTORS=["a-statement","access-wall","activitypub","actioncall","addcomment","advert","adlayout","ad-tldr","ad-placement","ads-container","_ad_","after_content","after_main_article","afterpost","allterms","-alert-","alert-box","appendix","around-the-web","aroundpages","article-author","article-badges","article-banner","article-bottom-section","article-bottom","article-category","article-card","article-citation","article__copy","article_date","article-date","article-end ","article_header","article-header","article__header","article__hero","article__info","article-info","article-meta","article_meta","article__meta","articlename","article-subject","article_subject","article-snippet","article-separator","article--share","article--topics","articletags","article-tags","article_tags","articletitle","article-title","article_title","articletopics","article-topics","article--lede","articlewell","associated-people","audio-card","author-bio","author-box","author-info","author_info","authorm","author-mini-bio","author-name","author-publish-info","authored-by","avatar","back-to-top","backlink_container","backlinks-section","bio-block","biobox","blog-pager","bookmark-","-bookmark","bottominfo","bottomnav","bottom-of-article","bottom-wrapper","brand-bar","breadcrumb","brdcrumb","button-wrapper","buttons-container","btn-","-btn","byline","captcha","card-text","card-media","card-post","carousel-container","cat_header","catlinks","card-author","chapter-list","collections","comments","commentbox","comment-button","commentcomp","comment-content","comment-count","comment-form","comment-number","comment-respond","comment-thread","comment-wrap","complementary","consent","contact-","content-card","content-topics","contentpromo","context-bar","context-widget","core-collateral","cover-","created-date","creative-commons_","c-subscribe","_cta","-cta","cta-","cta_","current-issue","custom-list-number","dateline","dateheader","date-header","date-pub","disclaimer","disclosure","discussion","discuss_","disqus","donate","donation","dropdown","eletters","emailsignup","engagement-widget","enhancement","entry-author-info","entry-categories","entry-date","entry-title","entry-utility","-error","error-","eyebrow","expand-reduce","external-anchor","externallinkembedwrapper","extra-services","extra-title","facebook","fancy-box","favorite","featured-content","feedback","feed-links","field-site-sections","fixheader","floating-vid","follower","footer","footnote-back","footnoteback","form-group","for-you","frontmatter","further-reading","fullbleedheader","gated-","gh-feed","gist-meta","goog-","graph-view","hamburger","header_logo","header-logo","header-pattern","hero-list","-hidden","hide-for-print","hide-print","hide-when-no-script","hidden-print","hidden-sidenote","hidden-accessibility","infoline","instacartIntegration","interlude","interaction","itemendrow","jumplink","jump-to-","keepreading","keep-reading","keep_reading","keyword_wrap","kicker","labstab","-labels","language-name","lastupdated","latest-content","-ledes-","-license","license-","lightbox-popup","like-button","link-box","links-grid","links-title","listing-dynamic-terms","list-tags","listinks","loading","loa-info","logo_container","ltx_role_refnum","ltx_tag_bibitem","ltx_error","masthead","marketing","media-inquiry","-menu","menu-","metadata","might-like","minibio","more-about","_modal","-modal","more-","morenews","morestories","more_wrapper","most-read","move-helper","mw-editsection","mw-cite-backlink","mw-indicators","mw-jump-link","nav-","nav_","navigation-post","next-","newsgallery","news-story-title","newsletter_","newsletterbanner","newslettercontainer","newsletter-form","newsletter-signup","newslettersignup","newsletterwidget","newsletterwrapper","not-found","notessection","nomobile","noprint","open-slideshow","originally-published","other-blogs","outline-view","overlay","pagehead","page-header","page-title","paywall_message","-partners","permission-","plea","popular","popup_links","popover","pop_stories","pop-up","post-author","post-bottom","post__category","postcomment","postdate","post-date","post_date","post-details","post-feeds","postinfo","post-info","post_info","post-inline-date","post-links","postlist","post_list","post_meta","post-meta","postmeta","post_more","postnavi","post-navigation","postpath","post-preview","postsnippet","post_snippet","post-snippet","post-subject","posttax","post-tax","post_tax","posttag","post_tag","post-tag","post_time","posttitle","post-title","post_title","post__title","post-ufi-button","prev-post","prevnext","prev_next","prev-next","previousnext","press-inquiries","print-none","print-header","print:hidden","privacy-notice","privacy-settings","profile","promo_article","promo-bar","promo-box","pubdate","pub_date","pub-date","publish_date","publish-date","publication-date","publicationName","qr-code","qr_code","quick_up","_rail","ratingssection","read_also","readmore","read-next","read_next","read_time","read-time","reading_time","reading-time","reading-list","recent-","recent-articles","recentpost","recent_post","recent-post","recommend","redirectedfrom","recirc","register","related","relevant","reversefootnote","rss-link","screen-reader-text","scroll_to","scroll-to","_search","-search","section-nav","series-banner","share-box","sharedaddy","share-icons","sharelinks","share-post","share-print","share-section","show-for-print","sidebartitle","sidebar-content","sidebar-wrapper","sideitems","sidebar-author","sidebar-item","side-box","side-logo","sign-in-gate","similar-","similar_","similars-","site-index","site-header","siteheader","site-logo","site-name","site-wordpress","skip-content","skip-to-content","c-skip-link","_skip-link","-slider","slug-wrap","social-author","social-shar","social-date","speechify-ignore","speedbump","sponsor","springercitation","sr-only","_stats","story-date","story-navigation","storyreadtime","storysmall","storypublishdate","subject-label","subhead","submenu","-subscribe-","subscriber-drive","subscription-","_tags","tags__item","tag_list","taxonomy","table-of-contents","tabs-","terminaltout","time-rubric","timestamp","time-read","time-to-read","tip_off","tiptout","-tout-","toc-container","toggle-caption","tooltip","topbar","topic-list","topic-subnav","top-wrapper","tree-item","trending","trust-feat","trust-badge","trust-project","twitter","u-hide","upsell","viewbottom","visually-hidden","welcomebox"],e.FOOTNOTE_INLINE_REFERENCES=["sup.reference","cite.ltx_cite",'sup[id^="fnr"]','span[id^="fnr"]','span[class*="footnote_ref"]',"span.footnote-link","a.citation",'a[id^="ref-link"]','a[href^="#fn"]','a[href^="#cite"]','a[href^="#reference"]','a[href^="#footnote"]','a[href^="#r"]','a[href^="#b"]','a[href*="cite_note"]','a[href*="cite_ref"]',"a.footnote-anchor","span.footnote-hovercard-target a",'a[role="doc-biblioref"]','a[id^="fnref"]','a[id^="ref-link"]'].join(","),e.FOOTNOTE_LIST_SELECTORS=["div.footnote ol","div.footnotes ol",'div[role="doc-endnotes"]','div[role="doc-footnotes"]',"ol.footnotes-list","ol.footnotes","ol.references",'ol[class*="article-references"]',"section.footnotes ol",'section[role="doc-endnotes"]','section[role="doc-footnotes"]','section[role="doc-bibliography"]',"ul.footnotes-list","ul.ltx_biblist",'div.footnote[data-component-name="FootnoteToDOM"]'].join(","),e.ALLOWED_EMPTY_ELEMENTS=new Set(["area","audio","base","br","circle","col","defs","ellipse","embed","figure","g","hr","iframe","img","input","line","link","mask","meta","object","param","path","pattern","picture","polygon","polyline","rect","source","stop","svg","td","th","track","use","video","wbr"]),e.ALLOWED_ATTRIBUTES=new Set(["alt","allow","allowfullscreen","aria-label","checked","colspan","controls","data-latex","data-src","data-srcset","data-lang","dir","display","frameborder","headers","height","href","lang","role","rowspan","src","srcset","title","type","width","accent","accentunder","align","columnalign","columnlines","columnspacing","columnspan","data-mjx-texclass","depth","displaystyle","fence","frame","framespacing","linethickness","lspace","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","rowalign","rowlines","rowspacing","rowspan","rspace","scriptlevel","separator","stretchy","symmetric","voffset","xmlns"]),e.ALLOWED_ATTRIBUTES_DEBUG=new Set(["class","id"])},649:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.imageRules=void 0;const r=/^data:image\/([^;]+);base64,/,n=/\.(jpg|jpeg|png|webp)\s+\d/,o=/^\s*\S+\.(jpg|jpeg|png|webp)\S*\s*$/,i=/\.(jpg|jpeg|png|webp|gif|avif)(\?.*)?$/i,a=/\s(\d+)w/,s=/dpr=(\d+(?:\.\d+)?)/,l=/^([^\s]+)/,c=/^[\w\-\.\/\\]+\.(jpg|jpeg|png|gif|webp|svg)$/i,d=/^\d{4}-\d{2}-\d{2}$/;function u(t,e){e.setAttribute("srcset",t);const r=function(t){const e=t.split(",");if(0===e.length)return null;const r=e[0].trim().match(l);if(r&&r[1]){const t=r[1];if(p(t)){for(let t=1;t<e.length;t++){const r=e[t].trim().match(l);if(r&&r[1]&&!p(r[1]))return r[1]}return null}return t}return null}(t);r&&g(r)&&e.setAttribute("src",r)}function m(t,e,r){for(let n=0;n<t.attributes.length;n++){const o=t.attributes[n];r.includes(o.name)||e.setAttribute(o.name,o.value)}}function h(t){const e=t.match(r);if(!e)return!1;if("svg+xml"===e[1])return!1;const n=e[0].length;return t.length-n<133}function p(t){return t.startsWith("data:image/svg+xml")}function g(t){return!t.startsWith("data:")&&(!(!t||""===t.trim())&&(i.test(t)||t.includes("image")||t.includes("img")||t.includes("photo")))}function f(t){if(v(t))return!0;return t.querySelectorAll("img, video, picture, source").length>0}function v(t){const e=t.tagName.toLowerCase();return"img"===e||"video"===e||"picture"===e||"source"===e}function y(t){if(v(t))return t;const e=t.querySelectorAll("picture");if(e.length>0)return e[0];const r=t.querySelectorAll("img"),n=[];for(let t=0;t<r.length;t++){const e=r[t],o=e.getAttribute("src")||"",i=e.getAttribute("alt")||"";o.includes("data:image/svg+xml")||(h(o)||!i.trim()&&r.length>1||n.push(e))}if(n.length>0)return n[0];const o=t.querySelectorAll("video");if(o.length>0)return o[0];const i=t.querySelectorAll("source");if(i.length>0)return i[0];const a=t.querySelectorAll("img, picture, source, video");return a.length>0?a[0]:null}function E(t){var e,r,n,o;const i=t.querySelector("figcaption");if(i)return i;const a=new Set,s=['[class*="caption"]','[class*="description"]','[class*="alt"]','[class*="title"]','[class*="credit"]','[class*="text"]','[class*="post-thumbnail-text"]','[class*="image-caption"]','[class*="photo-caption"]',"[aria-label]","[title]"].join(", "),l=t.querySelectorAll(s);for(let t=0;t<l.length;t++){const r=l[t];if(v(r))continue;const n=null===(e=r.textContent)||void 0===e?void 0:e.trim();if(n&&n.length>0&&!a.has(n))return a.add(n),r}const c=t.querySelector("img");if(c&&c.hasAttribute("alt")){const e=c.getAttribute("alt");if(e&&e.trim().length>0){const r=t.ownerDocument.createElement("div");return r.textContent=e,r}}if(t.parentElement){const e=t.parentElement.children;for(let n=0;n<e.length;n++){const o=e[n];if(o===t)continue;if(Array.from(o.classList).some((t=>t.includes("caption")||t.includes("credit")||t.includes("text")||t.includes("description")))){const t=null===(r=o.textContent)||void 0===r?void 0:r.trim();if(t&&t.length>0)return o}}}const d=t.querySelectorAll("img");for(let t=0;t<d.length;t++){const e=d[t];if(!e.parentElement)continue;let r=e.nextElementSibling;for(;r;){if(["EM","STRONG","SPAN","I","B","SMALL","CITE"].includes(r.tagName)){const t=null===(n=r.textContent)||void 0===n?void 0:n.trim();if(t&&t.length>0)return r}r=r.nextElementSibling}}for(let t=0;t<d.length;t++){const e=d[t],r=e.parentElement;if(!r)continue;const n=r.querySelectorAll("em, strong, span, i, b, small, cite");for(let t=0;t<n.length;t++){const r=n[t];if(r===e)continue;const i=null===(o=r.textContent)||void 0===o?void 0:o.trim();if(i&&i.length>0)return r}}return null}function b(t){const e=[],r=new Set,n=t=>{var o;if(t.nodeType===Node.TEXT_NODE){const n=(null===(o=t.textContent)||void 0===o?void 0:o.trim())||"";n&&!r.has(n)&&(e.push(n),r.add(n))}else if(t.nodeType===Node.ELEMENT_NODE){const e=t.childNodes;for(let t=0;t<e.length;t++)n(e[t])}},o=t.childNodes;for(let t=0;t<o.length;t++)n(o[t]);if(e.length>0)return e.join(" ");return t.innerHTML}function C(t){var e;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";return!(r.length<10||r.startsWith("http://")||r.startsWith("https://"))&&(!c.test(r)&&(!r.match(/^\d+$/)&&!d.test(r)))}function T(t,e){const r=t.tagName.toLowerCase();return"img"===r?function(t,e){const r=t.getAttribute("src")||"";if(h(r)||p(r)){const r=t.parentElement;if(r){const n=r.querySelectorAll("source"),o=[];for(let t=0;t<n.length;t++){const e=n[t];e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&o.push(e)}if(o.length>0){const r=e.createElement("img"),n=t.getAttribute("data-src");return n&&!p(n)&&r.setAttribute("src",n),m(t,r,["src"]),r}}}return t.cloneNode(!0)}(t,e):"picture"===r?function(t,e){const r=e.createElement("img"),n=t.querySelectorAll("source");if(n.length>1){const t=w(n);if(t){const e=t.getAttribute("srcset");e&&u(e,r)}}else if(1===n.length){const t=n[0].getAttribute("srcset");t&&u(t,r)}const o=t.querySelector("img");if(o){m(o,r,["srcset"]);const t=o.getAttribute("src");t&&r.setAttribute("src",t)}return r}(t,e):"source"===r?function(t,e){const r=e.createElement("img"),n=t.getAttribute("srcset");n&&u(n,r);const o=t.parentElement;if(o){const t=o.querySelectorAll("img"),e=[];for(let r=0;r<t.length;r++){const n=t[r],o=n.getAttribute("src")||"";h(o)||p(o)||""===o||e.push(n)}if(e.length>0){if(m(e[0],r,["src","srcset"]),!r.hasAttribute("src")||!g(r.getAttribute("src")||"")){const t=e[0].getAttribute("src");t&&g(t)&&r.setAttribute("src",t)}}else{const t=o.querySelector("img[data-src]");if(t&&(m(t,r,["src","srcset"]),!r.hasAttribute("src")||!g(r.getAttribute("src")||""))){const e=t.getAttribute("data-src");e&&g(e)&&r.setAttribute("src",e)}}}return r}(t,e):t.cloneNode(!0)}function w(t){if(0===t.length)return null;if(1===t.length)return t[0];for(let e=0;e<t.length;e++)if(!t[e].hasAttribute("media"))return t[e];let e=null,r=0;for(let n=0;n<t.length;n++){const o=t[n],i=o.getAttribute("srcset");if(!i)continue;const l=i.match(a),c=i.match(s);if(l&&l[1]){const t=parseInt(l[1],10)*(c?parseFloat(c[1]):1);t>r&&(r=t,e=o)}}return e||t[0]}e.imageRules=[{selector:"picture",element:"img",transform:(t,e)=>{const r=t.querySelectorAll("source"),n=e.createElement("img");if(r.length>1){const t=w(r);if(t){const e=t.getAttribute("srcset");e&&u(e,n)}}else if(1===r.length){const t=r[0].getAttribute("srcset");t&&u(t,n)}const o=t.querySelector("img");if(o){m(o,n,["srcset"]);const t=o.getAttribute("src");t&&n.setAttribute("src",t)}if(!n.hasAttribute("src")&&o){const t=o.getAttribute("src");t&&n.setAttribute("src",t)}return n}},{selector:'img[data-src], img[data-srcset], img[loading="lazy"], img.lazy, img.lazyload',element:"img",transform:(t,e)=>{const r=t.getAttribute("src")||"",i=function(t){if(t.hasAttribute("data-src")||t.hasAttribute("data-srcset"))return!0;for(let e=0;e<t.attributes.length;e++){const r=t.attributes[e];if("src"!==r.name&&/\.(jpg|jpeg|png|webp)/i.test(r.value))return!0}return!1}(t);h(r)&&i&&t.removeAttribute("src");const a=t.getAttribute("data-src");a&&!t.getAttribute("src")&&t.setAttribute("src",a);const s=t.getAttribute("data-srcset");s&&!t.getAttribute("srcset")&&t.setAttribute("srcset",s);for(let e=0;e<t.attributes.length;e++){const r=t.attributes[e];"src"!==r.name&&"srcset"!==r.name&&"alt"!==r.name&&(n.test(r.value)?t.setAttribute("srcset",r.value):o.test(r.value)&&t.setAttribute("src",r.value))}return t.classList.remove("lazy","lazyload"),t.removeAttribute("data-ll-status"),t.removeAttribute("data-src"),t.removeAttribute("data-srcset"),t.removeAttribute("loading"),t}},{selector:"span:has(img)",element:"span",transform:(t,e)=>{try{if(!f(t))return t;const r=y(t);if(!r)return t;const n=E(t),o=T(r,e);if(n&&C(n)){const t=e.createElement("figure");t.appendChild(o);const r=e.createElement("figcaption"),i=b(n);return r.innerHTML=i,t.appendChild(r),n.parentNode&&n.parentNode.removeChild(n),t}return o}catch(e){return console.warn("Error processing span with image:",e),t}}},{selector:'figure, [class*="figure"], [class*="image"], [class*="img"], [class*="photo"], [class*="picture"], [class*="media"], [class*="caption"]',element:"figure",transform:(t,e)=>{try{if(!f(t))return t;const r=y(t);if(!r)return t;const n=E(t),o=T(r,e);if(n&&C(n)){const t=e.createElement("figure");t.appendChild(o);const r=e.createElement("figcaption"),i=b(n);return r.innerHTML=i,t.appendChild(r),n.parentNode&&n.parentNode.removeChild(n),t}return o}catch(e){return console.warn("Error processing complex image element:",e),t}}}]},732:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GeminiExtractor=void 0;const n=r(181);class o extends n.ConversationExtractor{constructor(t,e){super(t,e),this.messageCount=null,this.conversationContainers=t.querySelectorAll("div.conversation-container"),this.footnotes=[]}canExtract(){return!!this.conversationContainers&&this.conversationContainers.length>0}extractMessages(){this.messageCount=0;const t=[];return this.conversationContainers?(this.extractSources(),this.conversationContainers.forEach((e=>{const r=e.querySelector("user-query");if(r){const e=r.querySelector(".query-text");if(e){const r=e.innerHTML||"";t.push({author:"You",content:r.trim(),metadata:{role:"user"}})}}const n=e.querySelector("model-response");if(n){const e=n.querySelector(".model-response-text .markdown"),r=n.querySelector("#extended-response-markdown-content")||e;if(r){let e=r.innerHTML||"";const n=document.createElement("div");n.innerHTML=e,n.querySelectorAll(".table-content").forEach((t=>{t.classList.remove("table-content")})),e=n.innerHTML,t.push({author:"Gemini",content:e.trim(),metadata:{role:"assistant"}})}}})),this.messageCount=t.length,t):t}extractSources(){const t=this.document.querySelectorAll("browse-item");t&&t.length>0&&t.forEach((t=>{var e,r,n,o;const i=t.querySelector("a");if(i instanceof HTMLAnchorElement){const t=i.href,a=(null===(r=null===(e=i.querySelector(".domain"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",s=(null===(o=null===(n=i.querySelector(".title"))||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||"";t&&(a||s)&&this.footnotes.push({url:t,text:s?`${a}: ${s}`:a})}}))}getFootnotes(){return this.footnotes}getMetadata(){var t;const e=this.getTitle(),r=null!==(t=this.messageCount)&&void 0!==t?t:this.extractMessages().length;return{title:e,site:"Gemini",url:this.url,messageCount:r,description:`Gemini conversation with ${r} messages`}}getTitle(){var t,e,r,n,o;const i=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(i&&"Gemini"!==i&&!i.includes("Gemini"))return i;const a=null===(r=null===(e=this.document.querySelector(".title-text"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim();if(a)return a;const s=null===(o=null===(n=this.conversationContainers)||void 0===n?void 0:n.item(0))||void 0===o?void 0:o.querySelector(".query-text");if(s){const t=s.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"Gemini Conversation"}}e.GeminiExtractor=o},754:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.codeBlockRules=void 0;const n=r(640),o=[/^language-(\w+)$/,/^lang-(\w+)$/,/^(\w+)-code$/,/^code-(\w+)$/,/^syntax-(\w+)$/,/^code-snippet__(\w+)$/,/^highlight-(\w+)$/,/^(\w+)-snippet$/,/(?:^|\s)(?:language|lang|brush|syntax)-(\w+)(?:\s|$)/i],i=new Set(["abap","actionscript","ada","adoc","agda","antlr4","applescript","arduino","armasm","asciidoc","aspnet","atom","bash","batch","c","clojure","cmake","cobol","coffeescript","cpp","c++","crystal","csharp","cs","dart","django","dockerfile","dotnet","elixir","elm","erlang","fortran","fsharp","gdscript","gitignore","glsl","golang","gradle","graphql","groovy","haskell","hs","haxe","hlsl","html","idris","java","javascript","js","jsx","jsdoc","json","jsonp","julia","kotlin","latex","lisp","elisp","livescript","lua","makefile","markdown","md","markup","masm","mathml","matlab","mongodb","mysql","nasm","nginx","nim","nix","objc","ocaml","pascal","perl","php","postgresql","powershell","prolog","puppet","python","regex","rss","ruby","rb","rust","scala","scheme","shell","sh","solidity","sparql","sql","ssml","svg","swift","tcl","terraform","tex","toml","typescript","ts","tsx","unrealscript","verilog","vhdl","webassembly","wasm","xml","yaml","yml","zig"]);e.codeBlockRules=[{selector:["pre",'div[class*="prismjs"]',".syntaxhighlighter",".highlight",".highlight-source",".wp-block-syntaxhighlighter-code",".wp-block-code",'div[class*="language-"]'].join(", "),element:"pre",transform:(t,e)=>{if(!(t=>"classList"in t&&"getAttribute"in t&&"querySelector"in t)(t))return t;const r=t=>{var e;const r=t.getAttribute("data-lang")||t.getAttribute("data-language");if(r)return r.toLowerCase();const n=Array.from(t.classList||[]);if(null===(e=t.classList)||void 0===e?void 0:e.contains("syntaxhighlighter")){const t=n.find((t=>!["syntaxhighlighter","nogutter"].includes(t)));if(t&&i.has(t.toLowerCase()))return t.toLowerCase()}for(const t of n)for(const e of o){const r=t.toLowerCase().match(e);if(r&&r[1]&&i.has(r[1].toLowerCase()))return r[1].toLowerCase()}for(const t of n)if(i.has(t.toLowerCase()))return t.toLowerCase();return""};let a="",s=t;for(;s&&!a;){a=r(s);const t=s.querySelector("code");!a&&t&&(a=r(t)),s=s.parentElement}const l=t=>{if(t.nodeType===n.NODE_TYPE.TEXT_NODE)return t.textContent||"";let e="";if(t instanceof HTMLElement){if("BR"===t.tagName)return"\n";if(t.matches('div[class*="line"], span[class*="line"], .ec-line, [data-line-number], [data-line]')){const e=t.querySelector('.code, .content, [class*="code-"], [class*="content-"]');if(e)return(e.textContent||"")+"\n";const r=t.querySelector('.line-number, .gutter, [class*="line-number"], [class*="gutter"]');if(r){return Array.from(t.childNodes).filter((t=>!r.contains(t))).map((t=>l(t))).join("")+"\n"}return t.textContent+"\n"}t.childNodes.forEach((t=>{e+=l(t)}))}return e};let c="";t.matches(".syntaxhighlighter, .wp-block-syntaxhighlighter-code")&&(c=(t=>{const e=t.querySelector(".syntaxhighlighter table .code .container");if(e)return Array.from(e.children).map((t=>{const e=Array.from(t.querySelectorAll("code")).map((t=>{var e;let r=t.textContent||"";return(null===(e=t.classList)||void 0===e?void 0:e.contains("spaces"))&&(r=" ".repeat(r.length)),r})).join("");return e||t.textContent||""})).join("\n");const r=t.querySelectorAll(".code .line");return r.length>0?Array.from(r).map((t=>{const e=Array.from(t.querySelectorAll("code")).map((t=>t.textContent||"")).join("");return e||t.textContent||""})).join("\n"):""})(t)),c||(c=l(t)),c=c.replace(/^\s+|\s+$/g,"").replace(/\t/g," ").replace(/\n{3,}/g,"\n\n").replace(/\u00a0/g," ").replace(/^\n+/,"").replace(/\n+$/,"");const d=e.createElement("pre"),u=e.createElement("code");return a&&(u.setAttribute("data-lang",a),u.setAttribute("class",`language-${a}`)),u.textContent=c,d.appendChild(u),d}}]},759:t=>{t.exports=e},840:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.standardizeContent=function(t,e,r,o=!1){(function(t){const e=t=>{if(t.nodeType===n.NODE_TYPE.ELEMENT_NODE){const e=t.tagName.toLowerCase();if("pre"===e||"code"===e)return}if(t.nodeType===n.NODE_TYPE.TEXT_NODE){const e=t.textContent||"",r=e.replace(/\xA0+/g,(e=>{var r,n,o,i;if(1===e.length){const e=null===(n=null===(r=t.previousSibling)||void 0===r?void 0:r.textContent)||void 0===n?void 0:n.slice(-1),a=null===(i=null===(o=t.nextSibling)||void 0===o?void 0:o.textContent)||void 0===i?void 0:i.charAt(0);if((null==e?void 0:e.match(/\w/))&&(null==a?void 0:a.match(/\w/)))return"\xa0"}return" ".repeat(e.length)}));r!==e&&(t.textContent=r)}t.hasChildNodes()&&Array.from(t.childNodes).forEach(e)};e(t)})(t),function(t){let e=0;Array.from(t.getElementsByTagName("*")).forEach((t=>{Array.from(t.childNodes).forEach((t=>{8===t.nodeType&&(t.remove(),e++)}))})),(0,c.logDebug)("Removed HTML comments:",e)}(t),function(t,e,r){const o=t=>t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim().toLowerCase(),i=t.getElementsByTagName("h1");Array.from(i).forEach((t=>{var e;const o=r.createElement("h2");o.innerHTML=t.innerHTML,Array.from(t.attributes).forEach((t=>{n.ALLOWED_ATTRIBUTES.has(t.name)&&o.setAttribute(t.name,t.value)})),null===(e=t.parentNode)||void 0===e||e.replaceChild(o,t)}));const a=t.getElementsByTagName("h2");if(a.length>0){const t=a[0],r=o(t.textContent||""),n=o(e);n&&n===r&&t.remove()}}(t,e.title,r),(0,a.standardizeFootnotes)(t),function(t,e){let r=0;d.forEach((n=>{t.querySelectorAll(n.selector).forEach((t=>{if(n.transform){const o=n.transform(t,e);t.replaceWith(o),r++}}))}));t.querySelectorAll("lite-youtube").forEach((t=>{const n=t.getAttribute("videoid");if(!n)return;const o=e.createElement("iframe");o.width="560",o.height="315",o.src=`https://www.youtube.com/embed/${n}`,o.title=t.getAttribute("videotitle")||"YouTube video player",o.frameBorder="0",o.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",o.setAttribute("allowfullscreen",""),t.replaceWith(o),r++})),(0,c.logDebug)("Converted embedded elements:",r)}(t,r),o?(m(t,o),u(t),h(t),(0,c.logDebug)("Debug mode: Skipping div flattening to preserve structure")):(p(t,r),m(t,o),function(t){let e=0,r=0,o=!0;for(;o;){r++,o=!1;const i=Array.from(t.getElementsByTagName("*")).filter((t=>{if(n.ALLOWED_EMPTY_ELEMENTS.has(t.tagName.toLowerCase()))return!1;const e=t.textContent||"",r=0===e.trim().length,o=e.includes("\xa0"),i=!t.hasChildNodes()||Array.from(t.childNodes).every((t=>{if(t.nodeType===n.NODE_TYPE.TEXT_NODE){const e=t.textContent||"";return 0===e.trim().length&&!e.includes("\xa0")}return!1}));if("div"===t.tagName.toLowerCase()){const e=Array.from(t.children);if(e.length>0&&e.every((t=>{var e;if("span"!==t.tagName.toLowerCase())return!1;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";return","===r||""===r||" "===r})))return!0}return r&&!o&&i}));i.length>0&&(i.forEach((t=>{t.remove(),e++})),o=!0)}(0,c.logDebug)("Removed empty elements:",e,"iterations:",r)}(t),u(t),p(t,r),h(t),function(t,e){let r=0;const o=Date.now(),i=t=>{var e;if(t.nodeType===n.NODE_TYPE.ELEMENT_NODE){const e=t.tagName.toLowerCase();if("pre"===e||"code"===e)return}if(Array.from(t.childNodes).forEach(i),t.nodeType===n.NODE_TYPE.TEXT_NODE){const n=t.textContent||"";if(!n||n.match(/^[\u200C\u200B\u200D\u200E\u200F\uFEFF\xA0\s]*$/))null===(e=t.parentNode)||void 0===e||e.removeChild(t),r++;else{const e=n.replace(/\n{3,}/g,"\n\n").replace(/^[\n\r\t]+/,"").replace(/[\n\r\t]+$/,"").replace(/[ \t]*\n[ \t]*/g,"\n").replace(/[ \t]{3,}/g," ").replace(/^[ ]+$/," ").replace(/\s+([,.!?:;])/g,"$1").replace(/[\u200C\u200B\u200D\u200E\u200F\uFEFF]+/g,"").replace(/(?:\xA0){2,}/g,"\xa0");e!==n&&(t.textContent=e,r+=n.length-e.length)}}},a=t=>{var o;if(!(0,c.isElement)(t))return;const i=t.tagName.toLowerCase();if("pre"===i||"code"===i)return;Array.from(t.childNodes).filter(c.isElement).forEach(a),t.normalize();const s="block"===(null===(o=(0,c.getComputedStyle)(t))||void 0===o?void 0:o.display),l=s?/^[\n\r\t \u200C\u200B\u200D\u200E\u200F\uFEFF\xA0]*$/:/^[\n\r\t\u200C\u200B\u200D\u200E\u200F\uFEFF]*$/,d=s?/^[\n\r\t \u200C\u200B\u200D\u200E\u200F\uFEFF\xA0]*$/:/^[\n\r\t\u200C\u200B\u200D\u200E\u200F\uFEFF]*$/;for(;t.firstChild&&t.firstChild.nodeType===n.NODE_TYPE.TEXT_NODE&&(t.firstChild.textContent||"").match(l);)t.removeChild(t.firstChild),r++;for(;t.lastChild&&t.lastChild.nodeType===n.NODE_TYPE.TEXT_NODE&&(t.lastChild.textContent||"").match(d);)t.removeChild(t.lastChild),r++;if(!s){const r=Array.from(t.childNodes);for(let o=0;o<r.length-1;o++){const i=r[o],a=r[o+1];if((0,c.isElement)(i)||(0,c.isElement)(a)){const r=a.textContent||"",o=i.textContent||"",s=r.match(/^[,.!?:;)\]]/),l=o.match(/[,.!?:;(\[]\s*$/),c=i.nodeType===n.NODE_TYPE.TEXT_NODE&&(i.textContent||"").endsWith(" ")||a.nodeType===n.NODE_TYPE.TEXT_NODE&&(a.textContent||"").startsWith(" ");if(!s&&!l&&!c){const r=e.createTextNode(" ");t.insertBefore(r,a)}}}}};i(t),a(t);const s=Date.now();(0,c.logDebug)("Removed empty lines:",{charactersRemoved:r,processingTime:`${(s-o).toFixed(2)}ms`})}(t,r))};const n=r(640),o=r(974),i=r(754),a=r(610),s=r(864),l=r(649),c=r(552),d=[...o.mathRules,...i.codeBlockRules,...s.headingRules,...l.imageRules,{selector:'div[data-testid^="paragraph"], div[role="paragraph"]',element:"p",transform:(t,e)=>{const r=e.createElement("p");return r.innerHTML=t.innerHTML,Array.from(t.attributes).forEach((t=>{n.ALLOWED_ATTRIBUTES.has(t.name)&&r.setAttribute(t.name,t.value)})),r}},{selector:'div[role="list"]',element:"ul",transform:(t,e)=>{var r;const n=t.querySelector('div[role="listitem"] .label'),o=((null===(r=null==n?void 0:n.textContent)||void 0===r?void 0:r.trim())||"").match(/^\d+\)/),i=e.createElement(o?"ol":"ul");return t.querySelectorAll('div[role="listitem"]').forEach((t=>{const r=e.createElement("li"),n=t.querySelector(".content");if(n){n.querySelectorAll('div[role="paragraph"]').forEach((t=>{const r=e.createElement("p");r.innerHTML=t.innerHTML,t.replaceWith(r)}));n.querySelectorAll('div[role="list"]').forEach((t=>{var r;const n=t.querySelector('div[role="listitem"] .label'),o=((null===(r=null==n?void 0:n.textContent)||void 0===r?void 0:r.trim())||"").match(/^\d+\)/),i=e.createElement(o?"ol":"ul");t.querySelectorAll('div[role="listitem"]').forEach((t=>{const r=e.createElement("li"),n=t.querySelector(".content");if(n){n.querySelectorAll('div[role="paragraph"]').forEach((t=>{const r=e.createElement("p");r.innerHTML=t.innerHTML,t.replaceWith(r)})),r.innerHTML=n.innerHTML}i.appendChild(r)})),t.replaceWith(i)})),r.innerHTML=n.innerHTML}i.appendChild(r)})),i}},{selector:'div[role="listitem"]',element:"li",transform:(t,e)=>{const r=t.querySelector(".content");if(!r)return t;return r.querySelectorAll('div[role="paragraph"]').forEach((t=>{const r=e.createElement("p");r.innerHTML=t.innerHTML,t.replaceWith(r)})),r}}];function u(t){let e=0;const r=e=>{let o="",i=e.nextSibling;for(;i;)(i.nodeType===n.NODE_TYPE.TEXT_NODE||i.nodeType===n.NODE_TYPE.ELEMENT_NODE)&&(o+=i.textContent||""),i=i.nextSibling;if(o.trim())return!0;const a=e.parentElement;return!(!a||a===t)&&r(a)};Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")).reverse().forEach((t=>{r(t)||(t.remove(),e++)})),e>0&&(0,c.logDebug)("Removed trailing headings:",e)}function m(t,e){let r=0;const o=t=>{if("svg"===t.tagName.toLowerCase()||"http://www.w3.org/2000/svg"===t.namespaceURI)return;const o=Array.from(t.attributes),i=t.tagName.toLowerCase();o.forEach((o=>{const a=o.name.toLowerCase(),s=o.value;"id"===a&&(s.startsWith("fnref:")||s.startsWith("fn:")||"footnotes"===s)||"class"===a&&("code"===i&&s.startsWith("language-")||"footnote-backref"===s)||(e?n.ALLOWED_ATTRIBUTES.has(a)||n.ALLOWED_ATTRIBUTES_DEBUG.has(a)||a.startsWith("data-")||(t.removeAttribute(o.name),r++):n.ALLOWED_ATTRIBUTES.has(a)||(t.removeAttribute(o.name),r++))}))};o(t),t.querySelectorAll("*").forEach(o),(0,c.logDebug)("Stripped attributes:",r)}function h(t){let e=0;const r=Date.now(),o=Array.from(t.getElementsByTagName("br"));let i=[];const a=()=>{if(i.length>2)for(let t=2;t<i.length;t++)i[t].remove(),e++;i=[]};o.forEach((t=>{var e;let r=!1;if(i.length>0){const o=i[i.length-1];let a=t.previousSibling;for(;a&&a.nodeType===n.NODE_TYPE.TEXT_NODE&&!(null===(e=a.textContent)||void 0===e?void 0:e.trim());)a=a.previousSibling;a===o&&(r=!0)}r?i.push(t):(a(),i=[t])})),a();const s=Date.now();(0,c.logDebug)("Standardized br elements:",{removed:e,processingTime:`${(s-r).toFixed(2)}ms`})}function p(t,e){let r=0;const o=Date.now();let i=!0;function a(t){var e;for(const r of t.childNodes){if(r.nodeType===n.NODE_TYPE.TEXT_NODE&&(null===(e=r.textContent)||void 0===e?void 0:e.trim()))return!0;if(r.nodeType===n.NODE_TYPE.ELEMENT_NODE&&n.INLINE_ELEMENTS.has(r.nodeName.toLowerCase()))return!0}return!1}const s=t=>{const e=t.tagName.toLowerCase();if(n.PRESERVE_ELEMENTS.has(e))return!0;const r=t.getAttribute("role");if(r&&["article","main","navigation","banner","contentinfo"].includes(r))return!0;const o=t.className;if("string"==typeof o&&o.toLowerCase().match(/(?:article|main|content|footnote|reference|bibliography)/))return!0;return!!Array.from(t.children).some((t=>n.PRESERVE_ELEMENTS.has(t.tagName.toLowerCase())||"article"===t.getAttribute("role")||t.className&&"string"==typeof t.className&&t.className.toLowerCase().match(/(?:article|main|content|footnote|reference|bibliography)/)))},l=t=>{var e;if(a(t))return!1;if(!(null===(e=t.textContent)||void 0===e?void 0:e.trim()))return!0;const r=Array.from(t.children);if(0===r.length)return!0;if(r.every((t=>{const e=t.tagName.toLowerCase();return n.BLOCK_ELEMENTS.includes(e)||"p"===e||"h1"===e||"h2"===e||"h3"===e||"h4"===e||"h5"===e||"h6"===e||"ul"===e||"ol"===e||"pre"===e||"blockquote"===e||"figure"===e})))return!0;const o=t.className.toLowerCase();if(/(?:wrapper|container|layout|row|col|grid|flex|outer|inner|content-area)/i.test(o))return!0;const i=Array.from(t.childNodes).filter((t=>{var e;return t.nodeType===n.NODE_TYPE.TEXT_NODE&&(null===(e=t.textContent)||void 0===e?void 0:e.trim())}));if(0===i.length)return!0;return!(!(r.length>0)||r.some((t=>{const e=t.tagName.toLowerCase();return n.INLINE_ELEMENTS.has(e)})))},d=o=>{var i,c;if(!o.isConnected||s(o))return!1;if(!o.hasChildNodes()||!(null===(i=o.textContent)||void 0===i?void 0:i.trim()))return o.remove(),r++,!0;if(o.parentElement===t){const t=Array.from(o.children);if(t.length>0&&!t.some((t=>{const e=t.tagName.toLowerCase();return n.INLINE_ELEMENTS.has(e)}))){const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}}if(l(o)){if(!Array.from(o.children).some((t=>{const e=t.tagName.toLowerCase();return n.INLINE_ELEMENTS.has(e)}))){const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}const d=Array.from(o.childNodes);if(d.length>0&&d.every((t=>t.nodeType===n.NODE_TYPE.TEXT_NODE||t.nodeType===n.NODE_TYPE.ELEMENT_NODE&&n.INLINE_ELEMENTS.has(t.nodeName.toLowerCase())))&&(null===(c=o.textContent)||void 0===c?void 0:c.trim())){const t=e.createElement("p");for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}if(1===o.children.length){const t=o.firstElementChild,e=t.tagName.toLowerCase();if(n.BLOCK_ELEMENTS.includes(e)&&!s(t))return o.replaceWith(t),r++,!0}let u=0,m=o.parentElement;for(;m;){const t=m.tagName.toLowerCase();n.BLOCK_ELEMENTS.includes(t)&&u++,m=m.parentElement}if(u>0&&!a(o)){const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}return!1},u=()=>{const e=Array.from(t.children).filter((t=>n.BLOCK_ELEMENTS.includes(t.tagName.toLowerCase())));let r=!1;return e.forEach((t=>{d(t)&&(r=!0)})),r},m=()=>{const e=Array.from(t.querySelectorAll(n.BLOCK_ELEMENTS.join(","))).sort(((t,e)=>{const r=t=>{let e=0,r=t.parentElement;for(;r;){const t=r.tagName.toLowerCase();n.BLOCK_ELEMENTS.includes(t)&&e++,r=r.parentElement}return e};return r(e)-r(t)}));let r=!1;return e.forEach((t=>{d(t)&&(r=!0)})),r},h=()=>{const o=Array.from(t.querySelectorAll(n.BLOCK_ELEMENTS.join(",")));let i=!1;return o.forEach((t=>{const n=Array.from(t.children);if(n.length>0&&n.every((t=>"p"===t.tagName.toLowerCase()))||!s(t)&&l(t)){const n=e.createDocumentFragment();for(;t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n),r++,i=!0}})),i};do{i=!1,u()&&(i=!0),m()&&(i=!0),h()&&(i=!0)}while(i);const p=Date.now();(0,c.logDebug)("Flattened wrapper elements:",{count:r,processingTime:`${(p-o).toFixed(2)}ms`})}},864:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.headingRules=void 0;const n=r(640);e.headingRules=[{selector:"h1, h2, h3, h4, h5, h6",element:"keep",transform:t=>{var e;const r=t.ownerDocument;if(!r)return console.warn("No document available"),t;const o=r.createElement(t.tagName);Array.from(t.attributes).forEach((t=>{n.ALLOWED_ATTRIBUTES.has(t.name)&&o.setAttribute(t.name,t.value)}));const i=t.cloneNode(!0),a=new Map;Array.from(i.querySelectorAll("*")).forEach((t=>{var e,r,n,o,s,l;let c=!1;if("a"===t.tagName.toLowerCase()){const r=t.getAttribute("href");((null==r?void 0:r.includes("#"))||(null==r?void 0:r.startsWith("#")))&&(a.set(t,(null===(e=t.textContent)||void 0===e?void 0:e.trim())||""),c=!0)}if(t.classList.contains("anchor")&&(a.set(t,(null===(r=t.textContent)||void 0===r?void 0:r.trim())||""),c=!0),"button"===t.tagName.toLowerCase()&&(c=!0),("span"===t.tagName.toLowerCase()||"div"===t.tagName.toLowerCase())&&t.querySelector('a[href^="#"]')){const e=t.querySelector('a[href^="#"]');e&&a.set(t,(null===(n=e.textContent)||void 0===n?void 0:n.trim())||""),c=!0}if(c){const e=t.parentElement;e&&e!==i&&(null===(o=e.textContent)||void 0===o?void 0:o.trim())===(null===(s=t.textContent)||void 0===s?void 0:s.trim())&&a.set(e,(null===(l=t.textContent)||void 0===l?void 0:l.trim())||"")}}));Array.from(i.querySelectorAll("*")).filter((t=>{if("a"===t.tagName.toLowerCase()){const e=t.getAttribute("href");return(null==e?void 0:e.includes("#"))||(null==e?void 0:e.startsWith("#"))}return!!t.classList.contains("anchor")||("button"===t.tagName.toLowerCase()||!("span"!==t.tagName.toLowerCase()&&"div"!==t.tagName.toLowerCase()||!t.querySelector('a[href^="#"]')))})).forEach((t=>t.remove()));let s=(null===(e=i.textContent)||void 0===e?void 0:e.trim())||"";return!s&&a.size>0&&(s=Array.from(a.values())[0]),o.textContent=s,o}}]},917:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExtractorRegistry=void 0;const n=r(959),o=r(248),i=r(258),a=r(458),s=r(632),l=r(397),c=r(732);class d{static initialize(){this.register({patterns:["twitter.com",/\/x\.com\/.*/],extractor:o.TwitterExtractor}),this.register({patterns:["reddit.com","old.reddit.com","new.reddit.com",/^https:\/\/[^\/]+\.reddit\.com/],extractor:n.RedditExtractor}),this.register({patterns:["youtube.com","youtu.be",/youtube\.com\/watch\?v=.*/,/youtu\.be\/.*/],extractor:i.YoutubeExtractor}),this.register({patterns:[/news\.ycombinator\.com\/item\?id=.*/],extractor:a.HackerNewsExtractor}),this.register({patterns:[/^https?:\/\/chatgpt\.com\/(c|share)\/.*/],extractor:s.ChatGPTExtractor}),this.register({patterns:[/^https?:\/\/claude\.ai\/(chat|share)\/.*/],extractor:l.ClaudeExtractor}),this.register({patterns:[/^https?:\/\/gemini\.google\.com\/app\/.*/],extractor:c.GeminiExtractor})}static register(t){this.mappings.push(t)}static findExtractor(t,e,r){try{const n=new URL(e).hostname;if(this.domainCache.has(n)){const o=this.domainCache.get(n);return o?new o(t,e,r):null}for(const{patterns:o,extractor:i}of this.mappings){if(o.some((t=>t instanceof RegExp?t.test(e):n.includes(t))))return this.domainCache.set(n,i),new i(t,e,r)}return this.domainCache.set(n,null),null}catch(t){return console.error("Error in findExtractor:",t),null}}static clearCache(){this.domainCache.clear()}}e.ExtractorRegistry=d,d.mappings=[],d.domainCache=new Map,d.initialize()},959:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RedditExtractor=void 0;const n=r(279);class o extends n.BaseExtractor{constructor(t,e){super(t,e),this.shredditPost=t.querySelector("shreddit-post")}canExtract(){return!!this.shredditPost}extract(){var t,e;const r=this.getPostContent(),n=this.extractComments(),o=this.createContentHtml(r,n),i=(null===(e=null===(t=this.document.querySelector("h1"))||void 0===t?void 0:t.textContent)||void 0===e?void 0:e.trim())||"",a=this.getSubreddit(),s=this.getPostAuthor(),l=this.createDescription(r);return{content:o,contentHtml:o,extractedContent:{postId:this.getPostId(),subreddit:a,postAuthor:s},variables:{title:i,author:s,site:`r/${a}`,description:l}}}getPostContent(){var t,e,r,n;return((null===(e=null===(t=this.shredditPost)||void 0===t?void 0:t.querySelector('[slot="text-body"]'))||void 0===e?void 0:e.innerHTML)||"")+((null===(n=null===(r=this.shredditPost)||void 0===r?void 0:r.querySelector("#post-image"))||void 0===n?void 0:n.outerHTML)||"")}createContentHtml(t,e){return`\n\t\t\t<div class="reddit-post">\n\t\t\t\t<div class="post-content">\n\t\t\t\t\t${t}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t${e?`\n\t\t\t\t<hr>\n\t\t\t\t<h2>Comments</h2>\n\t\t\t\t<div class="reddit-comments">\n\t\t\t\t\t${e}\n\t\t\t\t</div>\n\t\t\t`:""}\n\t\t`.trim()}extractComments(){const t=Array.from(this.document.querySelectorAll("shreddit-comment"));return this.processComments(t)}getPostId(){const t=this.url.match(/comments\/([a-zA-Z0-9]+)/);return(null==t?void 0:t[1])||""}getSubreddit(){const t=this.url.match(/\/r\/([^/]+)/);return(null==t?void 0:t[1])||""}getPostAuthor(){var t;return(null===(t=this.shredditPost)||void 0===t?void 0:t.getAttribute("author"))||""}createDescription(t){var e;if(!t)return"";const r=document.createElement("div");return r.innerHTML=t,(null===(e=r.textContent)||void 0===e?void 0:e.trim().slice(0,140).replace(/\s+/g," "))||""}processComments(t){var e;let r="",n=-1,o=[];for(const i of t){const t=parseInt(i.getAttribute("depth")||"0"),a=i.getAttribute("author")||"",s=i.getAttribute("score")||"0",l=i.getAttribute("permalink")||"",c=(null===(e=i.querySelector('[slot="comment"]'))||void 0===e?void 0:e.innerHTML)||"",d=i.querySelector("faceplate-timeago"),u=(null==d?void 0:d.getAttribute("ts"))||"",m=u?new Date(u).toISOString().split("T")[0]:"";if(0===t){for(;o.length>0;)r+="</blockquote>",o.pop();r+="<blockquote>",o=[0],n=0}else if(t<n)for(;o.length>0&&o[o.length-1]>=t;)r+="</blockquote>",o.pop();else t>n&&(r+="<blockquote>",o.push(t));r+=`<div class="comment">\n\t<div class="comment-metadata">\n\t\t<span class="comment-author"><strong>${a}</strong></span> \u2022\n\t\t<a href="https://reddit.com${l}" class="comment-link">${s} points</a> \u2022\n\t\t<span class="comment-date">${m}</span>\n\t</div>\n\t<div class="comment-content">${c}</div>\n</div>`,n=t}for(;o.length>0;)r+="</blockquote>",o.pop();return r}}e.RedditExtractor=o},968:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentScorer=void 0;const n=r(640),o=["article","content","entry","image","img","photo","figure","figcaption","table","pre","main","post","story"],i=["advertisement","all rights reserved","banner","cookie","comments","copyright","follow me","follow us","footer","header","homepage","login","menu","more articles","more like this","most read","nav","navigation","newsletter","newsletter","popular","privacy","recommended","register","related","responses","share","sidebar","sign in","sign up","signup","social","sponsored","subscribe","subscribe","terms","trending"],a=["ad","banner","cookie","copyright","footer","header","homepage","menu","nav","newsletter","popular","privacy","recommended","related","rights","share","sidebar","social","sponsored","subscribe","terms","trending","widget"];class s{constructor(t,e=!1){this.doc=t,this.debug=e}static scoreElement(t){let e=0;const r=t.textContent||"",o=r.split(/\s+/).length;e+=o;e+=10*t.getElementsByTagName("p").length;e-=5*(t.getElementsByTagName("a").length/(o||1));e-=3*(t.getElementsByTagName("img").length/(o||1));try{const r=t.getAttribute("style")||"",n=t.getAttribute("align")||"";(r.includes("float: right")||r.includes("text-align: right")||"right"===n)&&(e+=5)}catch(t){}/\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\s+\d{1,2},?\s+\d{4}\b/i.test(r)&&(e+=10);/\b(?:by|written by|author:)\s+[A-Za-z\s]+\b/i.test(r)&&(e+=10);const i=t.className.toLowerCase();(i.includes("content")||i.includes("article")||i.includes("post"))&&(e+=15);t.querySelector(n.FOOTNOTE_INLINE_REFERENCES)&&(e+=10);t.querySelector(n.FOOTNOTE_LIST_SELECTORS)&&(e+=10);if(e-=5*t.getElementsByTagName("table").length,"td"===t.tagName.toLowerCase()){const r=t.closest("table");if(r){const n=parseInt(r.getAttribute("width")||"0"),o=r.getAttribute("align")||"",i=r.className.toLowerCase();if(n>400||"center"===o||i.includes("content")||i.includes("article")){const n=Array.from(r.getElementsByTagName("td")),o=n.indexOf(t);o>0&&o<n.length-1&&(e+=10)}}}return e}static findBestElement(t,e=50){let r=null,n=0;return t.forEach((t=>{const e=this.scoreElement(t);e>n&&(n=e,r=t)})),n>e?r:null}static scoreAndRemove(t,e=!1){const r=Date.now();let o=0;const i=new Set;Array.from(t.querySelectorAll(n.BLOCK_ELEMENTS.join(","))).forEach((t=>{if(i.has(t))return;if(s.isLikelyContent(t))return;s.scoreNonContentBlock(t)<0&&(i.add(t),o++)})),i.forEach((t=>t.remove()));const a=Date.now();e&&console.log("Defuddle","Removed non-content blocks:",{count:o,processingTime:`${(a-r).toFixed(2)}ms`})}static isLikelyContent(t){const e=t.getAttribute("role");if(e&&["article","main","contentinfo"].includes(e))return!0;const r=t.className.toLowerCase(),n=t.id.toLowerCase();for(const t of o)if(r.includes(t)||n.includes(t))return!0;const i=(t.textContent||"").split(/\s+/).length,a=t.getElementsByTagName("p").length;return i>50&&a>1}static scoreNonContentBlock(t){if(t.querySelector(n.FOOTNOTE_LIST_SELECTORS))return 0;let e=0;const r=t.textContent||"",o=r.split(/\s+/).length;if(o<3)return 0;for(const t of i)r.toLowerCase().includes(t)&&(e-=10);const s=t.getElementsByTagName("a").length;s/(o||1)>.5&&(e-=15);const l=t.getElementsByTagName("ul").length+t.getElementsByTagName("ol").length;l>0&&s>3*l&&(e-=10);const c=t.className.toLowerCase(),d=t.id.toLowerCase();for(const t of a)(c.includes(t)||d.includes(t))&&(e-=8);return e}}e.ContentScorer=s},974:function(t,e,r){var n,o=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=n(t),a=0;a<r.length;a++)"default"!==r[a]&&o(e,t,r[a]);return i(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.mathRules=e.createCleanMathEl=e.getLatexFromElement=void 0;const s=r(594),l=a(r(759)),c=r(282);e.getLatexFromElement=t=>{const e=(0,c.getBasicLatexFromElement)(t);if(e)return e;const r=(0,c.getMathMLFromElement)(t);if(null==r?void 0:r.mathml)try{return s.MathMLToLaTeX.convert(r.mathml)}catch(t){console.warn("Failed to convert MathML to LaTeX:",t)}return null};e.createCleanMathEl=(t,e,r,n)=>{const o=n.createElement("math");if(o.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),o.setAttribute("display",r?"block":"inline"),o.setAttribute("data-latex",e||""),null==t?void 0:t.mathml){const e=n.createElement("div");e.innerHTML=t.mathml;const r=e.querySelector("math");r&&(o.innerHTML=r.innerHTML)}else if(e)try{const t=l.renderToString(e,{displayMode:r,throwOnError:!1}),i=n.createElement("div");i.innerHTML=t;const a=i.querySelector("math");a?o.innerHTML=a.innerHTML:o.textContent=e}catch(t){console.warn("Failed to convert LaTeX to MathML:",t),o.textContent=e}return o},e.mathRules=[{selector:c.mathSelectors,element:"math",transform:t=>{if(!("style"in t)||!("className"in t))return t;const r=(0,c.getMathMLFromElement)(t),n=(0,e.getLatexFromElement)(t),o=(0,c.isBlockDisplay)(t),i=(0,e.createCleanMathEl)(r,n,o,t.ownerDocument);if(t.parentElement){t.parentElement.querySelectorAll('script[type^="math/"], .MathJax_Preview, script[type="text/javascript"][src*="mathjax"], script[type="text/javascript"][src*="katex"]').forEach((t=>t.remove()))}return i}}]}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var i=n[t]={exports:{}};return r[t].call(i.exports,i,i.exports,o),i.exports}var i={};return(()=>{var t=i;const e=o(628);t.default=e.Defuddle})(),i=i.default})()));
package/dist/markdown.js CHANGED
@@ -11,7 +11,7 @@ function isGenericElement(node) {
11
11
  return node !== null && typeof node === 'object' && 'getAttribute' in node;
12
12
  }
13
13
  function isElement(node) {
14
- return node !== null && typeof node === 'object' && 'nodeType' in node && node.nodeType === constants_1.NODE_TYPE.ELEMENT_NODE;
14
+ return node.nodeType === constants_1.NODE_TYPE.ELEMENT_NODE;
15
15
  }
16
16
  function asGenericElement(node) {
17
17
  return node;