{"version":3,"sources":["../src/ModifiersUtils.js"],"names":["dayMatchesModifier","getModifiersForDay","day","modifier","arr","Array","isArray","some","mod","Date","after","before","daysOfWeek","getDay","dayOfWeek","modifiersObj","Object","keys","reduce","modifiers","modifierName","value","push"],"mappings":";;;;;QAWgBA,kB,GAAAA,kB;QAkDAC,kB,GAAAA,kB;;AA7DhB;;AACA;;AAEA;;;;;;;;AAQO,SAASD,kBAAT,CAA4BE,GAA5B,EAAiCC,QAAjC,EAA2C;AAChD,MAAI,CAACA,QAAL,EAAe;AACb,WAAO,KAAP;AACD;AACD,MAAMC,MAAMC,MAAMC,OAAN,CAAcH,QAAd,IAA0BA,QAA1B,GAAqC,CAACA,QAAD,CAAjD;AACA,SAAOC,IAAIG,IAAJ,CAAS,eAAO;AACrB,QAAI,CAACC,GAAL,EAAU;AACR,aAAO,KAAP;AACD;AACD,QAAIA,eAAeC,IAAnB,EAAyB;AACvB,aAAO,0BAAUP,GAAV,EAAeM,GAAf,CAAP;AACD;AACD,QAAI,6BAAeA,GAAf,CAAJ,EAAyB;AACvB,aAAO,6BAAaN,GAAb,EAAkBM,GAAlB,CAAP;AACD;AACD,QAAIA,IAAIE,KAAJ,IAAaF,IAAIG,MAAjB,IAA2B,2BAAWH,IAAIG,MAAf,EAAuBH,IAAIE,KAA3B,CAA/B,EAAkE;AAChE,aAAO,2BAAWR,GAAX,EAAgBM,IAAIE,KAApB,KAA8B,4BAAYR,GAAZ,EAAiBM,IAAIG,MAArB,CAArC;AACD;AACD,QACEH,IAAIE,KAAJ,IACAF,IAAIG,MADJ,KAEC,2BAAWH,IAAIE,KAAf,EAAsBF,IAAIG,MAA1B,KAAqC,0BAAUH,IAAIE,KAAd,EAAqBF,IAAIG,MAAzB,CAFtC,CADF,EAIE;AACA,aAAO,2BAAWT,GAAX,EAAgBM,IAAIE,KAApB,KAA8B,4BAAYR,GAAZ,EAAiBM,IAAIG,MAArB,CAArC;AACD;AACD,QAAIH,IAAIE,KAAR,EAAe;AACb,aAAO,2BAAWR,GAAX,EAAgBM,IAAIE,KAApB,CAAP;AACD;AACD,QAAIF,IAAIG,MAAR,EAAgB;AACd,aAAO,4BAAYT,GAAZ,EAAiBM,IAAIG,MAArB,CAAP;AACD;AACD,QAAIH,IAAII,UAAR,EAAoB;AAClB,aAAOJ,IAAII,UAAJ,CAAeL,IAAf,CAAoB;AAAA,eAAaL,IAAIW,MAAJ,OAAiBC,SAA9B;AAAA,OAApB,CAAP;AACD;AACD,QAAI,OAAON,GAAP,KAAe,UAAnB,EAA+B;AAC7B,aAAOA,IAAIN,GAAJ,CAAP;AACD;AACD,WAAO,KAAP;AACD,GAjCM,CAAP;AAkCD;;AAED;;;;;;;;;AASO,SAASD,kBAAT,CAA4BC,GAA5B,EAAoD;AAAA,MAAnBa,YAAmB,uEAAJ,EAAI;;AACzD,SAAOC,OAAOC,IAAP,CAAYF,YAAZ,EAA0BG,MAA1B,CAAiC,UAACC,SAAD,EAAYC,YAAZ,EAA6B;AACnE,QAAMC,QAAQN,aAAaK,YAAb,CAAd;AACA,QAAIpB,mBAAmBE,GAAnB,EAAwBmB,KAAxB,CAAJ,EAAoC;AAClCF,gBAAUG,IAAV,CAAeF,YAAf;AACD;AACD,WAAOD,SAAP;AACD,GANM,EAMJ,EANI,CAAP;AAOD;;kBAEc,EAAEnB,sCAAF,EAAsBC,sCAAtB,E","file":"ModifiersUtils.js","sourcesContent":["import { isDayAfter, isDayBefore, isDayInRange, isSameDay } from './DateUtils';\nimport { isRangeOfDates } from './Helpers';\n\n/**\n * Return `true` if a date matches the specified modifier.\n *\n * @export\n * @param {Date} day\n * @param {Any} modifier\n * @return {Boolean}\n */\nexport function dayMatchesModifier(day, modifier) {\n  if (!modifier) {\n    return false;\n  }\n  const arr = Array.isArray(modifier) ? modifier : [modifier];\n  return arr.some(mod => {\n    if (!mod) {\n      return false;\n    }\n    if (mod instanceof Date) {\n      return isSameDay(day, mod);\n    }\n    if (isRangeOfDates(mod)) {\n      return isDayInRange(day, mod);\n    }\n    if (mod.after && mod.before && isDayAfter(mod.before, mod.after)) {\n      return isDayAfter(day, mod.after) && isDayBefore(day, mod.before);\n    }\n    if (\n      mod.after &&\n      mod.before &&\n      (isDayAfter(mod.after, mod.before) || isSameDay(mod.after, mod.before))\n    ) {\n      return isDayAfter(day, mod.after) || isDayBefore(day, mod.before);\n    }\n    if (mod.after) {\n      return isDayAfter(day, mod.after);\n    }\n    if (mod.before) {\n      return isDayBefore(day, mod.before);\n    }\n    if (mod.daysOfWeek) {\n      return mod.daysOfWeek.some(dayOfWeek => day.getDay() === dayOfWeek);\n    }\n    if (typeof mod === 'function') {\n      return mod(day);\n    }\n    return false;\n  });\n}\n\n/**\n * Return the modifiers matching the given day for the given\n * object of modifiers.\n *\n * @export\n * @param {Date} day\n * @param {Object} [modifiersObj={}]\n * @return {Array}\n */\nexport function getModifiersForDay(day, modifiersObj = {}) {\n  return Object.keys(modifiersObj).reduce((modifiers, modifierName) => {\n    const value = modifiersObj[modifierName];\n    if (dayMatchesModifier(day, value)) {\n      modifiers.push(modifierName);\n    }\n    return modifiers;\n  }, []);\n}\n\nexport default { dayMatchesModifier, getModifiersForDay };\n"]}