1
0
tech-public/biblio.js
2021-11-23 12:48:33 +03:00

1 line
62 KiB
JavaScript

!function(n){var o={};function r(e){if(o[e])return o[e].exports;var t=o[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,r),t.l=!0,t.exports}r.m=n,r.c=o,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=32)}([function(e,t,n){"use strict";var r=n(5),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;e=Object.getPrototypeOf(e);return null===e||e===Object.prototype}function d(e){return"[object Function]"===o.call(e)}function c(e,t){if(null!=e)if(i(e="object"!=typeof e?[e]:e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.call(null,e[r],r,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return e="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:d,isStream:function(e){return a(e)&&d(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:c,merge:function n(){var o={};function e(e,t){u(o[t])&&u(e)?o[t]=n(o[t],e):u(e)?o[t]=n({},e):i(e)?o[t]=e.slice():o[t]=e}for(var t=0,r=arguments.length;t<r;t++)c(arguments[t],e);return o},extend:function(n,e,o){return c(e,function(e,t){n[t]=o&&"function"==typeof e?r(e,o):e}),n},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return e=65279===e.charCodeAt(0)?e.slice(1):e}}},function(r,_,e){!function(n){var o;!function(){"use strict";function e(){this.init()}e.prototype={init:function(){var e=this||g;return e._counter=1e3,e._html5AudioPool=[],e.html5PoolSize=10,e._codecs={},e._howls=[],e._muted=!1,e._volume=1,e._canPlayEvent="canplaythrough",e._navigator="undefined"!=typeof window&&window.navigator?window.navigator:null,e.masterGain=null,e.noAudio=!1,e.usingWebAudio=!0,e.autoSuspend=!0,e.ctx=null,e.autoUnlock=!0,e._setup(),e},volume:function(e){var t=this||g;if(e=parseFloat(e),t.ctx||l(),void 0!==e&&0<=e&&e<=1){if(t._volume=e,t._muted)return t;t.usingWebAudio&&t.masterGain.gain.setValueAtTime(e,g.ctx.currentTime);for(var n=0;n<t._howls.length;n++)if(!t._howls[n]._webAudio)for(var o=t._howls[n]._getSoundIds(),r=0;r<o.length;r++){var i=t._howls[n]._soundById(o[r]);i&&i._node&&(i._node.volume=i._volume*e)}return t}return t._volume},mute:function(e){var t=this||g;t.ctx||l(),t._muted=e,t.usingWebAudio&&t.masterGain.gain.setValueAtTime(e?0:t._volume,g.ctx.currentTime);for(var n=0;n<t._howls.length;n++)if(!t._howls[n]._webAudio)for(var o=t._howls[n]._getSoundIds(),r=0;r<o.length;r++){var i=t._howls[n]._soundById(o[r]);i&&i._node&&(i._node.muted=!!e||i._muted)}return t},stop:function(){for(var e=this||g,t=0;t<e._howls.length;t++)e._howls[t].stop();return e},unload:function(){for(var e=this||g,t=e._howls.length-1;0<=t;t--)e._howls[t].unload();return e.usingWebAudio&&e.ctx&&void 0!==e.ctx.close&&(e.ctx.close(),e.ctx=null,l()),e},codecs:function(e){return(this||g)._codecs[e.replace(/^x-/,"")]},_setup:function(){var t=this||g;if(t.state=t.ctx&&t.ctx.state||"suspended",t._autoSuspend(),!t.usingWebAudio)if("undefined"!=typeof Audio)try{void 0===(new Audio).oncanplaythrough&&(t._canPlayEvent="canplay")}catch(e){t.noAudio=!0}else t.noAudio=!0;try{(new Audio).muted&&(t.noAudio=!0)}catch(e){}return t.noAudio||t._setupCodecs(),t},_setupCodecs:function(){var t=this||g,e=null;try{e="undefined"!=typeof Audio?new Audio:null}catch(e){return t}if(!e||"function"!=typeof e.canPlayType)return t;var n=e.canPlayType("audio/mpeg;").replace(/^no$/,""),o=t._navigator?t._navigator.userAgent:"",r=o.match(/OPR\/([0-6].)/g),i=r&&parseInt(r[0].split("/")[1],10)<33,r=-1!==o.indexOf("Safari")&&-1===o.indexOf("Chrome"),o=o.match(/Version\/(.*?) /),o=r&&o&&parseInt(o[1],10)<15;return t._codecs={mp3:!(i||!n&&!e.canPlayType("audio/mp3;").replace(/^no$/,"")),mpeg:!!n,opus:!!e.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,""),ogg:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),oga:!!e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),wav:!!(e.canPlayType('audio/wav; codecs="1"')||e.canPlayType("audio/wav")).replace(/^no$/,""),aac:!!e.canPlayType("audio/aac;").replace(/^no$/,""),caf:!!e.canPlayType("audio/x-caf;").replace(/^no$/,""),m4a:!!(e.canPlayType("audio/x-m4a;")||e.canPlayType("audio/m4a;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),m4b:!!(e.canPlayType("audio/x-m4b;")||e.canPlayType("audio/m4b;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),mp4:!!(e.canPlayType("audio/x-mp4;")||e.canPlayType("audio/mp4;")||e.canPlayType("audio/aac;")).replace(/^no$/,""),weba:!(o||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),webm:!(o||!e.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")),dolby:!!e.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/,""),flac:!!(e.canPlayType("audio/x-flac;")||e.canPlayType("audio/flac;")).replace(/^no$/,"")},t},_unlockAudio:function(){var a=this||g;if(!a._audioUnlocked&&a.ctx){a._audioUnlocked=!1,a.autoUnlock=!1,a._mobileUnloaded||44100===a.ctx.sampleRate||(a._mobileUnloaded=!0,a.unload()),a._scratchBuffer=a.ctx.createBuffer(1,1,22050);var u=function(e){for(;a._html5AudioPool.length<a.html5PoolSize;)try{var t=new Audio;t._unlocked=!0,a._releaseHtml5Audio(t)}catch(e){a.noAudio=!0;break}for(var n=0;n<a._howls.length;n++)if(!a._howls[n]._webAudio)for(var o=a._howls[n]._getSoundIds(),r=0;r<o.length;r++){var i=a._howls[n]._soundById(o[r]);i&&i._node&&!i._node._unlocked&&(i._node._unlocked=!0,i._node.load())}a._autoResume();var s=a.ctx.createBufferSource();s.buffer=a._scratchBuffer,s.connect(a.ctx.destination),void 0===s.start?s.noteOn(0):s.start(0),"function"==typeof a.ctx.resume&&a.ctx.resume(),s.onended=function(){s.disconnect(0),a._audioUnlocked=!0,document.removeEventListener("touchstart",u,!0),document.removeEventListener("touchend",u,!0),document.removeEventListener("click",u,!0),document.removeEventListener("keydown",u,!0);for(var e=0;e<a._howls.length;e++)a._howls[e]._emit("unlock")}};return document.addEventListener("touchstart",u,!0),document.addEventListener("touchend",u,!0),document.addEventListener("click",u,!0),document.addEventListener("keydown",u,!0),a}},_obtainHtml5Audio:function(){var e=this||g;if(e._html5AudioPool.length)return e._html5AudioPool.pop();e=(new Audio).play();return e&&"undefined"!=typeof Promise&&(e instanceof Promise||"function"==typeof e.then)&&e.catch(function(){console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.")}),new Audio},_releaseHtml5Audio:function(e){var t=this||g;return e._unlocked&&t._html5AudioPool.push(e),t},_autoSuspend:function(){var t=this;if(t.autoSuspend&&t.ctx&&void 0!==t.ctx.suspend&&g.usingWebAudio){for(var e=0;e<t._howls.length;e++)if(t._howls[e]._webAudio)for(var n=0;n<t._howls[e]._sounds.length;n++)if(!t._howls[e]._sounds[n]._paused)return t;return t._suspendTimer&&clearTimeout(t._suspendTimer),t._suspendTimer=setTimeout(function(){var e;t.autoSuspend&&(t._suspendTimer=null,t.state="suspending",e=function(){t.state="suspended",t._resumeAfterSuspend&&(delete t._resumeAfterSuspend,t._autoResume())},t.ctx.suspend().then(e,e))},3e4),t}},_autoResume:function(){var t=this;if(t.ctx&&void 0!==t.ctx.resume&&g.usingWebAudio)return"running"===t.state&&"interrupted"!==t.ctx.state&&t._suspendTimer?(clearTimeout(t._suspendTimer),t._suspendTimer=null):"suspended"===t.state||"running"===t.state&&"interrupted"===t.ctx.state?(t.ctx.resume().then(function(){t.state="running";for(var e=0;e<t._howls.length;e++)t._howls[e]._emit("resume")}),t._suspendTimer&&(clearTimeout(t._suspendTimer),t._suspendTimer=null)):"suspending"===t.state&&(t._resumeAfterSuspend=!0),t}};function t(e){e.src&&0!==e.src.length?this.init(e):console.error("An array of source files must be passed with any new Howl.")}var g=new e;t.prototype={init:function(e){var t=this;return g.ctx||l(),t._autoplay=e.autoplay||!1,t._format="string"!=typeof e.format?e.format:[e.format],t._html5=e.html5||!1,t._muted=e.mute||!1,t._loop=e.loop||!1,t._pool=e.pool||5,t._preload="boolean"!=typeof e.preload&&"metadata"!==e.preload||e.preload,t._rate=e.rate||1,t._sprite=e.sprite||{},t._src="string"!=typeof e.src?e.src:[e.src],t._volume=void 0!==e.volume?e.volume:1,t._xhr={method:e.xhr&&e.xhr.method?e.xhr.method:"GET",headers:e.xhr&&e.xhr.headers?e.xhr.headers:null,withCredentials:!(!e.xhr||!e.xhr.withCredentials)&&e.xhr.withCredentials},t._duration=0,t._state="unloaded",t._sounds=[],t._endTimers={},t._queue=[],t._playLock=!1,t._onend=e.onend?[{fn:e.onend}]:[],t._onfade=e.onfade?[{fn:e.onfade}]:[],t._onload=e.onload?[{fn:e.onload}]:[],t._onloaderror=e.onloaderror?[{fn:e.onloaderror}]:[],t._onplayerror=e.onplayerror?[{fn:e.onplayerror}]:[],t._onpause=e.onpause?[{fn:e.onpause}]:[],t._onplay=e.onplay?[{fn:e.onplay}]:[],t._onstop=e.onstop?[{fn:e.onstop}]:[],t._onmute=e.onmute?[{fn:e.onmute}]:[],t._onvolume=e.onvolume?[{fn:e.onvolume}]:[],t._onrate=e.onrate?[{fn:e.onrate}]:[],t._onseek=e.onseek?[{fn:e.onseek}]:[],t._onunlock=e.onunlock?[{fn:e.onunlock}]:[],t._onresume=[],t._webAudio=g.usingWebAudio&&!t._html5,void 0!==g.ctx&&g.ctx&&g.autoUnlock&&g._unlockAudio(),g._howls.push(t),t._autoplay&&t._queue.push({event:"play",action:function(){t.play()}}),t._preload&&"none"!==t._preload&&t.load(),t},load:function(){var e=this,t=null;if(g.noAudio)e._emit("loaderror",null,"No audio support.");else{"string"==typeof e._src&&(e._src=[e._src]);for(var n,o,r=0;r<e._src.length;r++){if(e._format&&e._format[r])n=e._format[r];else{if("string"!=typeof(o=e._src[r])){e._emit("loaderror",null,"Non-string found in selected audio sources - ignoring.");continue}n=(n=(n=/^data:audio\/([^;,]+);/i.exec(o))||/\.([^.]+)$/.exec(o.split("?",1)[0]))&&n[1].toLowerCase()}if(n||console.warn('No file extension was found. Consider using the "format" property or specify an extension.'),n&&g.codecs(n)){t=e._src[r];break}}if(t)return e._src=t,e._state="loading","https:"===window.location.protocol&&"http:"===t.slice(0,5)&&(e._html5=!0,e._webAudio=!1),new i(e),e._webAudio&&a(e),e;e._emit("loaderror",null,"No codec support for selected audio sources.")}},play:function(t,n){var o=this,e=null;if("number"==typeof t)e=t,t=null;else{if("string"==typeof t&&"loaded"===o._state&&!o._sprite[t])return null;if(void 0===t&&(t="__default",!o._playLock)){for(var r=0,i=0;i<o._sounds.length;i++)o._sounds[i]._paused&&!o._sounds[i]._ended&&(r++,e=o._sounds[i]._id);1===r?t=null:e=null}}var s=e?o._soundById(e):o._inactiveSound();if(!s)return null;if(e&&!t&&(t=s._sprite||"__default"),"loaded"!==o._state){s._sprite=t,s._ended=!1;var a=s._id;return o._queue.push({event:"play",action:function(){o.play(a)}}),a}if(e&&!s._paused)return n||o._loadQueue("play"),s._id;o._webAudio&&g._autoResume();var u=Math.max(0,0<s._seek?s._seek:o._sprite[t][0]/1e3),d=Math.max(0,(o._sprite[t][0]+o._sprite[t][1])/1e3-u),c=1e3*d/Math.abs(s._rate),l=o._sprite[t][0]/1e3,_=(o._sprite[t][0]+o._sprite[t][1])/1e3;s._sprite=t,s._ended=!1;var p=function(){s._paused=!1,s._seek=u,s._start=l,s._stop=_,s._loop=!(!s._loop&&!o._sprite[t][2])};if(!(_<=u)){var f,h,m,v=s._node;return o._webAudio?(h=function(){o._playLock=!1,p(),o._refreshBuffer(s);var e=s._muted||o._muted?0:s._volume;v.gain.setValueAtTime(e,g.ctx.currentTime),s._playStart=g.ctx.currentTime,void 0===v.bufferSource.start?s._loop?v.bufferSource.noteGrainOn(0,u,86400):v.bufferSource.noteGrainOn(0,u,d):s._loop?v.bufferSource.start(0,u,86400):v.bufferSource.start(0,u,d),c!==1/0&&(o._endTimers[s._id]=setTimeout(o._ended.bind(o,s),c)),n||setTimeout(function(){o._emit("play",s._id),o._loadQueue()},0)},"running"===g.state&&"interrupted"!==g.ctx.state?h():(o._playLock=!0,o.once("resume",h),o._clearTimer(s._id))):(f=function(){v.currentTime=u,v.muted=s._muted||o._muted||g._muted||v.muted,v.volume=s._volume*g.volume(),v.playbackRate=s._rate;try{var e=v.play();if(e&&"undefined"!=typeof Promise&&(e instanceof Promise||"function"==typeof e.then)?(o._playLock=!0,p(),e.then(function(){o._playLock=!1,v._unlocked=!0,n?o._loadQueue():o._emit("play",s._id)}).catch(function(){o._playLock=!1,o._emit("playerror",s._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."),s._ended=!0,s._paused=!0})):n||(o._playLock=!1,p(),o._emit("play",s._id)),v.playbackRate=s._rate,v.paused)return void o._emit("playerror",s._id,"Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");"__default"!==t||s._loop?o._endTimers[s._id]=setTimeout(o._ended.bind(o,s),c):(o._endTimers[s._id]=function(){o._ended(s),v.removeEventListener("ended",o._endTimers[s._id],!1)},v.addEventListener("ended",o._endTimers[s._id],!1))}catch(e){o._emit("playerror",s._id,e)}},"data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"===v.src&&(v.src=o._src,v.load()),h=window&&window.ejecta||!v.readyState&&g._navigator.isCocoonJS,3<=v.readyState||h?f():(o._playLock=!0,o._state="loading",m=function(){o._state="loaded",f(),v.removeEventListener(g._canPlayEvent,m,!1)},v.addEventListener(g._canPlayEvent,m,!1),o._clearTimer(s._id))),s._id}o._ended(s)},pause:function(e){var t=this;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"pause",action:function(){t.pause(e)}}),t;for(var n=t._getSoundIds(e),o=0;o<n.length;o++){t._clearTimer(n[o]);var r=t._soundById(n[o]);if(r&&!r._paused&&(r._seek=t.seek(n[o]),r._rateSeek=0,r._paused=!0,t._stopFade(n[o]),r._node))if(t._webAudio){if(!r._node.bufferSource)continue;void 0===r._node.bufferSource.stop?r._node.bufferSource.noteOff(0):r._node.bufferSource.stop(0),t._cleanBuffer(r._node)}else isNaN(r._node.duration)&&r._node.duration!==1/0||r._node.pause();arguments[1]||t._emit("pause",r?r._id:null)}return t},stop:function(e,t){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"stop",action:function(){n.stop(e)}}),n;for(var o=n._getSoundIds(e),r=0;r<o.length;r++){n._clearTimer(o[r]);var i=n._soundById(o[r]);i&&(i._seek=i._start||0,i._rateSeek=0,i._paused=!0,i._ended=!0,n._stopFade(o[r]),i._node&&(n._webAudio?i._node.bufferSource&&(void 0===i._node.bufferSource.stop?i._node.bufferSource.noteOff(0):i._node.bufferSource.stop(0),n._cleanBuffer(i._node)):isNaN(i._node.duration)&&i._node.duration!==1/0||(i._node.currentTime=i._start||0,i._node.pause(),i._node.duration===1/0&&n._clearSound(i._node))),t||n._emit("stop",i._id))}return n},mute:function(e,t){var n=this;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"mute",action:function(){n.mute(e,t)}}),n;if(void 0===t){if("boolean"!=typeof e)return n._muted;n._muted=e}for(var o=n._getSoundIds(t),r=0;r<o.length;r++){var i=n._soundById(o[r]);i&&(i._muted=e,i._interval&&n._stopFade(i._id),n._webAudio&&i._node?i._node.gain.setValueAtTime(e?0:i._volume,g.ctx.currentTime):i._node&&(i._node.muted=!!g._muted||e),n._emit("mute",i._id))}return n},volume:function(){var e,t,n=this,o=arguments;if(0===o.length)return n._volume;if(1===o.length||2===o.length&&void 0===o[1]?0<=n._getSoundIds().indexOf(o[0])?r=parseInt(o[0],10):e=parseFloat(o[0]):2<=o.length&&(e=parseFloat(o[0]),r=parseInt(o[1],10)),!(void 0!==e&&0<=e&&e<=1))return(t=r?n._soundById(r):n._sounds[0])?t._volume:0;if("loaded"!==n._state||n._playLock)return n._queue.push({event:"volume",action:function(){n.volume.apply(n,o)}}),n;void 0===r&&(n._volume=e);for(var r=n._getSoundIds(r),i=0;i<r.length;i++)(t=n._soundById(r[i]))&&(t._volume=e,o[2]||n._stopFade(r[i]),n._webAudio&&t._node&&!t._muted?t._node.gain.setValueAtTime(e,g.ctx.currentTime):t._node&&!t._muted&&(t._node.volume=e*g.volume()),n._emit("volume",t._id));return n},fade:function(e,t,n,o){var r=this;if("loaded"!==r._state||r._playLock)return r._queue.push({event:"fade",action:function(){r.fade(e,t,n,o)}}),r;e=Math.min(Math.max(0,parseFloat(e)),1),t=Math.min(Math.max(0,parseFloat(t)),1),n=parseFloat(n),r.volume(e,o);for(var i=r._getSoundIds(o),s=0;s<i.length;s++){var a,u,d=r._soundById(i[s]);d&&(o||r._stopFade(i[s]),r._webAudio&&!d._muted&&(u=(a=g.ctx.currentTime)+n/1e3,d._volume=e,d._node.gain.setValueAtTime(e,a),d._node.gain.linearRampToValueAtTime(t,u)),r._startFadeInterval(d,e,t,n,i[s],void 0===o))}return r},_startFadeInterval:function(t,n,o,r,e,i){var s=this,a=n,u=o-n,d=Math.abs(u/.01),d=Math.max(4,0<d?r/d:r),c=Date.now();t._fadeTo=o,t._interval=setInterval(function(){var e=(Date.now()-c)/r;c=Date.now(),a+=u*e,a=Math.round(100*a)/100,a=u<0?Math.max(o,a):Math.min(o,a),s._webAudio?t._volume=a:s.volume(a,t._id,!0),i&&(s._volume=a),(o<n&&a<=o||n<o&&o<=a)&&(clearInterval(t._interval),t._interval=null,t._fadeTo=null,s.volume(o,t._id),s._emit("fade",t._id))},d)},_stopFade:function(e){var t=this,n=t._soundById(e);return n&&n._interval&&(t._webAudio&&n._node.gain.cancelScheduledValues(g.ctx.currentTime),clearInterval(n._interval),n._interval=null,t.volume(n._fadeTo,e),n._fadeTo=null,t._emit("fade",e)),t},loop:function(){var e,t,n,o=this,r=arguments;if(0===r.length)return o._loop;if(1===r.length){if("boolean"!=typeof r[0])return!!(n=o._soundById(parseInt(r[0],10)))&&n._loop;o._loop=e=r[0]}else 2===r.length&&(e=r[0],t=parseInt(r[1],10));for(var i=o._getSoundIds(t),s=0;s<i.length;s++)(n=o._soundById(i[s]))&&(n._loop=e,o._webAudio&&n._node&&n._node.bufferSource&&(n._node.bufferSource.loop=e)&&(n._node.bufferSource.loopStart=n._start||0,n._node.bufferSource.loopEnd=n._stop,o.playing(i[s])&&(o.pause(i[s],!0),o.play(i[s],!0))));return o},rate:function(){var e,t=this,n=arguments;if(0===n.length?i=t._sounds[0]._id:1===n.length?0<=t._getSoundIds().indexOf(n[0])?i=parseInt(n[0],10):e=parseFloat(n[0]):2===n.length&&(e=parseFloat(n[0]),i=parseInt(n[1],10)),"number"!=typeof e)return((r=t._soundById(i))||t)._rate;if("loaded"!==t._state||t._playLock)return t._queue.push({event:"rate",action:function(){t.rate.apply(t,n)}}),t;void 0===i&&(t._rate=e);for(var o,r,i=t._getSoundIds(i),s=0;s<i.length;s++)(r=t._soundById(i[s]))&&(t.playing(i[s])&&(r._rateSeek=t.seek(i[s]),r._playStart=t._webAudio?g.ctx.currentTime:r._playStart),r._rate=e,t._webAudio&&r._node&&r._node.bufferSource?r._node.bufferSource.playbackRate.setValueAtTime(e,g.ctx.currentTime):r._node&&(r._node.playbackRate=e),o=t.seek(i[s]),o=1e3*((t._sprite[r._sprite][0]+t._sprite[r._sprite][1])/1e3-o)/Math.abs(r._rate),!t._endTimers[i[s]]&&r._paused||(t._clearTimer(i[s]),t._endTimers[i[s]]=setTimeout(t._ended.bind(t,r),o)),t._emit("rate",r._id));return t},seek:function(){var e,t,n=this,o=arguments;if(0===o.length?n._sounds.length&&(t=n._sounds[0]._id):1===o.length?0<=n._getSoundIds().indexOf(o[0])?t=parseInt(o[0],10):n._sounds.length&&(t=n._sounds[0]._id,e=parseFloat(o[0])):2===o.length&&(e=parseFloat(o[0]),t=parseInt(o[1],10)),void 0===t)return 0;if("number"==typeof e&&("loaded"!==n._state||n._playLock))return n._queue.push({event:"seek",action:function(){n.seek.apply(n,o)}}),n;var r=n._soundById(t);if(r){if(!("number"==typeof e&&0<=e)){if(n._webAudio){var i=n.playing(t)?g.ctx.currentTime-r._playStart:0,s=r._rateSeek?r._rateSeek-r._seek:0;return r._seek+(s+i*Math.abs(r._rate))}return r._node.currentTime}var a=n.playing(t);a&&n.pause(t,!0),r._seek=e,r._ended=!1,n._clearTimer(t),n._webAudio||!r._node||isNaN(r._node.duration)||(r._node.currentTime=e);var u,d=function(){a&&n.play(t,!0),n._emit("seek",t)};a&&!n._webAudio?(u=function(){n._playLock?setTimeout(u,0):d()},setTimeout(u,0)):d()}return n},playing:function(e){if("number"==typeof e){e=this._soundById(e);return!!e&&!e._paused}for(var t=0;t<this._sounds.length;t++)if(!this._sounds[t]._paused)return!0;return!1},duration:function(e){var t=this._duration,e=this._soundById(e);return t=e?this._sprite[e._sprite][1]/1e3:t},state:function(){return this._state},unload:function(){for(var e=this,t=e._sounds,n=0;n<t.length;n++)t[n]._paused||e.stop(t[n]._id),e._webAudio||(e._clearSound(t[n]._node),t[n]._node.removeEventListener("error",t[n]._errorFn,!1),t[n]._node.removeEventListener(g._canPlayEvent,t[n]._loadFn,!1),t[n]._node.removeEventListener("ended",t[n]._endFn,!1),g._releaseHtml5Audio(t[n]._node)),delete t[n]._node,e._clearTimer(t[n]._id);var o=g._howls.indexOf(e);0<=o&&g._howls.splice(o,1);for(var r=!0,n=0;n<g._howls.length;n++)if(g._howls[n]._src===e._src||0<=e._src.indexOf(g._howls[n]._src)){r=!1;break}return s&&r&&delete s[e._src],g.noAudio=!1,e._state="unloaded",e._sounds=[],e=null},on:function(e,t,n,o){e=this["_on"+e];return"function"==typeof t&&e.push(o?{id:n,fn:t,once:o}:{id:n,fn:t}),this},off:function(e,t,n){var o=this,r=o["_on"+e],i=0;if("number"==typeof t&&(n=t,t=null),t||n)for(i=0;i<r.length;i++){var s=n===r[i].id;if(t===r[i].fn&&s||!t&&s){r.splice(i,1);break}}else if(e)o["_on"+e]=[];else for(var a=Object.keys(o),i=0;i<a.length;i++)0===a[i].indexOf("_on")&&Array.isArray(o[a[i]])&&(o[a[i]]=[]);return o},once:function(e,t,n){return this.on(e,t,n,1),this},_emit:function(e,t,n){for(var o=this,r=o["_on"+e],i=r.length-1;0<=i;i--)r[i].id&&r[i].id!==t&&"load"!==e||(setTimeout(function(e){e.call(this,t,n)}.bind(o,r[i].fn),0),r[i].once&&o.off(e,r[i].fn,r[i].id));return o._loadQueue(e),o},_loadQueue:function(e){var t,n=this;return 0<n._queue.length&&((t=n._queue[0]).event===e&&(n._queue.shift(),n._loadQueue()),e||t.action()),n},_ended:function(e){var t=this,n=e._sprite;if(!t._webAudio&&e._node&&!e._node.paused&&!e._node.ended&&e._node.currentTime<e._stop)return setTimeout(t._ended.bind(t,e),100),t;var o=!(!e._loop&&!t._sprite[n][2]);return t._emit("end",e._id),!t._webAudio&&o&&t.stop(e._id,!0).play(e._id),t._webAudio&&o&&(t._emit("play",e._id),e._seek=e._start||0,e._rateSeek=0,e._playStart=g.ctx.currentTime,n=1e3*(e._stop-e._start)/Math.abs(e._rate),t._endTimers[e._id]=setTimeout(t._ended.bind(t,e),n)),t._webAudio&&!o&&(e._paused=!0,e._ended=!0,e._seek=e._start||0,e._rateSeek=0,t._clearTimer(e._id),t._cleanBuffer(e._node),g._autoSuspend()),t._webAudio||o||t.stop(e._id,!0),t},_clearTimer:function(e){var t,n=this;return n._endTimers[e]&&("function"!=typeof n._endTimers[e]?clearTimeout(n._endTimers[e]):(t=n._soundById(e))&&t._node&&t._node.removeEventListener("ended",n._endTimers[e],!1),delete n._endTimers[e]),n},_soundById:function(e){for(var t=0;t<this._sounds.length;t++)if(e===this._sounds[t]._id)return this._sounds[t];return null},_inactiveSound:function(){var e=this;e._drain();for(var t=0;t<e._sounds.length;t++)if(e._sounds[t]._ended)return e._sounds[t].reset();return new i(e)},_drain:function(){var e=this,t=e._pool,n=0,o=0;if(!(e._sounds.length<t)){for(o=0;o<e._sounds.length;o++)e._sounds[o]._ended&&n++;for(o=e._sounds.length-1;0<=o;o--){if(n<=t)return;e._sounds[o]._ended&&(e._webAudio&&e._sounds[o]._node&&e._sounds[o]._node.disconnect(0),e._sounds.splice(o,1),n--)}}},_getSoundIds:function(e){if(void 0!==e)return[e];for(var t=[],n=0;n<this._sounds.length;n++)t.push(this._sounds[n]._id);return t},_refreshBuffer:function(e){return e._node.bufferSource=g.ctx.createBufferSource(),e._node.bufferSource.buffer=s[this._src],e._panner?e._node.bufferSource.connect(e._panner):e._node.bufferSource.connect(e._node),e._node.bufferSource.loop=e._loop,e._loop&&(e._node.bufferSource.loopStart=e._start||0,e._node.bufferSource.loopEnd=e._stop||0),e._node.bufferSource.playbackRate.setValueAtTime(e._rate,g.ctx.currentTime),this},_cleanBuffer:function(e){var t=g._navigator&&0<=g._navigator.vendor.indexOf("Apple");if(g._scratchBuffer&&e.bufferSource&&(e.bufferSource.onended=null,e.bufferSource.disconnect(0),t))try{e.bufferSource.buffer=g._scratchBuffer}catch(e){}return e.bufferSource=null,this},_clearSound:function(e){/MSIE |Trident\//.test(g._navigator&&g._navigator.userAgent)||(e.src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA")}};var i=function(e){this._parent=e,this.init()};i.prototype={init:function(){var e=this,t=e._parent;return e._muted=t._muted,e._loop=t._loop,e._volume=t._volume,e._rate=t._rate,e._seek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++g._counter,t._sounds.push(e),e.create(),e},create:function(){var e=this,t=e._parent,n=g._muted||e._muted||e._parent._muted?0:e._volume;return t._webAudio?(e._node=void 0===g.ctx.createGain?g.ctx.createGainNode():g.ctx.createGain(),e._node.gain.setValueAtTime(n,g.ctx.currentTime),e._node.paused=!0,e._node.connect(g.masterGain)):g.noAudio||(e._node=g._obtainHtml5Audio(),e._errorFn=e._errorListener.bind(e),e._node.addEventListener("error",e._errorFn,!1),e._loadFn=e._loadListener.bind(e),e._node.addEventListener(g._canPlayEvent,e._loadFn,!1),e._endFn=e._endListener.bind(e),e._node.addEventListener("ended",e._endFn,!1),e._node.src=t._src,e._node.preload=!0===t._preload?"auto":t._preload,e._node.volume=n*g.volume(),e._node.load()),e},reset:function(){var e=this,t=e._parent;return e._muted=t._muted,e._loop=t._loop,e._volume=t._volume,e._rate=t._rate,e._seek=0,e._rateSeek=0,e._paused=!0,e._ended=!0,e._sprite="__default",e._id=++g._counter,e},_errorListener:function(){var e=this;e._parent._emit("loaderror",e._id,e._node.error?e._node.error.code:0),e._node.removeEventListener("error",e._errorFn,!1)},_loadListener:function(){var e=this._parent;e._duration=Math.ceil(10*this._node.duration)/10,0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue()),this._node.removeEventListener(g._canPlayEvent,this._loadFn,!1)},_endListener:function(){var e=this,t=e._parent;t._duration===1/0&&(t._duration=Math.ceil(10*e._node.duration)/10,t._sprite.__default[1]===1/0&&(t._sprite.__default[1]=1e3*t._duration),t._ended(e)),e._node.removeEventListener("ended",e._endFn,!1)}};var s={},a=function(t){var e=t._src;if(s[e])return t._duration=s[e].duration,void c(t);if(/^data:[^;]+;base64,/.test(e)){for(var n=atob(e.split(",")[1]),o=new Uint8Array(n.length),r=0;r<n.length;++r)o[r]=n.charCodeAt(r);d(o.buffer,t)}else{var i=new XMLHttpRequest;i.open(t._xhr.method,e,!0),i.withCredentials=t._xhr.withCredentials,i.responseType="arraybuffer",t._xhr.headers&&Object.keys(t._xhr.headers).forEach(function(e){i.setRequestHeader(e,t._xhr.headers[e])}),i.onload=function(){var e=(i.status+"")[0];"0"===e||"2"===e||"3"===e?d(i.response,t):t._emit("loaderror",null,"Failed loading audio file with status: "+i.status+".")},i.onerror=function(){t._webAudio&&(t._html5=!0,t._webAudio=!1,t._sounds=[],delete s[e],t.load())},u(i)}},u=function(t){try{t.send()}catch(e){t.onerror()}},d=function(e,t){function n(){t._emit("loaderror",null,"Decoding audio data failed.")}function o(e){e&&0<t._sounds.length?(s[t._src]=e,c(t,e)):n()}"undefined"!=typeof Promise&&1===g.ctx.decodeAudioData.length?g.ctx.decodeAudioData(e).then(o).catch(n):g.ctx.decodeAudioData(e,o,n)},c=function(e,t){t&&!e._duration&&(e._duration=t.duration),0===Object.keys(e._sprite).length&&(e._sprite={__default:[0,1e3*e._duration]}),"loaded"!==e._state&&(e._state="loaded",e._emit("load"),e._loadQueue())},l=function(){if(g.usingWebAudio){try{"undefined"!=typeof AudioContext?g.ctx=new AudioContext:"undefined"!=typeof webkitAudioContext?g.ctx=new webkitAudioContext:g.usingWebAudio=!1}catch(e){g.usingWebAudio=!1}g.ctx||(g.usingWebAudio=!1);var e=/iP(hone|od|ad)/.test(g._navigator&&g._navigator.platform),t=g._navigator&&g._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/),t=t?parseInt(t[1],10):null;e&&t&&t<9&&(t=/safari/.test(g._navigator&&g._navigator.userAgent.toLowerCase()),g._navigator&&!t&&(g.usingWebAudio=!1)),g.usingWebAudio&&(g.masterGain=void 0===g.ctx.createGain?g.ctx.createGainNode():g.ctx.createGain(),g.masterGain.gain.setValueAtTime(g._muted?0:g._volume,g.ctx.currentTime),g.masterGain.connect(g.ctx.destination)),g._setup()}};void 0===(o=function(){return{Howler:g,Howl:t}}.apply(_,[]))||(r.exports=o),_.Howler=g,_.Howl=t,void 0!==n?(n.HowlerGlobal=e,n.Howler=g,n.Howl=t,n.Sound=i):"undefined"!=typeof window&&(window.HowlerGlobal=e,window.Howler=g,window.Howl=t,window.Sound=i)}(),function(){"use strict";var n,o,r;HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(e){var t=this;if(!t.ctx||!t.ctx.listener)return t;for(var n=t._howls.length-1;0<=n;n--)t._howls[n].stereo(e);return t},HowlerGlobal.prototype.pos=function(e,t,n){var o=this;return o.ctx&&o.ctx.listener?(t="number"!=typeof t?o._pos[1]:t,n="number"!=typeof n?o._pos[2]:n,"number"!=typeof e?o._pos:(o._pos=[e,t,n],void 0!==o.ctx.listener.positionX?(o.ctx.listener.positionX.setTargetAtTime(o._pos[0],Howler.ctx.currentTime,.1),o.ctx.listener.positionY.setTargetAtTime(o._pos[1],Howler.ctx.currentTime,.1),o.ctx.listener.positionZ.setTargetAtTime(o._pos[2],Howler.ctx.currentTime,.1)):o.ctx.listener.setPosition(o._pos[0],o._pos[1],o._pos[2]),o)):o},HowlerGlobal.prototype.orientation=function(e,t,n,o,r,i){var s=this;if(!s.ctx||!s.ctx.listener)return s;var a=s._orientation;return t="number"!=typeof t?a[1]:t,n="number"!=typeof n?a[2]:n,o="number"!=typeof o?a[3]:o,r="number"!=typeof r?a[4]:r,i="number"!=typeof i?a[5]:i,"number"!=typeof e?a:(s._orientation=[e,t,n,o,r,i],void 0!==s.ctx.listener.forwardX?(s.ctx.listener.forwardX.setTargetAtTime(e,Howler.ctx.currentTime,.1),s.ctx.listener.forwardY.setTargetAtTime(t,Howler.ctx.currentTime,.1),s.ctx.listener.forwardZ.setTargetAtTime(n,Howler.ctx.currentTime,.1),s.ctx.listener.upX.setTargetAtTime(o,Howler.ctx.currentTime,.1),s.ctx.listener.upY.setTargetAtTime(r,Howler.ctx.currentTime,.1),s.ctx.listener.upZ.setTargetAtTime(i,Howler.ctx.currentTime,.1)):s.ctx.listener.setOrientation(e,t,n,o,r,i),s)},Howl.prototype.init=(n=Howl.prototype.init,function(e){var t=this;return t._orientation=e.orientation||[1,0,0],t._stereo=e.stereo||null,t._pos=e.pos||null,t._pannerAttr={coneInnerAngle:void 0!==e.coneInnerAngle?e.coneInnerAngle:360,coneOuterAngle:void 0!==e.coneOuterAngle?e.coneOuterAngle:360,coneOuterGain:void 0!==e.coneOuterGain?e.coneOuterGain:0,distanceModel:void 0!==e.distanceModel?e.distanceModel:"inverse",maxDistance:void 0!==e.maxDistance?e.maxDistance:1e4,panningModel:void 0!==e.panningModel?e.panningModel:"HRTF",refDistance:void 0!==e.refDistance?e.refDistance:1,rolloffFactor:void 0!==e.rolloffFactor?e.rolloffFactor:1},t._onstereo=e.onstereo?[{fn:e.onstereo}]:[],t._onpos=e.onpos?[{fn:e.onpos}]:[],t._onorientation=e.onorientation?[{fn:e.onorientation}]:[],n.call(this,e)}),Howl.prototype.stereo=function(e,t){var n=this;if(!n._webAudio)return n;if("loaded"!==n._state)return n._queue.push({event:"stereo",action:function(){n.stereo(e,t)}}),n;var o=void 0===Howler.ctx.createStereoPanner?"spatial":"stereo";if(void 0===t){if("number"!=typeof e)return n._stereo;n._stereo=e,n._pos=[e,0,0]}for(var r=n._getSoundIds(t),i=0;i<r.length;i++){var s=n._soundById(r[i]);if(s){if("number"!=typeof e)return s._stereo;s._stereo=e,s._pos=[e,0,0],s._node&&(s._pannerAttr.panningModel="equalpower",s._panner&&s._panner.pan||d(s,o),"spatial"==o?void 0!==s._panner.positionX?(s._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),s._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),s._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):s._panner.setPosition(e,0,0):s._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),n._emit("stereo",s._id)}}return n},Howl.prototype.pos=function(e,t,n,o){var r=this;if(!r._webAudio)return r;if("loaded"!==r._state)return r._queue.push({event:"pos",action:function(){r.pos(e,t,n,o)}}),r;if(t="number"!=typeof t?0:t,n="number"!=typeof n?-.5:n,void 0===o){if("number"!=typeof e)return r._pos;r._pos=[e,t,n]}for(var i=r._getSoundIds(o),s=0;s<i.length;s++){var a=r._soundById(i[s]);if(a){if("number"!=typeof e)return a._pos;a._pos=[e,t,n],a._node&&(a._panner&&!a._panner.pan||d(a,"spatial"),void 0!==a._panner.positionX?(a._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),a._panner.positionY.setValueAtTime(t,Howler.ctx.currentTime),a._panner.positionZ.setValueAtTime(n,Howler.ctx.currentTime)):a._panner.setPosition(e,t,n)),r._emit("pos",a._id)}}return r},Howl.prototype.orientation=function(e,t,n,o){var r=this;if(!r._webAudio)return r;if("loaded"!==r._state)return r._queue.push({event:"orientation",action:function(){r.orientation(e,t,n,o)}}),r;if(t="number"!=typeof t?r._orientation[1]:t,n="number"!=typeof n?r._orientation[2]:n,void 0===o){if("number"!=typeof e)return r._orientation;r._orientation=[e,t,n]}for(var i=r._getSoundIds(o),s=0;s<i.length;s++){var a=r._soundById(i[s]);if(a){if("number"!=typeof e)return a._orientation;a._orientation=[e,t,n],a._node&&(a._panner||(a._pos||(a._pos=r._pos||[0,0,-.5]),d(a,"spatial")),void 0!==a._panner.orientationX?(a._panner.orientationX.setValueAtTime(e,Howler.ctx.currentTime),a._panner.orientationY.setValueAtTime(t,Howler.ctx.currentTime),a._panner.orientationZ.setValueAtTime(n,Howler.ctx.currentTime)):a._panner.setOrientation(e,t,n)),r._emit("orientation",a._id)}}return r},Howl.prototype.pannerAttr=function(){var e,t,n=this,o=arguments;if(!n._webAudio)return n;if(0===o.length)return n._pannerAttr;if(1===o.length){if("object"!=typeof o[0])return((s=n._soundById(parseInt(o[0],10)))||n)._pannerAttr;e=o[0],void 0===t&&(e.pannerAttr||(e.pannerAttr={coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}),n._pannerAttr={coneInnerAngle:void 0!==e.pannerAttr.coneInnerAngle?e.pannerAttr.coneInnerAngle:n._coneInnerAngle,coneOuterAngle:void 0!==e.pannerAttr.coneOuterAngle?e.pannerAttr.coneOuterAngle:n._coneOuterAngle,coneOuterGain:void 0!==e.pannerAttr.coneOuterGain?e.pannerAttr.coneOuterGain:n._coneOuterGain,distanceModel:void 0!==e.pannerAttr.distanceModel?e.pannerAttr.distanceModel:n._distanceModel,maxDistance:void 0!==e.pannerAttr.maxDistance?e.pannerAttr.maxDistance:n._maxDistance,refDistance:void 0!==e.pannerAttr.refDistance?e.pannerAttr.refDistance:n._refDistance,rolloffFactor:void 0!==e.pannerAttr.rolloffFactor?e.pannerAttr.rolloffFactor:n._rolloffFactor,panningModel:void 0!==e.pannerAttr.panningModel?e.pannerAttr.panningModel:n._panningModel})}else 2===o.length&&(e=o[0],t=parseInt(o[1],10));for(var r,i,s,a=n._getSoundIds(t),u=0;u<a.length;u++)(s=n._soundById(a[u]))&&(r=s._pannerAttr,r={coneInnerAngle:(void 0!==e.coneInnerAngle?e:r).coneInnerAngle,coneOuterAngle:(void 0!==e.coneOuterAngle?e:r).coneOuterAngle,coneOuterGain:(void 0!==e.coneOuterGain?e:r).coneOuterGain,distanceModel:(void 0!==e.distanceModel?e:r).distanceModel,maxDistance:(void 0!==e.maxDistance?e:r).maxDistance,refDistance:(void 0!==e.refDistance?e:r).refDistance,rolloffFactor:(void 0!==e.rolloffFactor?e:r).rolloffFactor,panningModel:(void 0!==e.panningModel?e:r).panningModel},(i=s._panner)?(i.coneInnerAngle=r.coneInnerAngle,i.coneOuterAngle=r.coneOuterAngle,i.coneOuterGain=r.coneOuterGain,i.distanceModel=r.distanceModel,i.maxDistance=r.maxDistance,i.refDistance=r.refDistance,i.rolloffFactor=r.rolloffFactor,i.panningModel=r.panningModel):(s._pos||(s._pos=n._pos||[0,0,-.5]),d(s,"spatial")));return n},Sound.prototype.init=(o=Sound.prototype.init,function(){var e=this,t=e._parent;e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,o.call(this),e._stereo?t.stereo(e._stereo):e._pos&&t.pos(e._pos[0],e._pos[1],e._pos[2],e._id)}),Sound.prototype.reset=(r=Sound.prototype.reset,function(){var e=this,t=e._parent;return e._orientation=t._orientation,e._stereo=t._stereo,e._pos=t._pos,e._pannerAttr=t._pannerAttr,e._stereo?t.stereo(e._stereo):e._pos?t.pos(e._pos[0],e._pos[1],e._pos[2],e._id):e._panner&&(e._panner.disconnect(0),e._panner=void 0,t._refreshBuffer(e)),r.call(this)});var d=function(e,t){"spatial"===(t=t||"spatial")?(e._panner=Howler.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,void 0!==e._panner.positionX?(e._panner.positionX.setValueAtTime(e._pos[0],Howler.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],Howler.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],Howler.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),void 0!==e._panner.orientationX?(e._panner.orientationX.setValueAtTime(e._orientation[0],Howler.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],Howler.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],Howler.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=Howler.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,Howler.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}}()}.call(this,e(13))},function(e,t,n){e.exports=n(14)},function(u,e,d){"use strict";!function(e){var o=d(0),n=d(20),r=d(7),t={"Content-Type":"application/x-www-form-urlencoded"};function i(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,a={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:s="undefined"!=typeof XMLHttpRequest||void 0!==e&&"[object process]"===Object.prototype.toString.call(e)?d(8):s,transformRequest:[function(e,t){return n(t,"Accept"),n(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(i(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)||t&&"application/json"===t["Content-Type"]?(i(t,"application/json"),function(e,t,n){if(o.isString(e))try{return(t||JSON.parse)(e),o.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||a.transitional,n=t&&t.silentJSONParsing,t=t&&t.forcedJSONParsing,n=!n&&"json"===this.responseType;if(n||t&&o.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw r(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return 200<=e&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};o.forEach(["delete","get","head"],function(e){a.headers[e]={}}),o.forEach(["post","put","patch"],function(e){a.headers[e]=o.merge(t)}),u.exports=a}.call(this,d(19))},function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,e.exports=o},function(e,t,n){"use strict";e.exports=function(n,o){return function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];return n.apply(o,e)}}},function(e,t,n){"use strict";var r=n(0);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var o,n=n?n(t):r.isURLSearchParams(t)?t.toString():(o=[],r.forEach(t,function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),o.push(i(t)+"="+i(e))}))}),o.join("&"));return n&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+n),e}},function(e,t,n){"use strict";e.exports=function(e,t,n,o,r){return e.config=t,n&&(e.code=n),e.request=o,e.response=r,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},function(e,t,n){"use strict";var _=n(0),p=n(21),f=n(22),h=n(6),m=n(23),v=n(26),g=n(27),y=n(9),b=n(3),w=n(4);e.exports=function(l){return new Promise(function(t,n){var e,o=l.data,r=l.headers,i=l.responseType;function s(){l.cancelToken&&l.cancelToken.unsubscribe(e),l.signal&&l.signal.removeEventListener("abort",e)}_.isFormData(o)&&delete r["Content-Type"];var a,u=new XMLHttpRequest;l.auth&&(a=l.auth.username||"",d=l.auth.password?unescape(encodeURIComponent(l.auth.password)):"",r.Authorization="Basic "+btoa(a+":"+d));var d=m(l.baseURL,l.url);function c(){var e;u&&(e="getAllResponseHeaders"in u?v(u.getAllResponseHeaders()):null,e={data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:e,config:l,request:u},p(function(e){t(e),s()},function(e){n(e),s()},e),u=null)}u.open(l.method.toUpperCase(),h(d,l.params,l.paramsSerializer),!0),u.timeout=l.timeout,"onloadend"in u?u.onloadend=c:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(c)},u.onabort=function(){u&&(n(y("Request aborted",l,"ECONNABORTED",u)),u=null)},u.onerror=function(){n(y("Network Error",l,null,u)),u=null},u.ontimeout=function(){var e=l.timeout?"timeout of "+l.timeout+"ms exceeded":"timeout exceeded",t=l.transitional||b.transitional;l.timeoutErrorMessage&&(e=l.timeoutErrorMessage),n(y(e,l,t.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},!_.isStandardBrowserEnv()||(d=(l.withCredentials||g(d))&&l.xsrfCookieName?f.read(l.xsrfCookieName):void 0)&&(r[l.xsrfHeaderName]=d),"setRequestHeader"in u&&_.forEach(r,function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete r[t]:u.setRequestHeader(t,e)}),_.isUndefined(l.withCredentials)||(u.withCredentials=!!l.withCredentials),i&&"json"!==i&&(u.responseType=l.responseType),"function"==typeof l.onDownloadProgress&&u.addEventListener("progress",l.onDownloadProgress),"function"==typeof l.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",l.onUploadProgress),(l.cancelToken||l.signal)&&(e=function(e){u&&(n(!e||e.type?new w("canceled"):e),u.abort(),u=null)},l.cancelToken&&l.cancelToken.subscribe(e),l.signal&&(l.signal.aborted?e():l.signal.addEventListener("abort",e))),o=o||null,u.send(o)})}},function(e,t,n){"use strict";var i=n(7);e.exports=function(e,t,n,o,r){e=new Error(e);return i(e,t,n,o,r)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var d=n(0);e.exports=function(t,n){n=n||{};var o={};function r(e,t){return d.isPlainObject(e)&&d.isPlainObject(t)?d.merge(e,t):d.isPlainObject(t)?d.merge({},t):d.isArray(t)?t.slice():t}function i(e){return d.isUndefined(n[e])?d.isUndefined(t[e])?void 0:r(void 0,t[e]):r(t[e],n[e])}function e(e){if(!d.isUndefined(n[e]))return r(void 0,n[e])}function s(e){return d.isUndefined(n[e])?d.isUndefined(t[e])?void 0:r(void 0,t[e]):r(void 0,n[e])}function a(e){return e in n?r(t[e],n[e]):e in t?r(void 0,t[e]):void 0}var u={url:e,method:e,data:e,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return d.forEach(Object.keys(t).concat(Object.keys(n)),function(e){var t=u[e]||i,n=t(e);d.isUndefined(n)&&t!==a||(o[e]=n)}),o}},function(e,t){e.exports={version:"0.23.0"}},function(e,t){var n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";var r=n(0),i=n(5),s=n(15),a=n(11);var o=function t(n){var e=new s(n),o=i(s.prototype.request,e);return r.extend(o,s.prototype,e),r.extend(o,e),o.create=function(e){return t(a(n,e))},o}(n(3));o.Axios=s,o.Cancel=n(4),o.CancelToken=n(29),o.isCancel=n(10),o.VERSION=n(12).version,o.all=function(e){return Promise.all(e)},o.spread=n(30),o.isAxiosError=n(31),e.exports=o,e.exports.default=o},function(e,t,n){"use strict";var o=n(0),r=n(6),i=n(16),c=n(17),l=n(11),_=n(28),p=_.validators;function s(e){this.defaults=e,this.interceptors={request:new i,response:new i}}s.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=l(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&_.assertOptions(e,{silentJSONParsing:p.transitional(p.boolean),forcedJSONParsing:p.transitional(p.boolean),clarifyTimeoutError:p.transitional(p.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,n.unshift(e.fulfilled,e.rejected))});var r,i=[];if(this.interceptors.response.forEach(function(e){i.push(e.fulfilled,e.rejected)}),!o){var s=[c,void 0];for(Array.prototype.unshift.apply(s,n),s=s.concat(i),r=Promise.resolve(t);s.length;)r=r.then(s.shift(),s.shift());return r}for(var a=t;n.length;){var u=n.shift(),d=n.shift();try{a=u(a)}catch(e){d(e);break}}try{r=c(a)}catch(e){return Promise.reject(e)}for(;i.length;)r=r.then(i.shift(),i.shift());return r},s.prototype.getUri=function(e){return e=l(this.defaults,e),r(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(n){s.prototype[n]=function(e,t){return this.request(l(t||{},{method:n,url:e,data:(t||{}).data}))}}),o.forEach(["post","put","patch"],function(o){s.prototype[o]=function(e,t,n){return this.request(l(n||{},{method:o,url:e,data:t}))}}),e.exports=s},function(e,t,n){"use strict";var o=n(0);function r(){this.handlers=[]}r.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(t){o.forEach(this.handlers,function(e){null!==e&&t(e)})},e.exports=r},function(e,t,n){"use strict";var o=n(0),r=n(18),i=n(10),s=n(3),a=n(4);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a("canceled")}e.exports=function(t){return u(t),t.headers=t.headers||{},t.data=r.call(t,t.data,t.headers,t.transformRequest),t.headers=o.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),o.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||s.adapter)(t).then(function(e){return u(t),e.data=r.call(t,e.data,e.headers,t.transformResponse),e},function(e){return i(e)||(u(t),e&&e.response&&(e.response.data=r.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}},function(e,t,n){"use strict";var r=n(0),i=n(3);e.exports=function(t,n,e){var o=this||i;return r.forEach(e,function(e){t=e.call(o,t,n)}),t}},function(e,t){var n,o,e=e.exports={};function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===r||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:r}catch(e){n=r}try{o="function"==typeof clearTimeout?clearTimeout:i}catch(e){o=i}}();var a,u=[],d=!1,c=-1;function l(){d&&a&&(d=!1,a.length?u=a.concat(u):c=-1,u.length&&_())}function _(){if(!d){var e=s(l);d=!0;for(var t=u.length;t;){for(a=u,u=[];++c<t;)a&&a[c].run();c=-1,t=u.length}a=null,d=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===i||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}e.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new p(e,t)),1!==u.length||d||s(_)},p.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=f,e.addListener=f,e.once=f,e.off=f,e.removeListener=f,e.removeAllListeners=f,e.emit=f,e.prependListener=f,e.prependOnceListener=f,e.listeners=function(e){return[]},e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")},e.umask=function(){return 0}},function(e,t,n){"use strict";var r=n(0);e.exports=function(n,o){r.forEach(n,function(e,t){t!==o&&t.toUpperCase()===o.toUpperCase()&&(n[o]=e,delete n[t])})}},function(e,t,n){"use strict";var r=n(9);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var a=n(0);e.exports=a.isStandardBrowserEnv()?{write:function(e,t,n,o,r,i){var s=[];s.push(e+"="+encodeURIComponent(t)),a.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),a.isString(o)&&s.push("path="+o),a.isString(r)&&s.push("domain="+r),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){e=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var o=n(24),r=n(25);e.exports=function(e,t){return e&&!o(t)?r(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(0),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,o={};return e&&r.forEach(e.split("\n"),function(e){n=e.indexOf(":"),t=r.trim(e.substr(0,n)).toLowerCase(),n=r.trim(e.substr(n+1)),t&&(o[t]&&0<=i.indexOf(t)||(o[t]="set-cookie"===t?(o[t]||[]).concat([n]):o[t]?o[t]+", "+n:n))}),o}},function(e,t,n){"use strict";var o,r,i,s=n(0);function a(e){return r&&(i.setAttribute("href",e),e=i.href),i.setAttribute("href",e),{href:i.href,protocol:i.protocol?i.protocol.replace(/:$/,""):"",host:i.host,search:i.search?i.search.replace(/^\?/,""):"",hash:i.hash?i.hash.replace(/^#/,""):"",hostname:i.hostname,port:i.port,pathname:"/"===i.pathname.charAt(0)?i.pathname:"/"+i.pathname}}e.exports=s.isStandardBrowserEnv()?(r=/(msie|trident)/i.test(navigator.userAgent),i=document.createElement("a"),o=a(window.location.href),function(e){e=s.isString(e)?a(e):e;return e.protocol===o.protocol&&e.host===o.host}):function(){return!0}},function(e,t,n){"use strict";var s=n(12).version,o={};["object","boolean","number","function","string","symbol"].forEach(function(t,n){o[t]=function(e){return typeof e===t||"a"+(n<1?"n ":" ")+t}});var a={};o.transitional=function(o,r,n){function i(e,t){return"[Axios v"+s+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(e,t,n){if(!1===o)throw new Error(i(t," has been removed"+(r?" in "+r:"")));return r&&!a[t]&&(a[t]=!0,console.warn(i(t," has been deprecated since v"+r+" and will be removed in the near future"))),!o||o(e,t,n)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var o=Object.keys(e),r=o.length;0<r--;){var i=o[r],s=t[i];if(s){var a=e[i],a=void 0===a||s(a,i,e);if(!0!==a)throw new TypeError("option "+i+" must be "+a)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:o}},function(e,t,n){"use strict";var r=n(4);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var o=this;this.promise.then(function(e){if(o._listeners){for(var t=o._listeners.length,n=0;n<t;n++)o._listeners[n](e);o._listeners=null}}),this.promise.then=function(e){var t,e=new Promise(function(e){o.subscribe(e),t=e}).then(e);return e.cancel=function(){o.unsubscribe(t)},e},e(function(e){o.reason||(o.reason=new r(e),t(o.reason))})}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){!this._listeners||-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)},o.source=function(){var t;return{token:new o(function(e){t=e}),cancel:t}},e.exports=o},function(e,t,n){"use strict";e.exports=function(t){return function(e){return t.apply(null,e)}}},function(e,t,n){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},function(e,t,n){"use strict";n.r(t),n.d(t,"Biblio",function(){return s});var o=n(1),t=n(2),r=n.n(t);class i{constructor(e,t){this._userKey=t,r.a.defaults.baseURL="https://api.bibliovk.ru/api/ref/",r.a.defaults.headers={"X-Biblio-Auth":"Bearer "+e,"X-Biblio-User":t||"","X-Biblio-Referer":window.location.href}}getBook(e){if(e)return this._get("book/"+(this._userKey?"":"guest/")+e)}getUser(){if(this._userKey)return this._get("me")}getUserBilling(){if(this._userKey)return this._get("me/billing")}getBookPurchaseLink(e){if(e)return this._get(`https://pay.bibliovk.ru/book/${e}/purchase`)}getTrackAudio(e,t=!1){if(e)return this._get(`/track/${e}/play/mp3/medium?reserve=`+(t?1:0))}getBookAudio(e,t=!1){if(e)return this._get(`/book/${e}/full/medium?reserve=`+(t?1:0))}saveUserBookPosition(e,t,n){if(e&&t&&n)return r.a.put("me/savedPosition",{book_id:e,track_id:t,position:n})}saveUserBookListeningTime(e,t){if(this._userKey&&e&&!(t<=0))return r.a.post("system/listen-time/collect",{data:{book_id:e,time:t,timestamp:Math.round(Date.now()/1e3)}})}_get(e){return r.a.get(e,{data:{}}).then(e=>e.data).catch(e=>Promise.reject(e))}}class s{constructor(e){this._defaultFields(),this._bookId=e.book_id,this._referalKey=e.referal_key,this._userKey=e.user_key,this._init()}_defaultFields(){this._audio=null,this._state="none",this._currentTrackId=0,this._currentTrack=null,this._sleepTimerId=0,this._isInit=!1,this._bookId=0,this._referalKey=null,this._userKey=null,this._api=null,this._user=null,this._userBilling=null,this._book=null,this._isSample=null,this._audio=null,this._audioProgressIntervalId=0,this._savePositionIntervalId=0,this._listeningTimeIntervalId=0,this._listeningTime=0,this._rate=1,this._on={init:[],progress:[],play:[],pause:[],rate:[],ended:[],volume:[]},this.EVENT_INIT="init",this.EVENT_WIDGET="init",this.EVENT_PROGRESS="progress",this.EVENT_PLAY="play",this.EVENT_PAUSE="pause",this.EVENT_RATE="rate",this.EVENT_PLAYBACKRATE_CHANGE="rate",this.EVENT_ENDED="ended",this.EVENT_VOLUME="volume",this.EVENT_STOP="stop",this.EVENT_CRASHED="crashed",this.EVENT_ERROR="error",this.EVENT_STATE="state"}async _init(){return this._api=new i(this._referalKey,this._userKey),this._user=await this._api.getUser(),this._userBilling=await this._api.getUserBilling(),this._book=await this._api.getBook(this._bookId),this._isSample=this._bookIsSample(),this._book.saved_position?this._currentTrackId=this._book.saved_position.track_id:this._currentTrackId=this._book.tracks[0].id,this._currentTrack=this._getTrack(),this._isSample&&await this._setupAudioSrc(this._book.audio_sample),this._isInit=!0,this._setState("idle"),this._emit("init",this),this}on(e,t){e=(e=e.replace("bbl-","")).replace(/-/g,"_"),this._on[e="stop"===(e="playback_change"===(e="widget_init"===e?"init":e)?"rate":e)?"pause":e]&&"function"==typeof t&&this._on[e].push(t)}getPlayerState(){return this._state}getPlaybackRate(){return this._audio?this._audio.rate():1}getPosition(){let e=0;var t;return this._isSample?e=this._audio?this._audio.seek():0:this._audio?(e=this._audio.seek(),this._book.concat_created&&(t=this._book.tracks.filter(e=>e.number<this._currentTrack.number).reduce((e,t)=>e+t.duration,0),e-=t)):this._book.saved_position&&(e=this._book.saved_position.position),Math.round(e)}getCurrentTrack(){return this._currentTrackId}getDuration(){if(this._isSample)return Math.round(this._audio.duration());let t=this._currentTrack;if(!t){let e=this._book.tracks[0].id;this._book.saved_position&&(e=this._book.saved_position.track_id),t=this._getTrack(e)}return t.duration}getBookMeta(){return Object.assign({genres:this._book.genres_ids,copyright_holder:this._book.meta_data.copyright_holder},this._book)}getTracksMeta(){return!!this._book&&this._book.tracks}getVolume(){return o.Howler.volume()}getBookPurchaseIsNeed(){return this._isSample}getAmount(){return!!this._book&&this._book.amount}isWidgetInit(){return this._isInit}isForSubscribers(){return!!this._book&&this._book.for_subscribers}isSleepTimerActive(){return!!this._sleepTimerId}pause(){this._audio.pause()}stop(){this.pause()}play(t){if(this._isInit){let e=0;if(this._isSample)this._audio?this._audio.playing()||this._audio.play():(this._setupAudioSrc(this._book.audio_sample),this._audio.play());else{if(t){if(t===this._currentTrackId&&this._audio&&!this._audio.playing())return void this._audio.play()}else{if(this._audio)return void(this._audio.playing()||this._audio.play());this._book.saved_position?(t=this._book.saved_position.track_id,e=this._book.saved_position.position):t=this._book.tracks[0].id}var n=this._getTrack(t);n&&(this._currentTrackId=t,this._currentTrack=n,this._book.concat_created?(e=this._book.tracks.filter(e=>e.number<this._currentTrack.number).reduce((e,t)=>e+t.duration,e),this._audio?(this._audio.seek(e),this._audio.playing()||this._audio.play()):this._setupAudio(null,e).then(()=>{this._audio.play()})):this._setupAudio(t,e).then(()=>{this._audio.play()}))}}}seek(e){if(!e&&!this._audio)return!1;this._audio.seek(e)}ff(){if(!this._audio)return!1;var e=this._audio.seek()+15;this._audio.seek(e)}rw(){if(!this._audio)return!1;let e=this._audio.seek()-15;e<0&&(e=0),this._book.concat_created&&this.getPosition()-15<0&&(e=this._audio.seek()-this.getPosition()),this._audio.seek(e)}destroy(){o.Howler.unload(),this.stopSleepTimer(),this._defaultFields()}stopSleepTimer(){clearTimeout(this._sleepTimerId),this._sleepTimerId=0}startPurchaseBook(){this._userKey&&this._isSample&&this._bookId&&this._api.getBookPurchaseLink(this._bookId).then(e=>{e.redirect_to&&(window.location.href=e.redirect_to)})}startPurchaseSubscription(e="biblio.month"){if(!this._userKey)return!1;e=[this._userKey,this._referalKey,window.location.href,e].join("||"),e=btoa(unescape(encodeURIComponent(e)));window.location.href="https://pay.bibliovk.ru/subscribe?data="+e}setSleepTimer(e,t){this._sleepTimerId=setTimeout(()=>{this._audio.pause(0),this._sleepTimerId=0},60*e*60*1e3+60*t*1e3)}setPlaybackRate(e){if(!this._audio)return!1;this._rate=e,this._audio.rate(e)}setVolume(e){o.Howler.volume(e)}_emit(e,t){this._on[e].forEach(e=>e(t))}_setProgressIntervalId(){this._audioProgressIntervalId=setInterval(()=>{this._audio&&this._audio.playing()?(this._listeningTime++,this._emit("progress",{position:this.getPosition(),duration:this.getDuration()}),this.getDuration()<=this.getPosition()&&this._book.concat_created&&this._currentTrack.next_id&&(this._currentTrackId=this._currentTrack.next_id,this._currentTrack=this._getTrack(),this._emit("ended"),this._emit("play"))):(clearInterval(this._audioProgressIntervalId),this._audioProgressIntervalId=0)},1e3)}_setSavePositionIntervalId(){this._savePositionIntervalId=setInterval(()=>{this._audio&&this._audio.playing()?this._saveUserBookPosition():(clearInterval(this._savePositionIntervalId),this._savePositionIntervalId=0)},5e3)}_setListeningTimeIntervalId(){this._listeningTimeIntervalId=setInterval(()=>{this._audio&&this._audio.playing()&&0<this._listeningTime?this._saveUserBookListeningTime():(clearInterval(this._listeningTimeIntervalId),this._listeningTimeIntervalId=0),this._listeningTime=0},6e4)}_setState(e){this._state=e}_getTrack(t){return t=t||this._currentTrackId,this._book.tracks.find(e=>e.id===t)}_bookIsSample(){if(!this._user)return!0;let e=!1;return(0<this._book.amount||this._book.for_subscribers)&&(e=!0,this._user.purchased_books.includes(this._book.id)&&(e=!1),this._book.for_subscribers&&"free"!==this._userBilling.name&&(e=!1)),e}_saveUserBookListeningTime(){this._isSample||(this._api.saveUserBookListeningTime(this._bookId,this._listeningTime),this._listeningTime=0)}_saveUserBookPosition(){this._isSample||this._api.saveUserBookPosition(this._bookId,this._currentTrackId,this.getPosition())}_setupAudioSrc(t){return new Promise(e=>{o.Howler.unload(),this._setState("idle"),this._audio=new o.Howl({src:t,html5:!0,rate:this._rate,onplay:()=>{this._setState("playing"),this._setProgressIntervalId(),this._setSavePositionIntervalId(),this._setListeningTimeIntervalId(),this._emit("play")},onpause:()=>{this._saveUserBookPosition(),this._saveUserBookListeningTime(),this._setState("paused"),this._emit("pause")},onend:()=>{this._saveUserBookPosition(),this._saveUserBookListeningTime(),!this._book.concat_created&&this._currentTrack.next_id&&this.play(this._currentTrack.next_id),this._setState("idle"),this._emit("ended")},onload:()=>{e(this._audio)},onrate:()=>this._emit("rate"),onvolume:()=>this._emit("volume")})})}_setupAudio(o,r=0){return new Promise(async e=>{let t,n;n=this._book.concat_created?(t=await this._api.getBookAudio(this._bookId),await this._api.getBookAudio(this._bookId,!0)):(t=await this._api.getTrackAudio(o),await this._api.getTrackAudio(o,!0)),this._setupAudioSrc(t.download_url),this._audio.once("loaderror",()=>{this._setupAudioSrc(n.download_url),this._audio.once("load",()=>{this._audio.seek(r),e()})}).once("load",()=>{this._audio.seek(r),e()})})}}window.Biblio=s}]);