PageSourceSearch

https://femmepetaleflowers.co.za/wp-content/plugins/woocommerce-bookings/dist/frontend.js?ver=2.2.9

js femmepetaleflowers.co.za collected 2026-10-04 21:06:51 UTC 224,638 bytes, 6,039 lines download raw bytes

1/******/ (() => { // webpackBootstrap
2/******/ 	"use strict";
3/******/ 	var __webpack_modules__ = ({
4
5/***/ 2:
6/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
7
8/* harmony export */ __webpack_require__.d(__webpack_exports__, {
9/* harmony export */   f: () => (/* binding */ get_client_server_timezone_offset_hrs),
10/* harmony export */   u: () => (/* binding */ display_error)
11/* harmony export */ });
12/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(428);
13/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
14/* globals: booking_form_params */
15
16
17/**
18 * Returns the hour offset between the client and the server.
19 *
20 * @param {*} referenceDate at which to compute offset.
21 * @return {number} Number of hours between server and client.
22 */
23function get_client_server_timezone_offset_hrs(referenceDate) {
24  if (!booking_form_params.timezone_conversion) {
25    return 0;
26  }
27  let reference_time = moment(referenceDate);
28  const client_offset = reference_time.utcOffset();
29  reference_time.tz(booking_form_params.server_timezone);
30  const server_offset = reference_time.utcOffset();
31  return (client_offset - server_offset) / 60.0;
32}
33function display_error(errorMessage = booking_form_params.i18n_request_failed, after = '#wc-bookings-booking-form') {
34  // Remove 'active' class from old notices.
35  jquery__WEBPACK_IMPORTED_MODULE_0___default()('.woocommerce-error.wc-bookings-notice').removeClass('active');
36
37  // Create a new error notice element.
38  let errorMessageHTML = document.createElement('p');
39  errorMessageHTML.setAttribute('class', 'woocommerce-error wc-bookings-notice active');
40  errorMessageHTML.setAttribute('style', 'display: none;');
41  errorMessageHTML.textContent = errorMessage;
42  jquery__WEBPACK_IMPORTED_MODULE_0___default()(errorMessageHTML).insertAfter(after);
43
44  // Show a new notice and hide old ones.
45  jquery__WEBPACK_IMPORTED_MODULE_0___default()('.woocommerce-error.wc-bookings-notice.active').slideDown({
46    complete: function () {
47      jquery__WEBPACK_IMPORTED_MODULE_0___default()('.woocommerce-error.wc-bookings-notice:not(.active)').slideUp();
48    }
49  });
50}
51
52/***/ }),
53
54/***/ 771:
55/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
56
57/* harmony export */ __webpack_require__.d(__webpack_exports__, {
58/* harmony export */   A: () => (/* binding */ HookApi)
59/* harmony export */ });
60/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(619);
61/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__);
62
63
64/**
65 * Global variable for booking. This uses to expose public methods.
66 *
67 * @use window.wc_bookings.hooks
68 *
69 * @since 1.15.79
70 */
71const HookApi = () => {
72  return window.wc_bookings.hooks;
73};
74
75/***/ }),
76
77/***/ 428:
78/***/ ((module) => {
79
80module.exports = window["jQuery"];
81
82/***/ }),
83
84/***/ 619:
85/***/ ((module) => {
86
87module.exports = window["wp"]["hooks"];
88
89/***/ })
90
91/******/ 	});
92/************************************************************************/
93/******/ 	// The module cache
94/******/ 	var __webpack_module_cache__ = {};
95/******/ 	
96/******/ 	// The require function
97/******/ 	function __webpack_require__(moduleId) {
98/******/ 		// Check if module is in cache
99/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
100/******/ 		if (cachedModule !== undefined) {
101/******/ 			return cachedModule.exports;
102/******/ 		}
103/******/ 		// Create a new module (and put it into the cache)
104/******/ 		var module = __webpack_module_cache__[moduleId] = {
105/******/ 			// no module.id needed
106/******/ 			// no module.loaded needed
107/******/ 			exports: {}
108/******/ 		};
109/******/ 	
110/******/ 		// Execute the module function
111/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
112/******/ 	
113/******/ 		// Return the exports of the module
114/******/ 		return module.exports;
115/******/ 	}
116/******/ 	
117/************************************************************************/
118/******/ 	/* webpack/runtime/compat get default export */
119/******/ 	(() => {
120/******/ 		// getDefaultExport function for compatibility with non-harmony modules
121/******/ 		__webpack_require__.n = (module) => {
122/******/ 			var getter = module && module.__esModule ?
123/******/ 				() => (module['default']) :
124/******/ 				() => (module);
125/******/ 			__webpack_require__.d(getter, { a: getter });
126/******/ 			return getter;
127/******/ 		};
128/******/ 	})();
129/******/ 	
130/******/ 	/* webpack/runtime/define property getters */
131/******/ 	(() => {
132/******/ 		// define getter functions for harmony exports
133/******/ 		__webpack_require__.d = (exports, definition) => {
134/******/ 			for(var key in definition) {
135/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
136/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
137/******/ 				}
138/******/ 			}
139/******/ 		};
140/******/ 	})();
141/******/ 	
142/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
143/******/ 	(() => {
144/******/ 		__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
145/******/ 	})();
146/******/ 	
147/************************************************************************/
148var __webpack_exports__ = {};
149// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
150(() => {
151/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(619);
152/* harmony import */ var _wordpress_hooks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__);
153// Global variable for booking. This uses to expose public methods.
154
155
156// This global param use to expose public methods.
157window.wc_bookings = window.wc_bookings || {};
158window.wc_bookings.hooks = (0,_wordpress_hooks__WEBPACK_IMPORTED_MODULE_0__.createHooks)();
159})();
160
161// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
162(() => {
163/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(428);
164/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
165/* global wc_bookings_booking_form */
166
167
168/*
169 * This script registers functions to wc_bookings_booking_form global object.
170 * These functions return product setting value for specific booking form.
171 *
172 * @since 1.15.73
173 */
174jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).ready(function ($) {
175  /**
176   * Should return whether multiple booking forms exist on webpage.
177   *
178   * @since 1.15.73
179   *
180   * @param {object} element
181   * @return {boolean}
182   */
183  wc_bookings_booking_form.is_multiple_booking_forms_exist = () => {
184    return !!$('.wc-bookings-booking-form').closest('form').length;
185  };
186
187  /**
188   * Should return booking form product id.
189   *
190   * @since 1.15.73
191   *
192   * @param {object} element
193   * @return {string}
194   */
195  wc_bookings_booking_form.get_booking_product_id = element => {
196    let form = element.closest('form');
197    form = element instanceof (jquery__WEBPACK_IMPORTED_MODULE_0___default()) ? form.get(0) : form;
198    return parseInt(form.querySelector('.wc-booking-product-id').value);
199  };
200
201  /**
202   * Should return booking duration.
203   *
204   * @since 1.15.73
205   *
206   * @param {object} element
207   * @return {string}
208   */
209  wc_bookings_booking_form.get_booking_duration = element => {
210    let product_id = null;
211    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
212      return window.wc_bookings_booking_form.booking_duration;
213    }
214    product_id = wc_bookings_booking_form.get_booking_product_id(element);
215    return window[`wc_bookings_booking_form_${product_id}`]['booking_duration'];
216  };
217
218  /**
219   * Should return booking duration type.
220   *
221   * @since 1.15.73
222   *
223   * @param {object} element
224   * @return {string}
225   */
226  wc_bookings_booking_form.get_booking_duration_type = element => {
227    let product_id = null;
228    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
229      return window.wc_bookings_booking_form.booking_duration_type;
230    }
231    product_id = wc_bookings_booking_form.get_booking_product_id(element);
232    return window[`wc_bookings_booking_form_${product_id}`]['duration_type'];
233  };
234
235  /**
236   * Should return booking max duration.
237   *
238   * @since 1.15.73
239   *
240   * @param {object} element
241   * @return {string}
242   */
243  wc_bookings_booking_form.get_booking_max_duration = element => {
244    let product_id = null;
245    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
246      return window.wc_bookings_booking_form.booking_max_duration;
247    }
248    product_id = wc_bookings_booking_form.get_booking_product_id(element);
249    return window[`wc_bookings_booking_form_${product_id}`]['booking_max_duration'];
250  };
251
252  /**
253   * Should return booking max duration.
254   *
255   * @since 1.15.73
256   *
257   * @param {object} element
258   * @return {string}
259   */
260  wc_bookings_booking_form.get_booking_min_duration = element => {
261    let product_id = null;
262    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
263      return window.wc_bookings_booking_form.booking_min_duration;
264    }
265    product_id = wc_bookings_booking_form.get_booking_product_id(element);
266    return window[`wc_bookings_booking_form_${product_id}`]['booking_min_duration'];
267  };
268
269  /**
270   * Should return booking check availability against.
271   *
272   * @since 1.15.73
273   *
274   * @param {object} element
275   * @return {string}
276   */
277  wc_bookings_booking_form.get_booking_check_availability_against = element => {
278    let product_id = null;
279    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
280      return window.wc_bookings_booking_form.check_availability_against;
281    }
282    product_id = wc_bookings_booking_form.get_booking_product_id(element);
283    return window[`wc_bookings_booking_form_${product_id}`]['check_availability_against'];
284  };
285
286  /**
287   * Should return booking default availability.
288   *
289   * @since 1.15.73
290   *
291   * @param {object} element
292   * @return {string}
293   */
294  wc_bookings_booking_form.get_booking_default_availability = element => {
295    let product_id = null;
296    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
297      return window.wc_bookings_booking_form.default_availability;
298    }
299    product_id = wc_bookings_booking_form.get_booking_product_id(element);
300    return window[`wc_bookings_booking_form_${product_id}`]['default_availability'];
301  };
302
303  /**
304   * Should return booking duration unit.
305   *
306   * @since 1.15.73
307   *
308   * @param {object} element
309   * @return {string}
310   */
311  wc_bookings_booking_form.get_booking_duration_unit = element => {
312    let product_id = null;
313    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
314      return window.wc_bookings_booking_form.duration_unit;
315    }
316    product_id = wc_bookings_booking_form.get_booking_product_id(element);
317    return window[`wc_bookings_booking_form_${product_id}`]['duration_unit'];
318  };
319
320  /**
321   * Should return booking resources assignment.
322   *
323   * @since 1.15.73
324   *
325   * @param {object} element
326   * @return {string}
327   */
328  wc_bookings_booking_form.get_booking_resources_assignment = element => {
329    let product_id = null;
330    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
331      return window.wc_bookings_booking_form.resources_assignment;
332    }
333    product_id = wc_bookings_booking_form.get_booking_product_id(element);
334    return window[`wc_bookings_booking_form_${product_id}`]['resources_assignment'];
335  };
336
337  /**
338   * Should return booking resources IDs.
339   *
340   * @since 1.16.02
341   *
342   * @param {object} element
343   * @return {array} The resource IDs.
344   */
345  wc_bookings_booking_form.get_booking_resource_ids = element => {
346    let product_id = null;
347    if (!wc_bookings_booking_form.is_multiple_booking_forms_exist()) {
348      return window.wc_bookings_booking_form.resource_ids;
349    }
350    product_id = wc_bookings_booking_form.get_booking_product_id(element);
351    return window[`wc_bookings_booking_form_${product_id}`]['resource_ids'];
352  };
353
354  /**
355   * should return sanitized text
356   *
357   * @since 1.15.73
358   *
359   * @param {string} text
360   *
361   * @return {string}
362   */
363  wc_bookings_booking_form.sanitize_text = text => {
364    const element = document.createElement('div');
365    element.innerText = text;
366    return element.innerHTML;
367  };
368});
369})();
370
371// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
372(() => {
373/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(428);
374/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
375/* harmony import */ var _bookings_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
376/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(771);
377/**
378 * External dependencies
379 */
380
381
382/**
383 * Internal dependencies
384 */
385
386
387jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).ready(function ($) {
388  if (!window.console) {
389    window.console = {
390      log: function () {}
391    };
392  }
393  let xhr = [];
394  wc_bookings_booking_form.wc_booking_form = $('.wc-bookings-booking-form').closest('form');
395  $('.wc-bookings-booking-form').on('change', 'input, select:not("#wc-bookings-form-start-time, #wc-bookings-form-end-time")', function (e) {
396    var name = $(this).attr('name');
397    const booking_duration_type = wc_bookings_booking_form.get_booking_duration_type($(this));
398    const booking_duration_unit = wc_bookings_booking_form.get_booking_duration_unit($(this));
399    const $form = $(this).closest('form');
400
401    /**
402     * Fire action when form internal changes.
403     *
404     * @since 1.15.79
405     * @param {HTMLElement} field Changed field.
406     */
407    (0,_utils__WEBPACK_IMPORTED_MODULE_2__/* .HookApi */ .A)().doAction('wc_bookings_form_field_change', {
408      field: $(this).get(0)
409    });
410
411    // If it's the resource dropdown, we refresh the datepicker so that the
412    // calendar availability reflects the potential differences, where it
413    // may differ for different resources.
414    if ('wc_bookings_field_resource' === name) {
415      // Clear selection as availability in another resource might not apply.
416      wc_bookings_booking_form.wc_bookings_date_picker.clear_selection();
417      // Re-init the picker.
418      wc_bookings_booking_form.wc_bookings_date_picker.init();
419      return;
420    }
421
422    // Don't do anything on date change for hour and minute durations.
423    if ('wc_bookings_field_start_date_day' === name && ['hour', 'minute'].includes(booking_duration_unit)) {
424      return;
425    }
426
427    // If start time is not set, don't do anything.
428    if ('customer' === booking_duration_type && '0' === $form.find('#wc-bookings-form-start-time').val()) {
429      return;
430    }
431
432    // If end time is not set, don't do anything.
433    if ('customer' === booking_duration_type && '0' === $form.find('#wc-bookings-form-end-time').val()) {
434      return;
435    }
436    let $fieldset = $form.find('fieldset');
437    let $picker = $fieldset.find('.picker:eq(0)');
438    if ($picker.data('is_range_picker_enabled')) {
439      if ('wc_bookings_field_duration' !== name && -1 === name.indexOf('wc_bookings_field_persons')) {
440        return;
441      }
442    }
443    let index = $form.index(this);
444    let isEmptyCalendarSelection = !$form.find("[name='wc_bookings_field_start_date_day']").val() && !$form.find('#wc_bookings_field_start_date').val();
445
446    // Do not update if triggered by Product Addons and no date is selected.
447    if (jquery__WEBPACK_IMPORTED_MODULE_0___default()(e.target).hasClass('addon') && isEmptyCalendarSelection) {
448      return;
449    }
450    let required_fields = $form.find('input.required_for_calculation');
451    let filled = true;
452    $.each(required_fields, function (index, field) {
453      let value = $(field).val();
454      if (!value) {
455        filled = false;
456      }
457    });
458    if (!filled) {
459      $form.find('.wc-bookings-booking-cost').hide();
460      return;
461    }
462
463    /**
464     * Fire action before calculate booking cost.
465     *
466     * @since 1.15.79
467     */
468    (0,_utils__WEBPACK_IMPORTED_MODULE_2__/* .HookApi */ .A)().doAction('wc_bookings_pre_calculte_booking_cost', {
469      'field': $(this).get(0),
470      'fieldset': $fieldset.get(0),
471      'date_picker': $picker.get(0),
472      'form': $form.get(0)
473    });
474    $form.find('.wc-bookings-booking-cost').block({
475      message: null,
476      overlayCSS: {
477        background: '#fff',
478        backgroundSize: '16px 16px',
479        opacity: 0.6
480      }
481    }).show();
482    xhr[index] = $.ajax({
483      type: 'POST',
484      url: booking_form_params.ajax_url,
485      data: {
486        action: 'wc_bookings_calculate_costs',
487        form: $form.serialize()
488      },
489      success: function (code) {
490        if (code.charAt(0) !== '{') {
491          // eslint-disable-next-line
492          console.log(code);
493          code = '{' + code.split(/\{(.+)?/)[1];
494        }
495        let result = JSON.parse(code);
496        if (result.result === 'ERROR') {
497          $form.find('.wc-bookings-booking-cost').html(result.html);
498          $form.find('.wc-bookings-booking-cost').unblock();
499          $form.find('.wc-bookings-booking-cost').show();
500          $form.find('.single_add_to_cart_button').addClass('disabled');
501        } else if (result.result === 'SUCCESS') {
502          $form.find('.wc-bookings-booking-cost').html(result.html);
503          $form.find('.wc-bookings-booking-cost').unblock();
504          $form.find('.single_add_to_cart_button').removeClass('disabled');
505          if (booking_form_params.pao_active && 'true' !== booking_form_params.pao_pre_30 && typeof result.raw_price !== 'undefined') {
506            $form.find('.wc-bookings-booking-cost').attr('data-raw-price', result.raw_price);
507            $('form.cart').trigger('woocommerce-product-addons-update');
508          }
509        } else {
510          $form.find('.wc-bookings-booking-cost').hide();
511          $form.find('.single_add_to_cart_button').addClass('disabled');
512          // eslint-disable-next-line
513          console.log(code);
514        }
515        $(document.body).trigger('wc_booking_form_changed', [$form]);
516
517        // Hide error notices.
518        $('.woocommerce-error.wc-bookings-notice').slideUp();
519      },
520      error: function (jqXHR, exception) {
521        if ('abort' === exception) {
522          return; // Assuming the date is changed very quickly.
523        }
524        (0,_bookings_lib__WEBPACK_IMPORTED_MODULE_1__/* .display_error */ .u)();
525        $form.find('.wc-bookings-booking-cost').hide();
526        $form.find('.single_add_to_cart_button').addClass('disabled');
527        if (booking_form_params.pao_active && 'true' !== booking_form_params.pao_pre_30) {
528          $('form.cart').trigger('woocommerce-product-addons-update');
529        }
530      },
531      dataType: "html"
532    });
533  }).each(function () {
534    let button = $(this).closest('form').find('.single_add_to_cart_button');
535    button.addClass('disabled');
536  });
537  $('.single_add_to_cart_button').on('click', function (event) {
538    if ($(this).hasClass('disabled')) {
539      // eslint-disable-next-line
540      alert(booking_form_params.i18n_choose_options);
541      event.preventDefault();
542      return false;
543    }
544  });
545
546  // Prevent custom booking creation if required slots are not selected.
547  // Checking if price is visible, if not, slots are not selected.
548  $('.add_custom_booking').on('click', function (event) {
549    if (!$('.wc-bookings-booking-cost').is(':visible') || $('.wc-bookings-booking-cost .booking-error').is(':visible')) {
550      // eslint-disable-next-line
551      alert(booking_form_params.i18n_choose_options);
552      event.preventDefault();
553      return false;
554    }
555  });
556  if ('true' === booking_form_params.pao_pre_30) {
557    $('.wc-bookings-booking-form').parent().on('updated_addons', function () {
558      $('.wc-bookings-booking-form').find('input').first().trigger('change');
559    });
560  }
561  $('.wc-bookings-booking-form, .wc-bookings-booking-form-button').show().prop('disabled', false);
562});
563})();
564
565// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
566(() => {
567
568// EXTERNAL MODULE: external "jQuery"
569var external_jQuery_ = __webpack_require__(428);
570var external_jQuery_default = /*#__PURE__*/__webpack_require__.n(external_jQuery_);
571;// CONCATENATED MODULE: external "_"
572const external_namespaceObject = window["_"];
573var external_default = /*#__PURE__*/__webpack_require__.n(external_namespaceObject);
574// EXTERNAL MODULE: ./src/js/bookings-lib.js
575var bookings_lib = __webpack_require__(2);
576;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/weekday.js
577// =============================================================================
578// Weekday
579// =============================================================================
580var ALL_WEEKDAYS = [
581    'MO',
582    'TU',
583    'WE',
584    'TH',
585    'FR',
586    'SA',
587    'SU',
588];
589var Weekday = /** @class */ (function () {
590    function Weekday(weekday, n) {
591        if (n === 0)
592            throw new Error("Can't create weekday with n == 0");
593        this.weekday = weekday;
594        this.n = n;
595    }
596    Weekday.fromStr = function (str) {
597        return new Weekday(ALL_WEEKDAYS.indexOf(str));
598    };
599    // __call__ - Cannot call the object directly, do it through
600    // e.g. RRule.TH.nth(-1) instead,
601    Weekday.prototype.nth = function (n) {
vendor: 15,523 bytes, lines 602-1058
602        return this.n === n ? this : new Weekday(this.weekday, n);
603    };
604    // __eq__
605    Weekday.prototype.equals = function (other) {
606        return this.weekday === other.weekday && this.n === other.n;
607    };
608    // __repr__
609    Weekday.prototype.toString = function () {
610        var s = ALL_WEEKDAYS[this.weekday];
611        if (this.n)
612            s = (this.n > 0 ? '+' : '') + String(this.n) + s;
613        return s;
614    };
615    Weekday.prototype.getJsWeekday = function () {
616        return this.weekday === 6 ? 0 : this.weekday + 1;
617    };
618    return Weekday;
619}());
620
621//# sourceMappingURL=weekday.js.map
622;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/helpers.js
623// =============================================================================
624// Helper functions
625// =============================================================================
626
627var isPresent = function (value) {
628    return value !== null && value !== undefined;
629};
630var isNumber = function (value) {
631    return typeof value === 'number';
632};
633var isWeekdayStr = function (value) {
634    return typeof value === 'string' && ALL_WEEKDAYS.includes(value);
635};
636var isArray = Array.isArray;
637/**
638 * Simplified version of python's range()
639 */
640var range = function (start, end) {
641    if (end === void 0) { end = start; }
642    if (arguments.length === 1) {
643        end = start;
644        start = 0;
645    }
646    var rang = [];
647    for (var i = start; i < end; i++)
648        rang.push(i);
649    return rang;
650};
651var clone = function (array) {
652    return [].concat(array);
653};
654var repeat = function (value, times) {
655    var i = 0;
656    var array = [];
657    if (isArray(value)) {
658        for (; i < times; i++)
659            array[i] = [].concat(value);
660    }
661    else {
662        for (; i < times; i++)
663            array[i] = value;
664    }
665    return array;
666};
667var toArray = function (item) {
668    if (isArray(item)) {
669        return item;
670    }
671    return [item];
672};
673function padStart(item, targetLength, padString) {
674    if (padString === void 0) { padString = ' '; }
675    var str = String(item);
676    targetLength = targetLength >> 0;
677    if (str.length > targetLength) {
678        return String(str);
679    }
680    targetLength = targetLength - str.length;
681    if (targetLength > padString.length) {
682        padString += repeat(padString, targetLength / padString.length);
683    }
684    return padString.slice(0, targetLength) + String(str);
685}
686/**
687 * Python like split
688 */
689var split = function (str, sep, num) {
690    var splits = str.split(sep);
691    return num
692        ? splits.slice(0, num).concat([splits.slice(num).join(sep)])
693        : splits;
694};
695/**
696 * closure/goog/math/math.js:modulo
697 * Copyright 2006 The Closure Library Authors.
698 * The % operator in JavaScript returns the remainder of a / b, but differs from
699 * some other languages in that the result will have the same sign as the
700 * dividend. For example, -1 % 8 == -1, whereas in some other languages
701 * (such as Python) the result would be 7. This function emulates the more
702 * correct modulo behavior, which is useful for certain applications such as
703 * calculating an offset index in a circular list.
704 *
705 * @param {number} a The dividend.
706 * @param {number} b The divisor.
707 * @return {number} a % b where the result is between 0 and b (either 0 <= x < b
708 * or b < x <= 0, depending on the sign of b).
709 */
710var pymod = function (a, b) {
711    var r = a % b;
712    // If r and b differ in sign, add b to wrap the result to the correct sign.
713    return r * b < 0 ? r + b : r;
714};
715/**
716 * @see: <http://docs.python.org/library/functions.html#divmod>
717 */
718var divmod = function (a, b) {
719    return { div: Math.floor(a / b), mod: pymod(a, b) };
720};
721var empty = function (obj) {
722    return !isPresent(obj) || obj.length === 0;
723};
724/**
725 * Python-like boolean
726 *
727 * @return {Boolean} value of an object/primitive, taking into account
728 * the fact that in Python an empty list's/tuple's
729 * boolean value is False, whereas in JS it's true
730 */
731var notEmpty = function (obj) {
732    return !empty(obj);
733};
734/**
735 * Return true if a value is in an array
736 */
737var includes = function (arr, val) {
738    return notEmpty(arr) && arr.indexOf(val) !== -1;
739};
740//# sourceMappingURL=helpers.js.map
741;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/dateutil.js
742
743var datetime = function (y, m, d, h, i, s) {
744    if (h === void 0) { h = 0; }
745    if (i === void 0) { i = 0; }
746    if (s === void 0) { s = 0; }
747    return new Date(Date.UTC(y, m - 1, d, h, i, s));
748};
749/**
750 * General date-related utilities.
751 * Also handles several incompatibilities between JavaScript and Python
752 *
753 */
754var MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
755/**
756 * Number of milliseconds of one day
757 */
758var ONE_DAY = 1000 * 60 * 60 * 24;
759/**
760 * @see: <http://docs.python.org/library/datetime.html#datetime.MAXYEAR>
761 */
762var MAXYEAR = 9999;
763/**
764 * Python uses 1-Jan-1 as the base for calculating ordinals but we don't
765 * want to confuse the JS engine with milliseconds > Number.MAX_NUMBER,
766 * therefore we use 1-Jan-1970 instead
767 */
768var ORDINAL_BASE = datetime(1970, 1, 1);
769/**
770 * Python: MO-SU: 0 - 6
771 * JS: SU-SAT 0 - 6
772 */
773var PY_WEEKDAYS = [6, 0, 1, 2, 3, 4, 5];
774/**
775 * py_date.timetuple()[7]
776 */
777var getYearDay = function (date) {
778    var dateNoTime = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
779    return (Math.ceil((dateNoTime.valueOf() - new Date(date.getUTCFullYear(), 0, 1).valueOf()) /
780        ONE_DAY) + 1);
781};
782var isLeapYear = function (year) {
783    return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
784};
785var isDate = function (value) {
786    return value instanceof Date;
787};
788var isValidDate = function (value) {
789    return isDate(value) && !isNaN(value.getTime());
790};
791/**
792 * @return {Number} the date's timezone offset in ms
793 */
794var tzOffset = function (date) {
795    return date.getTimezoneOffset() * 60 * 1000;
796};
797/**
798 * @see: <http://www.mcfedries.com/JavaScript/DaysBetween.asp>
799 */
800var daysBetween = function (date1, date2) {
801    // The number of milliseconds in one day
802    // Convert both dates to milliseconds
803    var date1ms = date1.getTime();
804    var date2ms = date2.getTime();
805    // Calculate the difference in milliseconds
806    var differencems = date1ms - date2ms;
807    // Convert back to days and return
808    return Math.round(differencems / ONE_DAY);
809};
810/**
811 * @see: <http://docs.python.org/library/datetime.html#datetime.date.toordinal>
812 */
813var toOrdinal = function (date) {
814    return daysBetween(date, ORDINAL_BASE);
815};
816/**
817 * @see - <http://docs.python.org/library/datetime.html#datetime.date.fromordinal>
818 */
819var fromOrdinal = function (ordinal) {
820    return new Date(ORDINAL_BASE.getTime() + ordinal * ONE_DAY);
821};
822var getMonthDays = function (date) {
823    var month = date.getUTCMonth();
824    return month === 1 && isLeapYear(date.getUTCFullYear())
825        ? 29
826        : MONTH_DAYS[month];
827};
828/**
829 * @return {Number} python-like weekday
830 */
831var getWeekday = function (date) {
832    return PY_WEEKDAYS[date.getUTCDay()];
833};
834/**
835 * @see: <http://docs.python.org/library/calendar.html#calendar.monthrange>
836 */
837var monthRange = function (year, month) {
838    var date = datetime(year, month + 1, 1);
839    return [getWeekday(date), getMonthDays(date)];
840};
841/**
842 * @see: <http://docs.python.org/library/datetime.html#datetime.datetime.combine>
843 */
844var combine = function (date, time) {
845    time = time || date;
846    return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds()));
847};
848var dateutil_clone = function (date) {
849    var dolly = new Date(date.getTime());
850    return dolly;
851};
852var cloneDates = function (dates) {
853    var clones = [];
854    for (var i = 0; i < dates.length; i++) {
855        clones.push(dateutil_clone(dates[i]));
856    }
857    return clones;
858};
859/**
860 * Sorts an array of Date or Time objects
861 */
862var sort = function (dates) {
863    dates.sort(function (a, b) {
864        return a.getTime() - b.getTime();
865    });
866};
867var timeToUntilString = function (time, utc) {
868    if (utc === void 0) { utc = true; }
869    var date = new Date(time);
870    return [
871        padStart(date.getUTCFullYear().toString(), 4, '0'),
872        padStart(date.getUTCMonth() + 1, 2, '0'),
873        padStart(date.getUTCDate(), 2, '0'),
874        'T',
875        padStart(date.getUTCHours(), 2, '0'),
876        padStart(date.getUTCMinutes(), 2, '0'),
877        padStart(date.getUTCSeconds(), 2, '0'),
878        utc ? 'Z' : '',
879    ].join('');
880};
881var untilStringToDate = function (until) {
882    var re = /^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/;
883    var bits = re.exec(until);
884    if (!bits)
885        throw new Error("Invalid UNTIL value: ".concat(until));
886    return new Date(Date.UTC(parseInt(bits[1], 10), parseInt(bits[2], 10) - 1, parseInt(bits[3], 10), parseInt(bits[5], 10) || 0, parseInt(bits[6], 10) || 0, parseInt(bits[7], 10) || 0));
887};
888var dateTZtoISO8601 = function (date, timeZone) {
889    // date format for sv-SE is almost ISO8601
890    var dateStr = date.toLocaleString('sv-SE', { timeZone: timeZone });
891    // '2023-02-07 10:41:36'
892    return dateStr.replace(' ', 'T') + 'Z';
893};
894var dateInTimeZone = function (date, timeZone) {
895    var localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
896    // Date constructor can only reliably parse dates in ISO8601 format
897    var dateInLocalTZ = new Date(dateTZtoISO8601(date, localTimeZone));
898    var dateInTargetTZ = new Date(dateTZtoISO8601(date, timeZone !== null && timeZone !== void 0 ? timeZone : 'UTC'));
899    var tzOffset = dateInTargetTZ.getTime() - dateInLocalTZ.getTime();
900    return new Date(date.getTime() - tzOffset);
901};
902//# sourceMappingURL=dateutil.js.map
903;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iterresult.js
904/**
905 * This class helps us to emulate python's generators, sorta.
906 */
907var IterResult = /** @class */ (function () {
908    function IterResult(method, args) {
909        this.minDate = null;
910        this.maxDate = null;
911        this._result = [];
912        this.total = 0;
913        this.method = method;
914        this.args = args;
915        if (method === 'between') {
916            this.maxDate = args.inc
917                ? args.before
918                : new Date(args.before.getTime() - 1);
919            this.minDate = args.inc ? args.after : new Date(args.after.getTime() + 1);
920        }
921        else if (method === 'before') {
922            this.maxDate = args.inc ? args.dt : new Date(args.dt.getTime() - 1);
923        }
924        else if (method === 'after') {
925            this.minDate = args.inc ? args.dt : new Date(args.dt.getTime() + 1);
926        }
927    }
928    /**
929     * Possibly adds a date into the result.
930     *
931     * @param {Date} date - the date isn't necessarly added to the result
932     * list (if it is too late/too early)
933     * @return {Boolean} true if it makes sense to continue the iteration
934     * false if we're done.
935     */
936    IterResult.prototype.accept = function (date) {
937        ++this.total;
938        var tooEarly = this.minDate && date < this.minDate;
939        var tooLate = this.maxDate && date > this.maxDate;
940        if (this.method === 'between') {
941            if (tooEarly)
942                return true;
943            if (tooLate)
944                return false;
945        }
946        else if (this.method === 'before') {
947            if (tooLate)
948                return false;
949        }
950        else if (this.method === 'after') {
951            if (tooEarly)
952                return true;
953            this.add(date);
954            return false;
955        }
956        return this.add(date);
957    };
958    /**
959     *
960     * @param {Date} date that is part of the result.
961     * @return {Boolean} whether we are interested in more values.
962     */
963    IterResult.prototype.add = function (date) {
964        this._result.push(date);
965        return true;
966    };
967    /**
968     * 'before' and 'after' return only one date, whereas 'all'
969     * and 'between' an array.
970     *
971     * @return {Date,Array?}
972     */
973    IterResult.prototype.getValue = function () {
974        var res = this._result;
975        switch (this.method) {
976            case 'all':
977            case 'between':
978                return res;
979            case 'before':
980            case 'after':
981            default:
982                return (res.length ? res[res.length - 1] : null);
983        }
984    };
985    IterResult.prototype.clone = function () {
986        return new IterResult(this.method, this.args);
987    };
988    return IterResult;
989}());
990/* harmony default export */ const iterresult = (IterResult);
991//# sourceMappingURL=iterresult.js.map
992;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
993/******************************************************************************
994Copyright (c) Microsoft Corporation.
995
996Permission to use, copy, modify, and/or distribute this software for any
997purpose with or without fee is hereby granted.
998
999THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1000REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1001AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1002INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1003LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1004OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1005PERFORMANCE OF THIS SOFTWARE.
1006***************************************************************************** */
1007/* global Reflect, Promise, SuppressedError, Symbol */
1008
1009var extendStatics = function(d, b) {
1010  extendStatics = Object.setPrototypeOf ||
1011      ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
1012      function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
1013  return extendStatics(d, b);
1014};
1015
1016function __extends(d, b) {
1017  if (typeof b !== "function" && b !== null)
1018      throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
1019  extendStatics(d, b);
1020  function __() { this.constructor = d; }
1021  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
1022}
1023
1024var __assign = function() {
1025  __assign = Object.assign || function __assign(t) {
1026      for (var s, i = 1, n = arguments.length; i < n; i++) {
1027          s = arguments[i];
1028          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1029      }
1030      return t;
1031  }
1032  return __assign.apply(this, arguments);
1033}
1034
1035function __rest(s, e) {
1036  var t = {};
1037  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
1038      t[p] = s[p];
1039  if (s != null && typeof Object.getOwnPropertySymbols === "function")
1040      for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
1041          if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
1042              t[p[i]] = s[p[i]];
1043      }
1044  return t;
1045}
1046
1047function __decorate(decorators, target, key, desc) {
1048  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1049  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1050  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1051  return c > 3 && r && Object.defineProperty(target, key, r), r;
1052}
1053
1054function __param(paramIndex, decorator) {
1055  return function (target, key) { decorator(target, key, paramIndex); }
1056}
1057
1058function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializer
vendor: 9,101 bytes, lines 1058-1246
1058s, extraInitializers) {
1059  function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
1060  var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
1061  var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
1062  var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
1063  var _, done = false;
1064  for (var i = decorators.length - 1; i >= 0; i--) {
1065      var context = {};
1066      for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
1067      for (var p in contextIn.access) context.access[p] = contextIn.access[p];
1068      context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
1069      var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
1070      if (kind === "accessor") {
1071          if (result === void 0) continue;
1072          if (result === null || typeof result !== "object") throw new TypeError("Object expected");
1073          if (_ = accept(result.get)) descriptor.get = _;
1074          if (_ = accept(result.set)) descriptor.set = _;
1075          if (_ = accept(result.init)) initializers.unshift(_);
1076      }
1077      else if (_ = accept(result)) {
1078          if (kind === "field") initializers.unshift(_);
1079          else descriptor[key] = _;
1080      }
1081  }
1082  if (target) Object.defineProperty(target, contextIn.name, descriptor);
1083  done = true;
1084};
1085
1086function __runInitializers(thisArg, initializers, value) {
1087  var useValue = arguments.length > 2;
1088  for (var i = 0; i < initializers.length; i++) {
1089      value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
1090  }
1091  return useValue ? value : void 0;
1092};
1093
1094function __propKey(x) {
1095  return typeof x === "symbol" ? x : "".concat(x);
1096};
1097
1098function __setFunctionName(f, name, prefix) {
1099  if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
1100  return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
1101};
1102
1103function __metadata(metadataKey, metadataValue) {
1104  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
1105}
1106
1107function __awaiter(thisArg, _arguments, P, generator) {
1108  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
1109  return new (P || (P = Promise))(function (resolve, reject) {
1110      function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
1111      function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
1112      function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1113      step((generator = generator.apply(thisArg, _arguments || [])).next());
1114  });
1115}
1116
1117function __generator(thisArg, body) {
1118  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
1119  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
1120  function verb(n) { return function (v) { return step([n, v]); }; }
1121  function step(op) {
1122      if (f) throw new TypeError("Generator is already executing.");
1123      while (g && (g = 0, op[0] && (_ = 0)), _) try {
1124          if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
1125          if (y = 0, t) op = [op[0] & 2, t.value];
1126          switch (op[0]) {
1127              case 0: case 1: t = op; break;
1128              case 4: _.label++; return { value: op[1], done: false };
1129              case 5: _.label++; y = op[1]; op = [0]; continue;
1130              case 7: op = _.ops.pop(); _.trys.pop(); continue;
1131              default:
1132                  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
1133                  if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
1134                  if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
1135                  if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
1136                  if (t[2]) _.ops.pop();
1137                  _.trys.pop(); continue;
1138          }
1139          op = body.call(thisArg, _);
1140      } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
1141      if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
1142  }
1143}
1144
1145var __createBinding = Object.create ? (function(o, m, k, k2) {
1146  if (k2 === undefined) k2 = k;
1147  var desc = Object.getOwnPropertyDescriptor(m, k);
1148  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1149      desc = { enumerable: true, get: function() { return m[k]; } };
1150  }
1151  Object.defineProperty(o, k2, desc);
1152}) : (function(o, m, k, k2) {
1153  if (k2 === undefined) k2 = k;
1154  o[k2] = m[k];
1155});
1156
1157function __exportStar(m, o) {
1158  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
1159}
1160
1161function __values(o) {
1162  var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1163  if (m) return m.call(o);
1164  if (o && typeof o.length === "number") return {
1165      next: function () {
1166          if (o && i >= o.length) o = void 0;
1167          return { value: o && o[i++], done: !o };
1168      }
1169  };
1170  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1171}
1172
1173function __read(o, n) {
1174  var m = typeof Symbol === "function" && o[Symbol.iterator];
1175  if (!m) return o;
1176  var i = m.call(o), r, ar = [], e;
1177  try {
1178      while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1179  }
1180  catch (error) { e = { error: error }; }
1181  finally {
1182      try {
1183          if (r && !r.done && (m = i["return"])) m.call(i);
1184      }
1185      finally { if (e) throw e.error; }
1186  }
1187  return ar;
1188}
1189
1190/** @deprecated */
1191function __spread() {
1192  for (var ar = [], i = 0; i < arguments.length; i++)
1193      ar = ar.concat(__read(arguments[i]));
1194  return ar;
1195}
1196
1197/** @deprecated */
1198function __spreadArrays() {
1199  for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1200  for (var r = Array(s), k = 0, i = 0; i < il; i++)
1201      for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1202          r[k] = a[j];
1203  return r;
1204}
1205
1206function __spreadArray(to, from, pack) {
1207  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1208      if (ar || !(i in from)) {
1209          if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1210          ar[i] = from[i];
1211      }
1212  }
1213  return to.concat(ar || Array.prototype.slice.call(from));
1214}
1215
1216function __await(v) {
1217  return this instanceof __await ? (this.v = v, this) : new __await(v);
1218}
1219
1220function __asyncGenerator(thisArg, _arguments, generator) {
1221  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1222  var g = generator.apply(thisArg, _arguments || []), i, q = [];
1223  return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
1224  function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
1225  function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
1226  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
1227  function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
1228  function fulfill(value) { resume("next", value); }
1229  function reject(value) { resume("throw", value); }
1230  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
1231}
1232
1233function __asyncDelegator(o) {
1234  var i, p;
1235  return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
1236  function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
1237}
1238
1239function __asyncValues(o) {
1240  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1241  var m = o[Symbol.asyncIterator], i;
1242  return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
1243  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
1244  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
1245}
1246
vendor: 4,072 bytes, lines 1247-1356
1247function __makeTemplateObject(cooked, raw) {
1248  if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
1249  return cooked;
1250};
1251
1252var __setModuleDefault = Object.create ? (function(o, v) {
1253  Object.defineProperty(o, "default", { enumerable: true, value: v });
1254}) : function(o, v) {
1255  o["default"] = v;
1256};
1257
1258function __importStar(mod) {
1259  if (mod && mod.__esModule) return mod;
1260  var result = {};
1261  if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1262  __setModuleDefault(result, mod);
1263  return result;
1264}
1265
1266function __importDefault(mod) {
1267  return (mod && mod.__esModule) ? mod : { default: mod };
1268}
1269
1270function __classPrivateFieldGet(receiver, state, kind, f) {
1271  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
1272  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
1273  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
1274}
1275
1276function __classPrivateFieldSet(receiver, state, value, kind, f) {
1277  if (kind === "m") throw new TypeError("Private method is not writable");
1278  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
1279  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
1280  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1281}
1282
1283function __classPrivateFieldIn(state, receiver) {
1284  if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
1285  return typeof state === "function" ? receiver === state : state.has(receiver);
1286}
1287
1288function __addDisposableResource(env, value, async) {
1289  if (value !== null && value !== void 0) {
1290    if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
1291    var dispose, inner;
1292    if (async) {
1293      if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
1294      dispose = value[Symbol.asyncDispose];
1295    }
1296    if (dispose === void 0) {
1297      if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
1298      dispose = value[Symbol.dispose];
1299      if (async) inner = dispose;
1300    }
1301    if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
1302    if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
1303    env.stack.push({ value: value, dispose: dispose, async: async });
1304  }
1305  else if (async) {
1306    env.stack.push({ async: true });
1307  }
1308  return value;
1309}
1310
1311var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1312  var e = new Error(message);
1313  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1314};
1315
1316function __disposeResources(env) {
1317  function fail(e) {
1318    env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
1319    env.hasError = true;
1320  }
1321  function next() {
1322    while (env.stack.length) {
1323      var rec = env.stack.pop();
1324      try {
1325        var result = rec.dispose && rec.dispose.call(rec.value);
1326        if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
1327      }
1328      catch (e) {
1329          fail(e);
1330      }
1331    }
1332    if (env.hasError) throw env.error;
1333  }
1334  return next();
1335}
1336
1337/* harmony default export */ const tslib_es6 = ({
1338  __extends,
1339  __assign,
1340  __rest,
1341  __decorate,
1342  __param,
1343  __metadata,
1344  __awaiter,
1345  __generator,
1346  __createBinding,
1347  __exportStar,
1348  __values,
1349  __read,
1350  __spread,
1351  __spreadArrays,
1352  __spreadArray,
1353  __await,
1354  __asyncGenerator,
1355  __asyncDelegator,
1356  __asyncValues,
vendor: 17,925 bytes, lines 1357-1863
1357  __makeTemplateObject,
1358  __importStar,
1359  __importDefault,
1360  __classPrivateFieldGet,
1361  __classPrivateFieldSet,
1362  __classPrivateFieldIn,
1363  __addDisposableResource,
1364  __disposeResources,
1365});
1366
1367;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/callbackiterresult.js
1368
1369
1370/**
1371 * IterResult subclass that calls a callback function on each add,
1372 * and stops iterating when the callback returns false.
1373 */
1374var CallbackIterResult = /** @class */ (function (_super) {
1375    __extends(CallbackIterResult, _super);
1376    function CallbackIterResult(method, args, iterator) {
1377        var _this = _super.call(this, method, args) || this;
1378        _this.iterator = iterator;
1379        return _this;
1380    }
1381    CallbackIterResult.prototype.add = function (date) {
1382        if (this.iterator(date, this._result.length)) {
1383            this._result.push(date);
1384            return true;
1385        }
1386        return false;
1387    };
1388    return CallbackIterResult;
1389}(iterresult));
1390/* harmony default export */ const callbackiterresult = (CallbackIterResult);
1391//# sourceMappingURL=callbackiterresult.js.map
1392;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/nlp/i18n.js
1393// =============================================================================
1394// i18n
1395// =============================================================================
1396var ENGLISH = {
1397    dayNames: [
1398        'Sunday',
1399        'Monday',
1400        'Tuesday',
1401        'Wednesday',
1402        'Thursday',
1403        'Friday',
1404        'Saturday',
1405    ],
1406    monthNames: [
1407        'January',
1408        'February',
1409        'March',
1410        'April',
1411        'May',
1412        'June',
1413        'July',
1414        'August',
1415        'September',
1416        'October',
1417        'November',
1418        'December',
1419    ],
1420    tokens: {
1421        SKIP: /^[ \r\n\t]+|^\.$/,
1422        number: /^[1-9][0-9]*/,
1423        numberAsText: /^(one|two|three)/i,
1424        every: /^every/i,
1425        'day(s)': /^days?/i,
1426        'weekday(s)': /^weekdays?/i,
1427        'week(s)': /^weeks?/i,
1428        'hour(s)': /^hours?/i,
1429        'minute(s)': /^minutes?/i,
1430        'month(s)': /^months?/i,
1431        'year(s)': /^years?/i,
1432        on: /^(on|in)/i,
1433        at: /^(at)/i,
1434        the: /^the/i,
1435        first: /^first/i,
1436        second: /^second/i,
1437        third: /^third/i,
1438        nth: /^([1-9][0-9]*)(\.|th|nd|rd|st)/i,
1439        last: /^last/i,
1440        for: /^for/i,
1441        'time(s)': /^times?/i,
1442        until: /^(un)?til/i,
1443        monday: /^mo(n(day)?)?/i,
1444        tuesday: /^tu(e(s(day)?)?)?/i,
1445        wednesday: /^we(d(n(esday)?)?)?/i,
1446        thursday: /^th(u(r(sday)?)?)?/i,
1447        friday: /^fr(i(day)?)?/i,
1448        saturday: /^sa(t(urday)?)?/i,
1449        sunday: /^su(n(day)?)?/i,
1450        january: /^jan(uary)?/i,
1451        february: /^feb(ruary)?/i,
1452        march: /^mar(ch)?/i,
1453        april: /^apr(il)?/i,
1454        may: /^may/i,
1455        june: /^june?/i,
1456        july: /^july?/i,
1457        august: /^aug(ust)?/i,
1458        september: /^sep(t(ember)?)?/i,
1459        october: /^oct(ober)?/i,
1460        november: /^nov(ember)?/i,
1461        december: /^dec(ember)?/i,
1462        comma: /^(,\s*|(and|or)\s*)+/i,
1463    },
1464};
1465/* harmony default export */ const i18n = (ENGLISH);
1466//# sourceMappingURL=i18n.js.map
1467;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/nlp/totext.js
1468
1469
1470
1471// =============================================================================
1472// Helper functions
1473// =============================================================================
1474/**
1475 * Return true if a value is in an array
1476 */
1477var contains = function (arr, val) {
1478    return arr.indexOf(val) !== -1;
1479};
1480var defaultGetText = function (id) { return id.toString(); };
1481var defaultDateFormatter = function (year, month, day) { return "".concat(month, " ").concat(day, ", ").concat(year); };
1482/**
1483 *
1484 * @param {RRule} rrule
1485 * Optional:
1486 * @param {Function} gettext function
1487 * @param {Object} language definition
1488 * @constructor
1489 */
1490var ToText = /** @class */ (function () {
1491    function ToText(rrule, gettext, language, dateFormatter) {
1492        if (gettext === void 0) { gettext = defaultGetText; }
1493        if (language === void 0) { language = i18n; }
1494        if (dateFormatter === void 0) { dateFormatter = defaultDateFormatter; }
1495        this.text = [];
1496        this.language = language || i18n;
1497        this.gettext = gettext;
1498        this.dateFormatter = dateFormatter;
1499        this.rrule = rrule;
1500        this.options = rrule.options;
1501        this.origOptions = rrule.origOptions;
1502        if (this.origOptions.bymonthday) {
1503            var bymonthday = [].concat(this.options.bymonthday);
1504            var bynmonthday = [].concat(this.options.bynmonthday);
1505            bymonthday.sort(function (a, b) { return a - b; });
1506            bynmonthday.sort(function (a, b) { return b - a; });
1507            // 1, 2, 3, .., -5, -4, -3, ..
1508            this.bymonthday = bymonthday.concat(bynmonthday);
1509            if (!this.bymonthday.length)
1510                this.bymonthday = null;
1511        }
1512        if (isPresent(this.origOptions.byweekday)) {
1513            var byweekday = !isArray(this.origOptions.byweekday)
1514                ? [this.origOptions.byweekday]
1515                : this.origOptions.byweekday;
1516            var days = String(byweekday);
1517            this.byweekday = {
1518                allWeeks: byweekday.filter(function (weekday) {
1519                    return !weekday.n;
1520                }),
1521                someWeeks: byweekday.filter(function (weekday) {
1522                    return Boolean(weekday.n);
1523                }),
1524                isWeekdays: days.indexOf('MO') !== -1 &&
1525                    days.indexOf('TU') !== -1 &&
1526                    days.indexOf('WE') !== -1 &&
1527                    days.indexOf('TH') !== -1 &&
1528                    days.indexOf('FR') !== -1 &&
1529                    days.indexOf('SA') === -1 &&
1530                    days.indexOf('SU') === -1,
1531                isEveryDay: days.indexOf('MO') !== -1 &&
1532                    days.indexOf('TU') !== -1 &&
1533                    days.indexOf('WE') !== -1 &&
1534                    days.indexOf('TH') !== -1 &&
1535                    days.indexOf('FR') !== -1 &&
1536                    days.indexOf('SA') !== -1 &&
1537                    days.indexOf('SU') !== -1,
1538            };
1539            var sortWeekDays = function (a, b) {
1540                return a.weekday - b.weekday;
1541            };
1542            this.byweekday.allWeeks.sort(sortWeekDays);
1543            this.byweekday.someWeeks.sort(sortWeekDays);
1544            if (!this.byweekday.allWeeks.length)
1545                this.byweekday.allWeeks = null;
1546            if (!this.byweekday.someWeeks.length)
1547                this.byweekday.someWeeks = null;
1548        }
1549        else {
1550            this.byweekday = null;
1551        }
1552    }
1553    /**
1554     * Test whether the rrule can be fully converted to text.
1555     *
1556     * @param {RRule} rrule
1557     * @return {Boolean}
1558     */
1559    ToText.isFullyConvertible = function (rrule) {
1560        var canConvert = true;
1561        if (!(rrule.options.freq in ToText.IMPLEMENTED))
1562            return false;
1563        if (rrule.origOptions.until && rrule.origOptions.count)
1564            return false;
1565        for (var key in rrule.origOptions) {
1566            if (contains(['dtstart', 'tzid', 'wkst', 'freq'], key))
1567                return true;
1568            if (!contains(ToText.IMPLEMENTED[rrule.options.freq], key))
1569                return false;
1570        }
1571        return canConvert;
1572    };
1573    ToText.prototype.isFullyConvertible = function () {
1574        return ToText.isFullyConvertible(this.rrule);
1575    };
1576    /**
1577     * Perform the conversion. Only some of the frequencies are supported.
1578     * If some of the rrule's options aren't supported, they'll
1579     * be omitted from the output an "(~ approximate)" will be appended.
1580     *
1581     * @return {*}
1582     */
1583    ToText.prototype.toString = function () {
1584        var gettext = this.gettext;
1585        if (!(this.options.freq in ToText.IMPLEMENTED)) {
1586            return gettext('RRule error: Unable to fully convert this rrule to text');
1587        }
1588        this.text = [gettext('every')];
1589        // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1590        // @ts-ignore
1591        this[RRule.FREQUENCIES[this.options.freq]]();
1592        if (this.options.until) {
1593            this.add(gettext('until'));
1594            var until = this.options.until;
1595            this.add(this.dateFormatter(until.getUTCFullYear(), this.language.monthNames[until.getUTCMonth()], until.getUTCDate()));
1596        }
1597        else if (this.options.count) {
1598            this.add(gettext('for'))
1599                .add(this.options.count.toString())
1600                .add(this.plural(this.options.count) ? gettext('times') : gettext('time'));
1601        }
1602        if (!this.isFullyConvertible())
1603            this.add(gettext('(~ approximate)'));
1604        return this.text.join('');
1605    };
1606    ToText.prototype.HOURLY = function () {
1607        var gettext = this.gettext;
1608        if (this.options.interval !== 1)
1609            this.add(this.options.interval.toString());
1610        this.add(this.plural(this.options.interval) ? gettext('hours') : gettext('hour'));
1611    };
1612    ToText.prototype.MINUTELY = function () {
1613        var gettext = this.gettext;
1614        if (this.options.interval !== 1)
1615            this.add(this.options.interval.toString());
1616        this.add(this.plural(this.options.interval)
1617            ? gettext('minutes')
1618            : gettext('minute'));
1619    };
1620    ToText.prototype.DAILY = function () {
1621        var gettext = this.gettext;
1622        if (this.options.interval !== 1)
1623            this.add(this.options.interval.toString());
1624        if (this.byweekday && this.byweekday.isWeekdays) {
1625            this.add(this.plural(this.options.interval)
1626                ? gettext('weekdays')
1627                : gettext('weekday'));
1628        }
1629        else {
1630            this.add(this.plural(this.options.interval) ? gettext('days') : gettext('day'));
1631        }
1632        if (this.origOptions.bymonth) {
1633            this.add(gettext('in'));
1634            this._bymonth();
1635        }
1636        if (this.bymonthday) {
1637            this._bymonthday();
1638        }
1639        else if (this.byweekday) {
1640            this._byweekday();
1641        }
1642        else if (this.origOptions.byhour) {
1643            this._byhour();
1644        }
1645    };
1646    ToText.prototype.WEEKLY = function () {
1647        var gettext = this.gettext;
1648        if (this.options.interval !== 1) {
1649            this.add(this.options.interval.toString()).add(this.plural(this.options.interval) ? gettext('weeks') : gettext('week'));
1650        }
1651        if (this.byweekday && this.byweekday.isWeekdays) {
1652            if (this.options.interval === 1) {
1653                this.add(this.plural(this.options.interval)
1654                    ? gettext('weekdays')
1655                    : gettext('weekday'));
1656            }
1657            else {
1658                this.add(gettext('on')).add(gettext('weekdays'));
1659            }
1660        }
1661        else if (this.byweekday && this.byweekday.isEveryDay) {
1662            this.add(this.plural(this.options.interval) ? gettext('days') : gettext('day'));
1663        }
1664        else {
1665            if (this.options.interval === 1)
1666                this.add(gettext('week'));
1667            if (this.origOptions.bymonth) {
1668                this.add(gettext('in'));
1669                this._bymonth();
1670            }
1671            if (this.bymonthday) {
1672                this._bymonthday();
1673            }
1674            else if (this.byweekday) {
1675                this._byweekday();
1676            }
1677            if (this.origOptions.byhour) {
1678                this._byhour();
1679            }
1680        }
1681    };
1682    ToText.prototype.MONTHLY = function () {
1683        var gettext = this.gettext;
1684        if (this.origOptions.bymonth) {
1685            if (this.options.interval !== 1) {
1686                this.add(this.options.interval.toString()).add(gettext('months'));
1687                if (this.plural(this.options.interval))
1688                    this.add(gettext('in'));
1689            }
1690            else {
1691                // this.add(gettext('MONTH'))
1692            }
1693            this._bymonth();
1694        }
1695        else {
1696            if (this.options.interval !== 1) {
1697                this.add(this.options.interval.toString());
1698            }
1699            this.add(this.plural(this.options.interval)
1700                ? gettext('months')
1701                : gettext('month'));
1702        }
1703        if (this.bymonthday) {
1704            this._bymonthday();
1705        }
1706        else if (this.byweekday && this.byweekday.isWeekdays) {
1707            this.add(gettext('on')).add(gettext('weekdays'));
1708        }
1709        else if (this.byweekday) {
1710            this._byweekday();
1711        }
1712    };
1713    ToText.prototype.YEARLY = function () {
1714        var gettext = this.gettext;
1715        if (this.origOptions.bymonth) {
1716            if (this.options.interval !== 1) {
1717                this.add(this.options.interval.toString());
1718                this.add(gettext('years'));
1719            }
1720            else {
1721                // this.add(gettext('YEAR'))
1722            }
1723            this._bymonth();
1724        }
1725        else {
1726            if (this.options.interval !== 1) {
1727                this.add(this.options.interval.toString());
1728            }
1729            this.add(this.plural(this.options.interval) ? gettext('years') : gettext('year'));
1730        }
1731        if (this.bymonthday) {
1732            this._bymonthday();
1733        }
1734        else if (this.byweekday) {
1735            this._byweekday();
1736        }
1737        if (this.options.byyearday) {
1738            this.add(gettext('on the'))
1739                .add(this.list(this.options.byyearday, this.nth, gettext('and')))
1740                .add(gettext('day'));
1741        }
1742        if (this.options.byweekno) {
1743            this.add(gettext('in'))
1744                .add(this.plural(this.options.byweekno.length)
1745                ? gettext('weeks')
1746                : gettext('week'))
1747                .add(this.list(this.options.byweekno, undefined, gettext('and')));
1748        }
1749    };
1750    ToText.prototype._bymonthday = function () {
1751        var gettext = this.gettext;
1752        if (this.byweekday && this.byweekday.allWeeks) {
1753            this.add(gettext('on'))
1754                .add(this.list(this.byweekday.allWeeks, this.weekdaytext, gettext('or')))
1755                .add(gettext('the'))
1756                .add(this.list(this.bymonthday, this.nth, gettext('or')));
1757        }
1758        else {
1759            this.add(gettext('on the')).add(this.list(this.bymonthday, this.nth, gettext('and')));
1760        }
1761        // this.add(gettext('DAY'))
1762    };
1763    ToText.prototype._byweekday = function () {
1764        var gettext = this.gettext;
1765        if (this.byweekday.allWeeks && !this.byweekday.isWeekdays) {
1766            this.add(gettext('on')).add(this.list(this.byweekday.allWeeks, this.weekdaytext));
1767        }
1768        if (this.byweekday.someWeeks) {
1769            if (this.byweekday.allWeeks)
1770                this.add(gettext('and'));
1771            this.add(gettext('on the')).add(this.list(this.byweekday.someWeeks, this.weekdaytext, gettext('and')));
1772        }
1773    };
1774    ToText.prototype._byhour = function () {
1775        var gettext = this.gettext;
1776        this.add(gettext('at')).add(this.list(this.origOptions.byhour, undefined, gettext('and')));
1777    };
1778    ToText.prototype._bymonth = function () {
1779        this.add(this.list(this.options.bymonth, this.monthtext, this.gettext('and')));
1780    };
1781    ToText.prototype.nth = function (n) {
1782        n = parseInt(n.toString(), 10);
1783        var nth;
1784        var gettext = this.gettext;
1785        if (n === -1)
1786            return gettext('last');
1787        var npos = Math.abs(n);
1788        switch (npos) {
1789            case 1:
1790            case 21:
1791            case 31:
1792                nth = npos + gettext('st');
1793                break;
1794            case 2:
1795            case 22:
1796                nth = npos + gettext('nd');
1797                break;
1798            case 3:
1799            case 23:
1800                nth = npos + gettext('rd');
1801                break;
1802            default:
1803                nth = npos + gettext('th');
1804        }
1805        return n < 0 ? nth + ' ' + gettext('last') : nth;
1806    };
1807    ToText.prototype.monthtext = function (m) {
1808        return this.language.monthNames[m - 1];
1809    };
1810    ToText.prototype.weekdaytext = function (wday) {
1811        var weekday = isNumber(wday) ? (wday + 1) % 7 : wday.getJsWeekday();
1812        return ((wday.n ? this.nth(wday.n) + ' ' : '') +
1813            this.language.dayNames[weekday]);
1814    };
1815    ToText.prototype.plural = function (n) {
1816        return n % 100 !== 1;
1817    };
1818    ToText.prototype.add = function (s) {
1819        this.text.push(' ');
1820        this.text.push(s);
1821        return this;
1822    };
1823    ToText.prototype.list = function (arr, callback, finalDelim, delim) {
1824        var _this = this;
1825        if (delim === void 0) { delim = ','; }
1826        if (!isArray(arr)) {
1827            arr = [arr];
1828        }
1829        var delimJoin = function (array, delimiter, finalDelimiter) {
1830            var list = '';
1831            for (var i = 0; i < array.length; i++) {
1832                if (i !== 0) {
1833                    if (i === array.length - 1) {
1834                        list += ' ' + finalDelimiter + ' ';
1835                    }
1836                    else {
1837                        list += delimiter + ' ';
1838                    }
1839                }
1840                list += array[i];
1841            }
1842            return list;
1843        };
1844        callback =
1845            callback ||
1846                function (o) {
1847                    return o.toString();
1848                };
1849        var realCallback = function (arg) {
1850            return callback && callback.call(_this, arg);
1851        };
1852        if (finalDelim) {
1853            return delimJoin(arr.map(realCallback), delim, finalDelim);
1854        }
1855        else {
1856            return arr.map(realCallback).join(delim + ' ');
1857        }
1858    };
1859    return ToText;
1860}());
1861/* harmony default export */ const totext = (ToText);
1862//# sourceMappingURL=totext.js.map
1863;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/nlp/parsetext.j
vendor: 12,501 bytes, lines 1863-2253
1863s
1864
1865
1866// =============================================================================
1867// Parser
1868// =============================================================================
1869var Parser = /** @class */ (function () {
1870    function Parser(rules) {
1871        this.done = true;
1872        this.rules = rules;
1873    }
1874    Parser.prototype.start = function (text) {
1875        this.text = text;
1876        this.done = false;
1877        return this.nextSymbol();
1878    };
1879    Parser.prototype.isDone = function () {
1880        return this.done && this.symbol === null;
1881    };
1882    Parser.prototype.nextSymbol = function () {
1883        var best;
1884        var bestSymbol;
1885        this.symbol = null;
1886        this.value = null;
1887        do {
1888            if (this.done)
1889                return false;
1890            var rule = void 0;
1891            best = null;
1892            for (var name_1 in this.rules) {
1893                rule = this.rules[name_1];
1894                var match = rule.exec(this.text);
1895                if (match) {
1896                    if (best === null || match[0].length > best[0].length) {
1897                        best = match;
1898                        bestSymbol = name_1;
1899                    }
1900                }
1901            }
1902            if (best != null) {
1903                this.text = this.text.substr(best[0].length);
1904                if (this.text === '')
1905                    this.done = true;
1906            }
1907            if (best == null) {
1908                this.done = true;
1909                this.symbol = null;
1910                this.value = null;
1911                return;
1912            }
1913        } while (bestSymbol === 'SKIP');
1914        this.symbol = bestSymbol;
1915        this.value = best;
1916        return true;
1917    };
1918    Parser.prototype.accept = function (name) {
1919        if (this.symbol === name) {
1920            if (this.value) {
1921                var v = this.value;
1922                this.nextSymbol();
1923                return v;
1924            }
1925            this.nextSymbol();
1926            return true;
1927        }
1928        return false;
1929    };
1930    Parser.prototype.acceptNumber = function () {
1931        return this.accept('number');
1932    };
1933    Parser.prototype.expect = function (name) {
1934        if (this.accept(name))
1935            return true;
1936        throw new Error('expected ' + name + ' but found ' + this.symbol);
1937    };
1938    return Parser;
1939}());
1940function parseText(text, language) {
1941    if (language === void 0) { language = i18n; }
1942    var options = {};
1943    var ttr = new Parser(language.tokens);
1944    if (!ttr.start(text))
1945        return null;
1946    S();
1947    return options;
1948    function S() {
1949        // every [n]
1950        ttr.expect('every');
1951        var n = ttr.acceptNumber();
1952        if (n)
1953            options.interval = parseInt(n[0], 10);
1954        if (ttr.isDone())
1955            throw new Error('Unexpected end');
1956        switch (ttr.symbol) {
1957            case 'day(s)':
1958                options.freq = RRule.DAILY;
1959                if (ttr.nextSymbol()) {
1960                    AT();
1961                    F();
1962                }
1963                break;
1964            // FIXME Note: every 2 weekdays != every two weeks on weekdays.
1965            // DAILY on weekdays is not a valid rule
1966            case 'weekday(s)':
1967                options.freq = RRule.WEEKLY;
1968                options.byweekday = [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR];
1969                ttr.nextSymbol();
1970                AT();
1971                F();
1972                break;
1973            case 'week(s)':
1974                options.freq = RRule.WEEKLY;
1975                if (ttr.nextSymbol()) {
1976                    ON();
1977                    AT();
1978                    F();
1979                }
1980                break;
1981            case 'hour(s)':
1982                options.freq = RRule.HOURLY;
1983                if (ttr.nextSymbol()) {
1984                    ON();
1985                    F();
1986                }
1987                break;
1988            case 'minute(s)':
1989                options.freq = RRule.MINUTELY;
1990                if (ttr.nextSymbol()) {
1991                    ON();
1992                    F();
1993                }
1994                break;
1995            case 'month(s)':
1996                options.freq = RRule.MONTHLY;
1997                if (ttr.nextSymbol()) {
1998                    ON();
1999                    F();
2000                }
2001                break;
2002            case 'year(s)':
2003                options.freq = RRule.YEARLY;
2004                if (ttr.nextSymbol()) {
2005                    ON();
2006                    F();
2007                }
2008                break;
2009            case 'monday':
2010            case 'tuesday':
2011            case 'wednesday':
2012            case 'thursday':
2013            case 'friday':
2014            case 'saturday':
2015            case 'sunday':
2016                options.freq = RRule.WEEKLY;
2017                var key = ttr.symbol
2018                    .substr(0, 2)
2019                    .toUpperCase();
2020                options.byweekday = [RRule[key]];
2021                if (!ttr.nextSymbol())
2022                    return;
2023                // TODO check for duplicates
2024                while (ttr.accept('comma')) {
2025                    if (ttr.isDone())
2026                        throw new Error('Unexpected end');
2027                    var wkd = decodeWKD();
2028                    if (!wkd) {
2029                        throw new Error('Unexpected symbol ' + ttr.symbol + ', expected weekday');
2030                    }
2031                    options.byweekday.push(RRule[wkd]);
2032                    ttr.nextSymbol();
2033                }
2034                AT();
2035                MDAYs();
2036                F();
2037                break;
2038            case 'january':
2039            case 'february':
2040            case 'march':
2041            case 'april':
2042            case 'may':
2043            case 'june':
2044            case 'july':
2045            case 'august':
2046            case 'september':
2047            case 'october':
2048            case 'november':
2049            case 'december':
2050                options.freq = RRule.YEARLY;
2051                options.bymonth = [decodeM()];
2052                if (!ttr.nextSymbol())
2053                    return;
2054                // TODO check for duplicates
2055                while (ttr.accept('comma')) {
2056                    if (ttr.isDone())
2057                        throw new Error('Unexpected end');
2058                    var m = decodeM();
2059                    if (!m) {
2060                        throw new Error('Unexpected symbol ' + ttr.symbol + ', expected month');
2061                    }
2062                    options.bymonth.push(m);
2063                    ttr.nextSymbol();
2064                }
2065                ON();
2066                F();
2067                break;
2068            default:
2069                throw new Error('Unknown symbol');
2070        }
2071    }
2072    function ON() {
2073        var on = ttr.accept('on');
2074        var the = ttr.accept('the');
2075        if (!(on || the))
2076            return;
2077        do {
2078            var nth = decodeNTH();
2079            var wkd = decodeWKD();
2080            var m = decodeM();
2081            // nth <weekday> | <weekday>
2082            if (nth) {
2083                // ttr.nextSymbol()
2084                if (wkd) {
2085                    ttr.nextSymbol();
2086                    if (!options.byweekday)
2087                        options.byweekday = [];
2088                    options.byweekday.push(RRule[wkd].nth(nth));
2089                }
2090                else {
2091                    if (!options.bymonthday)
2092                        options.bymonthday = [];
2093                    options.bymonthday.push(nth);
2094                    ttr.accept('day(s)');
2095                }
2096                // <weekday>
2097            }
2098            else if (wkd) {
2099                ttr.nextSymbol();
2100                if (!options.byweekday)
2101                    options.byweekday = [];
2102                options.byweekday.push(RRule[wkd]);
2103            }
2104            else if (ttr.symbol === 'weekday(s)') {
2105                ttr.nextSymbol();
2106                if (!options.byweekday) {
2107                    options.byweekday = [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR];
2108                }
2109            }
2110            else if (ttr.symbol === 'week(s)') {
2111                ttr.nextSymbol();
2112                var n = ttr.acceptNumber();
2113                if (!n) {
2114                    throw new Error('Unexpected symbol ' + ttr.symbol + ', expected week number');
2115                }
2116                options.byweekno = [parseInt(n[0], 10)];
2117                while (ttr.accept('comma')) {
2118                    n = ttr.acceptNumber();
2119                    if (!n) {
2120                        throw new Error('Unexpected symbol ' + ttr.symbol + '; expected monthday');
2121                    }
2122                    options.byweekno.push(parseInt(n[0], 10));
2123                }
2124            }
2125            else if (m) {
2126                ttr.nextSymbol();
2127                if (!options.bymonth)
2128                    options.bymonth = [];
2129                options.bymonth.push(m);
2130            }
2131            else {
2132                return;
2133            }
2134        } while (ttr.accept('comma') || ttr.accept('the') || ttr.accept('on'));
2135    }
2136    function AT() {
2137        var at = ttr.accept('at');
2138        if (!at)
2139            return;
2140        do {
2141            var n = ttr.acceptNumber();
2142            if (!n) {
2143                throw new Error('Unexpected symbol ' + ttr.symbol + ', expected hour');
2144            }
2145            options.byhour = [parseInt(n[0], 10)];
2146            while (ttr.accept('comma')) {
2147                n = ttr.acceptNumber();
2148                if (!n) {
2149                    throw new Error('Unexpected symbol ' + ttr.symbol + '; expected hour');
2150                }
2151                options.byhour.push(parseInt(n[0], 10));
2152            }
2153        } while (ttr.accept('comma') || ttr.accept('at'));
2154    }
2155    function decodeM() {
2156        switch (ttr.symbol) {
2157            case 'january':
2158                return 1;
2159            case 'february':
2160                return 2;
2161            case 'march':
2162                return 3;
2163            case 'april':
2164                return 4;
2165            case 'may':
2166                return 5;
2167            case 'june':
2168                return 6;
2169            case 'july':
2170                return 7;
2171            case 'august':
2172                return 8;
2173            case 'september':
2174                return 9;
2175            case 'october':
2176                return 10;
2177            case 'november':
2178                return 11;
2179            case 'december':
2180                return 12;
2181            default:
2182                return false;
2183        }
2184    }
2185    function decodeWKD() {
2186        switch (ttr.symbol) {
2187            case 'monday':
2188            case 'tuesday':
2189            case 'wednesday':
2190            case 'thursday':
2191            case 'friday':
2192            case 'saturday':
2193            case 'sunday':
2194                return ttr.symbol.substr(0, 2).toUpperCase();
2195            default:
2196                return false;
2197        }
2198    }
2199    function decodeNTH() {
2200        switch (ttr.symbol) {
2201            case 'last':
2202                ttr.nextSymbol();
2203                return -1;
2204            case 'first':
2205                ttr.nextSymbol();
2206                return 1;
2207            case 'second':
2208                ttr.nextSymbol();
2209                return ttr.accept('last') ? -2 : 2;
2210            case 'third':
2211                ttr.nextSymbol();
2212                return ttr.accept('last') ? -3 : 3;
2213            case 'nth':
2214                var v = parseInt(ttr.value[1], 10);
2215                if (v < -366 || v > 366)
2216                    throw new Error('Nth out of range: ' + v);
2217                ttr.nextSymbol();
2218                return ttr.accept('last') ? -v : v;
2219            default:
2220                return false;
2221        }
2222    }
2223    function MDAYs() {
2224        ttr.accept('on');
2225        ttr.accept('the');
2226        var nth = decodeNTH();
2227        if (!nth)
2228            return;
2229        options.bymonthday = [nth];
2230        ttr.nextSymbol();
2231        while (ttr.accept('comma')) {
2232            nth = decodeNTH();
2233            if (!nth) {
2234                throw new Error('Unexpected symbol ' + ttr.symbol + '; expected monthday');
2235            }
2236            options.bymonthday.push(nth);
2237            ttr.nextSymbol();
2238        }
2239    }
2240    function F() {
2241        if (ttr.symbol === 'until') {
2242            var date = Date.parse(ttr.text);
2243            if (!date)
2244                throw new Error('Cannot parse until date:' + ttr.text);
2245            options.until = new Date(date);
2246        }
2247        else if (ttr.accept('for')) {
2248            options.count = parseInt(ttr.value[0], 10);
2249            ttr.expect('number');
2250            // ttr.expect('times')
2251        }
2252    }
2253}
2254//# sourceMappingURL=parsetext.js.map
2255;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/types.js
2256var Frequency;
2257(function (Frequency) {
2258    Frequency[Frequency["YEARLY"] = 0] = "YEARLY";
2259    Frequency[Frequency["MONTHLY"] = 1] = "MONTHLY";
2260    Frequency[Frequency["WEEKLY"] = 2] = "WEEKLY";
2261    Frequency[Frequency["DAILY"] = 3] = "DAILY";
2262    Frequency[Frequency["HOURLY"] = 4] = "HOURLY";
2263    Frequency[Frequency["MINUTELY"] = 5] = "MINUTELY";
2264    Frequency[Frequency["SECONDLY"] = 6] = "SECONDLY";
2265})(Frequency || (Frequency = {}));
2266function freqIsDailyOrGreater(freq) {
2267    return freq < Frequency.HOURLY;
2268}
2269//# sourceMappingURL=types.js.map
2270;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/nlp/index.js
2271
2272
2273
2274
2275
2276/* !
2277 * rrule.js - Library for working with recurrence rules for calendar dates.
2278 * https://github.com/jakubroztocil/rrule
2279 *
2280 * Copyright 2010, Jakub Roztocil and Lars Schoning
2281 * Licenced under the BSD licence.
2282 * https://github.com/jakubroztocil/rrule/blob/master/LICENCE
2283 *
2284 */
2285/**
2286 *
2287 * Implementation of RRule.fromText() and RRule::toText().
2288 *
2289 *
2290 * On the client side, this file needs to be included
2291 * when those functions are used.
2292 *
2293 */
2294// =============================================================================
2295// fromText
2296// =============================================================================
2297/**
2298 * Will be able to convert some of the below described rules from
2299 * text format to a rule object.
2300 *
2301 *
2302 * RULES
2303 *
2304 * Every ([n])
2305 * day(s)
2306 * | [weekday], ..., (and) [weekday]
2307 * | weekday(s)
2308 * | week(s)
2309 * | month(s)
2310 * | [month], ..., (and) [month]
2311 * | year(s)
2312 *
2313 *
2314 * Plus 0, 1, or multiple of these:
2315 *
2316 * on [weekday], ..., (or) [weekday] the [monthday], [monthday], ... (or) [monthday]
2317 *
2318 * on [weekday], ..., (and) [weekday]
2319 *
2320 * on the [monthday], [monthday], ... (and) [monthday] (day of the month)
2321 *
2322 * on the [nth-weekday], ..., (and) [nth-weekday] (of the month/year)
2323 *
2324 *
2325 * Plus 0 or 1 of these:
2326 *
2327 * for [n] time(s)
2328 *
2329 * until [date]
2330 *
2331 * Plus (.)
2332 *
2333 *
2334 * Definitely no supported for parsing:
2335 *
2336 * (for year):
vendor: 44,605 bytes, lines 2337-3609
2337 * in week(s) [n], ..., (and) [n]
2338 *
2339 * on the [yearday], ..., (and) [n] day of the year
2340 * on day [yearday], ..., (and) [n]
2341 *
2342 *
2343 * NON-TERMINALS
2344 *
2345 * [n]: 1, 2 ..., one, two, three ..
2346 * [month]: January, February, March, April, May, ... December
2347 * [weekday]: Monday, ... Sunday
2348 * [nth-weekday]: first [weekday], 2nd [weekday], ... last [weekday], ...
2349 * [monthday]: first, 1., 2., 1st, 2nd, second, ... 31st, last day, 2nd last day, ..
2350 * [date]:
2351 * - [month] (0-31(,) ([year])),
2352 * - (the) 0-31.(1-12.([year])),
2353 * - (the) 0-31/(1-12/([year])),
2354 * - [weekday]
2355 *
2356 * [year]: 0000, 0001, ... 01, 02, ..
2357 *
2358 * Definitely not supported for parsing:
2359 *
2360 * [yearday]: first, 1., 2., 1st, 2nd, second, ... 366th, last day, 2nd last day, ..
2361 *
2362 * @param {String} text
2363 * @return {Object, Boolean} the rule, or null.
2364 */
2365var fromText = function (text, language) {
2366    if (language === void 0) { language = i18n; }
2367    return new RRule(parseText(text, language) || undefined);
2368};
2369var common = [
2370    'count',
2371    'until',
2372    'interval',
2373    'byweekday',
2374    'bymonthday',
2375    'bymonth',
2376];
2377totext.IMPLEMENTED = [];
2378totext.IMPLEMENTED[Frequency.HOURLY] = common;
2379totext.IMPLEMENTED[Frequency.MINUTELY] = common;
2380totext.IMPLEMENTED[Frequency.DAILY] = ['byhour'].concat(common);
2381totext.IMPLEMENTED[Frequency.WEEKLY] = common;
2382totext.IMPLEMENTED[Frequency.MONTHLY] = common;
2383totext.IMPLEMENTED[Frequency.YEARLY] = ['byweekno', 'byyearday'].concat(common);
2384// =============================================================================
2385// Export
2386// =============================================================================
2387var toText = function (rrule, gettext, language, dateFormatter) {
2388    return new totext(rrule, gettext, language, dateFormatter).toString();
2389};
2390var isFullyConvertible = totext.isFullyConvertible;
2391
2392//# sourceMappingURL=index.js.map
2393;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/datetime.js
2394
2395
2396
2397
2398var Time = /** @class */ (function () {
2399    function Time(hour, minute, second, millisecond) {
2400        this.hour = hour;
2401        this.minute = minute;
2402        this.second = second;
2403        this.millisecond = millisecond || 0;
2404    }
2405    Time.prototype.getHours = function () {
2406        return this.hour;
2407    };
2408    Time.prototype.getMinutes = function () {
2409        return this.minute;
2410    };
2411    Time.prototype.getSeconds = function () {
2412        return this.second;
2413    };
2414    Time.prototype.getMilliseconds = function () {
2415        return this.millisecond;
2416    };
2417    Time.prototype.getTime = function () {
2418        return ((this.hour * 60 * 60 + this.minute * 60 + this.second) * 1000 +
2419            this.millisecond);
2420    };
2421    return Time;
2422}());
2423
2424var DateTime = /** @class */ (function (_super) {
2425    __extends(DateTime, _super);
2426    function DateTime(year, month, day, hour, minute, second, millisecond) {
2427        var _this = _super.call(this, hour, minute, second, millisecond) || this;
2428        _this.year = year;
2429        _this.month = month;
2430        _this.day = day;
2431        return _this;
2432    }
2433    DateTime.fromDate = function (date) {
2434        return new this(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.valueOf() % 1000);
2435    };
2436    DateTime.prototype.getWeekday = function () {
2437        return getWeekday(new Date(this.getTime()));
2438    };
2439    DateTime.prototype.getTime = function () {
2440        return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond)).getTime();
2441    };
2442    DateTime.prototype.getDay = function () {
2443        return this.day;
2444    };
2445    DateTime.prototype.getMonth = function () {
2446        return this.month;
2447    };
2448    DateTime.prototype.getYear = function () {
2449        return this.year;
2450    };
2451    DateTime.prototype.addYears = function (years) {
2452        this.year += years;
2453    };
2454    DateTime.prototype.addMonths = function (months) {
2455        this.month += months;
2456        if (this.month > 12) {
2457            var yearDiv = Math.floor(this.month / 12);
2458            var monthMod = pymod(this.month, 12);
2459            this.month = monthMod;
2460            this.year += yearDiv;
2461            if (this.month === 0) {
2462                this.month = 12;
2463                --this.year;
2464            }
2465        }
2466    };
2467    DateTime.prototype.addWeekly = function (days, wkst) {
2468        if (wkst > this.getWeekday()) {
2469            this.day += -(this.getWeekday() + 1 + (6 - wkst)) + days * 7;
2470        }
2471        else {
2472            this.day += -(this.getWeekday() - wkst) + days * 7;
2473        }
2474        this.fixDay();
2475    };
2476    DateTime.prototype.addDaily = function (days) {
2477        this.day += days;
2478        this.fixDay();
2479    };
2480    DateTime.prototype.addHours = function (hours, filtered, byhour) {
2481        if (filtered) {
2482            // Jump to one iteration before next day
2483            this.hour += Math.floor((23 - this.hour) / hours) * hours;
2484        }
2485        for (;;) {
2486            this.hour += hours;
2487            var _a = divmod(this.hour, 24), dayDiv = _a.div, hourMod = _a.mod;
2488            if (dayDiv) {
2489                this.hour = hourMod;
2490                this.addDaily(dayDiv);
2491            }
2492            if (empty(byhour) || includes(byhour, this.hour))
2493                break;
2494        }
2495    };
2496    DateTime.prototype.addMinutes = function (minutes, filtered, byhour, byminute) {
2497        if (filtered) {
2498            // Jump to one iteration before next day
2499            this.minute +=
2500                Math.floor((1439 - (this.hour * 60 + this.minute)) / minutes) * minutes;
2501        }
2502        for (;;) {
2503            this.minute += minutes;
2504            var _a = divmod(this.minute, 60), hourDiv = _a.div, minuteMod = _a.mod;
2505            if (hourDiv) {
2506                this.minute = minuteMod;
2507                this.addHours(hourDiv, false, byhour);
2508            }
2509            if ((empty(byhour) || includes(byhour, this.hour)) &&
2510                (empty(byminute) || includes(byminute, this.minute))) {
2511                break;
2512            }
2513        }
2514    };
2515    DateTime.prototype.addSeconds = function (seconds, filtered, byhour, byminute, bysecond) {
2516        if (filtered) {
2517            // Jump to one iteration before next day
2518            this.second +=
2519                Math.floor((86399 - (this.hour * 3600 + this.minute * 60 + this.second)) /
2520                    seconds) * seconds;
2521        }
2522        for (;;) {
2523            this.second += seconds;
2524            var _a = divmod(this.second, 60), minuteDiv = _a.div, secondMod = _a.mod;
2525            if (minuteDiv) {
2526                this.second = secondMod;
2527                this.addMinutes(minuteDiv, false, byhour, byminute);
2528            }
2529            if ((empty(byhour) || includes(byhour, this.hour)) &&
2530                (empty(byminute) || includes(byminute, this.minute)) &&
2531                (empty(bysecond) || includes(bysecond, this.second))) {
2532                break;
2533            }
2534        }
2535    };
2536    DateTime.prototype.fixDay = function () {
2537        if (this.day <= 28) {
2538            return;
2539        }
2540        var daysinmonth = monthRange(this.year, this.month - 1)[1];
2541        if (this.day <= daysinmonth) {
2542            return;
2543        }
2544        while (this.day > daysinmonth) {
2545            this.day -= daysinmonth;
2546            ++this.month;
2547            if (this.month === 13) {
2548                this.month = 1;
2549                ++this.year;
2550                if (this.year > MAXYEAR) {
2551                    return;
2552                }
2553            }
2554            daysinmonth = monthRange(this.year, this.month - 1)[1];
2555        }
2556    };
2557    DateTime.prototype.add = function (options, filtered) {
2558        var freq = options.freq, interval = options.interval, wkst = options.wkst, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
2559        switch (freq) {
2560            case Frequency.YEARLY:
2561                return this.addYears(interval);
2562            case Frequency.MONTHLY:
2563                return this.addMonths(interval);
2564            case Frequency.WEEKLY:
2565                return this.addWeekly(interval, wkst);
2566            case Frequency.DAILY:
2567                return this.addDaily(interval);
2568            case Frequency.HOURLY:
2569                return this.addHours(interval, filtered, byhour);
2570            case Frequency.MINUTELY:
2571                return this.addMinutes(interval, filtered, byhour, byminute);
2572            case Frequency.SECONDLY:
2573                return this.addSeconds(interval, filtered, byhour, byminute, bysecond);
2574        }
2575    };
2576    return DateTime;
2577}(Time));
2578
2579//# sourceMappingURL=datetime.js.map
2580;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/parseoptions.js
2581
2582
2583
2584
2585
2586
2587
2588function initializeOptions(options) {
2589    var invalid = [];
2590    var keys = Object.keys(options);
2591    // Shallow copy for options and origOptions and check for invalid
2592    for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
2593        var key = keys_1[_i];
2594        if (!includes(defaultKeys, key))
2595            invalid.push(key);
2596        if (isDate(options[key]) && !isValidDate(options[key])) {
2597            invalid.push(key);
2598        }
2599    }
2600    if (invalid.length) {
2601        throw new Error('Invalid options: ' + invalid.join(', '));
2602    }
2603    return __assign({}, options);
2604}
2605function parseOptions(options) {
2606    var opts = __assign(__assign({}, DEFAULT_OPTIONS), initializeOptions(options));
2607    if (isPresent(opts.byeaster))
2608        opts.freq = RRule.YEARLY;
2609    if (!(isPresent(opts.freq) && RRule.FREQUENCIES[opts.freq])) {
2610        throw new Error("Invalid frequency: ".concat(opts.freq, " ").concat(options.freq));
2611    }
2612    if (!opts.dtstart)
2613        opts.dtstart = new Date(new Date().setMilliseconds(0));
2614    if (!isPresent(opts.wkst)) {
2615        opts.wkst = RRule.MO.weekday;
2616    }
2617    else if (isNumber(opts.wkst)) {
2618        // cool, just keep it like that
2619    }
2620    else {
2621        opts.wkst = opts.wkst.weekday;
2622    }
2623    if (isPresent(opts.bysetpos)) {
2624        if (isNumber(opts.bysetpos))
2625            opts.bysetpos = [opts.bysetpos];
2626        for (var i = 0; i < opts.bysetpos.length; i++) {
2627            var v = opts.bysetpos[i];
2628            if (v === 0 || !(v >= -366 && v <= 366)) {
2629                throw new Error('bysetpos must be between 1 and 366,' + ' or between -366 and -1');
2630            }
2631        }
2632    }
2633    if (!(Boolean(opts.byweekno) ||
2634        notEmpty(opts.byweekno) ||
2635        notEmpty(opts.byyearday) ||
2636        Boolean(opts.bymonthday) ||
2637        notEmpty(opts.bymonthday) ||
2638        isPresent(opts.byweekday) ||
2639        isPresent(opts.byeaster))) {
2640        switch (opts.freq) {
2641            case RRule.YEARLY:
2642                if (!opts.bymonth)
2643                    opts.bymonth = opts.dtstart.getUTCMonth() + 1;
2644                opts.bymonthday = opts.dtstart.getUTCDate();
2645                break;
2646            case RRule.MONTHLY:
2647                opts.bymonthday = opts.dtstart.getUTCDate();
2648                break;
2649            case RRule.WEEKLY:
2650                opts.byweekday = [getWeekday(opts.dtstart)];
2651                break;
2652        }
2653    }
2654    // bymonth
2655    if (isPresent(opts.bymonth) && !isArray(opts.bymonth)) {
2656        opts.bymonth = [opts.bymonth];
2657    }
2658    // byyearday
2659    if (isPresent(opts.byyearday) &&
2660        !isArray(opts.byyearday) &&
2661        isNumber(opts.byyearday)) {
2662        opts.byyearday = [opts.byyearday];
2663    }
2664    // bymonthday
2665    if (!isPresent(opts.bymonthday)) {
2666        opts.bymonthday = [];
2667        opts.bynmonthday = [];
2668    }
2669    else if (isArray(opts.bymonthday)) {
2670        var bymonthday = [];
2671        var bynmonthday = [];
2672        for (var i = 0; i < opts.bymonthday.length; i++) {
2673            var v = opts.bymonthday[i];
2674            if (v > 0) {
2675                bymonthday.push(v);
2676            }
2677            else if (v < 0) {
2678                bynmonthday.push(v);
2679            }
2680        }
2681        opts.bymonthday = bymonthday;
2682        opts.bynmonthday = bynmonthday;
2683    }
2684    else if (opts.bymonthday < 0) {
2685        opts.bynmonthday = [opts.bymonthday];
2686        opts.bymonthday = [];
2687    }
2688    else {
2689        opts.bynmonthday = [];
2690        opts.bymonthday = [opts.bymonthday];
2691    }
2692    // byweekno
2693    if (isPresent(opts.byweekno) && !isArray(opts.byweekno)) {
2694        opts.byweekno = [opts.byweekno];
2695    }
2696    // byweekday / bynweekday
2697    if (!isPresent(opts.byweekday)) {
2698        opts.bynweekday = null;
2699    }
2700    else if (isNumber(opts.byweekday)) {
2701        opts.byweekday = [opts.byweekday];
2702        opts.bynweekday = null;
2703    }
2704    else if (isWeekdayStr(opts.byweekday)) {
2705        opts.byweekday = [Weekday.fromStr(opts.byweekday).weekday];
2706        opts.bynweekday = null;
2707    }
2708    else if (opts.byweekday instanceof Weekday) {
2709        if (!opts.byweekday.n || opts.freq > RRule.MONTHLY) {
2710            opts.byweekday = [opts.byweekday.weekday];
2711            opts.bynweekday = null;
2712        }
2713        else {
2714            opts.bynweekday = [[opts.byweekday.weekday, opts.byweekday.n]];
2715            opts.byweekday = null;
2716        }
2717    }
2718    else {
2719        var byweekday = [];
2720        var bynweekday = [];
2721        for (var i = 0; i < opts.byweekday.length; i++) {
2722            var wday = opts.byweekday[i];
2723            if (isNumber(wday)) {
2724                byweekday.push(wday);
2725                continue;
2726            }
2727            else if (isWeekdayStr(wday)) {
2728                byweekday.push(Weekday.fromStr(wday).weekday);
2729                continue;
2730            }
2731            if (!wday.n || opts.freq > RRule.MONTHLY) {
2732                byweekday.push(wday.weekday);
2733            }
2734            else {
2735                bynweekday.push([wday.weekday, wday.n]);
2736            }
2737        }
2738        opts.byweekday = notEmpty(byweekday) ? byweekday : null;
2739        opts.bynweekday = notEmpty(bynweekday) ? bynweekday : null;
2740    }
2741    // byhour
2742    if (!isPresent(opts.byhour)) {
2743        opts.byhour = opts.freq < RRule.HOURLY ? [opts.dtstart.getUTCHours()] : null;
2744    }
2745    else if (isNumber(opts.byhour)) {
2746        opts.byhour = [opts.byhour];
2747    }
2748    // byminute
2749    if (!isPresent(opts.byminute)) {
2750        opts.byminute =
2751            opts.freq < RRule.MINUTELY ? [opts.dtstart.getUTCMinutes()] : null;
2752    }
2753    else if (isNumber(opts.byminute)) {
2754        opts.byminute = [opts.byminute];
2755    }
2756    // bysecond
2757    if (!isPresent(opts.bysecond)) {
2758        opts.bysecond =
2759            opts.freq < RRule.SECONDLY ? [opts.dtstart.getUTCSeconds()] : null;
2760    }
2761    else if (isNumber(opts.bysecond)) {
2762        opts.bysecond = [opts.bysecond];
2763    }
2764    return { parsedOptions: opts };
2765}
2766function buildTimeset(opts) {
2767    var millisecondModulo = opts.dtstart.getTime() % 1000;
2768    if (!freqIsDailyOrGreater(opts.freq)) {
2769        return [];
2770    }
2771    var timeset = [];
2772    opts.byhour.forEach(function (hour) {
2773        opts.byminute.forEach(function (minute) {
2774            opts.bysecond.forEach(function (second) {
2775                timeset.push(new Time(hour, minute, second, millisecondModulo));
2776            });
2777        });
2778    });
2779    return timeset;
2780}
2781//# sourceMappingURL=parseoptions.js.map
2782;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/parsestring.js
2783
2784
2785
2786
2787
2788function parseString(rfcString) {
2789    var options = rfcString
2790        .split('\n')
2791        .map(parseLine)
2792        .filter(function (x) { return x !== null; });
2793    return __assign(__assign({}, options[0]), options[1]);
2794}
2795function parseDtstart(line) {
2796    var options = {};
2797    var dtstartWithZone = /DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)/i.exec(line);
2798    if (!dtstartWithZone) {
2799        return options;
2800    }
2801    var tzid = dtstartWithZone[1], dtstart = dtstartWithZone[2];
2802    if (tzid) {
2803        options.tzid = tzid;
2804    }
2805    options.dtstart = untilStringToDate(dtstart);
2806    return options;
2807}
2808function parseLine(rfcString) {
2809    rfcString = rfcString.replace(/^\s+|\s+$/, '');
2810    if (!rfcString.length)
2811        return null;
2812    var header = /^([A-Z]+?)[:;]/.exec(rfcString.toUpperCase());
2813    if (!header) {
2814        return parseRrule(rfcString);
2815    }
2816    var key = header[1];
2817    switch (key.toUpperCase()) {
2818        case 'RRULE':
2819        case 'EXRULE':
2820            return parseRrule(rfcString);
2821        case 'DTSTART':
2822            return parseDtstart(rfcString);
2823        default:
2824            throw new Error("Unsupported RFC prop ".concat(key, " in ").concat(rfcString));
2825    }
2826}
2827function parseRrule(line) {
2828    var strippedLine = line.replace(/^RRULE:/i, '');
2829    var options = parseDtstart(strippedLine);
2830    var attrs = line.replace(/^(?:RRULE|EXRULE):/i, '').split(';');
2831    attrs.forEach(function (attr) {
2832        var _a = attr.split('='), key = _a[0], value = _a[1];
2833        switch (key.toUpperCase()) {
2834            case 'FREQ':
2835                options.freq = Frequency[value.toUpperCase()];
2836                break;
2837            case 'WKST':
2838                options.wkst = Days[value.toUpperCase()];
2839                break;
2840            case 'COUNT':
2841            case 'INTERVAL':
2842            case 'BYSETPOS':
2843            case 'BYMONTH':
2844            case 'BYMONTHDAY':
2845            case 'BYYEARDAY':
2846            case 'BYWEEKNO':
2847            case 'BYHOUR':
2848            case 'BYMINUTE':
2849            case 'BYSECOND':
2850                var num = parseNumber(value);
2851                var optionKey = key.toLowerCase();
2852                // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2853                // @ts-ignore
2854                options[optionKey] = num;
2855                break;
2856            case 'BYWEEKDAY':
2857            case 'BYDAY':
2858                options.byweekday = parseWeekday(value);
2859                break;
2860            case 'DTSTART':
2861            case 'TZID':
2862                // for backwards compatibility
2863                var dtstart = parseDtstart(line);
2864                options.tzid = dtstart.tzid;
2865                options.dtstart = dtstart.dtstart;
2866                break;
2867            case 'UNTIL':
2868                options.until = untilStringToDate(value);
2869                break;
2870            case 'BYEASTER':
2871                options.byeaster = Number(value);
2872                break;
2873            default:
2874                throw new Error("Unknown RRULE property '" + key + "'");
2875        }
2876    });
2877    return options;
2878}
2879function parseNumber(value) {
2880    if (value.indexOf(',') !== -1) {
2881        var values = value.split(',');
2882        return values.map(parseIndividualNumber);
2883    }
2884    return parseIndividualNumber(value);
2885}
2886function parseIndividualNumber(value) {
2887    if (/^[+-]?\d+$/.test(value)) {
2888        return Number(value);
2889    }
2890    return value;
2891}
2892function parseWeekday(value) {
2893    var days = value.split(',');
2894    return days.map(function (day) {
2895        if (day.length === 2) {
2896            // MO, TU, ...
2897            return Days[day]; // wday instanceof Weekday
2898        }
2899        // -1MO, +3FR, 1SO, 13TU ...
2900        var parts = day.match(/^([+-]?\d{1,2})([A-Z]{2})$/);
2901        if (!parts || parts.length < 3) {
2902            throw new SyntaxError("Invalid weekday string: ".concat(day));
2903        }
2904        var n = Number(parts[1]);
2905        var wdaypart = parts[2];
2906        var wday = Days[wdaypart].weekday;
2907        return new Weekday(wday, n);
2908    });
2909}
2910//# sourceMappingURL=parsestring.js.map
2911;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/datewithzone.js
2912
2913var DateWithZone = /** @class */ (function () {
2914    function DateWithZone(date, tzid) {
2915        if (isNaN(date.getTime())) {
2916            throw new RangeError('Invalid date passed to DateWithZone');
2917        }
2918        this.date = date;
2919        this.tzid = tzid;
2920    }
2921    Object.defineProperty(DateWithZone.prototype, "isUTC", {
2922        get: function () {
2923            return !this.tzid || this.tzid.toUpperCase() === 'UTC';
2924        },
2925        enumerable: false,
2926        configurable: true
2927    });
2928    DateWithZone.prototype.toString = function () {
2929        var datestr = timeToUntilString(this.date.getTime(), this.isUTC);
2930        if (!this.isUTC) {
2931            return ";TZID=".concat(this.tzid, ":").concat(datestr);
2932        }
2933        return ":".concat(datestr);
2934    };
2935    DateWithZone.prototype.getTime = function () {
2936        return this.date.getTime();
2937    };
2938    DateWithZone.prototype.rezonedDate = function () {
2939        if (this.isUTC) {
2940            return this.date;
2941        }
2942        return dateInTimeZone(this.date, this.tzid);
2943    };
2944    return DateWithZone;
2945}());
2946
2947//# sourceMappingURL=datewithzone.js.map
2948;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/optionstostring.js
2949
2950
2951
2952
2953
2954function optionsToString(options) {
2955    var rrule = [];
2956    var dtstart = '';
2957    var keys = Object.keys(options);
2958    var defaultKeys = Object.keys(DEFAULT_OPTIONS);
2959    for (var i = 0; i < keys.length; i++) {
2960        if (keys[i] === 'tzid')
2961            continue;
2962        if (!includes(defaultKeys, keys[i]))
2963            continue;
2964        var key = keys[i].toUpperCase();
2965        var value = options[keys[i]];
2966        var outValue = '';
2967        if (!isPresent(value) || (isArray(value) && !value.length))
2968            continue;
2969        switch (key) {
2970            case 'FREQ':
2971                outValue = RRule.FREQUENCIES[options.freq];
2972                break;
2973            case 'WKST':
2974                if (isNumber(value)) {
2975                    outValue = new Weekday(value).toString();
2976                }
2977                else {
2978                    outValue = value.toString();
2979                }
2980                break;
2981            case 'BYWEEKDAY':
2982                /*
2983                  NOTE: BYWEEKDAY is a special case.
2984                  RRule() deconstructs the rule.options.byweekday array
2985                  into an array of Weekday arguments.
2986                  On the other hand, rule.origOptions is an array of Weekdays.
2987                  We need to handle both cases here.
2988                  It might be worth change RRule to keep the Weekdays.
2989        
2990                  Also, BYWEEKDAY (used by RRule) vs. BYDAY (RFC)
2991        
2992                  */
2993                key = 'BYDAY';
2994                outValue = toArray(value)
2995                    .map(function (wday) {
2996                    if (wday instanceof Weekday) {
2997                        return wday;
2998                    }
2999                    if (isArray(wday)) {
3000                        return new Weekday(wday[0], wday[1]);
3001                    }
3002                    return new Weekday(wday);
3003                })
3004                    .toString();
3005                break;
3006            case 'DTSTART':
3007                dtstart = buildDtstart(value, options.tzid);
3008                break;
3009            case 'UNTIL':
3010                outValue = timeToUntilString(value, !options.tzid);
3011                break;
3012            default:
3013                if (isArray(value)) {
3014                    var strValues = [];
3015                    for (var j = 0; j < value.length; j++) {
3016                        strValues[j] = String(value[j]);
3017                    }
3018                    outValue = strValues.toString();
3019                }
3020                else {
3021                    outValue = String(value);
3022                }
3023        }
3024        if (outValue) {
3025            rrule.push([key, outValue]);
3026        }
3027    }
3028    var rules = rrule
3029        .map(function (_a) {
3030        var key = _a[0], value = _a[1];
3031        return "".concat(key, "=").concat(value.toString());
3032    })
3033        .join(';');
3034    var ruleString = '';
3035    if (rules !== '') {
3036        ruleString = "RRULE:".concat(rules);
3037    }
3038    return [dtstart, ruleString].filter(function (x) { return !!x; }).join('\n');
3039}
3040function buildDtstart(dtstart, tzid) {
3041    if (!dtstart) {
3042        return '';
3043    }
3044    return 'DTSTART' + new DateWithZone(new Date(dtstart), tzid).toString();
3045}
3046//# sourceMappingURL=optionstostring.js.map
3047;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/cache.js
3048
3049
3050
3051function argsMatch(left, right) {
3052    if (Array.isArray(left)) {
3053        if (!Array.isArray(right))
3054            return false;
3055        if (left.length !== right.length)
3056            return false;
3057        return left.every(function (date, i) { return date.getTime() === right[i].getTime(); });
3058    }
3059    if (left instanceof Date) {
3060        return right instanceof Date && left.getTime() === right.getTime();
3061    }
3062    return left === right;
3063}
3064var Cache = /** @class */ (function () {
3065    function Cache() {
3066        this.all = false;
3067        this.before = [];
3068        this.after = [];
3069        this.between = [];
3070    }
3071    /**
3072     * @param {String} what - all/before/after/between
3073     * @param {Array,Date} value - an array of dates, one date, or null
3074     * @param {Object?} args - _iter arguments
3075     */
3076    Cache.prototype._cacheAdd = function (what, value, args) {
3077        if (value) {
3078            value = value instanceof Date ? dateutil_clone(value) : cloneDates(value);
3079        }
3080        if (what === 'all') {
3081            this.all = value;
3082        }
3083        else {
3084            args._value = value;
3085            this[what].push(args);
3086        }
3087    };
3088    /**
3089     * @return false - not in the cache
3090     * @return null  - cached, but zero occurrences (before/after)
3091     * @return Date  - cached (before/after)
3092     * @return []    - cached, but zero occurrences (all/between)
3093     * @return [Date1, DateN] - cached (all/between)
3094     */
3095    Cache.prototype._cacheGet = function (what, args) {
3096        var cached = false;
3097        var argsKeys = args ? Object.keys(args) : [];
3098        var findCacheDiff = function (item) {
3099            for (var i = 0; i < argsKeys.length; i++) {
3100                var key = argsKeys[i];
3101                if (!argsMatch(args[key], item[key])) {
3102                    return true;
3103                }
3104            }
3105            return false;
3106        };
3107        var cachedObject = this[what];
3108        if (what === 'all') {
3109            cached = this.all;
3110        }
3111        else if (isArray(cachedObject)) {
3112            // Let's see whether we've already called the
3113            // 'what' method with the same 'args'
3114            for (var i = 0; i < cachedObject.length; i++) {
3115                var item = cachedObject[i];
3116                if (argsKeys.length && findCacheDiff(item))
3117                    continue;
3118                cached = item._value;
3119                break;
3120            }
3121        }
3122        if (!cached && this.all) {
3123            // Not in the cache, but we already know all the occurrences,
3124            // so we can find the correct dates from the cached ones.
3125            var iterResult = new iterresult(what, args);
3126            for (var i = 0; i < this.all.length; i++) {
3127                if (!iterResult.accept(this.all[i]))
3128                    break;
3129            }
3130            cached = iterResult.getValue();
3131            this._cacheAdd(what, cached, args);
3132        }
3133        return isArray(cached)
3134            ? cloneDates(cached)
3135            : cached instanceof Date
3136                ? dateutil_clone(cached)
3137                : cached;
3138    };
3139    return Cache;
3140}());
3141
3142//# sourceMappingURL=cache.js.map
3143;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/masks.js
3144
3145
3146// =============================================================================
3147// Date masks
3148// =============================================================================
3149// Every mask is 7 days longer to handle cross-year weekly periods.
3150var M365MASK = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], repeat(1, 31), true), repeat(2, 28), true), repeat(3, 31), true), repeat(4, 30), true), repeat(5, 31), true), repeat(6, 30), true), repeat(7, 31), true), repeat(8, 31), true), repeat(9, 30), true), repeat(10, 31), true), repeat(11, 30), true), repeat(12, 31), true), repeat(1, 7), true);
3151var M366MASK = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], repeat(1, 31), true), repeat(2, 29), true), repeat(3, 31), true), repeat(4, 30), true), repeat(5, 31), true), repeat(6, 30), true), repeat(7, 31), true), repeat(8, 31), true), repeat(9, 30), true), repeat(10, 31), true), repeat(11, 30), true), repeat(12, 31), true), repeat(1, 7), true);
3152var M28 = range(1, 29);
3153var M29 = range(1, 30);
3154var M30 = range(1, 31);
3155var M31 = range(1, 32);
3156var MDAY366MASK = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], M31, true), M29, true), M31, true), M30, true), M31, true), M30, true), M31, true), M31, true), M30, true), M31, true), M30, true), M31, true), M31.slice(0, 7), true);
3157var MDAY365MASK = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], M31, true), M28, true), M31, true), M30, true), M31, true), M30, true), M31, true), M31, true), M30, true), M31, true), M30, true), M31, true), M31.slice(0, 7), true);
3158var NM28 = range(-28, 0);
3159var NM29 = range(-29, 0);
3160var NM30 = range(-30, 0);
3161var NM31 = range(-31, 0);
3162var NMDAY366MASK = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], NM31, true), NM29, true), NM31, true), NM30, true), NM31, true), NM30, true), NM31, true), NM31, true), NM30, true), NM31, true), NM30, true), NM31, true), NM31.slice(0, 7), true);
3163var NMDAY365MASK = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], NM31, true), NM28, true), NM31, true), NM30, true), NM31, true), NM30, true), NM31, true), NM31, true), NM30, true), NM31, true), NM30, true), NM31, true), NM31.slice(0, 7), true);
3164var M366RANGE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
3165var M365RANGE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
3166var WDAYMASK = (function () {
3167    var wdaymask = [];
3168    for (var i = 0; i < 55; i++)
3169        wdaymask = wdaymask.concat(range(7));
3170    return wdaymask;
3171})();
3172
3173//# sourceMappingURL=masks.js.map
3174;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iterinfo/yearinfo.js
3175
3176
3177
3178
3179function rebuildYear(year, options) {
3180    var firstyday = datetime(year, 1, 1);
3181    var yearlen = isLeapYear(year) ? 366 : 365;
3182    var nextyearlen = isLeapYear(year + 1) ? 366 : 365;
3183    var yearordinal = toOrdinal(firstyday);
3184    var yearweekday = getWeekday(firstyday);
3185    var result = __assign(__assign({ yearlen: yearlen, nextyearlen: nextyearlen, yearordinal: yearordinal, yearweekday: yearweekday }, baseYearMasks(year)), { wnomask: null });
3186    if (empty(options.byweekno)) {
3187        return result;
3188    }
3189    result.wnomask = repeat(0, yearlen + 7);
3190    var firstwkst;
3191    var wyearlen;
3192    var no1wkst = (firstwkst = pymod(7 - yearweekday + options.wkst, 7));
3193    if (no1wkst >= 4) {
3194        no1wkst = 0;
3195        // Number of days in the year, plus the days we got
3196        // from last year.
3197        wyearlen = result.yearlen + pymod(yearweekday - options.wkst, 7);
3198    }
3199    else {
3200        // Number of days in the year, minus the days we
3201        // left in last year.
3202        wyearlen = yearlen - no1wkst;
3203    }
3204    var div = Math.floor(wyearlen / 7);
3205    var mod = pymod(wyearlen, 7);
3206    var numweeks = Math.floor(div + mod / 4);
3207    for (var j = 0; j < options.byweekno.length; j++) {
3208        var n = options.byweekno[j];
3209        if (n < 0) {
3210            n += numweeks + 1;
3211        }
3212        if (!(n > 0 && n <= numweeks)) {
3213            continue;
3214        }
3215        var i = void 0;
3216        if (n > 1) {
3217            i = no1wkst + (n - 1) * 7;
3218            if (no1wkst !== firstwkst) {
3219                i -= 7 - firstwkst;
3220            }
3221        }
3222        else {
3223            i = no1wkst;
3224        }
3225        for (var k = 0; k < 7; k++) {
3226            result.wnomask[i] = 1;
3227            i++;
3228            if (result.wdaymask[i] === options.wkst)
3229                break;
3230        }
3231    }
3232    if (includes(options.byweekno, 1)) {
3233        // Check week number 1 of next year as well
3234        // orig-TODO : Check -numweeks for next year.
3235        var i = no1wkst + numweeks * 7;
3236        if (no1wkst !== firstwkst)
3237            i -= 7 - firstwkst;
3238        if (i < yearlen) {
3239            // If week starts in next year, we
3240            // don't care about it.
3241            for (var j = 0; j < 7; j++) {
3242                result.wnomask[i] = 1;
3243                i += 1;
3244                if (result.wdaymask[i] === options.wkst)
3245                    break;
3246            }
3247        }
3248    }
3249    if (no1wkst) {
3250        // Check last week number of last year as
3251        // well. If no1wkst is 0, either the year
3252        // started on week start, or week number 1
3253        // got days from last year, so there are no
3254        // days from last year's last week number in
3255        // this year.
3256        var lnumweeks = void 0;
3257        if (!includes(options.byweekno, -1)) {
3258            var lyearweekday = getWeekday(datetime(year - 1, 1, 1));
3259            var lno1wkst = pymod(7 - lyearweekday.valueOf() + options.wkst, 7);
3260            var lyearlen = isLeapYear(year - 1) ? 366 : 365;
3261            var weekst = void 0;
3262            if (lno1wkst >= 4) {
3263                lno1wkst = 0;
3264                weekst = lyearlen + pymod(lyearweekday - options.wkst, 7);
3265            }
3266            else {
3267                weekst = yearlen - no1wkst;
3268            }
3269            lnumweeks = Math.floor(52 + pymod(weekst, 7) / 4);
3270        }
3271        else {
3272            lnumweeks = -1;
3273        }
3274        if (includes(options.byweekno, lnumweeks)) {
3275            for (var i = 0; i < no1wkst; i++)
3276                result.wnomask[i] = 1;
3277        }
3278    }
3279    return result;
3280}
3281function baseYearMasks(year) {
3282    var yearlen = isLeapYear(year) ? 366 : 365;
3283    var firstyday = datetime(year, 1, 1);
3284    var wday = getWeekday(firstyday);
3285    if (yearlen === 365) {
3286        return {
3287            mmask: M365MASK,
3288            mdaymask: MDAY365MASK,
3289            nmdaymask: NMDAY365MASK,
3290            wdaymask: WDAYMASK.slice(wday),
3291            mrange: M365RANGE,
3292        };
3293    }
3294    return {
3295        mmask: M366MASK,
3296        mdaymask: MDAY366MASK,
3297        nmdaymask: NMDAY366MASK,
3298        wdaymask: WDAYMASK.slice(wday),
3299        mrange: M366RANGE,
3300    };
3301}
3302//# sourceMappingURL=yearinfo.js.map
3303;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iterinfo/monthinfo.js
3304
3305
3306function rebuildMonth(year, month, yearlen, mrange, wdaymask, options) {
3307    var result = {
3308        lastyear: year,
3309        lastmonth: month,
3310        nwdaymask: [],
3311    };
3312    var ranges = [];
3313    if (options.freq === RRule.YEARLY) {
3314        if (empty(options.bymonth)) {
3315            ranges = [[0, yearlen]];
3316        }
3317        else {
3318            for (var j = 0; j < options.bymonth.length; j++) {
3319                month = options.bymonth[j];
3320                ranges.push(mrange.slice(month - 1, month + 1));
3321            }
3322        }
3323    }
3324    else if (options.freq === RRule.MONTHLY) {
3325        ranges = [mrange.slice(month - 1, month + 1)];
3326    }
3327    if (empty(ranges)) {
3328        return result;
3329    }
3330    // Weekly frequency won't get here, so we may not
3331    // care about cross-year weekly periods.
3332    result.nwdaymask = repeat(0, yearlen);
3333    for (var j = 0; j < ranges.length; j++) {
3334        var rang = ranges[j];
3335        var first = rang[0];
3336        var last = rang[1] - 1;
3337        for (var k = 0; k < options.bynweekday.length; k++) {
3338            var i = void 0;
3339            var _a = options.bynweekday[k], wday = _a[0], n = _a[1];
3340            if (n < 0) {
3341                i = last + (n + 1) * 7;
3342                i -= pymod(wdaymask[i] - wday, 7);
3343            }
3344            else {
3345                i = first + (n - 1) * 7;
3346                i += pymod(7 - wdaymask[i] + wday, 7);
3347            }
3348            if (first <= i && i <= last)
3349                result.nwdaymask[i] = 1;
3350        }
3351    }
3352    return result;
3353}
3354//# sourceMappingURL=monthinfo.js.map
3355;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iterinfo/easter.js
3356function easter(y, offset) {
3357    if (offset === void 0) { offset = 0; }
3358    var a = y % 19;
3359    var b = Math.floor(y / 100);
3360    var c = y % 100;
3361    var d = Math.floor(b / 4);
3362    var e = b % 4;
3363    var f = Math.floor((b + 8) / 25);
3364    var g = Math.floor((b - f + 1) / 3);
3365    var h = Math.floor(19 * a + b - d - g + 15) % 30;
3366    var i = Math.floor(c / 4);
3367    var k = c % 4;
3368    var l = Math.floor(32 + 2 * e + 2 * i - h - k) % 7;
3369    var m = Math.floor((a + 11 * h + 22 * l) / 451);
3370    var month = Math.floor((h + l - 7 * m + 114) / 31);
3371    var day = ((h + l - 7 * m + 114) % 31) + 1;
3372    var date = Date.UTC(y, month - 1, day + offset);
3373    var yearStart = Date.UTC(y, 0, 1);
3374    return [Math.ceil((date - yearStart) / (1000 * 60 * 60 * 24))];
3375}
3376//# sourceMappingURL=easter.js.map
3377;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iterinfo/index.js
3378
3379
3380
3381
3382
3383
3384
3385// =============================================================================
3386// Iterinfo
3387// =============================================================================
3388var Iterinfo = /** @class */ (function () {
3389    // eslint-disable-next-line no-empty-function
3390    function Iterinfo(options) {
3391        this.options = options;
3392    }
3393    Iterinfo.prototype.rebuild = function (year, month) {
3394        var options = this.options;
3395        if (year !== this.lastyear) {
3396            this.yearinfo = rebuildYear(year, options);
3397        }
3398        if (notEmpty(options.bynweekday) &&
3399            (month !== this.lastmonth || year !== this.lastyear)) {
3400            var _a = this.yearinfo, yearlen = _a.yearlen, mrange = _a.mrange, wdaymask = _a.wdaymask;
3401            this.monthinfo = rebuildMonth(year, month, yearlen, mrange, wdaymask, options);
3402        }
3403        if (isPresent(options.byeaster)) {
3404            this.eastermask = easter(year, options.byeaster);
3405        }
3406    };
3407    Object.defineProperty(Iterinfo.prototype, "lastyear", {
3408        get: function () {
3409            return this.monthinfo ? this.monthinfo.lastyear : null;
3410        },
3411        enumerable: false,
3412        configurable: true
3413    });
3414    Object.defineProperty(Iterinfo.prototype, "lastmonth", {
3415        get: function () {
3416            return this.monthinfo ? this.monthinfo.lastmonth : null;
3417        },
3418        enumerable: false,
3419        configurable: true
3420    });
3421    Object.defineProperty(Iterinfo.prototype, "yearlen", {
3422        get: function () {
3423            return this.yearinfo.yearlen;
3424        },
3425        enumerable: false,
3426        configurable: true
3427    });
3428    Object.defineProperty(Iterinfo.prototype, "yearordinal", {
3429        get: function () {
3430            return this.yearinfo.yearordinal;
3431        },
3432        enumerable: false,
3433        configurable: true
3434    });
3435    Object.defineProperty(Iterinfo.prototype, "mrange", {
3436        get: function () {
3437            return this.yearinfo.mrange;
3438        },
3439        enumerable: false,
3440        configurable: true
3441    });
3442    Object.defineProperty(Iterinfo.prototype, "wdaymask", {
3443        get: function () {
3444            return this.yearinfo.wdaymask;
3445        },
3446        enumerable: false,
3447        configurable: true
3448    });
3449    Object.defineProperty(Iterinfo.prototype, "mmask", {
3450        get: function () {
3451            return this.yearinfo.mmask;
3452        },
3453        enumerable: false,
3454        configurable: true
3455    });
3456    Object.defineProperty(Iterinfo.prototype, "wnomask", {
3457        get: function () {
3458            return this.yearinfo.wnomask;
3459        },
3460        enumerable: false,
3461        configurable: true
3462    });
3463    Object.defineProperty(Iterinfo.prototype, "nwdaymask", {
3464        get: function () {
3465            return this.monthinfo ? this.monthinfo.nwdaymask : [];
3466        },
3467        enumerable: false,
3468        configurable: true
3469    });
3470    Object.defineProperty(Iterinfo.prototype, "nextyearlen", {
3471        get: function () {
3472            return this.yearinfo.nextyearlen;
3473        },
3474        enumerable: false,
3475        configurable: true
3476    });
3477    Object.defineProperty(Iterinfo.prototype, "mdaymask", {
3478        get: function () {
3479            return this.yearinfo.mdaymask;
3480        },
3481        enumerable: false,
3482        configurable: true
3483    });
3484    Object.defineProperty(Iterinfo.prototype, "nmdaymask", {
3485        get: function () {
3486            return this.yearinfo.nmdaymask;
3487        },
3488        enumerable: false,
3489        configurable: true
3490    });
3491    Iterinfo.prototype.ydayset = function () {
3492        return [range(this.yearlen), 0, this.yearlen];
3493    };
3494    Iterinfo.prototype.mdayset = function (_, month) {
3495        var start = this.mrange[month - 1];
3496        var end = this.mrange[month];
3497        var set = repeat(null, this.yearlen);
3498        for (var i = start; i < end; i++)
3499            set[i] = i;
3500        return [set, start, end];
3501    };
3502    Iterinfo.prototype.wdayset = function (year, month, day) {
3503        // We need to handle cross-year weeks here.
3504        var set = repeat(null, this.yearlen + 7);
3505        var i = toOrdinal(datetime(year, month, day)) - this.yearordinal;
3506        var start = i;
3507        for (var j = 0; j < 7; j++) {
3508            set[i] = i;
3509            ++i;
3510            if (this.wdaymask[i] === this.options.wkst)
3511                break;
3512        }
3513        return [set, start, i];
3514    };
3515    Iterinfo.prototype.ddayset = function (year, month, day) {
3516        var set = repeat(null, this.yearlen);
3517        var i = toOrdinal(datetime(year, month, day)) - this.yearordinal;
3518        set[i] = i;
3519        return [set, i, i + 1];
3520    };
3521    Iterinfo.prototype.htimeset = function (hour, _, second, millisecond) {
3522        var _this = this;
3523        var set = [];
3524        this.options.byminute.forEach(function (minute) {
3525            set = set.concat(_this.mtimeset(hour, minute, second, millisecond));
3526        });
3527        sort(set);
3528        return set;
3529    };
3530    Iterinfo.prototype.mtimeset = function (hour, minute, _, millisecond) {
3531        var set = this.options.bysecond.map(function (second) { return new Time(hour, minute, second, millisecond); });
3532        sort(set);
3533        return set;
3534    };
3535    Iterinfo.prototype.stimeset = function (hour, minute, second, millisecond) {
3536        return [new Time(hour, minute, second, millisecond)];
3537    };
3538    Iterinfo.prototype.getdayset = function (freq) {
3539        switch (freq) {
3540            case Frequency.YEARLY:
3541                return this.ydayset.bind(this);
3542            case Frequency.MONTHLY:
3543                return this.mdayset.bind(this);
3544            case Frequency.WEEKLY:
3545                return this.wdayset.bind(this);
3546            case Frequency.DAILY:
3547                return this.ddayset.bind(this);
3548            default:
3549                return this.ddayset.bind(this);
3550        }
3551    };
3552    Iterinfo.prototype.gettimeset = function (freq) {
3553        switch (freq) {
3554            case Frequency.HOURLY:
3555                return this.htimeset.bind(this);
3556            case Frequency.MINUTELY:
3557                return this.mtimeset.bind(this);
3558            case Frequency.SECONDLY:
3559                return this.stimeset.bind(this);
3560        }
3561    };
3562    return Iterinfo;
3563}());
3564/* harmony default export */ const iterinfo = (Iterinfo);
3565//# sourceMappingURL=index.js.map
3566;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iter/poslist.js
3567
3568
3569function buildPoslist(bysetpos, timeset, start, end, ii, dayset) {
3570    var poslist = [];
3571    for (var j = 0; j < bysetpos.length; j++) {
3572        var daypos = void 0;
3573        var timepos = void 0;
3574        var pos = bysetpos[j];
3575        if (pos < 0) {
3576            daypos = Math.floor(pos / timeset.length);
3577            timepos = pymod(pos, timeset.length);
3578        }
3579        else {
3580            daypos = Math.floor((pos - 1) / timeset.length);
3581            timepos = pymod(pos - 1, timeset.length);
3582        }
3583        var tmp = [];
3584        for (var k = start; k < end; k++) {
3585            var val = dayset[k];
3586            if (!isPresent(val))
3587                continue;
3588            tmp.push(val);
3589        }
3590        var i = void 0;
3591        if (daypos < 0) {
3592            i = tmp.slice(daypos)[0];
3593        }
3594        else {
3595            i = tmp[daypos];
3596        }
3597        var time = timeset[timepos];
3598        var date = fromOrdinal(ii.yearordinal + i);
3599        var res = combine(date, time);
3600        // XXX: can this ever be in the array?
3601        // - compare the actual date instead?
3602        if (!includes(poslist, res))
3603            poslist.push(res);
3604    }
3605    sort(poslist);
3606    return poslist;
3607}
3608//# sourceMappingURL=poslist.js.map
3609;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iter/index.j
vendor: 5,629 bytes, lines 3609-3746
3609s
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619function iter(iterResult, options) {
3620    var dtstart = options.dtstart, freq = options.freq, interval = options.interval, until = options.until, bysetpos = options.bysetpos;
3621    var count = options.count;
3622    if (count === 0 || interval === 0) {
3623        return emitResult(iterResult);
3624    }
3625    var counterDate = DateTime.fromDate(dtstart);
3626    var ii = new iterinfo(options);
3627    ii.rebuild(counterDate.year, counterDate.month);
3628    var timeset = makeTimeset(ii, counterDate, options);
3629    for (;;) {
3630        var _a = ii.getdayset(freq)(counterDate.year, counterDate.month, counterDate.day), dayset = _a[0], start = _a[1], end = _a[2];
3631        var filtered = removeFilteredDays(dayset, start, end, ii, options);
3632        if (notEmpty(bysetpos)) {
3633            var poslist = buildPoslist(bysetpos, timeset, start, end, ii, dayset);
3634            for (var j = 0; j < poslist.length; j++) {
3635                var res = poslist[j];
3636                if (until && res > until) {
3637                    return emitResult(iterResult);
3638                }
3639                if (res >= dtstart) {
3640                    var rezonedDate = rezoneIfNeeded(res, options);
3641                    if (!iterResult.accept(rezonedDate)) {
3642                        return emitResult(iterResult);
3643                    }
3644                    if (count) {
3645                        --count;
3646                        if (!count) {
3647                            return emitResult(iterResult);
3648                        }
3649                    }
3650                }
3651            }
3652        }
3653        else {
3654            for (var j = start; j < end; j++) {
3655                var currentDay = dayset[j];
3656                if (!isPresent(currentDay)) {
3657                    continue;
3658                }
3659                var date = fromOrdinal(ii.yearordinal + currentDay);
3660                for (var k = 0; k < timeset.length; k++) {
3661                    var time = timeset[k];
3662                    var res = combine(date, time);
3663                    if (until && res > until) {
3664                        return emitResult(iterResult);
3665                    }
3666                    if (res >= dtstart) {
3667                        var rezonedDate = rezoneIfNeeded(res, options);
3668                        if (!iterResult.accept(rezonedDate)) {
3669                            return emitResult(iterResult);
3670                        }
3671                        if (count) {
3672                            --count;
3673                            if (!count) {
3674                                return emitResult(iterResult);
3675                            }
3676                        }
3677                    }
3678                }
3679            }
3680        }
3681        if (options.interval === 0) {
3682            return emitResult(iterResult);
3683        }
3684        // Handle frequency and interval
3685        counterDate.add(options, filtered);
3686        if (counterDate.year > MAXYEAR) {
3687            return emitResult(iterResult);
3688        }
3689        if (!freqIsDailyOrGreater(freq)) {
3690            timeset = ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, 0);
3691        }
3692        ii.rebuild(counterDate.year, counterDate.month);
3693    }
3694}
3695function isFiltered(ii, currentDay, options) {
3696    var bymonth = options.bymonth, byweekno = options.byweekno, byweekday = options.byweekday, byeaster = options.byeaster, bymonthday = options.bymonthday, bynmonthday = options.bynmonthday, byyearday = options.byyearday;
3697    return ((notEmpty(bymonth) && !includes(bymonth, ii.mmask[currentDay])) ||
3698        (notEmpty(byweekno) && !ii.wnomask[currentDay]) ||
3699        (notEmpty(byweekday) && !includes(byweekday, ii.wdaymask[currentDay])) ||
3700        (notEmpty(ii.nwdaymask) && !ii.nwdaymask[currentDay]) ||
3701        (byeaster !== null && !includes(ii.eastermask, currentDay)) ||
3702        ((notEmpty(bymonthday) || notEmpty(bynmonthday)) &&
3703            !includes(bymonthday, ii.mdaymask[currentDay]) &&
3704            !includes(bynmonthday, ii.nmdaymask[currentDay])) ||
3705        (notEmpty(byyearday) &&
3706            ((currentDay < ii.yearlen &&
3707                !includes(byyearday, currentDay + 1) &&
3708                !includes(byyearday, -ii.yearlen + currentDay)) ||
3709                (currentDay >= ii.yearlen &&
3710                    !includes(byyearday, currentDay + 1 - ii.yearlen) &&
3711                    !includes(byyearday, -ii.nextyearlen + currentDay - ii.yearlen)))));
3712}
3713function rezoneIfNeeded(date, options) {
3714    return new DateWithZone(date, options.tzid).rezonedDate();
3715}
3716function emitResult(iterResult) {
3717    return iterResult.getValue();
3718}
3719function removeFilteredDays(dayset, start, end, ii, options) {
3720    var filtered = false;
3721    for (var dayCounter = start; dayCounter < end; dayCounter++) {
3722        var currentDay = dayset[dayCounter];
3723        filtered = isFiltered(ii, currentDay, options);
3724        if (filtered)
3725            dayset[currentDay] = null;
3726    }
3727    return filtered;
3728}
3729function makeTimeset(ii, counterDate, options) {
3730    var freq = options.freq, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
3731    if (freqIsDailyOrGreater(freq)) {
3732        return buildTimeset(options);
3733    }
3734    if ((freq >= RRule.HOURLY &&
3735        notEmpty(byhour) &&
3736        !includes(byhour, counterDate.hour)) ||
3737        (freq >= RRule.MINUTELY &&
3738            notEmpty(byminute) &&
3739            !includes(byminute, counterDate.minute)) ||
3740        (freq >= RRule.SECONDLY &&
3741            notEmpty(bysecond) &&
3742            !includes(bysecond, counterDate.second))) {
3743        return [];
3744    }
3745    return ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, counterDate.millisecond);
3746}
vendor: 21,048 bytes, lines 3747-4413
3747//# sourceMappingURL=index.js.map
3748;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/rrule.js
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760// =============================================================================
3761// RRule
3762// =============================================================================
3763var Days = {
3764    MO: new Weekday(0),
3765    TU: new Weekday(1),
3766    WE: new Weekday(2),
3767    TH: new Weekday(3),
3768    FR: new Weekday(4),
3769    SA: new Weekday(5),
3770    SU: new Weekday(6),
3771};
3772var DEFAULT_OPTIONS = {
3773    freq: Frequency.YEARLY,
3774    dtstart: null,
3775    interval: 1,
3776    wkst: Days.MO,
3777    count: null,
3778    until: null,
3779    tzid: null,
3780    bysetpos: null,
3781    bymonth: null,
3782    bymonthday: null,
3783    bynmonthday: null,
3784    byyearday: null,
3785    byweekno: null,
3786    byweekday: null,
3787    bynweekday: null,
3788    byhour: null,
3789    byminute: null,
3790    bysecond: null,
3791    byeaster: null,
3792};
3793var defaultKeys = Object.keys(DEFAULT_OPTIONS);
3794/**
3795 *
3796 * @param {Options?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
3797 * - The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
3798 * @constructor
3799 */
3800var RRule = /** @class */ (function () {
3801    function RRule(options, noCache) {
3802        if (options === void 0) { options = {}; }
3803        if (noCache === void 0) { noCache = false; }
3804        // RFC string
3805        this._cache = noCache ? null : new Cache();
3806        // used by toString()
3807        this.origOptions = initializeOptions(options);
3808        var parsedOptions = parseOptions(options).parsedOptions;
3809        this.options = parsedOptions;
3810    }
3811    RRule.parseText = function (text, language) {
3812        return parseText(text, language);
3813    };
3814    RRule.fromText = function (text, language) {
3815        return fromText(text, language);
3816    };
3817    RRule.fromString = function (str) {
3818        return new RRule(RRule.parseString(str) || undefined);
3819    };
3820    RRule.prototype._iter = function (iterResult) {
3821        return iter(iterResult, this.options);
3822    };
3823    RRule.prototype._cacheGet = function (what, args) {
3824        if (!this._cache)
3825            return false;
3826        return this._cache._cacheGet(what, args);
3827    };
3828    RRule.prototype._cacheAdd = function (what, value, args) {
3829        if (!this._cache)
3830            return;
3831        return this._cache._cacheAdd(what, value, args);
3832    };
3833    /**
3834     * @param {Function} iterator - optional function that will be called
3835     * on each date that is added. It can return false
3836     * to stop the iteration.
3837     * @return Array containing all recurrences.
3838     */
3839    RRule.prototype.all = function (iterator) {
3840        if (iterator) {
3841            return this._iter(new callbackiterresult('all', {}, iterator));
3842        }
3843        var result = this._cacheGet('all');
3844        if (result === false) {
3845            result = this._iter(new iterresult('all', {}));
3846            this._cacheAdd('all', result);
3847        }
3848        return result;
3849    };
3850    /**
3851     * Returns all the occurrences of the rrule between after and before.
3852     * The inc keyword defines what happens if after and/or before are
3853     * themselves occurrences. With inc == True, they will be included in the
3854     * list, if they are found in the recurrence set.
3855     *
3856     * @return Array
3857     */
3858    RRule.prototype.between = function (after, before, inc, iterator) {
3859        if (inc === void 0) { inc = false; }
3860        if (!isValidDate(after) || !isValidDate(before)) {
3861            throw new Error('Invalid date passed in to RRule.between');
3862        }
3863        var args = {
3864            before: before,
3865            after: after,
3866            inc: inc,
3867        };
3868        if (iterator) {
3869            return this._iter(new callbackiterresult('between', args, iterator));
3870        }
3871        var result = this._cacheGet('between', args);
3872        if (result === false) {
3873            result = this._iter(new iterresult('between', args));
3874            this._cacheAdd('between', result, args);
3875        }
3876        return result;
3877    };
3878    /**
3879     * Returns the last recurrence before the given datetime instance.
3880     * The inc keyword defines what happens if dt is an occurrence.
3881     * With inc == True, if dt itself is an occurrence, it will be returned.
3882     *
3883     * @return Date or null
3884     */
3885    RRule.prototype.before = function (dt, inc) {
3886        if (inc === void 0) { inc = false; }
3887        if (!isValidDate(dt)) {
3888            throw new Error('Invalid date passed in to RRule.before');
3889        }
3890        var args = { dt: dt, inc: inc };
3891        var result = this._cacheGet('before', args);
3892        if (result === false) {
3893            result = this._iter(new iterresult('before', args));
3894            this._cacheAdd('before', result, args);
3895        }
3896        return result;
3897    };
3898    /**
3899     * Returns the first recurrence after the given datetime instance.
3900     * The inc keyword defines what happens if dt is an occurrence.
3901     * With inc == True, if dt itself is an occurrence, it will be returned.
3902     *
3903     * @return Date or null
3904     */
3905    RRule.prototype.after = function (dt, inc) {
3906        if (inc === void 0) { inc = false; }
3907        if (!isValidDate(dt)) {
3908            throw new Error('Invalid date passed in to RRule.after');
3909        }
3910        var args = { dt: dt, inc: inc };
3911        var result = this._cacheGet('after', args);
3912        if (result === false) {
3913            result = this._iter(new iterresult('after', args));
3914            this._cacheAdd('after', result, args);
3915        }
3916        return result;
3917    };
3918    /**
3919     * Returns the number of recurrences in this set. It will have go trough
3920     * the whole recurrence, if this hasn't been done before.
3921     */
3922    RRule.prototype.count = function () {
3923        return this.all().length;
3924    };
3925    /**
3926     * Converts the rrule into its string representation
3927     *
3928     * @see <http://www.ietf.org/rfc/rfc2445.txt>
3929     * @return String
3930     */
3931    RRule.prototype.toString = function () {
3932        return optionsToString(this.origOptions);
3933    };
3934    /**
3935     * Will convert all rules described in nlp:ToText
3936     * to text.
3937     */
3938    RRule.prototype.toText = function (gettext, language, dateFormatter) {
3939        return toText(this, gettext, language, dateFormatter);
3940    };
3941    RRule.prototype.isFullyConvertibleToText = function () {
3942        return isFullyConvertible(this);
3943    };
3944    /**
3945     * @return a RRule instance with the same freq and options
3946     * as this one (cache is not cloned)
3947     */
3948    RRule.prototype.clone = function () {
3949        return new RRule(this.origOptions);
3950    };
3951    // RRule class 'constants'
3952    RRule.FREQUENCIES = [
3953        'YEARLY',
3954        'MONTHLY',
3955        'WEEKLY',
3956        'DAILY',
3957        'HOURLY',
3958        'MINUTELY',
3959        'SECONDLY',
3960    ];
3961    RRule.YEARLY = Frequency.YEARLY;
3962    RRule.MONTHLY = Frequency.MONTHLY;
3963    RRule.WEEKLY = Frequency.WEEKLY;
3964    RRule.DAILY = Frequency.DAILY;
3965    RRule.HOURLY = Frequency.HOURLY;
3966    RRule.MINUTELY = Frequency.MINUTELY;
3967    RRule.SECONDLY = Frequency.SECONDLY;
3968    RRule.MO = Days.MO;
3969    RRule.TU = Days.TU;
3970    RRule.WE = Days.WE;
3971    RRule.TH = Days.TH;
3972    RRule.FR = Days.FR;
3973    RRule.SA = Days.SA;
3974    RRule.SU = Days.SU;
3975    RRule.parseString = parseString;
3976    RRule.optionsToString = optionsToString;
3977    return RRule;
3978}());
3979
3980//# sourceMappingURL=rrule.js.map
3981;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/iterset.js
3982
3983
3984
3985function iterSet(iterResult, _rrule, _exrule, _rdate, _exdate, tzid) {
3986    var _exdateHash = {};
3987    var _accept = iterResult.accept;
3988    function evalExdate(after, before) {
3989        _exrule.forEach(function (rrule) {
3990            rrule.between(after, before, true).forEach(function (date) {
3991                _exdateHash[Number(date)] = true;
3992            });
3993        });
3994    }
3995    _exdate.forEach(function (date) {
3996        var zonedDate = new DateWithZone(date, tzid).rezonedDate();
3997        _exdateHash[Number(zonedDate)] = true;
3998    });
3999    iterResult.accept = function (date) {
4000        var dt = Number(date);
4001        if (isNaN(dt))
4002            return _accept.call(this, date);
4003        if (!_exdateHash[dt]) {
4004            evalExdate(new Date(dt - 1), new Date(dt + 1));
4005            if (!_exdateHash[dt]) {
4006                _exdateHash[dt] = true;
4007                return _accept.call(this, date);
4008            }
4009        }
4010        return true;
4011    };
4012    if (iterResult.method === 'between') {
4013        evalExdate(iterResult.args.after, iterResult.args.before);
4014        iterResult.accept = function (date) {
4015            var dt = Number(date);
4016            if (!_exdateHash[dt]) {
4017                _exdateHash[dt] = true;
4018                return _accept.call(this, date);
4019            }
4020            return true;
4021        };
4022    }
4023    for (var i = 0; i < _rdate.length; i++) {
4024        var zonedDate = new DateWithZone(_rdate[i], tzid).rezonedDate();
4025        if (!iterResult.accept(new Date(zonedDate.getTime())))
4026            break;
4027    }
4028    _rrule.forEach(function (rrule) {
4029        iter(iterResult, rrule.options);
4030    });
4031    var res = iterResult._result;
4032    sort(res);
4033    switch (iterResult.method) {
4034        case 'all':
4035        case 'between':
4036            return res;
4037        case 'before':
4038            return ((res.length && res[res.length - 1]) || null);
4039        case 'after':
4040        default:
4041            return ((res.length && res[0]) || null);
4042    }
4043}
4044//# sourceMappingURL=iterset.js.map
4045;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/rrulestr.js
4046
4047
4048
4049
4050
4051
4052/**
4053 * RRuleStr
4054 * To parse a set of rrule strings
4055 */
4056var rrulestr_DEFAULT_OPTIONS = {
4057    dtstart: null,
4058    cache: false,
4059    unfold: false,
4060    forceset: false,
4061    compatible: false,
4062    tzid: null,
4063};
4064function parseInput(s, options) {
4065    var rrulevals = [];
4066    var rdatevals = [];
4067    var exrulevals = [];
4068    var exdatevals = [];
4069    var parsedDtstart = parseDtstart(s);
4070    var dtstart = parsedDtstart.dtstart;
4071    var tzid = parsedDtstart.tzid;
4072    var lines = splitIntoLines(s, options.unfold);
4073    lines.forEach(function (line) {
4074        var _a;
4075        if (!line)
4076            return;
4077        var _b = breakDownLine(line), name = _b.name, parms = _b.parms, value = _b.value;
4078        switch (name.toUpperCase()) {
4079            case 'RRULE':
4080                if (parms.length) {
4081                    throw new Error("unsupported RRULE parm: ".concat(parms.join(',')));
4082                }
4083                rrulevals.push(parseString(line));
4084                break;
4085            case 'RDATE':
4086                var _c = (_a = /RDATE(?:;TZID=([^:=]+))?/i.exec(line)) !== null && _a !== void 0 ? _a : [], rdateTzid = _c[1];
4087                if (rdateTzid && !tzid) {
4088                    tzid = rdateTzid;
4089                }
4090                rdatevals = rdatevals.concat(parseRDate(value, parms));
4091                break;
4092            case 'EXRULE':
4093                if (parms.length) {
4094                    throw new Error("unsupported EXRULE parm: ".concat(parms.join(',')));
4095                }
4096                exrulevals.push(parseString(value));
4097                break;
4098            case 'EXDATE':
4099                exdatevals = exdatevals.concat(parseRDate(value, parms));
4100                break;
4101            case 'DTSTART':
4102                break;
4103            default:
4104                throw new Error('unsupported property: ' + name);
4105        }
4106    });
4107    return {
4108        dtstart: dtstart,
4109        tzid: tzid,
4110        rrulevals: rrulevals,
4111        rdatevals: rdatevals,
4112        exrulevals: exrulevals,
4113        exdatevals: exdatevals,
4114    };
4115}
4116function buildRule(s, options) {
4117    var _a = parseInput(s, options), rrulevals = _a.rrulevals, rdatevals = _a.rdatevals, exrulevals = _a.exrulevals, exdatevals = _a.exdatevals, dtstart = _a.dtstart, tzid = _a.tzid;
4118    var noCache = options.cache === false;
4119    if (options.compatible) {
4120        options.forceset = true;
4121        options.unfold = true;
4122    }
4123    if (options.forceset ||
4124        rrulevals.length > 1 ||
4125        rdatevals.length ||
4126        exrulevals.length ||
4127        exdatevals.length) {
4128        var rset_1 = new RRuleSet(noCache);
4129        rset_1.dtstart(dtstart);
4130        rset_1.tzid(tzid || undefined);
4131        rrulevals.forEach(function (val) {
4132            rset_1.rrule(new RRule(groomRruleOptions(val, dtstart, tzid), noCache));
4133        });
4134        rdatevals.forEach(function (date) {
4135            rset_1.rdate(date);
4136        });
4137        exrulevals.forEach(function (val) {
4138            rset_1.exrule(new RRule(groomRruleOptions(val, dtstart, tzid), noCache));
4139        });
4140        exdatevals.forEach(function (date) {
4141            rset_1.exdate(date);
4142        });
4143        if (options.compatible && options.dtstart)
4144            rset_1.rdate(dtstart);
4145        return rset_1;
4146    }
4147    var val = rrulevals[0] || {};
4148    return new RRule(groomRruleOptions(val, val.dtstart || options.dtstart || dtstart, val.tzid || options.tzid || tzid), noCache);
4149}
4150function rrulestr(s, options) {
4151    if (options === void 0) { options = {}; }
4152    return buildRule(s, rrulestr_initializeOptions(options));
4153}
4154function groomRruleOptions(val, dtstart, tzid) {
4155    return __assign(__assign({}, val), { dtstart: dtstart, tzid: tzid });
4156}
4157function rrulestr_initializeOptions(options) {
4158    var invalid = [];
4159    var keys = Object.keys(options);
4160    var defaultKeys = Object.keys(rrulestr_DEFAULT_OPTIONS);
4161    keys.forEach(function (key) {
4162        if (!includes(defaultKeys, key))
4163            invalid.push(key);
4164    });
4165    if (invalid.length) {
4166        throw new Error('Invalid options: ' + invalid.join(', '));
4167    }
4168    return __assign(__assign({}, rrulestr_DEFAULT_OPTIONS), options);
4169}
4170function extractName(line) {
4171    if (line.indexOf(':') === -1) {
4172        return {
4173            name: 'RRULE',
4174            value: line,
4175        };
4176    }
4177    var _a = split(line, ':', 1), name = _a[0], value = _a[1];
4178    return {
4179        name: name,
4180        value: value,
4181    };
4182}
4183function breakDownLine(line) {
4184    var _a = extractName(line), name = _a.name, value = _a.value;
4185    var parms = name.split(';');
4186    if (!parms)
4187        throw new Error('empty property name');
4188    return {
4189        name: parms[0].toUpperCase(),
4190        parms: parms.slice(1),
4191        value: value,
4192    };
4193}
4194function splitIntoLines(s, unfold) {
4195    if (unfold === void 0) { unfold = false; }
4196    s = s && s.trim();
4197    if (!s)
4198        throw new Error('Invalid empty string');
4199    // More info about 'unfold' option
4200    // Go head to http://www.ietf.org/rfc/rfc2445.txt
4201    if (!unfold) {
4202        return s.split(/\s/);
4203    }
4204    var lines = s.split('\n');
4205    var i = 0;
4206    while (i < lines.length) {
4207        // TODO
4208        var line = (lines[i] = lines[i].replace(/\s+$/g, ''));
4209        if (!line) {
4210            lines.splice(i, 1);
4211        }
4212        else if (i > 0 && line[0] === ' ') {
4213            lines[i - 1] += line.slice(1);
4214            lines.splice(i, 1);
4215        }
4216        else {
4217            i += 1;
4218        }
4219    }
4220    return lines;
4221}
4222function validateDateParm(parms) {
4223    parms.forEach(function (parm) {
4224        if (!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(parm)) {
4225            throw new Error('unsupported RDATE/EXDATE parm: ' + parm);
4226        }
4227    });
4228}
4229function parseRDate(rdateval, parms) {
4230    validateDateParm(parms);
4231    return rdateval.split(',').map(function (datestr) { return untilStringToDate(datestr); });
4232}
4233//# sourceMappingURL=rrulestr.js.map
4234;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/rruleset.js
4235
4236
4237
4238
4239
4240
4241
4242function createGetterSetter(fieldName) {
4243    var _this = this;
4244    return function (field) {
4245        if (field !== undefined) {
4246            _this["_".concat(fieldName)] = field;
4247        }
4248        if (_this["_".concat(fieldName)] !== undefined) {
4249            return _this["_".concat(fieldName)];
4250        }
4251        for (var i = 0; i < _this._rrule.length; i++) {
4252            var field_1 = _this._rrule[i].origOptions[fieldName];
4253            if (field_1) {
4254                return field_1;
4255            }
4256        }
4257    };
4258}
4259var RRuleSet = /** @class */ (function (_super) {
4260    __extends(RRuleSet, _super);
4261    /**
4262     *
4263     * @param {Boolean?} noCache
4264     * The same stratagy as RRule on cache, default to false
4265     * @constructor
4266     */
4267    function RRuleSet(noCache) {
4268        if (noCache === void 0) { noCache = false; }
4269        var _this = _super.call(this, {}, noCache) || this;
4270        _this.dtstart = createGetterSetter.apply(_this, ['dtstart']);
4271        _this.tzid = createGetterSetter.apply(_this, ['tzid']);
4272        _this._rrule = [];
4273        _this._rdate = [];
4274        _this._exrule = [];
4275        _this._exdate = [];
4276        return _this;
4277    }
4278    RRuleSet.prototype._iter = function (iterResult) {
4279        return iterSet(iterResult, this._rrule, this._exrule, this._rdate, this._exdate, this.tzid());
4280    };
4281    /**
4282     * Adds an RRule to the set
4283     *
4284     * @param {RRule}
4285     */
4286    RRuleSet.prototype.rrule = function (rrule) {
4287        _addRule(rrule, this._rrule);
4288    };
4289    /**
4290     * Adds an EXRULE to the set
4291     *
4292     * @param {RRule}
4293     */
4294    RRuleSet.prototype.exrule = function (rrule) {
4295        _addRule(rrule, this._exrule);
4296    };
4297    /**
4298     * Adds an RDate to the set
4299     *
4300     * @param {Date}
4301     */
4302    RRuleSet.prototype.rdate = function (date) {
4303        _addDate(date, this._rdate);
4304    };
4305    /**
4306     * Adds an EXDATE to the set
4307     *
4308     * @param {Date}
4309     */
4310    RRuleSet.prototype.exdate = function (date) {
4311        _addDate(date, this._exdate);
4312    };
4313    /**
4314     * Get list of included rrules in this recurrence set.
4315     *
4316     * @return List of rrules
4317     */
4318    RRuleSet.prototype.rrules = function () {
4319        return this._rrule.map(function (e) { return rrulestr(e.toString()); });
4320    };
4321    /**
4322     * Get list of excluded rrules in this recurrence set.
4323     *
4324     * @return List of exrules
4325     */
4326    RRuleSet.prototype.exrules = function () {
4327        return this._exrule.map(function (e) { return rrulestr(e.toString()); });
4328    };
4329    /**
4330     * Get list of included datetimes in this recurrence set.
4331     *
4332     * @return List of rdates
4333     */
4334    RRuleSet.prototype.rdates = function () {
4335        return this._rdate.map(function (e) { return new Date(e.getTime()); });
4336    };
4337    /**
4338     * Get list of included datetimes in this recurrence set.
4339     *
4340     * @return List of exdates
4341     */
4342    RRuleSet.prototype.exdates = function () {
4343        return this._exdate.map(function (e) { return new Date(e.getTime()); });
4344    };
4345    RRuleSet.prototype.valueOf = function () {
4346        var result = [];
4347        if (!this._rrule.length && this._dtstart) {
4348            result = result.concat(optionsToString({ dtstart: this._dtstart }));
4349        }
4350        this._rrule.forEach(function (rrule) {
4351            result = result.concat(rrule.toString().split('\n'));
4352        });
4353        this._exrule.forEach(function (exrule) {
4354            result = result.concat(exrule
4355                .toString()
4356                .split('\n')
4357                .map(function (line) { return line.replace(/^RRULE:/, 'EXRULE:'); })
4358                .filter(function (line) { return !/^DTSTART/.test(line); }));
4359        });
4360        if (this._rdate.length) {
4361            result.push(rdatesToString('RDATE', this._rdate, this.tzid()));
4362        }
4363        if (this._exdate.length) {
4364            result.push(rdatesToString('EXDATE', this._exdate, this.tzid()));
4365        }
4366        return result;
4367    };
4368    /**
4369     * to generate recurrence field such as:
4370     * DTSTART:19970902T010000Z
4371     * RRULE:FREQ=YEARLY;COUNT=2;BYDAY=TU
4372     * RRULE:FREQ=YEARLY;COUNT=1;BYDAY=TH
4373     */
4374    RRuleSet.prototype.toString = function () {
4375        return this.valueOf().join('\n');
4376    };
4377    /**
4378     * Create a new RRuleSet Object completely base on current instance
4379     */
4380    RRuleSet.prototype.clone = function () {
4381        var rrs = new RRuleSet(!!this._cache);
4382        this._rrule.forEach(function (rule) { return rrs.rrule(rule.clone()); });
4383        this._exrule.forEach(function (rule) { return rrs.exrule(rule.clone()); });
4384        this._rdate.forEach(function (date) { return rrs.rdate(new Date(date.getTime())); });
4385        this._exdate.forEach(function (date) { return rrs.exdate(new Date(date.getTime())); });
4386        return rrs;
4387    };
4388    return RRuleSet;
4389}(RRule));
4390
4391function _addRule(rrule, collection) {
4392    if (!(rrule instanceof RRule)) {
4393        throw new TypeError(String(rrule) + ' is not RRule instance');
4394    }
4395    if (!includes(collection.map(String), String(rrule))) {
4396        collection.push(rrule);
4397    }
4398}
4399function _addDate(date, collection) {
4400    if (!(date instanceof Date)) {
4401        throw new TypeError(String(date) + ' is not Date instance');
4402    }
4403    if (!includes(collection.map(Number), Number(date))) {
4404        collection.push(date);
4405        sort(collection);
4406    }
4407}
4408function rdatesToString(param, rdates, tzid) {
4409    var isUTC = !tzid || tzid.toUpperCase() === 'UTC';
4410    var header = isUTC ? "".concat(param, ":") : "".concat(param, ";TZID=").concat(tzid, ":");
4411    var dateString = rdates
4412        .map(function (rdate) { return timeToUntilString(rdate.valueOf(), isUTC); })
4413        .join(',');
4414    return "".concat(header).concat(dateString);
4415}
4416//# sourceMappingURL=rruleset.js.map
4417;// CONCATENATED MODULE: ./node_modules/rrule/dist/esm/index.js
4418/* !
4419 * rrule.js - Library for working with recurrence rules for calendar dates.
4420 * https://github.com/jakubroztocil/rrule
4421 *
4422 * Copyright 2010, Jakub Roztocil and Lars Schoning
4423 * Licenced under the BSD licence.
4424 * https://github.com/jakubroztocil/rrule/blob/master/LICENCE
4425 *
4426 * Based on:
4427 * python-dateutil - Extensions to the standard Python datetime module.
4428 * Copyright (c) 2003-2011 - Gustavo Niemeyer <[email protected]>
4429 * Copyright (c) 2012 - Tomi Pieviläinen <[email protected]>
4430 * https://github.com/jakubroztocil/rrule/blob/master/LICENCE
4431 *
4432 */
4433
4434
4435
4436
4437
4438
4439//# sourceMappingURL=index.js.map
4440// EXTERNAL MODULE: ./src/js/utils.js
4441var utils = __webpack_require__(771);
4442;// CONCATENATED MODULE: ./src/js/date-picker.js
4443/* eslint-disable no-var */
4444/* globals: wc_bookings_booking_form, booking_form_params */
4445
4446/**
4447 * External dependencies
4448 */
4449
4450
4451
4452/**
4453 * Internal dependencies
4454 */
4455
4456
4457
4458
4459// globally accessible for tests
4460let wc_bookings_date_picker = {};
4461external_jQuery_default()(function ($) {
4462  let defaultDate;
4463  var wc_bookings_locale = window.navigator.userLanguage || window.navigator.language,
4464    wc_bookings_timeout = 0,
4465    currentDateRange = {},
4466    wc_bookings_date_picker = {
4467      init: function () {
4468        $('body').on('click', '.wc-bookings-date-picker legend', this.toggle_calendar);
4469        $('body').on('click', '.booking_date_year, .booking_date_month, .booking_date_day', this.open_calendar);
4470        $('body').on('input', '.booking_date_year, .booking_date_month, .booking_date_day', this.input_date_trigger);
4471        $('body').on('keyup', '.booking_date_year, .booking_date_month, .booking_date_day', this.input_date_keypress);
4472        $('body').on('keyup', '.booking_to_date_year, .booking_to_date_month, .booking_to_date_day', this.input_date_keypress);
4473        $('body').on('change', '.booking_to_date_year, .booking_to_date_month, .booking_to_date_day', this.input_date_trigger);
4474        $('.wc-bookings-date-picker legend').show();
4475        $('.wc-bookings-date-picker').each(function () {
4476          var form = $(this).closest('form'),
4477            picker = form.find('.picker'),
4478            fieldset = $(this).closest('fieldset');
4479          wc_bookings_date_picker.date_picker_init(picker);
4480          if (picker.data('display') == 'always_visible') {
4481            $('.wc-bookings-date-picker-date-fields', fieldset).hide();
4482          } else {
4483            picker.hide();
4484          }
4485          if (picker.data('is_range_picker_enabled')) {
4486            form.find('p.wc_bookings_field_duration').hide();
4487            form.find('.wc_bookings_field_start_date legend span.label').text('always_visible' !== picker.data('display') ? booking_form_params.i18n_dates : booking_form_params.i18n_start_date);
4488          }
4489        });
4490      },
4491      calc_duration: function (picker) {
4492        var form = picker.closest('form'),
4493          fieldSet = picker.closest('fieldset'),
4494          unit = picker.data('durationUnit');
4495        setTimeout(function () {
4496          var days = 1,
4497            e_year = parseInt(fieldSet.find('input.booking_to_date_year').val(), 10),
4498            e_month = parseInt(fieldSet.find('input.booking_to_date_month').val(), 10),
4499            e_day = parseInt(fieldSet.find('input.booking_to_date_day').val(), 10),
4500            s_year = parseInt(fieldSet.find('input.booking_date_year').val(), 10),
4501            s_month = parseInt(fieldSet.find('input.booking_date_month').val(), 10),
4502            s_day = parseInt(fieldSet.find('input.booking_date_day').val(), 10);
4503          if (e_year && e_month >= 0 && e_day && s_year && s_month >= 0 && s_day) {
4504            var s_date = new Date(Date.UTC(s_year, s_month - 1, s_day)),
4505              e_date = new Date(Date.UTC(e_year, e_month - 1, e_day));
4506            days = Math.floor((e_date.getTime() - s_date.getTime()) / (1000 * 60 * 60 * 24));
4507            if ('day' === unit) {
4508              days = days + 1;
4509            }
4510          }
4511          form.find('#wc_bookings_field_duration').val(days).trigger('change');
4512        });
4513      },
4514      open_calendar: function () {
4515        const $picker = $(this).closest('fieldset').find('.picker:eq(0)');
4516        wc_bookings_date_picker.date_picker_init($picker);
4517        $picker.slideDown();
4518      },
4519      toggle_calendar: function () {
4520        const $picker = $(this).closest('fieldset').find('.picker:eq(0)');
4521        wc_bookings_date_picker.date_picker_init($picker);
4522        $picker.slideToggle();
4523      },
4524      input_date_keypress: function () {
4525        var $fieldset = $(this).closest('fieldset'),
4526          $picker = $fieldset.find('.picker:eq(0)');
4527        if ($picker.data('is_range_picker_enabled')) {
4528          clearTimeout(wc_bookings_timeout);
4529          wc_bookings_timeout = setTimeout(wc_bookings_date_picker.calc_duration($picker), 800);
4530        }
4531      },
4532      clear_selection: function () {
4533        const form_containers = $('.wc-bookings-booking-form');
4534
4535        // If we use setDate on the picker it will shift the selected month to the current one.
4536
4537        form_containers.each((index, form_container) => {
4538          const $form_container = $(form_container);
4539          const form = $form_container.closest('form');
4540
4541          // Clear selection
4542          form.find('input.booking_date_year, input.booking_date_month, input.booking_date_day, input#wc_bookings_field_start_date').val('').trigger('change');
4543          form.find('.ui-state-active').removeClass('ui-state-active');
4544
4545          /**
4546           * @see https://github.com/woocommerce/woocommerce-bookings/pull/3277#issuecomment-1115969788
4547           * for the reasoning behind the following.
4548           */
4549          if (['hour', 'minute'].includes(wc_bookings_booking_form.get_booking_duration_unit(form))) {
4550            form.find('.wc-bookings-booking-form .block-picker').html(`<li>${wc_bookings_booking_form.sanitize_text(wc_bookings_booking_form.default_blocks_area_text)}</li>`);
4551          } else {
4552            // Reset block picker.
4553            wc_bookings_booking_form.time_picker_reset_selected(form.find('.block-picker'));
4554          }
4555          form.find('.wc-bookings-booking-cost').hide();
4556        });
4557      },
4558      input_date_trigger: function () {
4559        var $fieldset = $(this).closest('fieldset'),
4560          $picker = $fieldset.find('.picker:eq(0)'),
4561          $form = $(this).closest('form'),
4562          year = parseInt($fieldset.find('input.booking_date_year').val(), 10),
4563          month = parseInt($fieldset.find('input.booking_date_month').val(), 10),
4564          day = parseInt($fieldset.find('input.booking_date_day').val(), 10);
4565        if (year && month && day) {
4566          var date = new Date(year, month - 1, day);
4567          $picker.datepicker("setDate", date);
4568          if ($picker.data('is_range_picker_enabled')) {
4569            var to_year = parseInt($fieldset.find('input.booking_to_date_year').val(), 10),
4570              to_month = parseInt($fieldset.find('input.booking_to_date_month').val(), 10),
4571              to_day = parseInt($fieldset.find('input.booking_to_date_day').val(), 10);
4572            var to_date = new Date(to_year, to_month - 1, to_day);
4573            if (!to_date || to_date < date) {
4574              $fieldset.find('input.booking_to_date_year').val('').addClass('error');
4575              $fieldset.find('input.booking_to_date_month').val('').addClass('error');
4576              $fieldset.find('input.booking_to_date_day').val('').addClass('error');
4577            } else {
4578              $fieldset.find('input').removeClass('error');
4579            }
4580          }
4581          $fieldset.triggerHandler('date-selected', date);
4582        }
4583      },
4584      select_date_trigger: function (date) {
4585        var fieldset = $(this).closest('fieldset'),
4586          picker = fieldset.find('.picker:eq(0)'),
4587          form = $(this).closest('form'),
4588          parsed_date = date.split('-'),
4589          start_or_end_date = picker.data('start_or_end_date');
4590        if (!picker.data('is_range_picker_enabled') || !start_or_end_date) {
4591          start_or_end_date = 'start';
4592        }
4593        if (picker.data('is_range_picker_enabled') && start_or_end_date === 'end') {
4594          var start_date = wc_bookings_date_picker.get_input_date(fieldset, '');
4595          var moment_date = moment(date);
4596          if (start_date && moment_date.isBefore(start_date)) {
4597            start_or_end_date = 'start';
4598          }
4599        }
4600
4601        // End date selected
4602        if (start_or_end_date === 'end') {
4603          // Set min date to default
4604          picker.data('min_date', picker.data('o_min_date'));
4605
4606          // Set fields
4607          fieldset.find('input.booking_to_date_year').val(parsed_date[0]);
4608          fieldset.find('input.booking_to_date_month').val(parsed_date[1]);
4609          fieldset.find('input.booking_to_date_day').val(parsed_date[2]).trigger('change');
4610
4611          // Calc duration
4612          if (picker.data('is_range_picker_enabled')) {
4613            wc_bookings_date_picker.calc_duration(picker);
4614          }
4615
4616          // Next click will be start date
4617          picker.data('start_or_end_date', 'start');
4618          if (picker.data('is_range_picker_enabled')) {
4619            form.find('.wc_bookings_field_start_date legend span.label').text('always_visible' !== picker.data('display') ? booking_form_params.i18n_dates : booking_form_params.i18n_clear_date_selection);
4620          }
4621          if ('always_visible' !== picker.data('display')) {
4622            $(this).hide();
4623          }
4624          // Start date selected
4625        } else {
4626          // Set min date to today
4627          if (picker.data('is_range_picker_enabled')) {
4628            // Store the original min date if it is not already set.
4629            if (typeof picker.data('o_min_date') === 'undefined') {
4630              picker.data('o_min_date', picker.data('min_date'));
4631            }
4632            picker.data('min_date', date);
4633          }
4634
4635          // Set fields
4636          fieldset.find('input.booking_to_date_year').val('');
4637          fieldset.find('input.booking_to_date_month').val('');
4638          fieldset.find('input.booking_to_date_day').val('');
4639          fieldset.find('input.booking_date_year').val(parsed_date[0]);
4640          fieldset.find('input.booking_date_month').val(parsed_date[1]);
4641          fieldset.find('input.booking_date_day').val(parsed_date[2]).trigger('change');
4642
4643          // Calc duration
4644          if (picker.data('is_range_picker_enabled')) {
4645            wc_bookings_date_picker.calc_duration(picker);
4646          }
4647
4648          // Next click will be end date
4649          picker.data('start_or_end_date', 'end');
4650          if (picker.data('is_range_picker_enabled')) {
4651            form.find('.wc_bookings_field_start_date legend span.label').text(booking_form_params.i18n_end_date);
4652          }
4653          if ('always_visible' !== picker.data('display') && !picker.data('is_range_picker_enabled')) {
4654            $(this).hide();
4655          }
4656        }
4657        fieldset.triggerHandler('date-selected', date, start_or_end_date);
4658
4659        /**
4660         * Fire action after end date select.
4661         *
4662         * @param {object} fieldset Field.
4663         *
4664         * @since 1.15.79
4665         */
4666        (0,utils/* HookApi */.A)().doAction('wc_bookings_date_selected', {
4667          'fieldset': fieldset.get(0),
4668          'date_picker': picker.get(0)
4669        });
4670      },
4671      date_picker_init: function (element) {
4672        var WC_DatePicker = new WC_Bookings_DatePicker(element);
4673        const min_date = typeof WC_DatePicker.get_data_attr('o_min_date') !== 'undefined' ? WC_DatePicker.get_data_attr('o_min_date') : WC_DatePicker.get_data_attr('min_date');
4674        /*
4675         * This prevents the calendar resetting to the current date when re-initializing.
4676         *
4677         * The defaultDate is set to the current date when the datepicker is initialized.
4678         * As the user navigates from month to month, the defaultDate is updated to the
4679         * first of the month the user has navigated to.
4680         *
4681         * If the resource is updated, this allows the date picker to refresh without
4682         * changing the month back to the current month.
4683         */
4684        if (typeof defaultDate === 'undefined') {
4685          defaultDate = WC_DatePicker.get_data_attr('default_date');
4686        }
4687        WC_DatePicker.set_default_params({
4688          onSelect: wc_bookings_date_picker.select_date_trigger,
4689          minDate: min_date,
4690          maxDate: WC_DatePicker.get_data_attr('max_date'),
4691          defaultDate: defaultDate,
4692          closeText: WC_DatePicker.get_custom_data('closeText'),
4693          currentText: WC_DatePicker.get_custom_data('currentText'),
4694          prevText: WC_DatePicker.get_custom_data('prevText'),
4695          nextText: WC_DatePicker.get_custom_data('nextText'),
4696          monthNames: WC_DatePicker.get_custom_data('monthNames'),
4697          monthNamesShort: WC_DatePicker.get_custom_data('monthNamesShort'),
4698          dayNames: WC_DatePicker.get_custom_data('dayNames'),
4699          dayNamesShort: WC_DatePicker.get_custom_data('dayNamesShort'),
4700          dayNamesMin: WC_DatePicker.get_custom_data('dayNamesMin'),
4701          firstDay: booking_form_params.client_firstday ? moment().localeData().firstDayOfWeek() : WC_DatePicker.get_custom_data('firstDay'),
4702          isRTL: WC_DatePicker.get_custom_data('isRTL'),
4703          beforeShowDay: WC_DatePicker.maybe_load_from_cache.bind(WC_DatePicker),
4704          onChangeMonthYear: function (year, month) {
4705            this.get_data(year, month).done(function () {
4706              element.datepicker('refresh');
4707            });
4708            defaultDate = new Date(year, month - 1, 1);
4709          }.bind(WC_DatePicker)
4710        });
4711        WC_DatePicker.create();
4712        wc_bookings_booking_form.get_day_attributes = WC_DatePicker.maybe_load_from_cache.bind(WC_DatePicker);
4713      },
4714      refresh_datepicker: function () {
4715        var $picker = $('.wc-bookings-date-picker').find('.picker:eq(0)');
4716        $picker.datepicker('refresh');
4717
4718        /**
4719         * Fire action after date picker is refreshed.
4720         *
4721         * @param {object} $picker jQuery object of the date picker.
4722         * @since 1.15.79
4723         */
4724        (0,utils/* HookApi */.A)().doAction('wc_bookings_date_picker_refreshed', {
4725          'date_picker': $picker
4726        });
4727      },
4728      get_input_date: function (fieldset, where) {
4729        var year = fieldset.find('input.booking_' + where + 'date_year'),
4730          month = fieldset.find('input.booking_' + where + 'date_month'),
4731          day = fieldset.find('input.booking_' + where + 'date_day');
4732        if (0 !== year.val().length && 0 !== month.val().length && 0 !== day.val().length) {
4733          return year.val() + '-' + month.val() + '-' + day.val();
4734        } else {
4735          return '';
4736        }
4737      },
4738      get_number_of_days: function (defaultNumberOfDays, $form, $picker, wc_bookings_booking_form) {
4739        var number_of_days = defaultNumberOfDays;
4740        var wcbf = wc_bookings_booking_form;
4741        if ($form.find('#wc_bookings_field_duration').length > 0 && wcbf.duration_unit != 'minute' && wcbf.duration_unit != 'hour' && !$picker.data('is_range_picker_enabled')) {
4742          var user_duration = $form.find('#wc_bookings_field_duration').val();
4743          number_of_days = number_of_days * user_duration;
4744        }
4745        if (number_of_days < 1) {
4746          number_of_days = 1;
4747        }
4748        return number_of_days;
4749      },
4750      is_blocks_bookable: function (args) {
4751        var bookable = args.default_availability;
4752
4753        // Loop all the days we need to check for this block.
4754        for (var i = 0; i < args.number_of_days; i++) {
4755          var the_date = new Date(args.start_date);
4756          the_date.setDate(the_date.getDate() + i);
4757          var year = the_date.getFullYear(),
4758            month = the_date.getMonth() + 1,
4759            day = the_date.getDate(),
4760            day_of_week = the_date.getDay();
4761
4762          // Sunday is 0, Monday is 1, and so on.
4763          if (day_of_week === 0) {
4764            day_of_week = 7;
4765          }
4766
4767          // Is resource available in current date?
4768          // Note: resource_id = 0 is product's availability rules.
4769          // Each resource rules also contains product's rules.
4770          var resource_args = {
4771            date: the_date,
4772            default_availability: args.default_availability
4773          };
4774          var resource_rules = args.availability[args.resource_id];
4775
4776          /*
4777           * If the resource ID is zero, the check is for the availability rules of the product.
4778           *
4779           * If the availability rules are only checked against the start date then we can bypass the
4780           * checks for the second and subsequent days in the block.
4781           */
4782          if (args.resource_id === 0 && wc_bookings_booking_form.check_availability_against === 'start' && i > 0) {
4783            bookable = true;
4784          } else {
4785            bookable = wc_bookings_date_picker.is_resource_available_on_date(resource_args, resource_rules);
4786          }
4787
4788          // In case of automatic assignment we want to make sure at least
4789          // one resource is available.
4790          if ('automatic' === args.resources_assignment) {
4791            var automatic_resource_args = $.extend({
4792              availability: args.availability,
4793              fully_booked_days: args.fully_booked_days
4794            }, resource_args);
4795            bookable = wc_bookings_date_picker.has_available_resource(automatic_resource_args);
4796          }
4797          if (!bookable) {
4798            return 'not_bookable_by_rules';
4799          }
4800
4801          // Fully booked in entire block?
4802          var ymdIndex = year + '-' + month + '-' + day;
4803          if (args.fully_booked_days[ymdIndex]) {
4804            // If product does not have any resources, mark as bookable false.
4805            // OR if a product with customer defined resources found in an array, mark as bookable false.
4806            // This conditions fixes issues #2881 & #3453.
4807            if (this.bookingsData.fully_booked_days[ymdIndex][0] && 0 === args.resource_ids.length || 0 !== args.resource_id && this.bookingsData.fully_booked_days[ymdIndex][args.resource_id]) {
4808              bookable = false;
4809            }
4810          }
4811          if (!bookable) {
4812            break;
4813          }
4814        }
4815        return bookable;
4816      },
4817      rrule_cache: {},
4818      /**
4819       * Checks rules against date to check if there are any available minutes on the date.
4820       *
4821       * Depending on client/server timezone offset, prev/next day will be checked for available
4822       * minutes and then offsetted accordingly for timezone.
4823       *
4824       * @param args
4825       * @param rules array of rules in order from lowest override power to highest.
4826       *
4827       * @returns bool
4828       */
4829      is_resource_available_on_date: function (args, rules) {
4830        if ('object' !== typeof args || 'object' !== typeof rules) {
4831          return false;
4832        }
4833        const server_offset = (0,bookings_lib/* get_client_server_timezone_offset_hrs */.f)(args.date);
4834        const durationUnit = $('[data-duration-unit]').data('duration-unit');
4835        let availableMinutes;
4836
4837        // For days, skip the timezone conversion.
4838        if (server_offset === 0 || 'day' === durationUnit) {
4839          availableMinutes = this.get_available_minutes_on_date_for_rule(args, rules);
4840        } else {
4841          const {
4842            date: currentDate,
4843            ...argsNoDate
4844          } = args;
4845          const currentDayMinutes = this.get_available_minutes_on_date_for_rule({
4846            ...argsNoDate,
4847            date: currentDate
4848          }, rules);
4849          if (server_offset < 0) {
4850            const nextDayDate = new Date(currentDate);
4851            nextDayDate.setDate(currentDate.getDate() + 1);
4852            const nextDayMinutes = this.get_available_minutes_on_date_for_rule({
4853              ...argsNoDate,
4854              date: nextDayDate
4855            }, rules).map(m => m + 1440);
4856            availableMinutes = currentDayMinutes.concat(nextDayMinutes);
4857          } else {
4858            const prevDayDate = new Date(currentDate);
4859            prevDayDate.setDate(currentDate.getDate() - 1);
4860            const prevDayMinutes = this.get_available_minutes_on_date_for_rule({
4861              ...argsNoDate,
4862              date: prevDayDate
4863            }, rules).map(m => m - 1440);
4864            availableMinutes = prevDayMinutes.concat(currentDayMinutes);
4865          }
4866          // Offset minutes for timezone.
4867          availableMinutes = availableMinutes.map(m => m + server_offset * 60);
4868          // Filter out minutes that are not on the current day.
4869          availableMinutes = availableMinutes.filter(m => m > 0 && m < 1440);
4870        }
4871        return !external_default().isEmpty(availableMinutes);
4872      },
4873      /**
4874       * Goes through all the rules and applies them to get array of available minutes
4875       *
4876       * Rules are recursively applied. Rules later array will override rules earlier in the array if
4877       * applicable to the block being checked.
4878       *
4879       * @param args
4880       * @param rules array of rules in order from lowest override power to highest.
4881       *
4882       * @returns array
4883       */
4884      get_available_minutes_on_date_for_rule: function (args, rules) {
4885        var defaultAvailability = args.default_availability,
4886          year = args.date.getFullYear(),
4887          month = args.date.getMonth() + 1,
4888          // months start at 0
4889          day = args.date.getDate(),
4890          day_of_week = args.date.getDay(),
4891          week = wc_bookings_date_picker.get_week_number(args.date);
4892
4893        // Sunday is 0, Monday is 1, and so on.
4894        if (day_of_week === 0) {
4895          day_of_week = 7;
4896        }
4897        let minutesAvailableForDay = [];
4898
4899        // `args.fully_booked_days` and `args.resource_id` only available
4900        // when checking 'automatic' resource assignment.
4901        if (args.fully_booked_days && args.fully_booked_days[year + '-' + month + '-' + day] && args.fully_booked_days[year + '-' + month + '-' + day][args.resource_id]) {
4902          return minutesAvailableForDay;
4903        }
4904        var minutesForADay = external_default().range(1, 1440, 1);
4905        // Ensure that the minutes are set when the all slots are available by default.
4906        if (defaultAvailability) {
4907          minutesAvailableForDay = minutesForADay;
4908        }
4909        $.each(rules, function (index, rule) {
4910          var type = rule['type'],
4911            range = rule['range'],
4912            minutesAvailableForTime;
4913          try {
4914            switch (type) {
4915              case 'months':
4916                if (typeof range[month] != 'undefined') {
4917                  if (range[month]) {
4918                    minutesAvailableForDay = minutesForADay;
4919                  } else {
4920                    minutesAvailableForDay = [];
4921                  }
4922                  return true; // go to the next rule
4923                }
4924                break;
4925              case 'weeks':
4926                if (typeof range[week] != 'undefined') {
4927                  if (range[week]) {
4928                    minutesAvailableForDay = minutesForADay;
4929                  } else {
4930                    minutesAvailableForDay = [];
4931                  }
4932                  return true; // go to the next rule
4933                }
4934                break;
4935              case 'days':
4936                if (typeof range[day_of_week] != 'undefined') {
4937                  if (range[day_of_week]) {
4938                    minutesAvailableForDay = minutesForADay;
4939                  } else {
4940                    minutesAvailableForDay = [];
4941                  }
4942                  return true; // go to the next rule
4943                }
4944                break;
4945              case 'custom':
4946                if (typeof range[year][month][day] != 'undefined') {
4947                  if (range[year][month][day]) {
4948                    minutesAvailableForDay = minutesForADay;
4949                  } else {
4950                    minutesAvailableForDay = [];
4951                  }
4952                  return true; // go to the next rule
4953                }
4954                break;
4955              case 'rrule':
4956                const is_all_day = -1 === range.from.indexOf(':');
4957                const current_date = moment.utc(args.date);
4958                const current_date_sod = current_date.clone().startOf('day');
4959                const from_date = moment.utc(range.from);
4960                const to_date = moment.utc(range.to);
4961                const duration = moment.duration(to_date.diff(from_date));
4962                const rrule = rrulestr(range.rrule, {
4963                  dtstart: from_date.toDate()
4964                });
4965                const cache_key = index + currentDateRange.startDate + currentDateRange.endDate;
4966                if (typeof wc_bookings_date_picker.rrule_cache[cache_key] === 'undefined') {
4967                  wc_bookings_date_picker.rrule_cache[cache_key] = rrule.between(moment.utc(currentDateRange.startDate).subtract(duration).subtract(1, 'days').toDate(), moment.utc(currentDateRange.endDate).subtract(duration).add(1, 'days').toDate(), true).map(occurrence => new moment(occurrence));
4968                }
4969                wc_bookings_date_picker.rrule_cache[cache_key].forEac
4969h(occurrence => {
4970                  const occurrence_sod = occurrence.clone().startOf('day');
4971                  const end_occurrence = occurrence.clone().add(duration);
4972                  const end_occurrence_sod = end_occurrence.clone().startOf('day');
4973                  if (current_date_sod.isSameOrAfter(occurrence_sod) && current_date_sod.isBefore(end_occurrence_sod)) {
4974                    if (is_all_day) {
4975                      minutesAvailableForDay = range.rule ? minutesForADay : [];
4976                    } else if (current_date_sod.isSame(occurrence_sod)) {
4977                      const minutesFromStartOfDay = moment.duration(occurrence.diff(occurrence_sod)).asMinutes();
4978                      minutesAvailableForTime = external_default().range(minutesFromStartOfDay, minutesFromStartOfDay + duration.asMinutes(), 1);
4979                      if (range.rule) {
4980                        minutesAvailableForDay = external_default().union(minutesAvailableForDay, minutesAvailableForTime);
4981                      } else {
4982                        minutesAvailableForDay = external_default().difference(minutesAvailableForDay, minutesAvailableForTime);
4983                      }
4984                    } else if (current_date_sod.isAfter(occurrence_sod) && current_date_sod.isBefore(end_occurrence_sod)) {
4985                      // Event is a multi-day event with start and end time but current day is fully inside the start day and end days
4986                      minutesAvailableForDay = range.rule ? minutesForADay : [];
4987                    } else if (current_date_sod.isSame(end_occurrence_sod)) {
4988                      // Event is multi-day and current day is the last day of event. Find how many minutes there are before end time.
4989                      minutesAvailableForTime = external_default().range(1, moment.duration(end_occurrence.diff(end_occurrence_sod)).asMinutes(), 1);
4990                      if (range.rule) {
4991                        minutesAvailableForDay = external_default().union(minutesAvailableForDay, minutesAvailableForTime);
4992                      } else {
4993                        minutesAvailableForDay = external_default().difference(minutesAvailableForDay, minutesAvailableForTime);
4994                      }
4995                    }
4996                  }
4997                });
4998                break;
4999              case 'time':
5000              case 'time:1':
5001              case 'time:2':
5002              case 'time:3':
5003              case 'time:4':
5004              case 'time:5':
5005              case 'time:6':
5006              case 'time:7':
5007                if (day_of_week === range.day || 0 === range.day) {
5008                  var fromHour = parseInt(range.from.split(':')[0]);
5009                  var fromMinute = parseInt(range.from.split(':')[1]);
5010                  var toHour = parseInt(range.to.split(':')[0]);
5011                  var toMinute = parseInt(range.to.split(':')[1]);
5012
5013                  // each minute in the day gets a number from 1 to 1440
5014                  var fromMinuteNumber = fromMinute + fromHour * 60;
5015                  var toMinuteNumber = toMinute + toHour * 60;
5016                  minutesAvailableForTime = external_default().range(fromMinuteNumber, toMinuteNumber, 1);
5017                  if (range.rule) {
5018                    minutesAvailableForDay = external_default().union(minutesAvailableForDay, minutesAvailableForTime);
5019                  } else {
5020                    minutesAvailableForDay = external_default().difference(minutesAvailableForDay, minutesAvailableForTime);
5021                  }
5022                  return true;
5023                }
5024                break;
5025              case 'time:range':
5026              case 'custom:daterange':
5027                range = range[year][month][day];
5028                var fromHour = parseInt(range.from.split(':')[0]);
5029                var fromMinute = parseInt(range.from.split(':')[1]);
5030                var toHour = parseInt(range.to.split(':')[0]);
5031                var toMinute = parseInt(range.to.split(':')[1]);
5032
5033                // each minute in the day gets a number from 1 to 1440
5034                var fromMinuteNumber = fromMinute + fromHour * 60;
5035                var toMinuteNumber = toMinute + toHour * 60;
5036                minutesAvailableForTime = external_default().range(fromMinuteNumber, toMinuteNumber, 1);
5037                if (range.rule) {
5038                  minutesAvailableForDay = external_default().union(minutesAvailableForDay, minutesAvailableForTime);
5039                } else {
5040                  minutesAvailableForDay = external_default().difference(minutesAvailableForDay, minutesAvailableForTime);
5041                }
5042                break;
5043            }
5044          } catch (err) {
5045            return true; // go to the next rule
5046          }
5047        });
5048        return minutesAvailableForDay;
5049      },
5050      get_week_number: function (date) {
5051        return moment(date).format('W');
5052      },
5053      has_available_resource: function (args) {
5054        for (var resource_id in args.availability) {
5055          resource_id = parseInt(resource_id, 10);
5056
5057          // Skip resource_id '0' that has been performed before.
5058          if (0 === resource_id) {
5059            continue;
5060          }
5061          var resource_rules = args.availability[resource_id];
5062          args.resource_id = resource_id;
5063          if (wc_bookings_date_picker.is_resource_available_on_date(args, resource_rules)) {
5064            return true;
5065          }
5066        }
5067        return false;
5068      }
5069    };
5070
5071  /**
5072   * Represents a jQuery UI DatePicker.
5073   *
5074   * @constructor
5075   * @version 1.10.11
5076   * @since   1.10.11
5077   * @param   {object} element - jQuery object for the picker that was initialized.
5078   * @param   {object} opts - Optional arguments.
5079   */
5080  var WC_Bookings_DatePicker = function WC_Bookings_DatePicker(element) {
5081    this.$picker = $(element);
5082    this.$form = this.$picker.closest('form, .cart');
5083    this.customData = {};
5084    this.opts = {
5085      cache: false
5086    };
5087    this.cache = {
5088      data: {},
5089      attributes: {}
5090    };
5091    $.each(wc_bookings_booking_form, function (key, val) {
5092      this.customData[key] = val;
5093    }.bind(this));
5094    $.each(booking_form_params, function (key, val) {
5095      this.customData[key] = val;
5096    }.bind(this));
5097    if (this.customData.cache_ajax_requests && ('true' == this.customData.cache_ajax_requests.toLowerCase() || 'false' == this.customData.cache_ajax_requests.toLowerCase())) {
5098      this.opts.cache = 'true' == this.customData.cache_ajax_requests.toLowerCase();
5099    }
5100
5101    // Multiple global objects get defined on client side when more than one booking product is used per page.
5102    // For this reason, the localized param value is set to the last defined global object which creates issue with booking calendars.
5103    // And the global object always refer to the recently loaded booking product. To fix issue, we are adding product specific settings to customData.
5104    // https://github.com/woocommerce/woocommerce-bookings/issues/1636
5105    this.customData.product_id = wc_bookings_booking_form.get_booking_product_id(element);
5106    this.customData.booking_duration = wc_bookings_booking_form.get_booking_duration(element);
5107    this.customData.booking_min_duration = wc_bookings_booking_form.get_booking_min_duration(element);
5108    this.customData.booking_max_duration = wc_bookings_booking_form.get_booking_max_duration(element);
5109    this.customData.check_availability_against = wc_bookings_booking_form.get_booking_check_availability_against(element);
5110    this.customData.default_availability = wc_bookings_booking_form.get_booking_default_availability(element);
5111    this.customData.duration_type = wc_bookings_booking_form.get_booking_duration_type(element);
5112    this.customData.booking_duration_type = wc_bookings_booking_form.get_booking_duration_type(element);
5113    this.customData.duration_unit = wc_bookings_booking_form.get_booking_duration_unit(element);
5114    this.customData.resources_assignment = wc_bookings_booking_form.get_booking_resources_assignment(element);
5115    this.customData.resource_ids = wc_bookings_booking_form.get_booking_resource_ids(element);
5116    if (!this.$picker.length) {
5117      return;
5118    }
5119  };
5120
5121  /**
5122   * Creates the DatePicker referenced by initializing the first data call.
5123   *
5124   * @version 1.10.11
5125   * @since   1.10.11
5126   */
5127  WC_Bookings_DatePicker.prototype.create = function create() {
5128    var year = parseInt(this.$form.find('input.booking_date_year').val(), 10);
5129    var month = parseInt(this.$form.find('input.booking_date_month').val(), 10);
5130    var day = parseInt(this.$form.find('input.booking_date_day').val(), 10);
5131    this.$picker.empty().removeClass('hasDatepicker').datepicker(this.get_default_params());
5132    $('.ui-datepicker-current-day').removeClass('ui-datepicker-current-day');
5133    if (year && month && day) {
5134      this.$picker.datepicker('setDate', new Date(year, month - 1, day));
5135    }
5136    var picker_month = this.$picker.datepicker('getDate').getMonth() + 1;
5137    var picker_year = this.$picker.datepicker('getDate').getFullYear();
5138    this.get_data(picker_year, picker_month).done(function () {
5139      wc_bookings_date_picker.refresh_datepicker();
5140    });
5141  };
5142
5143  /**
5144   * If caching is being requested beforeShowDay will use this method to load styles from cache if available.
5145   *
5146   * @version 1.10.11
5147   * @since   1.10.11
5148   * @param   {object} date - Date to apply attributes to.
5149   */
5150  WC_Bookings_DatePicker.prototype.maybe_load_from_cache = function maybe_load_from_cache(date) {
5151    var cacheKey = date.getTime();
5152    var defaultClass = '1' === this.customData.default_availability ? 'bookable' : 'not-bookable';
5153    var attributes = [false, defaultClass, ''];
5154    var cachedAttributes = this.cache.attributes[cacheKey];
5155    if (cachedAttributes) {
5156      cachedAttributes = [cachedAttributes.selectable, cachedAttributes.class.join(' '), cachedAttributes.title];
5157    } else if (this.bookingsData) {
5158      var attrs = this.getDateElementAttributes(date);
5159      attributes = [attrs.selectable, attrs.class.join(' '), attrs.title];
5160    }
5161    return cachedAttributes || attributes;
5162  };
5163
5164  /**
5165   * Returns the default parameters.
5166   *
5167   * @version 1.10.11
5168   * @since   1.10.11
5169   */
5170  WC_Bookings_DatePicker.prototype.get_default_params = function get_default_params() {
5171    return this.defaultParams || {};
5172  };
5173
5174  /**
5175   * Set and override the default parameters.
5176   *
5177   * @version 1.10.11
5178   * @since   1.10.11
5179   * @param   {object} params - Parameters to be set or overridden.
5180   */
5181  WC_Bookings_DatePicker.prototype.set_default_params = function set_default_params(params) {
5182    var _defaultParams = {
5183      showWeek: false,
5184      showOn: false,
5185      numberOfMonths: 1,
5186      showButtonPanel: false,
5187      showOtherMonths: true,
5188      selectOtherMonths: true,
5189      gotoCurrent: true,
5190      dateFormat: $.datepicker.ISO_8601
5191    };
5192    if (typeof params !== 'object') {
5193      throw new Error('Cannot set params with typeof ' + typeof params);
5194    }
5195    this.defaultParams = $.extend(_defaultParams, params) || {};
5196  };
5197
5198  /**
5199   * Get the data from the server for a block of time.
5200   *
5201   * @since   1.10.11
5202   * @param   {string} year - Year being requested.
5203   * @param   {string} month - Month being requested.
5204   * @returns {object} Deferred object to be resolved after the http request
5205   */
5206  WC_Bookings_DatePicker.prototype.get_data = function get_data(year, month) {
5207    /**
5208     * Overlay styles when jQuery.block is called to block the DOM.
5209     */
5210    var blockUIOverlayCSS = {
5211      background: '#fff',
5212      opacity: 0.6
5213    };
5214
5215    /**
5216     * Get a date range based on the start date.
5217     *
5218     * @since   1.10.11
5219     * @param   {string} startDate - Optional start date to get the date range from.
5220     * @returns {object} Object referencing the start date and end date for the range calculated.
5221     */
5222    var get_date_range = function get_date_range(startDate) {
5223      if (!startDate) {
5224        startDate = new Date([year, month, '01'].join('/'));
5225      }
5226      var range = this.get_number_of_days_in_month(month);
5227      return this.get_padded_date_range(startDate, range);
5228    }.bind(this);
5229    var deferred = $.Deferred();
5230    var dateRange = get_date_range();
5231    var cacheKey = dateRange.startDate.getTime() + '-' + dateRange.endDate.getTime();
5232    if (this.opts.cache && this.cache.data[cacheKey]) {
5233      deferred.resolveWith(this, [dateRange, this.cache.data[cacheKey]]);
5234    } else {
5235      var resource_id = parseInt(this.$form.find('select#wc_bookings_field_resource').val(), 10) || 0;
5236      var params = {
5237        'product_id': this.get_custom_data('product_id'),
5238        'wc-ajax': 'wc_bookings_find_booked_day_blocks',
5239        'security': this.$form.data('nonce'),
5240        'resource_id': resource_id
5241      };
5242      this.$picker.block({
5243        message: null,
5244        overlayCSS: blockUIOverlayCSS
5245      });
5246      if (booking_form_params.timezone_conversion) {
5247        params.timezone_offset = (0,bookings_lib/* get_client_server_timezone_offset_hrs */.f)(dateRange.startDate);
5248        $('#timezone_offset').val(params.timezone_offset);
5249      }
5250      params.min_date = moment(dateRange.startDate).format('YYYY-MM-DD');
5251      params.max_date = moment(dateRange.endDate).format('YYYY-MM-DD');
5252      $('#min_date').val(params.min_date);
5253      $('#max_date').val(params.max_date);
5254      $.ajax({
5255        context: this,
5256        url: wc_bookings_date_picker_args.ajax_url,
5257        method: 'GET',
5258        data: params
5259      }).done(function (data) {
5260        if ('old_availability' in data && data.old_availability) {
5261          if (0 === $('#old_availability_served').length) {
5262            let old_availability = document.createElement('p');
5263            old_availability.setAttribute('id', 'old_availability_served');
5264            old_availability.textContent = booking_form_params.i18n_old_availability;
5265            $(old_availability).insertBefore('#wc-bookings-booking-form');
5266          }
5267        } else {
5268          $('#old_availability_served').remove();
5269        }
5270        this.bookingsData = this.bookingsData || {};
5271        $.each(data, function (key, val) {
5272          if (Array.isArray(val) || typeof val === 'object') {
5273            var emptyType = Array.isArray(val) ? [] : {};
5274            this.bookingsData[key] = this.bookingsData[key] || emptyType;
5275            $.extend(this.bookingsData[key], val);
5276          } else {
5277            this.bookingsData[key] = val;
5278          }
5279        }.bind(this));
5280        wc_bookings_booking_form.wc_bookings_date_picker.bookingsData = this.bookingsData;
5281        this.cache.data[cacheKey] = data;
5282        if (!year && !month && this.bookingsData.min_date) {
5283          dateRange = get_date_range(this.get_default_date(this.bookingsData.min_date));
5284        }
5285        deferred.resolveWith(this, [dateRange, data]);
5286        this.$picker.unblock();
5287      }.bind(this));
5288    }
5289    return deferred;
5290  };
5291
5292  /**
5293   * Gets the default date
5294   *
5295   * @version 1.10.11
5296   * @since   1.10.11
5297   * @returns {Date}  Default date
5298   */
5299  WC_Bookings_DatePicker.prototype.get_default_date = function get_default_date(minBookableDate) {
5300    var defaultDate;
5301    var defaultDateFromData = this.$picker.data('default_date').split('-');
5302    // We change the day to be 31, as default_date defaults to the current day,
5303    // but we want to go as far as to the end of the current month.
5304    defaultDateFromData[2] = '31';
5305    var modifier = 1;
5306
5307    // If for some reason the default_date didn't get or set incorrectly we should
5308    // try to fix it even though it may be indicative somewith else has gone wrong
5309    // on the backend.
5310    defaultDate = defaultDateFromData.length !== 3 ? new Date() : new Date(defaultDateFromData);
5311
5312    // The server will sometimes return a min_bookable_date with the data request
5313    // If that happens we need to modify the default date to start from this
5314    // modified date.
5315    if (minBookableDate) {
5316      switch (minBookableDate.unit) {
5317        case 'month':
5318          modifier = 30;
5319          break;
5320        case 'week':
5321          modifier = 7;
5322          break;
5323      }
5324      modifier = modifier * minBookableDate.value;
5325      defaultDate.setDate(defaultDate.getDate() + modifier);
5326    }
5327    return defaultDate;
5328  };
5329
5330  /**
5331   * Get number of days in a month
5332   *
5333   * @version 1.10.11
5334   * @since   1.10.11
5335   * @param   {number} [ month = currentMonth ] - The month in a 1 based index to get the number of days for.
5336   * @returns {number} Number of days in the month.
5337   */
5338  WC_Bookings_DatePicker.prototype.get_number_of_days_in_month = function get_number_of_days_in_month(month) {
5339    var currentDate = this.get_default_date();
5340    month = month || currentDate.getMonth() + 1;
5341    return new Date(currentDate.getFullYear(), month, 0).getDate();
5342  };
5343
5344  /**
5345   * Get custom data that was set by the server prior to rendering the client.
5346   *
5347   * @version 1.10.11
5348   * @since   1.10.11
5349   * @param   {string} key - Custom data attribute to get.
5350   */
5351  WC_Bookings_DatePicker.prototype.get_custom_data = function get_custom_data(key) {
5352    if (!key) {
5353      return;
5354    }
5355    return this.customData[key] || null;
5356  };
5357
5358  /**
5359   * Get data attribute set on the $picker element.
5360   *
5361   * @version 1.10.11
5362   * @since   1.10.11
5363   * @param   {string} attr - Data attribute to get.
5364   */
5365  WC_Bookings_DatePicker.prototype.get_data_attr = function get_data_attr(attr) {
5366    if (!attr) {
5367      return;
5368    }
5369    return this.$picker.data(attr);
5370  };
5371
5372  /**
5373   * Gets a date range with a padding in days on either side of the range.
5374   *
5375   * @version 1.10.11
5376   * @since   1.10.11
5377   * @param   {Date}   date - Date to start from.
5378   * @param   {number} rangeInDays - Number of days to build for the range.
5379   * @param   {number} padInDays - Number of days to pad on either side of the range.
5380   */
5381  WC_Bookings_DatePicker.prototype.get_padded_date_range = function get_padded_date_range(date, rangeInDays, padInDays) {
5382    date = date || this.get_default_date();
5383    rangeInDays = rangeInDays || 30;
5384    padInDays = padInDays || 7;
5385    var currentDate = new Date();
5386    var isCurrentDayToday = date < currentDate;
5387    var startDate = new Date(date.setDate(isCurrentDayToday ? currentDate.getDate() : '01')); // We dont go back further than today
5388    var endDate = new Date(startDate.getTime());
5389    startDate.setDate(startDate.getDate() - (isCurrentDayToday ? 0 : padInDays)); // No reason to pad the left if the date is today
5390    endDate.setDate(endDate.getDate() + (rangeInDays + padInDays));
5391    if (startDate < currentDate) {
5392      startDate = currentDate;
5393    }
5394    return {
5395      startDate: startDate,
5396      endDate: endDate
5397    };
5398  };
5399
5400  /**
5401   * Gets the date element attributes. This was formerly called is_bookable but changed names to more accurately reflect its new purpose.
5402   *
5403   * @version 1.10.11
5404   * @since   1.10.11
5405   * @param   {Date}   key - Date to get the element attributes for.
5406   * @returns {object} Attributes computed for the date.
5407   */
5408  WC_Bookings_DatePicker.prototype.getDateElementAttributes = function getDateElementAttributes(date) {
5409    var attributes = {
5410      class: [],
5411      title: '',
5412      selectable: true
5413    };
5414    var moment_date = moment(date);
5415    var resource_id = this.$form.find('select#wc_bookings_field_resource').val() > 0 ? this.$form.find('select#wc_bookings_field_resource').val() : 0;
5416    var year = date.getFullYear();
5417    var month = date.getMonth() + 1;
5418    var day = date.getDate();
5419    var day_of_week = date.getDay();
5420    var ymdIndex = year + '-' + month + '-' + day;
5421    var today = new Date();
5422
5423    // Unavailable days?
5424    if (this.bookingsData.unavailable_days && this.bookingsData.unavailable_days[ymdIndex] && this.bookingsData.unavailable_days[ymdIndex][resource_id]) {
5425      attributes.title = booking_form_params.i18n_date_unavailable;
5426      attributes.selectable = false;
5427      attributes.class.push('not_bookable');
5428    }
5429
5430    // Unavailable days when the resources is automatically assigned.
5431    if (wc_bookings_booking_form.resources_assignment === 'automatic' && this.bookingsData.unavailable_days && this.bookingsData.unavailable_days[ymdIndex] && Object.keys(this.bookingsData.unavailable_days[ymdIndex]).length === wc_bookings_booking_form.resource_ids.length) {
5432      attributes.title = booking_form_params.i18n_date_unavailable;
5433      attributes.selectable = false;
5434      attributes.class.push('not_bookable');
5435      attributes.class.push('not_bookable_by_resources');
5436    }
5437
5438    // Buffer days?
5439    if (this.bookingsData.buffer_days && this.bookingsData.buffer_days[ymdIndex]) {
5440      // If "resources_assignment" is set to customer selected, check if the selected resource has a buffer day for a particular date.
5441      // If "resources_assignment" is set to "automatic", make the date not bookable if it is a buffer day for all available resources.
5442      if (this.bookingsData.buffer_days[ymdIndex][0] || this.bookingsData.buffer_days[ymdIndex][resource_id] || 'automatic' === this.customData.resources_assignment && Ob
5442ject.keys(this.bookingsData.buffer_days[ymdIndex]).length === this.customData.resource_ids.length) {
5443        attributes.title = booking_form_params.i18n_date_unavailable;
5444        attributes.selectable = false;
5445        attributes.class.push('not_bookable');
5446      }
5447    }
5448
5449    // Restricted days?
5450    if (this.bookingsData.restricted_days && undefined === this.bookingsData.restricted_days[day_of_week]) {
5451      attributes.title = booking_form_params.i18n_date_unavailable;
5452      attributes.selectable = false;
5453      attributes.class.push('not_bookable');
5454    }
5455    if (moment_date.isBefore(today, 'day')) {
5456      attributes.title = booking_form_params.i18n_date_unavailable;
5457      attributes.selectable = false;
5458      attributes.class.push('not_bookable');
5459    }
5460    var number_of_days = wc_bookings_date_picker.get_number_of_days(this.customData.booking_duration, this.$form, this.$picker, wc_bookings_booking_form);
5461    var block_args = {
5462      start_date: date,
5463      number_of_days: wc_bookings_booking_form.check_availability_against === 'start' ? 1 : number_of_days,
5464      fully_booked_days: this.bookingsData.fully_booked_days,
5465      availability: this.bookingsData.availability_rules,
5466      default_availability: this.customData.default_availability,
5467      resource_id: resource_id,
5468      resource_ids: this.customData.resource_ids,
5469      resources_assignment: this.customData.resources_assignment
5470    };
5471    var bookable = wc_bookings_date_picker.is_blocks_bookable(block_args);
5472    if ('not_bookable_by_rules' === bookable) {
5473      attributes.class.push('not_bookable_by_rules');
5474      bookable = false;
5475    }
5476
5477    // Fully booked?
5478    if (this.bookingsData.fully_booked_days[ymdIndex]) {
5479      // If product does not have any resources, mark as fully booked if found in the array.
5480      // OR if a product with customer defined resources found in an array, mark as fully booked.
5481      // This conditions fixes issues #2881 & #3453.
5482      if (this.bookingsData.fully_booked_days[ymdIndex][0] && 0 === this.customData.resource_ids.length || 0 !== resource_id && this.bookingsData.fully_booked_days[ymdIndex][resource_id]) {
5483        attributes.title = booking_form_params.i18n_date_fully_booked;
5484        attributes.selectable = false;
5485        attributes.class.push('fully_booked');
5486        return attributes;
5487      } else if ('automatic' === this.customData.resources_assignment) {
5488        attributes.class.push('partial_booked');
5489      }
5490    }
5491
5492    // Apply partially booked CSS class.
5493    if (this.bookingsData.partially_booked_days && this.bookingsData.partially_booked_days[ymdIndex]) {
5494      if ('automatic' === this.customData.resources_assignment || this.bookingsData.partially_booked_days[ymdIndex][0] || this.bookingsData.partially_booked_days[ymdIndex][resource_id]) {
5495        attributes.class.push('partial_booked');
5496      }
5497    }
5498
5499    // Calculate end date to check 'in-range' or not.
5500    var fieldset = this.$picker.closest('fieldset');
5501    var start_date = $.datepicker.parseDate($.datepicker.ISO_8601, wc_bookings_date_picker.get_input_date(fieldset, ''));
5502    var end_date;
5503    if (this.$picker.data('is_range_picker_enabled')) {
5504      end_date = $.datepicker.parseDate($.datepicker.ISO_8601, wc_bookings_date_picker.get_input_date(fieldset, 'to_'));
5505    } else if (start_date && number_of_days > 1) {
5506      // We only want to do this for days, and number_of_days will
5507      // be 1 if the duration day is something different
5508      end_date = new Date(start_date);
5509      end_date.setDate(end_date.getDate() + (number_of_days - 1));
5510    }
5511
5512    // Add bookable-range CSS to all days in the range
5513    const inRange = start_date && (moment_date.isSame(start_date, 'day') || end_date && moment_date.isSameOrAfter(start_date, 'day') && moment_date.isSameOrBefore(end_date, 'day'));
5514
5515    // Add bookable-range CSS to all days in the range
5516    if (inRange) {
5517      attributes.class.push('bookable-range');
5518      // Add either selection-start-date or selection-end-date CSS to the first/last day only
5519      if (moment_date.isSame(start_date, 'day')) {
5520        attributes.class.push('selection-start-date');
5521      } else if (moment_date.isSame(end_date, 'day')) {
5522        attributes.class.push('selection-end-date');
5523      }
5524    }
5525    if (!bookable) {
5526      attributes.title = booking_form_params.i18n_date_unavailable;
5527      attributes.selectable = bookable;
5528      if (0 === resource_id) {
5529        attributes.class.push([this.bookingsData.fully_booked_days[ymdIndex] ? 'fully_booked' : 'not_bookable']);
5530      } else if (this.bookingsData.fully_booked_days[ymdIndex] && this.bookingsData.fully_booked_days[ymdIndex][resource_id]) {
5531        attributes.class.push([this.bookingsData.fully_booked_days[ymdIndex][resource_id] ? 'fully_booked' : 'not_bookable']);
5532      }
5533    } else {
5534      if (attributes.class.indexOf('partial_booked') > -1) {
5535        attributes.title = booking_form_params.i18n_date_partially_booked;
5536      } else if ('' === attributes.title) {
5537        attributes.title = booking_form_params.i18n_date_available;
5538      }
5539      if (!inRange) {
5540        attributes.class.push('bookable');
5541      }
5542    }
5543
5544    /**
5545     * Filter date element attributes.
5546     *
5547     * @param {object} attributes Attributes for the date element.
5548     * @param {object} this.bookingsData Booking data.
5549     * @param {object} this.$picker Date picker.
5550     *
5551     * @since 1.15.79
5552     */
5553    attributes = (0,utils/* HookApi */.A)().applyFilters('wc_bookings_date_picker_get_day_attributes', attributes, {
5554      booking_data: this.bookingsData,
5555      custom_data: this.customData,
5556      date_picker: this.$picker,
5557      resource_id,
5558      date
5559    });
5560    return attributes;
5561  };
5562  moment.locale(wc_bookings_locale);
5563  wc_bookings_date_picker.init();
5564  // use global object added by wp_localize_script
5565  wc_bookings_booking_form.wc_bookings_date_picker = wc_bookings_date_picker;
5566});
5567})();
5568
5569// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
5570(() => {
5571/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(428);
5572/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
5573/**
5574 * External dependencies
5575 */
5576
5577jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).ready(function ($) {
5578  var startSel = null,
5579    endSel = null;
5580  $('.wc-bookings-booking-form').closest('form').each((index, form) => {
5581    const $form = $(form);
5582    if ($form.find('.picker').data('is_range_picker_enabled')) {
5583      $form.find('p.wc_bookings_field_duration').hide();
5584    }
5585  });
5586  $('.block-picker').on('click', 'a', function () {
5587    const bookingform = $(this).closest('form');
5588    const $picker = bookingform.find('.picker');
5589
5590    // Enable this event for month duration only to prevent unwanted ajax calls.
5591    if (!bookingform.find('[name="wc_bookings_field_start_date_yearmonth"]').length) {
5592      return false;
5593    }
5594    var value = $(this).data('value');
5595    var target = $(this).closest('div').find('input');
5596    var range;
5597    var value = $(this).data('value');
5598    var block_picker = $(this).closest('ul');
5599    set_selected_month(block_picker, value);
5600    if (!$picker.data('is_range_picker_enabled')) {
5601      // If we are not using range picker just trigger change for AJAX request.
5602      target.val(value).trigger('change');
5603      return;
5604    }
5605
5606    // Unselect everything and set duration to default value.
5607    $(this).parent().siblings().children('a').removeClass('selected');
5608    $('#wc_bookings_field_duration').val(1);
5609    if (startSel && endSel) {
5610      // If we have both start and end selection, reset end.
5611      startSel = $(this).parent();
5612      endSel = null;
5613    } else if (startSel) {
5614      value = startSel.find('a').data('value');
5615      // If we have start selection, we set end selection and do calculation.
5616      endSel = $(this).parent();
5617      if (startSel.is(endSel)) {
5618        // Not a range, just a single entry.
5619        range = startSel;
5620      } else {
5621        // There is a range so select every entry inclusive.
5622        range = startSel.nextUntil(endSel).addBack();
5623        range = range.add(range.last().next());
5624      }
5625      range.children('a').addClass('selected');
5626
5627      // Set duration and date and trigger change for AJAX request.
5628      $('#wc_bookings_field_duration').val(range.length);
5629    } else {
5630      startSel = $(this).parent();
5631    }
5632    target.val(value).trigger('change');
5633  });
5634  var max_width = 0;
5635  var max_height = 0;
5636  $('.block-picker a').each(function () {
5637    var width = $(this).width();
5638    var height = $(this).height();
5639    if (width > max_width) {
5640      max_width = width;
5641    }
5642    if (height > max_height) {
5643      max_height = height;
5644    }
5645  });
5646  $('.block-picker a').width(max_width);
5647  $('.block-picker a').height(max_height);
5648  function set_selected_month(block_picker, value) {
5649    var submit_button = block_picker.closest('form').find('.wc-bookings-booking-form-button');
5650    if (undefined === value) {
5651      submit_button.addClass('disabled');
5652      return;
5653    }
5654    var selected_block = block_picker.find('[data-value="' + value + '"]');
5655    if (undefined === selected_block.data('value')) {
5656      submit_button.addClass('disabled');
5657      return;
5658    }
5659    block_picker.closest('ul').find('a').removeClass('selected');
5660    selected_block.addClass('selected');
5661    submit_button.removeClass('disabled');
5662  }
5663});
5664})();
5665
5666// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
5667(() => {
5668/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(428);
5669/* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
5670/* harmony import */ var _bookings_lib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
5671/**
5672 * External dependencies
5673 */
5674
5675
5676/**
5677 * Internal dependencies
5678 */
5679
5680jquery__WEBPACK_IMPORTED_MODULE_0___default()(document).ready(function ($) {
5681  var local_timezone = moment.tz.guess() || booking_form_params.server_timezone;
5682  if (booking_form_params.timezone_conversion) {
5683    $('.wc-bookings-date-picker-timezone').text(local_timezone.replace('_', ' '));
5684    $('[name="wc_bookings_field_start_date_local_timezone"]').val(local_timezone);
5685  }
5686  $('.block-picker').on('click', 'a', function () {
5687    const bookingform = $(this).closest('form');
5688
5689    // Don't enable this event for month duration.
5690    if (bookingform.find('[name="wc_bookings_field_start_date_yearmonth"]').length) {
5691      return false;
5692    }
5693    var value = $(this).data('value');
5694    var block_picker = $(this).closest('ul');
5695    set_selected_time(block_picker, value);
5696    return false;
5697  });
5698  function set_selected_time(block_picker, value) {
5699    var submit_button = block_picker.closest('form').find('.wc-bookings-booking-form-button');
5700    if (undefined === value) {
5701      submit_button.addClass('disabled');
5702      return;
5703    }
5704    var selected_block = block_picker.find('[data-value="' + value + '"]');
5705    if (undefined === selected_block.data('value')) {
5706      submit_button.addClass('disabled');
5707      return;
5708    }
5709    var target = block_picker.closest('div').find('input');
5710    target.val(value).trigger('change');
5711    block_picker.closest('ul').find('a').removeClass('selected');
5712    selected_block.addClass('selected');
5713    submit_button.removeClass('disabled');
5714  }
5715  function time_picker_reset_selected(block_picker) {
5716    block_picker.closest('ul').find('a').removeClass('selected');
5717  }
5718  wc_bookings_booking_form.time_picker_reset_selected = time_picker_reset_selected;
5719  $('.wc-bookings-booking-form').on('change', '#wc-bookings-form-start-time', function () {
5720    var value = $(this).val(),
5721      bookingForm = $(this).closest('form'),
5722      id = $(this).parents('.wc-bookings-start-time-container').data('productId'),
5723      blocks = $(this).parents('.wc-bookings-start-time-container').data('blocks'),
5724      formField = $(this).parents('.form-field').eq(0);
5725
5726    // Disable end time dropdown.
5727    $('#wc-bookings-form-end-time').attr('disabled', 'disabled');
5728
5729    // Set the end time dropdown opacity.
5730    $('#wc-bookings-form-end-time').css('opacity', '0.5');
5731
5732    // Hide the cost as a reset.
5733    $(this).closest('form').find('.wc-bookings-booking-cost').html('').hide();
5734    if ('0' === value) {
5735      $(this).closest('form').find('.wc-bookings-booking-form-button').addClass('disabled');
5736      return false;
5737    }
5738
5739    // Disable the Book button.
5740    bookingForm.find('.wc-bookings-booking-form-button').addClass('disabled');
5741    var resource_id = bookingForm.find('#wc_bookings_field_resource').val();
5742    var year_str = bookingForm.find('input.booking_date_year').val();
5743    var year = parseInt(year_str, 10);
5744    var month_str = bookingForm.find('input.booking_date_month').val();
5745    var month = parseInt(month_str, 10);
5746    var day_str = bookingForm.find('input.booking_date_day').val();
5747    var day = parseInt(day_str, 10);
5748    var person_qty = bookingForm.find('#wc_bookings_field_persons').val();
5749    var date_str = year_str + '-' + month_str + '-' + day_str;
5750    if (!year || !month || !day) {
5751      return;
5752    }
5753    xhr = $.ajax({
5754      type: 'POST',
5755      url: booking_form_params.ajax_url,
5756      data: {
5757        action: 'wc_bookings_get_end_time_html',
5758        security: booking_form_params.nonce.get_end_time_html,
5759        start_date_time: value,
5760        product_id: id,
5761        blocks: blocks,
5762        resource_id: resource_id,
5763        person_qty
5764      },
5765      success: function (response) {
5766        bookingForm.find('.wc-bookings-end-time-container').replaceWith(response);
5767        offset_block_times_for_end_time(date_str);
5768        formField.find('input.required_for_calculation').val(value);
5769      },
5770      dataType: "html"
5771    });
5772    return false;
5773  });
5774  $('.wc-bookings-booking-form').on('change', '#wc-bookings-form-end-time', function () {
5775    // Hide the cost as a reset.
5776    $('.wc-bookings-booking-cost').html('').hide();
5777    var value = $(this).val(),
5778      block_picker = $(this);
5779    $(this).parents('.wc-bookings-booking-form').find('.wc_bookings_field_duration').val(value);
5780    var submit_button = block_picker.closest('form').find('.wc-bookings-booking-form-button');
5781    if (undefined === value || '0' === value || '0' === $(this).parents('.wc-bookings-booking-form').find('#wc-bookings-form-start-time').val()) {
5782      submit_button.addClass('disabled');
5783      return;
5784    }
5785    block_picker.parents('.form-field').eq(0).find('input.required_for_calculation').trigger('change');
5786    submit_button.removeClass('disabled');
5787  });
5788  function set_selected_customer_time(block_picker, value) {
5789    var submit_button = block_picker.closest('form').find('.wc-bookings-booking-form-button');
5790    if (undefined === value || '0' === value) {
5791      submit_button.addClass('disabled');
5792      return;
5793    }
5794    var target = block_picker.parents('.form-field').eq(0).find('input.required_for_calculation');
5795    target.val(value).trigger('change');
5796    submit_button.removeClass('disabled');
5797  }
5798  $('.wc_bookings_field_duration').on('change', function () {
5799    if (!['hour', 'minute'].includes(wc_bookings_booking_form.get_booking_duration_unit($(this)))) {
5800      return;
5801    }
5802    show_available_time_blocks(this);
5803  });
5804  $('#wc_bookings_field_resource').on('change', function () {
5805    const duration_unit = wc_bookings_booking_form.get_booking_duration_unit($(this));
5806    if ('month' === duration_unit) {
5807      show_available_month_blocks(this);
5808    } else if (!['hour', 'minute'].includes(duration_unit)) {
5809      return;
5810    }
5811    time_picker_reset_selected($('.wc-bookings-booking-form').find('.block-picker'));
5812  });
5813  $('.wc-bookings-booking-form fieldset').on('date-selected', function () {
5814    $('.wc_bookings_field_duration').val(1);
5815    if (!['hour', 'minute'].includes(wc_bookings_booking_form.get_booking_duration_unit($(this)))) {
5816      return;
5817    }
5818    show_available_time_blocks(this);
5819  });
5820  var xhr;
5821  function show_available_month_blocks(element) {
5822    var $form = $(element).closest('form');
5823    var form_val = $form.serialize();
5824    var block_picker = $(element).closest('div').find('.block-picker');
5825    block_picker.closest('div').block({
5826      message: null,
5827      overlayCSS: {
5828        background: '#fff',
5829        backgroundSize: '16px 16px',
5830        opacity: 0.6
5831      }
5832    }).show();
5833    var xhr = $.ajax({
5834      type: 'POST',
5835      url: booking_form_params.ajax_url,
5836      data: {
5837        action: 'wc_bookings_get_booking_blocks',
5838        form: form_val,
5839        security: booking_form_params.nonce.show_available_month_blocks
5840      },
5841      success: function (result) {
5842        result = JSON.parse(result);
5843
5844        // Check for failure.
5845        if (!result.success) {
5846          alert(result.data);
5847          return false;
5848        }
5849        block_picker.closest('div').unblock();
5850        $('.block-picker').html(result.data);
5851      },
5852      error: function (jqXHR, exception) {
5853        if ('abort' === exception) {
5854          return; // Assuming the date is changed very quickly.
5855        }
5856        (0,_bookings_lib__WEBPACK_IMPORTED_MODULE_1__/* .display_error */ .u)();
5857      },
5858      dataType: 'html'
5859    });
5860  }
5861  function show_available_time_blocks(element) {
5862    var $form = $(element).closest('form');
5863    var fieldset = $(element).closest('div').find('fieldset');
5864    var block_picker = $(element).closest('div').find('.block-picker');
5865    var selected_block = block_picker.find('.selected');
5866    var year_str = fieldset.find('input.booking_date_year').val();
5867    var year = parseInt(year_str, 10);
5868    var month_str = fieldset.find('input.booking_date_month').val();
5869    var month = parseInt(month_str, 10);
5870    var day_str = fieldset.find('input.booking_date_day').val();
5871    var day = parseInt(day_str, 10);
5872    var date_str = year_str + '-' + month_str + '-' + day_str;
5873    if (!year || !month || !day) {
5874      return;
5875    }
5876
5877    // clear blocks
5878    block_picker.closest('div').find('input').val('').trigger('change');
5879    block_picker.closest('div').block({
5880      message: null,
5881      overlayCSS: {
5882        background: '#fff',
5883        backgroundSize: '16px 16px',
5884        opacity: 0.6
5885      }
5886    }).show();
5887    $form.find('.wc-bookings-booking-cost').html('').hide();
5888
5889    // Get blocks via ajax
5890    if (xhr) xhr.abort();
5891    var form_val = $form.serialize();
5892
5893    /*
5894     * Get previous/next day in addition to current day based on server/client timezone offset.
5895     * This will give the client enough blocks to fill out 24 hours of blocks in its timezone.
5896     */
5897    var server_offset = (0,_bookings_lib__WEBPACK_IMPORTED_MODULE_1__/* .get_client_server_timezone_offset_hrs */ .f)(date_str);
5898    if (server_offset < 0) {
5899      form_val += '&get_next_day=true';
5900    } else if (server_offset > 0) {
5901      form_val += '&get_prev_day=true';
5902    }
5903    xhr = $.ajax({
5904      type: 'POST',
5905      url: booking_form_params.ajax_url,
5906      data: {
5907        action: 'wc_bookings_get_blocks',
5908        form: form_val
5909      },
5910      success: function (code) {
5911        block_picker.html(code);
5912        resize_blocks();
5913        offset_block_times(date_str, $(element));
5914        block_picker.closest('div').unblock();
5915        set_selected_time(block_picker, selected_block.data('value'));
5916
5917        // Hide error notices.
5918        $('.woocommerce-error.wc-bookings-notice').slideUp();
5919      },
5920      error: function (jqXHR, exception) {
5921        if ('abort' === exception) {
5922          return; // Assuming the date is changed very quickly.
5923        }
5924        (0,_bookings_lib__WEBPACK_IMPORTED_MODULE_1__/* .display_error */ .u)();
5925
5926        // Remove loading spin and refresh the datepicker.
5927        $('.blockOverlay').remove();
5928        wc_bookings_booking_form.wc_bookings_date_picker.clear_selection();
5929        wc_bookings_booking_form.wc_bookings_date_picker.refresh_datepicker();
5930      },
5931      dataType: 'html'
5932    });
5933  }
5934  function resize_blocks() {
5935    var max_width = 0;
5936    var max_height = 0;
5937    $('.block-picker a').each(function () {
5938      var width = $(this).width();
5939      var height = $(this).height();
5940      if (width > max_width) {
5941        max_width = width;
5942      }
5943      if (height > max_height) {
5944        max_height = height;
5945      }
5946    });
5947    $('.block-picker a').width(max_width);
5948    $('.block-picker a').height(max_height);
5949  }
5950  function offset_block_times_for_end_time(date_str) {
5951    if (!booking_form_params.timezone_conversion) {
5952      return;
5953    }
5954    var from = moment.tz(date_str, local_timezone);
5955    var to = moment(from);
5956    var element = '.block-picker #wc-bookings-form-end-time > option';
5957    to.add(1, 'days');
5958    $(element).each(function () {
5959      var block_time = $(this).data('value');
5960      if ('undefined' === typeof block_time || '0' == block_time) {
5961        return true;
5962      }
5963      var server_offset = (0,_bookings_lib__WEBPACK_IMPORTED_MODULE_1__/* .get_client_server_timezone_offset_hrs */ .f)(date_str);
5964      var client_local_time = moment.tz(block_time, booking_form_params.server_timezone);
5965      var duration_display = $(this).data('durationDisplay');
5966      client_local_time.add(server_offset, 'hours');
5967      $(this).text(client_local_time.format(booking_form_params.server_time_format) + duration_display);
5968    });
5969  }
5970  function offset_block_times(date_str, element) {
5971    if (!booking_form_params.timezone_conversion) {
5972      return;
5973    }
5974    const booking_duration_type = wc_bookings_booking_form.get_booking_duration_type(element);
5975    const booking_duration_unit = wc_bookings_booking_form.get_booking_duration_unit(element);
5976    var from = moment.tz(date_str, local_timezone);
5977    var to = moment(from);
5978    var selector = '.block-picker .block a';
5979    to.add(1, 'days');
5980    if ('customer' === booking_duration_type && ['hour', 'minute'].includes(booking_duration_unit)) {
5981      selector = '.block-picker #wc-bookings-form-start-time > option';
5982    }
5983    $(selector).each(function () {
5984      if ('.block-picker #wc-bookings-form-start-time > option' === selector) {
5985        var block_time = $(this).val();
5986      } else {
5987        var block_time = $(this).attr('data-value'); // iso8061 format time string
5988      }
5989      if ('undefined' === typeof block_time || '0' == block_time) {
5990        return true;
5991      }
5992      var server_offset = (0,_bookings_lib__WEBPACK_IMPORTED_MODULE_1__/* .get_client_server_timezone_offset_hrs */ .f)(date_str);
5993      var server_local_time = moment.tz(block_time, booking_form_params.server_timezone);
5994      var client_local_time = moment.tz(block_time, booking_form_params.server_timezone);
5995      client_local_time.add(server_offset, 'hours');
5996      if (!server_local_time.isBetween(from, to, null, '[)')) {
5997        if ('.block-picker #wc-bookings-form-start-time > option' === selector) {
5998          // Delete any blocks outside of today.
5999          $(this).remove();
6000        } else {
6001          // Delete any blocks outside of today.
6002          $(this).parent().remove();
6003        }
6004      } else {
6005        if ('.block-picker #wc-bookings-form-start-time > option' === selector) {
6006          const block_time = moment($(this).val()).unix();
6007          const current_browser_time = moment().unix();
6008          if (block_time <= current_browser_time) {
6009            // Delete any blocks outside of right now in the past.
6010            $(this).remove();
6011          } else {
6012            $(this).text(server_local_time);
6013          }
6014        }
6015        $(this).text(client_local_time.format(booking_form_params.server_time_format));
6016
6017        // If the block has existing bookings, show the remaining slots after the time.
6018        if ($(this).data('remaining')) {
6019          if ('.block-picker #wc-bookings-form-start-time > option' === selector) {
6020            $(this).append(' (' + $(this).data('remaining') + ')');
6021          } else {
6022            $(this).append(' <small class="booking-spaces-left">(' + $(this).data('remaining') + ')</small>');
6023          }
6024        }
6025      }
6026    });
6027  }
6028});
6029})();
6030
6031// This entry need to be wrapped in an IIFE because it need to be isolated against other entry modules.
6032(() => {
6033// extracted by mini-css-extract-plugin
6034
6035})();
6036
6037/******/ })()
6038;
6039//# sourceMappingURL=frontend.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.