(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{g as k,n as p}from"./chunk-CLPINNGF.js";p();k();function f(i,t){return typeof i.get(t)!="string"?i.get(t)[0]:i.get(t)}function S(i,[t,l,n,r,o],h,[e,s,a,C,d,H]){t/=e,l/=s,n/=e,r/=s,t+=d,l+=H;let u=[a,C];if(o/=Math.min(e,s),n<2*o&&(o=n/2),r<2*o&&(o=r/2),i.beginPath(),h){let[c,g,m,b]=h,$=new Path2D;$.rect(c/e,g/s,m/e,b/s),i.clip($)}return o>=0&&(i.moveTo(t+o,l),i.arcTo(t+n,l,t+n,l+r,o),i.arcTo(t+n,l+r,t,l+r,o),i.arcTo(t,l+r,t,l,o),i.arcTo(t,l,t+n,l,o),i.closePath()),i}function T(i){i=String(i);let t=i.indexOf("#")===0,l=i.indexOf("rgb")===0,n=i.indexOf("oklch")===0,r,o,h;if(t){let e=i.substr(1).match(i.length===7?/(\S{2})/g:/(\S{1})/g);e&&(r=parseInt(e[0],16),o=parseInt(e[1],16),h=parseInt(e[2],16))}if(l){let e=i.match(/(\d+)/g);e&&(r=e[0],o=e[1],h=e[2])}if(n){let e=i.match(/oklch\(([\d.]+)\s+[\d.]+\s+[\d.]+\)/);if(e){let s=parseFloat(e[1]);return Math.round(s*255)}}if(typeof r<"u")return(r*299+o*587+h*114)/1e3}function W(i,{elemColor:t,elemMatrix:l,wordPositions:n,wordClipPositions:r,sentencePositions:o,sentenceColor:h,wordColor:e}){if(!h)throw new Error("Sentence color is not provided.");if(!e)throw new Error("Word color is not provided.");let s=T(t)>=160,a=n?new Array(n.length/4).fill(0).map((c,g)=>n.slice(g*4,g*4+4)):[],C=r?new Array(r.length/4).fill(0).map((c,g)=>r.slice(g*4,g*4+4)):[],d=new Array((o?.length||0)/4).fill(0).map((c,g)=>o?.slice(g*4,g*4+4));i.fillStyle=s?h.dark:h.light;let H=[1,1,0,0,0,0],u=l.split(",").map(Number);u=u.concat(H.slice(u.length));for(let c in d){let g=d[c];i.save(),S(i,[...g,6],g,u).fill(),i.restore()}i.fillStyle=s?e.dark:e.light;for(let c in a){let g=a[c],m=C[c];i.save(),S(i,[...g,6],m,u).fill(),i.restore()}}var D=i=>class{static get inputProperties(){return[`--${i}HighlightWordInfo`,`--${i}HighlightWordClipInfo`,`--${i}HighlightSentenceInfo`,`--${i}ElemColor`,`--${i}ElemMatrix`,`--${i}SentenceHighlightColorDark`,`--${i}SentenceHighlightColorLight`,`--${i}WordHighlightColorDark`,`--${i}WordHighlightColorLight`]}paint(t,l,n){let r=f(n,`--${i}ElemColor`),o=f(n,`--${i}ElemMatrix`),h=f(n,`--${i}HighlightWordInfo`)?.split(",").map(Number),e=f(n,`--${i}HighlightWordClipInfo`)?.split(",").map(Number),s=f(n,`--${i}HighlightSentenceInfo`)?.split(",").map(Number),a=f(n,`--${i}SentenceHighlightColorDark`),C=f(n,`--${i}SentenceHighlightColorLight`),d=f(n,`--${i}WordHighlightColorDark`),H=f(n,`--${i}WordHighlightColorLight`);W(t,{elemColor:r,elemMatrix:o,wordPositions:h,wordClipPositions:e,sentencePositions:s,sentenceColor:{dark:a,light:C},wordColor:{dark:d,light:H}})}};if("registerPaint"in globalThis){let i=["speechifyReadingNow","speechifySalience","speechifyClickToPlay","speechifyPlaybackHighlighter","summarizeHighlighterDark","summarizeHighlighterLight","summarizeSentenceMedium","sidepanelHighlighting"];for(let t of i)globalThis.registerPaint(t,D(t))}export{T as brightnessByColor,W as paint};
//# sourceMappingURL=houdini-PUVAJSQJ.js.map
