1import{a as y}from"./chunk-DLGGMMFU.js";import{a as Q}from"./chunk-YNUWL6FH.js";import{c as g,d as n,f as b,hb as C,i as m,ib as x,j as B,jb as D,k as S,kb as d,l as I,p,qb as T,wb as M,xb as O}from"./chunk-IDJYNL5J.js";import{g as _}from"./chunk-ZU3YJ3AW.js";import{x as v}from"./chunk-EGYSNIEU.js";import{Ya as w,d as l,ga as u,ja as f,pa as h,sd as s,ua as a,z as c}from"./chunk-F37HHLLX.js";var U=(()=>{class r{_http=a(_);_platform=a(w);_baseUrl=y.api.content;getBlogs(){if(v(this._platform)){let t=this._getOrCreateBrowserId();return this._http.get(`${this._baseUrl}/v1/blogs/user/${t}`).pipe(c(e=>e.filter(i=>i.status==="published")))}else return this._http.get(`${this._baseUrl}/v1/blogs`).pipe(c(t=>t.filter(e=>e.status==="published")))}incrementView(t){let e=this._getOrCreateBrowserId();return this._http.post(`${this._baseUrl}/v1/blogs/view`,{user_id:e,blog_slug:t})}_getOrCreateBrowserId(){let t="browserUniqueId",e=localStorage.getItem(t);return e||(e=Q(),localStorage.setItem(t,e),e)}static \u0275fac=function(e){return new(e||r)};static \u0275prov=h({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var X=b({providedIn:"root"},I({activeSlug:null,categoryQuery:"all"}),O(),C(),m(r=>({categories:s(()=>r.entities().map(t=>t.category).filter((t,e,i)=>i.indexOf(t)===e)),blogs:s(()=>{let o=r.entities(),t=r.categoryQuery();return o.filter(e=>t==="all"?!0:e.category===t).sort((e,i)=>new Date(i.created_at).getTime()-new Date(e.created_at).getTime())}),activeBlog:s(()=>{let o=r.entities(),t=r.activeSlug();return o.find(e=>e.slug===t)??null}),featuredBlogs:s(()=>{let o=r.entities(),t=o.length,e=[];if(t>4){for(;e.length<3;){let i=Math.ceil(Math.random()*t)-1;e.includes(i)||e.push(i)}return e.map(i=>o[i])}else return t<=3&&t>=1?o:[]}),recentBlogs:s(()=>{let o=r.entities(),t=r.activeSlug();return o.filter(e=>e.slug!==t).sort((e,i)=>new Date(i.created_at).getTime()-new Date(e.created_at).getTime()).slice(0,3)})})),m(r=>({relatedBlogs:s(()=>{let o=r.entities(),t=r.activeBlog(),e=r.activeSlug();return t?o.filter(i=>i.slug!==e&&i.category===t.category).sort((i,j)=>new Date(j.created_at).getTime()-new Date(i.created_at).getTime()).slice(0,3):[]})})),S((r,o=a(U))=>({setCategoryQuery:t=>{n(r,{categoryQuery:t})},getBlogs:p(l(f(()=>n(r,x())),u(()=>o.getBlogs().pipe(g({next:t=>{n(r,T(t),D())},error:()=>{n(r,d("Could not load blog list at this moment, please try again later."))}}))))),incrementView:p(l(u(t=>o.incrementView(t).pipe(g({next:()=>{let e=r.entities().find(i=>i.slug===t);e&&n(r,M({id:e.id,changes:{is_viewed:!0,view_count:e.view_count+1}}))},error:()=>{n(r,d("Could not increment view at this moment, please try again later."))}}))))),setActiveSlug:t=>{n(r,{activeSlug:t})}})),B({onInit:r=>{r.getBlogs()}}));export{X as a};
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.