'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(a){if(!(a instanceof Object))throw new TypeError("Iterator result "+a+" is not an object");}function B(){this.v=!1;this.o=null;this.i=void 0;this.h=1;this.l=this.u=0;this.F=this.j=null}function C(a){if(a.v)throw new TypeError("Generator is already running");a.v=!0}B.prototype.C=function(a){this.i=a};function D(a,b){a.j={K:b,isException:!0};a.h=a.u||a.l}B.prototype.getNextAddressJsc=function(){return this.h};B.prototype.getYieldResultJsc=function(){return this.i};
B.prototype.return=function(a){this.j={return:a};this.h=this.l};B.prototype["return"]=B.prototype.return;B.prototype.N=function(a){this.j={D:a};this.h=this.l};B.prototype.jumpThroughFinallyBlocks=B.prototype.N;B.prototype.g=function(a,b){this.h=b;return{value:a}};B.prototype.yield=B.prototype.g;B.prototype.R=function(a,b){a=q(a);var f=a.next();A(f);if(f.done)this.i=f.value,this.h=b;else return this.o=a,this.g(f.value,b)};B.prototype.yieldAll=B.prototype.R;B.prototype.D=function(a){this.h=a};
B.prototype.jumpTo=B.prototype.D;B.prototype.m=function(){this.h=0};B.prototype.jumpToEnd=B.prototype.m;B.prototype.B=function(a,b){this.u=a;b!=void 0&&(this.l=b)};B.prototype.setCatchFinallyBlocks=B.prototype.B;B.prototype.P=function(a){this.u=0;this.l=a||0};B.prototype.setFinallyBlock=B.prototype.P;B.prototype.G=function(a,b){this.h=a;this.u=b||0};B.prototype.leaveTryBlock=B.prototype.G;B.prototype.A=function(a){this.u=a||0;a=this.j.K;this.j=null;return a};B.prototype.enterCatchBlock=B.prototype.A;
B.prototype.I=function(a,b,f){f?this.F[f]=this.j:this.F=[this.j];this.u=a||0;this.l=b||0};B.prototype.enterFinallyBlock=B.prototype.I;B.prototype.O=function(a,b){b=this.F.splice(b||0)[0];(b=this.j=this.j||b)?b.isException?this.h=this.u||this.l:b.D!=void 0&&this.l<b.D?(this.h=b.D,this.j=null):this.h=this.l:this.h=a};B.prototype.leaveFinallyBlock=B.prototype.O;B.prototype.M=function(a){return new E(a)};B.prototype.forIn=B.prototype.M;
function E(a){this.i=a;this.g=[];for(var b in a)this.g.push(b);this.g.reverse()}E.prototype.h=function(){for(;this.g.length>0;){var a=this.g.pop();if(a in this.i)return a}return null};E.prototype.getNext=E.prototype.h;function F(a){this.g=new B;this.h=a}function G(a,b){C(a.g);var f=a.g.o;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.o,f);A(k);if(!k.done)return a.g.v=!1,k;var m=k.value}catch(e){return a.g.o=null,D(a.g,e),I(a)}a.g.o=null;g.call(a.g,m);return I(a)}function I(a){for(;a.g.h;)try{var b=a.h(a.g);if(b)return a.g.v=!1,{value:b.value,done:!1}}catch(f){a.g.i=void 0,D(a.g,f)}a.g.v=!1;if(a.g.j){b=a.g.j;a.g.j=null;if(b.isException)throw b.K;return{value:b.return,done:!0}}return{value:void 0,done:!0}}
function J(a){this.next=function(b){C(a.g);a.g.o?b=H(a,a.g.o.next,b,a.g.C):(a.g.C(b),b=I(a));return b};this.throw=function(b){C(a.g);a.g.o?b=H(a,a.g.o["throw"],b,a.g.C):(D(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.C),reject:e(this.l)}};b.prototype.C=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.G(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.I(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.F();this.v()};b.prototype.F=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.v=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.G=
function(e){var c=this.j();e.H(c.resolve,c.reject)};b.prototype.I=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.H(d(e,h),d(c,l));return r};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.H=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).H(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).H(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 aa(){var a=P;a.g.runtime.getPlatformInfo();setInterval(function(){a.g.runtime.getPlatformInfo()},2E4)};function Q(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:"",J:!1};return{lang:a,S:f,L:g,J:!0}}function ba(a){L(function(b){return b.return(ca(a))})}function da(a){L(function(b){if(b.h==1)return b.g(R(S),2);if(!b.i)return b.return();S.l&&S.l(a);a.type!=="end"&&a.type!=="error"||T(S);b.m()})}function U(a){return L(function(b){return b.h==1?b.g(a.g.offscreen.hasDocument(),2):b.return(b.i)})}
function V(a){var b,f;return L(function(g){switch(g.h){case 1:return g.g(U(a),2);case 2:if(g.i)return g.return();g.B(3);return g.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"},g.g(a.g.runtime.sendMessage(b),6);case 6:T(a);g.G(4);break;case 3:f=g.A(),console.error("Failed to create offscreen document:",f);case 4:return g.g(ea(a.h),
0)}})}function fa(a){L(function(b){if(b.h==1)return b.g(U(a),2);if(b.h!=3)return b.i?b.g(a.g.offscreen.closeDocument(),3):b.return();b.m()})}function R(a){var b;return L(function(f){if(f.h==1)return f.B(2),f.g(V(a),4);if(f.h!=2)return f.return(!0);b=f.A();console.error("Error ensuring offscreen document is ready:",b);return f.return(!1)})}function W(a){a.j&&(clearTimeout(a.j),a.j=void 0)}function T(a){W(a);a.j=setTimeout(function(){fa(a)},3E5)};function ha(){this.g=chrome;this.h=new Map}function ia(a,b){var f,g,k;return L(function(m){if(m.h==1)return f={type:"getLanguageStatus",lang:b},m.g(a.g.runtime.sendMessage(f),2);g=m.i;k={lang:g.lang,installStatus:g.status};a.g.ttsEngine.updateLanguage(k);m.m()})}
function ja(a){var b=S.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.m()})}
function ca(a){var b=S.h,f,g;return L(function(k){if(k.h==1)return b.h.get(a)==="uninstallLanguage"&&b.h.delete(a),k.g(X(b),2);f=k.i;f[a]=Date.now();g={};return k.g(b.g.storage.local.set((g.lastUsedTimestamps=f,g)),0)})}
function ea(a){var b,f,g,k,m,e,c,d,h;return L(function(l){switch(l.h){case 1:return l.g(Y(a),2);case 2:return(b=l.i)?l.g(X(a),3):l.return();case 3:f=l.i;g=ka(b,f);if(g.length===0)return l.return();k=q(g);m=k.next();case 4:if(m.done)return d={},l.g(a.g.storage.local.set((d.installedTimestamps=b,d)),8);e=m.value;c={type:"removeUnusedLanguage",lang:e};return l.g(a.g.runtime.sendMessage(c),7);case 7:e in b&&delete b[e];e in f&&delete f[e];m=k.next();l.D(4);break;case 8:return h={},l.g(a.g.storage.local.set((h.lastUsedTimestamps=
f,h)),0)}})}function ka(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(){la(a)},200)}
function la(a){var b,f,g,k,m,e,c,d,h,l,r,p,t,y;L(function(v){switch(v.h){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 v.g(ma(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 v.g(a.g.runtime.sendMessage(p),5);case 5:t=v.i;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.D(2);break;case 6:return v.return(na(a,f))}})}function ma(a,b){var f,g,k,m,e;return L(function(c){if(c.h==1)return c.g(Y(a),2);f=c.i;g=q(b);for(k=g.next();!k.done;k=g.next())m=k.value,delete f[m];e={};return c.g(a.g.storage.local.set((e.installedTimestamps=f,e)),0)})}function na(a,b){var f,g,k;return L(function(m){if(m.h==1)return f=Date.now(),m.g(Y(a),2);g=m.i;b.forEach(function(e){g[e]=f});k={};return m.g(a.g.storage.local.set((k.installedTimestamps=g,k)),0)})}
function Y(a){var b;return L(function(f){if(f.h==1)return f.g(a.g.storage.local.get("installedTimestamps"),2);b=f.i;return f.return(b.installedTimestamps||{})})}function X(a){var b;return L(function(f){if(f.h==1)return f.g(a.g.storage.local.get("lastUsedTimestamps"),2);b=f.i;return f.return(b.lastUsedTimestamps||{})})};var S=new function(){var a=new ha,b=this;this.g=chrome;this.h=a;this.A=function(f,g,k){var m,e,c;return L(function(d){switch(d.h){case 1:return W(b),d.g(R(b),2);case 2:if(!d.i)return k({type:"error",errorMessage:"Offscreen document not ready."}),d.return();b.l=k;m={type:"speak",utterance:f,options:g};d.B(3);return d.g(b.g.runtime.sendMessage(m),5);case 5:d.G(0);break;case 3:e=d.A(),c=e instanceof Error?e.message:"Error while trying to speak.",k({type:"error",errorMessage:c}),d.m()}})};this.B=function(){var f;
return L(function(g){if(g.h==1)return g.g(R(b),2);if(g.h!=3){if(!g.i)return T(b),g.return();b.l=void 0;f={type:"stop"};return g.g(b.g.runtime.sendMessage(f),3)}T(b);g.m()})};this.u=function(){var f;return L(function(g){if(g.h==1)return g.g(R(b),2);if(!g.i)return g.return();f={type:"pause"};return g.g(b.g.runtime.sendMessage(f),0)})};this.v=function(){var f;return L(function(g){if(g.h==1)return g.g(R(b),2);if(!g.i)return g.return();f={type:"resume"};return g.g(b.g.runtime.sendMessage(f),0)})};this.m=
function(f,g,k){var m,e,c,d,h,l,r;return L(function(p){if(p.h==1)return p.g(R(b),2);if(!p.i)return p.return();m=Q(f,g,k);e=m.lang;c=m.L;d=m.J;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.m()})};this.o=function(f,g,k){var m,e,c,d,h,l,r;return L(function(p){if(p.h==1)return p.g(R(b),2);if(!p.i)return p.return();m=Q(f,
g,k);e=m.lang;c=m.L;d=m.J;r=(l=(h=c)==null?void 0:h.source)!=null?l:"unknown";return d&&r===b.i?p.return(ia(b.h,e)):p.return()})};this.C=function(f,g){return L(function(k){if(k.h==1)return k.g(R(b),2);if(!k.i||f.source!==b.i)return k.return();var m=b.h;m.h.set(g,"uninstallLanguage");Z(m);k.m()})};this.i=this.g.ttsEngine.TtsClientSource.CHROMEFEATURE;this.g.runtime.onInstalled.addListener(function(){return L(function(f){return f.g(V(b),0)})});this.g.runtime.onStartup.addListener(function(){return L(function(f){return f.g(R(b),
0)})});this.g.ttsEngine.onSpeak.addListener(this.A);this.g.ttsEngine.onStop.addListener(this.B);this.g.ttsEngine.onPause.addListener(this.u);this.g.ttsEngine.onResume.addListener(this.v);this.g.ttsEngine.onInstallLanguageRequest.addListener(this.m);this.g.ttsEngine.onLanguageStatusRequest.addListener(this.o);this.g.ttsEngine.onUninstallLanguageRequest.addListener(this.C);P||(P=new O(this.g),aa())};
chrome.runtime.onMessage.addListener(function(a){a.type==="offscreenVoicesResponse"?ja(a.voices):a.type==="offscreenTtsEventResponse"?da(a.event):a.type==="languageUsed"&&ba(a.language);return!0});
