Files
ntspi-app/public/js/bvi.min.js
T
2026-03-20 21:47:02 +05:00

7 lines
38 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*!
* Button visually impaired - v1.0.0 https://bvi.isvek.ru
* Copyright 2014-2021 Oleg Korotenko <bvi@isvek.ru>.
* Licensed MIT (https://github.com/veks/button-visually-impaired-javascript/blob/master/LICENSE.md)
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).isvek=t()}(this,(function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function t(t){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?e(Object(i),!0).forEach((function(e){a(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}!function(e){var t=function(e){var t,i=Object.prototype,r=i.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",l=o.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function u(e,t,n,i){var r=t&&t.prototype instanceof g?t:g,o=Object.create(r.prototype),a=new q(i||[]);return o._invoke=function(e,t,n){var i=f;return function(r,o){if(i===d)throw new Error("Generator is already running");if(i===m){if("throw"===r)throw o;return H()}for(n.method=r,n.arg=o;;){var a=n.delegate;if(a){var c=E(a,n);if(c){if(c===b)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var l=v(e,t,n);if("normal"===l.type){if(i=n.done?m:h,l.arg===b)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=m,n.method="throw",n.arg=l.arg)}}}(e,n,a),o}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var f="suspendedStart",h="suspendedYield",d="executing",m="completed",b={};function g(){}function p(){}function y(){}var S={};s(S,a,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(x([])));k&&k!==i&&r.call(k,a)&&(S=k);var w=y.prototype=g.prototype=Object.create(S);function L(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function B(e,t){function i(o,a,c,l){var s=v(e[o],e,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"===n(f)&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){i("next",e,c,l)}),(function(e){i("throw",e,c,l)})):t.resolve(f).then((function(e){u.value=e,c(u)}),(function(e){return i("throw",e,c,l)}))}l(s.arg)}var o;this._invoke=function(e,n){function r(){return new t((function(t,r){i(e,n,t,r)}))}return o=o?o.then(r,r):r()}}function E(e,n){var i=e.iterator[n.method];if(i===t){if(n.delegate=null,"throw"===n.method){if(e.iterator.return&&(n.method="return",n.arg=t,E(e,n),"throw"===n.method))return b;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return b}var r=v(i,e.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,b;var o=r.arg;return o?o.done?(n[e.resultName]=o.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,b):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,b)}function O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function q(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,this),this.reset(!0)}function x(e){if(e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function n(){for(;++i<e.length;)if(r.call(e,i))return n.value=e[i],n.done=!1,n;return n.value=t,n.done=!0,n};return o.next=o}}return{next:H}}function H(){return{value:t,done:!0}}return p.prototype=y,s(w,"constructor",y),s(y,"constructor",p),p.displayName=s(y,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,s(e,l,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},L(B.prototype),s(B.prototype,c,(function(){return this})),e.AsyncIterator=B,e.async=function(t,n,i,r,o){void 0===o&&(o=Promise);var a=new B(u(t,n,i,r),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},L(w),s(w,l,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var i=t.pop();if(i in e)return n.value=i,n.done=!1,n}return n.done=!0,n}},e.values=x,q.prototype={constructor:q,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function i(i,r){return c.type="throw",c.arg=e,n.next=i,r&&(n.method="next",n.arg=t),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(l&&s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),b},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;A(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:x(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),b}},e}({});try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":n(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(),[Element.prototype,Document.prototype,DocumentFragment.prototype].forEach((function(e){e.hasOwnProperty("prepend")||Object.defineProperty(e,"prepend",{configurable:!0,enumerable:!0,writable:!0,value:function(){var e=Array.prototype.slice.call(arguments),t=document.createDocumentFragment();e.forEach((function(e){var n=e instanceof Node;t.appendChild(n?e:document.createTextNode(String(e)))})),this.insertBefore(t,this.firstChild)}})})),window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),window.HTMLCollection&&!HTMLCollection.prototype.forEach&&(HTMLCollection.prototype.forEach=Array.prototype.forEach);var l=function(e){switch(e){case"on":case"true":case"1":return!0;default:return!1}},s=function(e,t,n){for("string"==typeof t&&(t=document.createElement(t)),e.appendChild(t).className=n;e.firstChild!==t;)t.appendChild(e.firstChild)},u=function(e){var t=document.createDocumentFragment();if(e){for(;e.firstChild;){var n=e.removeChild(e.firstChild);t.appendChild(n)}e.parentNode.replaceChild(t,e)}},v=function(e,t){Object.keys(e).forEach((function(e){"function"==typeof t&&t(e)}))},f=function(e,t){Array.from(e).forEach((function(e){"function"==typeof t&&t(e)}))},h=function(){return window.speechSynthesis},d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=new Date,i=n.getTime();i+=864e5,n.setTime(i),document.cookie="bvi_".concat(e,"=").concat(t,";path=/;expires=").concat(n.toUTCString(),";domain=").concat(location.host)},m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";e="bvi_".concat(e,"=");for(var t=decodeURIComponent(document.cookie),n=t.split(";"),i=0;i<n.length;i++){var r=n[i].trim();if(-1!==r.indexOf(e))return r.substring(e.length,r.length)}},b=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";document.cookie="bvi_".concat(e,"=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=").concat(location.host)},g={"ru-RU":{text:{fontSize:"Размер шрифта",siteColors:"Цвета сайта",images:"Изображения",speech:"Синтез речи",settings:"Настройки",regularVersionOfTheSite:"Обычная версия сайта",letterSpacing:"Межбуквенное расстояние",normal:"Стандартный",average:"Средний",big:"Большой",lineHeight:"Межстрочный интервал",font:"Шрифт",arial:"Без засечек",times:"С засечками",builtElements:"Встроенные элементы (Видео, карты и тд.)",on:"Включить",off:"Выключить",reset:"Сбросить настройки",plural_0:"пиксель",plural_1:"пекселя",plural_2:"пикселей"},voice:{fontSizePlus:"Размер шрифта увели́чен",fontSizeMinus:"Размер шрифта уме́ньшен",siteColorBlackOnWhite:"Цвет сайта черным по белому",siteColorWhiteOnBlack:"Цвет сайта белым по черному",siteColorDarkBlueOnBlue:"Цвет сайта тёмно-синим по голубому",siteColorBeigeBrown:"Цвет сайта кори́чневым по бе́жевому",siteColorGreenOnDarkBrown:"Цвет сайта зеленым по тёмно-коричневому",imagesOn:"Изображения включены",imagesOFF:"Изображения выключены",imagesGrayscale:"Изображения чёрно-белые",speechOn:"Синтез речи включён",speechOff:"Синтез речи вы́ключен",lineHeightNormal:"Межстрочный интервал стандартный",lineHeightAverage:"Межстрочный интервал средний",lineHeightBig:"Межстрочный интервал большой",LetterSpacingNormal:"Интервал между буквами стандартный",LetterSpacingAverage:"Интервал между буквами средний",LetterSpacingBig:"Интервал между буквами большой",fontArial:"Шрифт без засечек",fontTimes:"Шрифт с засечками",builtElementsOn:"Встроенные элементы включены",builtElementsOFF:"Встроенные элементы выключены",resetSettings:"Установлены настройки по умолча́нию",panelShow:"Панель открыта",panelHide:"Панель скрыта",panelOn:"Версия сайта для слабови́дящий",panelOff:"Обычная версия сайта"}},"en-US":{text:{fontSize:"Font size",siteColors:"Site colors",images:"Images",speech:"Speech synthesis",settings:"Settings",regularVersionOfTheSite:"Regular version Of The site",letterSpacing:"Letter spacing",normal:"Single",average:"One and a half",big:"Double",lineHeight:"Line spacing",font:"Font",arial:"Sans Serif - Arial",times:"Serif - Times New Roman",builtElements:"Include inline elements (Videos, maps, etc.)",on:"Enable",off:"Disabled",reset:"Reset settings",plural_0:"pixel",plural_1:"pixels",plural_2:"pixels"},voice:{fontSizePlus:"Font size increased",fontSizeMinus:"Font size reduced",siteColorBlackOnWhite:"Site color black on white",siteColorWhiteOnBlack:"Site color white on black",siteColorDarkBlueOnBlue:"Site color dark blue on cyan",siteColorBeigeBrown:"SiteColorBeigeBrown",siteColorGreenOnDarkBrown:"Site color green on dark brown",imagesOn:"Images enable",imagesOFF:"Images disabled",imagesGrayscale:"Images gray scale",speechOn:"Synthesis speech enable",speechOff:"Synthesis speech disabled",lineHeightNormal:"Line spacing single",lineHeightAverage:"Line spacing one and a half",lineHeightBig:"Line spacing double",LetterSpacingNormal:"Letter spacing single",LetterSpacingAverage:"Letter spacing one and a half",LetterSpacingBig:"Letter spacing letter double",fontArial:"Sans Serif - Arial",fontTimes:"Serif - Times New Roman",builtElementsOn:"Include inline elements are enabled",builtElementsOFF:"Include inline elements are disabled",resetSettings:"Default settings have been set",panelShow:"Panel show",panelHide:"Panel hide",panelOn:"Site version for visually impaired",panelOff:"Regular version of the site"}}},p=function(){function e(t){i(this,e),this._config=t}return o(e,[{key:"t",value:function(e){return g[this._config.lang].text[e]}},{key:"v",value:function(e){return g[this._config.lang].voice[e]}}]),e}(),y={target:".bvi-open",fontSize:16,theme:"white",images:"grayscale",letterSpacing:"normal",lineHeight:"normal",speech:!0,fontFamily:"arial",builtElements:!1,panelFixed:!0,panelHide:!1,reload:!1,lang:"ru-RU"},S={target:"string",fontSize:"number",theme:"string",images:"(string|boolean)",letterSpacing:"string",lineHeight:"string",speech:"boolean",fontFamily:"string",builtElements:"boolean",panelFixed:"boolean",panelHide:"boolean",reload:"boolean",lang:"string"},_={target:"",fontSize:"(^[1-9]$|^[1-3][0-9]?$|^39$)",theme:"(white|black|blue|brown|green)",images:"(true|false|grayscale)",letterSpacing:"(normal|average|big)",lineHeight:"(normal|average|big)",speech:"(true|false)",fontFamily:"(arial|times)",builtElements:"(true|false)",panelFixed:"(true|false)",panelHide:"(true|false)",reload:"(true|false)",lang:"(ru-RU|en-US)"};return{Bvi:function(){function e(t){i(this,e),this._config=this._getConfig(t),this._elements=document.querySelectorAll(this._config.target),this._i18n=new p({lang:this._config.lang}),this._addEventListeners(),this._init(),console.log("Bvi console: ready Button visually impaired v1.0.0")}return o(e,[{key:"_init",value:function(){v(this._config,(function(e){void 0===m(e)&&b("panelActive")})),l(m("panelActive"))?(this._set(),this._getPanel(),this._addEventListenersPanel(),this._images(),this._speechPlayer(),"speechSynthesis"in window&&l(m("speech"))&&setInterval((function(){if(!1===h().pending){var e=document.querySelectorAll(".bvi-speech-play"),t=document.querySelectorAll(".bvi-speech-pause"),n=document.querySelectorAll(".bvi-speech-resume"),i=document.querySelectorAll(".bvi-speech-stop"),r=function(e,t){e.forEach((function(e){return t(e)}))};r(e,(function(e){return e.classList.remove("disabled")})),r(t,(function(e){return e.classList.add("disabled")})),r(n,(function(e){return e.classList.add("disabled")})),r(i,(function(e){return e.classList.add("disabled")}))}}),1e3)):this._remove()}},{key:"_addEventListeners",value:function(){var e=this;if(!this._elements)return!1;this._elements.forEach((function(t){t.addEventListener("click",(function(t){t.preventDefault(),v(e._config,(function(t){return d(t,e._config[t])})),d("panelActive",!0),e._init(),e._speech("".concat(e._i18n.v("panelOn")))}))}))}},{key:"_addEventListenersPanel",value:function(){var e=this,t={fontSizeMinus:document.querySelector(".bvi-fontSize-minus"),fontSizePlus:document.querySelector(".bvi-fontSize-plus"),themeWhite:document.querySelector(".bvi-theme-white"),themeBlack:document.querySelector(".bvi-theme-black"),themeBlue:document.querySelector(".bvi-theme-blue"),themeBrown:document.querySelector(".bvi-theme-brown"),themeGreen:document.querySelector(".bvi-theme-green"),imagesOn:document.querySelector(".bvi-images-on"),imagesOff:document.querySelector(".bvi-images-off"),imagesGrayscale:document.querySelector(".bvi-images-grayscale"),speechOn:document.querySelector(".bvi-speech-on"),speechOff:document.querySelector(".bvi-speech-off"),lineHeightNormal:document.querySelector(".bvi-line-height-normal"),lineHeightAverage:document.querySelector(".bvi-line-height-average"),lineHeightBig:document.querySelector(".bvi-line-height-big"),letterSpacingNormal:document.querySelector(".bvi-letter-spacing-normal"),letterSpacingAverage:document.querySelector(".bvi-letter-spacing-average"),letterSpacingBig:document.querySelector(".bvi-letter-spacing-big"),fontFamilyArial:document.querySelector(".bvi-font-family-arial"),fontFamilyTimes:document.querySelector(".bvi-font-family-times"),builtElementsOn:document.querySelector(".bvi-built-elements-on"),builtElementsOff:document.querySelector(".bvi-built-elements-off"),reset:document.querySelector(".bvi-reset"),links:document.querySelectorAll(".bvi-link"),modal:document.querySelector(".bvi-modal")},n=function(e){var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw o}}}}(e.parentNode.children);try{for(n.s();!(t=n.n()).done;)t.value.classList.remove("active")}catch(e){n.e(e)}finally{n.f()}e.classList.add("active")},i=function(e,t){e.addEventListener("click",(function(e){e.preventDefault(),"function"==typeof t&&t(e)}))},r=function(){document.querySelectorAll(".bvi-link").forEach((function(e){e.classList.remove("active")})),v(e._config,(function(e){if("theme"===e){var t=m(e);document.querySelector(".bvi-theme-".concat(t)).classList.add("active")}if("images"===e){var n="grayscale"===m(e)?"grayscale":l(m(e))?"on":"off";document.querySelector(".bvi-images-".concat(n)).classList.add("active")}if("speech"===e){var i=l(m(e))?"on":"off";document.querySelector(".bvi-speech-".concat(i)).classList.add("active")}if("lineHeight"===e){var r=m(e);document.querySelector(".bvi-line-height-".concat(r)).classList.add("active")}if("letterSpacing"===e){var o=m(e);document.querySelector(".bvi-letter-spacing-".concat(o)).classList.add("active")}if("fontFamily"===e){var a=m(e);document.querySelector(".bvi-font-family-".concat(a)).classList.add("active")}if("builtElements"===e){var c=l(m(e))?"on":"off";document.querySelector(".bvi-built-elements-".concat(c)).classList.add("active")}}))};r(),i(t.fontSizeMinus,(function(){var i=parseFloat(m("fontSize"))-1;0!==i&&(e._setAttrDataBviBody("fontSize",i),d("fontSize",i),e._speech("".concat(e._i18n.v("fontSizeMinus"))),n(t.fontSizeMinus))})),i(t.fontSizePlus,(function(){var i=parseFloat(m("fontSize"))+1;40!==i&&(e._setAttrDataBviBody("fontSize",i),d("fontSize",i),e._speech("".concat(e._i18n.v("fontSizePlus"))),n(t.fontSizePlus))})),i(t.themeWhite,(function(){e._setAttrDataBviBody("theme","white"),d("theme","white"),e._speech("".concat(e._i18n.v("siteColorBlackOnWhite"))),n(t.themeWhite)})),i(t.themeBlack,(function(){e._setAttrDataBviBody("theme","black"),d("theme","black"),e._speech("".concat(e._i18n.v("siteColorWhiteOnBlack"))),n(t.themeBlack)})),i(t.themeBlue,(function(){e._setAttrDataBviBody("theme","blue"),d("theme","blue"),e._speech("".concat(e._i18n.v("siteColorDarkBlueOnBlue"))),n(t.themeBlue)})),i(t.themeBrown,(function(){e._setAttrDataBviBody("theme","brown"),d("theme","brown"),e._speech("".concat(e._i18n.v("siteColorBeigeBrown"))),n(t.themeBrown)})),i(t.themeGreen,(function(){e._setAttrDataBviBody("theme","green"),d("theme","green"),e._speech("".concat(e._i18n.v("siteColorGreenOnDarkBrown"))),n(t.themeGreen)})),i(t.imagesOn,(function(){e._setAttrDataBviBody("images","true"),d("images","true"),e._speech("".concat(e._i18n.v("imagesOn"))),n(t.imagesOn)})),i(t.imagesOff,(function(){e._setAttrDataBviBody("images","false"),d("images","false"),e._speech("".concat(e._i18n.v("imagesOFF"))),n(t.imagesOff)})),i(t.imagesGrayscale,(function(){e._setAttrDataBviBody("images","grayscale"),d("images","grayscale"),e._speech("".concat(e._i18n.v("imagesGrayscale"))),n(t.imagesGrayscale)})),i(t.speechOn,(function(){e._setAttrDataBviBody("speech","true"),d("speech","true"),e._speech("".concat(e._i18n.v("speechOn"))),n(t.speechOn),e._speechPlayer()})),i(t.speechOff,(function(){e._speech("".concat(e._i18n.v("speechOff"))),e._setAttrDataBviBody("speech","false"),d("speech","false"),n(t.speechOff),e._speechPlayer()})),i(t.lineHeightNormal,(function(){e._setAttrDataBviBody("lineHeight","normal"),d("lineHeight","normal"),e._speech("".concat(e._i18n.v("lineHeightNormal"))),n(t.lineHeightNormal)})),i(t.lineHeightAverage,(function(){e._setAttrDataBviBody("lineHeight","average"),d("lineHeight","average"),e._speech("".concat(e._i18n.v("lineHeightAverage"))),n(t.lineHeightAverage)})),i(t.lineHeightBig,(function(){e._setAttrDataBviBody("lineHeight","big"),d("lineHeight","big"),e._speech("".concat(e._i18n.v("lineHeightBig"))),n(t.lineHeightBig)})),i(t.letterSpacingNormal,(function(){e._setAttrDataBviBody("letterSpacing","normal"),d("letterSpacing","normal"),e._speech("".concat(e._i18n.v("LetterSpacingNormal"))),n(t.letterSpacingNormal)})),i(t.letterSpacingAverage,(function(){e._setAttrDataBviBody("letterSpacing","average"),d("letterSpacing","average"),e._speech("".concat(e._i18n.v("LetterSpacingAverage"))),n(t.letterSpacingAverage)})),i(t.letterSpacingBig,(function(){e._setAttrDataBviBody("letterSpacing","big"),d("letterSpacing","big"),e._speech("".concat(e._i18n.v("LetterSpacingBig"))),n(t.letterSpacingBig)})),i(t.fontFamilyArial,(function(){e._setAttrDataBviBody("fontFamily","arial"),d("fontFamily","arial"),e._speech("".concat(e._i18n.v("fontArial"))),n(t.fontFamilyArial)})),i(t.fontFamilyTimes,(function(){e._setAttrDataBviBody("fontFamily","times"),d("fontFamily","times"),e._speech("".concat(e._i18n.v("fontTimes"))),n(t.fontFamilyTimes)})),i(t.builtElementsOn,(function(){e._setAttrDataBviBody("builtElements","true"),d("builtElements","true"),e._speech("".concat(e._i18n.v("builtElementsOn"))),n(t.builtElementsOn)})),i(t.builtElementsOff,(function(){e._setAttrDataBviBody("builtElements","false"),d("builtElements","false"),e._speech("".concat(e._i18n.v("builtElementsOFF"))),n(t.builtElementsOff)})),i(t.reset,(function(){e._speech("".concat(e._i18n.v("resetSettings"))),v(e._config,(function(t){e._setAttrDataBviBody(t,e._config[t]),d(t,e._config[t]),r()}))})),f(t.links,(function(n){i(n,(function(n){var i=n.target.getAttribute("data-bvi");"close"===i&&(e._setAttrDataBviBody("panelActive","false"),d("panelActive","false"),e._init()),"modal"===i&&(document.body.style.overflow="hidden",document.body.classList.add("bvi-noscroll"),t.modal.classList.toggle("show")),"modal-close"===i&&(document.body.classList.remove("bvi-noscroll"),document.body.style.overflow="",t.modal.classList.remove("show")),"panel-hide"===i&&(document.querySelector(".bvi-panel").classList.add("bvi-panel-hide"),document.querySelector(".bvi-link-fixed-top").classList.remove("bvi-hide"),document.querySelector(".bvi-link-fixed-top").classList.add("bvi-show"),d("panelHide","true"),e._speech("".concat(e._i18n.v("panelHide")))),"panel-show"===i&&(document.querySelector(".bvi-link-fixed-top").classList.remove("bvi-show"),document.querySelector(".bvi-link-fixed-top").classList.add("bvi-hide"),document.querySelector(".bvi-panel").classList.remove("bvi-panel-hide"),d("panelHide","false"),e._speech("".concat(e._i18n.v("panelShow"))))}))})),i(t.modal,(function(e){e.target.contains(t.modal)&&(document.body.classList.remove("bvi-noscroll"),document.body.style.overflow="",t.modal.classList.remove("show"))}))}},{key:"_getPanel",value:function(){var e=function(){var e=void 0!==window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;l(m("panelFixed"))&&(e>200?document.querySelector(".bvi-panel").classList.add("bvi-fixed-top"):document.querySelector(".bvi-panel").classList.remove("bvi-fixed-top"))},t=l(m("panelHide"))?" bvi-panel-hide":"",n=l(m("panelHide"))?"bvi-show":" bvi-hide",i="\n <div class='bvi-panel".concat(t,'\'>\n <div class="bvi-blocks bvi-block-center">\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("fontSize"),'</div>\n <a class="bvi-link bvi-fontSize-minus">А-</a>\n <a class="bvi-link bvi-fontSize-plus">А+</a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("siteColors"),'</div>\n <a href="#" class="bvi-link bvi-theme-white">Ц</a>\n <a href="#" class="bvi-link bvi-theme-black">Ц</a>\n <a href="#" class="bvi-link bvi-theme-blue">Ц</a>\n <a href="#" class="bvi-link bvi-theme-brown">Ц</a>\n <a href="#" class="bvi-link bvi-theme-green">Ц</a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("images"),'</div>\n <a href="#" class="bvi-link bvi-images-on">\n <i class="bvi-images bvi-images-image"></i>\n </a>\n <a href="#" class="bvi-link bvi-images-off">\n <i class="bvi-images bvi-images-minus-circle"></i>\n </a>\n <a href="#" class="bvi-link bvi-images-grayscale">\n <i class="bvi-images bvi-images-adjust"></i>\n </a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("speech"),'</div>\n <a href="#" class="bvi-link bvi-speech-off">\n <i class="bvi-images bvi-images-volume-off"></i>\n </a>\n <a href="#" class="bvi-link bvi-speech-on">\n <i class="bvi-images bvi-images-volume-up"></i>\n </a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("settings"),'</div>\n <a href="#" class="bvi-link" data-bvi="modal">\n <i class="bvi-images bvi-images-cog"></i>\n </a>\n <a href="#" class="bvi-link" data-bvi="close">\n ').concat(this._i18n.t("regularVersionOfTheSite"),'\n </a>\n <a href="#" class="bvi-link" data-bvi="panel-hide">\n <i class="bvi-images bvi-images-minus"></i>\n </a>\n </div>\n </div>\n <div class="bvi-modal">\n <div class="bvi-modal-dialog">\n <div class="bvi-modal-content">\n <div class="bvi-modal-header">\n <div class="bvi-modal-title">').concat(this._i18n.t("settings"),'</div>\n <a href="#" class="bvi-link bvi-modal-close" data-bvi="modal-close">×</a>\n </div>\n <div class="bvi-modal-body">\n <div class="bvi-blocks bvi-block-center">\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("letterSpacing"),'</div>\n <a href="#" class="bvi-link bvi-letter-spacing-normal">').concat(this._i18n.t("normal"),'</a>\n <a href="#" class="bvi-link bvi-letter-spacing-average">').concat(this._i18n.t("average"),'</a>\n <a href="#" class="bvi-link bvi-letter-spacing-big">').concat(this._i18n.t("big"),'</a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("lineHeight"),'</div>\n <a href="#" class="bvi-link bvi-line-height-normal">').concat(this._i18n.t("normal"),'</a>\n <a href="#" class="bvi-link bvi-line-height-average">').concat(this._i18n.t("average"),'</a>\n <a href="#" class="bvi-link bvi-line-height-big">').concat(this._i18n.t("big"),'</a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("font"),'</div>\n <a href="#" class="bvi-link bvi-font-family-arial">').concat(this._i18n.t("arial"),'</a>\n <a href="#" class="bvi-link bvi-font-family-times">').concat(this._i18n.t("times"),'</a>\n </div>\n <div class="bvi-block">\n <div class="bvi-block-title">').concat(this._i18n.t("builtElements"),'</div>\n <a href="#" class="bvi-link bvi-built-elements-on">').concat(this._i18n.t("on"),'</a>\n <a href="#" class="bvi-link bvi-built-elements-off">').concat(this._i18n.t("off"),'</a>\n </div>\n </div>\n <div class="bvi-blocks bvi-block-center">\n <a href="https://bvi.isvek.ru" class="bvi-copyright" target="_blank">bvi.isvek.ru</a>\n </div>\n </div>\n <div class="bvi-modal-footer">\n <a href="#" class="bvi-link bvi-reset">').concat(this._i18n.t("reset"),"</a>\n </div>\n </div>\n </div>\n </div>\n </div>"),r='<a href="#" class="bvi-link bvi-link-fixed-top bvi-no-styles '.concat(n,'" data-bvi="panel-show">')+'<i class="bvi-images bvi-images-eye bvi-images-size-32 bvi-no-styles"></i></a>';window.addEventListener("scroll",e),document.querySelector(".bvi-body").insertAdjacentHTML("beforebegin",i),document.querySelector(".bvi-body").insertAdjacentHTML("afterbegin",r),e()}},{key:"_set",value:function(){var e=this;document.body.classList.add("bvi-active"),s(document.body,"div","bvi-body"),v(this._config,(function(t){return e._setAttrDataBviBody(t,m(t))})),f(this._elements,(function(e){return e.style.display="none"})),document.querySelectorAll("img").forEach((function(e){e.classList.contains("bvi-img")&&e.classList.remove("bvi-img")})),document.querySelectorAll("body *").forEach((function(e){e.classList.contains("bvi-background-image")&&e.classList.remove("bvi-background-image")}))}},{key:"_remove",value:function(){var e=document.querySelector(".bvi-panel"),t=document.querySelector(".bvi-body"),n=document.querySelector(".bvi-link-fixed-top");e&&e.remove(),t&&u(t),n&&n.remove(),this._speech("".concat(this._i18n.v("panelOff"))),document.body.classList.remove("bvi-active"),f(this._elements,(function(e){return e.style.display=""})),l(m("reload"))&&document.location.reload(),v(this._config,(function(e){b(e)})),this._speechPlayer(),b("panelActive")}},{key:"_images",value:function(){document.querySelectorAll("img").forEach((function(e){e.classList.contains("bvi-no-style")||e.classList.add("bvi-img")})),document.querySelectorAll(".bvi-body *").forEach((function(e){var t=getComputedStyle(e);"none"===t.backgroundImage||"none"===t.background||e.classList.contains("bvi-no-style")||e.classList.add("bvi-background-image")}))}},{key:"_getConfig",value:function(e){e=t(t({},y),e);var i={};for(var r in y)i[r]=e[r];return function(e,t,i){Object.keys(t).forEach((function(i){var r,o=t[i],a=e[i],c=a&&(r=a)&&"object"===n(r)&&void 0!==r.nodeType?"element":function(e){return null==e?"".concat(e):{}.toString.call(e).match(/\s([a-z]+)/i)[1].toLowerCase()}(a);if(!new RegExp(o).test(c))throw new TypeError('Bvi console: Опция "'.concat(i,'" предоставленный тип "').concat(c,'", ожидаемый тип "').concat(o,'".'))})),Object.keys(i).forEach((function(t){var n=i[t],r=e[t];if(!new RegExp(n).test(r))throw new TypeError('Bvi console: Опция "'.concat(t,'" параметр "').concat(r,'", ожидаемый параметр "').concat(n,'".'))}))}(i,S,_),i}},{key:"_setAttrDataBviBody",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";document.querySelector(".bvi-body").setAttribute("data-bvi-".concat(e),t)}},{key:"_speechPlayer",value:function(){var e=this,t=document.querySelectorAll(".bvi-speech-text"),n=document.querySelectorAll(".bvi-speech-link"),i=document.querySelectorAll(".bvi-speech");if("speechSynthesis"in window&&l(m("speech"))){if(i){t&&t.forEach((function(e){return u(e)})),n&&n.forEach((function(e){return e.remove()})),i.forEach((function(e,t){var n="bvi-speech-text-id-".concat(t+1);s(e,"div","bvi-speech-text ".concat(n)),e.insertAdjacentHTML("afterbegin",'\n <div class="bvi-speech-link">\n <a href="#" class="bvi-link bvi-speech-play" title="Воспроизвести">Воспроизвести</a>\n <a href="#" class="bvi-link bvi-speech-pause disabled" title="Пауза">Пауза</a>\n <a href="#" class="bvi-link bvi-speech-resume disabled" title="Продолжить">Продолжить</a>\n <a href="#" class="bvi-link bvi-speech-stop disabled" title="Стоп">Стоп</i></a>\n </div>')}));var r=document.querySelectorAll(".bvi-speech-play"),o=document.querySelectorAll(".bvi-speech-pause"),a=document.querySelectorAll(".bvi-speech-resume"),c=document.querySelectorAll(".bvi-speech-stop"),v=function(e,t){e.forEach((function(e){e.addEventListener("click",(function(n){if(n.preventDefault(),"function"==typeof t)return t(e,n)}),!1)}))};v(r,(function(t,n){var i=n.target,r=i.parentNode.nextElementSibling,o=n.target.closest(".bvi-speech-link"),a=document.querySelectorAll(".bvi-speech-play"),c=document.querySelectorAll(".bvi-speech-pause"),l=document.querySelectorAll(".bvi-speech-resume"),s=document.querySelectorAll(".bvi-speech-stop");e._speech(r.textContent,r,!0),a.forEach((function(e){return e.classList.remove("disabled")})),c.forEach((function(e){return e.classList.add("disabled")})),l.forEach((function(e){return e.classList.add("disabled")})),s.forEach((function(e){return e.classList.add("disabled")})),i.classList.add("disabled"),o.querySelector(".bvi-speech-pause").classList.remove("disabled"),o.querySelector(".bvi-speech-stop").classList.remove("disabled")})),v(o,(function(e,t){var n=t.target,i=t.target.closest(".bvi-speech-link");n.classList.add("disabled"),i.querySelector(".bvi-speech-resume").classList.remove("disabled"),h().pause()})),v(a,(function(e,t){var n=t.target,i=t.target.closest(".bvi-speech-link");n.classList.add("disabled"),i.querySelector(".bvi-speech-pause").classList.remove("disabled"),h().resume()})),v(c,(function(e,t){var n=t.target,i=t.target.closest(".bvi-speech-link");n.classList.add("disabled"),i.querySelector(".bvi-speech-pause").classList.add("disabled"),i.querySelector(".bvi-speech-play").classList.remove("disabled"),h().cancel()}))}}else t&&t.forEach((function(e){return u(e)})),n&&n.forEach((function(e){return e.remove()}))}},{key:"_speech",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if("speechSynthesis"in window&&l(m("speech"))){h().cancel();for(var r=function(e,t){e=String(e),t=Number(t)>>>0;var n=e.slice(0,t+1).search(/\S+$/),i=e.slice(t).search(/\s/);return i<0?e.slice(n):e.slice(n,i+t)},o=120,a=new RegExp("^[\\s\\S]{"+Math.floor(o/2)+","+o+"}[.!?,]{1}|^[\\s\\S]{1,"+o+"}$|^[\\s\\S]{1,"+o+"} "),c=[],s=e,u=h().getVoices();s.length>0;)c.push(s.match(a)[0]),s=s.substring(c[c.length-1].length);c.forEach((function(e){var o=new SpeechSynthesisUtterance(e.trim());o.volume=1,o.rate=1,o.pitch=1,o.lang=n._config.lang;for(var a=0;a<u.length;a++)"ru-RU"===n._config.lang&&"Microsoft Pavel - Russian (Russia)"===u[a].name&&(o.voice=u[a]),"en-US"===n._config.lang&&"Microsoft Pavel - English (English)"===u[a].name&&(o.voice=u[a]);i&&(o.onboundary=function(e){t.classList.add("bvi-highlighting");var n=r(e.utterance.text,e.charIndex),i=t.textContent,o=n.replace(/(\s+)/,"((<[^>]+>)*$1(<[^>]+>)*)"),a=new RegExp("("+o+")","gi");i=(i=i.replace(a,"<mark>$1</mark>")).replace(/(<mark>[^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/,"$1</mark>$2<mark>$4"),t.innerHTML=i},o.onend=function(e){t.classList.remove("bvi-highlighting");var n=t.textContent;n=n.replace(/(<mark>$1<\/mark>)/,"$1"),t.innerHTML=n}),h().speak(o)}))}}}]),e}()}}));
//# sourceMappingURL=bvi.min.js.map