text: !function(){function t(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}function i(t,i){for(var s=0;s<i.length;s++){var a=i[s];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{kez3:function(s,a,n){"use strict";n.r(a),n.d(a,"PlaylistsModule",(function(){return $}));var e=n("ofXK"),l=n("3Pt+"),r=n("hDf6"),c=n("tyNb"),o=n("ufXC"),b=n("OgP6"),p=n("ktVm"),u=n("t083"),h=n("XtVx"),f=n("KI15"),g=n("Gcu2"),y=n("fXoL"),d=n("Oz9T"),m=n("cpgm");function v(t,i){if(1&t){var s=y.Mb();y.Lb(0,"li",6),y.Lb(1,"a",8),y.Sb("click",(function(){return y.lc(s),y.Wb().setPlaylist("current")})),y.pc(2,"Current playlist"),y.Kb(),y.Kb()}}function k(t,i){if(1&t){var s=y.Mb();y.Lb(0,"a",8),y.Sb("click",(function(){return y.lc(s),y.Wb().setPlaylist("last.fm")})),y.pc(1,"Loved tracks on last.fm"),y.Kb()}}function L(t,i){if(1&t){var s=y.Mb();y.Lb(0,"a",8),y.Sb("click",(function(){return y.lc(s),y.Wb().setPlaylist("radio")})),y.pc(1),y.Kb()}if(2&t){var a=y.Wb();y.xb(1),y.rc("",a.playlistService.numberOfTracksInAPlaylist," tracks by preference")}}function K(t,i){if(1&t){var s=y.Mb();y.Lb(0,"li",6),y.Lb(1,"a",11),y.Sb("click",(function(){y.lc(s);var t=i.$implicit;return y.Wb().setPlaylist(t)})),y.pc(2),y.Lb(3,"a",11),y.Sb("click",(function(){y.lc(s);var t=i.$implicit;return y.Wb().removePlaylist(t)})),y.Jb(4,"span",12),y.Kb(),y.Kb(),y.Kb()}if(2&t){var a=i.$implicit;y.xb(2),y.rc("",a.name," ")}}function S(t,i){if(1&t&&(y.Lb(0,"p",17),y.pc(1),y.Kb()),2&t){var s=y.Wb(2);y.xb(1),y.rc("Tracks found: ",s.playlist.tracks.length,"")}}function x(t,i){if(1&t&&(y.Lb(0,"div",13),y.Jb(1,"br"),y.oc(2,S,2,1,"p",14),y.Lb(3,"div",15),y.Jb(4,"div",16),y.Jb(5,"div",16),y.Jb(6,"div",16),y.Jb(7,"div",16),y.Jb(8,"div",16),y.Kb(),y.Kb()),2&t){var s=y.Wb();y.xb(2),y.cc("ngIf",s.playlist&&s.playlist.tracks&&s.playlist.tracks.length>0)}}function I(t,i){if(1&t&&y.Jb(0,"mdb-tracklist",22),2&t){var s=y.Wb(3);y.cc("playlist",s.playlist)}}function P(t,i){if(1&t&&(y.Lb(0,"div",0),y.oc(1,I,1,1,"mdb-tracklist",21),y.Kb()),2&t){var s=y.Wb(2);y.xb(1),y.cc("ngIf",!s.loading)}}function w(t,i){1&t&&(y.Lb(0,"div",0),y.Lb(1,"div",2),y.Lb(2,"div",23),y.Lb(3,"p"),y.pc(4," Unfortunately this playlist is empty :( "),y.Jb(5,"br"),y.pc(6,"Find some tracks from an "),y.Lb(7,"a",24),y.Jb(8,"span",25),y.pc(9," artist"),y.Kb(),y.pc(10,", "),y.Lb(11,"a",26),y.Jb(12,"span",27),y.pc(13," album"),y.Kb(),y.pc(14," or a "),y.Lb(15,"a",28),y.Jb(16,"span",29),y.pc(17," year"),y.Kb(),y.Kb(),y.Kb(),y.Kb(),y.Kb())}function A(t,i){if(1&t&&(y.Lb(0,"div",13),y.Lb(1,"h4",18),y.pc(2),y.Lb(3,"span",19),y.pc(4),y.Xb(5,"timeFormat"),y.Kb(),y.Kb(),y.oc(6,P,2,1,"div",20),y.oc(7,w,18,0,"div",20),y.Kb()),2&t){var s=y.Wb();y.xb(2),y.rc(" ",s.playlist.name," "),y.xb(2),y.sc("(",s.playlist.tracks.length," / ",y.Yb(5,5,s.playlistLength)," )"),y.xb(2),y.cc("ngIf",s.playlist&&s.playlist.tracks&&0!==s.playlist.tracks.length),y.xb(1),y.cc("ngIf",s.playlist&&s.playlist.tracks&&0===s.playlist.tracks.length)}}function C(t,i){if(1&t&&(y.Lb(0,"option"),y.pc(1),y.Kb()),2&t){var s=i.$implicit;y.xb(1),y.qc(s.name)}}var F=function(t){return{"theme-alt":t}};function J(t,i){if(1&t){var s=y.Mb();y.Lb(0,"div",13),y.Lb(1,"h4",30),y.pc(2," Select an artist as starting point "),y.Kb(),y.Lb(3,"form",31,32),y.Lb(5,"div",33),y.Lb(6,"label",34),y.pc(7,"Select an artist"),y.Kb(),y.Lb(8,"div",35),y.Lb(9,"select",36,37),y.Sb("ngModelChange",(function(t){return y.lc(s),y.Wb().startingArtistName=t}))("ngModelChange",(function(t){return y.lc(s),y.Wb().onChange(t)})),y.oc(11,C,2,1,"option",38),y.Kb(),y.Kb(),y.Kb(),y.Kb(),y.Kb()}if(2&t){var a=y.Wb();y.xb(3),y.cc("ngClass",y.fc(3,F,"dark"===a.theme)),y.xb(6),y.cc("ngModel",a.startingArtistName),y.xb(2),y.cc("ngForOf",a.artists)}}var T,W,O,M=[{path:"",component:(T=function(){function s(i,a,n,e,l,r,c){var o=this;t(this,s),this.pathService=i,this.coreService=a,this.router=n,this.playerService=e,this.lastfmservice=l,this.configService=r,this.playlistService=c,this.playlistLength=0,this.loading=!1,this.username=localStorage.getItem("lastfm-username"),this.showStartingArtist=!1,this.ownPlaylists=[],this.artists=[];var b=this.playerService.getCurrentPlaylist();b&&(this.currentPlaylist=b.playlist,this.trackIndex=b.startIndex,this.setTrack()),this.subscription=this.playerService.playlistAnnounced$.subscribe((function(t){o.currentPlaylist=t.playlist,o.trackIndex=t.startIndex,o.setTrack()})),this.core=this.coreService.getCore(),this.subscription2=this.core.coreParsed$.subscribe((function(t){o.ngOnInit()})),this.theme=r.mode,this.newPlaylist=new f.a}var a,n,e;return a=s,(n=[{key:"setTrack",value:function(){this.track=this.currentPlaylist.tracks[this.trackIndex],this.track&&(this.track.position=0)}},{key:"ngOnInit",value:function(){this.pathService.announcePage("Playlists"),this.artists=this.core.artistsList(),this.ownPlaylists=[]}},{key:"ngOnDestroy",value:function(){this.subscription.unsubscribe(),this.subscription2.unsubscribe()}},{key:"setPlaylist",value:function(t){var i=this;this.loading=!0,this.showStartingArtist=!1,"current"===t?(this.playlist=this.currentPlaylist,this.calculateLength(),this.loading=!1):"last.fm"===t?this.lastfmservice.getLovedTracks(this.username).subscribe((function(t){i.playlist=i.playlistService.extractTracks(t.lovedtracks.track),i.calculateLength(),i.loading=!1})):"random"===t?(this.playlist=this.playlistService.generateRandom(),this.playlist.isContinues=!0,this.playlist.type=t,this.calculateLength(),this.loading=!1):"radio"===t?this.playlist=this.generateRadio():"artist"===t?this.askForStartingArtist():t instanceof f.a?(this.playlist=t,this.calculateLength(),this.loading=!1):console.info("unknown playlist",t)}},{key:"generateRadio",value:function(){var t=this;this.lastfmservice.getTopArtists(this.username).subscribe((function(i){t.playlist=t.playlistService.extractArtists(i=i.topartists.artist),t.playlist.isContinues=!0,t.playlist.type="radio",t.calculateLength(),t.loading=!1}))}},{key:"onChange",value:function(){var t=this.core.getArtistByName(this.startingArtistName),i=new f.a;i.name="Artist radio for "+t.name,i.tracks=[this.playlistService.getRandomTrackFromList([t])],this.showStartingArtist=!1,this.playlist=i,this.getNextSimilairArtist(t,this.playlist)}},{key:"getNextSimilairArtist",value:function(t,i){var s=this;this.loading=!0,this.lastfmservice.getSimilairArtists(t).subscribe((function(t){t=t.similarartists.artist,s.loading=!1;var a=[];if(t.forEach((function(t){var i=s.core.getArtistByName(t.name);i&&a.push(i)})),a.length>0){var n=s.playlistService.getNextTrackForPlaylist(a,i);n&&i.tracks.length<s.playlistService.numberOfTracksInAPlaylist&&(i.tracks.push(n),s.getNextSimilairArtist(n.artist,i))}s.calculateLength()}))}},{key:"askForStartingArtist",value:function(){this.loading=!1,this.playlist=null,this.showStartingArtist=!0}},{key:"calculateLength",value:function(){var t=this;this.playlistLength=0,this.playlist.tracks.forEach((function(i){t.playlistLength+=i.duration}))}}])&&i(a.prototype,n),e&&i(a,e),s}(),T.\u0275fac=function(t){return new(t||T)(y.Ib(h.a),y.Ib(p.a),y.Ib(c.c),y.Ib(o.a),y.Ib(u.a),y.Ib(b.a),y.Ib(g.a))},T.\u0275cmp=y.Cb({type:T,selectors:[["app-playlists"]],decls:22,vars:8,consts:[[1,"animated-page"],[1,"container"],[1,"row"],[1,"col-12","col-lg-3","playlists-lg-fixed"],[1,"nav","flex-column"],["class","nav-item",4,"ngIf"],[1,"nav-item"],["class","btn btn-link px-0",3,"click",4,"ngIf"],[1,"btn","btn-link","px-0",3,"click"],["class","nav-item",4,"ngFor","ngForOf"],["class","col-12 col-lg-9 offset-lg-3",4,"ngIf"],[3,"click"],[1,"glyph","glyph-delete"],[1,"col-12","col-lg-9","offset-lg-3"],["class","small muted",4,"ngIf"],[1,"progress-bar"],[1,"progress-circle"],[1,"small","muted"],[1,"playlists-header"],[1,"small","muted","color-type-secondary"],["class","animated-page",4,"ngIf"],[3,"playlist",4,"ngIf"],[3,"playlist"],[1,"col"],["routerLink","/artists"],[1,"glyph","glyph-people"],["routerLink","/albums"],[1,"glyph","glyph-music-album"],["routerLink","/years"],[1,"glyph","glyph-calendar"],["sticky","",1,"header-seperator"],["role","form",3,"ngClass"],["sortForm","ngForm"],[1,"form-group","row"],["for","sort",1,"col-12","col-sm-3","col-form-label"],[1,"col","col-sm-9"],["name","sort","id","sort",1,"form-control",3,"ngModel","ngModelChange"],["name","ngModel"],[4,"ngFor","ngForOf"]],template:function(t,i){1&t&&(y.Lb(0,"div",0),y.Lb(1,"div",1),y.Lb(2,"div",2),y.Lb(3,"div",3),y.Lb(4,"h4"),y.pc(5,"Playlists"),y.Kb(),y.Lb(6,"ul",4),y.oc(7,v,3,0,"li",5),y.Lb(8,"li",6),y.oc(9,k,2,0,"a",7),y.Kb(),y.Lb(10,"li",6),y.Lb(11,"a",8),y.Sb("click",(function(){return i.setPlaylist("random")})),y.pc(12),y.Kb(),y.Kb(),y.Lb(13,"li",6),y.oc(14,L,2,1,"a",7),y.Kb(),y.Lb(15,"li",6),y.Lb(16,"a",8),y.Sb("click",(function(){return i.setPlaylist("artist")})),y.pc(17,"Artist radio"),y.Kb(),y.Kb(),y.oc(18,K,5,1,"li",9),y.Kb(),y.Kb(),y.oc(19,x,9,1,"div",10),y.oc(20,A,8,7,"div",10),y.oc(21,J,12,5,"div",10),y.Kb(),y.Kb(),y.Kb()),2&t&&(y.xb(7),y.cc("ngIf",i.currentPlaylist),y.xb(2),y.cc("ngIf",i.username&&"mdb-skipped"!==i.username),y.xb(3),y.rc("",i.playlistService.numberOfTracksInAPlaylist," random tracks"),y.xb(2),y.cc("ngIf",i.username&&"mdb-skipped"!==i.username),y.xb(4),y.cc("ngForOf",i.ownPlaylists),y.xb(1),y.cc("ngIf",i.loading),y.xb(1),y.cc("ngIf",i.playlist&&!i.loading&&!i.showStartingArtist),y.xb(1),y.cc("ngIf",i.showStartingArtist&&!i.loading&&!i.playlist))},directives:[e.k,e.j,d.a,c.d,l.m,l.d,l.e,e.i,l.k,l.c,l.f,l.g,l.l],pipes:[m.a],encapsulation:2}),T)}],N=((O=function i(){t(this,i)}).\u0275mod=y.Gb({type:O}),O.\u0275inj=y.Fb({factory:function(t){return new(t||O)},imports:[[c.e.forChild(M)],c.e]}),O),$=((W=function i(){t(this,i)}).\u0275mod=y.Gb({type:W}),W.\u0275inj=y.Fb({factory:function(t){return new(t||W)},imports:[[e.b,N,r.a,l.b]]}),W)}}])}();