/* Highcharts JS v7.0.3 (2019-02-06) Sonification module (c) 2012-2019 ystein Moseng License: www.highcharts.com/license */ (function(l){"object"===typeof module&&module.exports?(l["default"]=l,module.exports=l):"function"===typeof define&&define.amd?define(function(){return l}):l("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(l){var t=function(c){function f(c){this.init(c)}var g={type:"oscillator",playCallbackInterval:20,oscillator:{waveformShape:"sine"}};f.prototype.init=function(b){this.initAudioContext()?(this.options=c.merge(g,b),this.id=this.options.id=b&&b.id||c.uniqueKey(),b=c.audioContext,this.gainNode= b.createGain(),this.setGain(0),(this.panNode=b.createStereoPanner&&b.createStereoPanner())?(this.setPan(0),this.gainNode.connect(this.panNode),this.panNode.connect(b.destination)):this.gainNode.connect(b.destination),"oscillator"===this.options.type&&this.initOscillator(this.options.oscillator),this.playCallbackTimers=[]):c.error(29)};f.prototype.copy=function(b){return new f(c.merge(this.options,{id:null},b))};f.prototype.initAudioContext=function(){var b=c.win.AudioContext||c.win.webkitAudioContext, d=!!c.audioContext;return b?(c.audioContext=c.audioContext||new b,!d&&c.audioContext&&"running"===c.audioContext.state&&c.audioContext.suspend(),!!(c.audioContext&&c.audioContext.createOscillator&&c.audioContext.createGain)):!1};f.prototype.initOscillator=function(b){this.oscillator=c.audioContext.createOscillator();this.oscillator.type=b.waveformShape;this.oscillator.connect(this.gainNode);this.oscillatorStarted=!1};f.prototype.setPan=function(b){this.panNode&&this.panNode.pan.setValueAtTime(b,c.audioContext.currentTime)}; f.prototype.setGain=function(b,d){this.gainNode&&(1.2f?d:a},Infinity):b};f.prototype.clearPlayCallbackTimers=function(){this.playCallbackTimers.forEach(function(c){clearInterval(c)});this.playCallbackTimers=[]};f.prototype.setFrequency=function(c,d){d=d||{};c=this.getValidFrequency(c,d.min,d.max);"oscillator"===this.options.type&&this.oscillatorPlay(c)};f.prototype.oscillatorPlay= function(b){this.oscillatorStarted||(this.oscillator.start(),this.oscillatorStarted=!0);this.oscillator.frequency.setValueAtTime(b,c.audioContext.currentTime)};f.prototype.preparePlay=function(){this.setGain(.001);"suspended"===c.audioContext.state&&c.audioContext.resume();this.oscillator&&!this.oscillatorStarted&&(this.oscillator.start(),this.oscillatorStarted=!0)};f.prototype.play=function(b){var d=this,a=b.duration||0,e=function(a,c,e){var g=b.duration,f=0,q=d.options.playCallbackInterval;if("function"=== typeof a){var n=setInterval(function(){f++;var b=f*q/g;if(1<=b)d[c](a(1),e),clearInterval(n);else d[c](a(b),e)},q);d.playCallbackTimers.push(n)}else d[c](a,e)};if(d.id)if("suspended"===c.audioContext.state||this.oscillator&&!this.oscillatorStarted)d.preparePlay(),setTimeout(function(){d.play(b)},10);else{d.playCallbackTimers.length&&d.clearPlayCallbackTimers();d.cancelGainRamp();d.stopOscillatorTimeout&&(clearTimeout(d.stopOscillatorTimeout),delete d.stopOscillatorTimeout);d.stopTimeout&&(clearTimeout(d.stopTimeout), delete d.stopTimeout,d.stopCallback&&(d._play=d.play,d.play=function(){},d.stopCallback("cancelled"),d.play=d._play));var g=a=b.max||f.push(new c.sonification.TimelineEvent({time:b.max})); f.length&&a.addTimelineEvents(f)})}function v(a){return a.reduce(function(a,b){return a+c.splat(b).reduce(function(a,c){return(c=c.series&&c.seriesOptions&&c.seriesOptions.timeExtremes)?Math.max(a,c.max-c.min):a},0)},0)}function r(a,b){var d=Math.max(b-u(a),0),e=v(a);return a.reduce(function(a,b){b=c.splat(b).reduce(function(a,b){b instanceof c.sonification.TimelinePath?a.push(b):b.series&&(b.seriesOptions.duration=b.seriesOptions.duration||f.virtualAxisTranslate(b.seriesOptions.timeExtremes.max- b.seriesOptions.timeExtremes.min,{min:0,max:e},{min:0,max:d}),a.push(h(b.series,b.seriesOptions)));return a},[]);a.push(b);return a},[])}return{chartSonify:function(a){this.sonification.timeline&&this.sonification.timeline.pause();var b=d(this,a.instruments,a.dataExtremes),e=q(a.order,this,function(c){return p(c,b,a)}),e=l(e,a.afterSeriesWait||0),e=r(e,a.duration);e.forEach(function(a){k(a)});this.sonification.timeline=new c.sonification.Timeline({paths:e,onEnd:a.onEnd});this.sonification.timeline.play()}, seriesSonify:function(a){a=h(this,a);var b=this.chart.sonification;b.timeline&&b.timeline.pause();b.timeline=new c.sonification.Timeline({paths:[a]});b.timeline.play()},pause:function(a){this.sonification.timeline?this.sonification.timeline.pause(c.pick(a,!0)):this.sonification.currentlyPlayingPoint&&this.sonification.currentlyPlayingPoint.cancelSonify(a)},resume:function(a){this.sonification.timeline&&this.sonification.timeline.play(a)},rewind:function(a){this.sonification.timeline&&this.sonification.timeline.rewind(a)}, cancel:function(a){this.pauseSonify(a);this.resetSonifyCursor()},getCurrentPoints:function(){var a;return this.sonification.timeline?(a=this.sonification.timeline.getCursor(),Object.keys(a).map(function(b){return a[b].eventObject}).filter(function(a){return a instanceof c.Point})):[]},setCursor:function(a){var b=this.sonification.timeline;b&&c.splat(a).forEach(function(a){b.setCursor(a.id)})},resetCursor:function(){this.sonification.timeline&&this.sonification.timeline.resetCursor()},resetCursorEnd:function(){this.sonification.timeline&& this.sonification.timeline.resetCursorEnd()}}}(l,r),B=function(c,f){function g(a){this.init(a||{})}function b(a){this.init(a)}function d(a){this.init(a||{})}g.prototype.init=function(a){this.options=a;this.time=a.time||0;this.id=this.options.id=a.id||c.uniqueKey()};g.prototype.play=function(a){var b=this.options.eventObject,d=this.options.onEnd,f=a&&a.onEnd,g=this.options.playOptions&&this.options.playOptions.onEnd;a=c.merge(this.options.playOptions,a);b&&b.sonify?(a.onEnd=d||f||g?function(){var a= arguments;[d,f,g].forEach(function(b){b&&b.apply(this,a)})}:void 0,b.sonify(a)):(f&&f(),d&&d())};g.prototype.cancel=function(a){this.options.eventObject.cancelSonify(a)};b.prototype.init=function(a){this.options=a;this.id=this.options.id=a.id||c.uniqueKey();this.cursor=0;this.eventsPlaying={};this.events=a.silentWait?[new g({time:0}),new g({time:a.silentWait})]:this.options.events;this.sortEvents();this.updateEventIdMap();this.signalHandler=new f.SignalHandler(["playOnEnd","masterOnEnd","onStart", "onEventStart","onEventEnd"]);this.signalHandler.registerSignalCallbacks(c.merge(a,{masterOnEnd:a.onEnd}))};b.prototype.sortEvents=function(){this.events=this.events.sort(function(a,b){return a.time-b.time})};b.prototype.updateEventIdMap=function(){this.eventIdMap=this.events.reduce(function(a,b,c){a[b.id]=c;return a},{})};b.prototype.addTimelineEvents=function(a){this.events=this.events.concat(a);this.sortEvents();this.updateEventIdMap()};b.prototype.getCursor=function(){return this.events[this.cursor]}; b.prototype.setCursor=function(a){a=this.eventIdMap[a];return void 0!==a?(this.cursor=a,!0):!1};b.prototype.play=function(a){this.pause();this.signalHandler.emitSignal("onStart");this.signalHandler.clearSignalCallbacks(["playOnEnd"]);this.signalHandler.registerSignalCallbacks({playOnEnd:a});this.playEvents(1)};b.prototype.rewind=function(a){this.pause();this.signalHandler.emitSignal("onStart");this.signalHandler.clearSignalCallbacks(["playOnEnd"]);this.signalHandler.registerSignalCallbacks({playOnEnd:a}); this.playEvents(-1)};b.prototype.resetCursor=function(){this.cursor=0};b.prototype.resetCursorEnd=function(){this.cursor=this.events.length-1};b.prototype.pause=function(a){var b=this;clearTimeout(b.nextScheduledPlay);Object.keys(b.eventsPlaying).forEach(function(c){b.eventsPlaying[c]&&b.eventsPlaying[c].cancel(a)});b.eventsPlaying={}};b.prototype.playEvents=function(a){var b=this,c=b.events[this.cursor],d=b.events[this.cursor+a],f,g=function(a){b.signalHandler.emitSignal("masterOnEnd",a);b.signalHandler.emitSignal("playOnEnd", a)};c.timelinePath=b;!1===b.signalHandler.emitSignal("onEventStart",c)?g({event:c,cancelled:!0}):(b.eventsPlaying[c.id]=c,c.play({onEnd:function(a){a={event:c,cancelled:!!a};delete b.eventsPlaying[c.id];b.signalHandler.emitSignal("onEventEnd",a);d||g(a)}}),d&&(f=Math.abs(d.time-c.time),1>f?(b.cursor+=a,b.playEvents(a)):this.nextScheduledPlay=setTimeout(function(){b.cursor+=a;b.playEvents(a)},f)))};d.prototype.init=function(a){this.options=a;this.cursor=0;this.paths=a.paths;this.pathsPlaying={};this.signalHandler= new f.SignalHandler(["playOnEnd","masterOnEnd","onPathStart","onPathEnd"]);this.signalHandler.registerSignalCallbacks(c.merge(a,{masterOnEnd:a.onEnd}))};d.prototype.play=function(a){this.pause();this.signalHandler.clearSignalCallbacks(["playOnEnd"]);this.signalHandler.registerSignalCallbacks({playOnEnd:a});this.playPaths(1)};d.prototype.rewind=function(a){this.pause();this.signalHandler.clearSignalCallbacks(["playOnEnd"]);this.signalHandler.registerSignalCallbacks({playOnEnd:a});this.playPaths(-1)}; d.prototype.playPaths=function(a){var b=c.splat(this.paths[this.cursor]),d=this.paths[this.cursor+a],f=this,g=this.signalHandler,l=0,r=function(e){g.emitSignal("onPathStart",e);f.pathsPlaying[e.id]=e;e[0=b.length&&(d&&!h?(f.cursor+=a,c.splat(d).forEach(function(b){b[0