(function(){try{var g=typeof window!=="undefined"?window:typeof global!=="undefined"?global:typeof self!=="undefined"?self:{};g["__faroBundleId_Speechify Chrome Extension"]="13.4.1"}catch(l){}})();
import{Ua as x,Wa as N,Xa as p,_a as y,bd as P,fd as H,gd as f,ic as g,jc as h,rd as C,yf as k}from"./chunk-XMRXO6YU.js";import{g as O}from"./chunk-ODCFEFOB.js";import"./chunk-24ZZP5UQ.js";import"./chunk-GQY3J744.js";import{I as v}from"./chunk-NWEJW7RD.js";import"./chunk-ASZMUWWE.js";import{b as L,c as S}from"./chunk-4XRFE7WB.js";import"./chunk-6I7EUWRH.js";import{d as F,g as T,n as M}from"./chunk-CLPINNGF.js";M();T();var A=F(O());var _=e=>{let o=document.createRange();return e.length===0?document.body:(o.setStartBefore(e[0]),o.setEndAfter(e[e.length-1]),o.commonAncestorContainer??document.body)},q=async({awaitedElement:e,startingNode:o,shouldParseShadowRoot:t,useHybridParsingMode:n})=>{e&&await y(e);let a=o?document.querySelector(o)??document.body:document.body;return g({getContent:await h(async({invalidateCache:s})=>({content:await k.getParsedElements({useHybridParsingMode:n,invalidateCache:s,shouldParseShadowRoot:t,startingNodeElement:a}),chunksBefore:0,chunksAfter:0})),converter:s=>({text:C(s),ref:{ref:s}}),options:{sideEffects:!1,autoplay:!1,experimentalEdits:async function*(s){let r=f({ignoreCache:!1,startingNode:a??document.body,shouldParseShadowRoot:t}),i=a??_(r),l=()=>new Promise(d=>{let c=[],u=()=>{E.disconnect(),d([])},m=(0,A.default)(b=>{c=[];let R=f({startingNode:a??document.body,shouldParseShadowRoot:t,ignoreCache:!0});r.length!==R.length&&(r=R,E.disconnect(),s.removeEventListener("abort",u),d(b))},1e3),E=new MutationObserver(b=>{c.push(...b),m(c)});s.addEventListener("abort",u),E.observe(i,{childList:!0,subtree:!0})});for(;!s.aborted&&r.length<1e3;)yield await l()}},metadata:{source:"PillPlayer"}},!0)},w=e=>{let o=[],t=e.heading?N(e.heading):null,n=Array.from(p(e.paragraphChunks));if(e.subHeading){let r=Array.from(p(e.subHeading));r.length>0&&n.unshift(...r)}let a=0;return(t?[t,...n]:n).forEach(r=>{if(x(r)&&!H(r)){let i=P(r).textContent??"";a+=i.length,o.push(r)}}),a<100&&(o=f()),o},D=async e=>{e.awaitedElement&&await y(e.awaitedElement);let o=window.location.origin.includes("wikipedia.org");return g({getContent:await h(async()=>({content:w(e),chunksBefore:0,chunksAfter:0})),converter:t=>{let n=t instanceof HTMLElement?P(t):t;return{text:C(n),ref:{ref:t,highlightInfo:{startOffset:0,unsetColor:o}}}},options:{sideEffects:!1,autoplay:!1,experimentalEdits:async function*(t){let n=w(e),a=_(n),s=()=>new Promise(r=>{let i=[],l=()=>{c.disconnect(),r([])},d=(0,A.default)(u=>{i=[];let m=w(e);n.length!==m.length&&(n=m,c.disconnect(),t.removeEventListener("abort",l),r(u))},1e3),c=new MutationObserver(u=>{i.push(...u),d(i)});t.addEventListener("abort",l),c.observe(a,{childList:!0,subtree:!0})});for(;!t.aborted&&n.length<1e3;)yield await s()}},metadata:{source:"PillPlayer"}},!0)},I=async(e,o)=>{if(e&&L(e))return D(e.selectors);let t=o.ceParsingMode,n=e&&S(e)?e.config:{awaitedElement:null,startingNode:{selector:null,parseShadowRoot:!1},useHybridParsingMode:t==="hybrid"&&e?.mode!=="extract"};return q({awaitedElement:n?.awaitedElement,startingNode:n?.startingNode?.selector??null,shouldParseShadowRoot:n?.startingNode?.parseShadowRoot,useHybridParsingMode:n?.useHybridParsingMode??!1})};async function B(e,o,t,n){let a=await I(e,n);v("restart-page-content",async()=>g(a,!0),"standard-player")}export{B as default,I as queueContent};
//# sourceMappingURL=init-DE7UPSX3.js.map
