'use strict';function n(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}function q(a){var b=typeof Symbol!="undefined"&&Symbol.iterator&&a[Symbol.iterator];if(b)return b.call(a);if(typeof a.length=="number")return{next:n(a)};throw Error(String(a)+" is not an iterable or ArrayLike");}var u=typeof Object.defineProperties=="function"?Object.defineProperty:function(a,b,f){if(a==Array.prototype||a==Object.prototype)return a;a[b]=f.value;return a};
function w(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var f=a[b];if(f&&f.Math==Math)return f}throw Error("Cannot find global object");}var x=w(this);function z(a,b){if(b)a:{var f=x;a=a.split(".");for(var g=0;g<a.length-1;g++){var k=a[g];if(!(k in f))break a;f=f[k]}a=a[a.length-1];g=f[a];b=b(g);b!=g&&b!=null&&u(f,a,{configurable:!0,writable:!0,value:b})}}
function A(){this.m=!1;this.i=null;this.h=void 0;this.g=1;this.u=this.l=0;this.j=null}function B(a){if(a.m)throw new TypeError("Generator is already running");a.m=!0}A.prototype.o=function(a){this.h=a};function C(a,b){a.j={F:b,isException:!0};a.g=a.l||a.u}A.prototype.return=function(a){this.j={return:a};this.g=this.u};function D(a,b,f){a.g=f;return{value:b}}function E(a){a.l=0;var b=a.j.F;a.j=null;return b}function F(a){this.g=new A;this.h=a}
function G(a,b){B(a.g);var f=a.g.i;if(f)return H(a,"return"in f?f["return"]:function(g){return{value:g,done:!0}},b,a.g.return);a.g.return(b);return I(a)}function H(a,b,f,g){try{var k=b.call(a.g.i,f);if(!(k instanceof Object))throw new TypeError("Iterator result "+k+" is not an object");if(!k.done)return a.g.m=!1,k;var m=k.value}catch(e){return a.g.i=null,C(a.g,e),I(a)}a.g.i=null;g.call(a.g,m);return I(a)}
function I(a){for(;a.g.g;)try{var b=a.h(a.g);if(b)return a.g.m=!1,{value:b.value,done:!1}}catch(f){a.g.h=void 0,C(a.g,f)}a.g.m=!1;if(a.g.j){b=a.g.j;a.g.j=null;if(b.isException)throw b.F;return{value:b.return,done:!0}}return{value:void 0,done:!0}}
function J(a){this.next=function(b){B(a.g);a.g.i?b=H(a,a.g.i.next,b,a.g.o):(a.g.o(b),b=I(a));return b};this.throw=function(b){B(a.g);a.g.i?b=H(a,a.g.i["throw"],b,a.g.o):(C(a.g,b),b=I(a));return b};this.return=function(b){return G(a,b)};this[Symbol.iterator]=function(){return this}}function K(a){function b(g){return a.next(g)}function f(g){return a.throw(g)}return new Promise(function(g,k){function m(e){e.done?g(e.value):Promise.resolve(e.value).then(b,f).then(m,k)}m(a.next())})}
function L(a){return K(new J(new F(a)))}z("Symbol",function(a){function b(m){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new f(g+(m||"")+"_"+k++,m)}function f(m,e){this.g=m;u(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;f.prototype.toString=function(){return this.g};var g="jscomp_symbol_"+(Math.random()*1E9>>>0)+"_",k=0;return b});
z("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");u(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return M(n(this))}});return a});function M(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
z("Promise",function(a){function b(e){this.h=0;this.i=void 0;this.g=[];this.o=!1;var c=this.j();try{e(c.resolve,c.reject)}catch(d){c.reject(d)}}function f(){this.g=null}function g(e){return e instanceof b?e:new b(function(c){c(e)})}if(a)return a;f.prototype.h=function(e){if(this.g==null){this.g=[];var c=this;this.i(function(){c.l()})}this.g.push(e)};var k=x.setTimeout;f.prototype.i=function(e){k(e,0)};f.prototype.l=function(){for(;this.g&&this.g.length;){var e=this.g;this.g=[];for(var c=0;c<e.length;++c){var d=
e[c];e[c]=null;try{d()}catch(h){this.j(h)}}}this.g=null};f.prototype.j=function(e){this.i(function(){throw e;})};b.prototype.j=function(){function e(h){return function(l){d||(d=!0,h.call(c,l))}}var c=this,d=!1;return{resolve:e(this.H),reject:e(this.l)}};b.prototype.H=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.J(e);else{a:switch(typeof e){case "object":var c=e!=null;break a;case "function":c=!0;break a;default:c=!1}c?this.B(e):this.m(e)}};
b.prototype.B=function(e){var c=void 0;try{c=e.then}catch(d){this.l(d);return}typeof c=="function"?this.K(c,e):this.m(e)};b.prototype.l=function(e){this.u(2,e)};b.prototype.m=function(e){this.u(1,e)};b.prototype.u=function(e,c){if(this.h!=0)throw Error("Cannot settle("+e+", "+c+"): Promise already settled in state"+this.h);this.h=e;this.i=c;this.h===2&&this.I();this.D()};b.prototype.I=function(){var e=this;k(function(){if(e.A()){var c=x.console;typeof c!=="undefined"&&c.error(e.i)}},1)};b.prototype.A=
function(){if(this.o)return!1;var e=x.CustomEvent,c=x.Event,d=x.dispatchEvent;if(typeof d==="undefined")return!0;typeof e==="function"?e=new e("unhandledrejection",{cancelable:!0}):typeof c==="function"?e=new c("unhandledrejection",{cancelable:!0}):(e=x.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e));e.promise=this;e.reason=this.i;return d(e)};b.prototype.D=function(){if(this.g!=null){for(var e=0;e<this.g.length;++e)m.h(this.g[e]);this.g=null}};var m=new f;b.prototype.J=
function(e){var c=this.j();e.v(c.resolve,c.reject)};b.prototype.K=function(e,c){var d=this.j();try{e.call(c,d.resolve,d.reject)}catch(h){d.reject(h)}};b.prototype.then=function(e,c){function d(p,t){return typeof p=="function"?function(y){try{h(p(y))}catch(v){l(v)}}:t}var h,l,r=new b(function(p,t){h=p;l=t});this.v(d(e,h),d(c,l));return r};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.v=function(e,c){function d(){switch(h.h){case 1:e(h.i);break;case 2:c(h.i);break;default:throw Error("Unexpected state: "+
h.h);}}var h=this;this.g==null?m.h(d):this.g.push(d);this.o=!0};b.resolve=g;b.reject=function(e){return new b(function(c,d){d(e)})};b.race=function(e){return new b(function(c,d){for(var h=q(e),l=h.next();!l.done;l=h.next())g(l.value).v(c,d)})};b.all=function(e){var c=q(e),d=c.next();return d.done?g([]):new b(function(h,l){function r(y){return function(v){p[y]=v;t--;t==0&&h(p)}}var p=[],t=0;do p.push(void 0),t++,g(d.value).v(r(p.length-1),l),d=c.next();while(!d.done)})};return b});
function N(a,b){return Object.prototype.hasOwnProperty.call(a,b)}
z("WeakMap",function(a){function b(d){this.g=(c+=Math.random()+1).toString();if(d){d=q(d);for(var h;!(h=d.next()).done;)h=h.value,this.set(h[0],h[1])}}function f(){}function g(d){var h=typeof d;return h==="object"&&d!==null||h==="function"}function k(d){if(!N(d,e)){var h=new f;u(d,e,{value:h})}}function m(d){var h=Object[d];h&&(Object[d]=function(l){if(l instanceof f)return l;Object.isExtensible(l)&&k(l);return h(l)})}if(function(){if(!a||!Object.seal)return!1;try{var d=Object.seal({}),h=Object.seal({}),
l=new a([[d,2],[h,3]]);if(l.get(d)!=2||l.get(h)!=3)return!1;l.delete(d);l.set(h,4);return!l.has(d)&&l.get(h)==4}catch(r){return!1}}())return a;var e="$jscomp_hidden_"+Math.random();m("freeze");m("preventExtensions");m("seal");var c=0;b.prototype.set=function(d,h){if(!g(d))throw Error("Invalid WeakMap key");k(d);if(!N(d,e))throw Error("WeakMap key fail: "+d);d[e][this.g]=h;return this};b.prototype.get=function(d){return g(d)&&N(d,e)?d[e][this.g]:void 0};b.prototype.has=function(d){return g(d)&&N(d,
e)&&N(d[e],this.g)};b.prototype.delete=function(d){return g(d)&&N(d,e)&&N(d[e],this.g)?delete d[e][this.g]:!1};return b});
z("Map",function(a){function b(){var c={};return c.previous=c.next=c.head=c}function f(c,d){var h=c[1];return M(function(){if(h){for(;h.head!=c[1];)h=h.previous;for(;h.next!=h.head;)return h=h.next,{done:!1,value:d(h)};h=null}return{done:!0,value:void 0}})}function g(c,d){var h=d&&typeof d;h=="object"||h=="function"?m.has(d)?h=m.get(d):(h=""+ ++e,m.set(d,h)):h="p_"+d;var l=c[0][h];if(l&&N(c[0],h))for(c=0;c<l.length;c++){var r=l[c];if(d!==d&&r.key!==r.key||d===r.key)return{id:h,list:l,index:c,entry:r}}return{id:h,
list:l,index:-1,entry:void 0}}function k(c){this[0]={};this[1]=b();this.size=0;if(c){c=q(c);for(var d;!(d=c.next()).done;)d=d.value,this.set(d[0],d[1])}}if(function(){if(!a||typeof a!="function"||!a.prototype.entries||typeof Object.seal!="function")return!1;try{var c=Object.seal({x:4}),d=new a(q([[c,"s"]]));if(d.get(c)!="s"||d.size!=1||d.get({x:4})||d.set({x:4},"t")!=d||d.size!=2)return!1;var h=d.entries(),l=h.next();if(l.done||l.value[0]!=c||l.value[1]!="s")return!1;l=h.next();return l.done||l.value[0].x!=
4||l.value[1]!="t"||!h.next().done?!1:!0}catch(r){return!1}}())return a;var m=new WeakMap;k.prototype.set=function(c,d){c=c===0?0:c;var h=g(this,c);h.list||(h.list=this[0][h.id]=[]);h.entry?h.entry.value=d:(h.entry={next:this[1],previous:this[1].previous,head:this[1],key:c,value:d},h.list.push(h.entry),this[1].previous.next=h.entry,this[1].previous=h.entry,this.size++);return this};k.prototype.delete=function(c){c=g(this,c);return c.entry&&c.list?(c.list.splice(c.index,1),c.list.length||delete this[0][c.id],
c.entry.previous.next=c.entry.next,c.entry.next.previous=c.entry.previous,c.entry.head=null,this.size--,!0):!1};k.prototype.clear=function(){this[0]={};this[1]=this[1].previous=b();this.size=0};k.prototype.has=function(c){return!!g(this,c).entry};k.prototype.get=function(c){return(c=g(this,c).entry)&&c.value};k.prototype.entries=function(){return f(this,function(c){return[c.key,c.value]})};k.prototype.keys=function(){return f(this,function(c){return c.key})};k.prototype.values=function(){return f(this,
function(c){return c.value})};k.prototype.forEach=function(c,d){for(var h=this.entries(),l;!(l=h.next()).done;)l=l.value,c.call(d,l[1],l[0],this)};k.prototype[Symbol.iterator]=k.prototype.entries;var e=0;return k});z("Object.entries",function(a){return a?a:function(b){var f=[],g;for(g in b)N(b,g)&&f.push([g,b[g]]);return f}});function O(a){this.g=a}var P;function Q(){var a=P;a.g.runtime.getPlatformInfo();setInterval(function(){a.g.runtime.getPlatformInfo()},2E4)};function R(a,b,f){if(typeof a==="object"&&typeof b==="string"){var g=a;a=b}else if(typeof a==="string"&&typeof b==="function")f=b;else return{lang:"",C:!1};return{lang:a,L:f,G:g,C:!0}}function S(a){L(function(b){return b.return(T(a))})}function aa(a){L(function(b){if(b.g==1)return D(b,U(V),2);if(!b.h)return b.return();V.j&&V.j(a);b.g=0})}function ba(a){return L(function(b){return b.g==1?D(b,a.g.offscreen.hasDocument(),2):b.return(b.h)})}
function W(a){var b,f;return L(function(g){switch(g.g){case 1:return D(g,ba(a),2);case 2:if(g.h)return g.return();g.l=3;return D(g,a.g.offscreen.createDocument({url:"offscreen.html",reasons:[a.g.offscreen.Reason.AUDIO_PLAYBACK,a.g.offscreen.Reason.USER_MEDIA],justification:"Required for Text-to-Speech audio synthesis and playback"}),5);case 5:return b={type:"init"},D(g,a.g.runtime.sendMessage(b),6);case 6:g.g=4;g.l=0;break;case 3:f=E(g),console.error("Failed to create offscreen document:",f);case 4:return D(g,
ca(a.h),0)}})}function U(a){var b;return L(function(f){if(f.g==1)return f.l=2,D(f,W(a),4);if(f.g!=2)return f.return(!0);b=E(f);console.error("Error ensuring offscreen document is ready:",b);return f.return(!1)})};function da(){this.g=chrome;this.h=new Map}function ea(a,b){var f,g,k;return L(function(m){if(m.g==1)return f={type:"getLanguageStatus",lang:b},D(m,a.g.runtime.sendMessage(f),2);g=m.h;k={lang:g.lang,installStatus:g.status};a.g.ttsEngine.updateLanguage(k);m.g=0})}
function fa(a){var b=V.h,f,g,k,m,e,c,d,h,l,r,p,t;L(function(y){f=[];g=q(Object.entries(a));for(k=g.next();!k.done;k=g.next())for(m=k.value,e=q(m),c=e.next().value,d=e.next().value,h=c,l=d,r=q(l),p=r.next();!p.done;p=r.next())t=p.value,f.push({lang:h,voiceName:t,eventTypes:["start","end","error","word"]});b.g.ttsEngine.updateVoices(f);y.g=0})}
function T(a){var b=V.h,f,g;return L(function(k){if(k.g==1)return b.h.get(a)==="uninstallLanguage"&&b.h.delete(a),D(k,X(b),2);f=k.h;f[a]=Date.now();g={};return D(k,b.g.storage.local.set((g.lastUsedTimestamps=f,g)),0)})}
function ca(a){var b,f,g,k,m,e,c,d,h;return L(function(l){switch(l.g){case 1:return D(l,Y(a),2);case 2:return(b=l.h)?D(l,X(a),3):l.return();case 3:f=l.h;g=ha(b,f);if(g.length===0)return l.return();k=q(g);m=k.next();case 4:if(m.done)return d={},D(l,a.g.storage.local.set((d.installedTimestamps=b,d)),8);e=m.value;c={type:"removeUnusedLanguage",lang:e};return D(l,a.g.runtime.sendMessage(c),7);case 7:e in b&&delete b[e];e in f&&delete f[e];m=k.next();l.g=4;break;case 8:return h={},D(l,a.g.storage.local.set((h.lastUsedTimestamps=
f,h)),0)}})}function ha(a,b){var f=Date.now();return Object.entries(a).filter(function(g){var k=q(g);g=k.next().value;k=k.next().value;var m=g in b;return f-Number(m?b[g]:k)>(m?7776E6:12096E5)}).map(function(g){return q(g).next().value})}function Z(a){a.i&&clearTimeout(a.i);a.i=setTimeout(function(){ia(a)},200)}
function ia(a){var b,f,g,k,m,e,c,d,h,l,r,p,t,y;L(function(v){switch(v.g){case 1:if(a.h.size===0)return v.return();b=new Map(a.h);a.h.clear();f=[];g=[];k=q(b);m=k.next();case 2:if(m.done)return D(v,ja(a,g),6);e=m.value;c=q(e);d=c.next().value;h=c.next().value;l=d;r=h;p={type:r,lang:l};return D(v,a.g.runtime.sendMessage(p),5);case 5:t=v.h;y={lang:t.lang,installStatus:t.status};a.g.ttsEngine.updateLanguage(y);switch(t.status){case a.g.ttsEngine.LanguageInstallStatus.INSTALLED:f.push(l);break;case a.g.ttsEngine.LanguageInstallStatus.NOT_INSTALLED:g.push(l)}m=
k.next();v.g=2;break;case 6:return v.return(ka(a,f))}})}function ja(a,b){var f,g,k,m,e;return L(function(c){if(c.g==1)return D(c,Y(a),2);f=c.h;g=q(b);for(k=g.next();!k.done;k=g.next())m=k.value,delete f[m];e={};return D(c,a.g.storage.local.set((e.installedTimestamps=f,e)),0)})}function ka(a,b){var f,g,k;return L(function(m){if(m.g==1)return f=Date.now(),D(m,Y(a),2);g=m.h;b.forEach(function(e){g[e]=f});k={};return D(m,a.g.storage.local.set((k.installedTimestamps=g,k)),0)})}
function Y(a){var b;return L(function(f){if(f.g==1)return D(f,a.g.storage.local.get("installedTimestamps"),2);b=f.h;return f.return(b.installedTimestamps||{})})}function X(a){var b;return L(function(f){if(f.g==1)return D(f,a.g.storage.local.get("lastUsedTimestamps"),2);b=f.h;return f.return(b.lastUsedTimestamps||{})})};var V=new function(){var a=new da,b=this;this.g=chrome;this.h=a;this.D=function(f,g,k){var m,e,c;return L(function(d){switch(d.g){case 1:return D(d,U(b),2);case 2:if(!d.h)return k({type:"error",errorMessage:"Offscreen document not ready."}),d.return();b.j=k;m={type:"speak",utterance:f,options:g};d.l=3;return D(d,b.g.runtime.sendMessage(m),5);case 5:d.g=0;d.l=0;break;case 3:e=E(d),c=e instanceof Error?e.message:"Error while trying to speak.",k({type:"error",errorMessage:c}),d.g=0}})};this.A=function(){var f;
return L(function(g){if(g.g==1)return D(g,U(b),2);if(!g.h)return g.return();b.j=void 0;f={type:"stop"};return D(g,b.g.runtime.sendMessage(f),0)})};this.o=function(){var f;return L(function(g){if(g.g==1)return D(g,U(b),2);if(!g.h)return g.return();f={type:"pause"};return D(g,b.g.runtime.sendMessage(f),0)})};this.u=function(){var f;return L(function(g){if(g.g==1)return D(g,U(b),2);if(!g.h)return g.return();f={type:"resume"};return D(g,b.g.runtime.sendMessage(f),0)})};this.l=function(f,g,k){var m,e,
c,d,h,l,r;return L(function(p){if(p.g==1)return D(p,U(b),2);if(!p.h)return p.return();m=R(f,g,k);e=m.lang;c=m.G;d=m.C;r=(l=(h=c)==null?void 0:h.source)!=null?l:"unknown";if(!d||r!==b.i)return p.return();var t=b.h;t.h.set(e,"installLanguage");Z(t);t.g.ttsEngine.updateLanguage({lang:e,installStatus:t.g.ttsEngine.LanguageInstallStatus.INSTALLING});p.g=0})};this.m=function(f,g,k){var m,e,c,d,h,l,r;return L(function(p){if(p.g==1)return D(p,U(b),2);if(!p.h)return p.return();m=R(f,g,k);e=m.lang;c=m.G;d=
m.C;r=(l=(h=c)==null?void 0:h.source)!=null?l:"unknown";return d&&r===b.i?p.return(ea(b.h,e)):p.return()})};this.B=function(f,g){return L(function(k){if(k.g==1)return D(k,U(b),2);if(!k.h||f.source!==b.i)return k.return();var m=b.h;m.h.set(g,"uninstallLanguage");Z(m);k.g=0})};this.i=this.g.ttsEngine.TtsClientSource.CHROMEFEATURE;this.g.runtime.onInstalled.addListener(function(){return L(function(f){return D(f,W(b),0)})});this.g.runtime.onStartup.addListener(function(){return L(function(f){return D(f,
U(b),0)})});this.g.ttsEngine.onSpeak.addListener(this.D);this.g.ttsEngine.onStop.addListener(this.A);this.g.ttsEngine.onPause.addListener(this.o);this.g.ttsEngine.onResume.addListener(this.u);this.g.ttsEngine.onInstallLanguageRequest.addListener(this.l);this.g.ttsEngine.onLanguageStatusRequest.addListener(this.m);this.g.ttsEngine.onUninstallLanguageRequest.addListener(this.B);P||(P=new O(this.g),Q())};
chrome.runtime.onMessage.addListener(function(a){a.type==="offscreenVoicesResponse"?fa(a.voices):a.type==="offscreenTtsEventResponse"?aa(a.event):a.type==="languageUsed"&&S(a.language);return!0});
