(window["webpackJsonpLIS"] = window["webpackJsonpLIS"] || []).push([["vendors~toubiz-events"],{

/***/ "./node_modules/@newland/assets-neos/Scripts/toubiz-events/event-results-list-controller.js":
/*!**************************************************************************************************!*\
  !*** ./node_modules/@newland/assets-neos/Scripts/toubiz-events/event-results-list-controller.js ***!
  \**************************************************************************************************/
/*! exports provided: EventsResultsListController */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"EventsResultsListController\", function() { return EventsResultsListController; });\n/* harmony import */ var _common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../common/selector-utilities */ \"./node_modules/@newland/assets-neos/Scripts/common/selector-utilities.js\");\n/* harmony import */ var _common_results_list_controller_class__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../common/results-list-controller.class */ \"./node_modules/@newland/assets-neos/Scripts/common/results-list-controller.class.js\");\n/* harmony import */ var _common_date_formatting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../common/date-formatting */ \"./node_modules/@newland/assets-neos/Scripts/common/date-formatting.js\");\n/* harmony import */ var _nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @nimius/event-utility */ \"./node_modules/@nimius/event-utility/index.js\");\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _createForOfIteratorHelper(r, e) { var t = \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && \"number\" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n\n\n\n\nvar ATTRIBUTE = Object.freeze({\n  DATE_PICKER: 'data-toubiz-date-picker',\n  DATE_PICKER_BUTTON: 'data-toubiz-date-picker-button',\n  DATE_LINK: 'data-toubiz-events-date',\n  FROM_DATE: 'data-toubiz-events-from-date',\n  TO_DATE: 'data-toubiz-events-to-date',\n  ACTIVE_CLASSES: 'data-toubiz-events-date.active-classes',\n  INACTIVE_CLASSES: 'data-toubiz-events-date.inactive-classes'\n});\nvar EventsResultsListController = /*#__PURE__*/function (_ResultsListControlle) {\n  function EventsResultsListController() {\n    _classCallCheck(this, EventsResultsListController);\n    return _callSuper(this, EventsResultsListController, arguments);\n  }\n  _inherits(EventsResultsListController, _ResultsListControlle);\n  return _createClass(EventsResultsListController, [{\n    key: \"onInitialize\",\n    value: /** @protected */\n    function onInitialize() {\n      this.initializeEventSpecificBehaviour();\n    }\n\n    /** @protected */\n  }, {\n    key: \"onReinitialize\",\n    value: function onReinitialize() {\n      this.initializeEventSpecificBehaviour();\n    }\n\n    /** @private */\n  }, {\n    key: \"initializeEventSpecificBehaviour\",\n    value: function initializeEventSpecificBehaviour() {\n      this.initializeDateLinks();\n      this.initializeDatePicker();\n      this.updateDateFields();\n      this.hasDateSelection = true;\n    }\n\n    /** @private */\n  }, {\n    key: \"updateDateFields\",\n    value: function updateDateFields() {\n      this.fromDate = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.FROM_DATE));\n      this.toDate = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.TO_DATE));\n    }\n\n    /** @private */\n  }, {\n    key: \"initializeDateLinks\",\n    value: function initializeDateLinks() {\n      var _this = this;\n      this.dateLinks = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_LINK), true);\n      var _iterator = _createForOfIteratorHelper(this.dateLinks),\n        _step;\n      try {\n        var _loop = function _loop() {\n          var link = _step.value;\n          link.addEventListener('click', function (event) {\n            event.preventDefault();\n            _this.updateDates(link.getAttribute(ATTRIBUTE.DATE_LINK), link.getAttribute(ATTRIBUTE.DATE_LINK), [link]);\n          });\n        };\n        for (_iterator.s(); !(_step = _iterator.n()).done;) {\n          _loop();\n        }\n      } catch (err) {\n        _iterator.e(err);\n      } finally {\n        _iterator.f();\n      }\n    }\n\n    /** @private */\n  }, {\n    key: \"initializeDatePicker\",\n    value: function initializeDatePicker() {\n      var _this2 = this;\n      this.picker = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_PICKER));\n      if (!this.picker) {\n        return;\n      }\n      this.pickerButton = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_PICKER_BUTTON));\n      this.picker.addEventListener('toubiz-date-picker.change', function (event) {\n        return _this2.updateDates(event.detail.range.start, event.detail.range.end, [_this2.picker, _this2.pickerButton]);\n      });\n    }\n  }, {\n    key: \"resetDateSelection\",\n    value: function resetDateSelection() {\n      this.fromDate.value = '';\n      this.toDate.value = '';\n      Object(_nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__[\"fireEvent\"])(this.picker, 'toubiz-date-picker.set', {\n        start: null,\n        end: null\n      });\n      this.toggleSelection();\n    }\n\n    /**\n     * @private\n     * @param {Date|string} fromDate\n     * @param {Date|string} toDate\n     * @param {HTMLElement} element\n     */\n  }, {\n    key: \"updateDates\",\n    value: function updateDates(fromDate, toDate) {\n      var elementsToActivate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];\n      var fromBefore = this.fromDate.value;\n      var toBefore = this.toDate.value;\n      Object(_nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__[\"fireEvent\"])(this.toggleButton, 'target-enhancement.close');\n      var from = fromDate instanceof Date ? fromDate : this.parseDateString(fromDate);\n      var to = toDate instanceof Date ? toDate : this.parseDateString(toDate);\n      this.fromDate.value = Object(_common_date_formatting__WEBPACK_IMPORTED_MODULE_2__[\"dateToShortIsoString\"])(from);\n      this.toDate.value = Object(_common_date_formatting__WEBPACK_IMPORTED_MODULE_2__[\"dateToShortIsoString\"])(to);\n      if (fromBefore !== this.fromDate.value || toBefore !== this.toDate.value) {\n        var picker = this.select(Object(_common_selector_utilities__WEBPACK_IMPORTED_MODULE_0__[\"attributeSelector\"])(ATTRIBUTE.DATE_PICKER));\n        Object(_nimius_event_utility__WEBPACK_IMPORTED_MODULE_3__[\"fireEvent\"])(picker, 'toubiz-date-picker.set', {\n          start: from,\n          end: to\n        });\n        this.formReload.reload();\n        this.toggleSelection(elementsToActivate, true);\n      }\n    }\n\n    /**\n     * @private\n     * @param {string} string\n     * @returns {Date}\n     */\n  }, {\n    key: \"parseDateString\",\n    value: function parseDateString(string) {\n      var date = new Date();\n      switch (string) {\n        case 'today':\n          return date;\n        case 'tomorrow':\n          date.setDate(date.getDate() + 1);\n          return date;\n        default:\n          return new Date(string);\n      }\n    }\n  }, {\n    key: \"toggleSelection\",\n    value: function toggleSelection() {\n      var elements = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n      var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n      this.toggleElementClasses([].concat(_toConsumableArray(this.dateLinks), [this.picker, this.pickerButton]), false);\n      if (elements.length > 0) {\n        this.toggleElementClasses(elements, state);\n      }\n    }\n  }]);\n}(_common_results_list_controller_class__WEBPACK_IMPORTED_MODULE_1__[\"ResultsListController\"]);\n\n//# sourceURL=webpack://LIS/./node_modules/@newland/assets-neos/Scripts/toubiz-events/event-results-list-controller.js?");

/***/ })

}]);