(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 O,Jb as R,Zb as N,_a as A,ac as F,db as G,eb as g,jc as B,yb as k}from"./chunk-XMRXO6YU.js";import{o as D}from"./chunk-ODCFEFOB.js";import{i as E,l,m as T,r as I,s as M}from"./chunk-24ZZP5UQ.js";import{g as v}from"./chunk-GQY3J744.js";import{M as L}from"./chunk-NWEJW7RD.js";import"./chunk-ASZMUWWE.js";import"./chunk-4XRFE7WB.js";import"./chunk-6I7EUWRH.js";import{d as b,g as i,i as o,k as x,m as Y,n as s}from"./chunk-CLPINNGF.js";s();i();Y();s();i();var y=b(v());s();i();var d=b(v()),z=e=>t=>!(e.ignoredSelectors?.some(n=>t.classList.contains(n))||e.ignoredSelectorForCodeSegment&&e.ignoredTagForCodeSegment&&t.classList.contains(e.ignoredSelectorForCodeSegment)&&t.tagName.toLowerCase()===e.ignoredTagForCodeSegment),_=e=>{let t="";return e instanceof Node?(e.childNodes.forEach(n=>{if(n.nodeType===Node.ELEMENT_NODE){let r=window.getComputedStyle(n);r.display!=="none"&&r.visibility!=="hidden"&&(t+=_(n))}else n.nodeType===Node.TEXT_NODE&&(t+=n.textContent)}),t.trim()):e.text},q=e=>{let[t,n]=(0,d.useState)(null),r=document.querySelector(e.contentMainSelector);return(0,d.useEffect)(()=>{(async()=>{let m=Array.from(document.querySelectorAll(e.contentSelector)).filter(a=>getComputedStyle(a.parentElement,null)?.getPropertyValue("display")!=="none").filter(z(e)),p={getContent:await B(async()=>({content:m,chunksAfter:0,chunksBefore:0})),converter:a=>({text:_(a),ref:{ref:a}}),options:{autoplay:!0,sideEffects:!1},metadata:{source:"GoogleGenAIResult"}};n(p)})()},[r]),{currentContent:t}};s();i();var V=()=>o("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{marginLeft:"1px"}},o("path",{d:"M6.6875 3.24223C7.27083 3.57902 7.27083 4.42099 6.6875 4.75777L1.8125 7.57236C1.22917 7.90914 0.5 7.48816 0.5 6.81458L0.5 1.18542C0.5 0.511842 1.22917 0.0908579 1.8125 0.427646L6.6875 3.24223Z",fill:l["icn-txt-prim"]})),$=()=>o("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o("path",{d:"M0.512817 1.125C0.512817 0.641751 0.904568 0.25 1.38782 0.25H2.13782C2.62107 0.25 3.01282 0.641751 3.01282 1.125V6.875C3.01282 7.35825 2.62107 7.75 2.13782 7.75H1.38782C0.904568 7.75 0.512817 7.35825 0.512817 6.875V1.125Z",fill:l["icn-txt-prim"]}),o("path",{d:"M4.98716 1.125C4.98716 0.641751 5.37891 0.25 5.86216 0.25H6.61216C7.09541 0.25 7.48716 0.641751 7.48716 1.125V6.875C7.48716 7.35825 7.09541 7.75 6.61216 7.75H5.86216C5.37891 7.75 4.98716 7.35825 4.98716 6.875V1.125Z",fill:l["icn-txt-prim"]}));var J=E.div`
  display: flex;
  gap: 4px;
  padding: 6px 10px 6px 6px;
  align-items: center;
  background: ${({isDarkMode:e})=>g({isDarkMode:e,color:"bg-blue"})};
  border-radius: 9999px;
  cursor: pointer;

  .close-icon {
    display: none;
    color: ${({isDarkMode:e})=>g({isDarkMode:e,color:"icn-txt-sec"})};
  }

  &:hover {
    padding-right: 6px;

    .close-icon {
      display: block;
    }
  }
`,H=E.div`
  display: flex;
  align-items: center;
  justify-content: center;
  background: ${({isDarkMode:e})=>g({isDarkMode:e,color:"sf-prim-cta"})};
  width: 20px;
  height: 20px;
  border-radius: 100%;
`,ee=({isPlaying:e,isLoading:t})=>t?o(O,{color:l["icn-txt-white"],width:"12px",height:"12px"}):e?o($,null):o(V,null),K=({config:{selectors:e,playButtons:t}})=>{let n=G(),r=t?.google?.listenToAnswer===!1,[h,C]=(0,y.useState)(!r),{currentContent:m}=q(e),{state:p,play:a,pause:W,queueAndPlayContent:Z,isActive:u}=F(m),{duration:U}=N(m,u),f=u&&p==="playing",w=u&&p==="buffering",j=async c=>{if(c.preventDefault(),c.stopPropagation(),D()||L("browser-action",{animate:!1},"pill-player"),!u)return Z();if(!w){if(f)return W();if(!f)return a()}},X=c=>{c.stopPropagation(),k.playButtons.set("google-gen-ai-result","google","listenToAnswer",!1),C(!1)};return(0,y.useEffect)(()=>{C(!r)},[r]),h?o(J,{onClick:c=>j(c),isDarkMode:n},!U.isLoading&&o(H,{isDarkMode:n},o(ee,{isLoading:w,isPlaying:f})),o(M,{font:"subheading-6",style:{color:n?l["icn-txt-prim"]:T["icn-txt-prim"]},className:"label"},f?"Pause":"Listen"),o(I,{className:"close-icon",backgroundColor:"transparent",onClick:X})):null};var Q="speechify-google-gen-ai-player-root";async function oe(e){let t=e.selectors;await A(t.mainSelector),te(),await R(800);let n=document.querySelector(`${t.mainSelector}`);if(n){let r=document.createElement("span");r.id=Q,r.style.display="flex",r.style.marginTop="10px",r.style.marginBottom="10px",n.appendChild(r),x(o(K,{config:e}),r)}}var te=()=>{let e=document.querySelector(`#${Q}`);e&&(e.remove(),x(null,e))};export{oe as default};
//# sourceMappingURL=init-UH2JZKFS.js.map
