diff --git a/mopidy_spotmop/__init__.py b/mopidy_spotmop/__init__.py
index dcb6998..67b71c9 100755
--- a/mopidy_spotmop/__init__.py
+++ b/mopidy_spotmop/__init__.py
@@ -11,7 +11,7 @@
from services.auth import auth
from mopidy import config, ext
-__version__ = '2.5.12'
+__version__ = '2.5.13'
__ext_name__ = 'spotmop'
__verbosemode__ = False
diff --git a/mopidy_spotmop/static/app.js b/mopidy_spotmop/static/app.js
index 11714fa..b03d59f 100644
--- a/mopidy_spotmop/static/app.js
+++ b/mopidy_spotmop/static/app.js
@@ -32915,10 +32915,13 @@ angular.module('spotmop.search', [])
$scope.artists = [];
$scope.playlists = [];
$scope.type = $stateParams.type;
- $scope.query = $filter('stripAccents')( $stateParams.query );
+ $scope.query = '';
+ if( $stateParams.query )
+ $scope.query = $filter('stripAccents')( $stateParams.query );
+
$scope.loading = false;
var searchDelayer;
-
+
// focus on our search field on load (if not touch device, otherwise we get annoying on-screen keyboard)
if( !$scope.isTouchDevice() )
$(document).find('.search-form input.query').focus();
@@ -32927,31 +32930,6 @@ angular.module('spotmop.search', [])
if( $scope.query )
performSearch( $scope.type, $scope.query );
- /**
- * Watch our query string for changes
- * When changed, clear all results, wait for 0.5 seconds for next key, then fire off the search
- var tempQuery = '', queryTimeout;
- $scope.$watch('query', function(newValue, oldValue){
-
- if( newValue != oldValue && newValue && newValue != '' ){
- $scope.loading = true;
- $scope.tracklist = {tracks: [], type: 'track'};
- $scope.albums = [];
- $scope.artists = [];
- $scope.playlists = [];
-
- if (queryTimeout)
- $timeout.cancel(queryTimeout);
-
- tempQuery = newValue;
- queryTimeout = $timeout(function() {
- $scope.query = tempQuery;
- performSearch( $scope.type, $scope.query );
- }, 1000);
- }
- })
- **/
-
/**
* Fetch the search results
@@ -34259,14 +34237,14 @@ angular.module('spotmop.services.pusher', [
}
// notify server of our actual username
- var name = SettingsService.getSetting('pushername', null)
+ var name = SettingsService.getSetting('pushername', '')
if( name )
service.setMe( name );
// standard notification, fire it out!
}else{
// make sure we're not notifying ourselves
- if( data.id != SettingsService.getSetting('pusherid', null) && !SettingsService.getSetting('pusherdisabled', false) )
+ if( data.id != SettingsService.getSetting('pusherid', '') && !SettingsService.getSetting('pusherdisabled', false) )
$rootScope.$broadcast('spotmop:pusher:received', data);
}
}
@@ -35759,12 +35737,15 @@ angular.module('spotmop.services.settings', [])
* @param property = string (optional sub-property)
**/
getSetting: function( setting, defaultValue, property ){
-
+
if( typeof(property) === 'undefined')
property = false;
+ // if we're getting a sub-property
if( property ){
- if( typeof($localStorage.settings[setting][property]) !== 'undefined' ){
+
+ // make sure our parent property, and sub-property exist
+ if( typeof($localStorage.settings[setting]) !== 'undefined' && typeof($localStorage.settings[setting][property]) !== 'undefined' ){
return $localStorage.settings[setting][property];
}
}else{
diff --git a/mopidy_spotmop/static/app.min.js b/mopidy_spotmop/static/app.min.js
index 18243e6..a7eff66 100644
--- a/mopidy_spotmop/static/app.min.js
+++ b/mopidy_spotmop/static/app.min.js
@@ -1,6 +1,6 @@
/**
* Mopidy-Spotmop
- * Built 2016-02-04
+ * Built 2016-02-07
**/
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b="length"in a&&a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(ha.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=oa[a]={};return _.each(a.match(na)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+h.uid++}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ua,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:ta.test(c)?_.parseJSON(c):c}catch(e){}sa.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Ka.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)ra.set(a[c],"globalEval",!b||ra.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(ra.hasData(a)&&(f=ra.access(a),g=ra.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sa.hasData(a)&&(h=sa.access(a),i=_.extend({},h),sa.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ya.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Oa[a];return c||(c=t(a,b),"none"!==c&&c||(Na=(Na||_("")).appendTo(b.documentElement),b=Na[0].contentDocument,b.write(),b.close(),c=t(a,b),Na.detach()),Oa[a]=c),c}function v(a,b,c){var d,e,f,g,h=a.style;return c=c||Ra(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||_.contains(a.ownerDocument,a)||(g=_.style(a,b)),Qa.test(g)&&Pa.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function w(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}function x(a,b){if(b in a)return b;for(var c=b[0].toUpperCase()+b.slice(1),d=b,e=Xa.length;e--;)if(b=Xa[e]+c,b in a)return b;return d}function y(a,b,c){var d=Ta.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function z(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=_.css(a,c+wa[f],!0,e)),d?("content"===c&&(g-=_.css(a,"padding"+wa[f],!0,e)),"margin"!==c&&(g-=_.css(a,"border"+wa[f]+"Width",!0,e))):(g+=_.css(a,"padding"+wa[f],!0,e),"padding"!==c&&(g+=_.css(a,"border"+wa[f]+"Width",!0,e)));return g}function A(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ra(a),g="border-box"===_.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=v(a,b,f),(0>e||null==e)&&(e=a.style[b]),Qa.test(e))return e;d=g&&(Y.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+z(a,b,c||(g?"border":"content"),d,f)+"px"}function B(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=ra.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&xa(d)&&(f[g]=ra.access(d,"olddisplay",u(d.nodeName)))):(e=xa(d),"none"===c&&e||ra.set(d,"olddisplay",e?c:_.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function C(a,b,c,d,e){return new C.prototype.init(a,b,c,d,e)}function D(){return setTimeout(function(){Ya=void 0}),Ya=_.now()}function E(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=wa[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function F(a,b,c){for(var d,e=(cb[b]||[]).concat(cb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function G(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},n=a.style,o=a.nodeType&&xa(a),p=ra.get(a,"fxshow");c.queue||(h=_._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,_.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[n.overflow,n.overflowX,n.overflowY],j=_.css(a,"display"),k="none"===j?ra.get(a,"olddisplay")||u(a.nodeName):j,"inline"===k&&"none"===_.css(a,"float")&&(n.display="inline-block")),c.overflow&&(n.overflow="hidden",l.always(function(){n.overflow=c.overflow[0],n.overflowX=c.overflow[1],n.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],$a.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(o?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;o=!0}m[d]=p&&p[d]||_.style(a,d)}else j=void 0;if(_.isEmptyObject(m))"inline"===("none"===j?u(a.nodeName):j)&&(n.display=j);else{p?"hidden"in p&&(o=p.hidden):p=ra.access(a,"fxshow",{}),f&&(p.hidden=!o),o?_(a).show():l.done(function(){_(a).hide()}),l.done(function(){var b;ra.remove(a,"fxshow");for(b in m)_.style(a,b,m[b])});for(d in m)g=F(o?p[d]:0,d,l),d in p||(p[d]=g.start,o&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function H(a,b){var c,d,e,f,g;for(c in a)if(d=_.camelCase(c),e=b[d],f=a[c],_.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=_.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function I(a,b,c){var d,e,f=0,g=bb.length,h=_.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Ya||D(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:_.extend({},b),opts:_.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Ya||D(),duration:c.duration,tweens:[],createTween:function(b,c){var d=_.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(H(k,j.opts.specialEasing);g>f;f++)if(d=bb[f].call(j,a,k,j.opts))return d;return _.map(k,F,j),_.isFunction(j.opts.start)&&j.opts.start.call(a,j),_.fx.timer(_.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function J(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(na)||[];if(_.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function K(a,b,c,d){function e(h){var i;return f[h]=!0,_.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||g||f[j]?g?!(i=j):void 0:(b.dataTypes.unshift(j),e(j),!1)}),i}var f={},g=a===tb;return e(b.dataTypes[0])||!f["*"]&&e("*")}function L(a,b){var c,d,e=_.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&_.extend(!0,a,d),a}function M(a,b,c){for(var d,e,f,g,h=a.contents,i=a.dataTypes;"*"===i[0];)i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function N(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];for(f=k.shift();f;)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}function O(a,b,c,d){var e;if(_.isArray(b))_.each(b,function(b,e){c||yb.test(a)?d(a,e):O(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==_.type(b))d(a,b);else for(e in b)O(a+"["+e+"]",b[e],c,d)}function P(a){return _.isWindow(a)?a:9===a.nodeType&&a.defaultView}var Q=[],R=Q.slice,S=Q.concat,T=Q.push,U=Q.indexOf,V={},W=V.toString,X=V.hasOwnProperty,Y={},Z=a.document,$="2.1.4",_=function(a,b){return new _.fn.init(a,b)},aa=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,ba=/^-ms-/,ca=/-([\da-z])/gi,da=function(a,b){return b.toUpperCase()};_.fn=_.prototype={jquery:$,constructor:_,selector:"",length:0,toArray:function(){return R.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:R.call(this)},pushStack:function(a){var b=_.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return _.each(this,a,b)},map:function(a){return this.pushStack(_.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(R.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:T,sort:Q.sort,splice:Q.splice},_.extend=_.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||_.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(_.isPlainObject(d)||(e=_.isArray(d)))?(e?(e=!1,f=c&&_.isArray(c)?c:[]):f=c&&_.isPlainObject(c)?c:{},g[b]=_.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},_.extend({expando:"jQuery"+($+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===_.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!_.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==_.type(a)||a.nodeType||_.isWindow(a)?!1:a.constructor&&!X.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?V[W.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=_.trim(a),a&&(1===a.indexOf("use strict")?(b=Z.createElement("script"),b.text=a,Z.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(ba,"ms-").replace(ca,da)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,d){var e,f=0,g=a.length,h=c(a);if(d){if(h)for(;g>f&&(e=b.apply(a[f],d),e!==!1);f++);else for(f in a)if(e=b.apply(a[f],d),e===!1)break}else if(h)for(;g>f&&(e=b.call(a[f],f,a[f]),e!==!1);f++);else for(f in a)if(e=b.call(a[f],f,a[f]),e===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(aa,"")},makeArray:function(a,b){var d=b||[];return null!=a&&(c(Object(a))?_.merge(d,"string"==typeof a?[a]:a):T.call(d,a)),d},inArray:function(a,b,c){return null==b?-1:U.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,d){var e,f=0,g=a.length,h=c(a),i=[];if(h)for(;g>f;f++)e=b(a[f],f,d),null!=e&&i.push(e);else for(f in a)e=b(a[f],f,d),null!=e&&i.push(e);return S.apply([],i)},guid:1,proxy:function(a,b){var c,d,e;return"string"==typeof b&&(c=a[b],b=a,a=c),_.isFunction(a)?(d=R.call(arguments,2),e=function(){return a.apply(b||this,d.concat(R.call(arguments)))},e.guid=a.guid=a.guid||_.guid++,e):void 0},now:Date.now,support:Y}),_.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){V["[object "+b+"]"]=b.toLowerCase()});var ea=function(a){function b(a,b,c,d){var e,f,g,h,i,j,l,n,o,p;if((b?b.ownerDocument||b:O)!==G&&F(b),b=b||G,c=c||[],h=b.nodeType,"string"!=typeof a||!a||1!==h&&9!==h&&11!==h)return c;if(!d&&I){if(11!==h&&(e=sa.exec(a)))if(g=e[1]){if(9===h){if(f=b.getElementById(g),!f||!f.parentNode)return c;if(f.id===g)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(g))&&M(b,f)&&f.id===g)return c.push(f),c}else{if(e[2])return $.apply(c,b.getElementsByTagName(a)),c;if((g=e[3])&&v.getElementsByClassName)return $.apply(c,b.getElementsByClassName(g)),c}if(v.qsa&&(!J||!J.test(a))){if(n=l=N,o=b,p=1!==h&&a,1===h&&"object"!==b.nodeName.toLowerCase()){for(j=z(a),(l=b.getAttribute("id"))?n=l.replace(ua,"\\$&"):b.setAttribute("id",n),n="[id='"+n+"'] ",i=j.length;i--;)j[i]=n+m(j[i]);o=ta.test(a)&&k(b.parentNode)||b,p=j.join(",")}if(p)try{return $.apply(c,o.querySelectorAll(p)),c}catch(q){}finally{l||b.removeAttribute("id")}}}return B(a.replace(ia,"$1"),b,c,d)}function c(){function a(c,d){return b.push(c+" ")>w.cacheLength&&delete a[b.shift()],a[c+" "]=d}var b=[];return a}function d(a){return a[N]=!0,a}function e(a){var b=G.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function f(a,b){for(var c=a.split("|"),d=a.length;d--;)w.attrHandle[c[d]]=b}function g(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||V)-(~a.sourceIndex||V);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function h(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function i(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function j(a){return d(function(b){return b=+b,d(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function k(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}function l(){}function m(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function n(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=Q++;return b.first?function(b,c,f){for(;b=b[d];)if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[P,f];if(g){for(;b=b[d];)if((1===b.nodeType||e)&&a(b,c,g))return!0}else for(;b=b[d];)if(1===b.nodeType||e){if(i=b[N]||(b[N]={}),(h=i[d])&&h[0]===P&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function o(a){return a.length>1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function p(a,c,d){for(var e=0,f=c.length;f>e;e++)b(a,c[e],d);return d}function q(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function r(a,b,c,e,f,g){return e&&!e[N]&&(e=r(e)),f&&!f[N]&&(f=r(f,g)),d(function(d,g,h,i){var j,k,l,m=[],n=[],o=g.length,r=d||p(b||"*",h.nodeType?[h]:h,[]),s=!a||!d&&b?r:q(r,m,a,h,i),t=c?f||(d?a:o||e)?[]:g:s;if(c&&c(s,t,h,i),e)for(j=q(t,n),e(j,[],h,i),k=j.length;k--;)(l=j[k])&&(t[n[k]]=!(s[n[k]]=l));if(d){if(f||a){if(f){for(j=[],k=t.length;k--;)(l=t[k])&&j.push(s[k]=l);f(null,t=[],j,i)}for(k=t.length;k--;)(l=t[k])&&(j=f?aa(d,l):m[k])>-1&&(d[j]=!(g[j]=l))}}else t=q(t===g?t.splice(o,t.length):t),f?f(null,g,t,i):$.apply(g,t)})}function s(a){for(var b,c,d,e=a.length,f=w.relative[a[0].type],g=f||w.relative[" "],h=f?1:0,i=n(function(a){return a===b},g,!0),j=n(function(a){return aa(b,a)>-1},g,!0),k=[function(a,c,d){var e=!f&&(d||c!==C)||((b=c).nodeType?i(a,c,d):j(a,c,d));return b=null,e}];e>h;h++)if(c=w.relative[a[h].type])k=[n(o(k),c)];else{if(c=w.filter[a[h].type].apply(null,a[h].matches),c[N]){for(d=++h;e>d&&!w.relative[a[d].type];d++);return r(h>1&&o(k),h>1&&m(a.slice(0,h-1).concat({value:" "===a[h-2].type?"*":""})).replace(ia,"$1"),c,d>h&&s(a.slice(h,d)),e>d&&s(a=a.slice(d)),e>d&&m(a))}k.push(c)}return o(k)}function t(a,c){var e=c.length>0,f=a.length>0,g=function(d,g,h,i,j){var k,l,m,n=0,o="0",p=d&&[],r=[],s=C,t=d||f&&w.find.TAG("*",j),u=P+=null==s?1:Math.random()||.1,v=t.length;for(j&&(C=g!==G&&g);o!==v&&null!=(k=t[o]);o++){if(f&&k){for(l=0;m=a[l++];)if(m(k,g,h)){i.push(k);break}j&&(P=u)}e&&((k=!m&&k)&&n--,d&&p.push(k))}if(n+=o,e&&o!==n){for(l=0;m=c[l++];)m(p,r,g,h);if(d){if(n>0)for(;o--;)p[o]||r[o]||(r[o]=Y.call(i));r=q(r)}$.apply(i,r),j&&!d&&r.length>0&&n+c.length>1&&b.uniqueSort(i)}return j&&(P=u,C=s),p};return e?d(g):g}var u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N="sizzle"+1*new Date,O=a.document,P=0,Q=0,R=c(),S=c(),T=c(),U=function(a,b){return a===b&&(E=!0),0},V=1<<31,W={}.hasOwnProperty,X=[],Y=X.pop,Z=X.push,$=X.push,_=X.slice,aa=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},ba="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ca="[\\x20\\t\\r\\n\\f]",da="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",ea=da.replace("w","w#"),fa="\\["+ca+"*("+da+")(?:"+ca+"*([*^$|!~]?=)"+ca+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+ea+"))|)"+ca+"*\\]",ga=":("+da+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+fa+")*)|.*)\\)|)",ha=new RegExp(ca+"+","g"),ia=new RegExp("^"+ca+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ca+"+$","g"),ja=new RegExp("^"+ca+"*,"+ca+"*"),ka=new RegExp("^"+ca+"*([>+~]|"+ca+")"+ca+"*"),la=new RegExp("="+ca+"*([^\\]'\"]*?)"+ca+"*\\]","g"),ma=new RegExp(ga),na=new RegExp("^"+ea+"$"),oa={ID:new RegExp("^#("+da+")"),CLASS:new RegExp("^\\.("+da+")"),TAG:new RegExp("^("+da.replace("w","w*")+")"),ATTR:new RegExp("^"+fa),PSEUDO:new RegExp("^"+ga),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ca+"*(even|odd|(([+-]|)(\\d*)n|)"+ca+"*(?:([+-]|)"+ca+"*(\\d+)|))"+ca+"*\\)|)","i"),bool:new RegExp("^(?:"+ba+")$","i"),needsContext:new RegExp("^"+ca+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ca+"*((?:-\\d)?\\d*)"+ca+"*\\)|)(?=[^-]|$)","i")},pa=/^(?:input|select|textarea|button)$/i,qa=/^h\d$/i,ra=/^[^{]+\{\s*\[native \w/,sa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ta=/[+~]/,ua=/'|\\/g,va=new RegExp("\\\\([\\da-f]{1,6}"+ca+"?|("+ca+")|.)","ig"),wa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},xa=function(){F()};try{$.apply(X=_.call(O.childNodes),O.childNodes),X[O.childNodes.length].nodeType}catch(ya){$={apply:X.length?function(a,b){Z.apply(a,_.call(b))}:function(a,b){for(var c=a.length,d=0;a[c++]=b[d++];);a.length=c-1}}}v=b.support={},y=b.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},F=b.setDocument=function(a){var b,c,d=a?a.ownerDocument||a:O;return d!==G&&9===d.nodeType&&d.documentElement?(G=d,H=d.documentElement,c=d.defaultView,c&&c!==c.top&&(c.addEventListener?c.addEventListener("unload",xa,!1):c.attachEvent&&c.attachEvent("onunload",xa)),I=!y(d),v.attributes=e(function(a){return a.className="i",!a.getAttribute("className")}),v.getElementsByTagName=e(function(a){return a.appendChild(d.createComment("")),!a.getElementsByTagName("*").length}),v.getElementsByClassName=ra.test(d.getElementsByClassName),v.getById=e(function(a){return H.appendChild(a).id=N,!d.getElementsByName||!d.getElementsByName(N).length}),v.getById?(w.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&I){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},w.filter.ID=function(a){var b=a.replace(va,wa);return function(a){return a.getAttribute("id")===b}}):(delete w.find.ID,w.filter.ID=function(a){var b=a.replace(va,wa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),w.find.TAG=v.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):v.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},w.find.CLASS=v.getElementsByClassName&&function(a,b){return I?b.getElementsByClassName(a):void 0},K=[],J=[],(v.qsa=ra.test(d.querySelectorAll))&&(e(function(a){H.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&J.push("[*^$]="+ca+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||J.push("\\["+ca+"*(?:value|"+ba+")"),a.querySelectorAll("[id~="+N+"-]").length||J.push("~="),a.querySelectorAll(":checked").length||J.push(":checked"),a.querySelectorAll("a#"+N+"+*").length||J.push(".#.+[+~]")}),e(function(a){var b=d.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&J.push("name"+ca+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||J.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),J.push(",.*:")})),(v.matchesSelector=ra.test(L=H.matches||H.webkitMatchesSelector||H.mozMatchesSelector||H.oMatchesSelector||H.msMatchesSelector))&&e(function(a){v.disconnectedMatch=L.call(a,"div"),L.call(a,"[s!='']:x"),K.push("!=",ga)}),J=J.length&&new RegExp(J.join("|")),K=K.length&&new RegExp(K.join("|")),b=ra.test(H.compareDocumentPosition),M=b||ra.test(H.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},U=b?function(a,b){if(a===b)return E=!0,0;var c=!a.compareDocumentPosition-!b.compareDocumentPosition;return c?c:(c=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&c||!v.sortDetached&&b.compareDocumentPosition(a)===c?a===d||a.ownerDocument===O&&M(O,a)?-1:b===d||b.ownerDocument===O&&M(O,b)?1:D?aa(D,a)-aa(D,b):0:4&c?-1:1)}:function(a,b){if(a===b)return E=!0,0;var c,e=0,f=a.parentNode,h=b.parentNode,i=[a],j=[b];if(!f||!h)return a===d?-1:b===d?1:f?-1:h?1:D?aa(D,a)-aa(D,b):0;if(f===h)return g(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[e]===j[e];)e++;return e?g(i[e],j[e]):i[e]===O?-1:j[e]===O?1:0},d):G},b.matches=function(a,c){return b(a,null,null,c)},b.matchesSelector=function(a,c){if((a.ownerDocument||a)!==G&&F(a),c=c.replace(la,"='$1']"),!(!v.matchesSelector||!I||K&&K.test(c)||J&&J.test(c)))try{var d=L.call(a,c);if(d||v.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return b(c,G,null,[a]).length>0},b.contains=function(a,b){return(a.ownerDocument||a)!==G&&F(a),M(a,b)},b.attr=function(a,b){(a.ownerDocument||a)!==G&&F(a);var c=w.attrHandle[b.toLowerCase()],d=c&&W.call(w.attrHandle,b.toLowerCase())?c(a,b,!I):void 0;return void 0!==d?d:v.attributes||!I?a.getAttribute(b):(d=a.getAttributeNode(b))&&d.specified?d.value:null},b.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},b.uniqueSort=function(a){var b,c=[],d=0,e=0;if(E=!v.detectDuplicates,D=!v.sortStable&&a.slice(0),a.sort(U),E){for(;b=a[e++];)b===a[e]&&(d=c.push(e));for(;d--;)a.splice(c[d],1)}return D=null,a},x=b.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=x(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d++];)c+=x(b);return c},w=b.selectors={cacheLength:50,createPseudo:d,match:oa,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(va,wa),a[3]=(a[3]||a[4]||a[5]||"").replace(va,wa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||b.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&b.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return oa.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&ma.test(c)&&(b=z(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(va,wa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=R[a+" "];return b||(b=new RegExp("(^|"+ca+")"+a+"("+ca+"|$)"))&&R(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,c,d){return function(e){var f=b.attr(e,a);return null==f?"!="===c:c?(f+="","="===c?f===d:"!="===c?f!==d:"^="===c?d&&0===f.indexOf(d):"*="===c?d&&f.indexOf(d)>-1:"$="===c?d&&f.slice(-d.length)===d:"~="===c?(" "+f.replace(ha," ")+" ").indexOf(d)>-1:"|="===c?f===d||f.slice(0,d.length+1)===d+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[N]||(q[N]={}),j=k[a]||[],n=j[0]===P&&j[1],m=j[0]===P&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[P,n,m];break}}else if(s&&(j=(b[N]||(b[N]={}))[a])&&j[0]===P)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[N]||(l[N]={}))[a]=[P,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,c){var e,f=w.pseudos[a]||w.setFilters[a.toLowerCase()]||b.error("unsupported pseudo: "+a);return f[N]?f(c):f.length>1?(e=[a,a,"",c],w.setFilters.hasOwnProperty(a.toLowerCase())?d(function(a,b){for(var d,e=f(a,c),g=e.length;g--;)d=aa(a,e[g]),a[d]=!(b[d]=e[g])}):function(a){return f(a,0,e)}):f}},pseudos:{not:d(function(a){var b=[],c=[],e=A(a.replace(ia,"$1"));return e[N]?d(function(a,b,c,d){for(var f,g=e(a,null,d,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,d,f){return b[0]=a,e(b,null,f,c),b[0]=null,!c.pop()}}),has:d(function(a){return function(c){return b(a,c).length>0}}),contains:d(function(a){return a=a.replace(va,wa),function(b){return(b.textContent||b.innerText||x(b)).indexOf(a)>-1}}),lang:d(function(a){return na.test(a||"")||b.error("unsupported lang: "+a),a=a.replace(va,wa).toLowerCase(),function(b){var c;do if(c=I?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===H},focus:function(a){return a===G.activeElement&&(!G.hasFocus||G.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!w.pseudos.empty(a)},header:function(a){return qa.test(a.nodeName)},input:function(a){return pa.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:j(function(){return[0]}),last:j(function(a,b){return[b-1]}),eq:j(function(a,b,c){return[0>c?c+b:c]}),even:j(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:j(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:j(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:j(function(a,b,c){for(var d=0>c?c+b:c;++d2&&"ID"===(g=f[0]).type&&v.getById&&9===b.nodeType&&I&&w.relative[f[1].type]){if(b=(w.find.ID(g.matches[0].replace(va,wa),b)||[])[0],!b)return c;j&&(b=b.parentNode),a=a.slice(f.shift().value.length)}for(e=oa.needsContext.test(a)?0:f.length;e--&&(g=f[e],!w.relative[h=g.type]);)if((i=w.find[h])&&(d=i(g.matches[0].replace(va,wa),ta.test(f[0].type)&&k(b.parentNode)||b))){if(f.splice(e,1),a=d.length&&m(f),!a)return $.apply(c,d),c;break}}return(j||A(a,l))(d,b,!I,c,ta.test(a)&&k(b.parentNode)||b),c},v.sortStable=N.split("").sort(U).join("")===N,v.detectDuplicates=!!E,F(),v.sortDetached=e(function(a){return 1&a.compareDocumentPosition(G.createElement("div"))}),e(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||f("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),v.attributes&&e(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||f("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),e(function(a){return null==a.getAttribute("disabled")})||f(ba,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),b}(a);_.find=ea,_.expr=ea.selectors,_.expr[":"]=_.expr.pseudos,_.unique=ea.uniqueSort,_.text=ea.getText,_.isXMLDoc=ea.isXML,_.contains=ea.contains;var fa=_.expr.match.needsContext,ga=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,ha=/^.[^:#\[\.,]*$/;_.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?_.find.matchesSelector(d,a)?[d]:[]:_.find.matches(a,_.grep(b,function(a){return 1===a.nodeType}))},_.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;
@@ -14,6 +14,6 @@ var e;return b&&rd(b.nodeName)===c?e=b:(e=d.cloneNode(!1),b?a.insertBefore(e,b):
f=d,d=null),d){if(!K(d))throw new Error("'locals' must be an object")}else d=k;if(f){if(!o(f))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else f=l;var n=a.defer(),r=n.promise,s=r.$$promises={},t=N({},d),u=1+q.length/3,v=!1;if(H(f.$$failure))return i(f.$$failure),r;f.$$inheritedValues&&e(t,m(f.$$inheritedValues,p)),N(s,f.$$promises),f.$$values?(v=e(t,m(f.$$values,p)),r.$$inheritedValues=m(f.$$values,p),h()):(f.$$inheritedValues&&(r.$$inheritedValues=m(f.$$inheritedValues,p)),f.then(h,i));for(var w=0,x=q.length;x>w;w+=3)d.hasOwnProperty(q[w])?h():j(q[w],q[w+1],q[w+2]);return r}},this.resolve=function(a,b,c,d){return this.study(a)(b,c,d)}}function q(a,b,c){this.fromConfig=function(a,b,c){return H(a.template)?this.fromString(a.template,b):H(a.templateUrl)?this.fromUrl(a.templateUrl,b):H(a.templateProvider)?this.fromProvider(a.templateProvider,b,c):null},this.fromString=function(a,b){return I(a)?a(b):a},this.fromUrl=function(c,d){return I(c)&&(c=c(d)),null==c?null:a.get(c,{cache:b,headers:{Accept:"text/html"}}).then(function(a){return a.data})},this.fromProvider=function(a,b,d){return c.invoke(a,null,d||{params:b})}}function r(a,b,e){function f(b,c,d,e){if(q.push(b),o[b])return o[b];if(!/^\w+(-+\w+)*(?:\[\])?$/.test(b))throw new Error("Invalid parameter name '"+b+"' in pattern '"+a+"'");if(p[b])throw new Error("Duplicate parameter name '"+b+"' in pattern '"+a+"'");return p[b]=new P.Param(b,c,d,e),p[b]}function g(a,b,c,d){var e=["",""],f=a.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!b)return f;switch(c){case!1:e=["(",")"+(d?"?":"")];break;case!0:e=["?(",")?"];break;default:e=["("+c+"|",")?"]}return f+e[0]+b+e[1]}function h(e,f){var g,h,i,j,k;return g=e[2]||e[3],k=b.params[g],i=a.substring(m,e.index),h=f?e[4]:e[4]||("*"==e[1]?".*":null),j=P.type(h||"string")||d(P.type("string"),{pattern:new RegExp(h,b.caseInsensitive?"i":c)}),{id:g,regexp:h,segment:i,type:j,cfg:k}}b=N({params:{}},K(b)?b:{});var i,j=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,k=/([:]?)([\w\[\]-]+)|\{([\w\[\]-]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l="^",m=0,n=this.segments=[],o=e?e.params:{},p=this.params=e?e.params.$$new():new P.ParamSet,q=[];this.source=a;for(var r,s,t;(i=j.exec(a))&&(r=h(i,!1),!(r.segment.indexOf("?")>=0));)s=f(r.id,r.type,r.cfg,"path"),l+=g(r.segment,s.type.pattern.source,s.squash,s.isOptional),n.push(r.segment),m=j.lastIndex;t=a.substring(m);var u=t.indexOf("?");if(u>=0){var v=this.sourceSearch=t.substring(u);if(t=t.substring(0,u),this.sourcePath=a.substring(0,m+u),v.length>0)for(m=0;i=k.exec(v);)r=h(i,!0),s=f(r.id,r.type,r.cfg,"search"),m=j.lastIndex}else this.sourcePath=a,this.sourceSearch="";l+=g(t)+(b.strict===!1?"/?":"")+"$",n.push(t),this.regexp=new RegExp(l,b.caseInsensitive?"i":c),this.prefix=n[0],this.$$paramNames=q}function s(a){N(this,a)}function t(){function a(a){return null!=a?a.toString().replace(/\//g,"%2F"):a}function e(a){return null!=a?a.toString().replace(/%2F/g,"/"):a}function f(){return{strict:p,caseInsensitive:m}}function i(a){return I(a)||L(a)&&I(a[a.length-1])}function j(){for(;w.length;){var a=w.shift();if(a.pattern)throw new Error("You cannot override a type's .pattern at runtime.");b.extend(u[a.name],l.invoke(a.def))}}function k(a){N(this,a||{})}P=this;var l,m=!1,p=!0,q=!1,u={},v=!0,w=[],x={string:{encode:a,decode:e,is:function(a){return null==a||!H(a)||"string"==typeof a},pattern:/[^/]*/},"int":{encode:a,decode:function(a){return parseInt(a,10)},is:function(a){return H(a)&&this.decode(a.toString())===a},pattern:/\d+/},bool:{encode:function(a){return a?1:0},decode:function(a){return 0!==parseInt(a,10)},is:function(a){return a===!0||a===!1},pattern:/0|1/},date:{encode:function(a){return this.is(a)?[a.getFullYear(),("0"+(a.getMonth()+1)).slice(-2),("0"+a.getDate()).slice(-2)].join("-"):c},decode:function(a){if(this.is(a))return a;var b=this.capture.exec(a);return b?new Date(b[1],b[2]-1,b[3]):c},is:function(a){return a instanceof Date&&!isNaN(a.valueOf())},equals:function(a,b){return this.is(a)&&this.is(b)&&a.toISOString()===b.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:b.toJson,decode:b.fromJson,is:b.isObject,equals:b.equals,pattern:/[^/]*/},any:{encode:b.identity,decode:b.identity,equals:b.equals,pattern:/.*/}};t.$$getDefaultValue=function(a){if(!i(a.value))return a.value;if(!l)throw new Error("Injectable functions cannot be called at configuration time");return l.invoke(a.value)},this.caseInsensitive=function(a){return H(a)&&(m=a),m},this.strictMode=function(a){return H(a)&&(p=a),p},this.defaultSquashPolicy=function(a){if(!H(a))return q;if(a!==!0&&a!==!1&&!J(a))throw new Error("Invalid squash policy: "+a+". Valid policies: false, true, arbitrary-string");return q=a,a},this.compile=function(a,b){return new r(a,N(f(),b))},this.isMatcher=function(a){if(!K(a))return!1;var b=!0;return M(r.prototype,function(c,d){I(c)&&(b=b&&H(a[d])&&I(a[d]))}),b},this.type=function(a,b,c){if(!H(b))return u[a];if(u.hasOwnProperty(a))throw new Error("A type named '"+a+"' has already been defined.");return u[a]=new s(N({name:a},b)),c&&(w.push({name:a,def:c}),v||j()),this},M(x,function(a,b){u[b]=new s(N({name:b},a))}),u=d(u,{}),this.$get=["$injector",function(a){return l=a,v=!1,j(),M(x,function(a,b){u[b]||(u[b]=new s(a))}),this}],this.Param=function(a,b,d,e){function f(a){var b=K(a)?g(a):[],c=-1===h(b,"value")&&-1===h(b,"type")&&-1===h(b,"squash")&&-1===h(b,"array");return c&&(a={value:a}),a.$$fn=i(a.value)?a.value:function(){return a.value},a}function j(b,c,d){if(b.type&&c)throw new Error("Param '"+a+"' has two type configurations.");return c?c:b.type?b.type instanceof s?b.type:new s(b.type):"config"===d?u.any:u.string}function k(){var b={array:"search"===e?"auto":!1},c=a.match(/\[\]$/)?{array:!0}:{};return N(b,c,d).array}function m(a,b){var c=a.squash;if(!b||c===!1)return!1;if(!H(c)||null==c)return q;if(c===!0||J(c))return c;throw new Error("Invalid squash policy: '"+c+"'. Valid policies: false, true, or arbitrary string")}function p(a,b,d,e){var f,g,i=[{from:"",to:d||b?c:""},{from:null,to:d||b?c:""}];return f=L(a.replace)?a.replace:[],J(e)&&f.push({from:e,to:c}),g=o(f,function(a){return a.from}),n(i,function(a){return-1===h(g,a.from)}).concat(f)}function r(){if(!l)throw new Error("Injectable functions cannot be called at configuration time");var a=l.invoke(d.$$fn);if(null!==a&&a!==c&&!w.type.is(a))throw new Error("Default value ("+a+") for parameter '"+w.id+"' is not an instance of Type ("+w.type.name+")");return a}function t(a){function b(a){return function(b){return b.from===a}}function c(a){var c=o(n(w.replace,b(a)),function(a){return a.to});return c.length?c[0]:a}return a=c(a),H(a)?w.type.$normalize(a):r()}function v(){return"{Param:"+a+" "+b+" squash: '"+z+"' optional: "+y+"}"}var w=this;d=f(d),b=j(d,b,e);var x=k();b=x?b.$asArray(x,"search"===e):b,"string"!==b.name||x||"path"!==e||d.value!==c||(d.value="");var y=d.value!==c,z=m(d,y),A=p(d,x,y,z);N(this,{id:a,type:b,location:e,array:x,squash:z,replace:A,isOptional:y,value:t,dynamic:c,config:d,toString:v})},k.prototype={$$new:function(){return d(this,N(new k,{$$parent:this}))},$$keys:function(){for(var a=[],b=[],c=this,d=g(k.prototype);c;)b.push(c),c=c.$$parent;return b.reverse(),M(b,function(b){M(g(b),function(b){-1===h(a,b)&&-1===h(d,b)&&a.push(b)})}),a},$$values:function(a){var b={},c=this;return M(c.$$keys(),function(d){b[d]=c[d].value(a&&a[d])}),b},$$equals:function(a,b){var c=!0,d=this;return M(d.$$keys(),function(e){var f=a&&a[e],g=b&&b[e];d[e].type.equals(f,g)||(c=!1)}),c},$$validates:function(a){var d,e,f,g,h,i=this.$$keys();for(d=0;de;e++)if(b(j[e]))return;k&&b(k)}}function n(){return i=i||e.$on("$locationChangeSuccess",m)}var o,p=g.baseHref(),q=d.url();return l||n(),{sync:function(){m()},listen:function(){return n()},update:function(a){return a?void(q=d.url()):void(d.url()!==q&&(d.url(q),d.replace()))},push:function(a,b,e){var f=a.format(b||{});null!==f&&b&&b["#"]&&(f+="#"+b["#"]),d.url(f),o=e&&e.$$avoidResync?d.url():c,e&&e.replace&&d.replace()},href:function(c,e,f){if(!c.validates(e))return null;var g=a.html5Mode();b.isObject(g)&&(g=g.enabled);var i=c.format(e);if(f=f||{},g||null===i||(i="#"+a.hashPrefix()+i),null!==i&&e&&e["#"]&&(i+="#"+e["#"]),i=h(i,g,f.absolute),!f.absolute||!i)return i;var j=!g&&i?"/":"",k=d.port();return k=80===k||443===k?"":":"+k,[d.protocol(),"://",d.host(),k,j,i].join("")}}}var i,j=[],k=null,l=!1;this.rule=function(a){if(!I(a))throw new Error("'rule' must be a function");return j.push(a),this},this.otherwise=function(a){if(J(a)){var b=a;a=function(){return b}}else if(!I(a))throw new Error("'rule' must be a function");return k=a,this},this.when=function(a,b){var c,h=J(b);if(J(a)&&(a=d.compile(a)),!h&&!I(b)&&!L(b))throw new Error("invalid 'handler' in when()");var i={matcher:function(a,b){return h&&(c=d.compile(b),b=["$match",function(a){return c.format(a)}]),N(function(c,d){return g(c,b,a.exec(d.path(),d.search()))},{prefix:J(a.prefix)?a.prefix:""})},regex:function(a,b){if(a.global||a.sticky)throw new Error("when() RegExp must not be global or sticky");return h&&(c=b,b=["$match",function(a){return f(c,a)}]),N(function(c,d){return g(c,b,a.exec(d.path()))},{prefix:e(a)})}},j={matcher:d.isMatcher(a),regex:a instanceof RegExp};for(var k in j)if(j[k])return this.rule(i[k](a,b));throw new Error("invalid 'what' in when()")},this.deferIntercept=function(a){a===c&&(a=!0),l=a},this.$get=h,h.$inject=["$location","$rootScope","$injector","$browser"]}function v(a,e){function f(a){return 0===a.indexOf(".")||0===a.indexOf("^")}function m(a,b){if(!a)return c;var d=J(a),e=d?a:a.name,g=f(e);if(g){if(!b)throw new Error("No reference point given for path '"+e+"'");b=m(b);for(var h=e.split("."),i=0,j=h.length,k=b;j>i;i++)if(""!==h[i]||0!==i){if("^"!==h[i])break;if(!k.parent)throw new Error("Path '"+e+"' not valid for state '"+b.name+"'");k=k.parent}else k=b;h=h.slice(i).join("."),e=k.name+(k.name&&h?".":"")+h}var l=z[e];return!l||!d&&(d||l!==a&&l.self!==a)?c:l}function n(a,b){A[a]||(A[a]=[]),A[a].push(b)}function p(a){for(var b=A[a]||[];b.length;)q(b.shift())}function q(b){b=d(b,{self:b,resolve:b.resolve||{},toString:function(){return this.name}});var c=b.name;if(!J(c)||c.indexOf("@")>=0)throw new Error("State must have a valid name");if(z.hasOwnProperty(c))throw new Error("State '"+c+"'' is already defined");var e=-1!==c.indexOf(".")?c.substring(0,c.lastIndexOf(".")):J(b.parent)?b.parent:K(b.parent)&&J(b.parent.name)?b.parent.name:"";if(e&&!z[e])return n(e,b.self);for(var f in C)I(C[f])&&(b[f]=C[f](b,C.$delegates[f]));return z[c]=b,!b[B]&&b.url&&a.when(b.url,["$match","$stateParams",function(a,c){y.$current.navigable==b&&j(a,c)||y.transitionTo(b,a,{inherit:!0,location:!1})}]),p(c),b}function r(a){return a.indexOf("*")>-1}function s(a){for(var b=a.split("."),c=y.$current.name.split("."),d=0,e=b.length;e>d;d++)"*"===b[d]&&(c[d]="*");return"**"===b[0]&&(c=c.slice(h(c,b[1])),c.unshift("**")),"**"===b[b.length-1]&&(c.splice(h(c,b[b.length-2])+1,Number.MAX_VALUE),c.push("**")),b.length!=c.length?!1:c.join("")===b.join("")}function t(a,b){return J(a)&&!H(b)?C[a]:I(b)&&J(a)?(C[a]&&!C.$delegates[a]&&(C.$delegates[a]=C[a]),C[a]=b,this):this}function u(a,b){return K(a)?b=a:b.name=a,q(b),this}function v(a,e,f,h,l,n,p,q,t){function u(b,c,d,f){var g=a.$broadcast("$stateNotFound",b,c,d);if(g.defaultPrevented)return p.update(),D;if(!g.retry)return null;if(f.$retry)return p.update(),E;var h=y.transition=e.when(g.retry);return h.then(function(){return h!==y.transition?A:(b.options.$retry=!0,y.transitionTo(b.to,b.toParams,b.options))},function(){return D}),p.update(),h}function v(a,c,d,g,i,j){function m(){var c=[];return M(a.views,function(d,e){var g=d.resolve&&d.resolve!==a.resolve?d.resolve:{};g.$template=[function(){return f.load(e,{view:d,locals:i.globals,params:n,notify:j.notify})||""}],c.push(l.resolve(g,i.globals,i.resolve,a).then(function(c){if(I(d.controllerProvider)||L(d.controllerProvider)){var f=b.extend({},g,i.globals);c.$$controller=h.invoke(d.controllerProvider,null,f)}else c.$$controller=d.controller;c.$$state=a,c.$$controllerAs=d.controllerAs,i[e]=c}))}),e.all(c).then(function(){return i.globals})}var n=d?c:k(a.params.$$keys(),c),o={$stateParams:n};i.resolve=l.resolve(a.resolve,o,i.resolve,a);var p=[i.resolve.then(function(a){i.globals=a})];return g&&p.push(g),e.all(p).then(m).then(function(a){return i})}var A=e.reject(new Error("transition superseded")),C=e.reject(new Error("transition prevented")),D=e.reject(new Error("transition aborted")),E=e.reject(new Error("transition failed"));return x.locals={resolve:null,globals:{$stateParams:{}}},y={params:{},current:x.self,$current:x,transition:null},y.reload=function(a){return y.transitionTo(y.current,n,{reload:a||!0,inherit:!1,notify:!0})},y.go=function(a,b,c){return y.transitionTo(a,b,N({inherit:!0,relative:y.$current},c))},y.transitionTo=function(b,c,f){c=c||{},f=N({location:!0,inherit:!1,relative:null,notify:!0,reload:!1,$retry:!1},f||{});var g,j=y.$current,l=y.params,o=j.path,q=m(b,f.relative),r=c["#"];if(!H(q)){var s={to:b,toParams:c,options:f},t=u(s,j.self,l,f);if(t)return t;if(b=s.to,c=s.toParams,f=s.options,q=m(b,f.relative),!H(q)){if(!f.relative)throw new Error("No such state '"+b+"'");throw new Error("Could not resolve '"+b+"' from state '"+f.relative+"'")}}if(q[B])throw new Error("Cannot transition to abstract state '"+b+"'");if(f.inherit&&(c=i(n,c||{},y.$current,q)),!q.params.$$validates(c))return E;c=q.params.$$values(c),b=q;var z=b.path,D=0,F=z[D],G=x.locals,I=[];if(f.reload){if(J(f.reload)||K(f.reload)){if(K(f.reload)&&!f.reload.name)throw new Error("Invalid reload state object");var L=f.reload===!0?o[0]:m(f.reload);if(f.reload&&!L)throw new Error("No such reload state '"+(J(f.reload)?f.reload:f.reload.name)+"'");for(;F&&F===o[D]&&F!==L;)G=I[D]=F.locals,D++,F=z[D]}}else for(;F&&F===o[D]&&F.ownParams.$$equals(c,l);)G=I[D]=F.locals,D++,F=z[D];if(w(b,c,j,l,G,f))return r&&(c["#"]=r),y.params=c,O(y.params,n),f.location&&b.navigable&&b.navigable.url&&(p.push(b.navigable.url,c,{$$avoidResync:!0,replace:"replace"===f.location}),p.update(!0)),y.transition=null,e.when(y.current);if(c=k(b.params.$$keys(),c||{}),f.notify&&a.$broadcast("$stateChangeStart",b.self,c,j.self,l).defaultPrevented)return a.$broadcast("$stateChangeCancel",b.self,c,j.self,l),p.update(),C;for(var M=e.when(G),P=D;P=D;d--)g=o[d],g.self.onExit&&h.invoke(g.self.onExit,g.self,g.locals.globals),g.locals=null;for(d=D;d=0?e:e+"@"+(f?f.state.name:"")}function B(a,b){var c,d=a.match(/^\s*({[^}]*})\s*$/);if(d&&(a=b+"("+d[1]+")"),c=a.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/),!c||4!==c.length)throw new Error("Invalid state ref '"+a+"'");return{state:c[1],paramExpr:c[3]||null}}function C(a){var b=a.parent().inheritedData("$uiView");return b&&b.state&&b.state.name?b.state:void 0}function D(a,c){var d=["location","inherit","reload","absolute"];return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(e,f,g,h){var i=B(g.uiSref,a.current.name),j=null,k=C(f)||a.$current,l="[object SVGAnimatedString]"===Object.prototype.toString.call(f.prop("href"))?"xlink:href":"href",m=null,n="A"===f.prop("tagName").toUpperCase(),o="FORM"===f[0].nodeName,p=o?"action":l,q=!0,r={relative:k,inherit:!0},s=e.$eval(g.uiSrefOpts)||{};b.forEach(d,function(a){a in s&&(r[a]=s[a])});var t=function(c){if(c&&(j=b.copy(c)),q){m=a.href(i.state,j,r);var d=h[1]||h[0];return d&&d.$$addStateInfo(i.state,j),null===m?(q=!1,!1):void g.$set(p,m)}};i.paramExpr&&(e.$watch(i.paramExpr,function(a,b){a!==j&&t(a)},!0),j=b.copy(e.$eval(i.paramExpr))),t(),o||f.bind("click",function(b){var d=b.which||b.button;if(!(d>1||b.ctrlKey||b.metaKey||b.shiftKey||f.attr("target"))){var e=c(function(){a.go(i.state,j,r)});b.preventDefault();var g=n&&!m?1:0;b.preventDefault=function(){g--<=0&&c.cancel(e)}}})}}}function E(a,b,c){return{restrict:"A",controller:["$scope","$element","$attrs",function(b,d,e){function f(){g()?d.addClass(i):d.removeClass(i)}function g(){for(var a=0;ae;e++){g=h[e];var l=this.params[g],m=d[e+1];for(f=0;fe;e++)g=h[e],k[g]=this.params[g].value(b[g]);return k},r.prototype.parameters=function(a){return H(a)?this.params[a]||null:this.$$paramNames},r.prototype.validates=function(a){return this.params.$$validates(a)},r.prototype.format=function(a){function b(a){return encodeURIComponent(a).replace(/-/g,function(a){return"%5C%"+a.charCodeAt(0).toString(16).toUpperCase()})}a=a||{};var c=this.segments,d=this.parameters(),e=this.params;if(!this.validates(a))return null;var f,g=!1,h=c.length-1,i=d.length,j=c[0];for(f=0;i>f;f++){var k=h>f,l=d[f],m=e[l],n=m.value(a[l]),p=m.isOptional&&m.type.equals(m.value(),n),q=p?m.squash:!1,r=m.type.encode(n);if(k){var s=c[f+1];if(q===!1)null!=r&&(j+=L(r)?o(r,b).join("-"):encodeURIComponent(r)),j+=s;else if(q===!0){var t=j.match(/\/$/)?/\/?(.*)/:/(.*)/;j+=s.match(t)[1]}else J(q)&&(j+=q+s)}else{if(null==r||p&&q!==!1)continue;L(r)||(r=[r]),r=o(r,encodeURIComponent).join("&"+l+"="),j+=(g?"&":"?")+(l+"="+r),g=!0}}return j},s.prototype.is=function(a,b){return!0},s.prototype.encode=function(a,b){return a},s.prototype.decode=function(a,b){return a},s.prototype.equals=function(a,b){return a==b},s.prototype.$subPattern=function(){var a=this.pattern.toString();return a.substr(1,a.length-2)},s.prototype.pattern=/.*/,s.prototype.toString=function(){return"{Type:"+this.name+"}"},s.prototype.$normalize=function(a){return this.is(a)?a:this.decode(a)},s.prototype.$asArray=function(a,b){function d(a,b){function d(a,b){return function(){return a[b].apply(a,arguments)}}function e(a){return L(a)?a:H(a)?[a]:[]}function f(a){switch(a.length){case 0:return c;case 1:return"auto"===b?a[0]:a;default:return a}}function g(a){return!a}function h(a,b){return function(c){c=e(c);var d=o(c,a);return b===!0?0===n(d,g).length:f(d)}}function i(a){return function(b,c){var d=e(b),f=e(c);if(d.length!==f.length)return!1;for(var g=0;g1)throw"Multiple backgrounds are not supported";if(!d||"none"===d)throw"Element is not an but does not have a background-image";e[f]={img:new Image,el:e[f]},d=d.slice(4,-1),d=d.replace(/"/g,""),e[f].img.src=d,c("CSS Image - "+d)}return e}function g(a,b){var c=a;if("string"==typeof a?c=document.querySelectorAll(a):a&&1===a.nodeType&&(c=[a]),!c||0===c.length||void 0===c.length)throw"Elements not found";return b&&(c=f(c)),c=Array.prototype.slice.call(c)}function h(){C=document.createElement("canvas"),C&&C.getContext?(D=C.getContext("2d"),B=!0):B=!1,i()}function i(){z("debugOverlay")?(C.style.opacity=.5,C.style.pointerEvents="none",document.body.appendChild(C)):C.parentNode&&C.parentNode.removeChild(C)}function j(a){var d=(new Date).getTime()-a;c("Duration: "+d+"ms"),d>z("maxDuration")&&(console.log("BackgroundCheck - Killed"),q(),b())}function k(){F={left:0,top:0,right:document.body.clientWidth,bottom:window.innerHeight},C.width=document.body.clientWidth,C.height=window.innerHeight}function l(a,b,c){var d,e;return-1!==a.indexOf("px")?d=parseFloat(a):-1!==a.indexOf("%")?(d=parseFloat(a),e=d/100,d=e*b,c&&(d-=c*e)):d=b,d}function m(a){var b=window.getComputedStyle(a.el);a.el.style.backgroundRepeat="no-repeat",a.el.style.backgroundOrigin="padding-box";var c=b.backgroundSize.split(" "),d=c[0],e=void 0===c[1]?"auto":c[1],f=a.el.clientWidth/a.el.clientHeight,g=a.img.naturalWidth/a.img.naturalHeight;"cover"===d?f>=g?(d="100%",e="auto"):(d="auto",c[0]="auto",e="100%"):"contain"===d&&(1/g>1/f?(d="auto",c[0]="auto",e="100%"):(d="100%",e="auto")),d="auto"===d?a.img.naturalWidth:l(d,a.el.clientWidth),e="auto"===e?d/a.img.naturalWidth*a.img.naturalHeight:l(e,a.el.clientHeight),"auto"===c[0]&&"auto"!==c[1]&&(d=e/a.img.naturalHeight*a.img.naturalWidth);var h=b.backgroundPosition;"top"===h?h="50% 0%":"left"===h?h="0% 50%":"right"===h?h="100% 50%":"bottom"===h?h="50% 100%":"center"===h&&(h="50% 50%"),h=h.split(" ");var i,j;return 4===h.length?(i=h[1],j=h[3]):(i=h[0],j=h[1]),j=j||"50%",i=l(i,a.el.clientWidth,d),j=l(j,a.el.clientHeight,e),4===h.length&&("right"===h[0]&&(i=a.el.clientWidth-a.img.naturalWidth-i),"bottom"===h[2]&&(j=a.el.clientHeight-a.img.naturalHeight-j)),i+=a.el.getBoundingClientRect().left,j+=a.el.getBoundingClientRect().top,{left:Math.floor(i),right:Math.floor(i+d),top:Math.floor(j),bottom:Math.floor(j+e),width:Math.floor(d),height:Math.floor(e)}}function n(a){var b,c,d;if(a.nodeType){var e=a.getBoundingClientRect();b={left:e.left,right:e.right,top:e.top,bottom:e.bottom,width:e.width,height:e.height},d=a.parentNode,c=a}else b=m(a),d=a.el,c=a.img;d=d.getBoundingClientRect(),b.imageTop=0,b.imageLeft=0,b.imageWidth=c.naturalWidth,b.imageHeight=c.naturalHeight;var f,g=b.imageHeight/b.height;return b.topd.bottom&&(f=b.bottom-d.bottom,b.imageHeight-=g*f,b.height-=f),b.right>d.right&&(f=b.right-d.right,b.imageWidth-=g*f,b.width-=f),b.imageTop=Math.floor(b.imageTop),b.imageLeft=Math.floor(b.imageLeft),
b.imageHeight=Math.floor(b.imageHeight),b.imageWidth=Math.floor(b.imageWidth),b}function o(a){var b=n(a);a=a.nodeType?a:a.img,b.imageWidth>0&&b.imageHeight>0&&b.width>0&&b.height>0?D.drawImage(a,b.imageLeft,b.imageTop,b.imageWidth,b.imageHeight,b.left,b.top,b.width,b.height):c("Skipping image - "+a.src+" - area too small")}function p(a,b,c){var d=a.className;switch(c){case"add":d+=" "+b;break;case"remove":var e=new RegExp("(?:^|\\s)"+b+"(?!\\S)","g");d=d.replace(e,"")}a.className=d.trim()}function q(a){for(var b,c=a?[a]:z("targets"),d=0;d0&&g.height>0){q(a),a=z("changeParent")?a.parentNode:a,d=D.getImageData(g.left,g.top,g.width,g.height).data;for(var m=0;mz("minComplexity")/100&&p(a,z("classes").complex,"add"))}}function s(a,b){return a=(a.nodeType?a:a.el).getBoundingClientRect(),b=b===F?b:(b.nodeType?b:b.el).getBoundingClientRect(),!(a.rightb.right||a.top>b.bottom||a.bottomg;g++)b=z("targets")[g],s(b,F)&&("targets"!==d||a&&a!==b?"image"===d&&s(b,a)&&r(b):(e=!0,r(b)));if("targets"===d&&!e)throw a+" is not a target";j(c)}function u(a){var b=function(a){var b=0;return"static"!==window.getComputedStyle(a).position&&(b=parseInt(window.getComputedStyle(a).zIndex,10)||0,b>=0&&b++),b},c=a.parentNode,d=c?b(c):0,e=b(a);return 1e5*d+e}function v(a){var b=!1;return a.sort(function(a,c){a=a.nodeType?a:a.el,c=c.nodeType?c:c.el;var d=a.compareDocumentPosition(c),e=0;return a=u(a),c=u(c),a>c&&(b=!0),a===c&&2===d?e=1:a===c&&4===d&&(e=-1),e||a-c}),c("Sorted: "+b),b&&c(a),b}function w(a,b,d){if(B){var e=z("mask");c("--- BackgroundCheck ---"),c("onLoad event: "+(d&&d.src)),b!==!0&&(D.clearRect(0,0,C.width,C.height),D.fillStyle="rgb("+e.r+", "+e.g+", "+e.b+")",D.fillRect(0,0,C.width,C.height));for(var f,g,h=d?[d]:z("images"),i=v(h),j=!1,k=0;k0&&e.which!=g.which)&&!a(e.target).is(g.not)&&(!g.handle||a(e.target).closest(g.handle,e.currentTarget).length)&&(d.touched="touchstart"==e.type?this:null,g.propagates=1,g.mousedown=this,g.interactions=[d.interaction(this,g)],g.target=e.target,g.pageX=e.pageX,g.pageY=e.pageY,g.dragging=null,f=d.hijack(e,"draginit",g),g.propagates))return f=d.flatten(f),f&&f.length&&(g.interactions=[],a.each(f,function(){g.interactions.push(d.interaction(this,g))})),g.propagates=g.interactions.length,g.drop!==!1&&c.drop&&c.drop.handler(e,g),d.textselect(!1),d.touched?b.add(d.touched,"touchmove touchend",d.handler,g):b.add(document,"mousemove mouseup",d.handler,g),!d.touched||g.live?!1:void 0}},interaction:function(b,c){var e=a(b)[c.relative?"position":"offset"]()||{top:0,left:0};return{drag:b,callback:new d.callback,droppable:[],offset:e}},handler:function(e){var f=e.data;switch(e.type){case!f.dragging&&"touchmove":e.preventDefault();case!f.dragging&&"mousemove":if(Math.pow(e.pageX-f.pageX,2)+Math.pow(e.pageY-f.pageY,2)0?void a.removeData(this,"suppress."+b.type):e.apply(this,arguments)};var f=b.fixHooks.touchstart=b.fixHooks.touchmove=b.fixHooks.touchend=b.fixHooks.touchcancel={props:"clientX clientY pageX pageY screenX screenY".split(" "),filter:function(b,c){if(c){var d=c.touches&&c.touches[0]||c.changedTouches&&c.changedTouches[0]||null;d&&a.each(f.props,function(a,c){b[c]=d[c]})}return b}};c.draginit=c.dragstart=c.dragend=d}(jQuery),function(a){a.fn.drop=function(b,c,d){var e="string"==typeof b?b:"",f=a.isFunction(b)?b:a.isFunction(c)?c:null;return 0!==e.indexOf("drop")&&(e="drop"+e),d=(b==f?c:d)||{},f?this.bind(e,d,f):this.trigger(e)},a.drop=function(b){b=b||{},d.multi=b.multi===!0?1/0:b.multi===!1?1:isNaN(b.multi)?d.multi:b.multi,d.delay=b.delay||d.delay,d.tolerance=a.isFunction(b.tolerance)?b.tolerance:null===b.tolerance?null:d.tolerance,d.mode=b.mode||d.mode||"intersect"};var b=a.event,c=b.special,d=a.event.special.drop={multi:1,delay:20,mode:"overlap",targets:[],datakey:"dropdata",noBubble:!0,add:function(b){var c=a.data(this,d.datakey);c.related+=1},remove:function(){a.data(this,d.datakey).related-=1},setup:function(){if(!a.data(this,d.datakey)){var b={related:0,active:[],anyactive:0,winner:0,location:{}};a.data(this,d.datakey,b),d.targets.push(this)}},teardown:function(){var b=a.data(this,d.datakey)||{};if(!b.related){a.removeData(this,d.datakey);var c=this;d.targets=a.grep(d.targets,function(a){return a!==c})}},handler:function(b,e){var f;if(e)switch(b.type){case"mousedown":case"touchstart":f=a(d.targets),"string"==typeof e.drop&&(f=f.filter(e.drop)),f.each(function(){var b=a.data(this,d.datakey);b.active=[],b.anyactive=0,b.winner=0}),e.droppable=f,c.drag.hijack(b,"dropinit",e);break;case"mousemove":case"touchmove":d.event=b,d.timer||d.tolerate(e);break;case"mouseup":case"touchend":d.timer=clearTimeout(d.timer),e.propagates&&(c.drag.hijack(b,"drop",e),c.drag.hijack(b,"dropend",e))}},locate:function(b,c){var e=a.data(b,d.datakey),f=a(b),g=f.offset()||{},h=f.outerHeight(),i=f.outerWidth(),j={elem:b,width:i,height:h,top:g.top,left:g.left,right:g.left+i,bottom:g.top+h};return e&&(e.location=j,e.index=c,e.elem=b),j},contains:function(a,b){return(b[0]||b.left)>=a.left&&(b[0]||b.right)<=a.right&&(b[1]||b.top)>=a.top&&(b[1]||b.bottom)<=a.bottom},modes:{intersect:function(a,b,c){return this.contains(c,[a.pageX,a.pageY])?1e9:this.modes.overlap.apply(this,arguments)},overlap:function(a,b,c){return Math.max(0,Math.min(c.bottom,b.bottom)-Math.max(c.top,b.top))*Math.max(0,Math.min(c.right,b.right)-Math.max(c.left,b.left))},fit:function(a,b,c){return this.contains(c,b)?1:0},middle:function(a,b,c){return this.contains(c,[b.left+.5*b.width,b.top+.5*b.height])?1:0}},sort:function(a,b){return b.winner-a.winner||a.index-b.index},tolerate:function(b){var e,f,g,h,i,j,k,l,m=0,n=b.interactions.length,o=[d.event.pageX,d.event.pageY],p=d.tolerance||d.modes[d.mode];do if(l=b.interactions[m]){if(!l)return;l.drop=[],i=[],j=l.droppable.length,p&&(g=d.locate(l.proxy)),e=0;do if(k=l.droppable[e]){if(h=a.data(k,d.datakey),f=h.location,!f)continue;h.winner=p?p.call(d,d.event,g,f):d.contains(f,o)?1:0,i.push(h)}while(++e=k?h():g.set(l/k)),a):(f.error("Broken interceptor detected: Config object not supplied in response:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),a)},responseError:function(a){return a&&a.config?(a.config.ignoreLoadingBar||i(a.config)||(l++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url,result:a}),l>=k?h():g.set(l/k)),b.reject(a)):(f.error("Broken interceptor detected: Config object not supplied in rejection:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),b.reject(a))}}}];a.interceptors.push(b)}]),angular.module("cfp.loadingBar",[]).provider("cfpLoadingBar",function(){this.autoIncrement=!0,this.includeSpinner=!0,this.includeBar=!0,this.latencyThreshold=100,this.startSize=.02,this.parentSelector="#body",this.spinnerTemplate='',this.loadingBarTemplate='',this.$get=["$injector","$document","$timeout","$rootScope",function(a,b,c,d){function e(){k||(k=a.get("$animate"));var e=b.find(n).eq(0);c.cancel(m),r||(d.$broadcast("cfpLoadingBar:started"),r=!0,v&&k.enter(o,e,angular.element(e[0].lastChild)),u&&k.enter(q,e,angular.element(e[0].lastChild)),f(w))}function f(a){if(r){var b=100*a+"%";p.css("width",b),s=a,t&&(c.cancel(l),l=c(function(){g()},250))}}function g(){if(!(h()>=1)){var a=0,b=h();a=b>=0&&.25>b?(3*Math.random()+3)/100:b>=.25&&.65>b?3*Math.random()/100:b>=.65&&.9>b?2*Math.random()/100:b>=.9&&.99>b?.005:0;var c=h()+a;f(c)}}function h(){return s}function i(){s=0,r=!1}function j(){k||(k=a.get("$animate")),d.$broadcast("cfpLoadingBar:completed"),f(1),c.cancel(m),m=c(function(){var a=k.leave(o,i);a&&a.then&&a.then(i),k.leave(q)},500)}var k,l,m,n=this.parentSelector,o=angular.element(this.loadingBarTemplate),p=o.find("div").eq(0),q=angular.element(this.spinnerTemplate),r=!1,s=0,t=this.autoIncrement,u=this.includeSpinner,v=this.includeBar,w=this.startSize;return{start:e,set:f,status:h,inc:g,complete:j,autoIncrement:this.autoIncrement,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector,startSize:this.startSize}}]})}(),!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.Mopidy=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0)for(d=0;e>d;++d)c[d](a,b);else setTimeout(function(){throw b.message=a+" listener threw error: "+b.message,b},0)}function b(a){if("function"!=typeof a)throw new TypeError("Listener is not function");return a}function c(a){return a.supervisors||(a.supervisors=[]),a.supervisors}function d(a,b){return a.listeners||(a.listeners={}),b&&!a.listeners[b]&&(a.listeners[b]=[]),b?a.listeners[b]:a.listeners}function e(a){return a.errbacks||(a.errbacks=[]),a.errbacks}function f(f){function h(b,c,d){try{c.listener.apply(c.thisp||f,d)}catch(g){a(b,g,e(f))}}return f=f||{},f.on=function(a,e,f){return"function"==typeof a?c(this).push({listener:a,thisp:e}):void d(this,a).push({listener:b(e),thisp:f})},f.off=function(a,b){var f,g,h,i;if(!a){f=c(this),f.splice(0,f.length),g=d(this);for(h in g)g.hasOwnProperty(h)&&(f=d(this,h),f.splice(0,f.length));return f=e(this),void f.splice(0,f.length)}if("function"==typeof a?(f=c(this),b=a):f=d(this,a),!b)return void f.splice(0,f.length);for(h=0,i=f.length;i>h;++h)if(f[h].listener===b)return void f.splice(h,1)},f.once=function(a,b,c){var d=function(){f.off(a,d),b.apply(this,arguments)};f.on(a,d,c)},f.bind=function(a,b){var c,d,e;if(b)for(d=0,e=b.length;e>d;++d){if("function"!=typeof a[b[d]])throw new Error("No such method "+b[d]);this.on(b[d],a[b[d]],a)}else for(c in a)"function"==typeof a[c]&&this.on(c,a[c],a);return a},f.emit=function(a){var b,e,f=c(this),i=g.call(arguments);for(b=0,e=f.length;e>b;++b)h(a,f[b],i);for(f=d(this,a).slice(),i=g.call(arguments,1),b=0,e=f.length;e>b;++b)h(a,f[b],i)},f.errback=function(a){this.errbacks||(this.errbacks=[]),this.errbacks.push(b(a))},f}var g=Array.prototype.slice;return{createEventEmitter:f,aggregate:function(a){var b=f();return a.forEach(function(a){a.on(function(a,c){b.emit(a,c)})}),b}}})},{}],3:[function(a,b){function c(){}var d=b.exports={};d.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),d.title="browser",d.browser=!0,d.env={},d.argv=[],d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(b,c){!function(a){"use strict";a(function(a){var b=a("./makePromise"),c=a("./Scheduler"),d=a("./env").asap;return b({scheduler:new c(d)})})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"./Scheduler":5,"./env":17,"./makePromise":19}],5:[function(b,c){!function(a){"use strict";a(function(){function a(a){this._async=a,this._running=!1,this._queue=this,this._queueLen=0,this._afterQueue={},this._afterQueueLen=0;var b=this;this.drain=function(){b._drain()}}return a.prototype.enqueue=function(a){this._queue[this._queueLen++]=a,this.run()},a.prototype.afterQueue=function(a){this._afterQueue[this._afterQueueLen++]=a,this.run()},a.prototype.run=function(){this._running||(this._running=!0,this._async(this.drain))},a.prototype._drain=function(){for(var a=0;a>>0,j=i,k=[],l=0;i>l;++l)if(f=b[l],void 0!==f||l in b){if(e=a._handler(f),e.state()>0){h.become(e),a._visitRemaining(b,l,e);break}e.visit(h,c,d)}else--j;return 0===j&&h.reject(new RangeError("any(): array must not be empty")),g}function e(b,c){function d(a){this.resolved||(k.push(a),0===--n&&(l=null,this.resolve(k)))}function e(a){this.resolved||(l.push(a),0===--f&&(k=null,this.reject(l)))}var f,g,h,i=a._defer(),j=i._handler,k=[],l=[],m=b.length>>>0,n=0;for(h=0;m>h;++h)g=b[h],(void 0!==g||h in b)&&++n;for(c=Math.max(c,0),f=n-c+1,n=Math.min(c,n),c>n?j.reject(new RangeError("some(): array must contain at least "+c+" item(s), but had "+n)):0===n&&j.resolve(k),h=0;m>h;++h)g=b[h],(void 0!==g||h in b)&&a._handler(g).visit(j,d,e,j.notify);return i}function f(b,c){return a._traverse(c,b)}function g(b,c){var d=s.call(b);return a._traverse(c,d).then(function(a){return h(d,a)})}function h(b,c){for(var d=c.length,e=new Array(d),f=0,g=0;d>f;++f)c[f]&&(e[g++]=a._handler(b[f]).value);return e.length=g,e}function i(a){return p(a.map(j))}function j(c){var d=a._handler(c);return 0===d.state()?o(c).then(b.fulfilled,b.rejected):(d._unreport(),b.inspect(d))}function k(a,b){return arguments.length>2?q.call(a,m(b),arguments[2]):q.call(a,m(b))}function l(a,b){return arguments.length>2?r.call(a,m(b),arguments[2]):r.call(a,m(b))}function m(a){return function(b,c,d){return n(a,void 0,[b,c,d])}}var n=c(a),o=a.resolve,p=a.all,q=Array.prototype.reduce,r=Array.prototype.reduceRight,s=Array.prototype.slice;return a.any=d,a.some=e,a.settle=i,a.map=f,a.filter=g,a.reduce=k,a.reduceRight=l,a.prototype.spread=function(a){return this.then(p).then(function(b){return a.apply(this,b)})},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../apply":7,"../state":20}],9:[function(b,c){!function(a){"use strict";a(function(){function a(){throw new TypeError("catch predicate must be a function")}function b(a,b){return c(b)?a instanceof b:b(a)}function c(a){return a===Error||null!=a&&a.prototype instanceof Error}function d(a){return("object"==typeof a||"function"==typeof a)&&null!==a}function e(a){return a}return function(c){function f(a,c){return function(d){return b(d,c)?a.call(this,d):j(d)}}function g(a,b,c,e){var f=a.call(b);return d(f)?h(f,c,e):c(e)}function h(a,b,c){return i(a).then(function(){return b(c)})}var i=c.resolve,j=c.reject,k=c.prototype["catch"];return c.prototype.done=function(a,b){this._handler.visit(this._handler.receiver,a,b)},c.prototype["catch"]=c.prototype.otherwise=function(b){return arguments.length<2?k.call(this,b):"function"!=typeof b?this.ensure(a):k.call(this,f(arguments[1],b))},c.prototype["finally"]=c.prototype.ensure=function(a){return"function"!=typeof a?this:this.then(function(b){return g(a,this,e,b)},function(b){return g(a,this,j,b)})},c.prototype["else"]=c.prototype.orElse=function(a){return this.then(void 0,function(){return a})},c.prototype["yield"]=function(a){return this.then(function(){return a})},c.prototype.tap=function(a){return this.then(a)["yield"](this)},c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],10:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype.fold=function(b,c){var d=this._beget();return this._handler.fold(function(c,d,e){a._handler(c).fold(function(a,c,d){d.resolve(b.call(this,c,a))},d,this,e)},c,d._handler.receiver,d._handler),d},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],11:[function(b,c){!function(a){"use strict";a(function(a){var b=a("../state").inspect;return function(a){return a.prototype.inspect=function(){return b(a._handler(this))},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../state":20}],12:[function(b,c){!function(a){"use strict";a(function(){return function(a){function b(a,b,d,e){return c(function(b){return[b,a(b)]},b,d,e)}function c(a,b,e,f){function g(f,g){return d(e(f)).then(function(){return c(a,b,e,g)})}return d(f).then(function(c){return d(b(c)).then(function(b){return b?c:d(a(c)).spread(g)})})}var d=a.resolve;return a.iterate=b,a.unfold=c,a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],13:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype.progress=function(a){return this.then(void 0,void 0,a)},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],14:[function(b,c){!function(a){"use strict";a(function(a){function b(a,b,d,e){return c.setTimer(function(){a(d,e,b)},b)}var c=a("../env"),d=a("../TimeoutError");return function(a){function e(a,c,d){b(f,a,c,d)}function f(a,b){b.resolve(a)}function g(a,b,c){var e="undefined"==typeof a?new d("timed out after "+c+"ms"):a;b.reject(e)}return a.prototype.delay=function(a){var b=this._beget();return this._handler.fold(e,a,void 0,b._handler),b},a.prototype.timeout=function(a,d){var e=this._beget(),f=e._handler,h=b(g,a,d,e._handler);return this._handler.visit(f,function(a){c.clearTimer(h),this.resolve(a)},function(a){c.clearTimer(h),this.reject(a)},f.notify),e},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../TimeoutError":6,"../env":17}],15:[function(b,c){!function(a){"use strict";a(function(a){function b(a){throw a}function c(){}var d=a("../env").setTimer,e=a("../format");return function(a){function f(a){a.handled||(n.push(a),k("Potentially unhandled rejection ["+a.id+"] "+e.formatError(a.value)))}function g(a){var b=n.indexOf(a);b>=0&&(n.splice(b,1),l("Handled previous rejection ["+a.id+"] "+e.formatObject(a.value)))}function h(a,b){m.push(a,b),null===o&&(o=d(i,0))}function i(){for(o=null;m.length>0;)m.shift()(m.shift())}var j,k=c,l=c;"undefined"!=typeof console&&(j=console,k="undefined"!=typeof j.error?function(a){j.error(a)}:function(a){j.log(a)},l="undefined"!=typeof j.info?function(a){j.info(a)}:function(a){j.log(a)}),a.onPotentiallyUnhandledRejection=function(a){h(f,a)},a.onPotentiallyUnhandledRejectionHandled=function(a){h(g,a)},a.onFatalRejection=function(a){h(b,a.value)};var m=[],n=[],o=null;return a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../env":17,"../format":18}],16:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype["with"]=a.prototype.withThis=function(a){var b=this._beget(),c=b._handler;return c.receiver=a,this._handler.chain(c,a),b},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],17:[function(b,c){(function(d){!function(a){"use strict";a(function(a){function b(){return"undefined"!=typeof d&&null!==d&&"function"==typeof d.nextTick}function c(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function e(a){function b(){var a=c;c=void 0,a()}var c,d=document.createTextNode(""),e=new a(b);e.observe(d,{characterData:!0});var f=0;return function(a){c=a,d.data=f^=1}}var f,g="undefined"!=typeof setTimeout&&setTimeout,h=function(a,b){return setTimeout(a,b)},i=function(a){return clearTimeout(a)},j=function(a){return g(a,0)};if(b())j=function(a){return d.nextTick(a)};else if(f=c())j=e(f);else if(!g){var k=a,l=k("vertx");h=function(a,b){return l.setTimer(b,a)},i=l.cancelTimer,j=l.runOnLoop||l.runOnContext}return{setTimer:h,clearTimer:i,asap:j}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})}).call(this,b("FWaASH"))},{FWaASH:3}],18:[function(b,c){!function(a){"use strict";a(function(){function a(a){var c="object"==typeof a&&null!==a&&a.stack?a.stack:b(a);return a instanceof Error?c:c+" (WARNING: non-Error used)"}function b(a){var b=String(a);return"[object Object]"===b&&"undefined"!=typeof JSON&&(b=c(a,b)),b}function c(a,b){try{return JSON.stringify(a)}catch(c){return b}}return{formatError:a,formatObject:b,tryStringify:c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],19:[function(b,c){(function(b){!function(a){"use strict";a(function(){return function(a){function c(a,b){this._handler=a===u?b:d(a)}function d(a){function b(a){e.resolve(a)}function c(a){e.reject(a)}function d(a){e.notify(a)}var e=new w;try{a(b,c,d)}catch(f){c(f)}return e}function e(a){return J(a)?a:new c(u,new x(r(a)))}function f(a){return new c(u,new x(new A(a)))}function g(){return aa}function h(){return new c(u,new w)}function i(a,b){var c=new w(a.receiver,a.join().context);return new b(u,c)}function j(a){return l(T,null,a)}function k(a,b){return l(O,a,b)}function l(a,b,d){function e(c,e,g){g.resolved||m(d,f,c,a(b,e,c),g)}function f(a,b,c){k[a]=b,0===--j&&c.become(new z(k))}for(var g,h="function"==typeof b?e:f,i=new w,j=d.length>>>0,k=new Array(j),l=0;l0?b(c,f.value,e):(e.become(f),n(a,c+1,f))}else b(c,d,e)}function n(a,b,c){for(var d=b;dc&&a._unreport()}}function p(a){return"object"!=typeof a||null===a?f(new TypeError("non-iterable passed to race()")):0===a.length?g():1===a.length?e(a[0]):q(a)}function q(a){var b,d,e,f=new w;for(b=0;b0||"function"!=typeof b&&0>e)return new this.constructor(u,d);var f=this._beget(),g=f._handler;return d.chain(g,d.receiver,a,b,c),f},c.prototype["catch"]=function(a){return this.then(void 0,a)},c.prototype._beget=function(){return i(this._handler,this.constructor)},c.all=j,c.race=p,c._traverse=k,c._visitRemaining=n,u.prototype.when=u.prototype.become=u.prototype.notify=u.prototype.fail=u.prototype._unreport=u.prototype._report=U,u.prototype._state=0,u.prototype.state=function(){return this._state},u.prototype.join=function(){for(var a=this;void 0!==a.handler;)a=a.handler;return a},u.prototype.chain=function(a,b,c,d,e){this.when({resolver:a,receiver:b,fulfilled:c,rejected:d,progress:e})},u.prototype.visit=function(a,b,c,d){this.chain(Z,a,b,c,d)},u.prototype.fold=function(a,b,c,d){this.when(new I(a,b,c,d))},S(u,v),v.prototype.become=function(a){a.fail()};var Z=new v;S(u,w),w.prototype._state=0,w.prototype.resolve=function(a){this.become(r(a))},w.prototype.reject=function(a){this.resolved||this.become(new A(a))},w.prototype.join=function(){if(!this.resolved)return this;for(var a=this;void 0!==a.handler;)if(a=a.handler,a===this)return this.handler=D();return a},w.prototype.run=function(){var a=this.consumers,b=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var c=0;c0?c(d.value):b(d.value)}return{pending:a,fulfilled:c,rejected:b,inspect:d}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],21:[function(b,c){!function(a){"use strict";a(function(a){function b(a,b,c,d){var e=x.resolve(a);return arguments.length<2?e:e.then(b,c,d)}function c(a){return new x(a)}function d(a){return function(){for(var b=0,c=arguments.length,d=new Array(c);c>b;++b)d[b]=arguments[b];return y(a,this,d)}}function e(a){for(var b=0,c=arguments.length-1,d=new Array(c);c>b;++b)d[b]=arguments[b+1];return y(a,this,d)}function f(){return new g}function g(){function a(a){d._handler.resolve(a)}function b(a){d._handler.reject(a)}function c(a){d._handler.notify(a)}var d=x._defer();this.promise=d,this.resolve=a,this.reject=b,this.notify=c,this.resolver={resolve:a,reject:b,notify:c}}function h(a){return a&&"function"==typeof a.then}function i(){return x.all(arguments)}function j(a){return b(a,x.all)}function k(a){return b(a,x.settle)}function l(a,c){return b(a,function(a){return x.map(a,c)})}function m(a,c){return b(a,function(a){return x.filter(a,c)})}var n=a("./lib/decorators/timed"),o=a("./lib/decorators/array"),p=a("./lib/decorators/flow"),q=a("./lib/decorators/fold"),r=a("./lib/decorators/inspect"),s=a("./lib/decorators/iterate"),t=a("./lib/decorators/progress"),u=a("./lib/decorators/with"),v=a("./lib/decorators/unhandledRejection"),w=a("./lib/TimeoutError"),x=[o,p,q,s,t,r,u,n,v].reduce(function(a,b){return b(a)},a("./lib/Promise")),y=a("./lib/apply")(x);return b.promise=c,b.resolve=x.resolve,b.reject=x.reject,b.lift=d,b["try"]=e,b.attempt=e,b.iterate=x.iterate,b.unfold=x.unfold,b.join=i,b.all=j,b.settle=k,b.any=d(x.any),b.some=d(x.some),b.race=d(x.race),b.map=l,b.filter=m,b.reduce=d(x.reduce),b.reduceRight=d(x.reduceRight),b.isPromiseLike=h,b.Promise=x,b.defer=f,b.TimeoutError=w,b})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"./lib/Promise":4,"./lib/TimeoutError":6,"./lib/apply":7,"./lib/decorators/array":8,"./lib/decorators/flow":9,"./lib/decorators/fold":10,"./lib/decorators/inspect":11,"./lib/decorators/iterate":12,"./lib/decorators/progress":13,"./lib/decorators/timed":14,"./lib/decorators/unhandledRejection":15,"./lib/decorators/with":16}],22:[function(a,b){function c(a){return this instanceof c?(this._console=this._getConsole(a||{}),this._settings=this._configure(a||{}),this._backoffDelay=this._settings.backoffDelayMin,this._pendingRequests={},this._webSocket=null,d.createEventEmitter(this),this._delegateEvents(),void(this._settings.autoConnect&&this.connect())):new c(a)}var d=a("bane"),e=a("../lib/websocket/"),f=a("when");c.ConnectionError=function(a){this.name="ConnectionError",this.message=a},c.ConnectionError.prototype=Object.create(Error.prototype),c.ConnectionError.prototype.constructor=c.ConnectionError,c.ServerError=function(a){this.name="ServerError",this.message=a},c.ServerError.prototype=Object.create(Error.prototype),c.ServerError.prototype.constructor=c.ServerError,c.WebSocket=e.Client,c.when=f,c.prototype._getConsole=function(a){if("undefined"!=typeof a.console)return a.console;var b="undefined"!=typeof console&&console||{};return b.log=b.log||function(){},b.warn=b.warn||function(){},b.error=b.error||function(){},b},c.prototype._configure=function(a){var b="undefined"!=typeof document&&"https:"===document.location.protocol?"wss://":"ws://",c="undefined"!=typeof document&&document.location.host||"localhost";return a.webSocketUrl=a.webSocketUrl||b+c+"/mopidy/ws",a.autoConnect!==!1&&(a.autoConnect=!0),a.backoffDelayMin=a.backoffDelayMin||1e3,a.backoffDelayMax=a.backoffDelayMax||64e3,"undefined"==typeof a.callingConvention&&this._console.warn("Mopidy.js is using the default calling convention. The default will change in the future. You should explicitly specify which calling convention you use."),a.callingConvention=a.callingConvention||"by-position-only",a},c.prototype._delegateEvents=function(){this.off("websocket:close"),this.off("websocket:error"),this.off("websocket:incomingMessage"),this.off("websocket:open"),this.off("state:offline"),this.on("websocket:close",this._cleanup),this.on("websocket:error",this._handleWebSocketError),this.on("websocket:incomingMessage",this._handleMessage),this.on("websocket:open",this._resetBackoffDelay),this.on("websocket:open",this._getApiSpec),this.on("state:offline",this._reconnect)},c.prototype.connect=function(){if(this._webSocket){if(this._webSocket.readyState===c.WebSocket.OPEN)return;this._webSocket.close()}this._webSocket=this._settings.webSocket||new c.WebSocket(this._settings.webSocketUrl),this._webSocket.onclose=function(a){this.emit("websocket:close",a)}.bind(this),this._webSocket.onerror=function(a){this.emit("websocket:error",a)}.bind(this),this._webSocket.onopen=function(){this.emit("websocket:open")}.bind(this),this._webSocket.onmessage=function(a){this.emit("websocket:incomingMessage",a)}.bind(this)},c.prototype._cleanup=function(a){Object.keys(this._pendingRequests).forEach(function(b){var d=this._pendingRequests[b];delete this._pendingRequests[b];var e=new c.ConnectionError("WebSocket closed");e.closeEvent=a,d.reject(e)}.bind(this)),this.emit("state:offline")},c.prototype._reconnect=function(){this.emit("reconnectionPending",{timeToAttempt:this._backoffDelay}),setTimeout(function(){this.emit("reconnecting"),this.connect()}.bind(this),this._backoffDelay),this._backoffDelay=2*this._backoffDelay,this._backoffDelay>this._settings.backoffDelayMax&&(this._backoffDelay=this._settings.backoffDelayMax)},c.prototype._resetBackoffDelay=function(){this._backoffDelay=this._settings.backoffDelayMin},c.prototype.close=function(){this.off("state:offline",this._reconnect),this._webSocket.close()},c.prototype._handleWebSocketError=function(a){this._console.warn("WebSocket error:",a.stack||a)},c.prototype._send=function(a){switch(this._webSocket.readyState){case c.WebSocket.CONNECTING:return f.reject(new c.ConnectionError("WebSocket is still connecting"));case c.WebSocket.CLOSING:return f.reject(new c.ConnectionError("WebSocket is closing"));case c.WebSocket.CLOSED:return f.reject(new c.ConnectionError("WebSocket is closed"));default:var b=f.defer();return a.jsonrpc="2.0",a.id=this._nextRequestId(),this._pendingRequests[a.id]=b.resolver,this._webSocket.send(JSON.stringify(a)),this.emit("websocket:outgoingMessage",a),b.promise}},c.prototype._nextRequestId=function(){var a=-1;return function(){return a+=1}}(),c.prototype._handleMessage=function(a){try{var b=JSON.parse(a.data);b.hasOwnProperty("id")?this._handleResponse(b):b.hasOwnProperty("event")?this._handleEvent(b):this._console.warn("Unknown message type received. Message was: "+a.data)}catch(c){if(!(c instanceof SyntaxError))throw c;this._console.warn("WebSocket message parsing failed. Message was: "+a.data)}},c.prototype._handleResponse=function(a){if(!this._pendingRequests.hasOwnProperty(a.id))return void this._console.warn("Unexpected response received. Message was:",a);var b,d=this._pendingRequests[a.id];delete this._pendingRequests[a.id],a.hasOwnProperty("result")?d.resolve(a.result):a.hasOwnProperty("error")?(b=new c.ServerError(a.error.message),b.code=a.error.code,b.data=a.error.data,d.reject(b),this._console.warn("Server returned error:",a.error)):(b=new Error("Response without 'result' or 'error' received"),b.data={response:a},d.reject(b),this._console.warn("Response without 'result' or 'error' received. Message was:",a))},c.prototype._handleEvent=function(a){var b=a.event,c=a;delete c.event,this.emit("event:"+this._snakeToCamel(b),c)},c.prototype._getApiSpec=function(){return this._send({method:"core.describe"}).then(this._createApi.bind(this))["catch"](this._handleWebSocketError)},c.prototype._createApi=function(a){var b="by-position-or-by-name"===this._settings.callingConvention,c=function(a){return function(){var c={method:a};return 0===arguments.length?this._send(c):b?arguments.length>1?f.reject(new Error("Expected zero arguments, a single array, or a single object.")):Array.isArray(arguments[0])||arguments[0]===Object(arguments[0])?(c.params=arguments[0],this._send(c)):f.reject(new TypeError("Expected an array or an object.")):(c.params=Array.prototype.slice.call(arguments),this._send(c))}.bind(this)}.bind(this),d=function(a){var b=a.split(".");return b.length>=1&&"core"===b[0]&&(b=b.slice(1)),b},e=function(a){var b=this;return a.forEach(function(a){a=this._snakeToCamel(a),b[a]=b[a]||{},b=b[a]}.bind(this)),b}.bind(this),g=function(b){var f=d(b),g=this._snakeToCamel(f.slice(-1)[0]),h=e(f.slice(0,-1));h[g]=c(b),h[g].description=a[b].description,h[g].params=a[b].params}.bind(this);Object.keys(a).forEach(g),this.emit("state:online")},c.prototype._snakeToCamel=function(a){return a.replace(/(_[a-z])/g,function(a){return a.toUpperCase().replace("_","")})},b.exports=c},{"../lib/websocket/":1,bane:2,when:21}]},{},[22])(22)}),angular.module("spotmop",["ngResource","ngStorage","ngTouch","ui.router","angular-loading-bar","angular-google-analytics","spotmop.directives","spotmop.common.contextmenu","spotmop.common.tracklist","spotmop.services.notify","spotmop.services.settings","spotmop.services.player","spotmop.services.spotify","spotmop.services.mopidy","spotmop.services.echonest","spotmop.services.lastfm","spotmop.services.dialog","spotmop.services.pusher","spotmop.player","spotmop.queue","spotmop.library","spotmop.search","spotmop.settings","spotmop.discover","spotmop.browse","spotmop.browse.artist","spotmop.browse.album","spotmop.browse.playlist","spotmop.browse.user","spotmop.browse.genre","spotmop.browse.featured","spotmop.browse.new"]).config(["$stateProvider","$locationProvider","$urlRouterProvider","$httpProvider","AnalyticsProvider",function(a,b,c,d,e){c.otherwise("queue"),d.interceptors.push("SpotifyServiceIntercepter"),e.useAnalytics(!0),e.setAccount("UA-64701652-3")}]).run(["$rootScope","SettingsService","Analytics",function(a,b,c){}]).controller("ApplicationController",["$scope","$rootScope","$state","$localStorage","$timeout","$location","SpotifyService","MopidyService","EchonestService","PlayerService","SettingsService","NotifyService","PusherService","DialogService","Analytics",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){function p(a){var b=null;return $(a).hasClass("droppable")?b=$(a):$(a).closest(".droppable").length>0&&(b=$(a).closest(".droppable")),b}function q(a){var b=null;return $(a).hasClass("track")?b=$(a):$(a).closest(".track").length>0&&(b=$(a).closest(".track")),b}o.trackEvent("Spotmop","Started"),a.isTouchDevice=function(){return k.getSetting("emulateTouchDevice",!1)?!0:!!("ontouchstart"in window)},a.isSameDomainAsMopidy=function(){var a=k.getSetting("mopidyhost","localhost");return a&&"localhost"!=a?f.host()==a?!0:void 0:!0},a.state=j.state,a.currentTracklist=[],a.spotifyUser={},a.menuCollapsable=!1,a.reloadApp=function(){window.location.reload()},a.playlistsMenu=[],a.myPlaylists={},a.popupVolumeControls=function(){n.create("volumeControls",a)},$(document).on("mouseenter",".playlists-submenu-trigger",function(a){$(document).find(".menu-item.top-level.playlists").addClass("show-submenu")}),$(document).on("mouseleave",".menu-item.top-level.playlists",function(a){$(document).find(".menu-item.top-level.playlists").removeClass("show-submenu")}),a.updatePlaylists=function(b){g.getPlaylists(b,50).then(function(b){a.myPlaylists=b.items;var c=[];$.each(b.items,function(b,d){if(d.owner.id==a.spotifyUser.id){var e=d;e.link="/browse/playlist/"+d.uri,e.link="/browse/playlist/"+d.uri,c.push(e)}}),a.playlistsMenu=c})},a.windowWidth=$(document).width(),a.windowHeight=$(document).height(),a.mediumScreen=function(){return a.windowWidth<=800?!0:!1},a.smallScreen=function(){return a.windowWidth<=450?!0:!1},$(window).resize(function(){$(document).width()!=a.windowWidth&&(a.windowWidth=$(document).width(),$(document).find("body").removeClass("menu-revealed"))}),b.$on("$stateChangeStart",function(b){a.hideMenu(),o.trackPage(f.path())}),$(document).on("click","#body",function(b){$(b.target).closest(".menu-reveal-trigger").length<=0&&a.hideMenu()}),a.showMenu=function(){$(document).find("body").addClass("menu-revealed")},a.hideMenu=function(){$(document).find("body").removeClass("menu-revealed")},a.searchSubmit=function(a){o.trackEvent("Search","Performed search",a);var b=g.uriType(a);b?(l.notify("You've been redirected because that looked like a Spotify URI"),"artist"==b?($(document).find(".search-form input").val(""),c.go("browse.artist.overview",{uri:a})):"album"==b?($(document).find(".search-form input").val(""),c.go("browse.album",{uri:a})):"playlist"==b&&($(document).find(".search-form input").val(""),c.go("browse.playlist",{uri:a}))):c.go("search",{query:a})},a.linkingMode=function(a){var b="";return $.isArray(a)||(a=[a]),angular.forEach(a,function(a){""==b&&(c.is(a)?b="active":c.includes(a)&&(b="section"))}),b},a.$on("mopidy:state:online",function(){o.trackEvent("Mopidy","Online"),b.mopidyOnline=!0,h.getCurrentTlTracks().then(function(b){a.currentTracklist=b}),h.getConsume().then(function(a){k.setSetting("mopidyconsume",a)})}),a.$on("mopidy:state:offline",function(){b.mopidyOnline=!1}),b.spotifyAuthorized=!1,a.$on("spotmop:spotify:authenticationChanged",function(c,d){"client"==d?(b.spotifyAuthorized=!0,a.spotifyUser=k.getSetting("spotifyuser"),a.updatePlaylists(a.spotifyUser.id),o.trackEvent("Spotify","Authorized",a.spotifyUser.id)):(b.spotifyAuthorized=!1,a.playlistsMenu=[])}),a.$on("spotmop:spotify:online",function(){b.spotifyOnline=!0,b.spotifyAuthorized&&(a.spotifyUser=k.getSetting("spotifyuser"),a.updatePlaylists(a.spotifyUser.id))}),a.$on("spotmop:spotify:offline",function(){a.playlistsMenu=[],b.spotifyOnline=!1}),m.start(),b.$on("spotmop:pusher:online",function(b,c){var d=k.getSetting("pushername",null);"undefined"!=typeof d&&d&&""!=d||(n.create("initialsetup",a),o.trackEvent("Core","Initial setup"))}),b.$on("spotmop:pusher:received",function(a,b){var c="";b.spotifyuser=JSON.parse(b.spotifyuser),"undefined"!=typeof b.spotifyuser.images&&b.spotifyuser.images.length>0&&(c=b.spotifyuser.images[0].url),l.browserNotify(b.title,b.body,c),o.trackEvent("Pusher","Notification received",b.body)}),b.$on("mopidy:event:trackPlaybackEnded",function(a,b){k.getSetting("echonestenabled",!1)&&i.addToTasteProfile("play",b.tl_track.track.uri)}),h.start(),g.start(),k.getSetting("echonestenabled",!1)&&i.start(),b.shiftKeyHeld=!1,b.ctrlKeyHeld=!1,$("body").bind("keydown",function(a){if(16===a.which?b.shiftKeyHeld=!0:17===a.which&&(b.ctrlKeyHeld=!0),!$(document).find(":focus").is(":input")&&k.getSetting("keyboardShortcutsEnabled",!1)){var c=new Array(46,32,13,37,38,39,40,27);$.inArray(a.which,c)>-1&&a.preventDefault()}}).bind("keyup",function(a){!$(document).find(":focus").is(":input")&&k.getSetting("keyboardShortcutsEnabled",!1)&&(46===a.which&&b.$broadcast("spotmop:keyboardShortcut:delete"),32===a.which&&b.$broadcast("spotmop:keyboardShortcut:space"),13===a.which&&b.$broadcast("spotmop:keyboardShortcut:enter"),37===a.which&&b.$broadcast("spotmop:keyboardShortcut:left"),38===a.which&&b.$broadcast("spotmop:keyboardShortcut:up"),39===a.which&&b.$broadcast("spotmop:keyboardShortcut:right"),40===a.which&&b.$broadcast("spotmop:keyboardShortcut:down"),27===a.which&&(b.$broadcast("spotmop:keyboardShortcut:esc"),r&&(r=!1,$(document).find(".drag-tracer").hide()))),16===a.which&&(b.shiftKeyHeld=!1),17===a.which&&(b.ctrlKeyHeld=!1)}),$(document).on("mouseup","body",function(a){$(a.target).closest(".tracklist").length<=0&&b.$broadcast("spotmop:contextMenu:hide")});var r=!1,s=30;$(document).on("mousedown","body:not(.touchDevice) track, body:not(.touchDevice) tltrack",function(a){var b=$(a.currentTarget).closest(".tracklist"),c=b.find(".track.selected");r={safetyOff:!1,clientX:a.clientX,clientY:a.clientY,tracks:c}}),$(document).on("mouseup",function(b){if("undefined"!=typeof r&&r.safetyOff){$("body").removeClass("dragging"),$(document).find(".droppable").removeClass("dropping"),$(document).find(".drag-hovering").removeClass("drag-hovering");var c=p(b.target),d=q(b.target),e=!1;if(c&&c.closest(".main-menu").length>0&&(e=!0),c){$(document).find(".drag-tracer").html("Dropping...").fadeOut("fast"),$(document).find(".track.drag-hovering").removeClass("drag-hovering");var f=[];if($.each(r.tracks,function(a,b){f.push($(b).attr("data-uri"))}),e&&"queue"===c.attr("data-type"))f.length>10&&l.notify("Adding "+f.length+" track(s) to queue... this could take some time"),h.addToTrackList(f);else if(e&&"library"===c.attr("data-type")){var i=new Array;$.each(f,function(a,b){i.push(g.getFromUri("trackid",b))}),g.addTracksToLibrary(i)}else if(e&&"playlist"===c.attr("data-type"))g.addTracksToPlaylist(c.attr("data-uri"),f);else if(d){var j=1e3,k=0,m=$(d).parent().index();if($.each(r.tracks,function(a,b){$(b).parent().index()k&&(k=$(b).parent().index())}),d.closest(".tracklist").hasClass("queue-items"))m>=k&&(m-=f.length),h.moveTlTracks(j,k+1,m);else if(d.closest(".tracklist").hasClass("playlist-items")){var n=1;k>j&&(n=k-j,n++),a.$broadcast("spotmop:playlist:reorder",j,n,m)}}}else $(document).find(".drag-tracer").fadeOut("medium")}r=!1}),$(document).on("mousemove",function(a){if(r){var b=r.clientX-s,c=r.clientX+s,d=r.clientY-s,e=r.clientY+s;if(a.clientXc||a.clientYe){$("body").addClass("dragging"),$(document).find(".track.drag-hovering").removeClass("drag-hovering");var f=p(a.target),g=q(a.target),h=$(document).find(".drag-tracer");g&&g.addClass("drag-hovering"),r.safetyOff=!0,h.show(),$(document).find(".droppable").removeClass("dropping"),$(document).find(".dropping-within").removeClass("dropping-within");var i=!1;f&&f.closest(".main-menu").length>0&&(i=!0),f&&i&&"queue"===f.attr("data-type")?f.addClass("dropping"):f&&i&&"library"===f.attr("data-type")?f.addClass("dropping"):f&&i&&"playlists"===f.attr("data-type")?(f.closest(".menu-item.playlists").addClass("dropping-within"),f.addClass("dropping")):f&&i&&"playlist"===f.attr("data-type")?(f.addClass("dropping"),f.closest(".menu-item.playlists").addClass("dropping-within")):h.html("Dragging "+r.tracks.length+" track(s)")}}})}]),angular.module("spotmop.browse.album",[]).config(["$stateProvider",function(a){a.state("browse.album",{url:"/album/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("AlbumController",["$scope","$rootScope","$stateParams","$filter","MopidyService","SpotifyService",function(a,b,c,d,e,f){function g(b){return"undefined"==typeof b?!1:(h=!0,void f.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(b.items),a.tracklist.next=b.next,h=!1}))}a.album={},a.tracklist={type:"track"},a.convertedDate=function(){return a.mediumScreen()?d("date")(a.album.release_date,"yyyy"):"day"==a.album.release_date_precision?d("date")(a.album.release_date,"MMMM d, yyyy"):"month"==a.album.release_date_precision?d("date")(a.album.release_date,"MMMM yyyy"):"year"==a.album.release_date_precision?a.album.release_date:null},a.totalTime=function(){var b=0;return"undefined"!=typeof a.tracklist.tracks&&angular.forEach(a.tracklist.tracks,function(a){b+=a.duration_ms}),Math.round(b/1e5)},$(document).find(".browse > .content").on("scroll",function(b){var c=$(this).scrollTop(),d=$(this).outerHeight(),e=$(this).children(".inner").outerHeight(),f=-(c+d-e);100>=f&&a.$broadcast("spotmop:loadMore")}),a.playAlbum=function(){e.playStream(a.album.uri)},a.addToLibrary=function(){var b=[];angular.forEach(a.tracklist.tracks,function(a){b.push(f.getFromUri("trackid",a.uri))}),f.addTracksToLibrary(b)},f.getAlbum(c.uri).then(function(b){a.album=b,a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items,angular.forEach(a.tracklist.tracks,function(b){b.album=a.album});var d=[];angular.forEach(b.artists,function(a){d.push(a.uri)}),f.getArtists(d).then(function(b){a.album.artists=b.artists}),"undefined"!=typeof c.artisturi&&f.getArtist(c.artisturi).then(function(b){a.artist=b})});var h=!1;a.$on("spotmop:loadMore",function(){!h&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&g(a.tracklist.next)})}]),angular.module("spotmop.browse.artist",[]).config(["$stateProvider",function(a){a.state("browse.artist",{url:"/artist/:uri","abstract":!0,templateUrl:"app/browse/artist/template.html",controller:["$scope","$state",function(a,b){"browse.artist"===b.current.name&&b.go("browse.artist.overview")}]}).state("browse.artist.overview",{url:"",templateUrl:"app/browse/artist/overview.template.html",controller:"ArtistOverviewController"}).state("browse.artist.related",{url:"/related",templateUrl:"app/browse/artist/related.template.html",controller:"RelatedArtistsController"}).state("browse.artist.biography",{url:"/biography",templateUrl:"app/browse/artist/biography.template.html",controller:"ArtistBiographyController"}).state("browse.artistalbum",{url:"/artist/:artisturi/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("ArtistController",["$scope","$rootScope","$timeout","$interval","$stateParams","$sce","SpotifyService","SettingsService","EchonestService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h,i,j,k){a.artist={},a.tracklist={type:"track"},a.albums={},a.relatedArtists={},a.followArtist=function(){g.followArtist(e.uri).then(function(b){a.following=!0})},a.unfollowArtist=function(){g.unfollowArtist(e.uri).then(function(b){a.following=!1})},a.playArtistRadio=function(){j.error("This functionality has not yet been implemented")},g.getArtist(e.uri).then(function(b){a.artist=b}),b.spotifyAuthorized&&g.isFollowingArtist(e.uri,h.getSetting("spotifyuserid",null)).then(function(b){a.following=$.parseJSON(b)}),g.getRelatedArtists(e.uri).then(function(b){a.relatedArtists=b.artists})}]).controller("ArtistOverviewController",["$scope","$timeout","$rootScope","$stateParams","SpotifyService",function(a,b,c,d,e){function f(b){return"undefined"==typeof b?!1:(g=!0,void e.getUrl(b).then(function(b){a.albums.items=a.albums.items.concat(b.items),a.albums.next=b.next,g=!1}))}e.getAlbums(d.uri).then(function(b){a.$parent.albums=b,e.getTopTracks(d.uri).then(function(b){a.tracklist.tracks=b.tracks})});var g=!1;a.$on("spotmop:loadMore",function(){!g&&"undefined"!=typeof a.albums.next&&a.albums.next&&f(a.albums.next)})}]).controller("RelatedArtistsController",["$scope","$timeout","$rootScope",function(a,b,c){}]).controller("ArtistBiographyController",["$scope","$timeout","$rootScope","$stateParams","SpotifyService","LastfmService",function(a,b,c,d,e,f){function g(b){b=b.replace("&","and"),f.artistInfo(b).then(function(b){a.artist.biography=b.artist.bio})}"undefined"==typeof a.artist.name?e.getArtist(d.uri).then(function(a){g(a.name)}):g(a.artist.name)}]),angular.module("spotmop.browse",[]).config(["$stateProvider",function(a){a.state("browse",{url:"/browse",templateUrl:"app/browse/template.html"})}]),angular.module("spotmop.browse.featured",[]).config(["$stateProvider",function(a){a.state("browse.featured",{url:"/featured",templateUrl:"app/browse/featured/template.html",controller:"FeaturedController"}).state("browse.featuredplaylist",{url:"/featured/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("FeaturedController",["$scope","$rootScope","$filter","SpotifyService","NotifyService",function(a,b,c,d,e){a.playlists=[],a.featured=function(){return a.playlists[0]},a.partofday=function(){var a=parseFloat(c("date")(new Date,"H.m"));return a>=4&&9.3>a?"commute":a>=9.3&&11>a?"morning":a>=11&&13.5>a?"midday":a>=13.5&&17>a?"afternoon":a>=17&&19>a?"evening":a>=19&&21>a?"dinner":a>=21&&23>a||a>=0&&4>a?"late":void 0},d.featuredPlaylists().then(function(b){a.message=b.message,a.playlists=b.playlists.items})}]),angular.module("spotmop.browse.genre",[]).config(["$stateProvider",function(a){a.state("browse.genre",{url:"/genre",templateUrl:"app/browse/genre/template.html",controller:"GenreController"}).state("browse.genrecategory",{url:"/genre/:categoryid",templateUrl:"app/browse/genre/category.template.html",controller:"GenreCategoryController"}).state("browse.categoryplaylist",{url:"/genre/:categoryid/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("GenreController",["$scope","$rootScope","SpotifyService","NotifyService",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.categories.items=a.categories.items.concat(b.categories.items),a.categories.next=b.categories.next,f=!1}))}a.categories=[],c.discoverCategories().then(function(b){a.categories=b.categories});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.categories.next&&a.categories.next&&e(a.categories.next)})}]).controller("GenreCategoryController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists.items=a.playlists.items.concat(b.playlists.items),a.playlists.next=b.playlists.next,f=!1}))}a.category={},a.playlists=[],c.getCategory(d.categoryid).then(function(b){a.category=b,c.getCategoryPlaylists(d.categoryid).then(function(b){a.playlists=b.playlists})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.playlists.next&&a.playlists.next&&e(a.playlists.next)})}]),angular.module("spotmop.browse.new",[]).config(["$stateProvider",function(a){a.state("browse.new",{url:"/new",templateUrl:"app/browse/new/template.html",controller:"NewController"}).state("browse.newalbum",{url:"/new/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("NewController",["$scope","$element","$rootScope","SpotifyService","MopidyService",function(a,b,c,d,e){function f(b){return"undefined"==typeof b?!1:(g=!0,void d.getUrl(b).then(function(b){a.albums.items=a.albums.items.concat(b.albums.items),a.albums.next=b.albums.next,g=!1}))}a.albums=[],d.newReleases().then(function(b){a.albums=b.albums});var g=!1;a.$on("spotmop:loadMore",function(){!g&&"undefined"!=typeof a.albums.next&&a.albums.next&&f(a.albums.next)})}]),angular.module("spotmop.browse.playlist",[]).config(["$stateProvider",function(a){a.state("browse.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("PlaylistController",["$scope","$rootScope","$filter","$state","$stateParams","$sce","SpotifyService","MopidyService","SettingsService","DialogService","NotifyService",function(a,b,c,d,e,f,g,h,i,j,k){function l(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,c.added_by=a.added_by,c.is_local=a.is_local,b.push(c)}),b}function m(b){return"undefined"==typeof b?!1:(n=!0,void g.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(l(b.items)),a.tracklist.next=b.next,n=!1}))}a.playlist={images:[]},a.tracklist={tracks:[],type:"track"},a.totalTime=0,a.following=!1,a.followPlaylist=function(){g.followPlaylist(e.uri).then(function(b){a.following=!0,k.notify("Following playlist"),a.updatePlaylists()})},a.unfollowPlaylist=function(){g.unfollowPlaylist(e.uri).then(function(b){
-a.following=!1,k.notify("Playlist removed"),a.updatePlaylists()})},a.recoverPlaylist=function(){g.followPlaylist(e.uri).then(function(b){a.following=!0,k.notify("Playlist recovered"),a.updatePlaylists()})},a.editPlaylist=function(){j.create("editPlaylist",a)},a.playPlaylist=function(){h.playStream(a.playlist.uri,a.tracklist.tracks.length)},a.totalTime=function(){var b=0;return a.tracklist.tracks.length>0&&angular.forEach(a.tracklist.tracks,function(a){"undefined"!=typeof a&&(b+=a.duration_ms)}),Math.round(b/1e5)},$(document).find(".browse > .content").on("scroll",function(b){var c=$(this).scrollTop(),d=$(this).outerHeight(),e=$(this).children(".inner").outerHeight(),f=-(c+d-e);100>=f&&a.$broadcast("spotmop:loadMore")}),a.$on("spotmop:playlist:reorder",function(b,c,e,f){var h=d.params.uri;g.movePlaylistTracks(h,c,e,f);for(var i=[],j=0;e>j;j++)i.push(a.tracklist.tracks[c+j]);f>c&&(f-=e),i.reverse(),a.$apply(function(){a.tracklist.tracks.splice(c,e),angular.forEach(i,function(b){a.tracklist.tracks.splice(f,0,b)})})}),g.getPlaylist(e.uri).then(function(c){a.playlist=c,a.tracklist.next=c.tracks.next,a.tracklist.previous=c.tracks.previous,a.tracklist.offset=c.tracks.offset,a.tracklist.total=c.tracks.total,a.tracklist.tracks=l(c.tracks.items),a.playlist.description=f.trustAsHtml(a.playlist.description),b.spotifyAuthorized&&g.isFollowingPlaylist(e.uri,i.getSetting("spotifyuser",{id:null}).id).then(function(b){a.following=$.parseJSON(b)}),"undefined"!=typeof e.categoryid&&g.getCategory(e.categoryid).then(function(b){a.category=b})}),a.$on("spotmop:keyboardShortcut:delete",function(b){a.playlist.owner.id!==i.getSetting("spotifyuserid")?k.error("Cannot delete from a playlist you don't own"):a.$broadcast("spotmop:tracklist:deleteSelectedTracks")});var n=!1;a.$on("spotmop:loadMore",function(){!n&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&m(a.tracklist.next)})}]),angular.module("spotmop.browse.user",[]).config(["$stateProvider",function(a){a.state("browse.user",{url:"/user/:uri",templateUrl:"app/browse/user/template.html",controller:"UserController"})}]).controller("UserController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists=a.playlists.concat(b.items),a.next=b.next,f=!1}))}a.user={},a.playlists=[],c.getUser(d.uri).then(function(b){a.user=b,c.getPlaylists(b.id).then(function(b){a.playlists=b.items,a.next=b.next,a.totalPlaylists=b.total})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.next&&a.next&&e(a.next)})}]),angular.module("spotmop.common.contextmenu",[]).directive("contextmenu",function(){return{restrict:"E",templateUrl:"app/common/contextmenu/template.html",link:function(a,b,c){},controller:["$scope","$rootScope","$element",function(a,b,c){a.play=function(){b.$broadcast("spotmop:tracklist:playSelectedTracks"),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.enqueue=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.unqueue=function(){b.$broadcast("spotmop:tracklist:unqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.playNext=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks",!0),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.addToPlaylist=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToPlaylist"),c.fadeOut("fast")},a.removeFromPlaylist=function(){b.$broadcast("spotmop:tracklist:deleteSelectedTracks"),c.fadeOut("fast")},a.addToLibrary=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToLibrary"),c.fadeOut("fast")},a.selectAll=function(){b.$broadcast("spotmop:tracklist:selectAll")},a.unselectAll=function(){b.$broadcast("spotmop:tracklist:unselectAll"),c.fadeOut("fast")},a.$on("spotmop:contextMenu:show",function(b,d,e,f){var g=d.pageY-$(window).scrollTop(),h=d.pageX-window.pageYOffset;"undefined"!=typeof f&&f&&(h-=c.outerWidth()),c.css({top:g,left:h+5}).show(),a.$apply(function(){a.context=e})}),a.$on("spotmop:touchContextMenu:show",function(b,d){c.show(),a.$apply(function(){a.context=d})}),a.$on("spotmop:contextMenu:hide",function(a){c.fadeOut("fast")})}]}}),angular.module("spotmop.directives",[]).config(["cfpLoadingBarProvider",function(a){a.latencyThreshold=250}]).directive("singleclick",function(){return function(a,b,c){b.bind("touchstart click",function(b){b.preventDefault(),b.stopPropagation(),a.$apply(c.singleclick)})}}).directive("switch",["$rootScope","SettingsService",function(a,b){return{restrict:"E",scope:{name:"@"},replace:!0,transclude:!0,link:function(c,d,e){c.on=b.getSetting(c.name,!1),d.bind("touchstart click",function(d){d.preventDefault(),d.stopPropagation(),c.$apply(function(){c.on=!c.on,b.setSetting(c.name,c.on),a.$broadcast("spotmop:settings:changed",{name:c.name,value:c.on})})})},template:''}}]).directive("scrollingPanel",function(){return{restrict:"C",link:function(a,b,c){b.on("scroll",function(b){var c=$(this).scrollTop(),d=$(this).outerHeight(),e=$(this).children(".inner").outerHeight(),f=-(c+d-e);100>=f&&a.$broadcast("spotmop:loadMore")})}}}).directive("thumbnail",["$timeout","$http",function(a,b){return{restrict:"E",scope:{images:"=",size:"="},replace:!0,transclude:!0,link:function(a,c,d){function e(b){if(b.length<=0)return!1;for(var c=0;c=100&&d.height<=200)return d;if(d.height>200&&d.height<=300)return d;if(d.height>300&&d.height<400)return d}else{if(d.height>=200&&d.height<=300)return d;if(d.height>300&&d.height<=500)return d;if(d.height>=150&&d.height<200)return d}}return b[0]}a.image=e(a.images),a.image&&b({method:"GET",url:a.image.url,cache:!0}).success(function(){c.css("background-image","url("+a.image.url+")")})},template:''}}]).directive("confirmationButton",function(){return{restrict:"E",controller:["$scope","$element",function(a,b){a.text="Button text",a.confirming=!1,a.text=a.defaultText,$(document).on("click",function(c){c.target==b[0]&&1==c.which?a.confirming?"function"==typeof a.$parent[a.onConfirmation]()&&a.$parent[a.onConfirmation]():(a.confirming=!0,a.text=a.confirmationText,a.$apply()):(a.confirming=!1,a.text=a.defaultText,a.$apply())})}],scope:{text:"@",extraClasses:"@",confirmationText:"@",defaultText:"@",onConfirmation:"@"},replace:!0,transclude:!0,template:''}}).directive("textOverImage",function(){return{restrict:"A",link:function(a,b){a.$on("spotmop:detectBackgroundColor",function(a){BackgroundCheck.init({targets:$.merge($(b).parent(),$(document).find("#utilities")),images:b.closest(".intro").find(".image")}),BackgroundCheck.refresh()})}}}).directive("preloadedimage",["$rootScope","$timeout",function(a,b){return{restrict:"E",scope:{url:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,c){function d(){var c="";c+=a.url;var d=$('');d.load(function(){b.attr("style",'background-image: url("'+c+'");');var d=1;"undefined"!=typeof a.opacity&&(d=a.opacity),b.animate({opacity:d},200)})}b.attr("watch")&&a.$watch("url",function(a,b){a&&d()},!0),d()},template:""}}]).directive("backgroundparallax",["$rootScope","$timeout","$interval","$http",function(a,b,c,d){return{restrict:"E",terminal:!0,scope:{image:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,d){function e(a){var c=b.outerWidth(),d=b.outerHeight();if((h.canvas.width!=c||h.canvas.height!=d)&&(h.canvas.width=c,h.canvas.height=d),a.widthc){var e=c/a.width;a.width=a.width*e,a.height=a.height*e}if(a.heightf&&e(i)}})},10)},template:''}}]).filter("nullOrUndefined",[function(){return function(a,b){for(var c=[],d=0;d=b&&(b="0"+b);var c=Math.floor(a/6e4%60);return c+":"+b}}).filter("stripAccents",function(){return function(a){for(var b=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],c=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],d=0;d=200&&c.height<=300)return c.url;if(c.height>300&&c.height<=500)return c.url;if(c.height>=150&&c.height<200)return c.url}return a[0].url}}),angular.module("spotmop.common.tracklist",["spotmop.services.mopidy"]).directive("track",function(){return{restrict:"E",templateUrl:"app/common/tracklist/track.template.html",controller:["$element","$scope","$rootScope","MopidyService","NotifyService",function(a,b,c,d,e){a.mouseup(function(a){1===a.which?(b.isTouchDevice()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$emit("spotmop:track:clicked",b)):b.track.selected&&3===a.which&&b.$emit("spotmop:contextMenu:show",a,"track")}),a.dblclick(function(a){for(var c=b.tracklist.tracks.indexOf(b.track),f=[],g=c+1;g0){var a="Adding "+f.length+" tracks";f.length>10&&(a+="... this could take some time"),e.notify(a),d.addToTrackList(f)}})})}]}}).directive("tltrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/tltrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService",function(a,b,c,d,e){b.state=e.state,a.mouseup(function(a){1===a.which?(b.isTouchDevice()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$emit("spotmop:track:clicked",b)):b.track.selected&&3===a.which&&b.$emit("spotmop:contextMenu:show",a,"tltrack")}),a.dblclick(function(a){d.getCurrentTlTracks().then(function(a){$.each(a,function(a,c){return c.tlid==b.track.tlid?d.playTlTrack({tl_track:c}):void 0})})})}]}}).directive("localtrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/localtrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService","NotifyService",function(a,b,c,d,e,f){b.state=e.state,a.mouseup(function(a){1===a.which?(b.isTouchDevice()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$emit("spotmop:track:clicked",b)):b.track.selected&&3===a.which&&b.$emit("spotmop:contextMenu:show",a,"localtrack")}),a.dblclick(function(a){for(var c=b.tracklist.tracks.indexOf(b.track),e=[],g=c+1;g0){var a="Adding "+e.length+" tracks";e.length>10&&(a+="... this could take some time"),f.notify(a),d.addToTrackList(e)}})})}]}}).controller("TracklistController",["$element","$scope","$filter","$rootScope","$stateParams","MopidyService","SpotifyService","DialogService","NotifyService",function(a,b,c,d,e,f,g,h,i){function j(){var a=c("filter")(b.tracklist.tracks,{selected:!0}),d=a[0];if("tltrack"==b.tracklist.type)f.getCurrentTlTracks().then(function(a){$.each(a,function(a,b){return b.tlid==d.tlid?f.playTlTrack({tl_track:b}):void 0})});else{for(var e=[],g=1;g10&&(h+="... this could take some time"),i.notify(h),f.playTrack([d.uri],0).then(function(){e.length>0&&f.addToTrackList(e)})}}$(document).contextmenu(function(a){return $(a.target).closest(".tracklist").length>0?!1:void 0}),b.$on("spotmop:track:dragging",function(a){}),b.$on("spotmop:track:clicked",function(a,e){if(d.ctrlKeyHeld||b.isTouchDevice()?e.track.selected?e.$apply(function(){e.track.selected=!1}):e.$apply(function(){e.track.selected=!0}):d.ctrlKeyHeld||(angular.forEach(b.tracklist.tracks,function(a){a.selected=!1}),e.$apply(function(){e.track.selected=!0})),d.shiftKeyHeld){var f="undefined"!=typeof b.lastSelectedTrack?b.lastSelectedTrack.$index:0,g=e.$index;e.$index=h;h++)b.tracklist.tracks[h].selected=!0;b.$apply()}b.lastSelectedTrack=e,b.isTouchDevice()&&(c("filter")(b.tracklist.tracks,{selected:!0}).length>0?d.$broadcast("spotmop:touchContextMenu:show",b.tracklist.type):d.$broadcast("spotmop:contextMenu:hide"))}),b.$on("spotmop:tracklist:enqueueSelectedTracks",function(a,d){var e=null;if("undefined"!=typeof d&&1==d){e=0;var g=b.state().currentTlTrack;if(g){var h=c("filter")(b.currentTracklist,{tlid:g.tlid});h.length>0&&(e=b.currentTracklist.indexOf(h[0])+1)}}var j=c("filter")(b.tracklist.tracks,{selected:!0}),k=[];angular.forEach(j,function(a){k.push(a.uri)});var l="Adding "+j.length+" tracks to queue";j.length>10&&(l+="... this could take some time"),i.notify(l),f.addToTrackList(k,e)}),b.$on("spotmop:tracklist:playSelectedTracks",function(){j()}),b.$on("spotmop:keyboardShortcut:enter",function(){j()}),b.$on("spotmop:tracklist:unqueueSelectedTracks",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a){e.push(a.tlid)}),f.removeFromTrackList(e)}),b.$on("spotmop:tracklist:deleteSelectedTracks",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),f=[];angular.forEach(d,function(a,c){f.push(b.tracklist.tracks.indexOf(a)),a.transitioning=!0}),g.deleteTracksFromPlaylist(e.uri,b.playlist.snapshot_id,f).then(function(a){"undefined"!=typeof a.error?(i.error(a.error.message),angular.forEach(d,function(a,b){a.transitioning=!1})):(b.tracklist.tracks=c("nullOrUndefined")(b.tracklist.tracks,"selected"),b.playlist.snapshot_id=a.snapshot_id)})}),b.$on("spotmop:tracklist:addSelectedTracksToPlaylist",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a){"undefined"!=typeof a.track?e.push(a.track.uri):e.push(a.uri)}),h.create("addToPlaylist",b)}),b.$on("spotmop:tracklist:addSelectedTracksToLibrary",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a){"undefined"!=typeof a.track?e.push(g.getFromUri("trackid",a.track.uri)):e.push(g.getFromUri("trackid",a.uri))}),g.addTracksToLibrary(e)}),b.$on("spotmop:tracklist:selectAll",function(a){angular.forEach(b.tracklist.tracks,function(a){a.selected=!0})}),b.$on("spotmop:tracklist:unselectAll",function(a){angular.forEach(b.tracklist.tracks,function(a){a.selected=!1})})}]),angular.module("spotmop.common.tracklist.service",[]).factory("TracklistService",["$rootScope",function(a){return{getSelectedTracks:function(){console.log("triggered getSelectedTracks")}}}]),angular.module("spotmop.discover",[]).config(["$stateProvider",function(a){a.state("discover",{url:"/discover",templateUrl:"app/discover/template.html",controller:"DiscoverController"})}]).controller("DiscoverController",["$scope","$rootScope","SpotifyService","EchonestService","SettingsService","NotifyService",function(a,b,c,d,e,f){if(a.artists=[],a.playlists=[],a.albums=[],a.recommendations={currentArtist:{artists:[],recommendations:[]},suggestions:[]},e.getSetting("echonestenabled",!1)){if("undefined"!=typeof a.state().currentTlTrack.track){var g=[];angular.forEach(a.state().currentTlTrack.track.artists,function(a){g.push({name:a.name,name_encoded:encodeURIComponent(a.name),uri:a.uri})}),a.recommendations.currentArtist.artists=g,d.recommendedArtists(a.recommendations.currentArtist.artists).then(function(b){var d=b.response.artists,e=[];d.length<=0?f.error("Your taste profile is empty. Play some more music!"):(angular.forEach(d,function(a){"undefined"!=typeof a.foreign_ids&&a.foreign_ids.length>0&&e.push(a.foreign_ids[0].foreign_id)}),c.getArtists(e).then(function(b){a.recommendations.currentArtist.recommendations=b.artists}))})}d.recommendedArtists().then(function(b){var d=[];"undefined"!=typeof b.response&&"undefined"!=typeof b.response.artists&&(d=b.response.artists);var e=[];d.length<=0?f.error("Your taste profile is empty. Play some more music!"):(angular.forEach(d,function(a){e.push(a.foreign_ids[0].foreign_id)}),c.getArtists(e).then(function(b){a.recommendations.suggestions=b.artists}))})}}]),angular.module("spotmop.library",[]).config(["$stateProvider",function(a){a.state("library",{url:"/library",templateUrl:"app/library/template.html"}).state("library.playlists",{url:"/playlists",templateUrl:"app/library/playlists.template.html",controller:"LibraryPlaylistsController"}).state("library.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"}).state("library.tracks",{url:"/tracks",templateUrl:"app/library/tracks.template.html",controller:"LibraryTracksController"}).state("library.artists",{url:"/artists",templateUrl:"app/library/artists.template.html",controller:"LibraryArtistsController"}).state("library.albums",{url:"/albums",templateUrl:"app/library/albums.template.html",controller:"LibraryAlbumsController"}).state("library.files",{url:"/files/:folder",templateUrl:"app/library/files.template.html",controller:"LibraryFilesController"})}]).controller("LibraryTracksController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService",function(a,b,c,d,e,f){function g(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,b.push(c)}),b}function h(b){return"undefined"==typeof b?!1:(j=!0,void d.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(g(b.items)),a.tracklist.next=b.next,j=!1}))}a.tracklist={tracks:[]};var i=e.getSetting("spotifyuserid",a.$parent.spotifyUser.id);d.getMyTracks(i).then(function(b){a.tracklist=b,a.tracklist.tracks=g(b.items),"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()}),a.$on("spotmop:keyboardShortcut:delete",function(b){var e=c("filter")(a.tracklist.tracks,{selected:!0}),f=[];angular.forEach(e,function(a,b){f.push(d.getFromUri("trackid",a.uri))}),d.deleteTracksFromLibrary(f).then(function(b){a.tracklist.tracks=c("filter")(a.tracklist.tracks,{selected:!1})})});var j=!1;a.$on("spotmop:loadMore",function(){!j&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&h(a.tracklist.next)})}]).controller("LibraryFilesController",["$scope","$rootScope","$filter","$stateParams","SpotifyService","SettingsService","DialogService","MopidyService",function(a,b,c,d,e,f,g,h){function i(){h.getLibraryItems(k).then(function(b){var e=c("filter")(b,{type:"track"});a.tracklist.tracks=e;var f=j(c("filter")(b,{type:"directory"}));"local:directory"!=d.folder&&f.unshift({name:"..",uri:l,type:"directory",isParentFolder:!0}),a.folders=f})}function j(a){for(var b=0;b-1?e.lookup(a.track.uri).then(function(a){b(a[0])}):b(a))})}function o(){var a=p.currentTlTrack.track,b="No track playing";if(a){var c="■ ",d="";$.each(a.artists,function(a,b){""!=d&&(d+=", "),d+=b.name}),p.playing&&(c="▶ "),b=c+" "+a.name+" - "+d}document.title=b}var p={playing:!1,isRepeat:!1,isRandom:!1,isMute:!1,volume:100,playPosition:0,currentTlTrack:!1,playPositionPercent:function(){return p.currentTlTrack?(p.playPosition/p.currentTlTrack.track.length*100).toFixed(2):0}};a.$on("mopidy:state:online",function(){j(),n(),m(),l(),e.getState().then(function(a){"playing"==a?p.playing=!0:p.playing=!1})}),a.$on("mopidy:event:optionsChanged",function(a,b){j()}),a.$on("mopidy:event:playbackStateChanged",function(a,b){m(b.new_state)}),a.$on("mopidy:event:seeked",function(a,b){k(b.time_position)}),a.$on("mopidy:event:volumeChanged",function(a,b){b.volume!=p.volume&&l(b.volume)}),a.$on("mopidy:event:trackPlaybackStarted",function(a,b){("undefined"==typeof p.currentTlTrack.track||p.currentTlTrack.track.uri!=b.tl_track.track.uri)&&(p.currentTlTrack=b.tl_track,n(b.tl_track),m())}),b(function(){p.playing&&"undefined"!=typeof p.currentTlTrack&&p.playPosition=100&&(p.volume=100),q.setVolume(p.volume),h.shortcut("volume-up"))}),a.$on("spotmop:keyboardShortcut:down",function(b){a.ctrlKeyHeld&&(p.volume-=10,p.volume<0&&(p.volume=0),q.setVolume(p.volume),h.shortcut("volume-down"))});var q={state:function(){return p},playPause:function(){p.playing?(e.pause(),p.playing=!1):(e.play(),p.playing=!0)},stop:function(){e.stopPlayback(),p.playing=!1},next:function(){d.getSetting("echonestenabled",!1)&&g.addToTasteProfile("skip",p.currentTlTrack.track.uri),e.play(),e.next()},previous:function(){e.previous()},seek:function(a){p.playPosition=a,e.seek(a)},setVolume:function(a){p.volume=a,e.setVolume(a)},toggleRepeat:function(){p.isRepeat?e.setRepeat(!1).then(function(a){p.isRepeat=!1}):e.setRepeat(!0).then(function(a){p.isRepeat=!0}),console.log(p)},toggleRandom:function(){p.isRandom?e.setRandom(!1).then(function(a){p.isRandom=!1}):e.setRandom(!0).then(function(a){p.isRandom=!0})},toggleMute:function(){p.isMute?e.setMute(!1).then(function(a){p.isMute=!1}):e.setMute(!0).then(function(a){p.isMute=!0})}};return q}]),angular.module("spotmop.queue",[]).config(["$stateProvider",function(a){a.state("queue",{url:"/queue",templateUrl:"app/queue/template.html",controller:"QueueController"})}]).controller("QueueController",["$scope","$rootScope","$filter","$timeout","$state","MopidyService","SpotifyService",function(a,b,c,d,e,f,g){function h(b){var c=0;$.each(b,function(a,b){c+=b.track.length}),a.totalTime=Math.round(c/1e5)}a.totalTime=0,a.tracklist={type:"tltrack",tracks:a.$parent.currentTracklist},a.$watch(function(a){return a.$parent.currentTracklist},function(b,c){a.tracklist.tracks=b,h(b)}),a.$on("spotmop:keyboardShortcut:delete",function(b){var d=c("filter")(a.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a,b){e.push(a.tlid)}),a.$apply(function(){a.tracklist.tracks=c("filter")(a.tracklist.tracks,{selected:!1})}),f.removeFromTrackList(e)})}]),angular.module("spotmop.search",[]).config(["$stateProvider",function(a){a.state("search",{url:"/search/:query/:type",templateUrl:"app/search/template.html",controller:"SearchController",params:{type:{squash:!0,value:"all"},query:{squash:!0,value:null}}})}]).controller("SearchController",["$scope","$rootScope","$state","$stateParams","$timeout","$filter","SpotifyService",function(a,b,c,d,e,f,g){function h(b,c){if("undefined"==typeof b)var b=a.type;switch(b){case"track":g.getSearchResults("track",c,50).then(function(b){a.tracklist=b.tracks,a.tracklist.tracks=b.tracks.items,a.tracklist.type="track",a.next=b.tracks.next});break;case"album":g.getSearchResults("album",c,50).then(function(b){a.albums=b.albums,a.next=b.albums.next});break;case"artist":g.getSearchResults("artist",c,50).then(function(b){a.artists=b.artists,a.next=b.artists.next});break;case"playlist":g.getSearchResults("playlist",c,50).then(function(b){a.playlists=b.playlists,a.next=b.playlists.next});break;default:g.getSearchResults("track",c,50).then(function(b){a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items}),g.getSearchResults("album",c,50).then(function(b){a.albums=b.albums}),g.getSearchResults("artist",c,50).then(function(b){a.artists=b.artists}),g.getSearchResults("playlist",c,50).then(function(b){a.playlists=b.playlists})}}function i(b){return"undefined"==typeof b?!1:(j=!0,void g.getUrl(b).then(function(b){switch(a.type){case"artist":a.artists.items=a.artists.items.concat(b.artists.items),a.next=b.artists.next;break;case"album":a.albums.items=a.albums.items.concat(b.albums.items),a.next=b.albums.next;break;case"track":a.tracklist.tracks=a.tracklist.tracks.concat(b.tracks.items),a.next=b.tracks.next;break;case"playlist":a.playlists.items=a.playlists.items.concat(b.playlists.items),a.next=b.playlists.next}j=!1}))}a.tracklist={tracks:[],type:"track"},a.albums=[],a.artists=[],a.playlists=[],a.type=d.type,a.query=f("stripAccents")(d.query),a.loading=!1;a.isTouchDevice()||$(document).find(".search-form input.query").focus(),a.query&&h(a.type,a.query);var j=!1;a.$on("spotmop:loadMore",function(){!j&&"undefined"!=typeof a.next&&a.next&&i(a.next)})}]),angular.module("spotmop.services.dialog",[]).factory("DialogService",["$rootScope","$compile","$interval","$timeout",function(a,b,c,d){return{create:function(a,c){"undefined"==typeof c&&(c=!1),$("body").children(".dialog").length>0&&console.log("A dialog already exists..."),$("body").append(b('')(c))},remove:function(){$("body").children(".dialog").fadeOut(200,function(){$(this).remove()})}}}]).directive("dialog",["$compile",function(a){return{restrict:"E",replace:!0,transclude:!0,scope:{type:"@"},templateUrl:"app/services/dialog/template.html",link:function(b,c){c.find(".content").html(a("<"+b.type+"dialog />")(b))},controller:["$scope","$element","DialogService",function(a,b,c){a.closeDisabled=!1,"initialsetup"==a.type&&(a.closeDisabled=!0),a.closeDialog=function(){c.remove()},a.$on("spotmop:keyboardShortcut:esc",function(b){a.closeDisabled||c.remove()})}]}}]).directive("createplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/createplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f){a.saving=!1,a.playlistPublic="true",a.savePlaylist=function(){a.saving=!0,"true"==a.playlistPublic?a.playlistPublic=!0:a.playlistPublic=!1,f.createPlaylist(a.$parent.spotifyUser.id,{name:a.playlistName,"public":a.playlistPublic}).then(function(b){a.$parent.playlists.items.push(b),a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})}}]}}).directive("editplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/editplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SpotifyService",function(a,b,c,d,e){a.playlistNewName=a.$parent.playlist.name,a.playlistNewPublic=a.$parent.playlist["public"].toString(),a.saving=!1,a.savePlaylist=function(){a.saving=!0,"true"==a.playlistNewPublic?a.playlistNewPublic=!0:a.playlistNewPublic=!1,e.updatePlaylist(a.$parent.playlist.uri,{name:a.playlistNewName,"public":a.playlistNewPublic
-}).then(function(b){a.$parent.playlist.name=a.playlistNewName,a.$parent.playlist["public"]=a.playlistNewPublic,a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})}}]}}).directive("addtoplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/addtoplaylist.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SpotifyService","SettingsService",function(a,b,c,d,e,f,g){a.playlists=[];var h=g.getSetting("spotifyuser",{id:"undefined"}).id;f.getPlaylists(h,50).then(function(b){a.playlists=d("filter")(b.items,{owner:{id:h}})}),a.playlistSelected=function(b){var g=d("filter")(a.$parent.tracklist.tracks,{selected:!0}),h=[];angular.forEach(g,function(a){"undefined"!=typeof a.track?h.push(a.track.uri):h.push(a.uri)}),f.addTracksToPlaylist(b.uri,h).then(function(b){e.remove(),c.$broadcast("spotmop:tracklist:unselectAll"),a.$emit("spotmop:notifyUser",{id:"adding-to-playlist",message:"Added "+h.length+" tracks",autoremove:!0})})}}]}}).directive("volumecontrolsdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/volumecontrols.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","PlayerService",function(a,b,c,d,e,f){a.state=function(){return f.state()},a.setVolume=function(a){var b,c,d,e;b=$(a.target).hasClass("slider")?$(a.target):$(a.target).closest(".slider"),c=b.offset(),d=a.pageX-c.left,e=d/b.innerWidth()*100,e=parseInt(e),f.setVolume(e)}}]}}).directive("initialsetupdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/initialsetup.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f,g){f.setSetting("attemptSpotifyAuthorization",!0),a.saving=!1,a.save=function(){a.name&&""!=a.name?(a.saving=!0,f.getSetting("attemptSpotifyAuthorization",!1)&&g.authorize(),f.setSetting("pushername",a.name),e.remove()):a.error=!0}}]}}),angular.module("spotmop.services.echonest",[]).factory("EchonestService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$cacheFactory","$q","SettingsService",function(a,b,c,d,e,f,g,h,i){var j="http://developer.echonest.com/api/v4/",k=i.getSetting("echonestapikey","YVW64VSEPEV93M4EG");return{isOnline:!1,start:function(){i.setSetting("echonestenabled",!0),i.getSetting("echonesttasteprofileid",!1)?this.getTasteProfile(i.getSetting("echonesttasteprofileid",!1)).success(function(b){this.isOnline=!0,a.echonestOnline=!0,c.echonesttasteprofile=b.response.catalog}).error(function(b){this.isOnline=!1,a.echonestOnline=!1}):this.createTasteProfile().success(function(b){i.setSetting("echonesttasteprofileid",b.response.id),this.isOnline=!0,a.echonestOnline=!0}).error(function(b){this.isOnline=!1,a.echonestOnline=!1})},stop:function(){i.setSetting("echonestenabled",!1),a.echonestOnline=!1},createTasteProfile:function(){return $.ajax({url:j+"catalog/create",method:"POST",data:{api_key:k,format:"json",type:"general",name:"spotmop:"+Date.now()+Math.round(1e3*(Math.random()+1))}})},getTasteProfile:function(){var a=i.getSetting("echonesttasteprofileid",!1);return $.ajax({url:j+"tasteprofile/read?api_key="+k+"&id="+a,method:"GET"})},addToTasteProfile:function(a,b){var c=i.getSetting("echonesttasteprofileid",!1),d=[],e=[];return e="string"==typeof b?[b]:b,angular.forEach(e,function(b){d.push({action:a,item:{track_id:b}})}),$.ajax({url:j+"tasteprofile/update",method:"POST",data:{api_key:k,format:"json",data_type:"json",id:c,data:JSON.stringify(d)}})},getArtistBiography:function(b){var c=h.defer();return d({cache:!0,method:"GET",url:j+"artist/biographies?api_key="+k+"&format=json&results=1&id="+b}).success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"getArtistBiography",message:b.error.message}),c.reject(b.error.message)}),c.promise},recommendedArtists:function(b){var c=i.getSetting("echonesttasteprofileid",!1);if("undefined"==typeof b||!b||b.length<=0)var e="&seed_catalog="+c;else{var e="";angular.forEach(b,function(a){e+="&name="+a.name_encoded})}var f=h.defer();return d.get(j+"artist/similar?api_key="+k+e+"&format=json&bucket=id:spotify&results=10").success(function(a){f.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"catalogRadio",message:b.error.message}),f.reject("Failed to get albums")}),f.promise},favoriteArtists:function(){var b=i.getSetting("echonesttasteprofileid",!1),c=h.defer();return d.get(j+"playlist/static?api_key="+k+"&type=catalog&seed_catalog="+b+"&bucket=id:spotify&format=json&results=20&adventurousness=0").success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"favoriteArtists",message:b.error.message}),c.reject("Failed to get albums")}),c.promise},catalogRadio:function(){var b=i.getSetting("echonesttasteprofileid",!1),c=h.defer();return d.get(j+"playlist/static?api_key="+k+"&type=catalog-radio&seed_catalog="+b+"&bucket=artist_discovery&bucket=id:spotify&format=json&results=20").success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"catalogRadio",message:b.error.message}),c.reject("Failed to get albums")}),c.promise},startArtistRadio:function(b){var c=h.defer();return d.get(j+"playlist/dynamic/create?api_key="+k+"&type=artist-radio&artist="+b+"&bucket=tracks&bucket=id:spotify&results=1").success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"artistRadio",message:b.error.message}),c.reject("Failed to create artist radio")}),c.promise}}}]),angular.module("spotmop.services.lastfm",[]).factory("LastfmService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j){var k={sendRequest:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:l+"?format=json&api_key="+m+"&"+a}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},trackInfo:function(a,b){return this.sendRequest("method=track.getInfo&track="+b+"&artist="+a)},albumInfo:function(a,b){return this.sendRequest("method=album.getInfo&album="+b+"&artist="+a)},artistInfo:function(a){return this.sendRequest("method=artist.getInfo&artist="+a)}},l="http://ws.audioscrobbler.com/2.0",m=i.getSetting("lastfmkey","4320a3ef51c9b3d69de552ac083c55e3");return k}]),angular.module("spotmop.services.mopidy",[]).factory("MopidyService",["$q","$rootScope","$cacheFactory","$location","$timeout","SettingsService","EchonestService","PusherService",function(a,b,c,d,e,f,g,h){function i(c,d){return function(){var e=a.defer(),f=Array.prototype.slice.call(arguments),g=d||this;return b.$broadcast("spotmop:callingmopidy",{name:c,args:f}),g.isConnected?j(c,g,f).then(function(a){e.resolve(a),b.$broadcast("spotmop:calledmopidy",{name:c,args:f})},function(a){e.reject(a),b.$broadcast("spotmop:errormopidy",{name:c,args:f,err:a})}):j(c,g,f).then(function(a){e.resolve(a),b.$broadcast("spotmop:calledmopidy",{name:c,args:f})},function(a){e.reject(a),b.$broadcast("spotmop:errormopidy",{name:c,args:f,err:a})}),e.promise}}function j(a,b,c){for(var d=a.split("."),e=d.pop(),f=0;f'+a+"");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},error:function(a,b){if("undefined"==typeof b)var b=2500;var c=$(''+a+"");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},spotifyAuthenticationError:function(){this.error("Please authenticate with Spotify - you can find this under settings")},shortcut:function(a){$("#notifications").find("notification.keyboard-shortcut").remove();var b=$('');$("#notifications").append(b),d(function(){b.fadeOut(200,function(){b.remove()})},1500)},browserNotify:function(a,b,c){if(e.getSetting("notificationsDisabled",!1))return!1;var d=window.Notification||window.mozNotification||window.webkitNotification;if("undefined"==typeof d)return!1;if("undefined"!=typeof d&&d.requestPermission(function(a){}),"undefined"==typeof c)var c="";new d(a,{body:b,dir:"auto",lang:"EN",tag:"spotmopNotification",icon:c});return!0}}}]).directive("notification",function(){return{restrict:"AE",link:function(a,b,c){console.log(b)}}}),angular.module("spotmop.services.pusher",[]).factory("PusherService",["$rootScope","$http","$q","$localStorage","$cacheFactory","$templateCache","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h){"undefined"==typeof d.pusher&&(d.pusher={});var i="http://"+g.getSetting("mopidyhost",window.location.hostname);i+=":"+g.getSetting("mopidyport","6680"),i+="/spotmop/";var j={pusher:{},isConnected:!1,start:function(){var b=g.getSetting("mopidyhost",window.location.hostname),c=g.getSetting("pusherport","6681");try{var d="ws://"+b+":"+c+"/pusher",i=new WebSocket(d);i.onopen=function(){a.$broadcast("spotmop:pusher:online"),this.isConnected=!0},i.onmessage=function(b){var c=JSON.parse(b.data);if(c.pusher)if(c.startup){console.info("Pusher connected as "+c.details.id),g.setSetting("pusherid",c.details.id),g.setSetting("pusherip",c.details.ip),g.getSetting("version",0,"installed")!=c.version&&(h.notify("New version detected, clearing caches..."),e.get("$http").removeAll(),f.removeAll(),g.setSetting("version",c.version,"installed"));var d=g.getSetting("pushername",null);d&&j.setMe(d)}else c.id==g.getSetting("pusherid",null)||g.getSetting("pusherdisabled",!1)||a.$broadcast("spotmop:pusher:received",c)},i.onclose=function(){a.$broadcast("spotmop:pusher:offline"),j.isConnected=!1,setTimeout(function(){j.start()},5e3)},j.pusher=i}catch(k){console.log("Connecting with Pusher failed with the following error message: "+k)}},stop:function(){this.pusher=null,this.isConnected=!1},send:function(a){a.pusher=!0,a.id=g.getSetting("pusherid",null),j.pusher.send(JSON.stringify(a))},setMe:function(a){var b=g.getSetting("pusherid",null);$.ajax({method:"GET",cache:!1,url:i+"pusher/me?id="+b+"&name="+a})},getConnections:function(){var a=c.defer();return b({method:"GET",cache:!1,url:i+"pusher/connections"}).success(function(b){a.resolve(b)}).error(function(b){h.error(b.error.message),a.reject(b.error.message)}),a.promise}};return j}]),angular.module("spotmop.services.spotify",[]).factory("SpotifyService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j){var k={authenticationMethod:"server",start:function(){var b=$('');$(body).append(b),"undefined"==typeof c.spotify&&(c.spotify={}),"undefined"==typeof c.spotify.AccessToken&&(c.spotify.AccessToken=null),"undefined"==typeof c.spotify.RefreshToken&&(c.spotify.RefreshToken=null),"undefined"==typeof c.spotify.AuthorizationCode&&(c.spotify.AuthorizationCode=null),"undefined"==typeof c.spotify.AccessTokenExpiry&&(c.spotify.AccessTokenExpiry=null),window.addEventListener("message",function(b){if("http://jamesbarnsley.co.nz"!==b.origin)return!1;var d=JSON.parse(b.data);console.info("Spotify authorization successful"),c.spotify.AuthorizationCode=d.authorization_code,c.spotify.AccessToken=d.access_token,c.spotify.RefreshToken=d.refresh_token,a.spotifyOnline=!0,this.authenticationMethod="client",k.getMe().then(function(b){i.setSetting("spotifyuser",b),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)})},!1),this.isAuthorized()?(a.spotifyAuthorized=!0,this.authenticationMethod="client"):(i.setSetting("spotifyuser",!1),a.spotifyAuthorized=!1,this.authenticationMethod="server"),a.$broadcast("spotmop:spotify:online")},logout:function(){c.spotify={},this.authenticationMethod="server",this.refreshToken(),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)},authorize:function(){var a=$(document).find("#authorization-frame");a.attr("src","http://jamesbarnsley.co.nz/spotmop.php?action=authorize&app="+location.protocol+"//"+window.location.host)},isAuthorized:function(){return c.spotify.AuthorizationCode&&c.spotify.RefreshToken?!0:!1},refreshToken:function(){var b=h.defer(),e="";if("client"==this.authenticationMethod)e="http://jamesbarnsley.co.nz/spotmop.php?action=refresh&refresh_token="+c.spotify.RefreshToken;else{if("server"!=this.authenticationMethod)return!1;var f=i.getSetting("mopidyhost",window.location.hostname),g=i.getSetting("mopidyport","6680");e="http://"+f+":"+g+"/spotmop/auth"}return d({method:"GET",url:e,dataType:"json",async:!1,timeout:1e4}).success(function(d){"undefined"!=typeof d.error?(j.error("Spotify authorization error: "+d.error_description),a.spotifyOnline=!1,b.reject(d.error.message)):(c.spotify.AccessToken=d.access_token,c.spotify.AccessTokenExpiry=(new Date).getTime()+36e5,a.spotifyOnline=!0,b.resolve(d))}),b.promise},getFromUri:function(a,b){var c=b.split(":");return"userid"==a&&"user"==c[1]?c[2]:"playlistid"==a&&"playlist"==c[3]?c[4]:"artistid"==a&&"artist"==c[1]?c[2]:"albumid"==a&&"album"==c[1]?c[2]:"trackid"==a&&"track"==c[1]?c[2]:null},uriType:function(a){var b=a.split(":");return"spotify"==b[0]&&"artist"==b[1]?"artist":"spotify"==b[0]&&"album"==b[1]?"album":"spotify"==b[0]&&"user"==b[1]&&"playlist"==b[3]?"playlist":null},getUrl:function(a){var b=h.defer();return d({method:"GET",url:a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getMe:function(){var a=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(b){a.resolve(b)}).error(function(b){j.error(b.error.message),a.reject(b.error.message)}),a.promise):(a.reject(),a.promise)},getUser:function(a){var b=this.getFromUri("userid",a),c=h.defer();return d({method:"GET",url:l+"users/"+b}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},isFollowing:function(a,b){var e=this.getFromUri(a+"id",b),f=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/following/contains?type="+a+"&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},getTrack:function(a){var b=this.getFromUri("trackid",a),c=h.defer();return d({method:"GET",url:l+"tracks/"+b}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getMyTracks:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/tracks/",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},addTracksToLibrary:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"PUT",url:l+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},deleteTracksFromLibrary:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"DELETE",url:l+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},getMyArtists:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/following?type=artist",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},isFollowingArtist:function(a,b){var e=this.getFromUri("artistid",a),f=h.defer();return this.isAuthorized()?(d({cache:!1,method:"GET",url:l+"me/following/contains?type=artist&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},followArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"PUT",cache:!1,url:l+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},unfollowArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"DELETE",cache:!1,url:l+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},getPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!1,method:"GET",url:l+"users/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise},getPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return d({cache:!0,method:"GET",url:l+"users/"+b+"/playlists/"+e+"?market="+m,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise},isFollowingPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({cache:!0,method:"GET",url:l+"users/"+e+"/playlists/"+f+"/followers/contains?ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){j.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},followPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"PUT",url:l+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},unfollowPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"DELETE",url:l+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},featuredPlaylists:function(a){"undefined"==typeof a&&(a=40);var b=g("date")(new Date,"yyyy-MM-ddTHH:mm:ss"),e=i.getSetting("countrycode","NZ"),f=h.defer();return d({cache:!0,method:"GET",url:l+"browse/featured-playlists?timestamp="+b+"&country="+e+"&limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise},addTracksToPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"POST",url:l+"users/"+e+"/playlists/"+f+"/tracks",dataType:"json",data:JSON.stringify({uris:b}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){j.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},movePlaylistTracks:function(a,b,e,f){var g=this.getFromUri("userid",a),k=this.getFromUri("playlistid",a);if(g!=i.getSetting("spotifyuserid",null))return!1;if(!this.isAuthorized())return m.reject(),m.promise;var m=h.defer();return d({method:"PUT",url:l+"users/"+g+"/playlists/"+k+"/tracks",dataType:"json",data:JSON.stringify({range_start:b,range_length:e,insert_before:f}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){m.resolve(a)}).error(function(a){j.error(a.error.message),m.reject(a.error.message)}),m.promise},deleteTracksFromPlaylist:function(a,b,e){var f=this.getFromUri("userid",a),g=this.getFromUri("playlistid",a),i=h.defer();return d({method:"DELETE",url:l+"users/"+f+"/playlists/"+g+"/tracks",dataType:"json",data:JSON.stringify({snapshot_id:b,positions:e}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){i.resolve(a)}).error(function(a){j.error(a.error.message),i.reject(a.error.message)}),i.promise},createPlaylist:function(a,b){var e=h.defer();return this.isAuthorized()?(d({method:"POST",url:l+"users/"+a+"/playlists/",dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},updatePlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"PUT",url:l+"users/"+e+"/playlists/"+f,dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){j.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},newReleases:function(a){"undefined"==typeof a&&(a=40);var b=h.defer();return d({cache:!0,method:"GET",url:l+"browse/new-releases?country="+m+"&limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},discoverCategories:function(a){"undefined"==typeof a&&(a=40);var b=h.defer();return d({cache:!0,method:"GET",url:l+"browse/categories?limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategory:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:l+"browse/categories/"+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategoryPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!0,method:"GET",url:l+"browse/categories/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise},getArtist:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getArtists:function(a){var b=this,c="";angular.forEach(a,function(a){""!=c&&(c+=","),c+=b.getFromUri("artistid",a)});var e=h.defer();return d({method:"GET",url:l+"artists/?ids="+c}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise},getAlbums:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b+"/albums?album_type=album,single&market="+m}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getAlbum:function(a){var b=h.defer(),c=this.getFromUri("albumid",a);return d({method:"GET",url:l+"albums/"+c}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getTopTracks:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b+"/top-tracks?country="+m}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getRelatedArtists:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b+"/related-artists"}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getSearchResults:function(a,b,e){"undefined"==typeof e&&(e=10);var f=h.defer();return d({cache:!0,method:"GET",url:l+"search?q="+b+"&type="+a+"&country="+m+"&limit="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise}},l="https://api.spotify.com/v1/",m=i.getSetting("spotifycountry","NZ");i.getSetting("spotifylocale","en_NZ");return k}]).factory("SpotifyServiceIntercepter",["$q","$rootScope","$injector","$localStorage",function(a,b,c,d){"use strict";function e(a,b,d){function e(a){b.resolve(a)}function f(a){b.reject(a)}var g=c.get("$http");a.headers={Authorization:"Bearer "+d},g(a).then(e,f)}var f=0,g={responseError:function(b){if(401==b.status&&b.config.url.search("https://api.spotify.com/")>=0&&3>f){f++;var d=a.defer();return c.get("SpotifyService").refreshToken().then(function(a){return"undefined"!=typeof a.error?b:(f--,void e(b.config,d,a.access_token))}),d.promise}return b}};return g}]),angular.module("spotmop.settings",[]).config(["$stateProvider",function(a){a.state("settings",{url:"/settings",templateUrl:"app/settings/template.html"})}]).controller("SettingsController",["$scope","$http","$rootScope","$timeout","MopidyService","SpotifyService","EchonestService","SettingsService","NotifyService","PusherService",function(a,b,c,d,e,f,g,h,i,j){a.version,a.settings=h.getSettings(),a.currentSubpage="mopidy",a.subpageNavigate=function(b){a.currentSubpage=b},a.authorizeSpotify=function(){f.authorize()},a.refreshSpotifyToken=function(){i.notify("Refreshing token"),f.refreshToken().then(function(){})},a.spotifyLogout=function(){f.logout()},a.upgradeCheck=function(){i.notify("Checking for updates"),h.upgradeCheck().then(function(a){
-h.setSetting("version",a,"latest"),h.getSetting("version",0,"installed")0&&angular.forEach(a.tracklist.tracks,function(a){"undefined"!=typeof a&&(b+=a.duration_ms)}),Math.round(b/1e5)},$(document).find(".browse > .content").on("scroll",function(b){var c=$(this).scrollTop(),d=$(this).outerHeight(),e=$(this).children(".inner").outerHeight(),f=-(c+d-e);100>=f&&a.$broadcast("spotmop:loadMore")}),a.$on("spotmop:playlist:reorder",function(b,c,e,f){var h=d.params.uri;g.movePlaylistTracks(h,c,e,f);for(var i=[],j=0;e>j;j++)i.push(a.tracklist.tracks[c+j]);f>c&&(f-=e),i.reverse(),a.$apply(function(){a.tracklist.tracks.splice(c,e),angular.forEach(i,function(b){a.tracklist.tracks.splice(f,0,b)})})}),g.getPlaylist(e.uri).then(function(c){a.playlist=c,a.tracklist.next=c.tracks.next,a.tracklist.previous=c.tracks.previous,a.tracklist.offset=c.tracks.offset,a.tracklist.total=c.tracks.total,a.tracklist.tracks=l(c.tracks.items),a.playlist.description=f.trustAsHtml(a.playlist.description),b.spotifyAuthorized&&g.isFollowingPlaylist(e.uri,i.getSetting("spotifyuser",{id:null}).id).then(function(b){a.following=$.parseJSON(b)}),"undefined"!=typeof e.categoryid&&g.getCategory(e.categoryid).then(function(b){a.category=b})}),a.$on("spotmop:keyboardShortcut:delete",function(b){a.playlist.owner.id!==i.getSetting("spotifyuserid")?k.error("Cannot delete from a playlist you don't own"):a.$broadcast("spotmop:tracklist:deleteSelectedTracks")});var n=!1;a.$on("spotmop:loadMore",function(){!n&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&m(a.tracklist.next)})}]),angular.module("spotmop.browse.user",[]).config(["$stateProvider",function(a){a.state("browse.user",{url:"/user/:uri",templateUrl:"app/browse/user/template.html",controller:"UserController"})}]).controller("UserController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists=a.playlists.concat(b.items),a.next=b.next,f=!1}))}a.user={},a.playlists=[],c.getUser(d.uri).then(function(b){a.user=b,c.getPlaylists(b.id).then(function(b){a.playlists=b.items,a.next=b.next,a.totalPlaylists=b.total})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.next&&a.next&&e(a.next)})}]),angular.module("spotmop.common.contextmenu",[]).directive("contextmenu",function(){return{restrict:"E",templateUrl:"app/common/contextmenu/template.html",link:function(a,b,c){},controller:["$scope","$rootScope","$element",function(a,b,c){a.play=function(){b.$broadcast("spotmop:tracklist:playSelectedTracks"),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.enqueue=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.unqueue=function(){b.$broadcast("spotmop:tracklist:unqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.playNext=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks",!0),c.fadeOut("fast"),a.isTouchDevice()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.addToPlaylist=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToPlaylist"),c.fadeOut("fast")},a.removeFromPlaylist=function(){b.$broadcast("spotmop:tracklist:deleteSelectedTracks"),c.fadeOut("fast")},a.addToLibrary=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToLibrary"),c.fadeOut("fast")},a.selectAll=function(){b.$broadcast("spotmop:tracklist:selectAll")},a.unselectAll=function(){b.$broadcast("spotmop:tracklist:unselectAll"),c.fadeOut("fast")},a.$on("spotmop:contextMenu:show",function(b,d,e,f){var g=d.pageY-$(window).scrollTop(),h=d.pageX-window.pageYOffset;"undefined"!=typeof f&&f&&(h-=c.outerWidth()),c.css({top:g,left:h+5}).show(),a.$apply(function(){a.context=e})}),a.$on("spotmop:touchContextMenu:show",function(b,d){c.show(),a.$apply(function(){a.context=d})}),a.$on("spotmop:contextMenu:hide",function(a){c.fadeOut("fast")})}]}}),angular.module("spotmop.directives",[]).config(["cfpLoadingBarProvider",function(a){a.latencyThreshold=250}]).directive("singleclick",function(){return function(a,b,c){b.bind("touchstart click",function(b){b.preventDefault(),b.stopPropagation(),a.$apply(c.singleclick)})}}).directive("switch",["$rootScope","SettingsService",function(a,b){return{restrict:"E",scope:{name:"@"},replace:!0,transclude:!0,link:function(c,d,e){c.on=b.getSetting(c.name,!1),d.bind("touchstart click",function(d){d.preventDefault(),d.stopPropagation(),c.$apply(function(){c.on=!c.on,b.setSetting(c.name,c.on),a.$broadcast("spotmop:settings:changed",{name:c.name,value:c.on})})})},template:''}}]).directive("scrollingPanel",function(){return{restrict:"C",link:function(a,b,c){b.on("scroll",function(b){var c=$(this).scrollTop(),d=$(this).outerHeight(),e=$(this).children(".inner").outerHeight(),f=-(c+d-e);100>=f&&a.$broadcast("spotmop:loadMore")})}}}).directive("thumbnail",["$timeout","$http",function(a,b){return{restrict:"E",scope:{images:"=",size:"="},replace:!0,transclude:!0,link:function(a,c,d){function e(b){if(b.length<=0)return!1;for(var c=0;c=100&&d.height<=200)return d;if(d.height>200&&d.height<=300)return d;if(d.height>300&&d.height<400)return d}else{if(d.height>=200&&d.height<=300)return d;if(d.height>300&&d.height<=500)return d;if(d.height>=150&&d.height<200)return d}}return b[0]}a.image=e(a.images),a.image&&b({method:"GET",url:a.image.url,cache:!0}).success(function(){c.css("background-image","url("+a.image.url+")")})},template:''}}]).directive("confirmationButton",function(){return{restrict:"E",controller:["$scope","$element",function(a,b){a.text="Button text",a.confirming=!1,a.text=a.defaultText,$(document).on("click",function(c){c.target==b[0]&&1==c.which?a.confirming?"function"==typeof a.$parent[a.onConfirmation]()&&a.$parent[a.onConfirmation]():(a.confirming=!0,a.text=a.confirmationText,a.$apply()):(a.confirming=!1,a.text=a.defaultText,a.$apply())})}],scope:{text:"@",extraClasses:"@",confirmationText:"@",defaultText:"@",onConfirmation:"@"},replace:!0,transclude:!0,template:''}}).directive("textOverImage",function(){return{restrict:"A",link:function(a,b){a.$on("spotmop:detectBackgroundColor",function(a){BackgroundCheck.init({targets:$.merge($(b).parent(),$(document).find("#utilities")),images:b.closest(".intro").find(".image")}),BackgroundCheck.refresh()})}}}).directive("preloadedimage",["$rootScope","$timeout",function(a,b){return{restrict:"E",scope:{url:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,c){function d(){var c="";c+=a.url;var d=$('');d.load(function(){b.attr("style",'background-image: url("'+c+'");');var d=1;"undefined"!=typeof a.opacity&&(d=a.opacity),b.animate({opacity:d},200)})}b.attr("watch")&&a.$watch("url",function(a,b){a&&d()},!0),d()},template:""}}]).directive("backgroundparallax",["$rootScope","$timeout","$interval","$http",function(a,b,c,d){return{restrict:"E",terminal:!0,scope:{image:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,d){function e(a){var c=b.outerWidth(),d=b.outerHeight();if((h.canvas.width!=c||h.canvas.height!=d)&&(h.canvas.width=c,h.canvas.height=d),a.widthc){var e=c/a.width;a.width=a.width*e,a.height=a.height*e}if(a.heightf&&e(i)}})},10)},template:''}}]).filter("nullOrUndefined",[function(){return function(a,b){for(var c=[],d=0;d=b&&(b="0"+b);var c=Math.floor(a/6e4%60);return c+":"+b}}).filter("stripAccents",function(){return function(a){for(var b=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],c=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],d=0;d=200&&c.height<=300)return c.url;if(c.height>300&&c.height<=500)return c.url;if(c.height>=150&&c.height<200)return c.url}return a[0].url}}),angular.module("spotmop.common.tracklist",["spotmop.services.mopidy"]).directive("track",function(){return{restrict:"E",templateUrl:"app/common/tracklist/track.template.html",controller:["$element","$scope","$rootScope","MopidyService","NotifyService",function(a,b,c,d,e){a.mouseup(function(a){1===a.which?(b.isTouchDevice()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$emit("spotmop:track:clicked",b)):b.track.selected&&3===a.which&&b.$emit("spotmop:contextMenu:show",a,"track")}),a.dblclick(function(a){for(var c=b.tracklist.tracks.indexOf(b.track),f=[],g=c+1;g0){var a="Adding "+f.length+" tracks";f.length>10&&(a+="... this could take some time"),e.notify(a),d.addToTrackList(f)}})})}]}}).directive("tltrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/tltrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService",function(a,b,c,d,e){b.state=e.state,a.mouseup(function(a){1===a.which?(b.isTouchDevice()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$emit("spotmop:track:clicked",b)):b.track.selected&&3===a.which&&b.$emit("spotmop:contextMenu:show",a,"tltrack")}),a.dblclick(function(a){d.getCurrentTlTracks().then(function(a){$.each(a,function(a,c){return c.tlid==b.track.tlid?d.playTlTrack({tl_track:c}):void 0})})})}]}}).directive("localtrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/localtrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService","NotifyService",function(a,b,c,d,e,f){b.state=e.state,a.mouseup(function(a){1===a.which?(b.isTouchDevice()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$emit("spotmop:track:clicked",b)):b.track.selected&&3===a.which&&b.$emit("spotmop:contextMenu:show",a,"localtrack")}),a.dblclick(function(a){for(var c=b.tracklist.tracks.indexOf(b.track),e=[],g=c+1;g0){var a="Adding "+e.length+" tracks";e.length>10&&(a+="... this could take some time"),f.notify(a),d.addToTrackList(e)}})})}]}}).controller("TracklistController",["$element","$scope","$filter","$rootScope","$stateParams","MopidyService","SpotifyService","DialogService","NotifyService",function(a,b,c,d,e,f,g,h,i){function j(){var a=c("filter")(b.tracklist.tracks,{selected:!0}),d=a[0];if("tltrack"==b.tracklist.type)f.getCurrentTlTracks().then(function(a){$.each(a,function(a,b){return b.tlid==d.tlid?f.playTlTrack({tl_track:b}):void 0})});else{for(var e=[],g=1;g10&&(h+="... this could take some time"),i.notify(h),f.playTrack([d.uri],0).then(function(){e.length>0&&f.addToTrackList(e)})}}$(document).contextmenu(function(a){return $(a.target).closest(".tracklist").length>0?!1:void 0}),b.$on("spotmop:track:dragging",function(a){}),b.$on("spotmop:track:clicked",function(a,e){if(d.ctrlKeyHeld||b.isTouchDevice()?e.track.selected?e.$apply(function(){e.track.selected=!1}):e.$apply(function(){e.track.selected=!0}):d.ctrlKeyHeld||(angular.forEach(b.tracklist.tracks,function(a){a.selected=!1}),e.$apply(function(){e.track.selected=!0})),d.shiftKeyHeld){var f="undefined"!=typeof b.lastSelectedTrack?b.lastSelectedTrack.$index:0,g=e.$index;e.$index=h;h++)b.tracklist.tracks[h].selected=!0;b.$apply()}b.lastSelectedTrack=e,b.isTouchDevice()&&(c("filter")(b.tracklist.tracks,{selected:!0}).length>0?d.$broadcast("spotmop:touchContextMenu:show",b.tracklist.type):d.$broadcast("spotmop:contextMenu:hide"))}),b.$on("spotmop:tracklist:enqueueSelectedTracks",function(a,d){var e=null;if("undefined"!=typeof d&&1==d){e=0;var g=b.state().currentTlTrack;if(g){var h=c("filter")(b.currentTracklist,{tlid:g.tlid});h.length>0&&(e=b.currentTracklist.indexOf(h[0])+1)}}var j=c("filter")(b.tracklist.tracks,{selected:!0}),k=[];angular.forEach(j,function(a){k.push(a.uri)});var l="Adding "+j.length+" tracks to queue";j.length>10&&(l+="... this could take some time"),i.notify(l),f.addToTrackList(k,e)}),b.$on("spotmop:tracklist:playSelectedTracks",function(){j()}),b.$on("spotmop:keyboardShortcut:enter",function(){j()}),b.$on("spotmop:tracklist:unqueueSelectedTracks",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a){e.push(a.tlid)}),f.removeFromTrackList(e)}),b.$on("spotmop:tracklist:deleteSelectedTracks",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),f=[];angular.forEach(d,function(a,c){f.push(b.tracklist.tracks.indexOf(a)),a.transitioning=!0}),g.deleteTracksFromPlaylist(e.uri,b.playlist.snapshot_id,f).then(function(a){"undefined"!=typeof a.error?(i.error(a.error.message),angular.forEach(d,function(a,b){a.transitioning=!1})):(b.tracklist.tracks=c("nullOrUndefined")(b.tracklist.tracks,"selected"),b.playlist.snapshot_id=a.snapshot_id)})}),b.$on("spotmop:tracklist:addSelectedTracksToPlaylist",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a){"undefined"!=typeof a.track?e.push(a.track.uri):e.push(a.uri)}),h.create("addToPlaylist",b)}),b.$on("spotmop:tracklist:addSelectedTracksToLibrary",function(a){var d=c("filter")(b.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a){"undefined"!=typeof a.track?e.push(g.getFromUri("trackid",a.track.uri)):e.push(g.getFromUri("trackid",a.uri))}),g.addTracksToLibrary(e)}),b.$on("spotmop:tracklist:selectAll",function(a){angular.forEach(b.tracklist.tracks,function(a){a.selected=!0})}),b.$on("spotmop:tracklist:unselectAll",function(a){angular.forEach(b.tracklist.tracks,function(a){a.selected=!1})})}]),angular.module("spotmop.common.tracklist.service",[]).factory("TracklistService",["$rootScope",function(a){return{getSelectedTracks:function(){console.log("triggered getSelectedTracks")}}}]),angular.module("spotmop.discover",[]).config(["$stateProvider",function(a){a.state("discover",{url:"/discover",templateUrl:"app/discover/template.html",controller:"DiscoverController"})}]).controller("DiscoverController",["$scope","$rootScope","SpotifyService","EchonestService","SettingsService","NotifyService",function(a,b,c,d,e,f){if(a.artists=[],a.playlists=[],a.albums=[],a.recommendations={currentArtist:{artists:[],recommendations:[]},suggestions:[]},e.getSetting("echonestenabled",!1)){if("undefined"!=typeof a.state().currentTlTrack.track){var g=[];angular.forEach(a.state().currentTlTrack.track.artists,function(a){g.push({name:a.name,name_encoded:encodeURIComponent(a.name),uri:a.uri})}),a.recommendations.currentArtist.artists=g,d.recommendedArtists(a.recommendations.currentArtist.artists).then(function(b){var d=b.response.artists,e=[];d.length<=0?f.error("Your taste profile is empty. Play some more music!"):(angular.forEach(d,function(a){"undefined"!=typeof a.foreign_ids&&a.foreign_ids.length>0&&e.push(a.foreign_ids[0].foreign_id)}),c.getArtists(e).then(function(b){a.recommendations.currentArtist.recommendations=b.artists}))})}d.recommendedArtists().then(function(b){var d=[];"undefined"!=typeof b.response&&"undefined"!=typeof b.response.artists&&(d=b.response.artists);var e=[];d.length<=0?f.error("Your taste profile is empty. Play some more music!"):(angular.forEach(d,function(a){e.push(a.foreign_ids[0].foreign_id)}),c.getArtists(e).then(function(b){a.recommendations.suggestions=b.artists}))})}}]),angular.module("spotmop.library",[]).config(["$stateProvider",function(a){a.state("library",{url:"/library",templateUrl:"app/library/template.html"}).state("library.playlists",{url:"/playlists",templateUrl:"app/library/playlists.template.html",controller:"LibraryPlaylistsController"}).state("library.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"}).state("library.tracks",{url:"/tracks",templateUrl:"app/library/tracks.template.html",controller:"LibraryTracksController"}).state("library.artists",{url:"/artists",templateUrl:"app/library/artists.template.html",controller:"LibraryArtistsController"}).state("library.albums",{url:"/albums",templateUrl:"app/library/albums.template.html",controller:"LibraryAlbumsController"}).state("library.files",{url:"/files/:folder",templateUrl:"app/library/files.template.html",controller:"LibraryFilesController"})}]).controller("LibraryTracksController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService",function(a,b,c,d,e,f){function g(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,b.push(c)}),b}function h(b){return"undefined"==typeof b?!1:(j=!0,void d.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(g(b.items)),a.tracklist.next=b.next,j=!1}))}a.tracklist={tracks:[]};var i=e.getSetting("spotifyuserid",a.$parent.spotifyUser.id);d.getMyTracks(i).then(function(b){a.tracklist=b,a.tracklist.tracks=g(b.items),"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()}),a.$on("spotmop:keyboardShortcut:delete",function(b){var e=c("filter")(a.tracklist.tracks,{selected:!0}),f=[];angular.forEach(e,function(a,b){f.push(d.getFromUri("trackid",a.uri))}),d.deleteTracksFromLibrary(f).then(function(b){a.tracklist.tracks=c("filter")(a.tracklist.tracks,{selected:!1})})});var j=!1;a.$on("spotmop:loadMore",function(){!j&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&h(a.tracklist.next)})}]).controller("LibraryFilesController",["$scope","$rootScope","$filter","$stateParams","SpotifyService","SettingsService","DialogService","MopidyService",function(a,b,c,d,e,f,g,h){function i(){h.getLibraryItems(k).then(function(b){var e=c("filter")(b,{type:"track"});a.tracklist.tracks=e;var f=j(c("filter")(b,{type:"directory"}));"local:directory"!=d.folder&&f.unshift({name:"..",uri:l,type:"directory",isParentFolder:!0}),a.folders=f})}function j(a){for(var b=0;b-1?e.lookup(a.track.uri).then(function(a){b(a[0])}):b(a))})}function o(){var a=p.currentTlTrack.track,b="No track playing";if(a){var c="■ ",d="";$.each(a.artists,function(a,b){""!=d&&(d+=", "),d+=b.name}),p.playing&&(c="▶ "),b=c+" "+a.name+" - "+d}document.title=b}var p={playing:!1,isRepeat:!1,isRandom:!1,isMute:!1,volume:100,playPosition:0,currentTlTrack:!1,playPositionPercent:function(){return p.currentTlTrack?(p.playPosition/p.currentTlTrack.track.length*100).toFixed(2):0}};a.$on("mopidy:state:online",function(){j(),n(),m(),l(),e.getState().then(function(a){"playing"==a?p.playing=!0:p.playing=!1})}),a.$on("mopidy:event:optionsChanged",function(a,b){j()}),a.$on("mopidy:event:playbackStateChanged",function(a,b){m(b.new_state)}),a.$on("mopidy:event:seeked",function(a,b){k(b.time_position)}),a.$on("mopidy:event:volumeChanged",function(a,b){b.volume!=p.volume&&l(b.volume)}),a.$on("mopidy:event:trackPlaybackStarted",function(a,b){("undefined"==typeof p.currentTlTrack.track||p.currentTlTrack.track.uri!=b.tl_track.track.uri)&&(p.currentTlTrack=b.tl_track,n(b.tl_track),m())}),b(function(){p.playing&&"undefined"!=typeof p.currentTlTrack&&p.playPosition=100&&(p.volume=100),q.setVolume(p.volume),h.shortcut("volume-up"))}),a.$on("spotmop:keyboardShortcut:down",function(b){a.ctrlKeyHeld&&(p.volume-=10,p.volume<0&&(p.volume=0),q.setVolume(p.volume),h.shortcut("volume-down"))});var q={state:function(){return p},playPause:function(){p.playing?(e.pause(),p.playing=!1):(e.play(),p.playing=!0)},stop:function(){e.stopPlayback(),p.playing=!1},next:function(){d.getSetting("echonestenabled",!1)&&g.addToTasteProfile("skip",p.currentTlTrack.track.uri),e.play(),e.next()},previous:function(){e.previous()},seek:function(a){p.playPosition=a,e.seek(a)},setVolume:function(a){p.volume=a,e.setVolume(a)},toggleRepeat:function(){p.isRepeat?e.setRepeat(!1).then(function(a){p.isRepeat=!1}):e.setRepeat(!0).then(function(a){p.isRepeat=!0}),console.log(p)},toggleRandom:function(){p.isRandom?e.setRandom(!1).then(function(a){p.isRandom=!1}):e.setRandom(!0).then(function(a){p.isRandom=!0})},toggleMute:function(){p.isMute?e.setMute(!1).then(function(a){p.isMute=!1}):e.setMute(!0).then(function(a){p.isMute=!0})}};return q}]),angular.module("spotmop.queue",[]).config(["$stateProvider",function(a){a.state("queue",{url:"/queue",templateUrl:"app/queue/template.html",controller:"QueueController"})}]).controller("QueueController",["$scope","$rootScope","$filter","$timeout","$state","MopidyService","SpotifyService",function(a,b,c,d,e,f,g){function h(b){var c=0;$.each(b,function(a,b){c+=b.track.length}),a.totalTime=Math.round(c/1e5)}a.totalTime=0,a.tracklist={type:"tltrack",tracks:a.$parent.currentTracklist},a.$watch(function(a){return a.$parent.currentTracklist},function(b,c){a.tracklist.tracks=b,h(b)}),a.$on("spotmop:keyboardShortcut:delete",function(b){var d=c("filter")(a.tracklist.tracks,{selected:!0}),e=[];angular.forEach(d,function(a,b){e.push(a.tlid)}),a.$apply(function(){a.tracklist.tracks=c("filter")(a.tracklist.tracks,{selected:!1})}),f.removeFromTrackList(e)})}]),angular.module("spotmop.search",[]).config(["$stateProvider",function(a){a.state("search",{url:"/search/:query/:type",templateUrl:"app/search/template.html",controller:"SearchController",params:{type:{squash:!0,value:"all"},query:{squash:!0,value:null}}})}]).controller("SearchController",["$scope","$rootScope","$state","$stateParams","$timeout","$filter","SpotifyService",function(a,b,c,d,e,f,g){function h(b,c){if("undefined"==typeof b)var b=a.type;switch(b){case"track":g.getSearchResults("track",c,50).then(function(b){a.tracklist=b.tracks,a.tracklist.tracks=b.tracks.items,a.tracklist.type="track",a.next=b.tracks.next});break;case"album":g.getSearchResults("album",c,50).then(function(b){a.albums=b.albums,a.next=b.albums.next});break;case"artist":g.getSearchResults("artist",c,50).then(function(b){a.artists=b.artists,a.next=b.artists.next});break;case"playlist":g.getSearchResults("playlist",c,50).then(function(b){a.playlists=b.playlists,a.next=b.playlists.next});break;default:g.getSearchResults("track",c,50).then(function(b){a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items}),g.getSearchResults("album",c,50).then(function(b){a.albums=b.albums}),g.getSearchResults("artist",c,50).then(function(b){a.artists=b.artists}),g.getSearchResults("playlist",c,50).then(function(b){a.playlists=b.playlists})}}function i(b){return"undefined"==typeof b?!1:(j=!0,void g.getUrl(b).then(function(b){switch(a.type){case"artist":a.artists.items=a.artists.items.concat(b.artists.items),a.next=b.artists.next;break;case"album":a.albums.items=a.albums.items.concat(b.albums.items),a.next=b.albums.next;break;case"track":a.tracklist.tracks=a.tracklist.tracks.concat(b.tracks.items),a.next=b.tracks.next;break;case"playlist":a.playlists.items=a.playlists.items.concat(b.playlists.items),a.next=b.playlists.next}j=!1}))}a.tracklist={tracks:[],type:"track"},a.albums=[],a.artists=[],a.playlists=[],a.type=d.type,a.query="",d.query&&(a.query=f("stripAccents")(d.query)),a.loading=!1;a.isTouchDevice()||$(document).find(".search-form input.query").focus(),a.query&&h(a.type,a.query);var j=!1;a.$on("spotmop:loadMore",function(){!j&&"undefined"!=typeof a.next&&a.next&&i(a.next)})}]),angular.module("spotmop.services.dialog",[]).factory("DialogService",["$rootScope","$compile","$interval","$timeout",function(a,b,c,d){return{create:function(a,c){"undefined"==typeof c&&(c=!1),$("body").children(".dialog").length>0&&console.log("A dialog already exists..."),$("body").append(b('')(c))},remove:function(){$("body").children(".dialog").fadeOut(200,function(){$(this).remove()})}}}]).directive("dialog",["$compile",function(a){return{restrict:"E",replace:!0,transclude:!0,scope:{type:"@"},templateUrl:"app/services/dialog/template.html",link:function(b,c){c.find(".content").html(a("<"+b.type+"dialog />")(b))},controller:["$scope","$element","DialogService",function(a,b,c){a.closeDisabled=!1,"initialsetup"==a.type&&(a.closeDisabled=!0),a.closeDialog=function(){c.remove()},a.$on("spotmop:keyboardShortcut:esc",function(b){a.closeDisabled||c.remove()})}]}}]).directive("createplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/createplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f){a.saving=!1,a.playlistPublic="true",a.savePlaylist=function(){a.saving=!0,"true"==a.playlistPublic?a.playlistPublic=!0:a.playlistPublic=!1,f.createPlaylist(a.$parent.spotifyUser.id,{name:a.playlistName,"public":a.playlistPublic}).then(function(b){a.$parent.playlists.items.push(b),a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})}}]}}).directive("editplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/editplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SpotifyService",function(a,b,c,d,e){a.playlistNewName=a.$parent.playlist.name,a.playlistNewPublic=a.$parent.playlist["public"].toString(),a.saving=!1,a.savePlaylist=function(){a.saving=!0,"true"==a.playlistNewPublic?a.playlistNewPublic=!0:a.playlistNewPublic=!1,e.updatePlaylist(a.$parent.playlist.uri,{name:a.playlistNewName,
+"public":a.playlistNewPublic}).then(function(b){a.$parent.playlist.name=a.playlistNewName,a.$parent.playlist["public"]=a.playlistNewPublic,a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})}}]}}).directive("addtoplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/addtoplaylist.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SpotifyService","SettingsService",function(a,b,c,d,e,f,g){a.playlists=[];var h=g.getSetting("spotifyuser",{id:"undefined"}).id;f.getPlaylists(h,50).then(function(b){a.playlists=d("filter")(b.items,{owner:{id:h}})}),a.playlistSelected=function(b){var g=d("filter")(a.$parent.tracklist.tracks,{selected:!0}),h=[];angular.forEach(g,function(a){"undefined"!=typeof a.track?h.push(a.track.uri):h.push(a.uri)}),f.addTracksToPlaylist(b.uri,h).then(function(b){e.remove(),c.$broadcast("spotmop:tracklist:unselectAll"),a.$emit("spotmop:notifyUser",{id:"adding-to-playlist",message:"Added "+h.length+" tracks",autoremove:!0})})}}]}}).directive("volumecontrolsdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/volumecontrols.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","PlayerService",function(a,b,c,d,e,f){a.state=function(){return f.state()},a.setVolume=function(a){var b,c,d,e;b=$(a.target).hasClass("slider")?$(a.target):$(a.target).closest(".slider"),c=b.offset(),d=a.pageX-c.left,e=d/b.innerWidth()*100,e=parseInt(e),f.setVolume(e)}}]}}).directive("initialsetupdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/initialsetup.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f,g){f.setSetting("attemptSpotifyAuthorization",!0),a.saving=!1,a.save=function(){a.name&&""!=a.name?(a.saving=!0,f.getSetting("attemptSpotifyAuthorization",!1)&&g.authorize(),f.setSetting("pushername",a.name),e.remove()):a.error=!0}}]}}),angular.module("spotmop.services.echonest",[]).factory("EchonestService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$cacheFactory","$q","SettingsService",function(a,b,c,d,e,f,g,h,i){var j="http://developer.echonest.com/api/v4/",k=i.getSetting("echonestapikey","YVW64VSEPEV93M4EG");return{isOnline:!1,start:function(){i.setSetting("echonestenabled",!0),i.getSetting("echonesttasteprofileid",!1)?this.getTasteProfile(i.getSetting("echonesttasteprofileid",!1)).success(function(b){this.isOnline=!0,a.echonestOnline=!0,c.echonesttasteprofile=b.response.catalog}).error(function(b){this.isOnline=!1,a.echonestOnline=!1}):this.createTasteProfile().success(function(b){i.setSetting("echonesttasteprofileid",b.response.id),this.isOnline=!0,a.echonestOnline=!0}).error(function(b){this.isOnline=!1,a.echonestOnline=!1})},stop:function(){i.setSetting("echonestenabled",!1),a.echonestOnline=!1},createTasteProfile:function(){return $.ajax({url:j+"catalog/create",method:"POST",data:{api_key:k,format:"json",type:"general",name:"spotmop:"+Date.now()+Math.round(1e3*(Math.random()+1))}})},getTasteProfile:function(){var a=i.getSetting("echonesttasteprofileid",!1);return $.ajax({url:j+"tasteprofile/read?api_key="+k+"&id="+a,method:"GET"})},addToTasteProfile:function(a,b){var c=i.getSetting("echonesttasteprofileid",!1),d=[],e=[];return e="string"==typeof b?[b]:b,angular.forEach(e,function(b){d.push({action:a,item:{track_id:b}})}),$.ajax({url:j+"tasteprofile/update",method:"POST",data:{api_key:k,format:"json",data_type:"json",id:c,data:JSON.stringify(d)}})},getArtistBiography:function(b){var c=h.defer();return d({cache:!0,method:"GET",url:j+"artist/biographies?api_key="+k+"&format=json&results=1&id="+b}).success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"getArtistBiography",message:b.error.message}),c.reject(b.error.message)}),c.promise},recommendedArtists:function(b){var c=i.getSetting("echonesttasteprofileid",!1);if("undefined"==typeof b||!b||b.length<=0)var e="&seed_catalog="+c;else{var e="";angular.forEach(b,function(a){e+="&name="+a.name_encoded})}var f=h.defer();return d.get(j+"artist/similar?api_key="+k+e+"&format=json&bucket=id:spotify&results=10").success(function(a){f.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"catalogRadio",message:b.error.message}),f.reject("Failed to get albums")}),f.promise},favoriteArtists:function(){var b=i.getSetting("echonesttasteprofileid",!1),c=h.defer();return d.get(j+"playlist/static?api_key="+k+"&type=catalog&seed_catalog="+b+"&bucket=id:spotify&format=json&results=20&adventurousness=0").success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"favoriteArtists",message:b.error.message}),c.reject("Failed to get albums")}),c.promise},catalogRadio:function(){var b=i.getSetting("echonesttasteprofileid",!1),c=h.defer();return d.get(j+"playlist/static?api_key="+k+"&type=catalog-radio&seed_catalog="+b+"&bucket=artist_discovery&bucket=id:spotify&format=json&results=20").success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"catalogRadio",message:b.error.message}),c.reject("Failed to get albums")}),c.promise},startArtistRadio:function(b){var c=h.defer();return d.get(j+"playlist/dynamic/create?api_key="+k+"&type=artist-radio&artist="+b+"&bucket=tracks&bucket=id:spotify&results=1").success(function(a){c.resolve(a)}).error(function(b){a.$broadcast("spotmop:notifyUser",{type:"bad",id:"artistRadio",message:b.error.message}),c.reject("Failed to create artist radio")}),c.promise}}}]),angular.module("spotmop.services.lastfm",[]).factory("LastfmService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j){var k={sendRequest:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:l+"?format=json&api_key="+m+"&"+a}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},trackInfo:function(a,b){return this.sendRequest("method=track.getInfo&track="+b+"&artist="+a)},albumInfo:function(a,b){return this.sendRequest("method=album.getInfo&album="+b+"&artist="+a)},artistInfo:function(a){return this.sendRequest("method=artist.getInfo&artist="+a)}},l="http://ws.audioscrobbler.com/2.0",m=i.getSetting("lastfmkey","4320a3ef51c9b3d69de552ac083c55e3");return k}]),angular.module("spotmop.services.mopidy",[]).factory("MopidyService",["$q","$rootScope","$cacheFactory","$location","$timeout","SettingsService","EchonestService","PusherService",function(a,b,c,d,e,f,g,h){function i(c,d){return function(){var e=a.defer(),f=Array.prototype.slice.call(arguments),g=d||this;return b.$broadcast("spotmop:callingmopidy",{name:c,args:f}),g.isConnected?j(c,g,f).then(function(a){e.resolve(a),b.$broadcast("spotmop:calledmopidy",{name:c,args:f})},function(a){e.reject(a),b.$broadcast("spotmop:errormopidy",{name:c,args:f,err:a})}):j(c,g,f).then(function(a){e.resolve(a),b.$broadcast("spotmop:calledmopidy",{name:c,args:f})},function(a){e.reject(a),b.$broadcast("spotmop:errormopidy",{name:c,args:f,err:a})}),e.promise}}function j(a,b,c){for(var d=a.split("."),e=d.pop(),f=0;f'+a+"");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},error:function(a,b){if("undefined"==typeof b)var b=2500;var c=$(''+a+"");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},spotifyAuthenticationError:function(){this.error("Please authenticate with Spotify - you can find this under settings")},shortcut:function(a){$("#notifications").find("notification.keyboard-shortcut").remove();var b=$('');$("#notifications").append(b),d(function(){b.fadeOut(200,function(){b.remove()})},1500)},browserNotify:function(a,b,c){if(e.getSetting("notificationsDisabled",!1))return!1;var d=window.Notification||window.mozNotification||window.webkitNotification;if("undefined"==typeof d)return!1;if("undefined"!=typeof d&&d.requestPermission(function(a){}),"undefined"==typeof c)var c="";new d(a,{body:b,dir:"auto",lang:"EN",tag:"spotmopNotification",icon:c});return!0}}}]).directive("notification",function(){return{restrict:"AE",link:function(a,b,c){console.log(b)}}}),angular.module("spotmop.services.pusher",[]).factory("PusherService",["$rootScope","$http","$q","$localStorage","$cacheFactory","$templateCache","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h){"undefined"==typeof d.pusher&&(d.pusher={});var i="http://"+g.getSetting("mopidyhost",window.location.hostname);i+=":"+g.getSetting("mopidyport","6680"),i+="/spotmop/";var j={pusher:{},isConnected:!1,start:function(){var b=g.getSetting("mopidyhost",window.location.hostname),c=g.getSetting("pusherport","6681");try{var d="ws://"+b+":"+c+"/pusher",i=new WebSocket(d);i.onopen=function(){a.$broadcast("spotmop:pusher:online"),this.isConnected=!0},i.onmessage=function(b){var c=JSON.parse(b.data);if(c.pusher)if(c.startup){console.info("Pusher connected as "+c.details.id),g.setSetting("pusherid",c.details.id),g.setSetting("pusherip",c.details.ip),g.getSetting("version",0,"installed")!=c.version&&(h.notify("New version detected, clearing caches..."),e.get("$http").removeAll(),f.removeAll(),g.setSetting("version",c.version,"installed"));var d=g.getSetting("pushername","");d&&j.setMe(d)}else c.id==g.getSetting("pusherid","")||g.getSetting("pusherdisabled",!1)||a.$broadcast("spotmop:pusher:received",c)},i.onclose=function(){a.$broadcast("spotmop:pusher:offline"),j.isConnected=!1,setTimeout(function(){j.start()},5e3)},j.pusher=i}catch(k){console.log("Connecting with Pusher failed with the following error message: "+k)}},stop:function(){this.pusher=null,this.isConnected=!1},send:function(a){a.pusher=!0,a.id=g.getSetting("pusherid",null),j.pusher.send(JSON.stringify(a))},setMe:function(a){var b=g.getSetting("pusherid",null);$.ajax({method:"GET",cache:!1,url:i+"pusher/me?id="+b+"&name="+a})},getConnections:function(){var a=c.defer();return b({method:"GET",cache:!1,url:i+"pusher/connections"}).success(function(b){a.resolve(b)}).error(function(b){h.error(b.error.message),a.reject(b.error.message)}),a.promise}};return j}]),angular.module("spotmop.services.spotify",[]).factory("SpotifyService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j){var k={authenticationMethod:"server",start:function(){var b=$('');$(body).append(b),"undefined"==typeof c.spotify&&(c.spotify={}),"undefined"==typeof c.spotify.AccessToken&&(c.spotify.AccessToken=null),"undefined"==typeof c.spotify.RefreshToken&&(c.spotify.RefreshToken=null),"undefined"==typeof c.spotify.AuthorizationCode&&(c.spotify.AuthorizationCode=null),"undefined"==typeof c.spotify.AccessTokenExpiry&&(c.spotify.AccessTokenExpiry=null),window.addEventListener("message",function(b){if("http://jamesbarnsley.co.nz"!==b.origin)return!1;var d=JSON.parse(b.data);console.info("Spotify authorization successful"),c.spotify.AuthorizationCode=d.authorization_code,c.spotify.AccessToken=d.access_token,c.spotify.RefreshToken=d.refresh_token,a.spotifyOnline=!0,this.authenticationMethod="client",k.getMe().then(function(b){i.setSetting("spotifyuser",b),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)})},!1),this.isAuthorized()?(a.spotifyAuthorized=!0,this.authenticationMethod="client"):(i.setSetting("spotifyuser",!1),a.spotifyAuthorized=!1,this.authenticationMethod="server"),a.$broadcast("spotmop:spotify:online")},logout:function(){c.spotify={},this.authenticationMethod="server",this.refreshToken(),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)},authorize:function(){var a=$(document).find("#authorization-frame");a.attr("src","http://jamesbarnsley.co.nz/spotmop.php?action=authorize&app="+location.protocol+"//"+window.location.host)},isAuthorized:function(){return c.spotify.AuthorizationCode&&c.spotify.RefreshToken?!0:!1},refreshToken:function(){var b=h.defer(),e="";if("client"==this.authenticationMethod)e="http://jamesbarnsley.co.nz/spotmop.php?action=refresh&refresh_token="+c.spotify.RefreshToken;else{if("server"!=this.authenticationMethod)return!1;var f=i.getSetting("mopidyhost",window.location.hostname),g=i.getSetting("mopidyport","6680");e="http://"+f+":"+g+"/spotmop/auth"}return d({method:"GET",url:e,dataType:"json",async:!1,timeout:1e4}).success(function(d){"undefined"!=typeof d.error?(j.error("Spotify authorization error: "+d.error_description),a.spotifyOnline=!1,b.reject(d.error.message)):(c.spotify.AccessToken=d.access_token,c.spotify.AccessTokenExpiry=(new Date).getTime()+36e5,a.spotifyOnline=!0,b.resolve(d))}),b.promise},getFromUri:function(a,b){var c=b.split(":");return"userid"==a&&"user"==c[1]?c[2]:"playlistid"==a&&"playlist"==c[3]?c[4]:"artistid"==a&&"artist"==c[1]?c[2]:"albumid"==a&&"album"==c[1]?c[2]:"trackid"==a&&"track"==c[1]?c[2]:null},uriType:function(a){var b=a.split(":");return"spotify"==b[0]&&"artist"==b[1]?"artist":"spotify"==b[0]&&"album"==b[1]?"album":"spotify"==b[0]&&"user"==b[1]&&"playlist"==b[3]?"playlist":null},getUrl:function(a){var b=h.defer();return d({method:"GET",url:a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getMe:function(){var a=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(b){a.resolve(b)}).error(function(b){j.error(b.error.message),a.reject(b.error.message)}),a.promise):(a.reject(),a.promise)},getUser:function(a){var b=this.getFromUri("userid",a),c=h.defer();return d({method:"GET",url:l+"users/"+b}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},isFollowing:function(a,b){var e=this.getFromUri(a+"id",b),f=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/following/contains?type="+a+"&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},getTrack:function(a){var b=this.getFromUri("trackid",a),c=h.defer();return d({method:"GET",url:l+"tracks/"+b}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getMyTracks:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/tracks/",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},addTracksToLibrary:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"PUT",url:l+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},deleteTracksFromLibrary:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"DELETE",url:l+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},getMyArtists:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:l+"me/following?type=artist",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},isFollowingArtist:function(a,b){var e=this.getFromUri("artistid",a),f=h.defer();return this.isAuthorized()?(d({cache:!1,method:"GET",url:l+"me/following/contains?type=artist&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},followArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"PUT",cache:!1,url:l+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},unfollowArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"DELETE",cache:!1,url:l+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},getPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!1,method:"GET",url:l+"users/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise},getPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return d({cache:!0,method:"GET",url:l+"users/"+b+"/playlists/"+e+"?market="+m,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise},isFollowingPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({cache:!0,method:"GET",url:l+"users/"+e+"/playlists/"+f+"/followers/contains?ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){j.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},followPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"PUT",url:l+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},unfollowPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"DELETE",url:l+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},featuredPlaylists:function(a){"undefined"==typeof a&&(a=40);var b=g("date")(new Date,"yyyy-MM-ddTHH:mm:ss"),e=i.getSetting("countrycode","NZ"),f=h.defer();return d({cache:!0,method:"GET",url:l+"browse/featured-playlists?timestamp="+b+"&country="+e+"&limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise},addTracksToPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"POST",url:l+"users/"+e+"/playlists/"+f+"/tracks",dataType:"json",data:JSON.stringify({uris:b}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){j.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},movePlaylistTracks:function(a,b,e,f){var g=this.getFromUri("userid",a),k=this.getFromUri("playlistid",a);if(g!=i.getSetting("spotifyuserid",null))return!1;if(!this.isAuthorized())return m.reject(),m.promise;var m=h.defer();return d({method:"PUT",url:l+"users/"+g+"/playlists/"+k+"/tracks",dataType:"json",data:JSON.stringify({range_start:b,range_length:e,insert_before:f}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){m.resolve(a)}).error(function(a){j.error(a.error.message),m.reject(a.error.message)}),m.promise},deleteTracksFromPlaylist:function(a,b,e){var f=this.getFromUri("userid",a),g=this.getFromUri("playlistid",a),i=h.defer();return d({method:"DELETE",url:l+"users/"+f+"/playlists/"+g+"/tracks",dataType:"json",data:JSON.stringify({snapshot_id:b,positions:e}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){i.resolve(a)}).error(function(a){j.error(a.error.message),i.reject(a.error.message)}),i.promise},createPlaylist:function(a,b){var e=h.defer();return this.isAuthorized()?(d({method:"POST",url:l+"users/"+a+"/playlists/",dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},updatePlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"PUT",url:l+"users/"+e+"/playlists/"+f,dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){j.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},newReleases:function(a){"undefined"==typeof a&&(a=40);var b=h.defer();return d({cache:!0,method:"GET",url:l+"browse/new-releases?country="+m+"&limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},discoverCategories:function(a){"undefined"==typeof a&&(a=40);var b=h.defer();return d({cache:!0,method:"GET",url:l+"browse/categories?limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategory:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:l+"browse/categories/"+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategoryPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!0,method:"GET",url:l+"browse/categories/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise},getArtist:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getArtists:function(a){var b=this,c="";angular.forEach(a,function(a){""!=c&&(c+=","),c+=b.getFromUri("artistid",a)});var e=h.defer();return d({method:"GET",url:l+"artists/?ids="+c}).success(function(a){e.resolve(a)}).error(function(a){j.error(a.error.message),e.reject(a.error.message)}),e.promise},getAlbums:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b+"/albums?album_type=album,single&market="+m}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getAlbum:function(a){var b=h.defer(),c=this.getFromUri("albumid",a);return d({method:"GET",url:l+"albums/"+c}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},getTopTracks:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b+"/top-tracks?country="+m}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getRelatedArtists:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:l+"artists/"+b+"/related-artists"}).success(function(a){c.resolve(a)}).error(function(a){j.error(a.error.message),c.reject(a.error.message)}),c.promise},getSearchResults:function(a,b,e){"undefined"==typeof e&&(e=10);var f=h.defer();return d({cache:!0,method:"GET",url:l+"search?q="+b+"&type="+a+"&country="+m+"&limit="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){j.error(a.error.message),f.reject(a.error.message)}),f.promise}},l="https://api.spotify.com/v1/",m=i.getSetting("spotifycountry","NZ");i.getSetting("spotifylocale","en_NZ");return k}]).factory("SpotifyServiceIntercepter",["$q","$rootScope","$injector","$localStorage",function(a,b,c,d){"use strict";function e(a,b,d){function e(a){b.resolve(a)}function f(a){b.reject(a)}var g=c.get("$http");a.headers={Authorization:"Bearer "+d},g(a).then(e,f)}var f=0,g={responseError:function(b){if(401==b.status&&b.config.url.search("https://api.spotify.com/")>=0&&3>f){f++;var d=a.defer();return c.get("SpotifyService").refreshToken().then(function(a){return"undefined"!=typeof a.error?b:(f--,void e(b.config,d,a.access_token))}),d.promise}return b}};return g}]),angular.module("spotmop.settings",[]).config(["$stateProvider",function(a){a.state("settings",{url:"/settings",templateUrl:"app/settings/template.html"})}]).controller("SettingsController",["$scope","$http","$rootScope","$timeout","MopidyService","SpotifyService","EchonestService","SettingsService","NotifyService","PusherService",function(a,b,c,d,e,f,g,h,i,j){a.version,a.settings=h.getSettings(),a.currentSubpage="mopidy",a.subpageNavigate=function(b){a.currentSubpage=b},a.authorizeSpotify=function(){f.authorize()},a.refreshSpotifyToken=function(){i.notify("Refreshing token"),f.refreshToken().then(function(){})},a.spotifyLogout=function(){f.logout()},a.upgradeCheck=function(){i.notify("Checking for updates"),
+h.upgradeCheck().then(function(a){h.setSetting("version",a,"latest"),h.getSetting("version",0,"installed")