UNPKG

wcif-helpers

Version:
3 lines (2 loc) 1.76 kB
const e=(e,t)=>{let r=null;return t.schedule.venues.forEach((t=>{t.rooms.forEach((t=>{t.activities.forEach((t=>{t.activityCode===e&&(r=t),t.childActivities.forEach((t=>{t.activityCode===e&&(r=t)}))}))}))})),r},t=(e,t,r)=>{let n=null;return r.schedule.venues.forEach((r=>{const i=r.rooms.find((e=>e.name===t));i&&i.activities.forEach((t=>{t.activityCode===e&&(n=t),t.childActivities.forEach((t=>{t.activityCode===e&&(n=t)}))}))})),n},r=(e,t)=>{let r=null;return t.schedule.venues.forEach((t=>{t.rooms.forEach((t=>{t.activities.forEach((t=>{t.id===e&&(r=t),t.childActivities.forEach((t=>{t.id===e&&(r=t)}))}))}))})),r},n=(e,t)=>{switch(e){case"1":return"Best of 1";case"2":return"Best of 2";case"3":return"Best of 3";case"a":return t?`Best of ${t} / Average of 5`:"Average of 5";case"m":return"Mean of 3";default:return"Unknown"}},i=(e,t)=>t.events.find((t=>t.id===e)),c=(e,t)=>{const r=s(e),n=i(r,t);return null==n?void 0:n.rounds.find((t=>t.id===e))},s=e=>e.split("-")[0],o=(e,t)=>{const r=c(e,t);return(null==r?void 0:r.cutoff)||null},a=(e,t)=>{const r=c(e,t);return(null==r?void 0:r.timeLimit)||null},u=(e,t)=>{const r=c(e,t);if(!r)return 0;switch(r.format){case"1":return 1;case"2":return 2;case"3":case"m":return 3;case"a":return 5}},f=(e,t)=>{const r=[];for(let n=0;n<t;n++)r.push(new Date(e)),e.setDate(e.getDate()+1);return r},l=(e,t)=>t.persons.find((t=>t.registrantId===e));export{e as getActivityInfoFromSchedule,t as getActivityInfoFromScheduleWithRoom,f as getCompetitionDates,o as getCutoffByRoundId,s as getEventIdFromRoundId,i as getEventInfoFromWcif,r as getGroupInfoByActivityId,a as getLimitByRoundId,u as getNumberOfAttemptsForRound,l as getPersonFromWcif,c as getRoundInfoFromWcif,n as prettyRoundFormat}; //# sourceMappingURL=index.js.map