1import{b as p,c as d}from"./chunk-NGU2QJKY.js";import{Pa as h,b as f,l as o,n as l}from"./chunk-LW6HKP4X.js";import{k as c}from"./chunk-AOMQVBFH.js";var y=(()=>{let i=class i{constructor(e){this.sanitizer=e,this.currentMusicSubject=new f([]),this.currentMusic$=this.currentMusicSubject.asObservable(),this.pin=!1,this.heldItems=[]}setPin(e){this.pin=e,!this.pin&&this.heldItems.length>0&&(this.currentMusicSubject.next([...this.heldItems]),this.heldItems=[])}setCurrentMusic(e){this.pin?this.heldItems=[...e]:this.currentMusicSubject.next([...e])}prependCurrentMusic(e){let r=this.currentMusicSubject.getValue(),t=[...e,...r];this.setCurrentMusic(t)}getCurrentMusic(){return this.currentMusicSubject.getValue()}urlizeTracks(e){return e.source=="spotify"?e.type=="album"?e.url="https://open.spotify.com/embed/album/"+e.sourceId:e.type=="track"?e.url="https://open.spotify.com/embed/track/"+e.sourceId:e.type=="playlist"&&(e.url="https://open.spotify.com/embed/playlist/"+e.sourceId):e.source=="youtube"?e.url="https://www.youtube.com/embed/"+e.sourceId:e.source=="bandcamp"?e.url=`https://bandcamp.com/EmbeddedPlayer/${e.type}=${e.sourceId}/size=medium/bgcol=ffffff/linkcol=0687f5/transparent=true`:e.source=="mixcloud"?e.url="https://player-widget.mixcloud.com/widget/iframe/?hide_cover=1&feed=/"+e.sourceId:e.source=="soundcloud"?(console.log("track soundcloud"),(e.type=="track"||e.type=="tracks")&&(e.url=`https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/${e.sourceId}&color=%23ff5500&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true&visual=true`)):e.source=="apple"&&(e.type=="album"?e.url="https://embed.music.apple.com/us/album/albumtitle/"+e.sourceId:e.type=="track"?e.url="https://embed.music.apple.com/us/track/title/"+e.sourceId:e.type=="playlist"&&(e.url="https://embed.music.apple.com/us/playlist/playlisttitle/"+e.sourceId)),e.url&&(e.safeUrl=this.sanitizer.bypassSecurityTrustResourceUrl(e.url)),e}urlizeArtist(e){let r="";return e.source==="spotify"?(e.link="https://open.spotify.com/artist/"+e.id,r="https://open.spotify.com/embed/artist/"+e.id):e.source==="youtube"?e.link="https://www.youtube.com/channel/"+e.id:e.source==="bandcamp"&&(e.link="https://bandcamp.com/"+e.id),e.link&&(e.safeUrl=this.sanitizer.bypassSecurityTrustResourceUrl(r)),e}};i.\u0275fac=function(r){return new(r||i)(l(h))},i.\u0275prov=o({token:i,factory:i.\u0275fac,providedIn:"root"});let n=i;return n})();var x=(()=>{let i=class i{constructor(e,r,t,a){this.typesenseService=e,this.sanitizer=r,this.musicService=t,this.feedsService=a,this.COLLECTION_NAME="articles",this.FIRSTPAGESIZE=15,this.currentArticles=[],this.searchParams={q:"*"},this.hasFilter=!1}initSearchParams(){return c(this,null,function*(){this.searchParams={q:"*",query_by:"title,description, genres, keywords, sourceName",facet_by:"genres, sourceName",max_facet_values:10,per_page:this.FIRSTPAGESIZE,page:1,sort_by:"dayCode:desc, rank:desc, score:desc"},this.hasFilter=!1})}cleanArticles(e){for(let r of e){let t=this.feedsService.findFeed(r.sourceId);t?(r.sourceName=t.sourceName,r.sourceImage=t.sourceImage):console.error("did not find feed",r.sourceName);let a=r.contentUrl||r.url||"";r.safeUrl=this.sanitizer.bypassSecurityTrustResourceUrl(a),typeof r.author=="string"&&r.author.toLowerCase().includes("unknown")&&(r.author=""),r.music.forEach(s=>(this.musicService.urlizeTracks(s),s)),r.artists=r.artists.filter((s,b,m)=>b===m.findIndex(u=>u.name===s.name&&u.id===s.id)).filter(s=>s.name&&s.id).map(s=>(this.musicService.urlizeArtist(s),s)),r.genres=Array.from(new Set(r.genres.map(s=>s.trim()))),r.keywords=Array.from(new Set(r.keywords.map(s=>s.trim()))),r.description&&(r.safeDescription=this.sanitizer.bypassSecurityTrustHtml(r.description)),r.readable&&(r.safeReadable=this.sanitizer.bypassSecurityTrustHtml(r.readable))}}nextPage(){return c(this,null,function*(){try{if(this.response=yield this.typesenseService.getPaged(this.COLLECTION_NAME,this.searchParams),!this.response||!this.response.hits)this.currentArticles=[];else{let e=this.response.hits.map(r=>r.document);if(this.cleanArticles(e),this.searchParams.page===1){this.currentArticles=[...e],this.searchParams.per_page=5;let r=this.searchParams.per_page,t=this.currentArticles.length/r;this.searchParams.page=t+1}else this.currentArticles=this.currentArticles.concat(e),typeof this.searchParams.page=="number"&&this.searchParams.page++;if(e.length===0)return console.log("No more articles to fetch."),this.currentArticles}return this.currentArticles}catch(e){throw console.error("Error fetching next page of articles:",e),e}})}getFacets(){var e,r;return(e=this.response)!=null&&e.facet_counts?(r=this.response)==null?void 0:r.facet_counts:void 0}nextArticle(e,r){if(!this.currentArticles||this.currentArticles.length===0)return!1;let t=this.currentArticles.findIndex(s=>s.id===e.id);if(t===-1)return!1;let a=r==="next"?t+1:t-1;return a<0?a=this.currentArticles.length-1:a>=this.currentArticles.length&&(a=0),this.currentArticles[a]}setNextArticle(e){this.theNextArticle=e}getDisplayableIndex(){return this.currentArticles.findIndex(r=>{var t;return r.id===((t=this.theNextArticle)==null?void 0:t.id)})}deleteArticle(e){return c(this,null,function*(){try{yield this.typesenseService.deleteDocument(this.COLLECTION_NAME,e),this.currentArticles=this.currentArticles.filter(r=>r.id!==e)}catch(r){throw console.error("Error deleting article:",r),r}})}firstPage(){return c(this,null,function*(){this.searchParams.page=1,this.searchParams.per_page=this.FIRSTPAGESIZE})}setSortParams(e){return c(this,null,function*(){this.searchParams.sort_by=e,this.firstPage()})}setSearchString(e){return c(this,null,function*(){this.searchParams.q=e,this.firstPage(),delete this.searchParams.sort_by})}setSearchParams(e){return c(this,null,function*(){this.searchParams=e,this.firstPage(),this.searchParams.filter_by&&(this.hasFilter=!0)})}addFilter(e,r,t=":="){this.searchParams||this.initSearchParams(),this.searchParams.filter_by?(console.error("did not use existing facets!"),this.searchParams.filter_by=`${e}${t}${r}`):this.searchParams.filter_by=`${e}${t}${r}`}deleteFilter(e){if(this.searchParams&&this.searchParams.filter_by){let t=this.searchParams.filter_by.split(" && ").filter(a=>!a.startsWith(`${e}`));this.searchParams.filter_by=t.join(" && "),this.searchParams.filter_by||(delete this.searchParams.filter_by,this.hasFilter=!1)}}deleteAllFilters(){this.searchParams&&this.searchParams.filter_by&&(delete this.searchParams.filter_by,this.hasFilter=!1)}};i.\u0275fac=function(r){return new(r||i)(l(p),l(h),l(y),l(d))},i.\u0275prov=o({token:i,factory:i.\u0275fac,providedIn:"root"});let n=i;return n})();export{y as a,x as b};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.