(()=>{"use strict";var e={64:(e,t,n)=>{t.Z=void 0;var i=n(8);function s(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};return new Promise((function(n,s){e.browserSupport||s("Your browser does not support Speech Synthesis");var o=(0,i.isNil)(t.listeners)?{}:t.listeners,a=!!(0,i.isNil)(t.splitSentences)||t.splitSentences,r=(0,i.isNil)(t.lang)?void 0:t.lang,u=(0,i.isNil)(t.volume)?1:t.volume,c=(0,i.isNil)(t.rate)?1:t.rate,l=(0,i.isNil)(t.pitch)?1:t.pitch,p=(0,i.isNil)(t.voice)?void 0:t.voice;Object.keys(o).forEach((function(e){var t=o[e];"onvoiceschanged"!==e&&(speechSynthesis[e]=function(e){t&&t(e)})})),e._loadVoices().then((function(t){o.onvoiceschanged&&o.onvoiceschanged(t),!(0,i.isNil)(r)&&e.setLanguage(r),!(0,i.isNil)(p)&&e.setVoice(p),!(0,i.isNil)(u)&&e.setVolume(u),!(0,i.isNil)(c)&&e.setRate(c),!(0,i.isNil)(l)&&e.setPitch(l),!(0,i.isNil)(a)&&e.setSplitSentences(a),n({voices:t,lang:e.lang,voice:e.voice,volume:e.volume,rate:e.rate,pitch:e.pitch,splitSentences:e.splitSentences,browserSupport:e.browserSupport})})).catch((function(e){s(e)}))}))}},{key:"_fetchVoices",value:function(){return new Promise((function(e,t){setTimeout((function(){var n=speechSynthesis.getVoices();return(0,i.size)(n)>0?e(n):t("Could not fetch voices")}),100)}))}},{key:"_loadVoices",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10;return this._fetchVoices().catch((function(n){if(0===t)throw n;return e._loadVoices(t-1)}))}},{key:"hasBrowserSupport",value:function(){return this.browserSupport}},{key:"setVoice",value:function(e){var t,n=speechSynthesis.getVoices();if((0,i.isString)(e)&&(t=n.find((function(t){return t.name===e}))),(0,i.isObject)(e)&&(t=e),!t)throw"Error setting voice. The voice you passed is not valid or the voices have not been loaded yet.";this.synthesisVoice=t}},{key:"setLanguage",value:function(e){if(e=e.replace("_","-"),!(0,i.validateLocale)(e))throw"Error setting language. Please verify your locale is BCP47 format (http://schneegans.de/lv/?tags=es-FR&format=text)";this.lang=e}},{key:"setVolume",value:function(e){if(e=parseFloat(e),!(!(0,i.isNan)(e)&&e>=0&&e<=1))throw"Error setting volume. Please verify your volume value is a number between 0 and 1.";this.volume=e}},{key:"setRate",value:function(e){if(e=parseFloat(e),!(!(0,i.isNan)(e)&&e>=0&&e<=10))throw"Error setting rate. Please verify your volume value is a number between 0 and 10.";this.rate=e}},{key:"setPitch",value:function(e){if(e=parseFloat(e),!(!(0,i.isNan)(e)&&e>=0&&e<=2))throw"Error setting pitch. Please verify your pitch value is a number between 0 and 2.";this.pitch=e}},{key:"setSplitSentences",value:function(e){this.splitSentences=e}},{key:"speak",value:function(e){var t=this;return new Promise((function(n,s){var o=e.text,a=e.listeners,r=void 0===a?{}:a,u=e.queue,c=void 0===u||u,l=(0,i.trim)(o);(0,i.isNil)(l)&&n(),!c&&t.cancel();var p=[],h=t.splitSentences?(0,i.splitSentences)(l):[l];h.forEach((function(e,o){var a=o===(0,i.size)(h)-1,u=new SpeechSynthesisUtterance;t.synthesisVoice&&(u.voice=t.synthesisVoice),t.lang&&(u.lang=t.lang),t.volume&&(u.volume=t.volume),t.rate&&(u.rate=t.rate),t.pitch&&(u.pitch=t.pitch),u.text=e,Object.keys(r).forEach((function(e){var t=r[e];u[e]=function(i){t&&t(i),"onerror"===e&&s({utterances:p,lastUtterance:u,error:i}),"onend"===e&&a&&n({utterances:p,lastUtterance:u})}})),p.push(u),speechSynthesis.speak(u)}))}))}},{key:"pending",value:function(){return speechSynthesis.pending}},{key:"paused",value:function(){return speechSynthesis.paused}},{key:"speaking",value:function(){return speechSynthesis.speaking}},{key:"pause",value:function(){speechSynthesis.pause()}},{key:"resume",value:function(){speechSynthesis.resume()}},{key:"cancel",value:function(){speechSynthesis.cancel()}}],n&&s(t.prototype,n),o&&s(t,o),e}();t.Z=o},8:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.trim=t.isObject=t.isNil=t.isNan=t.size=t.isString=t.validateLocale=t.splitSentences=void 0;t.splitSentences=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.replace(/\.+/g,".|").replace(/\?/g,"?|").replace(/\!/g,"!|").split("|").map((function(e){return s(e)})).filter(Boolean)};var n=/^(?:(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))$|^((?:[a-z]{2,3}(?:(?:-[a-z]{3}){1,3})?)|[a-z]{4}|[a-z]{5,8})(?:-([a-z]{4}))?(?:-([a-z]{2}|\d{3}))?((?:-(?:[\da-z]{5,8}|\d[\da-z]{3}))*)?((?:-[\da-wy-z](?:-[\da-z]{2,8})+)*)?(-x(?:-[\da-z]{1,8})+)?$|^(x(?:-[\da-z]{1,8})+)$/i;t.validateLocale=function(e){return"string"==typeof e&&n.test(e)};var i=function(e){return"string"==typeof e||e instanceof String};t.isString=i;t.size=function(e){return e&&Array.isArray(e)&&e.length?e.length:0};t.isNan=function(e){return"number"==typeof e&&isNaN(e)};t.isNil=function(e){return null==e};t.isObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)};var s=function(e){return i(e)?e.trim():""};t.trim=s}},t={};function n(i){var s=t[i];if(void 0!==s)return s.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,n),o.exports}(()=>{var e=n(64);function t(e,t){for(var n=0;n-1;return!!e}},{key:"getBrowser",value:function(){return a(this,l)}},{key:"getLanguage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a(this,f),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a(this,d);return a(this,d)===t||r(this,m,_).call(this,e,t),a(this,d)}},{key:"getVoice",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:a(this,f),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a(this,d);return a(this,f)===e||r(this,m,_).call(this,e,t),a(this,f)}}],o&&t(n.prototype,o),c&&t(n,c),Object.defineProperty(n,"prototype",{writable:!1}),e}();function x(){var e=this,t=a(this,p).browser;Object.keys(t).map((function(n){t[n]&&u(e,l,n.replace("is_",""))}))}function _(e,t){var n,i="",s=e||a(this,v),o=t||a(this,g),c=r(this,b,T).call(this,o),l=r(this,S,B).call(this,c);if(l.length>1)for(var p=0;p '+this.playButtonText()+""},replayButtonText:function(){return this.buttonTextArr.replay_text},replayButtonContent:function(){return'
'+this.replayButtonText()+"
"},pauseButtonText:function(){return this.buttonTextArr.pause_text},pauseButtonContent:function(){return'
'+this.pauseButtonText()+"
"},resumeButtonText:function(){return this.buttonTextArr.resume_text},resumeButtonContent:function(){return'
'+this.buttonTextArr.resume_text+"
"},recordStartButtonContent:function(){return' '+this.buttonTextArr.start_text},recordStopButtonConten:function(){return' '+this.buttonTextArr.stop_text},displayApiMissing:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="",i="";if(A.speechRecognitionIsActive||(n+="Text To Audio: Please enable speechRecognition"),A.speechSynthesis||(n+=n?" , speechSynthesis.":"Text To Audio: Please enable speechSynthesis."),e){var s=document.getElementById(e).previousSibling;s?(n+=' Click here to enable',s.style.display="block",s.innerHTML=n,setTimeout((function(){document.querySelector(".tta_notice").style.display="none",s.innerHTML=""}),5e3)):(i+=ttsObj.admin_url+"admin.php?page=text-to-audio#/docs",n+="\nFollow this link to enable: \n".concat(i),alert(n))}else t||"?page=text-to-audio"===location.search&&"#/customize"===location.hash?i+=ttsObj.admin_url+"admin.php?page=text-to-audio#/docs":i+="https://wordpress.org/plugins/text-to-audio/#how%20to%20enable%20%60%60speechsynthesis%60%60%20on%20firefox%3F",n+="\nFollow this link to enable: \n".concat(i),alert(n);throw new Error(n)},_init:function(){void 0!==A.ttsListeningSettings&&A.speech.init({volume:A.ttsListeningSettings.tta__listening_volume?A.ttsListeningSettings.tta__listening_volume:1,rate:A.ttsListeningSettings.tta__listening_rate?A.ttsListeningSettings.tta__listening_rate:1,pitch:A.ttsListeningSettings.tta__listening_pitch?A.ttsListeningSettings.tta__listening_pitch:2,splitSentences:!0,listeners:{onvoiceschanged:function(e){}}}).then((function(e){A.voices=e.voices,A.browser=new k(ttsObj,e.voices,A.ttsListeningSettings.tta__listening_lang,A.ttsListeningSettings.tta__listening_voice),A._prepareSpeakButton(A.speech)})).catch((function(e){console.error("An error occured while initializing : ",e)}))},_prepareSpeakButton:function(e){A.speakButton.addEventListener("click",(function(){"listen"==A.listenStatus?(A.speak(e),A.speakButton.innerHTML=A.pauseButtonContent(),A.speakButton.setAttribute("title","Text To Audio : "+A.pauseButtonText()),A.listenStatus="pause",A.browser.isAndroid()||(A.timer=setTimeout((function t(){e.pause(),console.log(e),setTimeout((function(){e.resume()}),0),A.timer=setTimeout(t,1e4)}),1e4))):"pause"==A.listenStatus?(e.pause(),A.speakButton.innerHTML=A.resumeButtonContent(),A.speakButton.setAttribute("title","Text To Audio : "+A.resumeButtonText()),A.listenStatus="resume",A.browser.isAndroid()||clearTimeout(A.timer)):"resume"==A.listenStatus&&(e.resume(),A.speakButton.innerHTML=A.pauseButtonContent(),A.listenStatus="pause",A.speakButton.setAttribute("title","Text To Audio : "+A.pauseButtonText()),A.browser.isAndroid()||(A.timer=setTimeout((function t(){e.pause(),console.log(e),setTimeout((function(){e.resume()}),0),A.timer=setTimeout(t,1e4)}),1e4)))}))}};window.tta=A,window.tta._init()})()})();