(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{$c as F,Qd as k,Za as G,Zb as M,ac as N,b as h,jc as q,rd as R,uc as V}from"./chunk-XMRXO6YU.js";import{g as X,o as O}from"./chunk-ODCFEFOB.js";import{i as v}from"./chunk-24ZZP5UQ.js";import{g as w}from"./chunk-GQY3J744.js";import{M as b}from"./chunk-NWEJW7RD.js";import"./chunk-ASZMUWWE.js";import"./chunk-4XRFE7WB.js";import"./chunk-6I7EUWRH.js";import{d as S,g,i as s,n as m}from"./chunk-CLPINNGF.js";m();g();var A=S(w()),$=S(X());m();g();var d=S(w());m();g();var B=({pathFill:e,width:t,height:r,...o})=>s("svg",{width:t??"14",height:r??"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},s("path",{d:"M4.60327 11.2584H5.60185C6.14558 11.2584 6.3913 10.9708 6.3913 10.5369V3.46318C6.3913 3.02925 6.14558 2.7417 5.60185 2.7417H4.60327C4.06477 2.7417 3.80859 3.03448 3.80859 3.46318V10.5369C3.80859 10.9656 4.06477 11.2584 4.60327 11.2584ZM8.39892 11.2584H9.40272C9.94122 11.2584 10.1922 10.9656 10.1922 10.5369V3.46318C10.1922 3.03448 9.94122 2.7417 9.40272 2.7417H8.39892C7.86042 2.7417 7.60946 3.02925 7.60946 3.46318V10.5369C7.60946 10.9708 7.86042 11.2584 8.39892 11.2584Z",fill:e??"#4A4A4A"}));m();g();var D=({width:e,height:t,pathFill:r,...o})=>s("svg",{width:e??"14",height:t??"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o},s("path",{d:"M4.40527 11.0833C4.60156 11.0833 4.76841 11.0048 4.9647 10.8919L10.6865 7.58442C11.0938 7.34396 11.2361 7.18693 11.2361 6.92685C11.2361 6.66676 11.0938 6.50973 10.6865 6.27419L4.9647 2.9618C4.76841 2.84894 4.60156 2.77533 4.40527 2.77533C4.04214 2.77533 3.81641 3.05013 3.81641 3.47706V10.3766C3.81641 10.8036 4.04214 11.0833 4.40527 11.0833Z",fill:r??"#4A4A4A"}));var Z=v(h)`
  font-family: var(--font-family);
  margin-left: 8px;
  background: rgba(32, 33, 36, 0.059);
  border-radius: 4px;
  cursor: pointer;
  height: 20px;
  padding: 3px 4px;
  overflow: hidden;
`,U=v(h)`
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
`,_=(e,t,r="")=>{if(e instanceof HTMLElement&&(t.some(n=>e.classList.contains(n))||r.split(", ").some(n=>e.matches(n))||e.clientWidth===1||e.style.display==="none"||e.style.visibility==="hidden"))return[];let o=Array.from(e.childNodes);return o.length===0?e.nodeType===Node.TEXT_NODE?[{text:e.textContent??"",elem:e}]:[]:o.flatMap(n=>n.nodeType===Node.TEXT_NODE?[{text:n.textContent??"",elem:n}]:n.nodeType===Node.ELEMENT_NODE?_(n,t,r):[]).filter(n=>n.text.trim().replace(/\n|\r\n/,"").length>1).filter(n=>(n.text.match(/\w+/)?.length??0)>0)},Y=async(e,t,r="")=>({getContent:await q(async()=>({content:_(e,t,r).map(a=>a.elem),chunksAfter:0,chunksBefore:0})),converter:o=>({text:R(o),ref:{ref:o}}),options:{autoplay:!0,sideEffects:!1},metadata:{source:"Google"}}),z=({isPlaying:e,isLoading:t,...r})=>{let o=(0,d.useMemo)(()=>t?"loading":e?"playing":"paused",[e,t]);return s(h,{...r},o==="playing"&&s(B,null),o==="loading"&&s(F,{color:"#4A4A4A",width:"14",height:"14"}),o==="paused"&&s(D,null))},C=({ignoreClasses:e,ignoreTags:t,handle:r,onStateChange:o,wrapper:a})=>{let[n,i]=(0,d.useState)(null),{play:l,pause:u,isActive:c,state:p,queueAndPlayContent:Q}=N(n)??{},{duration:L}=M(n,c),E=c&&p==="playing",P=c&&p==="buffering";(0,d.useEffect)(()=>{Y(a,e,t).then(i)},[a]),(0,d.useEffect)(()=>{o(r,p,u)},[p]);let W=async y=>{if(y.preventDefault(),y.stopPropagation(),O()||b("browser-action",{animate:!1},"pill-player"),!c)return Q();if(!P){if(E)return u();if(!E)return l()}};return s(Z,{yAlign:!0,relative:!0,column:!1,onClick:y=>W(y),separation:"4px"},!L.isLoading&&s(z,{isLoading:P,isPlaying:E}),s(U,{yAlign:!0,xAlign:!0},s(k,{color:"#676767",fixedWidthNumbers:!0,duration:L})))};var f="speechify-google-play-button-container";async function I(e,t,r=250){return new Promise(o=>{setTimeout(()=>{(0,A.render)(e,t),o(!0)},r)})}async function H(e,t,r,o){let a=Array.from(document.querySelectorAll(e.selector)).filter(Boolean);for(let[n,i]of a.entries())if(i){if(i.querySelector(`.${f}`))continue;let l=i.querySelector(e.player);if(!l)continue;let u=document.createElement("div");u.className=f,u.setAttribute("style",e.css),I(s(C,{ignoreClasses:t,ignoreTags:r,handle:`google-faq-${n}`,key:`google-faq-${n}}`,onStateChange:o,wrapper:i}),u),l.prepend(u)}}async function J(e,t,r,o){let a=document.querySelector(e.selector);if(!a||a.querySelector(`.${f}`))return;let n=a.querySelector(e.player);if(!n)return;let i=document.createElement("div");i.className=f,i.setAttribute("style",e.css),i.setAttribute("data-testId",V.GOOGLE_ABOUT_PLAY_BUTTON),I(s(C,{ignoreClasses:t,ignoreTags:r,handle:"google-panel",key:"google-panel",onStateChange:o,wrapper:a}),i),n.prepend(i)}async function j(e,t,r,o){let a=Array.from(document.querySelectorAll(e.selector)).filter(Boolean);for(let[n,i]of a.entries()){let l=i.parentElement?.parentElement;if(l){if(l.querySelector(`.${f}`))continue;let u=l.querySelector(e.player);if(!u)continue;let c=document.createElement("div");c.className=f,c.setAttribute("style",e.css),(0,A.render)(s(C,{ignoreClasses:t,ignoreTags:r,handle:`google-site-${n}`,key:`google-site-${n}`,onStateChange:o,wrapper:l}),c),u.append(c)}}}var K=e=>e.some(t=>t.target instanceof HTMLElement?t.target?.className?.includes("speechify")||t.target?.id?.includes("speechify"):!1);async function ee(e){await G(e.selectors.mutationContainer);let t=()=>{},r=(0,$.default)(n=>{if(K(n))return;let{ignoreClasses:i,ignoreTags:l}=e.selectors;if(e.selectors.faq?.enabled&&H(e.selectors.faq,i,l,t),e.selectors.panels)for(let u of e.selectors.panels.variants){let c={...e.selectors.panels,...u};c.enabled&&J(c,i,l,t)}e.selectors.sites?.enabled&&j(e.selectors.sites,i,l,t)},100);r([]);let o=document.querySelector(e.selectors.mutationContainer),a=new MutationObserver(r);return o&&a.observe(o,{subtree:!0,childList:!0}),()=>{a.disconnect(),document.querySelectorAll(`.${f}`).forEach(n=>n.remove())}}export{ee as default};
//# sourceMappingURL=init-64PVRJME.js.map
