{"version":3,"sources":["hours.min.js"],"names":["$","when","getJSON","done","dataHours","allClosed","all_closed","knownTerms","known_terms","dayjs","extend","window","dayjs_plugin_customParseFormat","dayjs_plugin_isBetween","now","nowFormatted","format","nowWeekday","$buildingHours","currentHours","filter","hoursArray","start","start_date","startOf","end","end_date","endOf","isBetween","length","$allHours","find","day","isSame","text","spaces","i","spaceId","space_id","$hoursTextInsert","concat","exceptions","regularHours","hours","matchesException","exception","date","value","displayHours","$cardTerms","$exceptionDates","$allClosed","each","$this","this","startDateMoment","data","endDateMoment","addClass","isBefore","hide","removeClass","exceptionMoment","diffInDays","diff","append","hasClass","allClosedMoment"],"mappings":"AAAA,aACAA,GAAE,WACAA,EAAEC,KAAKD,EAAEE,QAAQ,4BAA4BC,MAAK,SAACC,GAEjD,IAAMC,EAAYD,EAAU,GAAGE,WACzBC,EAAaH,EAAU,GAAGI,YAGhCC,MAAMC,OAAOC,OAAOC,gCACpBH,MAAMC,OAAOC,OAAOE,wBAGpB,IAAMC,EAAML,QACNM,EAAeD,EAAIE,OAAO,cAC1BC,EAAaH,EAAIE,OAAO,QACxBE,EAAiBlB,EAAE,mBAgBzB,IAAMmB,EAAeZ,EAAWa,QAZhC,SAAsBC,GACpB,IAAMC,EAAQb,MAAMY,EAAWE,WAAY,cAAcC,QAAQ,OAC3DC,EAAMhB,MAAMY,EAAWK,SAAU,cAAcC,MAAM,OAI3D,OADgBb,EAAIc,UAAUN,EAAOG,MAqDnCP,EAAeW,QA3CnB,SAAsBxB,EAAWc,GAG/B,GAAiB,MAAbd,EAAmB,CACrB,IAAMyB,EAAYZ,EAAea,KAAK,kDAMtC,GALyB1B,EAAUe,QAAO,SAACY,GAEvC,OADkBvB,MAAMuB,EAAK,cACZC,OAAOlB,MAGPc,OAEnB,YADAC,EAAUI,KAAK,UAOnB,IAlB6C,IAiBrCC,EAAWhB,EAAa,GAAxBgB,OACCC,EAAI,EAAGA,EAAID,EAAON,OAAQO,GAAK,EAAG,CACzC,IAAMC,EA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IAAMC,EAAQrD,EAAEsD,MACVa,EAAkB1D,MAAM4C,EAAMG,KAAK,UAAW,cAC9CO,EAAaI,EAAgBH,KAAKjD,EAAc,QAGlDoD,EAAgBlC,OAAOlB,IACzBsC,EAAMY,OAAO,iEAGXF,EAAa,GAAKA,GAAc,GAClCV,EAAMY,OAAO","file":"hours.min.js","sourcesContent":["/* eslint-disable no-undef */\n$(() => {\n $.when($.getJSON('/assets/data/hours.json')).done((dataHours) => {\n\n const allClosed = dataHours[0].all_closed;\n const knownTerms = dataHours[0].known_terms;\n\n //window['moment-range'].extendMoment(moment);\n dayjs.extend(window.dayjs_plugin_customParseFormat);\n dayjs.extend(window.dayjs_plugin_isBetween);\n\n // set today's date to memory\n const now = dayjs();\n const nowFormatted = now.format('YYYY-MM-DD');\n const nowWeekday = now.format('dddd');\n const $buildingHours = $('#building-hours');\n\n // test to see if a given date (now) falls within a range of dates (start_date / end_date\n // of a location's data). Return true if so.\n function hoursInRange(hoursArray) {\n const start = dayjs(hoursArray.start_date, 'YYYY-MM-DD').startOf('day');\n const end = dayjs(hoursArray.end_date, 'YYYY-MM-DD').endOf('day');\n //const range = moment.range(start, end);\n //return range.contains(now);\n const between = now.isBetween(start, end);\n return between;\n\n }\n\n // using filter, and the hoursInRange function, find the currently applicable array of\n // hours information & finally, parse them.\n const currentHours = knownTerms.filter(hoursInRange);\n\n // parse the hours\n function displayHours(allClosed, currentHours) {\n // before looping through larger arrays, check if today is closed for everybody,\n // if so note it and return\n if (allClosed != null) {\n const $allHours = $buildingHours.find('td.hours-info, div.hours-info, span.hours-info');\n const matchesAllClosed = allClosed.filter((day) => {\n const dayMoment = dayjs(day, 'YYYY-MM-DD');\n return dayMoment.isSame(nowFormatted);\n });\n\n if (matchesAllClosed.length) {\n $allHours.text('closed');\n return;\n }\n }\n\n // Not all locations closed. set up variables for matching to individual locations & hours\n const { spaces } = currentHours[0];\n for (let i = 0; i < spaces.length; i += 1) {\n const spaceId = spaces[i].space_id;\n const $hoursTextInsert = $(`#${spaceId}-todays-hours`);\n const exceptions = spaces[i].exceptions || [];\n const regularHours = spaces[i].hours;\n\n // Are there any exceptions listed for this space?\n // If so, filter the dates and return true if matching today's date.\n // Resulting list will be either 1 or 0 length.\n const matchesException = exceptions.filter((exception) => {\n const exceptionMoment = dayjs(exception.date, 'YYYY-MM-DD');\n return exceptionMoment.isSame(nowFormatted);\n });\n\n // If today's date matches an exception, print the value message to the screen in the\n // appropriate span Otherwise, there are no matching exceptions, print standard\n // weekday/weekend hours for the timespan.\n if (matchesException.length) {\n $hoursTextInsert.text(matchesException[0].value);\n } else {\n $hoursTextInsert.text(regularHours[nowWeekday]);\n }\n }\n }\n\n if ($buildingHours.length) {\n displayHours(allClosed, currentHours);\n }\n\n // building Hours Blocks\n const $cardTerms = $('div.weekly-hours').find('div.card');\n const $exceptionDates = $cardTerms.find('li.exceptions');\n const $allClosed = $('ul.all-closed li');\n\n\n\n // Loop through cards of displayed yaml hours\n $cardTerms.each(function () {\n const $this = $(this);\n const startDateMoment = dayjs($this.data('start-term'), 'YYYY-MM-DD').startOf('day');\n const endDateMoment = dayjs($this.data('end-term'), 'YYYY-MM-DD').endOf('day');\n\n $this.addClass(\"testing123456\");\n // hide hours that have an end date in the past.\n if (endDateMoment.isBefore(now)) {\n $this.hide();\n $(\"body\").addClass(\"baz\");\n\n }\n\n // open current hours card\n if (now.isBetween(startDateMoment, endDateMoment)) {\n $(\"body\").addClass(\"beez\");\n\n $this.find('.collapsed')\n .removeClass('collapsed')\n .end()\n .find('.weekly-hours')\n .addClass('show');\n }\n });\n\n // hide exceptions occuring in the past\n $exceptionDates.each(function () {\n const $this = $(this);\n const exceptionMoment = dayjs($this.data('exception-date'), 'YYYY-MM-DD');\n const diffInDays = exceptionMoment.diff(nowFormatted, 'days');\n\n // hide exceptions in the past.\n if (diffInDays < 0) {\n $this.removeClass('in-future').hide();\n }\n\n // highlight if the closed date is today.\n if (exceptionMoment.isSame(nowFormatted)) {\n $this.append('today');\n }\n\n if (diffInDays > 0 && diffInDays <= 7) {\n $this.append('upcoming');\n }\n });\n const $localExceptions = $('.local-exceptions');\n\n $localExceptions.each(function () {\n if (!$(this).find('li').hasClass('in-future')) {\n $(this).hide();\n }\n });\n\n // hide exceptions occuring in the past\n $allClosed.each(function () {\n const $this = $(this);\n const allClosedMoment = dayjs($this.data('closed'), 'YYYY-MM-DD');\n const diffInDays = allClosedMoment.diff(nowFormatted, 'days');\n\n // highlight if the closed date is today.\n if (allClosedMoment.isSame(nowFormatted)) {\n $this.append(' today');\n }\n\n if (diffInDays > 0 && diffInDays <= 7) {\n $this.append(' upcoming');\n }\n });\n });\n});\n"]}