import{a as S}from"./chunk-G7INVXNI.js";import{f as C,g as H,i as c}from"./chunk-TDIPI4U5.js";import{Z as D,ba as b,ga as d,k as r}from"./chunk-SBSTEEKM.js";import{a as A,b as E}from"./chunk-FBSYYVFF.js";var T=(()=>{class n{static{this.type="[CTF] Get Ctf"}}return n})(),v=(()=>{class n{static{this.type="[CTF] Filter Ctf"}constructor(e){this.payload=e}}return n})();var m=function(n){return n.NON_DEMARRE="Non d\xE9marr\xE9",n.EN_COURS="En cours",n.TERMINE="Termin\xE9",n}(m||{});var o,s=class g{static{o=this}constructor(t){this.service=t}static{this.ctfComparator=(t,e)=>o.ctfPriority(e)-o.ctfPriority(t)}static selectCtfs(t){return t.enigmeFiltree.sort(o.ctfComparator)}static selectNextEnigmeAvailable(t){return t.nextEnigmeAvailable}static selectCtfsUser(t){return t.enigme.filter(e=>e.dateHeureDebut)}static selectCtfsUserInProgress(t){return t.enigme.filter(e=>e.dateHeureDebut&&!e.dateHeureFin)}static selectHighlightCtfs(t){return t.enigme.filter(e=>e.highlights&&!e.dateHeureFin)}static selectDistinctTags(t){return t.tagsDistinct}static ctfPriority(t){return t.isNew&&!t.dateHeureDebut&&!t.dateHeureFin?3:t.dateHeureDebut&&!t.dateHeureFin?2:t.dateHeureDebut&&t.dateHeureFin?0:1}getCtfAction(t){return this.service.getAllEnigmes().pipe(D(e=>{let u=t.getState();e.enigmeList?.length>0&&(e.enigmeList.map(l=>{if(l.availableOn){let f=new Date,p=f.getTimezoneOffset(),i=new Date(f).getTime()+p*6e4-new Date(l.availableOn).getTime();l.isNew=i<864e5*3}}),t.setState(E(A({},u),{enigme:e.enigmeList,enigmeFiltree:e.enigmeList,tagsDistinct:[...new Set(e.enigmeList.map(l=>l.tags).flat())],nextEnigmeAvailable:e.nextEnigmeAvailable?new Date(e.nextEnigmeAvailable):null})))}))}filterCtfAction(t,{payload:e}){let u=e.selectTheme,l=e.selectDifficulty,f=e.selectStatus,a=[...t.getState().enigme];u!=="Tous"&&(a=a.filter(i=>i.tags.includes(u))),l!=="Tous"&&(a=a.filter(i=>i.difficulty===l)),f!=="Tous"&&(a=a.filter(i=>f===m.NON_DEMARRE?i.dateHeureDebut===null:f===m.EN_COURS?i.dateHeureDebut!==null&&i.dateHeureFin===null:i.dateHeureFin!==null)),t.patchState({enigmeFiltree:a})}static{this.\u0275fac=function(e){return new(e||g)(d(S))}}static{this.\u0275prov=b({token:g,factory:g.\u0275fac})}};r([C(T)],s.prototype,"getCtfAction",null);r([C(v)],s.prototype,"filterCtfAction",null);r([c()],s,"selectCtfs",null);r([c()],s,"selectNextEnigmeAvailable",null);r([c()],s,"selectCtfsUser",null);r([c()],s,"selectCtfsUserInProgress",null);r([c()],s,"selectHighlightCtfs",null);r([c()],s,"selectDistinctTags",null);s=o=r([H({name:"CtfStore",defaults:{enigme:[],enigmeFiltree:[],tagsDistinct:[],nextEnigmeAvailable:null}})],s);export{T as a,v as b,m as c,s as d}; //# sourceMappingURL=chunk-BKKIK56W.js.map