Google
Edit File: audio-player-46a0acf4c8f7bfeb7ec2-min.js
webpackJsonp([20],{0:function(h,e,b){b(1636);b(1634);b(1633);b(1815);b(1406);b(1719)},22:function(h,e,b){h.exports={"default":b(239),__esModule:!0}},39:function(h,e,b){var g=b(276)["default"];e["default"]=function(b,k,a){var d=!0;for(;d;)if(null===b&&(b=Function.prototype),d=g(b,k),void 0===d){b=Object.getPrototypeOf(b);if(null===b)break;d=!0}else{if("value"in d)return d.value;k=d.get;return void 0===k?void 0:k.call(a)}};e.__esModule=!0},40:function(h,e,b){var g=b(229)["default"],f=b(277)["default"]; e["default"]=function(b,a){if("function"!==typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);b.prototype=g(a&&a.prototype,{constructor:{value:b,enumerable:!1,writable:!0,configurable:!0}});a&&(f?f(b,a):b.__proto__=a)};e.__esModule=!0},124:function(h,e,b){var g=b(91),f=b(44),k=b(373);h.exports=function(a,d){var c=(f.Object||{})[a]||Object[a],b={};b[a]=d(c);g(g.S+g.F*k(function(){c(1)}),"Object",b)}},229:function(h,e,b){h.exports={"default":b(278), __esModule:!0}},239:function(h,e,b){b(241);h.exports=b(44).Object.keys},241:function(h,e,b){var g=b(210);b(124)("keys",function(b){return function(k){return b(g(k))}})},276:function(h,e,b){h.exports={"default":b(279),__esModule:!0}},277:function(h,e,b){h.exports={"default":b(280),__esModule:!0}},278:function(h,e,b){var g=b(87);h.exports=function(b,k){return g.create(b,k)}},279:function(h,e,b){var g=b(87);b(282);h.exports=function(b,k){return g.getDesc(b,k)}},280:function(h,e,b){b(283);h.exports=b(44).Object.setPrototypeOf}, 282:function(h,e,b){var g=b(419);b(124)("getOwnPropertyDescriptor",function(b){return function(k,a){return b(g(k),a)}})},283:function(h,e,b){h=b(91);h(h.S,"Object",{setPrototypeOf:b(476).set})},459:function(h,e,b){var g=b(55),f=b(981),k=Math.max;h.exports=function(a,d,c){function b(c,d){d&&clearTimeout(d);r=n=w=void 0;c&&(t=f(),e=a.apply(s,l),!n&&!r&&(l=s=void 0))}function q(){var a=d-(f()-h);0>=a||a>d?b(w,r):n=setTimeout(q,a)}function m(){b(u,n)}function y(){l=arguments;h=f();s=this;w=u&&(n||!x); if(!1===v)var c=x&&!n;else{!r&&!x&&(t=h);var b=v-(h-t),p=0>=b||b>v;p?(r&&(r=clearTimeout(r)),t=h,e=a.apply(s,l)):r||(r=setTimeout(m,b))}p&&n?n=clearTimeout(n):!n&&d!==v&&(n=setTimeout(q,d));c&&(p=!0,e=a.apply(s,l));p&&(!n&&!r)&&(l=s=void 0);return e}var l,r,e,h,s,n,w,t=0,v=!1,u=!0;if("function"!=typeof a)throw new TypeError("Expected a function");d=0>d?0:+d||0;if(!0===c)var x=!0,u=!1;else g(c)&&(x=!!c.leading,v="maxWait"in c&&k(+c.maxWait||0,d),u="trailing"in c?!!c.trailing:u);y.cancel=function(){n&& clearTimeout(n);r&&clearTimeout(r);t=0;r=n=w=void 0};return y}},465:function(h,e,b){e=b(1307);h.exports=new e},477:function(h,e,b){var g=b(459),f=b(55);h.exports=function(b,a,d){var c=!0,p=!0;if("function"!=typeof b)throw new TypeError("Expected a function");!1===d?c=!1:f(d)&&(c="leading"in d?!!d.leading:c,p="trailing"in d?!!d.trailing:p);return g(b,a,{leading:c,maxWait:+a,trailing:p})}},521:function(h,e,b){h.exports={AlbumBlockViewBinder:b(1299),AlbumPageViewBinder:b(1300),CoverPageViewBinder:b(1301)}}, 623:function(h,e,b){var g=b(3)["default"],f=b(2)["default"],k=b(1302),a=b(984);e=function(){function d(){f(this,d)}g(d,[{key:"connectToNode",value:function(a){var d=this;this.container=a;this.trackNodes=this.getTrackNodes(a);a=this.trackNodes.map(this.getUrlFromTrackNode);this.albumController=new k(a,{handleTrackPositionChange:function(a,c,b){return d.handleTrackPositionChange(a,c,b)},handleCurrentTrackPositionChange:function(a,c){return d.handleCurrentTrackPositionChange(a,c)},handleActiveTrackChange:function(a){return d.handleActiveTrackChange(a)}, handlePlayingChange:function(a){return d.handlePlayingChange(a)},handleTrackDurationChange:function(a,c){return d.handleTrackDurationChange(a,c)}});this.bindUIEvents()}},{key:"getTrackNodes",value:function(a){a=a.querySelectorAll(".tracks .track");for(var d=Array(a.length),b=0;b<a.length;b++)d[b]=a[b];return d}},{key:"getUrlFromTrackNode",value:function(a){return a.querySelector(".link").getAttribute("href")}},{key:"bindUIEvents",value:function(){throw Error("Not implemented");}},{key:"handleCurrentTrackPositionChange", value:function(a,d){}},{key:"handleTrackPositionChange",value:function(a,d,b){}},{key:"handleActiveTrackChange",value:function(a){}},{key:"handlePlayingChange",value:function(a){this.container.classList.toggle("playing",a);this.container.classList.toggle("paused",!a)}},{key:"handleTrackDurationChange",value:function(a,d){}},{key:"getScrubHandlerForTrack",value:function(d){var b=this.albumController,f=a(function(){b.skipToTrack(d);b.beginScrubbing()},function(){return b.endScrubbing()},function(a){return b.seekTrackByPercentage(d, a)});return function(a){d===b.currentTrackId&&f(a)}}}]);return d}();h.exports=e},624:function(h,e){h.exports=function(b){var e=Math.floor(b%60);b=Math.floor(b/60);var f=Math.floor(b/60);0<f&&(b%=60);var k="";0<f&&(k+=f+":",10>b&&(k+="0"));10>e&&(e="0"+e);return k+(b+":"+e)}},981:function(h,e,b){e=b(247)(Date,"now")||function(){return(new Date).getTime()};h.exports=e},984:function(h,e){var b=function(b,f,k,a){var d=a.currentTarget,c=document.createElement("div");c.style.cssText="position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 10000000; cursor: pointer;"; var p=function(a){var c=0,b=d.ownerDocument.defaultView;if(b=b.parent===b?null:b.parent)c=b.document.querySelector("iframe#sqs-site-frame").getBoundingClientRect().left;b=d.getBoundingClientRect();return Math.max(Math.min((a-(b.left+c))/(b.right-b.left),1),0)},q=function(a){c.onmousemove=null;c.onmouseup=null;c.remove();a.preventDefault();k(p(a.clientX));f();window.onmouseleave=null};c.onmousemove=function(a){a.preventDefault();k(p(a.clientX))};c.onmouseup=q;window.onmouseleave=q;a.preventDefault(); b();document.body.appendChild(c)};h.exports=function(e,f,k){return b.bind(null,e,f,k)}},986:function(h,e,b){function g(a,c,b){this.fn=a;this.context=c;this.once=b||!1}function f(){}var k=Object.prototype.hasOwnProperty,a="function"!==typeof Object.create?"~":!1;f.prototype._events=void 0;f.prototype.eventNames=function(){var d=this._events,c=[],b;if(!d)return c;for(b in d)k.call(d,b)&&c.push(a?b.slice(1):b);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(d)):c};f.prototype.listeners= function(d,c){var b=a?a+d:d,b=this._events&&this._events[b];if(c)return!!b;if(!b)return[];if(b.fn)return[b.fn];for(var f=0,m=b.length,k=Array(m);f<m;f++)k[f]=b[f].fn;return k};f.prototype.emit=function(d,c,b,f,m,k){var l=a?a+d:d;if(!this._events||!this._events[l])return!1;var l=this._events[l],e=arguments.length,h,g;if("function"===typeof l.fn){l.once&&this.removeListener(d,l.fn,void 0,!0);switch(e){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,c),!0;case 3:return l.fn.call(l.context, c,b),!0;case 4:return l.fn.call(l.context,c,b,f),!0;case 5:return l.fn.call(l.context,c,b,f,m),!0;case 6:return l.fn.call(l.context,c,b,f,m,k),!0}g=1;for(h=Array(e-1);g<e;g++)h[g-1]=arguments[g];l.fn.apply(l.context,h)}else{var s=l.length,n;for(g=0;g<s;g++)switch(l[g].once&&this.removeListener(d,l[g].fn,void 0,!0),e){case 1:l[g].fn.call(l[g].context);break;case 2:l[g].fn.call(l[g].context,c);break;case 3:l[g].fn.call(l[g].context,c,b);break;default:if(!h){n=1;for(h=Array(e-1);n<e;n++)h[n-1]=arguments[n]}l[g].fn.apply(l[g].context, h)}}return!0};f.prototype.on=function(d,c,b){c=new g(c,b||this);d=a?a+d:d;this._events||(this._events=a?{}:Object.create(null));this._events[d]?this._events[d].fn?this._events[d]=[this._events[d],c]:this._events[d].push(c):this._events[d]=c;return this};f.prototype.once=function(d,c,b){c=new g(c,b||this,!0);d=a?a+d:d;this._events||(this._events=a?{}:Object.create(null));this._events[d]?this._events[d].fn?this._events[d]=[this._events[d],c]:this._events[d].push(c):this._events[d]=c;return this};f.prototype.removeListener= function(d,c,b,f){d=a?a+d:d;if(!this._events||!this._events[d])return this;var m=this._events[d],k=[];if(c)if(m.fn)(m.fn!==c||f&&!m.once||b&&m.context!==b)&&k.push(m);else for(var l=0,e=m.length;l<e;l++)(m[l].fn!==c||f&&!m[l].once||b&&m[l].context!==b)&&k.push(m[l]);k.length?this._events[d]=1===k.length?k[0]:k:delete this._events[d];return this};f.prototype.removeAllListeners=function(d){if(!this._events)return this;d?delete this._events[a?a+d:d]:this._events=a?{}:Object.create(null);return this}; f.prototype.off=f.prototype.removeListener;f.prototype.addListener=f.prototype.on;f.prototype.setMaxListeners=function(){return this};f.prefixed=a;h.exports=f},1299:function(h,e,b){var g=b(39)["default"],f=b(40)["default"],k=b(3)["default"],a=b(2)["default"];e=b(623);var d=b(984),c=b(624),p=b(477);b=function(b){function m(){a(this,m);g(Object.getPrototypeOf(m.prototype),"constructor",this).apply(this,arguments)}f(m,b);k(m,[{key:"bindUIEvents",value:function(){var a=this,c=this.container,b=this.albumController; c.querySelector(".album-controls .button.playpause").addEventListener("click",function(){return b.isPlaying?b.pause():b.play()});var f=c.querySelector(".universal-controls");f.querySelector(".play").addEventListener("click",function(){return b.play()});f.querySelector(".pause").addEventListener("click",function(){return b.pause()});f.querySelector(".prev").addEventListener("click",function(){return b.goToPreviousTrack()});f.querySelector(".next").addEventListener("click",function(){return b.goToNextTrack()}); c.querySelector(".universal-track .track-progress-bar").addEventListener("mousedown",d(function(){return b.beginScrubbing()},function(){return b.endScrubbing()},function(a){return b.seekCurrentTrackByPercentage(a)}));this.trackNodes.forEach(function(d,c){d.querySelector(".track-progress-bar").addEventListener("mousedown",a.getScrubHandlerForTrack(c));d.addEventListener("click",function(a){a.preventDefault();b.skipToTrack(c);b.play()})});c.ownerDocument.defaultView.addEventListener("resize",p(this.handleWindowResize.bind(this), 40));m.updateSizeClass(this.container)}},{key:"handleWindowResize",value:function(){this.ownerDocument.body.contains(this.container)&&m.updateSizeClass(this.container)}},{key:"handleCurrentTrackPositionChange",value:function(a,d){var c=this.container.querySelector(".universal-track");m.updateElapsedTimer(c,a,d)}},{key:"handleTrackPositionChange",value:function(a,d,c){m.updateElapsedTimer(this.trackNodes[a],d,c)}},{key:"handleTrackDurationChange",value:function(a,d){var b=this.trackNodes[a],f=c(d); b.querySelector(".timers .duration").textContent=f;a===this.albumController.currentTrackId&&(this.container.querySelector(".universal-track .timers .duration").textContent=f)}},{key:"handleActiveTrackChange",value:function(a){this.trackNodes.forEach(function(a,d){return a.classList.remove("selected")});if(null!==a){var d=this.trackNodes[a];d.classList.add("selected");a=d.getAttribute("data-artist");var d=d.getAttribute("data-title"),c=this.container.querySelector(".universal-track .track-info");c.querySelector(".title").textContent= d;c.querySelector(".artist").textContent=a}}}],[{key:"updateElapsedTimer",value:function(a,d,b){a.querySelector(".track-progress-bar .play-bar").style.width=100*b+"%";a.querySelector(".timers .elapsed").textContent=c(d)}},{key:"updateSizeClass",value:function(a){var d=parseInt(a.ownerDocument.defaultView.getComputedStyle(a).width,10),d=640>d?"sm":800>d?"md":"lg";a=a.classList;a.remove("sm");a.remove("md");a.remove("lg");a.add(d)}}]);return m}(e);h.exports=b},1300:function(h,e,b){var g=b(39)["default"], f=b(40)["default"],k=b(3)["default"],a=b(2)["default"];e=b(623);var d=b(624),c=b(477);b=function(b){function q(){a(this,q);g(Object.getPrototypeOf(q.prototype),"constructor",this).apply(this,arguments)}f(q,b);k(q,[{key:"bindUIEvents",value:function(){var a=this;this.eventHandlers=[{node:this.container.querySelector("a.button"),type:"click",fn:this.handleButtonClick.bind(this)},{node:this.container.ownerDocument.defaultView,type:"resize",fn:c(this.handleWindowResize.bind(this),40)}];this.trackNodes.forEach(function(d, c){a.eventHandlers.push({node:d,type:"click",fn:a.handleTrackNodeClick.bind(a,c)},{node:d.querySelector(".track-progress-bar"),type:"mousedown",fn:a.getScrubHandlerForTrack.call(a,c)})});this.eventHandlers.forEach(function(a){a.node.addEventListener(a.type,a.fn)});this.handleWindowResize()}},{key:"destroy",value:function(){this.eventHandlers.forEach(function(a){a.node.removeEventListener(a.type,a.fn)});this.albumController.changeCurrentTrackImpl(null);this.albumController=this.eventHandlers=null}}, {key:"handleButtonClick",value:function(a){a.preventDefault();this.albumController.playpause()}},{key:"handleTrackNodeClick",value:function(a,d){var c=this.albumController;d.preventDefault();c.skipToTrack(a);c.play()}},{key:"handleWindowResize",value:function(){var a=this.container.ownerDocument.defaultView;a.document.body.contains(this.container)&&(a=parseInt(a.getComputedStyle(this.container).width,10),this.container.classList.toggle("tablet",800>a),this.container.classList.toggle("phone",480>a))}}, {key:"handleTrackPositionChange",value:function(a,c,b){a=this.trackNodes[a];a.querySelector(".track-progress-bar .play-bar").style.width=100*b+"%";a.querySelector(".track-time").textContent=d(c)}},{key:"handleActiveTrackChange",value:function(a){this.trackNodes.forEach(function(a,d){return a.classList.remove("selected")});null!==a&&this.trackNodes[a].classList.add("selected")}}]);return q}(e);h.exports=b},1301:function(h,e,b){var g=b(39)["default"],f=b(40)["default"],k=b(3)["default"],a=b(2)["default"]; e=b(623);var d=b(624);b=function(c){function b(){a(this,b);g(Object.getPrototypeOf(b.prototype),"constructor",this).apply(this,arguments)}f(b,c);k(b,[{key:"bindUIEvents",value:function(){var a=this,d=this.container,c=this.albumController,b=d.querySelector(".button-play-pause");b&&b.addEventListener("click",function(){return c.playpause()});(b=d.querySelector(".button-previous"))&&b.addEventListener("click",function(){return c.goToPreviousTrack()});(d=d.querySelector(".button-next"))&&d.addEventListener("click", function(){return c.goToNextTrack()});this.trackNodes.forEach(function(d,b){d.querySelector(".track-progress-bar").addEventListener("mousedown",a.getScrubHandlerForTrack(b));d.addEventListener("click",function(a){a.preventDefault();c.skipToTrack(b);c.play()})})}},{key:"handleTrackPositionChange",value:function(a,c,b){a=this.trackNodes[a];a.querySelector(".track-progress-bar .play-bar").style.width=100*b+"%";a.querySelector(".track-time").textContent=d(c)}},{key:"handleActiveTrackChange",value:function(a){this.trackNodes.forEach(function(a, d){return a.classList.remove("selected")});null!==a&&this.trackNodes[a].classList.add("selected")}}]);return b}(e);h.exports=b},1302:function(h,e,b){var g=b(3)["default"],f=b(2)["default"],k=b(18)["default"],a=b(22)["default"],d=b(465);e=function(){};var c={handleTrackPositionChange:e,handleCurrentTrackPositionChange:e,handleActiveTrackChange:e,handlePlayingChange:e,handleTrackDurationChange:e};e=function(){function b(a,e){var g=this;f(this,b);this.handlers=k({},c,e);this.tracks=a.map(function(a){return d.createTrack(a)}); this.currentTrackId=null;this.isPlaying=!1;this._currentTrackEventListeners={};this.tracks.forEach(function(a,d){a.on("positionChange",function(){g.handlers.handleTrackPositionChange(d,a.position,a.position/a.duration)}).on("durationChange",function(){g.handlers.handleTrackDurationChange(d,a.duration)})});this.currentTrackEventListeners={positionChange:function(a){return g.handlers.handleCurrentTrackPositionChange(a.position,a.position/a.duration)},ended:function(){return!g.isScrubbing&&g.goToNextTrack()}, inactive:function(){return g.setIsPlayingImpl(!1)}}}g(b,[{key:"skipToTrack",value:function(a){var d=1>=arguments.length||void 0===arguments[1]?!1:arguments[1];if(0>a||a>=this.tracks.length)a=null;d&&null!==a&&this.seekTrack(a,0);this.changeCurrentTrackImpl(a)}},{key:"play",value:function(){null!==this.currentTrackId?(this.tracks[this.currentTrackId].play(),this.setIsPlayingImpl(!0)):0<this.tracks.length&&(this.skipToTrack(0,!0),this.play())}},{key:"pause",value:function(){null!==this.currentTrackId&& this.tracks[this.currentTrackId].pause();this.setIsPlayingImpl(!1)}},{key:"playpause",value:function(){this.isPlaying?this.pause():this.play()}},{key:"goToPreviousTrack",value:function(){var a=0>=arguments.length||void 0===arguments[0]?!0:arguments[0];null!==this.currentTrackId&&this.skipToTrack(this.currentTrackId-1,a)}},{key:"goToNextTrack",value:function(){var a=0>=arguments.length||void 0===arguments[0]?!0:arguments[0];null!==this.currentTrackId&&this.skipToTrack(this.currentTrackId+1,a)}},{key:"seekCurrentTrack", value:function(a){null!==this.currentTrackId&&this.seekTrack(this.currentTrackId)}},{key:"seekCurrentTrackByPercentage",value:function(a){null!==this.currentTrackId&&this.seekTrackByPercentage(this.currentTrackId,a)}},{key:"seekTrack",value:function(a,d){this.tracks[a].seek(d)}},{key:"seekTrackByPercentage",value:function(a,d){this.seekTrack(a,d*this.tracks[a].duration)}},{key:"beginScrubbing",value:function(){this.isScrubbing=!0}},{key:"endScrubbing",value:function(){this.isScrubbing=!1;this.isPlaying&& this.tracks[this.currentTrackId].play()}},{key:"changeCurrentTrackImpl",value:function(d){var c=this,b=this.currentTrackEventListeners;d!==this.currentTrackId&&(null!==this.currentTrackId&&function(){var d=c.tracks[c.currentTrackId];d.pause();a(b).forEach(function(a){return d.removeListener(a,b[a])})}(),null!==d?function(){var f=c.tracks[d];a(b).forEach(function(a){return f.on(a,b[a])});c.isPlaying&&f.play()}():this.setIsPlayingImpl(!1),this.currentTrackId=d,this.handlers.handleActiveTrackChange(d))}}, {key:"setIsPlayingImpl",value:function(a){a!==this.isPlaying&&(this.isPlaying=a,this.handlers.handlePlayingChange(a))}}]);return b}();h.exports=e},1305:function(h,e,b){var g=b(39)["default"],f=b(40)["default"],k=b(3)["default"],a=b(2)["default"],d=b(18)["default"],c=b(22)["default"];e=b(986);var p=b(1308),q={timeupdate:"playing",loadstart:"load",durationchange:"durationchange",canplay:"ready",pause:"pause",playing:"play",ended:"ended"},m={url:null,volume:1};b=function(b){function e(){var b=this,f= 0>=arguments.length||void 0===arguments[0]?{}:arguments[0];a(this,e);g(Object.getPrototypeOf(e.prototype),"constructor",this).call(this);f=d({},m,f);this.audioEl=document.createElement("audio");f.url&&(this.audioEl.src=this.url=f.url);this.audioEl.volume=f.volume;this._needsLoad=!0;c(q).forEach(function(a){return b.audioEl.addEventListener(a,function(){b.emit(q[a])})})}f(e,b);k(e,[{key:"setVolume",value:function(a){this.audioEl.volume=a}},{key:"getVolume",value:function(){return this.audioEl.volume}}, {key:"setSrc",value:function(a){this.audioEl.src=this.url=a;this._needsLoad=!0}},{key:"play",value:function(){var a=this;if(!this.audioEl.src)throw Error("Cannot play: Need to set a url first.");this._needsLoad?(this.once("ready",function(){return a.audioEl.play()}),this.audioEl.load(),this.audioEl.play(),this._needsLoad=!1):3<=this.audioEl.readyState&&this.audioEl.play()}},{key:"playFrom",value:function(a){var d=this;if(!this.audioEl.src)throw Error("Cannot play: Need to set a url first.");this._needsLoad? (this.once("ready",function(){d.audioEl.currentTime=a;d.audioEl.play()}),this.audioEl.load(),this.audioEl.play(),this._needsLoad=!1):3<=this.audioEl.readyState&&(this.audioEl.currentTime=a,this.audioEl.play())}},{key:"pause",value:function(){this.audioEl.pause()}},{key:"seek",value:function(a){if(0!==this.audioEl.readyState){!this.audioEl.paused&&p&&(a=Math.floor(a));var d=this.audioEl.currentTime;this.audioEl.currentTime=a;this.emit("seek",d,a)}}},{key:"getPosition",value:function(){return this.audioEl.currentTime}}, {key:"getDuration",value:function(){return this.audioEl.duration}}]);return e}(e);h.exports=b},1306:function(h,e,b){var g=b(39)["default"],f=b(40)["default"],k=b(3)["default"],a=b(2)["default"],d=b(18)["default"];e=b(986);b=function(){};var c={handlePlay:b,handlePause:b,handleSeek:b};e=function(b){function e(b){a(this,e);g(Object.getPrototypeOf(e.prototype),"constructor",this).call(this);this.url=b;this.duration=this.position=0;this.isActive=!1;this.callbacks=d({},c)}f(e,b);k(e,[{key:"setCallbacks", value:function(a){this.callbacks=d({},c,a)}},{key:"play",value:function(){this.callbacks.handlePlay()}},{key:"pause",value:function(){this.callbacks.handlePause()}},{key:"seek",value:function(a){this.callbacks.handleSeek(a)}},{key:"handlePositionChanged",value:function(a){this.position=a;this.emit("positionChange",this)}},{key:"handlePlay",value:function(){this.emit("play",this)}},{key:"handlePaused",value:function(){this.emit("pause",this)}},{key:"handleEnded",value:function(){this.emit("ended", this)}},{key:"handleDurationChanged",value:function(a){this.duration=a;this.emit("durationChange",this)}},{key:"handleReady",value:function(){this.emit("ready",this)}},{key:"handleActiveChange",value:function(a){this.isActive=a;this.emit(a?"active":"inactive",this)}}]);return e}(e);h.exports=e},1307:function(h,e,b){var g=b(3)["default"],f=b(2)["default"],k=b(1305),a=b(1306);e=function(){function d(){var a=this;f(this,d);this.player=new k;this.activeTrack=null;this.player.on("playing",function(){a.activeTrack&& a.activeTrack.handlePositionChanged(a.player.getPosition())}).on("durationchange",function(){a.activeTrack&&a.activeTrack.handleDurationChanged(a.player.getDuration())}).on("ready",function(){a.activeTrack&&a.activeTrack.handleReady()}).on("play",function(){a.activeTrack&&a.activeTrack.handlePlay()}).on("pause",function(){a.activeTrack&&a.activeTrack.handlePaused()}).on("ended",function(){a.activeTrack&&a.activeTrack.handleEnded()})}g(d,[{key:"createTrack",value:function(d){var b=this,f=new a(d); f.setCallbacks({handlePlay:function(){b.activate(f);b.player.playFrom(f.position)},handlePause:function(){f.isActive&&b.player.pause()},handleSeek:function(a){f.isActive&&b.player.seek(a);f.handlePositionChanged(a)}});return f}},{key:"activate",value:function(a){if(this.activeTrack!==a&&(this.activeTrack&&(this.activeTrack.pause(),this.activeTrack.handleActiveChange(!1)),this.activeTrack=a))this.player.setSrc(a.url),a.handleActiveChange(!0)}}]);return d}();h.exports=e},1308:function(h,e){var b=navigator.userAgent.toLowerCase(), b=-1!==b.indexOf("safari")&&-1===b.indexOf("chrome");h.exports=b},1406:function(h,e){YUI.add("squarespace-block-audio-player-template",function(b){var e=b.Handlebars;(function(){var b=e.template;(e.templates=e.templates||{})["block-audio-player.html"]=b(function(b,a,d,c,f){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,b.helpers);f=f||{};var e=this.escapeExpression;b='<div class="player">\n <div class="action">\n <div class="play">\n <div class="play-button"></div>\n </div>\n <div class="pause">\n <div class="pause-button"></div>\n </div>\n </div>\n <div class="labels">\n <div class="title-wrapper">\n <div class="title" title="'; (c=d.title)?c=c.call(a,{hash:{},data:f}):(c=a.title,c="function"===typeof c?c.apply(a):c);b+=e(c)+'" data-title="';(c=d.title)?c=c.call(a,{hash:{},data:f}):(c=a.title,c="function"===typeof c?c.apply(a):c);b+=e(c)+'">';(c=d.title)?c=c.call(a,{hash:{},data:f}):(c=a.title,c="function"===typeof c?c.apply(a):c);b+=e(c)+'</div>\n </div>\n <div class="artistName" title="';(c=d.artistName)?c=c.call(a,{hash:{},data:f}):(c=a.artistName,c="function"===typeof c?c.apply(a):c);b+=e(c)+'">';(c=d.artistName)? c=c.call(a,{hash:{},data:f}):(c=a.artistName,c="function"===typeof c?c.apply(a):c);b+=e(c)+'</div>\n </div>\n <div class="secondary-controls">\n <div class="time">\n <span class="progress"></span>\n <span class="total">';(c=d.duration)?c=c.call(a,{hash:{},data:f}):(c=a.duration,c="function"===typeof c?c.apply(a):c);return b+=e(c)+'</span>\n </div>\n </div>\n <div class="track">\n <span class="played"><span class="icon"></span></span>\n </div>\n</div>\n'})})();b.Handlebars.registerPartial("block-audio-player.html".replace("/", "."),e.templates["block-audio-player.html"])},"1.0",{requires:["handlebars-base"]})},1633:function(h,e,b){var g=b(521).AlbumBlockViewBinder;YUI.add("squarespace-album-block-player",function(b){b.on("windowresize",function(){b.all(".sqs-album-block").each(function(b){var a=b.one(".album-cover img");a&&(ImageLoader.load(a,{load:!0}),b.removeClass("loading"))})});b.config.win.Squarespace.onInitialize(b,function(){b.all(".sqs-album-block").each(function(b,a){(new g).connectToNode(b.getDOMNode())})})}, "1.0",{requires:["event-resize"]})},1634:function(h,e,b){var g=b(521).AlbumPageViewBinder;YUI.add("squarespace-album-player",function(b){var e,a=function(a){var c=a.one(".album-cover img");c&&b.config.win.ImageLoader.load(c,{load:!0});a.removeClass("loading")};b.on("windowresize",function(){b.all(".sqs-audio-playlist").each(function(d){a(d)})});b.config.win.Squarespace.onInitialize(b,function(){e=[];b.all(".sqs-audio-playlist").each(function(d){var b=new g;e.push(b);b.connectToNode(d.getDOMNode()); a(d)})});b.config.win.Squarespace.onDestroy(b,function(){e.forEach(function(a){a.destroy()});e=null})},"1.0",{requires:["event-resize"]})},1636:function(h,e,b){var g=b(465);YUI.add("squarespace-audio-player",function(b){var e=b.namespace("Squarespace.Widgets").AudioPlayer=b.Base.create("audioPlayer",b.Squarespace.Widgets.SSWidget,[],{initializer:function(a){a=this.get("render");b.Lang.isBoolean(a)?a=null:b.Lang.isString(a)&&(a=b.one(a));a&&(a._audioPlayer&&a._audioPlayer.destroy(),a._audioPlayer= this,b.Object.each(a.getData(),function(a,b){a&&this.set(b,a)},this))},destructor:function(){this._audio&&(this.stop(),this._audio=null)},renderUI:function(){e.superclass.renderUI.apply(this,arguments);var a=this.get("boundingBox"),c=a.one(".placeholder"),g=this.get("title"),h=this.get("author");g&&h?c.setContent(b.Node.create('<div class="wrapper"><div class="audio-author">'+h+'</div><div class="audio-title">'+g+"</div></div>")):g?c.setContent(b.Node.create('<div class="wrapper"><div class="audio-title">'+ g+"</div></div>")):c.setContent(b.Node.create('<div class="wrapper">'+this.get("strings.placeholder")+"</div>"));"true"===this.get("show-download")&&(c='<div class="download"><a href="'+b.Squarespace.UrlUtils.addQueryParam(this.get("url"),"download","true")+'" target="_blank">Download</a></div>',this.get("contentBox").append(c),a.addClass("download"));a.one(".progress-inner").setStyle("width","0px");c=this._volumeNode=a.one(".volume");if(!c)throw this.name+": No div.volume in template.";for(g=this.get("volumeLevels");0< g;g--)c.prepend('<div class="bar level-"'+g+'" data-volume-level="'+g+'"></div>');a.one(".duration").setContent(this.get("strings.durationPlaceHolder"))},bindUI:function(){var a=this.get("id");this.get("boundingBox").on(a+"|click",this._onClick,this);this.after(a+"|volumeChange",function(a){this._setVolume(a.newVal)},this);this.after(a+"|playStateChange",this._uiUpdateWrapperClass,this);this.after(a+"|readyStateChange",this._afterReadyStateChange,this);this.after(a+"|disabledChange",function(a){a.newVal&& this.stop()},this);b.on(a+"|audioPlayer:stopAll",function(a){var d=a?a.container:null;d&&b.Lang.isString(d)&&(d=b.one(d));(!a||!a.hasOwnProperty("container")||d instanceof b.Node&&d.contains(this.get("boundingBox")))&&this.stop()},this)},syncUI:function(){this._uiUpdateWrapperClass();this._uiUpdateVolumeLevel();var a=this.get("boundingBox");a.toggleClass("tiny",300>a.get("offsetWidth"))},play:function(){var a=this.getProperty("PLAY_STATES");g.player.setVolume(this.get("volume")/100);this._audio?this.get("playState")!== a.PLAYING&&this._audio.play():(this._registerTrack(),this._audio.play());this._set("playState",a.PLAYING)},pause:function(){this._audio&&this._audio.pause()},stop:function(){var a=this.get("playState"),b=this.getProperty("PLAY_STATES");a===b.PLAYING&&this._audio&&this._audio.pause()},seek:function(a){100<a||0>a?console.warn(this.name+": seek() - Percentage between 0-100 required."):(this._audio||(this._registerTrack(),this.play()),this._audio.seek(this._audio.duration*(a/100)))},setVolume:function(a){this.set("volume", a)},_setVolume:function(a){this._audio&&g.player.setVolume(a/100);this._set("volume",a);this._uiUpdateVolumeLevel()},_setVolumeLevel:function(a){this._setVolume(Math.round(100*(a/this.get("volumeLevels"))))},_registerTrack:function(){if(!this._audio){var a=this.get("boundingBox"),c=this.get("fixedUrl");a.addClass("loading");if(!c){this._showError("No URL provided.");return}this._audio=g.createTrack(c);this._audio.on("pause",b.bind(this._onPause,this));this._audio.on("ended",b.bind(this._onStop,this)); this._audio.on("inactive",b.bind(this._onPause,this));this._audio.on("positionChange",b.bind(this._onWhilePlaying,this));this._audio.on("ready",b.bind(this._onLoad,this));return!!this._audio}return!1},_uiUpdateVolumeLevel:function(){var a=this._volumeNode.get("children"),b=this.get("volumeLevels"),f=this.get("volume"),e=Math.round(f/100*b);a.each(function(a){parseInt(a.getAttribute("data-volume-level"),10)<=e?a.addClass("active"):a.removeClass("active")},this)},_uiUpdateWrapperClass:function(){var a= this.getProperty("READY_STATES"),b=this.getProperty("PLAY_STATES"),f=this.get("boundingBox"),e=f.getAttribute("class").split(" "),g;for(g in b)e.remove("play-state-"+b[g]);for(g in a)e.remove("ready-state-"+a[g]);f.addClass("ready-state-"+this.get("readyState"));f.setAttribute("class",e.join(" ")).addClass("play-state-"+this.get("playState")).addClass("ready-state-"+this.get("readyState"))},_onClick:function(a){if(b.UA.ios)window.location.href=this.get("url");else if(!a.target.ancestor().hasClass("download")&& (a.halt(),a.stopImmediatePropagation(),!this.get("disabled")&&!a.target.hasClass("duration")))if(a.target.ancestor(".volume"))this._setVolumeLevel(parseInt(a.target.getAttribute("data-volume-level"),10));else if(a.target.ancestor(".placeholder",!0))this.play();else{if(a.target.ancestor(".controls",!0)){a=this.get("playState");var c=this.getProperty("PLAY_STATES");switch(a){case c.PLAYING:this.pause();return;case c.PAUSED:case c.STOPPED:this.play();return;default:console.warn(this.name+": Wait, what? How did you get here? Case was ", a);return}}c=this.get("boundingBox").one(".progress").get("region");a.pageX>=c.left&&a.pageX<=c.right&&this.seek(100*((a.pageX-c.left)/c.width))}},_afterReadyStateChange:function(a){a=this.getProperty("READY_STATES");var b=this.get("readyState"),f=this.get("strings"),e=!1;switch(b){case a.INITIALIZED:this.enable();break;case a.FLASH_BLOCKED:e=f.soundManagerFlashFail;break;case a.SECURITY_ERROR:e=f.soundManagerSecurityFail;this._reportAudioError(a.SECURITY_ERROR);break;case a.SOUND_LOAD_FAILED:e=f.soundManagerURLFail; this._reportAudioError(a.SOUND_LOAD_FAILED);break;case a.SOUND_LOADED:break;default:console.warn(this.name+": Invalid ready state ("+b+").")}e&&(console.warn("AUDIO ERROR: "+e),this._showError(e),this.disable());this._uiUpdateWrapperClass()},_reportAudioError:function(a){try{var c=this.get("url");0<c.indexOf("static.squarespace.com")&&b.Squarespace.Analytics.trackInternal("system_audio_play_error",{readyState:this.get("readyState"),url:c})}catch(e){}},_getPlaytimeString:function(a){if(!this._audio)return this.get("strings.durationPlaceHolder"); var b="0:00",f="0:00",b=this._getMinSecString(this._audio.duration);a&&(f=this._getMinSecString(a));return f+" / "+b},_getMinSecString:function(a){return b.Squarespace.DateUtils.humanizeDuration(1E3*a)},_showError:function(a){this.get("boundingBox").addClass("error");this.get("boundingBox").one(".placeholder").setContent("Error: "+a)},_onWhilePlaying:function(a){if(!this.get("destroyed")){var b=this.get("boundingBox");b.one(".duration").setContent(this._getPlaytimeString(a.position));var f=this.getProperty("READY_STATES"); this.get("readyState")!==f.SOUND_LOADED&&this._set("readyState",f.SOUND_LOADED);f=b.one(".progress-inner");a=100*(a.position/this._audio.duration);b.removeClass("loading");f&&f.setStyle("width",a+"%")}},_onStop:function(){this._set("playState",this.getProperty("PLAY_STATES").STOPPED)},_onPause:function(){this._set("playState",this.getProperty("PLAY_STATES").PAUSED)},_onDataError:function(){this.stop();this._set("playState",this.getProperty("PLAY_STATES").STOPPED)},_onLoad:function(a){a||(this._loadFailTimer= b.later(1E4,this,function(){this.stop();this._set("readyState",this.getProperty("READY_STATES").SOUND_LOAD_FAILED)}))}},{CSS_PREFIX:"sqs-audio-player",PLAY_STATES:{PLAYING:"playing",PAUSED:"paused",STOPPED:"stopped"},READY_STATES:{INITIALIZED:"initialized",FLASH_BLOCKED:"flash-blocked",SECURITY_ERROR:"security-error",SOUND_LOAD_FAILED:"sound-load-failed",SOUND_LOADED:"sound-loaded"},TEMPLATE:'<div class="controls"></div><div class="placeholder"></div><div class="progress"><div class="progress-inner"><div class="scrubber"></div></div></div><div class="duration"></div><div class="volume"></div>', ATTRS:{strings:{value:{placeholder:"Click to play...",durationPlaceHolder:"0:00 / 0:00",loadFail:"Unable to load sound at the URL",soundManagerFlashFail:"Sorry, could not load because flash is blocked.",soundManagerSecurityFail:"Sorry, there was a JavaScript security error.",soundManagerURLFail:"Unable to access audio stream."}},fixedUrl:{getter:function(){var a=this.get("url");0<a.indexOf(Static.SQUARESPACE_CONTEXT.appDomain)&&(a=a.replace(/^(http:\/\/|https:\/\/|\/\/)/i,window.location.protocol+ "//"));return a},readOnly:!0},playState:{lazyAdd:!1,valueFn:function(){return this.getProperty("PLAY_STATES").STOPPED},readOnly:!0},readyState:{lazyAdd:!1,valueFn:function(){return this.getProperty("READY_STATES").INITIALIZED},readOnly:!0},url:{value:null},volume:{validator:function(a){(0>a||100<a)&&console.warn(this.name+": Volume must be between 0 and 100, volume remains unchanged.");return!0},value:66},volumeLevels:{value:6,writeOnce:"initOnly"},stopOthersOnPlay:{value:!0},render:{value:!0}}}), a;b.config.win.Squarespace.onInitialize(b,function(){a=[];b.all(".sqs-audio-embed").each(function(d){if(!(0<d.get("children").size())&&!b.Widget.getByNode(d.one("."+b.Squarespace.Widgets.AudioPlayer.CSS_PREFIX))){switch(b.Object.getValue(d.getData(),"design-style")||"minimal"){case "legacy":d=new b.Squarespace.Widgets.AudioPlayer({render:d});break;default:d=new b.Squarespace.Widgets.AudioPlayerMinimal({render:d})}a.push(d)}})});b.config.win.Squarespace.onDestroy(b,function(){a.forEach(function(a){a.destroy()}); a=null})},"1.0",{requires:"node event squarespace-date-utils squarespace-ss-widget squarespace-album-player squarespace-album-block-player squarespace-url-utils squarespace-widgets-audio-player".split(" ")})},1719:function(h,e,b){var g=b(123),f=b(465);YUI.add("squarespace-media-tracker",function(b){b.namespace("Squarespace");b.Squarespace.MediaTracker=b.Base.create("MediaTracker",b.Base,[],{initializer:function(){this.on("scrollStarted",function(a){this.set("isScrolling",!0)});this.on("scrollFinished", function(a){this.set("isScrolling",!1)});var a=this.get("audio");b.Array.forEach("playing load ready pause play ended".split(" "),function(d){a.on(d,b.bind(function(){this._trackEvent({time:Math.floor(a.getPosition()),seekStart:Math.floor(a.getPosition()),from:0,to:0,track:a.url,duration:Math.floor(a.getDuration()),recordType:g.AUDIO,type:"audio:"+d})},this))},this);a.on("seek",b.bind(function(b,c){this._trackEvent({seek:!0,time:Math.floor(a.getPosition()),from:0,to:0,track:a.url,duration:Math.floor(a.getDuration()), seekStart:Math.floor(b),recordType:g.AUDIO,type:"audio:playing"})},this))},destructor:function(){this._audioEvents.detach();this._audioEvents=null},_postMediaEvent:function(a,d){!0!==b.config.win.__WE_ARE_SQUARESPACE_DISABLING_CENSUS__&&b.Data.post({url:"/api/census/RecordHit",data:{data:a},success:noop,failure:noop})},_trackEvent:function(a){!this._updateTrackSwitch(a)&&!this._updateIgnoredEvent(a)&&(this._isDroppedBuffer(a)||this.set("seekStart",a.seekStart),!this._updateScroll(a)&&!this._updateHeartbeat(a)&& (this._updateSeek(a),this._updateMetaData(a)))},_isUpdatedPosition:function(a){return this.get("seekStart")!==this._retrieveTrackPosition(a.track)},_isDroppedBuffer:function(a){return a.seek&&"load"===this.get("prevEvent")},_shouldRecordLastPlay:function(a){a=this.get("seekStart")-this._retrieveTrackPosition(a.track);return 1<=a&&5>=a},_isPlayBlock:function(a){a=a.time-this._retrieveTrackPosition(a.track);return 1<=a&&5>=a},_isFirstPlay:function(a){return 0===a.time},_isPlayEvent:function(a){return"playing"=== a.type&&!this.get("isTrackSwitching")&&!this.get("isScrolling")},_isPauseEvent:function(a){return"pause"===a.type},_isReadyEvent:function(a){return"ready"===a.type},_isLoadEvent:function(a){return"load"===a.type},_isSeekEvent:function(a){return a.seek&&1<Math.abs(a.time-this.get("seekStart"))&&!this.get("isScrolling")},_isTrackSwitchingEvent:function(a){return a.track!==this.get("curTrack")},_isInitialScrollEvent:function(a){return this.get("isScrolling")&&0===this.get("scrollCount")},_isFinalScrollEvent:function(a){return!this.get("isScrolling")&& this.get("wasScroll")},_isUnrecordedPause:function(a){return 0!==a.time%5&&0!=a.time},_isHeartbeatBoundary:function(a){return 0===a.time%5||a.time===a.duration},_isHeartbeat:function(a){return this._isPlayEvent(a)&&this._isHeartbeatBoundary(a)&&a.time!=this._retrieveTrackPosition(a.track)||this._isPauseEvent(a)&&this._isUnrecordedPause(a)},_retrieveTrackPosition:function(a){a=this.get("trackMap")[a];void 0===a&&(a=0);return a},_updateIgnoredEvent:function(a){return this._isReadyEvent(a)||this._isLoadEvent(a)|| this._retrieveTrackPosition(a.track)===a.time?(this.set("prevEvent",a.type),!0):!1},_updateTrackMap:function(a,d){var c=this.get("trackMap"),f={};f[a]=d;c=b.merge(c,f);this.set("trackMap",c)},_updateHeartbeat:function(a){return this._isHeartbeat(a)?(this._handleHeartbeat(a),this._updateMetaData(a),!0):!1},_updateSeek:function(a){this._isSeekEvent(a)&&(this._handleSkipEvent(a),this._updateMetaData(a))},_updateTrackSwitch:function(a){if(this._isTrackSwitchingEvent(a))if(""===this.get("curTrack"))this.set("curTrack", a.track),this._updateTrackMap(a.track,0);else return this.setAttrs({prevTrack:this.get("curTrack"),curTrack:a.track||"",isTrackSwitching:!0}),this._handleSwitchEvent(a),this._updateMetaData(a),!0;return!1},_updateScroll:function(a){return this._isInitialScrollEvent()?(this.setAttrs({scrollPrev:a.time,scrollCount:this.get("scrollCount")+1,wasScroll:!0}),!0):this._isFinalScrollEvent()?(this.setAttrs({scrollCount:0,scrollEnd:a.time,wasScroll:!1}),this._handleScrollEvent(a),this._updateMetaData(a),!0): !1},_updateMetaData:function(a){this.setAttrs({curDuration:a.duration,prevPlayPosition:a.time})},_recordPreviousPlay:function(a,b,c){this.set("globalOrder",this.get("globalOrder")+1);this._postMediaEvent({type:"playing",from:b,to:c,track:a.track,duration:a.duration,ordering:this.get("globalOrder"),recordType:g.AUDIO})},_recordSeek:function(a,b,c){this.set("globalOrder",this.get("globalOrder")+1);this._postMediaEvent({type:"seek",from:b,to:c,track:a.track,duration:this.get("curDuration"),ordering:this.get("globalOrder"), recordType:g.AUDIO});this._updateTrackMap(a.track,c)},_handleSwitchEvent:function(a){a=this._retrieveTrackPosition(this.get("prevTrack"));void 0===a&&(a=0);this.set("globalOrder",this.get("globalOrder")+1);this._postMediaEvent({type:"playing",from:a,to:this.get("prevPlayPosition"),track:this.get("prevTrack"),duration:this.get("curDuration"),ordering:this.get("globalOrder"),recordType:g.AUDIO});this.set("isTrackSwitching",!1);this._updateTrackMap(this.get("prevTrack"),this.get("prevPlayPosition"))}, _handleScrollEvent:function(a){this._isUpdatedPosition(a)&&this._shouldRecordLastPlay(a)&&this._recordPreviousPlay(a,this._retrieveTrackPosition(a.track),this.get("scrollPrev"));this._recordSeek(a,this.get("scrollPrev"),this.get("scrollEnd"))},_handleSkipEvent:function(a){this._isUpdatedPosition(a)&&this._shouldRecordLastPlay(a)&&this._recordPreviousPlay(a,this._retrieveTrackPosition(a.track),this.get("seekStart"));this._recordSeek(a,this.get("seekStart"),a.time)},_handleHeartbeat:function(a){this._isPlayBlock(a)&& (this._recordPreviousPlay(a,this._retrieveTrackPosition(a.track),a.time),this._updateTrackMap(a.track,a.time))}},{ATTRS:{audio:{},isScrolling:{value:!1,validator:b.Squarespace.AttrValidators.isBoolean},isTrackSwitching:{value:!1,validator:b.Squarespace.AttrValidators.isBoolean},scrollPrev:{value:0,validator:b.Squarespace.AttrValidators.isNumber},scrollEnd:{value:0,validator:b.Squarespace.AttrValidators.isNumber},scrollCount:{value:0,validator:b.Squarespace.AttrValidators.isNumber},wasScroll:{value:!1, validator:b.Squarespace.AttrValidators.isBoolean},prevEvent:{value:"",validator:b.Squarespace.AttrValidators.isString},curDuration:{value:0},trackMap:{value:{}},prevTrack:{value:"",validator:b.Squarespace.AttrValidators.isString},curTrack:{value:"",validator:b.Squarespace.AttrValidators.isString},globalOrder:{value:0,validator:b.Squarespace.AttrValidators.isNumber},prevPlayPosition:{value:0,validator:b.Squarespace.AttrValidators.isNumber},seekStart:{value:0,validator:b.Squarespace.AttrValidators.isNumber}}}); b.Squarespace.Singletons.MediaTracker=new b.Squarespace.MediaTracker({audio:f.player})},"1.0",{requires:["base","squarespace-damask-context-globals"]})},1815:function(h,e,b){var g=b(465);YUI.add("squarespace-widgets-audio-player",function(b){var e=b.namespace("Squarespace.Widgets").AudioPlayerMinimal=b.Base.create("audioPlayer",b.Squarespace.Widgets.SSWidget,[],{initializer:function(){this.setAttrs(this.get("render").getData());""===this.get("title")&&this.set("title","Untitled");this.set("showDownload", "true"===this.get("show-download"));this.set("colorTheme",this.get("color-theme"));this.set("artistName",this.get("author"));this._resizeEmitter=new b.Squarespace.ResizeEmitter;this._registerTrack()},destructor:function(){b.Lang.isValue(this._funk)&&(this._funk.pause(),this._funk=null);b.Lang.isValue(this._resizeEmitter)&&(this._resizeEmitter.destroy(),this._resizeEmitter=null)},renderUI:function(){e.superclass.renderUI.call(this);this.get("showDownload")&&this._renderDownloadLink();this.get("boundingBox").addClass(this.get("colorTheme"))}, bindUI:function(){var a=this.get("contentBox");a.one(".action").on("click",function(){this.get("firstPlay")||this.set("playing",!this.get("playing"))},this);this.after("playingChange",this._playingChange,this);this.after("progressChange",function(a){var b=this.get("contentBox").one(".player .time .progress");b.setContent(a.newVal);b.addClass("loaded");this._updateTracker(this.get("position"))},this);this.after("durationChange",function(a){var b=this.get("contentBox").one(".player .time .total");b.setContent(a.newVal); b.addClass("loaded");this.syncUI()},this);this.after("titleChange",function(a){this.get("contentBox").one(".player .labels .title").setContent(a.newVal)},this);this.after("artistNameChange",function(a){this.get("contentBox").one(".player .labels .artistName").setContent(a.newVal)},this);this._registerEvent(this._resizeEmitter.on("resize:end",this.syncUI,this));var b=a.on("click",function(a){!(this.get("showDownload")&&a.target===this._downloadNode.one("a"))&&this.get("firstPlay")&&(a.halt(),b.detach(), b=null,this._setupScrubber(),this.set("firstPlay",!1),this.set("playing",!0))},this)},syncUI:function(){var a=this.get("boundingBox"),b=a.get("offsetWidth");a.one(".player .track").setStyle("width",b);a.toggleClass("playing",this.get("playing"));a.toggleClass("tiny",300>b);a.toggleClass("no-artist",""===this.get("artistName"));a.toggleClass("first-play",this.get("firstPlay"));a=a.one(".player .labels .title");b=a.get("offsetWidth")<a.get("scrollWidth");a.toggleClass("marquee-mark",b)},_renderNativeAudio:function(){var a= b.Lang.sub(e.NATIVE_TEMPLATE,this.getAttrs());this.get("contentBox").replace(b.Node.create(a))},_renderDownloadLink:function(){var a=this.get("contentBox").one(".player"),d='<div class="download"><a href="'+b.Squarespace.UrlUtils.addQueryParam(this.get("url"),"download","true")+'" target="_blank">Download</a></div>';this._downloadNode=a.one(".secondary-controls").appendChild(d);a.addClass("download")},_renderVisualizer:function(){for(var a=this.get("contentBox").one(".visualizer"),b="",c=0;100>c;c++)b+= '<div class="eq-bar"><div class="height"></div></div>';a.append(b)},_playingChange:function(a){var d=this.get("fixedUrl");b.UA.ios?window.location.href=d:(b.Lang.isValue(this._funk)||this._registerTrack(),a.newVal?this._funk.play():this._funk.pause(),this.syncUI())},_registerTrack:function(){var a=b.bind(function(){this.set("playing",!1)},this),d=b.bind(function(){this.set("playing",!0);g.player.setVolume(this.get("volume")/100)},this),c=b.bind(function(){var a=this._funk.duration;0<a&&(a=this._durationToStr(a), this.set("duration",a))},this),e=b.bind(function(){this.set("playing",!1);this.set("position",0)},this);this._funk=g.createTrack(this.get("fixedUrl"));this._funk.on("ready",c);this._funk.on("ended",e);this._funk.on("play",d);this._funk.on("pause",a);this._funk.on("inactive",a);this._funk.on("positionChange",b.bind(this._whilePlaying,this))},_whilePlaying:function(a){this.get("playing")&&(this.set("position",a.position),this.set("progress",this._durationToStr(a.position)))},_updateTracker:function(a){this.get("contentBox").one(".track .played").setStyle("width", 100*(a/this._funk.duration)+"%")},_mergeEQData:function(){for(var a=theSound.eqData,b=a.left,a=a.right,c=b.length,e=[],f=0;f<c;f++)e.push((parseFloat(b[f])+parseFloat(a[f]))/2);return e},_calculateEQChunks:function(){for(var a=this._mergeEQData(),d=[],c=0;c<length;c+=2){var e=0;b.Array.each(a.slice(c,c+2),function(a){e+=a});d.push(75*(e/2))}return d},_drawEQBars:function(){var a=this.get("contentBox").all(".eq-bar .height"),d=this._calculateEQChunks();b.Array.each(d,function(c,e){var g=a.item(e); b.Lang.isValue(g)&&g.setStyle("height",Math.min(45,d[e]))},this);this.syncUI()},_setupScrubber:function(){var a=b.Node.create('<div class="scrubber-shim"></div>'),d;a.setStyles({position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:Math.pow(10,7),cursor:"none"});this.get("contentBox").one(".player .track").on("mousedown",function(c){this._updatePosition(c);var e=g.player.getVolume();d=this.get("contentBox").one(".track").get("region");this._funk.isActive&&g.player.setVolume(0.25*e);b.one("body").append(a); a.once("mouseup",function(){g.player.setVolume(e);a.remove()},this)},this);a.on("mousemove",function(a){a=this._getRelativePosition(d,a.pageX);b.Squarespace.Singletons.MediaTracker.fire("scrollStarted");this._funk.seek(a);this.get("playing")||(this.set("progress",this._durationToStr(a)),this.set("position",a))},this);a.on("mouseup",function(a){this._getRelativePosition(d,a.pageX);b.Squarespace.Singletons.MediaTracker.fire("scrollFinished")},this)},_updatePosition:function(a){if(!this.get("firstPlay")){var b= this.get("contentBox").one(".track").get("region"),c=this.get("contentBox").one(".track .played .icon").get("offsetWidth")/2;this._funk.seek(this._getRelativePosition(b,a.pageX-c))}},_durationToStr:function(a){var b=Math.floor(a%60);a=Math.floor(a/60);var c=Math.floor(a/60);0<c&&(a%=60);var e="";0<c&&(e+=c+":",10>a&&(e+="0"));10>b&&(b="0"+b);return e+(a+":"+b)},_getRelativePosition:function(a,b){return this._funk.duration*Math.min(1,Math.max(0,(b-a.left)/a.width))},_selectVolume:function(a){var d= this.get("contentBox").all(".player .volume .bar");d.removeClass("active");d.filter(function(b){return parseInt(b.getAttribute("data-level"),10)<=a}).addClass("active");b.Squarespace.Singletons.Audio.set("volume",a)}},{CSS_PREFIX:"sqs-widgets-audio-player",HANDLEBARS_TEMPLATE:"block-audio-player.html",ATTRS:{fixedUrl:{getter:function(){var a=this.get("url");0<a.indexOf(Static.SQUARESPACE_CONTEXT.appDomain)&&(a=a.replace(/^(http:\/\/|https:\/\/|\/\/)/i,window.location.protocol+"//"));return a},readOnly:!0}, firstPlay:{value:!0,validator:b.Squarespace.AttrValidators.isBoolean},position:{value:0,validator:b.Squarespace.AttrValidators.isNumber},progress:{validator:b.Squarespace.AttrValidators.isNullOrString},duration:{validator:b.Squarespace.AttrValidators.isNullOrString},title:{value:"",validator:b.Squarespace.AttrValidators.isString},artistName:{value:"",validator:b.Squarespace.AttrValidators.isString},playing:{value:!1,validator:b.Squarespace.AttrValidators.isBoolean},volume:{value:100,validator:b.Squarespace.AttrValidators.isNumber}}})}, "1.0",{requires:"base node widget squarespace-block-audio-player-template squarespace-url-utils squarespace-media-tracker".split(" ")})}});