main.d8ebb8d6.js 104 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933
  1. // modules are defined as an array
  2. // [ module function, map of requires ]
  3. //
  4. // map of requires is short require name -> numeric require
  5. //
  6. // anything defined in a previous bundle is accessed via the
  7. // orig method which is the require for previous bundles
  8. parcelRequire = (function (modules, cache, entry, globalName) {
  9. // Save the require from previous bundle to this closure if any
  10. var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
  11. var nodeRequire = typeof require === 'function' && require;
  12. function newRequire(name, jumped) {
  13. if (!cache[name]) {
  14. if (!modules[name]) {
  15. // if we cannot find the module within our internal map or
  16. // cache jump to the current global require ie. the last bundle
  17. // that was added to the page.
  18. var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
  19. if (!jumped && currentRequire) {
  20. return currentRequire(name, true);
  21. }
  22. // If there are other bundles on this page the require from the
  23. // previous one is saved to 'previousRequire'. Repeat this as
  24. // many times as there are bundles until the module is found or
  25. // we exhaust the require chain.
  26. if (previousRequire) {
  27. return previousRequire(name, true);
  28. }
  29. // Try the node require function if it exists.
  30. if (nodeRequire && typeof name === 'string') {
  31. return nodeRequire(name);
  32. }
  33. var err = new Error('Cannot find module \'' + name + '\'');
  34. err.code = 'MODULE_NOT_FOUND';
  35. throw err;
  36. }
  37. localRequire.resolve = resolve;
  38. localRequire.cache = {};
  39. var module = cache[name] = new newRequire.Module(name);
  40. modules[name][0].call(module.exports, localRequire, module, module.exports, this);
  41. }
  42. return cache[name].exports;
  43. function localRequire(x){
  44. return newRequire(localRequire.resolve(x));
  45. }
  46. function resolve(x){
  47. return modules[name][1][x] || x;
  48. }
  49. }
  50. function Module(moduleName) {
  51. this.id = moduleName;
  52. this.bundle = newRequire;
  53. this.exports = {};
  54. }
  55. newRequire.isParcelRequire = true;
  56. newRequire.Module = Module;
  57. newRequire.modules = modules;
  58. newRequire.cache = cache;
  59. newRequire.parent = previousRequire;
  60. newRequire.register = function (id, exports) {
  61. modules[id] = [function (require, module) {
  62. module.exports = exports;
  63. }, {}];
  64. };
  65. var error;
  66. for (var i = 0; i < entry.length; i++) {
  67. try {
  68. newRequire(entry[i]);
  69. } catch (e) {
  70. // Save first error but execute all entries
  71. if (!error) {
  72. error = e;
  73. }
  74. }
  75. }
  76. if (entry.length) {
  77. // Expose entry point to Node, AMD or browser globals
  78. // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
  79. var mainExports = newRequire(entry[entry.length - 1]);
  80. // CommonJS
  81. if (typeof exports === "object" && typeof module !== "undefined") {
  82. module.exports = mainExports;
  83. // RequireJS
  84. } else if (typeof define === "function" && define.amd) {
  85. define(function () {
  86. return mainExports;
  87. });
  88. // <script>
  89. } else if (globalName) {
  90. this[globalName] = mainExports;
  91. }
  92. }
  93. // Override the current require with this new one
  94. parcelRequire = newRequire;
  95. if (error) {
  96. // throw error from earlier, _after updating parcelRequire_
  97. throw error;
  98. }
  99. return newRequire;
  100. })({"node_modules/flatpickr/dist/flatpickr.js":[function(require,module,exports) {
  101. var define;
  102. var global = arguments[3];
  103. /* flatpickr v4.6.3, @license MIT */
  104. (function (global, factory) {
  105. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.flatpickr = factory());
  106. })(this, function () {
  107. 'use strict';
  108. /*! *****************************************************************************
  109. Copyright (c) Microsoft Corporation. All rights reserved.
  110. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  111. this file except in compliance with the License. You may obtain a copy of the
  112. License at http://www.apache.org/licenses/LICENSE-2.0
  113. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  114. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  115. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  116. MERCHANTABLITY OR NON-INFRINGEMENT.
  117. See the Apache Version 2.0 License for specific language governing permissions
  118. and limitations under the License.
  119. ***************************************************************************** */
  120. var __assign = function () {
  121. __assign = Object.assign || function __assign(t) {
  122. for (var s, i = 1, n = arguments.length; i < n; i++) {
  123. s = arguments[i];
  124. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  125. }
  126. return t;
  127. };
  128. return __assign.apply(this, arguments);
  129. };
  130. var HOOKS = ["onChange", "onClose", "onDayCreate", "onDestroy", "onKeyDown", "onMonthChange", "onOpen", "onParseConfig", "onReady", "onValueUpdate", "onYearChange", "onPreCalendarPosition"];
  131. var defaults = {
  132. _disable: [],
  133. _enable: [],
  134. allowInput: false,
  135. altFormat: "F j, Y",
  136. altInput: false,
  137. altInputClass: "form-control input",
  138. animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
  139. ariaDateFormat: "F j, Y",
  140. clickOpens: true,
  141. closeOnSelect: true,
  142. conjunction: ", ",
  143. dateFormat: "Y-m-d",
  144. defaultHour: 12,
  145. defaultMinute: 0,
  146. defaultSeconds: 0,
  147. disable: [],
  148. disableMobile: false,
  149. enable: [],
  150. enableSeconds: false,
  151. enableTime: false,
  152. errorHandler: function (err) {
  153. return typeof console !== "undefined" && console.warn(err);
  154. },
  155. getWeek: function (givenDate) {
  156. var date = new Date(givenDate.getTime());
  157. date.setHours(0, 0, 0, 0); // Thursday in current week decides the year.
  158. date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7); // January 4 is always in week 1.
  159. var week1 = new Date(date.getFullYear(), 0, 4); // Adjust to Thursday in week 1 and count number of weeks from date to week1.
  160. return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
  161. },
  162. hourIncrement: 1,
  163. ignoredFocusElements: [],
  164. inline: false,
  165. locale: "default",
  166. minuteIncrement: 5,
  167. mode: "single",
  168. monthSelectorType: "dropdown",
  169. nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
  170. noCalendar: false,
  171. now: new Date(),
  172. onChange: [],
  173. onClose: [],
  174. onDayCreate: [],
  175. onDestroy: [],
  176. onKeyDown: [],
  177. onMonthChange: [],
  178. onOpen: [],
  179. onParseConfig: [],
  180. onReady: [],
  181. onValueUpdate: [],
  182. onYearChange: [],
  183. onPreCalendarPosition: [],
  184. plugins: [],
  185. position: "auto",
  186. positionElement: undefined,
  187. prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
  188. shorthandCurrentMonth: false,
  189. showMonths: 1,
  190. static: false,
  191. time_24hr: false,
  192. weekNumbers: false,
  193. wrap: false
  194. };
  195. var english = {
  196. weekdays: {
  197. shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  198. longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  199. },
  200. months: {
  201. shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  202. longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  203. },
  204. daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
  205. firstDayOfWeek: 0,
  206. ordinal: function (nth) {
  207. var s = nth % 100;
  208. if (s > 3 && s < 21) return "th";
  209. switch (s % 10) {
  210. case 1:
  211. return "st";
  212. case 2:
  213. return "nd";
  214. case 3:
  215. return "rd";
  216. default:
  217. return "th";
  218. }
  219. },
  220. rangeSeparator: " to ",
  221. weekAbbreviation: "Wk",
  222. scrollTitle: "Scroll to increment",
  223. toggleTitle: "Click to toggle",
  224. amPM: ["AM", "PM"],
  225. yearAriaLabel: "Year",
  226. hourAriaLabel: "Hour",
  227. minuteAriaLabel: "Minute",
  228. time_24hr: false
  229. };
  230. var pad = function (number) {
  231. return ("0" + number).slice(-2);
  232. };
  233. var int = function (bool) {
  234. return bool === true ? 1 : 0;
  235. };
  236. /* istanbul ignore next */
  237. function debounce(func, wait, immediate) {
  238. if (immediate === void 0) {
  239. immediate = false;
  240. }
  241. var timeout;
  242. return function () {
  243. var context = this,
  244. args = arguments;
  245. timeout !== null && clearTimeout(timeout);
  246. timeout = window.setTimeout(function () {
  247. timeout = null;
  248. if (!immediate) func.apply(context, args);
  249. }, wait);
  250. if (immediate && !timeout) func.apply(context, args);
  251. };
  252. }
  253. var arrayify = function (obj) {
  254. return obj instanceof Array ? obj : [obj];
  255. };
  256. function toggleClass(elem, className, bool) {
  257. if (bool === true) return elem.classList.add(className);
  258. elem.classList.remove(className);
  259. }
  260. function createElement(tag, className, content) {
  261. var e = window.document.createElement(tag);
  262. className = className || "";
  263. content = content || "";
  264. e.className = className;
  265. if (content !== undefined) e.textContent = content;
  266. return e;
  267. }
  268. function clearNode(node) {
  269. while (node.firstChild) node.removeChild(node.firstChild);
  270. }
  271. function findParent(node, condition) {
  272. if (condition(node)) return node;else if (node.parentNode) return findParent(node.parentNode, condition);
  273. return undefined; // nothing found
  274. }
  275. function createNumberInput(inputClassName, opts) {
  276. var wrapper = createElement("div", "numInputWrapper"),
  277. numInput = createElement("input", "numInput " + inputClassName),
  278. arrowUp = createElement("span", "arrowUp"),
  279. arrowDown = createElement("span", "arrowDown");
  280. if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
  281. numInput.type = "number";
  282. } else {
  283. numInput.type = "text";
  284. numInput.pattern = "\\d*";
  285. }
  286. if (opts !== undefined) for (var key in opts) numInput.setAttribute(key, opts[key]);
  287. wrapper.appendChild(numInput);
  288. wrapper.appendChild(arrowUp);
  289. wrapper.appendChild(arrowDown);
  290. return wrapper;
  291. }
  292. function getEventTarget(event) {
  293. if (typeof event.composedPath === "function") {
  294. var path = event.composedPath();
  295. return path[0];
  296. }
  297. return event.target;
  298. }
  299. var doNothing = function () {
  300. return undefined;
  301. };
  302. var monthToStr = function (monthNumber, shorthand, locale) {
  303. return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
  304. };
  305. var revFormat = {
  306. D: doNothing,
  307. F: function (dateObj, monthName, locale) {
  308. dateObj.setMonth(locale.months.longhand.indexOf(monthName));
  309. },
  310. G: function (dateObj, hour) {
  311. dateObj.setHours(parseFloat(hour));
  312. },
  313. H: function (dateObj, hour) {
  314. dateObj.setHours(parseFloat(hour));
  315. },
  316. J: function (dateObj, day) {
  317. dateObj.setDate(parseFloat(day));
  318. },
  319. K: function (dateObj, amPM, locale) {
  320. dateObj.setHours(dateObj.getHours() % 12 + 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
  321. },
  322. M: function (dateObj, shortMonth, locale) {
  323. dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
  324. },
  325. S: function (dateObj, seconds) {
  326. dateObj.setSeconds(parseFloat(seconds));
  327. },
  328. U: function (_, unixSeconds) {
  329. return new Date(parseFloat(unixSeconds) * 1000);
  330. },
  331. W: function (dateObj, weekNum, locale) {
  332. var weekNumber = parseInt(weekNum);
  333. var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
  334. date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
  335. return date;
  336. },
  337. Y: function (dateObj, year) {
  338. dateObj.setFullYear(parseFloat(year));
  339. },
  340. Z: function (_, ISODate) {
  341. return new Date(ISODate);
  342. },
  343. d: function (dateObj, day) {
  344. dateObj.setDate(parseFloat(day));
  345. },
  346. h: function (dateObj, hour) {
  347. dateObj.setHours(parseFloat(hour));
  348. },
  349. i: function (dateObj, minutes) {
  350. dateObj.setMinutes(parseFloat(minutes));
  351. },
  352. j: function (dateObj, day) {
  353. dateObj.setDate(parseFloat(day));
  354. },
  355. l: doNothing,
  356. m: function (dateObj, month) {
  357. dateObj.setMonth(parseFloat(month) - 1);
  358. },
  359. n: function (dateObj, month) {
  360. dateObj.setMonth(parseFloat(month) - 1);
  361. },
  362. s: function (dateObj, seconds) {
  363. dateObj.setSeconds(parseFloat(seconds));
  364. },
  365. u: function (_, unixMillSeconds) {
  366. return new Date(parseFloat(unixMillSeconds));
  367. },
  368. w: doNothing,
  369. y: function (dateObj, year) {
  370. dateObj.setFullYear(2000 + parseFloat(year));
  371. }
  372. };
  373. var tokenRegex = {
  374. D: "(\\w+)",
  375. F: "(\\w+)",
  376. G: "(\\d\\d|\\d)",
  377. H: "(\\d\\d|\\d)",
  378. J: "(\\d\\d|\\d)\\w+",
  379. K: "",
  380. M: "(\\w+)",
  381. S: "(\\d\\d|\\d)",
  382. U: "(.+)",
  383. W: "(\\d\\d|\\d)",
  384. Y: "(\\d{4})",
  385. Z: "(.+)",
  386. d: "(\\d\\d|\\d)",
  387. h: "(\\d\\d|\\d)",
  388. i: "(\\d\\d|\\d)",
  389. j: "(\\d\\d|\\d)",
  390. l: "(\\w+)",
  391. m: "(\\d\\d|\\d)",
  392. n: "(\\d\\d|\\d)",
  393. s: "(\\d\\d|\\d)",
  394. u: "(.+)",
  395. w: "(\\d\\d|\\d)",
  396. y: "(\\d{2})"
  397. };
  398. var formats = {
  399. // get the date in UTC
  400. Z: function (date) {
  401. return date.toISOString();
  402. },
  403. // weekday name, short, e.g. Thu
  404. D: function (date, locale, options) {
  405. return locale.weekdays.shorthand[formats.w(date, locale, options)];
  406. },
  407. // full month name e.g. January
  408. F: function (date, locale, options) {
  409. return monthToStr(formats.n(date, locale, options) - 1, false, locale);
  410. },
  411. // padded hour 1-12
  412. G: function (date, locale, options) {
  413. return pad(formats.h(date, locale, options));
  414. },
  415. // hours with leading zero e.g. 03
  416. H: function (date) {
  417. return pad(date.getHours());
  418. },
  419. // day (1-30) with ordinal suffix e.g. 1st, 2nd
  420. J: function (date, locale) {
  421. return locale.ordinal !== undefined ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
  422. },
  423. // AM/PM
  424. K: function (date, locale) {
  425. return locale.amPM[int(date.getHours() > 11)];
  426. },
  427. // shorthand month e.g. Jan, Sep, Oct, etc
  428. M: function (date, locale) {
  429. return monthToStr(date.getMonth(), true, locale);
  430. },
  431. // seconds 00-59
  432. S: function (date) {
  433. return pad(date.getSeconds());
  434. },
  435. // unix timestamp
  436. U: function (date) {
  437. return date.getTime() / 1000;
  438. },
  439. W: function (date, _, options) {
  440. return options.getWeek(date);
  441. },
  442. // full year e.g. 2016
  443. Y: function (date) {
  444. return date.getFullYear();
  445. },
  446. // day in month, padded (01-30)
  447. d: function (date) {
  448. return pad(date.getDate());
  449. },
  450. // hour from 1-12 (am/pm)
  451. h: function (date) {
  452. return date.getHours() % 12 ? date.getHours() % 12 : 12;
  453. },
  454. // minutes, padded with leading zero e.g. 09
  455. i: function (date) {
  456. return pad(date.getMinutes());
  457. },
  458. // day in month (1-30)
  459. j: function (date) {
  460. return date.getDate();
  461. },
  462. // weekday name, full, e.g. Thursday
  463. l: function (date, locale) {
  464. return locale.weekdays.longhand[date.getDay()];
  465. },
  466. // padded month number (01-12)
  467. m: function (date) {
  468. return pad(date.getMonth() + 1);
  469. },
  470. // the month number (1-12)
  471. n: function (date) {
  472. return date.getMonth() + 1;
  473. },
  474. // seconds 0-59
  475. s: function (date) {
  476. return date.getSeconds();
  477. },
  478. // Unix Milliseconds
  479. u: function (date) {
  480. return date.getTime();
  481. },
  482. // number of the day of the week
  483. w: function (date) {
  484. return date.getDay();
  485. },
  486. // last two digits of year e.g. 16 for 2016
  487. y: function (date) {
  488. return String(date.getFullYear()).substring(2);
  489. }
  490. };
  491. var createDateFormatter = function (_a) {
  492. var _b = _a.config,
  493. config = _b === void 0 ? defaults : _b,
  494. _c = _a.l10n,
  495. l10n = _c === void 0 ? english : _c;
  496. return function (dateObj, frmt, overrideLocale) {
  497. var locale = overrideLocale || l10n;
  498. if (config.formatDate !== undefined) {
  499. return config.formatDate(dateObj, frmt, locale);
  500. }
  501. return frmt.split("").map(function (c, i, arr) {
  502. return formats[c] && arr[i - 1] !== "\\" ? formats[c](dateObj, locale, config) : c !== "\\" ? c : "";
  503. }).join("");
  504. };
  505. };
  506. var createDateParser = function (_a) {
  507. var _b = _a.config,
  508. config = _b === void 0 ? defaults : _b,
  509. _c = _a.l10n,
  510. l10n = _c === void 0 ? english : _c;
  511. return function (date, givenFormat, timeless, customLocale) {
  512. if (date !== 0 && !date) return undefined;
  513. var locale = customLocale || l10n;
  514. var parsedDate;
  515. var dateOrig = date;
  516. if (date instanceof Date) parsedDate = new Date(date.getTime());else if (typeof date !== "string" && date.toFixed !== undefined // timestamp
  517. ) // create a copy
  518. parsedDate = new Date(date);else if (typeof date === "string") {
  519. // date string
  520. var format = givenFormat || (config || defaults).dateFormat;
  521. var datestr = String(date).trim();
  522. if (datestr === "today") {
  523. parsedDate = new Date();
  524. timeless = true;
  525. } else if (/Z$/.test(datestr) || /GMT$/.test(datestr) // datestrings w/ timezone
  526. ) parsedDate = new Date(date);else if (config && config.parseDate) parsedDate = config.parseDate(date, format);else {
  527. parsedDate = !config || !config.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
  528. var matched = void 0,
  529. ops = [];
  530. for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
  531. var token_1 = format[i];
  532. var isBackSlash = token_1 === "\\";
  533. var escaped = format[i - 1] === "\\" || isBackSlash;
  534. if (tokenRegex[token_1] && !escaped) {
  535. regexStr += tokenRegex[token_1];
  536. var match = new RegExp(regexStr).exec(date);
  537. if (match && (matched = true)) {
  538. ops[token_1 !== "Y" ? "push" : "unshift"]({
  539. fn: revFormat[token_1],
  540. val: match[++matchIndex]
  541. });
  542. }
  543. } else if (!isBackSlash) regexStr += "."; // don't really care
  544. ops.forEach(function (_a) {
  545. var fn = _a.fn,
  546. val = _a.val;
  547. return parsedDate = fn(parsedDate, val, locale) || parsedDate;
  548. });
  549. }
  550. parsedDate = matched ? parsedDate : undefined;
  551. }
  552. }
  553. /* istanbul ignore next */
  554. if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
  555. config.errorHandler(new Error("Invalid date provided: " + dateOrig));
  556. return undefined;
  557. }
  558. if (timeless === true) parsedDate.setHours(0, 0, 0, 0);
  559. return parsedDate;
  560. };
  561. };
  562. /**
  563. * Compute the difference in dates, measured in ms
  564. */
  565. function compareDates(date1, date2, timeless) {
  566. if (timeless === void 0) {
  567. timeless = true;
  568. }
  569. if (timeless !== false) {
  570. return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
  571. }
  572. return date1.getTime() - date2.getTime();
  573. }
  574. var isBetween = function (ts, ts1, ts2) {
  575. return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
  576. };
  577. var duration = {
  578. DAY: 86400000
  579. };
  580. if (typeof Object.assign !== "function") {
  581. Object.assign = function (target) {
  582. var args = [];
  583. for (var _i = 1; _i < arguments.length; _i++) {
  584. args[_i - 1] = arguments[_i];
  585. }
  586. if (!target) {
  587. throw TypeError("Cannot convert undefined or null to object");
  588. }
  589. var _loop_1 = function (source) {
  590. if (source) {
  591. Object.keys(source).forEach(function (key) {
  592. return target[key] = source[key];
  593. });
  594. }
  595. };
  596. for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
  597. var source = args_1[_a];
  598. _loop_1(source);
  599. }
  600. return target;
  601. };
  602. }
  603. var DEBOUNCED_CHANGE_MS = 300;
  604. function FlatpickrInstance(element, instanceConfig) {
  605. var self = {
  606. config: __assign({}, defaults, flatpickr.defaultConfig),
  607. l10n: english
  608. };
  609. self.parseDate = createDateParser({
  610. config: self.config,
  611. l10n: self.l10n
  612. });
  613. self._handlers = [];
  614. self.pluginElements = [];
  615. self.loadedPlugins = [];
  616. self._bind = bind;
  617. self._setHoursFromDate = setHoursFromDate;
  618. self._positionCalendar = positionCalendar;
  619. self.changeMonth = changeMonth;
  620. self.changeYear = changeYear;
  621. self.clear = clear;
  622. self.close = close;
  623. self._createElement = createElement;
  624. self.destroy = destroy;
  625. self.isEnabled = isEnabled;
  626. self.jumpToDate = jumpToDate;
  627. self.open = open;
  628. self.redraw = redraw;
  629. self.set = set;
  630. self.setDate = setDate;
  631. self.toggle = toggle;
  632. function setupHelperFunctions() {
  633. self.utils = {
  634. getDaysInMonth: function (month, yr) {
  635. if (month === void 0) {
  636. month = self.currentMonth;
  637. }
  638. if (yr === void 0) {
  639. yr = self.currentYear;
  640. }
  641. if (month === 1 && (yr % 4 === 0 && yr % 100 !== 0 || yr % 400 === 0)) return 29;
  642. return self.l10n.daysInMonth[month];
  643. }
  644. };
  645. }
  646. function init() {
  647. self.element = self.input = element;
  648. self.isOpen = false;
  649. parseConfig();
  650. setupLocale();
  651. setupInputs();
  652. setupDates();
  653. setupHelperFunctions();
  654. if (!self.isMobile) build();
  655. bindEvents();
  656. if (self.selectedDates.length || self.config.noCalendar) {
  657. if (self.config.enableTime) {
  658. setHoursFromDate(self.config.noCalendar ? self.latestSelectedDateObj || self.config.minDate : undefined);
  659. }
  660. updateValue(false);
  661. }
  662. setCalendarWidth();
  663. self.showTimeInput = self.selectedDates.length > 0 || self.config.noCalendar;
  664. var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  665. /* TODO: investigate this further
  666. Currently, there is weird positioning behavior in safari causing pages
  667. to scroll up. https://github.com/chmln/flatpickr/issues/563
  668. However, most browsers are not Safari and positioning is expensive when used
  669. in scale. https://github.com/chmln/flatpickr/issues/1096
  670. */
  671. if (!self.isMobile && isSafari) {
  672. positionCalendar();
  673. }
  674. triggerEvent("onReady");
  675. }
  676. function bindToInstance(fn) {
  677. return fn.bind(self);
  678. }
  679. function setCalendarWidth() {
  680. var config = self.config;
  681. if (config.weekNumbers === false && config.showMonths === 1) return;else if (config.noCalendar !== true) {
  682. window.requestAnimationFrame(function () {
  683. if (self.calendarContainer !== undefined) {
  684. self.calendarContainer.style.visibility = "hidden";
  685. self.calendarContainer.style.display = "block";
  686. }
  687. if (self.daysContainer !== undefined) {
  688. var daysWidth = (self.days.offsetWidth + 1) * config.showMonths;
  689. self.daysContainer.style.width = daysWidth + "px";
  690. self.calendarContainer.style.width = daysWidth + (self.weekWrapper !== undefined ? self.weekWrapper.offsetWidth : 0) + "px";
  691. self.calendarContainer.style.removeProperty("visibility");
  692. self.calendarContainer.style.removeProperty("display");
  693. }
  694. });
  695. }
  696. }
  697. /**
  698. * The handler for all events targeting the time inputs
  699. */
  700. function updateTime(e) {
  701. if (self.selectedDates.length === 0) {
  702. setDefaultTime();
  703. }
  704. if (e !== undefined && e.type !== "blur") {
  705. timeWrapper(e);
  706. }
  707. var prevValue = self._input.value;
  708. setHoursFromInputs();
  709. updateValue();
  710. if (self._input.value !== prevValue) {
  711. self._debouncedChange();
  712. }
  713. }
  714. function ampm2military(hour, amPM) {
  715. return hour % 12 + 12 * int(amPM === self.l10n.amPM[1]);
  716. }
  717. function military2ampm(hour) {
  718. switch (hour % 24) {
  719. case 0:
  720. case 12:
  721. return 12;
  722. default:
  723. return hour % 12;
  724. }
  725. }
  726. /**
  727. * Syncs the selected date object time with user's time input
  728. */
  729. function setHoursFromInputs() {
  730. if (self.hourElement === undefined || self.minuteElement === undefined) return;
  731. var hours = (parseInt(self.hourElement.value.slice(-2), 10) || 0) % 24,
  732. minutes = (parseInt(self.minuteElement.value, 10) || 0) % 60,
  733. seconds = self.secondElement !== undefined ? (parseInt(self.secondElement.value, 10) || 0) % 60 : 0;
  734. if (self.amPM !== undefined) {
  735. hours = ampm2military(hours, self.amPM.textContent);
  736. }
  737. var limitMinHours = self.config.minTime !== undefined || self.config.minDate && self.minDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.minDate, true) === 0;
  738. var limitMaxHours = self.config.maxTime !== undefined || self.config.maxDate && self.maxDateHasTime && self.latestSelectedDateObj && compareDates(self.latestSelectedDateObj, self.config.maxDate, true) === 0;
  739. if (limitMaxHours) {
  740. var maxTime = self.config.maxTime !== undefined ? self.config.maxTime : self.config.maxDate;
  741. hours = Math.min(hours, maxTime.getHours());
  742. if (hours === maxTime.getHours()) minutes = Math.min(minutes, maxTime.getMinutes());
  743. if (minutes === maxTime.getMinutes()) seconds = Math.min(seconds, maxTime.getSeconds());
  744. }
  745. if (limitMinHours) {
  746. var minTime = self.config.minTime !== undefined ? self.config.minTime : self.config.minDate;
  747. hours = Math.max(hours, minTime.getHours());
  748. if (hours === minTime.getHours()) minutes = Math.max(minutes, minTime.getMinutes());
  749. if (minutes === minTime.getMinutes()) seconds = Math.max(seconds, minTime.getSeconds());
  750. }
  751. setHours(hours, minutes, seconds);
  752. }
  753. /**
  754. * Syncs time input values with a date
  755. */
  756. function setHoursFromDate(dateObj) {
  757. var date = dateObj || self.latestSelectedDateObj;
  758. if (date) setHours(date.getHours(), date.getMinutes(), date.getSeconds());
  759. }
  760. function setDefaultHours() {
  761. var hours = self.config.defaultHour;
  762. var minutes = self.config.defaultMinute;
  763. var seconds = self.config.defaultSeconds;
  764. if (self.config.minDate !== undefined) {
  765. var minHr = self.config.minDate.getHours();
  766. var minMinutes = self.config.minDate.getMinutes();
  767. hours = Math.max(hours, minHr);
  768. if (hours === minHr) minutes = Math.max(minMinutes, minutes);
  769. if (hours === minHr && minutes === minMinutes) seconds = self.config.minDate.getSeconds();
  770. }
  771. if (self.config.maxDate !== undefined) {
  772. var maxHr = self.config.maxDate.getHours();
  773. var maxMinutes = self.config.maxDate.getMinutes();
  774. hours = Math.min(hours, maxHr);
  775. if (hours === maxHr) minutes = Math.min(maxMinutes, minutes);
  776. if (hours === maxHr && minutes === maxMinutes) seconds = self.config.maxDate.getSeconds();
  777. }
  778. setHours(hours, minutes, seconds);
  779. }
  780. /**
  781. * Sets the hours, minutes, and optionally seconds
  782. * of the latest selected date object and the
  783. * corresponding time inputs
  784. * @param {Number} hours the hour. whether its military
  785. * or am-pm gets inferred from config
  786. * @param {Number} minutes the minutes
  787. * @param {Number} seconds the seconds (optional)
  788. */
  789. function setHours(hours, minutes, seconds) {
  790. if (self.latestSelectedDateObj !== undefined) {
  791. self.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
  792. }
  793. if (!self.hourElement || !self.minuteElement || self.isMobile) return;
  794. self.hourElement.value = pad(!self.config.time_24hr ? (12 + hours) % 12 + 12 * int(hours % 12 === 0) : hours);
  795. self.minuteElement.value = pad(minutes);
  796. if (self.amPM !== undefined) self.amPM.textContent = self.l10n.amPM[int(hours >= 12)];
  797. if (self.secondElement !== undefined) self.secondElement.value = pad(seconds);
  798. }
  799. /**
  800. * Handles the year input and incrementing events
  801. * @param {Event} event the keyup or increment event
  802. */
  803. function onYearInput(event) {
  804. var year = parseInt(event.target.value) + (event.delta || 0);
  805. if (year / 1000 > 1 || event.key === "Enter" && !/[^\d]/.test(year.toString())) {
  806. changeYear(year);
  807. }
  808. }
  809. /**
  810. * Essentially addEventListener + tracking
  811. * @param {Element} element the element to addEventListener to
  812. * @param {String} event the event name
  813. * @param {Function} handler the event handler
  814. */
  815. function bind(element, event, handler, options) {
  816. if (event instanceof Array) return event.forEach(function (ev) {
  817. return bind(element, ev, handler, options);
  818. });
  819. if (element instanceof Array) return element.forEach(function (el) {
  820. return bind(el, event, handler, options);
  821. });
  822. element.addEventListener(event, handler, options);
  823. self._handlers.push({
  824. element: element,
  825. event: event,
  826. handler: handler,
  827. options: options
  828. });
  829. }
  830. /**
  831. * A mousedown handler which mimics click.
  832. * Minimizes latency, since we don't need to wait for mouseup in most cases.
  833. * Also, avoids handling right clicks.
  834. *
  835. * @param {Function} handler the event handler
  836. */
  837. function onClick(handler) {
  838. return function (evt) {
  839. evt.which === 1 && handler(evt);
  840. };
  841. }
  842. function triggerChange() {
  843. triggerEvent("onChange");
  844. }
  845. /**
  846. * Adds all the necessary event listeners
  847. */
  848. function bindEvents() {
  849. if (self.config.wrap) {
  850. ["open", "close", "toggle", "clear"].forEach(function (evt) {
  851. Array.prototype.forEach.call(self.element.querySelectorAll("[data-" + evt + "]"), function (el) {
  852. return bind(el, "click", self[evt]);
  853. });
  854. });
  855. }
  856. if (self.isMobile) {
  857. setupMobile();
  858. return;
  859. }
  860. var debouncedResize = debounce(onResize, 50);
  861. self._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
  862. if (self.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent)) bind(self.daysContainer, "mouseover", function (e) {
  863. if (self.config.mode === "range") onMouseOver(e.target);
  864. });
  865. bind(window.document.body, "keydown", onKeyDown);
  866. if (!self.config.inline && !self.config.static) bind(window, "resize", debouncedResize);
  867. if (window.ontouchstart !== undefined) bind(window.document, "touchstart", documentClick);else bind(window.document, "mousedown", onClick(documentClick));
  868. bind(window.document, "focus", documentClick, {
  869. capture: true
  870. });
  871. if (self.config.clickOpens === true) {
  872. bind(self._input, "focus", self.open);
  873. bind(self._input, "mousedown", onClick(self.open));
  874. }
  875. if (self.daysContainer !== undefined) {
  876. bind(self.monthNav, "mousedown", onClick(onMonthNavClick));
  877. bind(self.monthNav, ["keyup", "increment"], onYearInput);
  878. bind(self.daysContainer, "mousedown", onClick(selectDate));
  879. }
  880. if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined) {
  881. var selText = function (e) {
  882. return e.target.select();
  883. };
  884. bind(self.timeContainer, ["increment"], updateTime);
  885. bind(self.timeContainer, "blur", updateTime, {
  886. capture: true
  887. });
  888. bind(self.timeContainer, "mousedown", onClick(timeIncrement));
  889. bind([self.hourElement, self.minuteElement], ["focus", "click"], selText);
  890. if (self.secondElement !== undefined) bind(self.secondElement, "focus", function () {
  891. return self.secondElement && self.secondElement.select();
  892. });
  893. if (self.amPM !== undefined) {
  894. bind(self.amPM, "mousedown", onClick(function (e) {
  895. updateTime(e);
  896. triggerChange();
  897. }));
  898. }
  899. }
  900. }
  901. /**
  902. * Set the calendar view to a particular date.
  903. * @param {Date} jumpDate the date to set the view to
  904. * @param {boolean} triggerChange if change events should be triggered
  905. */
  906. function jumpToDate(jumpDate, triggerChange) {
  907. var jumpTo = jumpDate !== undefined ? self.parseDate(jumpDate) : self.latestSelectedDateObj || (self.config.minDate && self.config.minDate > self.now ? self.config.minDate : self.config.maxDate && self.config.maxDate < self.now ? self.config.maxDate : self.now);
  908. var oldYear = self.currentYear;
  909. var oldMonth = self.currentMonth;
  910. try {
  911. if (jumpTo !== undefined) {
  912. self.currentYear = jumpTo.getFullYear();
  913. self.currentMonth = jumpTo.getMonth();
  914. }
  915. } catch (e) {
  916. /* istanbul ignore next */
  917. e.message = "Invalid date supplied: " + jumpTo;
  918. self.config.errorHandler(e);
  919. }
  920. if (triggerChange && self.currentYear !== oldYear) {
  921. triggerEvent("onYearChange");
  922. buildMonthSwitch();
  923. }
  924. if (triggerChange && (self.currentYear !== oldYear || self.currentMonth !== oldMonth)) {
  925. triggerEvent("onMonthChange");
  926. }
  927. self.redraw();
  928. }
  929. /**
  930. * The up/down arrow handler for time inputs
  931. * @param {Event} e the click event
  932. */
  933. function timeIncrement(e) {
  934. if (~e.target.className.indexOf("arrow")) incrementNumInput(e, e.target.classList.contains("arrowUp") ? 1 : -1);
  935. }
  936. /**
  937. * Increments/decrements the value of input associ-
  938. * ated with the up/down arrow by dispatching an
  939. * "increment" event on the input.
  940. *
  941. * @param {Event} e the click event
  942. * @param {Number} delta the diff (usually 1 or -1)
  943. * @param {Element} inputElem the input element
  944. */
  945. function incrementNumInput(e, delta, inputElem) {
  946. var target = e && e.target;
  947. var input = inputElem || target && target.parentNode && target.parentNode.firstChild;
  948. var event = createEvent("increment");
  949. event.delta = delta;
  950. input && input.dispatchEvent(event);
  951. }
  952. function build() {
  953. var fragment = window.document.createDocumentFragment();
  954. self.calendarContainer = createElement("div", "flatpickr-calendar");
  955. self.calendarContainer.tabIndex = -1;
  956. if (!self.config.noCalendar) {
  957. fragment.appendChild(buildMonthNav());
  958. self.innerContainer = createElement("div", "flatpickr-innerContainer");
  959. if (self.config.weekNumbers) {
  960. var _a = buildWeeks(),
  961. weekWrapper = _a.weekWrapper,
  962. weekNumbers = _a.weekNumbers;
  963. self.innerContainer.appendChild(weekWrapper);
  964. self.weekNumbers = weekNumbers;
  965. self.weekWrapper = weekWrapper;
  966. }
  967. self.rContainer = createElement("div", "flatpickr-rContainer");
  968. self.rContainer.appendChild(buildWeekdays());
  969. if (!self.daysContainer) {
  970. self.daysContainer = createElement("div", "flatpickr-days");
  971. self.daysContainer.tabIndex = -1;
  972. }
  973. buildDays();
  974. self.rContainer.appendChild(self.daysContainer);
  975. self.innerContainer.appendChild(self.rContainer);
  976. fragment.appendChild(self.innerContainer);
  977. }
  978. if (self.config.enableTime) {
  979. fragment.appendChild(buildTime());
  980. }
  981. toggleClass(self.calendarContainer, "rangeMode", self.config.mode === "range");
  982. toggleClass(self.calendarContainer, "animate", self.config.animate === true);
  983. toggleClass(self.calendarContainer, "multiMonth", self.config.showMonths > 1);
  984. self.calendarContainer.appendChild(fragment);
  985. var customAppend = self.config.appendTo !== undefined && self.config.appendTo.nodeType !== undefined;
  986. if (self.config.inline || self.config.static) {
  987. self.calendarContainer.classList.add(self.config.inline ? "inline" : "static");
  988. if (self.config.inline) {
  989. if (!customAppend && self.element.parentNode) self.element.parentNode.insertBefore(self.calendarContainer, self._input.nextSibling);else if (self.config.appendTo !== undefined) self.config.appendTo.appendChild(self.calendarContainer);
  990. }
  991. if (self.config.static) {
  992. var wrapper = createElement("div", "flatpickr-wrapper");
  993. if (self.element.parentNode) self.element.parentNode.insertBefore(wrapper, self.element);
  994. wrapper.appendChild(self.element);
  995. if (self.altInput) wrapper.appendChild(self.altInput);
  996. wrapper.appendChild(self.calendarContainer);
  997. }
  998. }
  999. if (!self.config.static && !self.config.inline) (self.config.appendTo !== undefined ? self.config.appendTo : window.document.body).appendChild(self.calendarContainer);
  1000. }
  1001. function createDay(className, date, dayNumber, i) {
  1002. var dateIsEnabled = isEnabled(date, true),
  1003. dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString());
  1004. dayElement.dateObj = date;
  1005. dayElement.$i = i;
  1006. dayElement.setAttribute("aria-label", self.formatDate(date, self.config.ariaDateFormat));
  1007. if (className.indexOf("hidden") === -1 && compareDates(date, self.now) === 0) {
  1008. self.todayDateElem = dayElement;
  1009. dayElement.classList.add("today");
  1010. dayElement.setAttribute("aria-current", "date");
  1011. }
  1012. if (dateIsEnabled) {
  1013. dayElement.tabIndex = -1;
  1014. if (isDateSelected(date)) {
  1015. dayElement.classList.add("selected");
  1016. self.selectedDateElem = dayElement;
  1017. if (self.config.mode === "range") {
  1018. toggleClass(dayElement, "startRange", self.selectedDates[0] && compareDates(date, self.selectedDates[0], true) === 0);
  1019. toggleClass(dayElement, "endRange", self.selectedDates[1] && compareDates(date, self.selectedDates[1], true) === 0);
  1020. if (className === "nextMonthDay") dayElement.classList.add("inRange");
  1021. }
  1022. }
  1023. } else {
  1024. dayElement.classList.add("flatpickr-disabled");
  1025. }
  1026. if (self.config.mode === "range") {
  1027. if (isDateInRange(date) && !isDateSelected(date)) dayElement.classList.add("inRange");
  1028. }
  1029. if (self.weekNumbers && self.config.showMonths === 1 && className !== "prevMonthDay" && dayNumber % 7 === 1) {
  1030. self.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self.config.getWeek(date) + "</span>");
  1031. }
  1032. triggerEvent("onDayCreate", dayElement);
  1033. return dayElement;
  1034. }
  1035. function focusOnDayElem(targetNode) {
  1036. targetNode.focus();
  1037. if (self.config.mode === "range") onMouseOver(targetNode);
  1038. }
  1039. function getFirstAvailableDay(delta) {
  1040. var startMonth = delta > 0 ? 0 : self.config.showMonths - 1;
  1041. var endMonth = delta > 0 ? self.config.showMonths : -1;
  1042. for (var m = startMonth; m != endMonth; m += delta) {
  1043. var month = self.daysContainer.children[m];
  1044. var startIndex = delta > 0 ? 0 : month.children.length - 1;
  1045. var endIndex = delta > 0 ? month.children.length : -1;
  1046. for (var i = startIndex; i != endIndex; i += delta) {
  1047. var c = month.children[i];
  1048. if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj)) return c;
  1049. }
  1050. }
  1051. return undefined;
  1052. }
  1053. function getNextAvailableDay(current, delta) {
  1054. var givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self.currentMonth;
  1055. var endMonth = delta > 0 ? self.config.showMonths : -1;
  1056. var loopDelta = delta > 0 ? 1 : -1;
  1057. for (var m = givenMonth - self.currentMonth; m != endMonth; m += loopDelta) {
  1058. var month = self.daysContainer.children[m];
  1059. var startIndex = givenMonth - self.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0;
  1060. var numMonthDays = month.children.length;
  1061. for (var i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
  1062. var c = month.children[i];
  1063. if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i) >= Math.abs(delta)) return focusOnDayElem(c);
  1064. }
  1065. }
  1066. self.changeMonth(loopDelta);
  1067. focusOnDay(getFirstAvailableDay(loopDelta), 0);
  1068. return undefined;
  1069. }
  1070. function focusOnDay(current, offset) {
  1071. var dayFocused = isInView(document.activeElement || document.body);
  1072. var startElem = current !== undefined ? current : dayFocused ? document.activeElement : self.selectedDateElem !== undefined && isInView(self.selectedDateElem) ? self.selectedDateElem : self.todayDateElem !== undefined && isInView(self.todayDateElem) ? self.todayDateElem : getFirstAvailableDay(offset > 0 ? 1 : -1);
  1073. if (startElem === undefined) return self._input.focus();
  1074. if (!dayFocused) return focusOnDayElem(startElem);
  1075. getNextAvailableDay(startElem, offset);
  1076. }
  1077. function buildMonthDays(year, month) {
  1078. var firstOfMonth = (new Date(year, month, 1).getDay() - self.l10n.firstDayOfWeek + 7) % 7;
  1079. var prevMonthDays = self.utils.getDaysInMonth((month - 1 + 12) % 12);
  1080. var daysInMonth = self.utils.getDaysInMonth(month),
  1081. days = window.document.createDocumentFragment(),
  1082. isMultiMonth = self.config.showMonths > 1,
  1083. prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay",
  1084. nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
  1085. var dayNumber = prevMonthDays + 1 - firstOfMonth,
  1086. dayIndex = 0; // prepend days from the ending of previous month
  1087. for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
  1088. days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
  1089. } // Start at 1 since there is no 0th day
  1090. for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
  1091. days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex));
  1092. } // append days from the next month
  1093. for (var dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
  1094. days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
  1095. } //updateNavigationCurrentMonth();
  1096. var dayContainer = createElement("div", "dayContainer");
  1097. dayContainer.appendChild(days);
  1098. return dayContainer;
  1099. }
  1100. function buildDays() {
  1101. if (self.daysContainer === undefined) {
  1102. return;
  1103. }
  1104. clearNode(self.daysContainer); // TODO: week numbers for each month
  1105. if (self.weekNumbers) clearNode(self.weekNumbers);
  1106. var frag = document.createDocumentFragment();
  1107. for (var i = 0; i < self.config.showMonths; i++) {
  1108. var d = new Date(self.currentYear, self.currentMonth, 1);
  1109. d.setMonth(self.currentMonth + i);
  1110. frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
  1111. }
  1112. self.daysContainer.appendChild(frag);
  1113. self.days = self.daysContainer.firstChild;
  1114. if (self.config.mode === "range" && self.selectedDates.length === 1) {
  1115. onMouseOver();
  1116. }
  1117. }
  1118. function buildMonthSwitch() {
  1119. if (self.config.showMonths > 1 || self.config.monthSelectorType !== "dropdown") return;
  1120. var shouldBuildMonth = function (month) {
  1121. if (self.config.minDate !== undefined && self.currentYear === self.config.minDate.getFullYear() && month < self.config.minDate.getMonth()) {
  1122. return false;
  1123. }
  1124. return !(self.config.maxDate !== undefined && self.currentYear === self.config.maxDate.getFullYear() && month > self.config.maxDate.getMonth());
  1125. };
  1126. self.monthsDropdownContainer.tabIndex = -1;
  1127. self.monthsDropdownContainer.innerHTML = "";
  1128. for (var i = 0; i < 12; i++) {
  1129. if (!shouldBuildMonth(i)) continue;
  1130. var month = createElement("option", "flatpickr-monthDropdown-month");
  1131. month.value = new Date(self.currentYear, i).getMonth().toString();
  1132. month.textContent = monthToStr(i, self.config.shorthandCurrentMonth, self.l10n);
  1133. month.tabIndex = -1;
  1134. if (self.currentMonth === i) {
  1135. month.selected = true;
  1136. }
  1137. self.monthsDropdownContainer.appendChild(month);
  1138. }
  1139. }
  1140. function buildMonth() {
  1141. var container = createElement("div", "flatpickr-month");
  1142. var monthNavFragment = window.document.createDocumentFragment();
  1143. var monthElement;
  1144. if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
  1145. monthElement = createElement("span", "cur-month");
  1146. } else {
  1147. self.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
  1148. bind(self.monthsDropdownContainer, "change", function (e) {
  1149. var target = e.target;
  1150. var selectedMonth = parseInt(target.value, 10);
  1151. self.changeMonth(selectedMonth - self.currentMonth);
  1152. triggerEvent("onMonthChange");
  1153. });
  1154. buildMonthSwitch();
  1155. monthElement = self.monthsDropdownContainer;
  1156. }
  1157. var yearInput = createNumberInput("cur-year", {
  1158. tabindex: "-1"
  1159. });
  1160. var yearElement = yearInput.getElementsByTagName("input")[0];
  1161. yearElement.setAttribute("aria-label", self.l10n.yearAriaLabel);
  1162. if (self.config.minDate) {
  1163. yearElement.setAttribute("min", self.config.minDate.getFullYear().toString());
  1164. }
  1165. if (self.config.maxDate) {
  1166. yearElement.setAttribute("max", self.config.maxDate.getFullYear().toString());
  1167. yearElement.disabled = !!self.config.minDate && self.config.minDate.getFullYear() === self.config.maxDate.getFullYear();
  1168. }
  1169. var currentMonth = createElement("div", "flatpickr-current-month");
  1170. currentMonth.appendChild(monthElement);
  1171. currentMonth.appendChild(yearInput);
  1172. monthNavFragment.appendChild(currentMonth);
  1173. container.appendChild(monthNavFragment);
  1174. return {
  1175. container: container,
  1176. yearElement: yearElement,
  1177. monthElement: monthElement
  1178. };
  1179. }
  1180. function buildMonths() {
  1181. clearNode(self.monthNav);
  1182. self.monthNav.appendChild(self.prevMonthNav);
  1183. if (self.config.showMonths) {
  1184. self.yearElements = [];
  1185. self.monthElements = [];
  1186. }
  1187. for (var m = self.config.showMonths; m--;) {
  1188. var month = buildMonth();
  1189. self.yearElements.push(month.yearElement);
  1190. self.monthElements.push(month.monthElement);
  1191. self.monthNav.appendChild(month.container);
  1192. }
  1193. self.monthNav.appendChild(self.nextMonthNav);
  1194. }
  1195. function buildMonthNav() {
  1196. self.monthNav = createElement("div", "flatpickr-months");
  1197. self.yearElements = [];
  1198. self.monthElements = [];
  1199. self.prevMonthNav = createElement("span", "flatpickr-prev-month");
  1200. self.prevMonthNav.innerHTML = self.config.prevArrow;
  1201. self.nextMonthNav = createElement("span", "flatpickr-next-month");
  1202. self.nextMonthNav.innerHTML = self.config.nextArrow;
  1203. buildMonths();
  1204. Object.defineProperty(self, "_hidePrevMonthArrow", {
  1205. get: function () {
  1206. return self.__hidePrevMonthArrow;
  1207. },
  1208. set: function (bool) {
  1209. if (self.__hidePrevMonthArrow !== bool) {
  1210. toggleClass(self.prevMonthNav, "flatpickr-disabled", bool);
  1211. self.__hidePrevMonthArrow = bool;
  1212. }
  1213. }
  1214. });
  1215. Object.defineProperty(self, "_hideNextMonthArrow", {
  1216. get: function () {
  1217. return self.__hideNextMonthArrow;
  1218. },
  1219. set: function (bool) {
  1220. if (self.__hideNextMonthArrow !== bool) {
  1221. toggleClass(self.nextMonthNav, "flatpickr-disabled", bool);
  1222. self.__hideNextMonthArrow = bool;
  1223. }
  1224. }
  1225. });
  1226. self.currentYearElement = self.yearElements[0];
  1227. updateNavigationCurrentMonth();
  1228. return self.monthNav;
  1229. }
  1230. function buildTime() {
  1231. self.calendarContainer.classList.add("hasTime");
  1232. if (self.config.noCalendar) self.calendarContainer.classList.add("noCalendar");
  1233. self.timeContainer = createElement("div", "flatpickr-time");
  1234. self.timeContainer.tabIndex = -1;
  1235. var separator = createElement("span", "flatpickr-time-separator", ":");
  1236. var hourInput = createNumberInput("flatpickr-hour", {
  1237. "aria-label": self.l10n.hourAriaLabel
  1238. });
  1239. self.hourElement = hourInput.getElementsByTagName("input")[0];
  1240. var minuteInput = createNumberInput("flatpickr-minute", {
  1241. "aria-label": self.l10n.minuteAriaLabel
  1242. });
  1243. self.minuteElement = minuteInput.getElementsByTagName("input")[0];
  1244. self.hourElement.tabIndex = self.minuteElement.tabIndex = -1;
  1245. self.hourElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getHours() : self.config.time_24hr ? self.config.defaultHour : military2ampm(self.config.defaultHour));
  1246. self.minuteElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getMinutes() : self.config.defaultMinute);
  1247. self.hourElement.setAttribute("step", self.config.hourIncrement.toString());
  1248. self.minuteElement.setAttribute("step", self.config.minuteIncrement.toString());
  1249. self.hourElement.setAttribute("min", self.config.time_24hr ? "0" : "1");
  1250. self.hourElement.setAttribute("max", self.config.time_24hr ? "23" : "12");
  1251. self.minuteElement.setAttribute("min", "0");
  1252. self.minuteElement.setAttribute("max", "59");
  1253. self.timeContainer.appendChild(hourInput);
  1254. self.timeContainer.appendChild(separator);
  1255. self.timeContainer.appendChild(minuteInput);
  1256. if (self.config.time_24hr) self.timeContainer.classList.add("time24hr");
  1257. if (self.config.enableSeconds) {
  1258. self.timeContainer.classList.add("hasSeconds");
  1259. var secondInput = createNumberInput("flatpickr-second");
  1260. self.secondElement = secondInput.getElementsByTagName("input")[0];
  1261. self.secondElement.value = pad(self.latestSelectedDateObj ? self.latestSelectedDateObj.getSeconds() : self.config.defaultSeconds);
  1262. self.secondElement.setAttribute("step", self.minuteElement.getAttribute("step"));
  1263. self.secondElement.setAttribute("min", "0");
  1264. self.secondElement.setAttribute("max", "59");
  1265. self.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
  1266. self.timeContainer.appendChild(secondInput);
  1267. }
  1268. if (!self.config.time_24hr) {
  1269. // add self.amPM if appropriate
  1270. self.amPM = createElement("span", "flatpickr-am-pm", self.l10n.amPM[int((self.latestSelectedDateObj ? self.hourElement.value : self.config.defaultHour) > 11)]);
  1271. self.amPM.title = self.l10n.toggleTitle;
  1272. self.amPM.tabIndex = -1;
  1273. self.timeContainer.appendChild(self.amPM);
  1274. }
  1275. return self.timeContainer;
  1276. }
  1277. function buildWeekdays() {
  1278. if (!self.weekdayContainer) self.weekdayContainer = createElement("div", "flatpickr-weekdays");else clearNode(self.weekdayContainer);
  1279. for (var i = self.config.showMonths; i--;) {
  1280. var container = createElement("div", "flatpickr-weekdaycontainer");
  1281. self.weekdayContainer.appendChild(container);
  1282. }
  1283. updateWeekdays();
  1284. return self.weekdayContainer;
  1285. }
  1286. function updateWeekdays() {
  1287. if (!self.weekdayContainer) {
  1288. return;
  1289. }
  1290. var firstDayOfWeek = self.l10n.firstDayOfWeek;
  1291. var weekdays = self.l10n.weekdays.shorthand.slice();
  1292. if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
  1293. weekdays = weekdays.splice(firstDayOfWeek, weekdays.length).concat(weekdays.splice(0, firstDayOfWeek));
  1294. }
  1295. for (var i = self.config.showMonths; i--;) {
  1296. self.weekdayContainer.children[i].innerHTML = "\n <span class='flatpickr-weekday'>\n " + weekdays.join("</span><span class='flatpickr-weekday'>") + "\n </span>\n ";
  1297. }
  1298. }
  1299. /* istanbul ignore next */
  1300. function buildWeeks() {
  1301. self.calendarContainer.classList.add("hasWeeks");
  1302. var weekWrapper = createElement("div", "flatpickr-weekwrapper");
  1303. weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self.l10n.weekAbbreviation));
  1304. var weekNumbers = createElement("div", "flatpickr-weeks");
  1305. weekWrapper.appendChild(weekNumbers);
  1306. return {
  1307. weekWrapper: weekWrapper,
  1308. weekNumbers: weekNumbers
  1309. };
  1310. }
  1311. function changeMonth(value, isOffset) {
  1312. if (isOffset === void 0) {
  1313. isOffset = true;
  1314. }
  1315. var delta = isOffset ? value : value - self.currentMonth;
  1316. if (delta < 0 && self._hidePrevMonthArrow === true || delta > 0 && self._hideNextMonthArrow === true) return;
  1317. self.currentMonth += delta;
  1318. if (self.currentMonth < 0 || self.currentMonth > 11) {
  1319. self.currentYear += self.currentMonth > 11 ? 1 : -1;
  1320. self.currentMonth = (self.currentMonth + 12) % 12;
  1321. triggerEvent("onYearChange");
  1322. buildMonthSwitch();
  1323. }
  1324. buildDays();
  1325. triggerEvent("onMonthChange");
  1326. updateNavigationCurrentMonth();
  1327. }
  1328. function clear(triggerChangeEvent, toInitial) {
  1329. if (triggerChangeEvent === void 0) {
  1330. triggerChangeEvent = true;
  1331. }
  1332. if (toInitial === void 0) {
  1333. toInitial = true;
  1334. }
  1335. self.input.value = "";
  1336. if (self.altInput !== undefined) self.altInput.value = "";
  1337. if (self.mobileInput !== undefined) self.mobileInput.value = "";
  1338. self.selectedDates = [];
  1339. self.latestSelectedDateObj = undefined;
  1340. if (toInitial === true) {
  1341. self.currentYear = self._initialDate.getFullYear();
  1342. self.currentMonth = self._initialDate.getMonth();
  1343. }
  1344. self.showTimeInput = false;
  1345. if (self.config.enableTime === true) {
  1346. setDefaultHours();
  1347. }
  1348. self.redraw();
  1349. if (triggerChangeEvent) // triggerChangeEvent is true (default) or an Event
  1350. triggerEvent("onChange");
  1351. }
  1352. function close() {
  1353. self.isOpen = false;
  1354. if (!self.isMobile) {
  1355. if (self.calendarContainer !== undefined) {
  1356. self.calendarContainer.classList.remove("open");
  1357. }
  1358. if (self._input !== undefined) {
  1359. self._input.classList.remove("active");
  1360. }
  1361. }
  1362. triggerEvent("onClose");
  1363. }
  1364. function destroy() {
  1365. if (self.config !== undefined) triggerEvent("onDestroy");
  1366. for (var i = self._handlers.length; i--;) {
  1367. var h = self._handlers[i];
  1368. h.element.removeEventListener(h.event, h.handler, h.options);
  1369. }
  1370. self._handlers = [];
  1371. if (self.mobileInput) {
  1372. if (self.mobileInput.parentNode) self.mobileInput.parentNode.removeChild(self.mobileInput);
  1373. self.mobileInput = undefined;
  1374. } else if (self.calendarContainer && self.calendarContainer.parentNode) {
  1375. if (self.config.static && self.calendarContainer.parentNode) {
  1376. var wrapper = self.calendarContainer.parentNode;
  1377. wrapper.lastChild && wrapper.removeChild(wrapper.lastChild);
  1378. if (wrapper.parentNode) {
  1379. while (wrapper.firstChild) wrapper.parentNode.insertBefore(wrapper.firstChild, wrapper);
  1380. wrapper.parentNode.removeChild(wrapper);
  1381. }
  1382. } else self.calendarContainer.parentNode.removeChild(self.calendarContainer);
  1383. }
  1384. if (self.altInput) {
  1385. self.input.type = "text";
  1386. if (self.altInput.parentNode) self.altInput.parentNode.removeChild(self.altInput);
  1387. delete self.altInput;
  1388. }
  1389. if (self.input) {
  1390. self.input.type = self.input._type;
  1391. self.input.classList.remove("flatpickr-input");
  1392. self.input.removeAttribute("readonly");
  1393. self.input.value = "";
  1394. }
  1395. ["_showTimeInput", "latestSelectedDateObj", "_hideNextMonthArrow", "_hidePrevMonthArrow", "__hideNextMonthArrow", "__hidePrevMonthArrow", "isMobile", "isOpen", "selectedDateElem", "minDateHasTime", "maxDateHasTime", "days", "daysContainer", "_input", "_positionElement", "innerContainer", "rContainer", "monthNav", "todayDateElem", "calendarContainer", "weekdayContainer", "prevMonthNav", "nextMonthNav", "monthsDropdownContainer", "currentMonthElement", "currentYearElement", "navigationCurrentMonth", "selectedDateElem", "config"].forEach(function (k) {
  1396. try {
  1397. delete self[k];
  1398. } catch (_) {}
  1399. });
  1400. }
  1401. function isCalendarElem(elem) {
  1402. if (self.config.appendTo && self.config.appendTo.contains(elem)) return true;
  1403. return self.calendarContainer.contains(elem);
  1404. }
  1405. function documentClick(e) {
  1406. if (self.isOpen && !self.config.inline) {
  1407. var eventTarget_1 = getEventTarget(e);
  1408. var isCalendarElement = isCalendarElem(eventTarget_1);
  1409. var isInput = eventTarget_1 === self.input || eventTarget_1 === self.altInput || self.element.contains(eventTarget_1) || // web components
  1410. // e.path is not present in all browsers. circumventing typechecks
  1411. e.path && e.path.indexOf && (~e.path.indexOf(self.input) || ~e.path.indexOf(self.altInput));
  1412. var lostFocus = e.type === "blur" ? isInput && e.relatedTarget && !isCalendarElem(e.relatedTarget) : !isInput && !isCalendarElement && !isCalendarElem(e.relatedTarget);
  1413. var isIgnored = !self.config.ignoredFocusElements.some(function (elem) {
  1414. return elem.contains(eventTarget_1);
  1415. });
  1416. if (lostFocus && isIgnored) {
  1417. if (self.timeContainer !== undefined && self.minuteElement !== undefined && self.hourElement !== undefined) {
  1418. updateTime();
  1419. }
  1420. self.close();
  1421. if (self.config.mode === "range" && self.selectedDates.length === 1) {
  1422. self.clear(false);
  1423. self.redraw();
  1424. }
  1425. }
  1426. }
  1427. }
  1428. function changeYear(newYear) {
  1429. if (!newYear || self.config.minDate && newYear < self.config.minDate.getFullYear() || self.config.maxDate && newYear > self.config.maxDate.getFullYear()) return;
  1430. var newYearNum = newYear,
  1431. isNewYear = self.currentYear !== newYearNum;
  1432. self.currentYear = newYearNum || self.currentYear;
  1433. if (self.config.maxDate && self.currentYear === self.config.maxDate.getFullYear()) {
  1434. self.currentMonth = Math.min(self.config.maxDate.getMonth(), self.currentMonth);
  1435. } else if (self.config.minDate && self.currentYear === self.config.minDate.getFullYear()) {
  1436. self.currentMonth = Math.max(self.config.minDate.getMonth(), self.currentMonth);
  1437. }
  1438. if (isNewYear) {
  1439. self.redraw();
  1440. triggerEvent("onYearChange");
  1441. buildMonthSwitch();
  1442. }
  1443. }
  1444. function isEnabled(date, timeless) {
  1445. if (timeless === void 0) {
  1446. timeless = true;
  1447. }
  1448. var dateToCheck = self.parseDate(date, undefined, timeless); // timeless
  1449. if (self.config.minDate && dateToCheck && compareDates(dateToCheck, self.config.minDate, timeless !== undefined ? timeless : !self.minDateHasTime) < 0 || self.config.maxDate && dateToCheck && compareDates(dateToCheck, self.config.maxDate, timeless !== undefined ? timeless : !self.maxDateHasTime) > 0) return false;
  1450. if (self.config.enable.length === 0 && self.config.disable.length === 0) return true;
  1451. if (dateToCheck === undefined) return false;
  1452. var bool = self.config.enable.length > 0,
  1453. array = bool ? self.config.enable : self.config.disable;
  1454. for (var i = 0, d = void 0; i < array.length; i++) {
  1455. d = array[i];
  1456. if (typeof d === "function" && d(dateToCheck) // disabled by function
  1457. ) return bool;else if (d instanceof Date && dateToCheck !== undefined && d.getTime() === dateToCheck.getTime()) // disabled by date
  1458. return bool;else if (typeof d === "string" && dateToCheck !== undefined) {
  1459. // disabled by date string
  1460. var parsed = self.parseDate(d, undefined, true);
  1461. return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool;
  1462. } else if ( // disabled by range
  1463. typeof d === "object" && dateToCheck !== undefined && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime()) return bool;
  1464. }
  1465. return !bool;
  1466. }
  1467. function isInView(elem) {
  1468. if (self.daysContainer !== undefined) return elem.className.indexOf("hidden") === -1 && self.daysContainer.contains(elem);
  1469. return false;
  1470. }
  1471. function onKeyDown(e) {
  1472. // e.key e.keyCode
  1473. // "Backspace" 8
  1474. // "Tab" 9
  1475. // "Enter" 13
  1476. // "Escape" (IE "Esc") 27
  1477. // "ArrowLeft" (IE "Left") 37
  1478. // "ArrowUp" (IE "Up") 38
  1479. // "ArrowRight" (IE "Right") 39
  1480. // "ArrowDown" (IE "Down") 40
  1481. // "Delete" (IE "Del") 46
  1482. var isInput = e.target === self._input;
  1483. var allowInput = self.config.allowInput;
  1484. var allowKeydown = self.isOpen && (!allowInput || !isInput);
  1485. var allowInlineKeydown = self.config.inline && isInput && !allowInput;
  1486. if (e.keyCode === 13 && isInput) {
  1487. if (allowInput) {
  1488. self.setDate(self._input.value, true, e.target === self.altInput ? self.config.altFormat : self.config.dateFormat);
  1489. return e.target.blur();
  1490. } else {
  1491. self.open();
  1492. }
  1493. } else if (isCalendarElem(e.target) || allowKeydown || allowInlineKeydown) {
  1494. var isTimeObj = !!self.timeContainer && self.timeContainer.contains(e.target);
  1495. switch (e.keyCode) {
  1496. case 13:
  1497. if (isTimeObj) {
  1498. e.preventDefault();
  1499. updateTime();
  1500. focusAndClose();
  1501. } else selectDate(e);
  1502. break;
  1503. case 27:
  1504. // escape
  1505. e.preventDefault();
  1506. focusAndClose();
  1507. break;
  1508. case 8:
  1509. case 46:
  1510. if (isInput && !self.config.allowInput) {
  1511. e.preventDefault();
  1512. self.clear();
  1513. }
  1514. break;
  1515. case 37:
  1516. case 39:
  1517. if (!isTimeObj && !isInput) {
  1518. e.preventDefault();
  1519. if (self.daysContainer !== undefined && (allowInput === false || document.activeElement && isInView(document.activeElement))) {
  1520. var delta_1 = e.keyCode === 39 ? 1 : -1;
  1521. if (!e.ctrlKey) focusOnDay(undefined, delta_1);else {
  1522. e.stopPropagation();
  1523. changeMonth(delta_1);
  1524. focusOnDay(getFirstAvailableDay(1), 0);
  1525. }
  1526. }
  1527. } else if (self.hourElement) self.hourElement.focus();
  1528. break;
  1529. case 38:
  1530. case 40:
  1531. e.preventDefault();
  1532. var delta = e.keyCode === 40 ? 1 : -1;
  1533. if (self.daysContainer && e.target.$i !== undefined || e.target === self.input || e.target === self.altInput) {
  1534. if (e.ctrlKey) {
  1535. e.stopPropagation();
  1536. changeYear(self.currentYear - delta);
  1537. focusOnDay(getFirstAvailableDay(1), 0);
  1538. } else if (!isTimeObj) focusOnDay(undefined, delta * 7);
  1539. } else if (e.target === self.currentYearElement) {
  1540. changeYear(self.currentYear - delta);
  1541. } else if (self.config.enableTime) {
  1542. if (!isTimeObj && self.hourElement) self.hourElement.focus();
  1543. updateTime(e);
  1544. self._debouncedChange();
  1545. }
  1546. break;
  1547. case 9:
  1548. if (isTimeObj) {
  1549. var elems = [self.hourElement, self.minuteElement, self.secondElement, self.amPM].concat(self.pluginElements).filter(function (x) {
  1550. return x;
  1551. });
  1552. var i = elems.indexOf(e.target);
  1553. if (i !== -1) {
  1554. var target = elems[i + (e.shiftKey ? -1 : 1)];
  1555. e.preventDefault();
  1556. (target || self._input).focus();
  1557. }
  1558. } else if (!self.config.noCalendar && self.daysContainer && self.daysContainer.contains(e.target) && e.shiftKey) {
  1559. e.preventDefault();
  1560. self._input.focus();
  1561. }
  1562. break;
  1563. default:
  1564. break;
  1565. }
  1566. }
  1567. if (self.amPM !== undefined && e.target === self.amPM) {
  1568. switch (e.key) {
  1569. case self.l10n.amPM[0].charAt(0):
  1570. case self.l10n.amPM[0].charAt(0).toLowerCase():
  1571. self.amPM.textContent = self.l10n.amPM[0];
  1572. setHoursFromInputs();
  1573. updateValue();
  1574. break;
  1575. case self.l10n.amPM[1].charAt(0):
  1576. case self.l10n.amPM[1].charAt(0).toLowerCase():
  1577. self.amPM.textContent = self.l10n.amPM[1];
  1578. setHoursFromInputs();
  1579. updateValue();
  1580. break;
  1581. }
  1582. }
  1583. if (isInput || isCalendarElem(e.target)) {
  1584. triggerEvent("onKeyDown", e);
  1585. }
  1586. }
  1587. function onMouseOver(elem) {
  1588. if (self.selectedDates.length !== 1 || elem && (!elem.classList.contains("flatpickr-day") || elem.classList.contains("flatpickr-disabled"))) return;
  1589. var hoverDate = elem ? elem.dateObj.getTime() : self.days.firstElementChild.dateObj.getTime(),
  1590. initialDate = self.parseDate(self.selectedDates[0], undefined, true).getTime(),
  1591. rangeStartDate = Math.min(hoverDate, self.selectedDates[0].getTime()),
  1592. rangeEndDate = Math.max(hoverDate, self.selectedDates[0].getTime());
  1593. var containsDisabled = false;
  1594. var minRange = 0,
  1595. maxRange = 0;
  1596. for (var t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
  1597. if (!isEnabled(new Date(t), true)) {
  1598. containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate;
  1599. if (t < initialDate && (!minRange || t > minRange)) minRange = t;else if (t > initialDate && (!maxRange || t < maxRange)) maxRange = t;
  1600. }
  1601. }
  1602. for (var m = 0; m < self.config.showMonths; m++) {
  1603. var month = self.daysContainer.children[m];
  1604. var _loop_1 = function (i, l) {
  1605. var dayElem = month.children[i],
  1606. date = dayElem.dateObj;
  1607. var timestamp = date.getTime();
  1608. var outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange;
  1609. if (outOfRange) {
  1610. dayElem.classList.add("notAllowed");
  1611. ["inRange", "startRange", "endRange"].forEach(function (c) {
  1612. dayElem.classList.remove(c);
  1613. });
  1614. return "continue";
  1615. } else if (containsDisabled && !outOfRange) return "continue";
  1616. ["startRange", "inRange", "endRange", "notAllowed"].forEach(function (c) {
  1617. dayElem.classList.remove(c);
  1618. });
  1619. if (elem !== undefined) {
  1620. elem.classList.add(hoverDate <= self.selectedDates[0].getTime() ? "startRange" : "endRange");
  1621. if (initialDate < hoverDate && timestamp === initialDate) dayElem.classList.add("startRange");else if (initialDate > hoverDate && timestamp === initialDate) dayElem.classList.add("endRange");
  1622. if (timestamp >= minRange && (maxRange === 0 || timestamp <= maxRange) && isBetween(timestamp, initialDate, hoverDate)) dayElem.classList.add("inRange");
  1623. }
  1624. };
  1625. for (var i = 0, l = month.children.length; i < l; i++) {
  1626. _loop_1(i, l);
  1627. }
  1628. }
  1629. }
  1630. function onResize() {
  1631. if (self.isOpen && !self.config.static && !self.config.inline) positionCalendar();
  1632. }
  1633. function setDefaultTime() {
  1634. self.setDate(self.config.minDate !== undefined ? new Date(self.config.minDate.getTime()) : new Date(), true);
  1635. setDefaultHours();
  1636. updateValue();
  1637. }
  1638. function open(e, positionElement) {
  1639. if (positionElement === void 0) {
  1640. positionElement = self._positionElement;
  1641. }
  1642. if (self.isMobile === true) {
  1643. if (e) {
  1644. e.preventDefault();
  1645. e.target && e.target.blur();
  1646. }
  1647. if (self.mobileInput !== undefined) {
  1648. self.mobileInput.focus();
  1649. self.mobileInput.click();
  1650. }
  1651. triggerEvent("onOpen");
  1652. return;
  1653. }
  1654. if (self._input.disabled || self.config.inline) return;
  1655. var wasOpen = self.isOpen;
  1656. self.isOpen = true;
  1657. if (!wasOpen) {
  1658. self.calendarContainer.classList.add("open");
  1659. self._input.classList.add("active");
  1660. triggerEvent("onOpen");
  1661. positionCalendar(positionElement);
  1662. }
  1663. if (self.config.enableTime === true && self.config.noCalendar === true) {
  1664. if (self.selectedDates.length === 0) {
  1665. setDefaultTime();
  1666. }
  1667. if (self.config.allowInput === false && (e === undefined || !self.timeContainer.contains(e.relatedTarget))) {
  1668. setTimeout(function () {
  1669. return self.hourElement.select();
  1670. }, 50);
  1671. }
  1672. }
  1673. }
  1674. function minMaxDateSetter(type) {
  1675. return function (date) {
  1676. var dateObj = self.config["_" + type + "Date"] = self.parseDate(date, self.config.dateFormat);
  1677. var inverseDateObj = self.config["_" + (type === "min" ? "max" : "min") + "Date"];
  1678. if (dateObj !== undefined) {
  1679. self[type === "min" ? "minDateHasTime" : "maxDateHasTime"] = dateObj.getHours() > 0 || dateObj.getMinutes() > 0 || dateObj.getSeconds() > 0;
  1680. }
  1681. if (self.selectedDates) {
  1682. self.selectedDates = self.selectedDates.filter(function (d) {
  1683. return isEnabled(d);
  1684. });
  1685. if (!self.selectedDates.length && type === "min") setHoursFromDate(dateObj);
  1686. updateValue();
  1687. }
  1688. if (self.daysContainer) {
  1689. redraw();
  1690. if (dateObj !== undefined) self.currentYearElement[type] = dateObj.getFullYear().toString();else self.currentYearElement.removeAttribute(type);
  1691. self.currentYearElement.disabled = !!inverseDateObj && dateObj !== undefined && inverseDateObj.getFullYear() === dateObj.getFullYear();
  1692. }
  1693. };
  1694. }
  1695. function parseConfig() {
  1696. var boolOpts = ["wrap", "weekNumbers", "allowInput", "clickOpens", "time_24hr", "enableTime", "noCalendar", "altInput", "shorthandCurrentMonth", "inline", "static", "enableSeconds", "disableMobile"];
  1697. var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
  1698. var formats = {};
  1699. self.config.parseDate = userConfig.parseDate;
  1700. self.config.formatDate = userConfig.formatDate;
  1701. Object.defineProperty(self.config, "enable", {
  1702. get: function () {
  1703. return self.config._enable;
  1704. },
  1705. set: function (dates) {
  1706. self.config._enable = parseDateRules(dates);
  1707. }
  1708. });
  1709. Object.defineProperty(self.config, "disable", {
  1710. get: function () {
  1711. return self.config._disable;
  1712. },
  1713. set: function (dates) {
  1714. self.config._disable = parseDateRules(dates);
  1715. }
  1716. });
  1717. var timeMode = userConfig.mode === "time";
  1718. if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
  1719. var defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults.dateFormat;
  1720. formats.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
  1721. }
  1722. if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) {
  1723. var defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults.altFormat;
  1724. formats.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : defaultAltFormat + (" h:i" + (userConfig.enableSeconds ? ":S" : "") + " K");
  1725. }
  1726. if (!userConfig.altInputClass) {
  1727. self.config.altInputClass = self.input.className + " " + self.config.altInputClass;
  1728. }
  1729. Object.defineProperty(self.config, "minDate", {
  1730. get: function () {
  1731. return self.config._minDate;
  1732. },
  1733. set: minMaxDateSetter("min")
  1734. });
  1735. Object.defineProperty(self.config, "maxDate", {
  1736. get: function () {
  1737. return self.config._maxDate;
  1738. },
  1739. set: minMaxDateSetter("max")
  1740. });
  1741. var minMaxTimeSetter = function (type) {
  1742. return function (val) {
  1743. self.config[type === "min" ? "_minTime" : "_maxTime"] = self.parseDate(val, "H:i:S");
  1744. };
  1745. };
  1746. Object.defineProperty(self.config, "minTime", {
  1747. get: function () {
  1748. return self.config._minTime;
  1749. },
  1750. set: minMaxTimeSetter("min")
  1751. });
  1752. Object.defineProperty(self.config, "maxTime", {
  1753. get: function () {
  1754. return self.config._maxTime;
  1755. },
  1756. set: minMaxTimeSetter("max")
  1757. });
  1758. if (userConfig.mode === "time") {
  1759. self.config.noCalendar = true;
  1760. self.config.enableTime = true;
  1761. }
  1762. Object.assign(self.config, formats, userConfig);
  1763. for (var i = 0; i < boolOpts.length; i++) self.config[boolOpts[i]] = self.config[boolOpts[i]] === true || self.config[boolOpts[i]] === "true";
  1764. HOOKS.filter(function (hook) {
  1765. return self.config[hook] !== undefined;
  1766. }).forEach(function (hook) {
  1767. self.config[hook] = arrayify(self.config[hook] || []).map(bindToInstance);
  1768. });
  1769. self.isMobile = !self.config.disableMobile && !self.config.inline && self.config.mode === "single" && !self.config.disable.length && !self.config.enable.length && !self.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
  1770. for (var i = 0; i < self.config.plugins.length; i++) {
  1771. var pluginConf = self.config.plugins[i](self) || {};
  1772. for (var key in pluginConf) {
  1773. if (HOOKS.indexOf(key) > -1) {
  1774. self.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self.config[key]);
  1775. } else if (typeof userConfig[key] === "undefined") self.config[key] = pluginConf[key];
  1776. }
  1777. }
  1778. triggerEvent("onParseConfig");
  1779. }
  1780. function setupLocale() {
  1781. if (typeof self.config.locale !== "object" && typeof flatpickr.l10ns[self.config.locale] === "undefined") self.config.errorHandler(new Error("flatpickr: invalid locale " + self.config.locale));
  1782. self.l10n = __assign({}, flatpickr.l10ns["default"], typeof self.config.locale === "object" ? self.config.locale : self.config.locale !== "default" ? flatpickr.l10ns[self.config.locale] : undefined);
  1783. tokenRegex.K = "(" + self.l10n.amPM[0] + "|" + self.l10n.amPM[1] + "|" + self.l10n.amPM[0].toLowerCase() + "|" + self.l10n.amPM[1].toLowerCase() + ")";
  1784. var userConfig = __assign({}, instanceConfig, JSON.parse(JSON.stringify(element.dataset || {})));
  1785. if (userConfig.time_24hr === undefined && flatpickr.defaultConfig.time_24hr === undefined) {
  1786. self.config.time_24hr = self.l10n.time_24hr;
  1787. }
  1788. self.formatDate = createDateFormatter(self);
  1789. self.parseDate = createDateParser({
  1790. config: self.config,
  1791. l10n: self.l10n
  1792. });
  1793. }
  1794. function positionCalendar(customPositionElement) {
  1795. if (self.calendarContainer === undefined) return;
  1796. triggerEvent("onPreCalendarPosition");
  1797. var positionElement = customPositionElement || self._positionElement;
  1798. var calendarHeight = Array.prototype.reduce.call(self.calendarContainer.children, function (acc, child) {
  1799. return acc + child.offsetHeight;
  1800. }, 0),
  1801. calendarWidth = self.calendarContainer.offsetWidth,
  1802. configPos = self.config.position.split(" "),
  1803. configPosVertical = configPos[0],
  1804. configPosHorizontal = configPos.length > 1 ? configPos[1] : null,
  1805. inputBounds = positionElement.getBoundingClientRect(),
  1806. distanceFromBottom = window.innerHeight - inputBounds.bottom,
  1807. showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
  1808. var top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
  1809. toggleClass(self.calendarContainer, "arrowTop", !showOnTop);
  1810. toggleClass(self.calendarContainer, "arrowBottom", showOnTop);
  1811. if (self.config.inline) return;
  1812. var left = window.pageXOffset + inputBounds.left - (configPosHorizontal != null && configPosHorizontal === "center" ? (calendarWidth - inputBounds.width) / 2 : 0);
  1813. var right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
  1814. var rightMost = left + calendarWidth > window.document.body.offsetWidth;
  1815. var centerMost = right + calendarWidth > window.document.body.offsetWidth;
  1816. toggleClass(self.calendarContainer, "rightMost", rightMost);
  1817. if (self.config.static) return;
  1818. self.calendarContainer.style.top = top + "px";
  1819. if (!rightMost) {
  1820. self.calendarContainer.style.left = left + "px";
  1821. self.calendarContainer.style.right = "auto";
  1822. } else if (!centerMost) {
  1823. self.calendarContainer.style.left = "auto";
  1824. self.calendarContainer.style.right = right + "px";
  1825. } else {
  1826. var doc = document.styleSheets[0]; // some testing environments don't have css support
  1827. if (doc === undefined) return;
  1828. var bodyWidth = window.document.body.offsetWidth;
  1829. var centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
  1830. var centerBefore = ".flatpickr-calendar.centerMost:before";
  1831. var centerAfter = ".flatpickr-calendar.centerMost:after";
  1832. var centerIndex = doc.cssRules.length;
  1833. var centerStyle = "{left:" + inputBounds.left + "px;right:auto;}";
  1834. toggleClass(self.calendarContainer, "rightMost", false);
  1835. toggleClass(self.calendarContainer, "centerMost", true);
  1836. doc.insertRule(centerBefore + "," + centerAfter + centerStyle, centerIndex);
  1837. self.calendarContainer.style.left = centerLeft + "px";
  1838. self.calendarContainer.style.right = "auto";
  1839. }
  1840. }
  1841. function redraw() {
  1842. if (self.config.noCalendar || self.isMobile) return;
  1843. updateNavigationCurrentMonth();
  1844. buildDays();
  1845. }
  1846. function focusAndClose() {
  1847. self._input.focus();
  1848. if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== undefined) {
  1849. // hack - bugs in the way IE handles focus keeps the calendar open
  1850. setTimeout(self.close, 0);
  1851. } else {
  1852. self.close();
  1853. }
  1854. }
  1855. function selectDate(e) {
  1856. e.preventDefault();
  1857. e.stopPropagation();
  1858. var isSelectable = function (day) {
  1859. return day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("flatpickr-disabled") && !day.classList.contains("notAllowed");
  1860. };
  1861. var t = findParent(e.target, isSelectable);
  1862. if (t === undefined) return;
  1863. var target = t;
  1864. var selectedDate = self.latestSelectedDateObj = new Date(target.dateObj.getTime());
  1865. var shouldChangeMonth = (selectedDate.getMonth() < self.currentMonth || selectedDate.getMonth() > self.currentMonth + self.config.showMonths - 1) && self.config.mode !== "range";
  1866. self.selectedDateElem = target;
  1867. if (self.config.mode === "single") self.selectedDates = [selectedDate];else if (self.config.mode === "multiple") {
  1868. var selectedIndex = isDateSelected(selectedDate);
  1869. if (selectedIndex) self.selectedDates.splice(parseInt(selectedIndex), 1);else self.selectedDates.push(selectedDate);
  1870. } else if (self.config.mode === "range") {
  1871. if (self.selectedDates.length === 2) {
  1872. self.clear(false, false);
  1873. }
  1874. self.latestSelectedDateObj = selectedDate;
  1875. self.selectedDates.push(selectedDate); // unless selecting same date twice, sort ascendingly
  1876. if (compareDates(selectedDate, self.selectedDates[0], true) !== 0) self.selectedDates.sort(function (a, b) {
  1877. return a.getTime() - b.getTime();
  1878. });
  1879. }
  1880. setHoursFromInputs();
  1881. if (shouldChangeMonth) {
  1882. var isNewYear = self.currentYear !== selectedDate.getFullYear();
  1883. self.currentYear = selectedDate.getFullYear();
  1884. self.currentMonth = selectedDate.getMonth();
  1885. if (isNewYear) {
  1886. triggerEvent("onYearChange");
  1887. buildMonthSwitch();
  1888. }
  1889. triggerEvent("onMonthChange");
  1890. }
  1891. updateNavigationCurrentMonth();
  1892. buildDays();
  1893. updateValue();
  1894. if (self.config.enableTime) setTimeout(function () {
  1895. return self.showTimeInput = true;
  1896. }, 50); // maintain focus
  1897. if (!shouldChangeMonth && self.config.mode !== "range" && self.config.showMonths === 1) focusOnDayElem(target);else if (self.selectedDateElem !== undefined && self.hourElement === undefined) {
  1898. self.selectedDateElem && self.selectedDateElem.focus();
  1899. }
  1900. if (self.hourElement !== undefined) self.hourElement !== undefined && self.hourElement.focus();
  1901. if (self.config.closeOnSelect) {
  1902. var single = self.config.mode === "single" && !self.config.enableTime;
  1903. var range = self.config.mode === "range" && self.selectedDates.length === 2 && !self.config.enableTime;
  1904. if (single || range) {
  1905. focusAndClose();
  1906. }
  1907. }
  1908. triggerChange();
  1909. }
  1910. var CALLBACKS = {
  1911. locale: [setupLocale, updateWeekdays],
  1912. showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
  1913. minDate: [jumpToDate],
  1914. maxDate: [jumpToDate]
  1915. };
  1916. function set(option, value) {
  1917. if (option !== null && typeof option === "object") {
  1918. Object.assign(self.config, option);
  1919. for (var key in option) {
  1920. if (CALLBACKS[key] !== undefined) CALLBACKS[key].forEach(function (x) {
  1921. return x();
  1922. });
  1923. }
  1924. } else {
  1925. self.config[option] = value;
  1926. if (CALLBACKS[option] !== undefined) CALLBACKS[option].forEach(function (x) {
  1927. return x();
  1928. });else if (HOOKS.indexOf(option) > -1) self.config[option] = arrayify(value);
  1929. }
  1930. self.redraw();
  1931. updateValue(false);
  1932. }
  1933. function setSelectedDate(inputDate, format) {
  1934. var dates = [];
  1935. if (inputDate instanceof Array) dates = inputDate.map(function (d) {
  1936. return self.parseDate(d, format);
  1937. });else if (inputDate instanceof Date || typeof inputDate === "number") dates = [self.parseDate(inputDate, format)];else if (typeof inputDate === "string") {
  1938. switch (self.config.mode) {
  1939. case "single":
  1940. case "time":
  1941. dates = [self.parseDate(inputDate, format)];
  1942. break;
  1943. case "multiple":
  1944. dates = inputDate.split(self.config.conjunction).map(function (date) {
  1945. return self.parseDate(date, format);
  1946. });
  1947. break;
  1948. case "range":
  1949. dates = inputDate.split(self.l10n.rangeSeparator).map(function (date) {
  1950. return self.parseDate(date, format);
  1951. });
  1952. break;
  1953. default:
  1954. break;
  1955. }
  1956. } else self.config.errorHandler(new Error("Invalid date supplied: " + JSON.stringify(inputDate)));
  1957. self.selectedDates = dates.filter(function (d) {
  1958. return d instanceof Date && isEnabled(d, false);
  1959. });
  1960. if (self.config.mode === "range") self.selectedDates.sort(function (a, b) {
  1961. return a.getTime() - b.getTime();
  1962. });
  1963. }
  1964. function setDate(date, triggerChange, format) {
  1965. if (triggerChange === void 0) {
  1966. triggerChange = false;
  1967. }
  1968. if (format === void 0) {
  1969. format = self.config.dateFormat;
  1970. }
  1971. if (date !== 0 && !date || date instanceof Array && date.length === 0) return self.clear(triggerChange);
  1972. setSelectedDate(date, format);
  1973. self.showTimeInput = self.selectedDates.length > 0;
  1974. self.latestSelectedDateObj = self.selectedDates[self.selectedDates.length - 1];
  1975. self.redraw();
  1976. jumpToDate();
  1977. setHoursFromDate();
  1978. if (self.selectedDates.length === 0) {
  1979. self.clear(false);
  1980. }
  1981. updateValue(triggerChange);
  1982. if (triggerChange) triggerEvent("onChange");
  1983. }
  1984. function parseDateRules(arr) {
  1985. return arr.slice().map(function (rule) {
  1986. if (typeof rule === "string" || typeof rule === "number" || rule instanceof Date) {
  1987. return self.parseDate(rule, undefined, true);
  1988. } else if (rule && typeof rule === "object" && rule.from && rule.to) return {
  1989. from: self.parseDate(rule.from, undefined),
  1990. to: self.parseDate(rule.to, undefined)
  1991. };
  1992. return rule;
  1993. }).filter(function (x) {
  1994. return x;
  1995. }); // remove falsy values
  1996. }
  1997. function setupDates() {
  1998. self.selectedDates = [];
  1999. self.now = self.parseDate(self.config.now) || new Date(); // Workaround IE11 setting placeholder as the input's value
  2000. var preloadedDate = self.config.defaultDate || ((self.input.nodeName === "INPUT" || self.input.nodeName === "TEXTAREA") && self.input.placeholder && self.input.value === self.input.placeholder ? null : self.input.value);
  2001. if (preloadedDate) setSelectedDate(preloadedDate, self.config.dateFormat);
  2002. self._initialDate = self.selectedDates.length > 0 ? self.selectedDates[0] : self.config.minDate && self.config.minDate.getTime() > self.now.getTime() ? self.config.minDate : self.config.maxDate && self.config.maxDate.getTime() < self.now.getTime() ? self.config.maxDate : self.now;
  2003. self.currentYear = self._initialDate.getFullYear();
  2004. self.currentMonth = self._initialDate.getMonth();
  2005. if (self.selectedDates.length > 0) self.latestSelectedDateObj = self.selectedDates[0];
  2006. if (self.config.minTime !== undefined) self.config.minTime = self.parseDate(self.config.minTime, "H:i");
  2007. if (self.config.maxTime !== undefined) self.config.maxTime = self.parseDate(self.config.maxTime, "H:i");
  2008. self.minDateHasTime = !!self.config.minDate && (self.config.minDate.getHours() > 0 || self.config.minDate.getMinutes() > 0 || self.config.minDate.getSeconds() > 0);
  2009. self.maxDateHasTime = !!self.config.maxDate && (self.config.maxDate.getHours() > 0 || self.config.maxDate.getMinutes() > 0 || self.config.maxDate.getSeconds() > 0);
  2010. Object.defineProperty(self, "showTimeInput", {
  2011. get: function () {
  2012. return self._showTimeInput;
  2013. },
  2014. set: function (bool) {
  2015. self._showTimeInput = bool;
  2016. if (self.calendarContainer) toggleClass(self.calendarContainer, "showTimeInput", bool);
  2017. self.isOpen && positionCalendar();
  2018. }
  2019. });
  2020. }
  2021. function setupInputs() {
  2022. self.input = self.config.wrap ? element.querySelector("[data-input]") : element;
  2023. /* istanbul ignore next */
  2024. if (!self.input) {
  2025. self.config.errorHandler(new Error("Invalid input element specified"));
  2026. return;
  2027. } // hack: store previous type to restore it after destroy()
  2028. self.input._type = self.input.type;
  2029. self.input.type = "text";
  2030. self.input.classList.add("flatpickr-input");
  2031. self._input = self.input;
  2032. if (self.config.altInput) {
  2033. // replicate self.element
  2034. self.altInput = createElement(self.input.nodeName, self.config.altInputClass);
  2035. self._input = self.altInput;
  2036. self.altInput.placeholder = self.input.placeholder;
  2037. self.altInput.disabled = self.input.disabled;
  2038. self.altInput.required = self.input.required;
  2039. self.altInput.tabIndex = self.input.tabIndex;
  2040. self.altInput.type = "text";
  2041. self.input.setAttribute("type", "hidden");
  2042. if (!self.config.static && self.input.parentNode) self.input.parentNode.insertBefore(self.altInput, self.input.nextSibling);
  2043. }
  2044. if (!self.config.allowInput) self._input.setAttribute("readonly", "readonly");
  2045. self._positionElement = self.config.positionElement || self._input;
  2046. }
  2047. function setupMobile() {
  2048. var inputType = self.config.enableTime ? self.config.noCalendar ? "time" : "datetime-local" : "date";
  2049. self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
  2050. self.mobileInput.step = self.input.getAttribute("step") || "any";
  2051. self.mobileInput.tabIndex = 1;
  2052. self.mobileInput.type = inputType;
  2053. self.mobileInput.disabled = self.input.disabled;
  2054. self.mobileInput.required = self.input.required;
  2055. self.mobileInput.placeholder = self.input.placeholder;
  2056. self.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S";
  2057. if (self.selectedDates.length > 0) {
  2058. self.mobileInput.defaultValue = self.mobileInput.value = self.formatDate(self.selectedDates[0], self.mobileFormatStr);
  2059. }
  2060. if (self.config.minDate) self.mobileInput.min = self.formatDate(self.config.minDate, "Y-m-d");
  2061. if (self.config.maxDate) self.mobileInput.max = self.formatDate(self.config.maxDate, "Y-m-d");
  2062. self.input.type = "hidden";
  2063. if (self.altInput !== undefined) self.altInput.type = "hidden";
  2064. try {
  2065. if (self.input.parentNode) self.input.parentNode.insertBefore(self.mobileInput, self.input.nextSibling);
  2066. } catch (_a) {}
  2067. bind(self.mobileInput, "change", function (e) {
  2068. self.setDate(e.target.value, false, self.mobileFormatStr);
  2069. triggerEvent("onChange");
  2070. triggerEvent("onClose");
  2071. });
  2072. }
  2073. function toggle(e) {
  2074. if (self.isOpen === true) return self.close();
  2075. self.open(e);
  2076. }
  2077. function triggerEvent(event, data) {
  2078. // If the instance has been destroyed already, all hooks have been removed
  2079. if (self.config === undefined) return;
  2080. var hooks = self.config[event];
  2081. if (hooks !== undefined && hooks.length > 0) {
  2082. for (var i = 0; hooks[i] && i < hooks.length; i++) hooks[i](self.selectedDates, self.input.value, self, data);
  2083. }
  2084. if (event === "onChange") {
  2085. self.input.dispatchEvent(createEvent("change")); // many front-end frameworks bind to the input event
  2086. self.input.dispatchEvent(createEvent("input"));
  2087. }
  2088. }
  2089. function createEvent(name) {
  2090. var e = document.createEvent("Event");
  2091. e.initEvent(name, true, true);
  2092. return e;
  2093. }
  2094. function isDateSelected(date) {
  2095. for (var i = 0; i < self.selectedDates.length; i++) {
  2096. if (compareDates(self.selectedDates[i], date) === 0) return "" + i;
  2097. }
  2098. return false;
  2099. }
  2100. function isDateInRange(date) {
  2101. if (self.config.mode !== "range" || self.selectedDates.length < 2) return false;
  2102. return compareDates(date, self.selectedDates[0]) >= 0 && compareDates(date, self.selectedDates[1]) <= 0;
  2103. }
  2104. function updateNavigationCurrentMonth() {
  2105. if (self.config.noCalendar || self.isMobile || !self.monthNav) return;
  2106. self.yearElements.forEach(function (yearElement, i) {
  2107. var d = new Date(self.currentYear, self.currentMonth, 1);
  2108. d.setMonth(self.currentMonth + i);
  2109. if (self.config.showMonths > 1 || self.config.monthSelectorType === "static") {
  2110. self.monthElements[i].textContent = monthToStr(d.getMonth(), self.config.shorthandCurrentMonth, self.l10n) + " ";
  2111. } else {
  2112. self.monthsDropdownContainer.value = d.getMonth().toString();
  2113. }
  2114. yearElement.value = d.getFullYear().toString();
  2115. });
  2116. self._hidePrevMonthArrow = self.config.minDate !== undefined && (self.currentYear === self.config.minDate.getFullYear() ? self.currentMonth <= self.config.minDate.getMonth() : self.currentYear < self.config.minDate.getFullYear());
  2117. self._hideNextMonthArrow = self.config.maxDate !== undefined && (self.currentYear === self.config.maxDate.getFullYear() ? self.currentMonth + 1 > self.config.maxDate.getMonth() : self.currentYear > self.config.maxDate.getFullYear());
  2118. }
  2119. function getDateStr(format) {
  2120. return self.selectedDates.map(function (dObj) {
  2121. return self.formatDate(dObj, format);
  2122. }).filter(function (d, i, arr) {
  2123. return self.config.mode !== "range" || self.config.enableTime || arr.indexOf(d) === i;
  2124. }).join(self.config.mode !== "range" ? self.config.conjunction : self.l10n.rangeSeparator);
  2125. }
  2126. /**
  2127. * Updates the values of inputs associated with the calendar
  2128. */
  2129. function updateValue(triggerChange) {
  2130. if (triggerChange === void 0) {
  2131. triggerChange = true;
  2132. }
  2133. if (self.mobileInput !== undefined && self.mobileFormatStr) {
  2134. self.mobileInput.value = self.latestSelectedDateObj !== undefined ? self.formatDate(self.latestSelectedDateObj, self.mobileFormatStr) : "";
  2135. }
  2136. self.input.value = getDateStr(self.config.dateFormat);
  2137. if (self.altInput !== undefined) {
  2138. self.altInput.value = getDateStr(self.config.altFormat);
  2139. }
  2140. if (triggerChange !== false) triggerEvent("onValueUpdate");
  2141. }
  2142. function onMonthNavClick(e) {
  2143. var isPrevMonth = self.prevMonthNav.contains(e.target);
  2144. var isNextMonth = self.nextMonthNav.contains(e.target);
  2145. if (isPrevMonth || isNextMonth) {
  2146. changeMonth(isPrevMonth ? -1 : 1);
  2147. } else if (self.yearElements.indexOf(e.target) >= 0) {
  2148. e.target.select();
  2149. } else if (e.target.classList.contains("arrowUp")) {
  2150. self.changeYear(self.currentYear + 1);
  2151. } else if (e.target.classList.contains("arrowDown")) {
  2152. self.changeYear(self.currentYear - 1);
  2153. }
  2154. }
  2155. function timeWrapper(e) {
  2156. e.preventDefault();
  2157. var isKeyDown = e.type === "keydown",
  2158. input = e.target;
  2159. if (self.amPM !== undefined && e.target === self.amPM) {
  2160. self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
  2161. }
  2162. var min = parseFloat(input.getAttribute("min")),
  2163. max = parseFloat(input.getAttribute("max")),
  2164. step = parseFloat(input.getAttribute("step")),
  2165. curValue = parseInt(input.value, 10),
  2166. delta = e.delta || (isKeyDown ? e.which === 38 ? 1 : -1 : 0);
  2167. var newValue = curValue + step * delta;
  2168. if (typeof input.value !== "undefined" && input.value.length === 2) {
  2169. var isHourElem = input === self.hourElement,
  2170. isMinuteElem = input === self.minuteElement;
  2171. if (newValue < min) {
  2172. newValue = max + newValue + int(!isHourElem) + (int(isHourElem) && int(!self.amPM));
  2173. if (isMinuteElem) incrementNumInput(undefined, -1, self.hourElement);
  2174. } else if (newValue > max) {
  2175. newValue = input === self.hourElement ? newValue - max - int(!self.amPM) : min;
  2176. if (isMinuteElem) incrementNumInput(undefined, 1, self.hourElement);
  2177. }
  2178. if (self.amPM && isHourElem && (step === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step)) {
  2179. self.amPM.textContent = self.l10n.amPM[int(self.amPM.textContent === self.l10n.amPM[0])];
  2180. }
  2181. input.value = pad(newValue);
  2182. }
  2183. }
  2184. init();
  2185. return self;
  2186. }
  2187. /* istanbul ignore next */
  2188. function _flatpickr(nodeList, config) {
  2189. // static list
  2190. var nodes = Array.prototype.slice.call(nodeList).filter(function (x) {
  2191. return x instanceof HTMLElement;
  2192. });
  2193. var instances = [];
  2194. for (var i = 0; i < nodes.length; i++) {
  2195. var node = nodes[i];
  2196. try {
  2197. if (node.getAttribute("data-fp-omit") !== null) continue;
  2198. if (node._flatpickr !== undefined) {
  2199. node._flatpickr.destroy();
  2200. node._flatpickr = undefined;
  2201. }
  2202. node._flatpickr = FlatpickrInstance(node, config || {});
  2203. instances.push(node._flatpickr);
  2204. } catch (e) {
  2205. console.error(e);
  2206. }
  2207. }
  2208. return instances.length === 1 ? instances[0] : instances;
  2209. }
  2210. /* istanbul ignore next */
  2211. if (typeof HTMLElement !== "undefined" && typeof HTMLCollection !== "undefined" && typeof NodeList !== "undefined") {
  2212. // browser env
  2213. HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function (config) {
  2214. return _flatpickr(this, config);
  2215. };
  2216. HTMLElement.prototype.flatpickr = function (config) {
  2217. return _flatpickr([this], config);
  2218. };
  2219. }
  2220. /* istanbul ignore next */
  2221. var flatpickr = function (selector, config) {
  2222. if (typeof selector === "string") {
  2223. return _flatpickr(window.document.querySelectorAll(selector), config);
  2224. } else if (selector instanceof Node) {
  2225. return _flatpickr([selector], config);
  2226. } else {
  2227. return _flatpickr(selector, config);
  2228. }
  2229. };
  2230. /* istanbul ignore next */
  2231. flatpickr.defaultConfig = {};
  2232. flatpickr.l10ns = {
  2233. en: __assign({}, english),
  2234. "default": __assign({}, english)
  2235. };
  2236. flatpickr.localize = function (l10n) {
  2237. flatpickr.l10ns["default"] = __assign({}, flatpickr.l10ns["default"], l10n);
  2238. };
  2239. flatpickr.setDefaults = function (config) {
  2240. flatpickr.defaultConfig = __assign({}, flatpickr.defaultConfig, config);
  2241. };
  2242. flatpickr.parseDate = createDateParser({});
  2243. flatpickr.formatDate = createDateFormatter({});
  2244. flatpickr.compareDates = compareDates;
  2245. /* istanbul ignore next */
  2246. if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
  2247. jQuery.fn.flatpickr = function (config) {
  2248. return _flatpickr(this, config);
  2249. };
  2250. } // eslint-disable-next-line @typescript-eslint/camelcase
  2251. Date.prototype.fp_incr = function (days) {
  2252. return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
  2253. };
  2254. if (typeof window !== "undefined") {
  2255. window.flatpickr = flatpickr;
  2256. }
  2257. return flatpickr;
  2258. });
  2259. },{}],"scripts/main.js":[function(require,module,exports) {
  2260. "use strict";
  2261. var _flatpickr = _interopRequireDefault(require("flatpickr"));
  2262. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  2263. var initSwitcher = function initSwitcher(gridMode, listMode, content) {
  2264. var activeClass = 'active';
  2265. var displayList = 'display_list';
  2266. var displayGrid = 'display_grid';
  2267. var toggleSwitch = function toggleSwitch(btn, className) {
  2268. btn.classList.toggle(activeClass);
  2269. content.classList.toggle(className);
  2270. };
  2271. var active = listMode;
  2272. var eventListener = function eventListener(oldBtn, oldClass, newBtn, newClass) {
  2273. return function () {
  2274. if (active !== newBtn) {
  2275. active = newBtn; // remove old state
  2276. toggleSwitch(oldBtn, oldClass); // add new state
  2277. toggleSwitch(newBtn, newClass);
  2278. }
  2279. };
  2280. };
  2281. gridMode.addEventListener('click', eventListener(listMode, displayList, gridMode, displayGrid));
  2282. listMode.addEventListener('click', eventListener(gridMode, displayGrid, listMode, displayList));
  2283. };
  2284. initSwitcher(document.getElementById('mode-switcher-grid'), document.getElementById('mode-switcher-list'), document.getElementById('content'));
  2285. var initDatepicker = function initDatepicker(id) {
  2286. (0, _flatpickr.default)(id, {
  2287. dateFormat: "Y-m-d",
  2288. wrap: true,
  2289. weekNumbers: true
  2290. });
  2291. };
  2292. initDatepicker('#from-date');
  2293. initDatepicker('#to-date');
  2294. },{"flatpickr":"node_modules/flatpickr/dist/flatpickr.js"}],"node_modules/parcel/src/builtins/hmr-runtime.js":[function(require,module,exports) {
  2295. var global = arguments[3];
  2296. var OVERLAY_ID = '__parcel__error__overlay__';
  2297. var OldModule = module.bundle.Module;
  2298. function Module(moduleName) {
  2299. OldModule.call(this, moduleName);
  2300. this.hot = {
  2301. data: module.bundle.hotData,
  2302. _acceptCallbacks: [],
  2303. _disposeCallbacks: [],
  2304. accept: function (fn) {
  2305. this._acceptCallbacks.push(fn || function () {});
  2306. },
  2307. dispose: function (fn) {
  2308. this._disposeCallbacks.push(fn);
  2309. }
  2310. };
  2311. module.bundle.hotData = null;
  2312. }
  2313. module.bundle.Module = Module;
  2314. var checkedAssets, assetsToAccept;
  2315. var parent = module.bundle.parent;
  2316. if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
  2317. var hostname = "" || location.hostname;
  2318. var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
  2319. var ws = new WebSocket(protocol + '://' + hostname + ':' + "53056" + '/');
  2320. ws.onmessage = function (event) {
  2321. checkedAssets = {};
  2322. assetsToAccept = [];
  2323. var data = JSON.parse(event.data);
  2324. if (data.type === 'update') {
  2325. var handled = false;
  2326. data.assets.forEach(function (asset) {
  2327. if (!asset.isNew) {
  2328. var didAccept = hmrAcceptCheck(global.parcelRequire, asset.id);
  2329. if (didAccept) {
  2330. handled = true;
  2331. }
  2332. }
  2333. }); // Enable HMR for CSS by default.
  2334. handled = handled || data.assets.every(function (asset) {
  2335. return asset.type === 'css' && asset.generated.js;
  2336. });
  2337. if (handled) {
  2338. console.clear();
  2339. data.assets.forEach(function (asset) {
  2340. hmrApply(global.parcelRequire, asset);
  2341. });
  2342. assetsToAccept.forEach(function (v) {
  2343. hmrAcceptRun(v[0], v[1]);
  2344. });
  2345. } else if (location.reload) {
  2346. // `location` global exists in a web worker context but lacks `.reload()` function.
  2347. location.reload();
  2348. }
  2349. }
  2350. if (data.type === 'reload') {
  2351. ws.close();
  2352. ws.onclose = function () {
  2353. location.reload();
  2354. };
  2355. }
  2356. if (data.type === 'error-resolved') {
  2357. console.log('[parcel] ✨ Error resolved');
  2358. removeErrorOverlay();
  2359. }
  2360. if (data.type === 'error') {
  2361. console.error('[parcel] 🚨 ' + data.error.message + '\n' + data.error.stack);
  2362. removeErrorOverlay();
  2363. var overlay = createErrorOverlay(data);
  2364. document.body.appendChild(overlay);
  2365. }
  2366. };
  2367. }
  2368. function removeErrorOverlay() {
  2369. var overlay = document.getElementById(OVERLAY_ID);
  2370. if (overlay) {
  2371. overlay.remove();
  2372. }
  2373. }
  2374. function createErrorOverlay(data) {
  2375. var overlay = document.createElement('div');
  2376. overlay.id = OVERLAY_ID; // html encode message and stack trace
  2377. var message = document.createElement('div');
  2378. var stackTrace = document.createElement('pre');
  2379. message.innerText = data.error.message;
  2380. stackTrace.innerText = data.error.stack;
  2381. overlay.innerHTML = '<div style="background: black; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; opacity: 0.85; font-family: Menlo, Consolas, monospace; z-index: 9999;">' + '<span style="background: red; padding: 2px 4px; border-radius: 2px;">ERROR</span>' + '<span style="top: 2px; margin-left: 5px; position: relative;">🚨</span>' + '<div style="font-size: 18px; font-weight: bold; margin-top: 20px;">' + message.innerHTML + '</div>' + '<pre>' + stackTrace.innerHTML + '</pre>' + '</div>';
  2382. return overlay;
  2383. }
  2384. function getParents(bundle, id) {
  2385. var modules = bundle.modules;
  2386. if (!modules) {
  2387. return [];
  2388. }
  2389. var parents = [];
  2390. var k, d, dep;
  2391. for (k in modules) {
  2392. for (d in modules[k][1]) {
  2393. dep = modules[k][1][d];
  2394. if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) {
  2395. parents.push(k);
  2396. }
  2397. }
  2398. }
  2399. if (bundle.parent) {
  2400. parents = parents.concat(getParents(bundle.parent, id));
  2401. }
  2402. return parents;
  2403. }
  2404. function hmrApply(bundle, asset) {
  2405. var modules = bundle.modules;
  2406. if (!modules) {
  2407. return;
  2408. }
  2409. if (modules[asset.id] || !bundle.parent) {
  2410. var fn = new Function('require', 'module', 'exports', asset.generated.js);
  2411. asset.isNew = !modules[asset.id];
  2412. modules[asset.id] = [fn, asset.deps];
  2413. } else if (bundle.parent) {
  2414. hmrApply(bundle.parent, asset);
  2415. }
  2416. }
  2417. function hmrAcceptCheck(bundle, id) {
  2418. var modules = bundle.modules;
  2419. if (!modules) {
  2420. return;
  2421. }
  2422. if (!modules[id] && bundle.parent) {
  2423. return hmrAcceptCheck(bundle.parent, id);
  2424. }
  2425. if (checkedAssets[id]) {
  2426. return;
  2427. }
  2428. checkedAssets[id] = true;
  2429. var cached = bundle.cache[id];
  2430. assetsToAccept.push([bundle, id]);
  2431. if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
  2432. return true;
  2433. }
  2434. return getParents(global.parcelRequire, id).some(function (id) {
  2435. return hmrAcceptCheck(global.parcelRequire, id);
  2436. });
  2437. }
  2438. function hmrAcceptRun(bundle, id) {
  2439. var cached = bundle.cache[id];
  2440. bundle.hotData = {};
  2441. if (cached) {
  2442. cached.hot.data = bundle.hotData;
  2443. }
  2444. if (cached && cached.hot && cached.hot._disposeCallbacks.length) {
  2445. cached.hot._disposeCallbacks.forEach(function (cb) {
  2446. cb(bundle.hotData);
  2447. });
  2448. }
  2449. delete bundle.cache[id];
  2450. bundle(id);
  2451. cached = bundle.cache[id];
  2452. if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
  2453. cached.hot._acceptCallbacks.forEach(function (cb) {
  2454. cb();
  2455. });
  2456. return true;
  2457. }
  2458. }
  2459. },{}]},{},["node_modules/parcel/src/builtins/hmr-runtime.js","scripts/main.js"], null)
  2460. //# sourceMappingURL=/main.d8ebb8d6.js.map