From fd06aca57b67c945b57bba86ed346c1ffb74d4c5 Mon Sep 17 00:00:00 2001 From: "gideon.pyzer" Date: Tue, 9 May 2017 17:30:15 +0100 Subject: [PATCH] Only notify of selection change for events triggered from this library to avoid recursive crazyness --- demo/bundle.js | 4 ++-- dist/simple-list-item-range-selector.js | 2 +- package.json | 2 +- src/js/simple-list-item-range-selector.js | 16 +++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/demo/bundle.js b/demo/bundle.js index 7fc4c8b..8a0dc2d 100644 --- a/demo/bundle.js +++ b/demo/bundle.js @@ -69,7 +69,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ /******/ /******/ var hotApplyOnUpdate = true; -/******/ var hotCurrentHash = "2c573dee6c4d20e161d8"; // eslint-disable-line no-unused-vars +/******/ var hotCurrentHash = "7fa5b779677ea6871991"; // eslint-disable-line no-unused-vars /******/ var hotCurrentModuleData = {}; /******/ var hotMainModule = true; // eslint-disable-line no-unused-vars /******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars @@ -1441,7 +1441,7 @@ eval("\n\nvar _simpleListItemRangeSelector = __webpack_require__(116);\n\nvar _s /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\n__webpack_require__(117);\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nvar _instances = [];\n\nvar _clickModes = {\n CTRL_CLICK_TO_SELECT: 1,\n CLICK_TO_SELECT: 2\n};\n\nvar SimpleListItemRangeSelector = {\n createInstance: function createInstance(id) {\n var _clickMode = void 0;\n var _allItemElements = [];\n var _lastClickedIndexWithoutShift = void 0;\n var _rangeSelectionEnabled = true;\n var _newSelection = [];\n var _containerNode = void 0;\n var _itemsSelector = void 0;\n var _selectedClassName = void 0;\n var _resetSelector = void 0;\n var _onSelectionChanged = function _onSelectionChanged() {};\n var _debug = false;\n\n function _init(_ref) {\n var clickMode = _ref.clickMode,\n containerNode = _ref.containerNode,\n childSelector = _ref.childSelector,\n resetSelector = _ref.resetSelector,\n selectedClassName = _ref.selectedClassName,\n onSelectionChanged = _ref.onSelectionChanged,\n _ref$rangeSelectionEn = _ref.rangeSelectionEnabled,\n rangeSelectionEnabled = _ref$rangeSelectionEn === undefined ? true : _ref$rangeSelectionEn,\n debug = _ref.debug;\n\n\n if (containerNode) {\n _containerNode = containerNode;\n\n if (childSelector) {\n _itemsSelector = childSelector;\n } else {\n _itemsSelector = 'li';\n console.warn('No childSelector was specified. Defaulted to \"li\"');\n }\n\n _allItemElements = containerNode.querySelectorAll(_itemsSelector);\n\n if (_allItemElements) {\n _setClickMode(clickMode, SimpleListItemRangeSelector.clickModes.CTRL_CLICK_TO_SELECT);\n\n if (onSelectionChanged && typeof onSelectionChanged === 'function') {\n _onSelectionChanged = onSelectionChanged;\n }\n\n _selectedClassName = selectedClassName;\n _resetSelector = resetSelector;\n _debug = debug;\n\n _registerEvents({ resetEvent: resetSelector, rangeEvent: rangeSelectionEnabled });\n } else {\n throw Error('Items were not found using ' + _itemsSelector + ' selector.');\n }\n } else {\n throw Error('You need to specify a valid containerNode');\n }\n }\n\n function _ctrlKeyUsed(e) {\n var isMacUser = navigator.platform.indexOf('Mac') !== -1;\n\n if (isMacUser && e.metaKey) return true;else if (!isMacUser && e.ctrlKey) return true;\n\n return false;\n }\n\n function _setClickMode(clickMode, defaultMode) {\n if (_isValidClickMode(clickMode)) {\n _clickMode = clickMode;\n } else {\n _clickMode = defaultMode;\n console.warn('Invalid clickMode was specified. Defaulted to \"' + defaultMode.toString() + '\"');\n }\n }\n\n function _registerEvents() {\n var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref2$resetEvent = _ref2.resetEvent,\n resetEvent = _ref2$resetEvent === undefined ? false : _ref2$resetEvent,\n _ref2$rangeEvent = _ref2.rangeEvent,\n rangeEvent = _ref2$rangeEvent === undefined ? true : _ref2$rangeEvent;\n\n if (resetEvent && _resetSelector) {\n var resetElem = document.querySelector(_resetSelector);\n resetElem.addEventListener('click', _clearAllSelectionsHandler);\n }\n\n if (rangeEvent) {\n _rangeSelectionEnabled = true;\n _containerNode.addEventListener('selectstart', _preventDefaultHandler);\n }\n\n [].concat(_toConsumableArray(_allItemElements)).forEach(function (elem, index) {\n elem.setAttribute('data-slirs-index', index.toString());\n elem.addEventListener('click', _clickElementHandler);\n });\n }\n\n function _unregisterEvents() {\n var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref3$resetEvent = _ref3.resetEvent,\n resetEvent = _ref3$resetEvent === undefined ? false : _ref3$resetEvent,\n _ref3$rangeEvent = _ref3.rangeEvent,\n rangeEvent = _ref3$rangeEvent === undefined ? true : _ref3$rangeEvent,\n _ref3$clickEvent = _ref3.clickEvent,\n clickEvent = _ref3$clickEvent === undefined ? true : _ref3$clickEvent;\n\n if (resetEvent && _resetSelector) {\n var resetElem = document.querySelector(_resetSelector);\n resetElem.removeEventListener('click', _clearAllSelectionsHandler);\n }\n\n if (rangeEvent) {\n _rangeSelectionEnabled = false;\n _containerNode.removeEventListener('selectstart', _preventDefaultHandler);\n }\n\n if (clickEvent) {\n [].concat(_toConsumableArray(_allItemElements)).forEach(function (elem) {\n elem.removeEventListener('click', _clickElementHandler);\n });\n }\n }\n\n function _updateDOM(selection) {\n var selectedItems = [];\n var sortedSelection = selection.concat().sort();\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = _allItemElements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n\n var index = _indexOfItem(item);\n if (sortedSelection.includes(index)) {\n selectedItems.push(item);\n if (!_isItemSelected(item)) {\n item.setAttribute('data-slirs-selected', '1');\n if (_selectedClassName) {\n item.classList.add(_selectedClassName);\n }\n }\n } else {\n if (_isItemSelected(item)) {\n item.removeAttribute('data-slirs-selected');\n if (_selectedClassName) {\n item.classList.remove(_selectedClassName);\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n _onSelectionChanged(selectedItems);\n }\n\n function _updateSelection(e, updateDOM) {\n var item = this;\n var selectedItemIndex = _indexOfItem(item);\n\n if (!e.shiftKey || !_rangeSelectionEnabled) {\n _lastClickedIndexWithoutShift = selectedItemIndex;\n\n if (_isItemSelected(item)) {\n if (_clickMode === _clickModes.CTRL_CLICK_TO_SELECT && !_ctrlKeyUsed(e)) {\n // if user clicks without CTRL key, clear everything and select the one they clicked on\n _newSelection = [];\n _newSelection.push(selectedItemIndex);\n } else {\n // CTRL clicking or clicking in CLICK_TO_SELECT mode will unselect the item\n _newSelection.splice(_newSelection.indexOf(selectedItemIndex), 1);\n }\n } else {\n if (_clickMode === _clickModes.CTRL_CLICK_TO_SELECT && !_ctrlKeyUsed(e)) {\n // clear all selected items first if not using CTRL key\n _newSelection = [];\n }\n\n _newSelection.push(selectedItemIndex);\n }\n } else {\n var firstSelectedItem = document.querySelector(_itemsSelector + '[data-slirs-selected=\"1\"]');\n\n if (!firstSelectedItem) {\n // first item selected had shift modified applied so just select it normally\n _newSelection.push(selectedItemIndex);\n _lastClickedIndexWithoutShift = selectedItemIndex;\n updateDOM(_newSelection);\n return;\n }\n\n var firstSelectedItemIndex = _indexOfItem(firstSelectedItem);\n\n if (_debug) {\n console.log(\"first selected item: \", firstSelectedItemIndex, \" current selected item: \", selectedItemIndex, \" last selected item without shift: \", _lastClickedIndexWithoutShift);\n }\n\n if (firstSelectedItemIndex === selectedItemIndex) {\n // multiple items are selected currently and user wants to reduce range to just the selected item\n _unselectItemsWithinRange({\n start: selectedItemIndex + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n } else if (firstSelectedItemIndex < selectedItemIndex) {\n if (selectedItemIndex > _lastClickedIndexWithoutShift) {\n // user wants to add the next items up until selected item to complete a forward range\n _selectItemsWithinRange({ start: _lastClickedIndexWithoutShift + 1, end: selectedItemIndex });\n // the user may be reducing the range as a result, so clear selection after the current selected item\n _unselectItemsWithinRange({\n start: selectedItemIndex + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n // if a previous selection is before the last clicked index without a shift, we need to clear it\n _unselectItemsWithinRange({ start: _lastClickedIndexWithoutShift - 1, end: 0, mode: 'reverse' });\n } else {\n\n // user is selecting from the selected item to the last clicked item without shift\n _selectItemsWithinRange({ start: selectedItemIndex, end: _lastClickedIndexWithoutShift - 1 });\n // the user is reducing the selection above the last clicked index without shift, so we need to clear selection before the current selected item\n _unselectItemsWithinRange({ start: selectedItemIndex - 1, end: 0, mode: 'reverse' });\n // clear items after the last clicked index without shift\n _unselectItemsWithinRange({\n start: _lastClickedIndexWithoutShift + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n }\n } else {\n // user is selecting range upwards, so select between the last clicked index without shift and the selected item\n _selectItemsWithinRange({ start: selectedItemIndex, end: _lastClickedIndexWithoutShift });\n // clear items after the last clicked index without shift\n _unselectItemsWithinRange({\n start: _lastClickedIndexWithoutShift + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n }\n }\n\n updateDOM(_newSelection);\n }\n\n function _selectItemsWithinRange(_ref4) {\n var start = _ref4.start,\n end = _ref4.end;\n\n if (start < 0 || end < start) return;\n\n for (var i = start; i <= end; i++) {\n var item = _allItemElements[i];\n if (item && !_isItemSelected(item)) {\n var index = _indexOfItem(item);\n _newSelection.push(index);\n }\n }\n }\n\n function _unselectItemAtIndex(index) {\n var item = _allItemElements[index];\n if (item && _isItemSelected(item)) {\n _newSelection.splice(_newSelection.indexOf(index), 1);\n }\n }\n\n function _unselectItemsWithinRange(_ref5) {\n var start = _ref5.start,\n end = _ref5.end,\n mode = _ref5.mode;\n\n if (start < 0) return;\n\n if (mode === 'reverse' && end <= start) {\n for (var i = start; i >= end; i--) {\n _unselectItemAtIndex(i);\n }\n } else if (mode === 'forward' && end > start) {\n for (var _i = start; _i <= end; _i++) {\n _unselectItemAtIndex(_i);\n }\n }\n }\n\n function _isItemSelected(item) {\n return item.hasAttribute('data-slirs-selected', '1');\n }\n\n function _clearAllSelectionsHandler() {\n _newSelection = [];\n _updateDOM(_newSelection);\n }\n\n function _preventDefaultHandler(e) {\n e.preventDefault();\n return false;\n }\n\n function _clickElementHandler(e) {\n _updateSelection.call(this, e, _updateDOM);\n }\n\n function _indexOfItem(item) {\n try {\n return parseInt(item.getAttribute('data-slirs-index'));\n } catch (e) {\n throw Error('Index doesn\\'t exist. Something went dreadfully wrong.');\n }\n }\n\n function _isValidClickMode(value) {\n var isValid = false;\n\n if (typeof value === 'undefined' || value === '') {\n return false;\n }\n\n for (var mode in _clickModes) {\n if (value === _clickModes[mode]) {\n isValid = true;\n }\n }\n\n return isValid;\n }\n\n function _selectItem(item) {\n if (item && !_isItemSelected(item)) {\n var index = _indexOfItem(item);\n _newSelection.push(index);\n }\n\n _updateDOM(_newSelection);\n }\n\n function _unselectItem(item) {\n if (item) {\n var index = _indexOfItem(item);\n _unselectItemAtIndex(index);\n }\n\n _updateDOM(_newSelection);\n }\n\n function _disableRangeSelection() {\n _unregisterEvents({ rangeEvent: true, clickEvent: false });\n }\n\n function _resetDOM() {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = _allItemElements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n item.removeAttribute('data-slirs-index');\n item.removeAttribute('data-slirs-selected');\n\n if (_selectedClassName) {\n item.classList.remove(_selectedClassName);\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n\n function _reset() {\n _newSelection = [];\n _unregisterEvents({ resetEvent: true, rangeEvent: true, clickEvent: true });\n _resetDOM();\n }\n\n function _updateForNewItems(containerNode) {\n if (_debug) {\n console.log(\"Going to do update for new items\");\n }\n\n _containerNode = containerNode;\n\n if (_containerNode) {\n _allItemElements = _containerNode.querySelectorAll(_itemsSelector);\n\n [].concat(_toConsumableArray(_allItemElements)).forEach(function (elem, index) {\n elem.setAttribute('data-slirs-index', index.toString());\n elem.addEventListener('click', _clickElementHandler);\n });\n }\n }\n\n var instance = {\n id: id,\n init: _init,\n setClickMode: _setClickMode,\n selectItem: _selectItem,\n unselectItem: _unselectItem,\n disableRangeSelection: _disableRangeSelection,\n unregisterEvents: _unregisterEvents,\n updateForNewItems: _updateForNewItems,\n clearAllSelections: _clearAllSelectionsHandler,\n reset: _reset\n };\n\n _instances.push(instance);\n\n return instance;\n },\n getInstance: function getInstance(id) {\n return _instances.find(function (instance) {\n return instance.id === id;\n });\n },\n removeInstance: function removeInstance(id) {\n var instance = this.getInstance(id);\n\n if (instance) {\n instance.reset();\n var indexToRemove = _instances.indexOf(instance);\n _instances.splice(indexToRemove, 1);\n } else {\n throw Error('Instance cannot be found at Id' + id);\n }\n },\n\n clickModes: _clickModes\n};\n\nmodule.exports = SimpleListItemRangeSelector;//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMTE2LmpzIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vLy4vc3JjL2pzL3NpbXBsZS1saXN0LWl0ZW0tcmFuZ2Utc2VsZWN0b3IuanM/MTVmYyJdLCJzb3VyY2VzQ29udGVudCI6WyIndXNlIHN0cmljdCc7XG5cbnJlcXVpcmUoJ2JhYmVsLXBvbHlmaWxsJyk7XG5cbmZ1bmN0aW9uIF90b0NvbnN1bWFibGVBcnJheShhcnIpIHsgaWYgKE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gICAgZnVuY3Rpb24gX2luaXQoX3JlZikge1xuICAgICAgICAgICAgdmFyIGNsaWNrTW9kZSA9IF9yZWYuY2xpY2tNb2RlLFxuICAgICAgICAgICAgICAgIGNvbnRhaW5lck5vZGUgPSBfcmVmLmNvbnRhaW5lck5vZGUsXG4gICAgICAgICAgICAgICAgY2hpbGRTZWxlY3RvciA9IF9yZWYuY2hpbGRTZWxlY3RvcixcbiAgICAgICAgICAgICAgICByZXNldFNlbGVjdG9yID0gX3JlZi5yZXNldFNlbGVjdG9yLFxuICAgICAgICAgICAgICAgIHNlbGVjdGVkQ2xhc3NOYW1lID0gX3JlZi5zZWxlY3RlZENsYXNzTmFtZSxcbiAgICAgICAgICAgICAgICBvblNlbGVjdGlvbkNoYW5nZWQgPSBfcmVmLm9uU2VsZWN0aW9uQ2hhbmdlZCxcbiAgICAgICAgICAgICAgICBfcmVmJHJhbmdlU2VsZWN0aW9uRW4gPSBfcmVmLnJhbmdlU2VsZWN0aW9uRW5hYmxlZCxcbiAgICAgICAgICAgICAgICByYW5nZVNlbGVjdGlvbkVuYWJsZWQgPSBfcmVmJHJhbmdlU2VsZWN0aW9uRW4gPT09IHVuZGVmaW5lZCA/IHRydWUgOiBfcmVmJHJhbmdlU2VsZWN0aW9uRW4sXG4gICAgICAgICAgICAgICAgZGVidWcgPSBfcmVmLmRlYnVnO1xuXG5cbiAgICAgICAgICAgIGlmIChjb250YWluZXJOb2RlKSB7XG4gICAgICAgICAgICAgICAgX2NvbnRhaW5lck5vZGUgPSBjb250YWluZXJOb2RlO1xuXG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkU2VsZWN0b3IpIHtcbiAgICAgICAgICAgICAgICAgICAgX2l0ZW1zU2VsZWN0b3IgPSBjaGlsZFNlbGVjdG9yO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIF9pdGVtc1NlbGVjdG9yID0gJ2xpJztcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS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ICAgICAgIHZhciByZXNldEVsZW0gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKF9yZXNldFNlbGVjdG9yKTtcbiAgICAgICAgICAgICAgICByZXNldEVsZW0ucmVtb3ZlRXZlbnRMaXN0ZW5lcignY2xpY2snLCBfY2xlYXJBbGxTZWxlY3Rpb25zSGFuZGxlcik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChyYW5nZUV2ZW50KSB7XG4gICAgICAgICAgICAgICAgX3JhbmdlU2VsZWN0aW9uRW5hYmxlZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIF9jb250YWluZXJOb2RlLnJlbW92ZUV2ZW50TGlzdGVuZXIoJ3NlbGVjdHN0YXJ0JywgX3ByZXZlbnREZWZhdWx0SGFuZGxlcik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjbGlja0V2ZW50KSB7XG4gICAgICAgICAgICAgICAgW10uY29uY2F0KF90b0NvbnN1bWFibGVBcnJheShfYWxsSXRlbUVsZW1lbnRzKSkuZm9yRWFjaChmdW5jdGlvbiAoZWxlbSkge1xuICAgICAgICAgICAgICAgICAgICBlbGVtLnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgX2NsaWNrRWxlbWVudEhhbmRsZXIpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZURPTShzZWxlY3Rpb24pIHtcbiAgICAgICAgICAgIHZhciBzZWxlY3RlZEl0ZW1zID0gW107XG4gICAgICAgICAgICB2YXIgc29ydGVkU2VsZWN0aW9uID0gc2VsZWN0aW9uLmNvbmNhdCgpLnNvcnQoKTtcblxuICAgICAgICAgICAgdmFyIF9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24gPSB0cnVlO1xuICAgICAgICAgICAgdmFyIF9kaWRJdGVyYXRvckVycm9yID0gZmFsc2U7XG4gICAgICAgICAgICB2YXIgX2l0ZXJhdG9yRXJyb3IgPSB1bmRlZmluZWQ7XG5cbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgX2l0ZXJhdG9yID0gX2FsbEl0ZW1FbGVtZW50c1tTeW1ib2wuaXRlcmF0b3JdKCksIF9zdGVwOyAhKF9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24gPSAoX3N0ZXAgPSBfaXRlcmF0b3IubmV4dCgpKS5kb25lKTsgX2l0ZXJhdG9yTm9ybWFsQ29tcGxldGlvbiA9IHRydWUpIHtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGl0ZW0gPSBfc3RlcC52YWx1ZTtcblxuICAgICAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBfaW5kZXhPZkl0ZW0oaXRlbSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChzb3J0ZWRTZWxlY3Rpb24uaW5jbHVkZXMoaW5kZXgpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZWxlY3RlZEl0ZW1zLnB1c2goaXRlbSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIV9pc0l0ZW1TZWxlY3RlZChpdGVtKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW0uc2V0QXR0cmlidXRlKCdkYXRhLXNsaXJzLXNlbGVjdGVkJywgJzEnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoX3NlbGVjdGVkQ2xhc3NOYW1lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW0uY2xhc3NMaXN0LmFkZChfc2VsZWN0ZWRDbGFzc05hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfaXNJdGVtU2VsZWN0ZWQoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtLnJlbW92ZUF0dHJpYnV0ZSgnZGF0YS1zbGlycy1zZWxlY3RlZCcpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChfc2VsZWN0ZWRDbGFzc05hbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbS5jbGFzc0xpc3QucmVtb3ZlKF9zZWxlY3RlZENsYXNzTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICAgICAgICAgICAgX2RpZEl0ZXJhdG9yRXJyb3IgPSB0cnVlO1xuICAgICAgICAgICAgICAgIF9pdGVyYXRvckVycm9yID0gZXJyO1xuICAgICAgICAgICAgfSBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIV9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24gJiYgX2l0ZXJhdG9yLnJldHVybikge1xuICAgICAgICAgICAgICAgICAgICAgICAgX2l0ZXJhdG9yLnJldHVybigpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKF9kaWRJdGVyYXRvckVycm9yKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBfaXRlcmF0b3JFcnJvcjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgX29uU2VsZWN0aW9uQ2hhbmdlZChzZWxlY3RlZEl0ZW1zKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF91cGRhdGVTZWxlY3Rpb24oZSwg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hvdXRTaGlmdCArIDEsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZW5kOiBfYWxsSXRlbUVsZW1lbnRzLmxlbmd0aCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiAnZm9yd2FyZCdcbiAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gdXNlciBpcyBzZWxlY3RpbmcgcmFuZ2UgdXB3YXJkcywgc28gc2VsZWN0IGJldHdlZW4gdGhlIGxhc3QgY2xpY2tlZCBpbmRleCB3aXRob3V0IHNoaWZ0IGFuZCB0aGUgc2VsZWN0ZWQgaXRlbVxuICAgICAgICAgICAgICAgICAgICBfc2VsZWN0SXRlbXNXaXRoaW5SYW5nZSh7IHN0YXJ0OiBzZWxlY3RlZEl0ZW1JbmRleCwgZW5kOiBfbGFzdENsaWNrZWRJbmRleFdpdGhvdXRTaGlmdCB9KTtcbiAgICAgICAgICAgICAgICAgICAgLy8gY2xlYXIgaXRlbXMgYWZ0ZXIgdGhlIGxhc3QgY2xpY2tlZCBpbmRleCB3aXRob3V0IHNoaWZ0XG4gICAgICAgICAgICAgICAgICAgIF91bnNlbGVjdEl0ZW1zV2l0aGluUmFuZ2Uoe1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IF9sYXN0Q2xpY2tlZEluZGV4V2l0aG91dFNoaWZ0ICsgMSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZDogX2FsbEl0ZW1FbGVtZW50cy5sZW5ndGgsXG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiAnZm9yd2FyZCdcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB1cGRhdGVET00oX25ld1NlbGVjdGlvbik7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfc2VsZWN0SXRlbXNXaXRoaW5SYW5nZShfcmVmNCkge1xuICAgICAgICAgICAgdmFyIHN0YXJ0ID0gX3JlZjQuc3RhcnQsXG4gICAgICAgICAgICAgICAgZW5kID0gX3JlZjQuZW5kO1xuXG4gICAgICAgICAgICBpZiAoc3RhcnQgPCAwIHx8IGVuZCA8IHN0YXJ0KSByZXR1cm47XG5cbiAgICAgICAgICAgIGZvciAodmFyIGkgPSBzdGFydDsgaSA8PSBlbmQ7IGkrKykge1xuICAgICAgICAgICAgICAgIHZhciBpdGVtID0gX2FsbEl0ZW1FbGVtZW50c1tpXTtcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSAmJiAhX2lzSXRlbVNlbGVjdGVkKGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IF9pbmRleE9mSXRlbShpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgX25ld1NlbGVjdGlvbi5wdXNoKGluZGV4KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfdW5zZWxlY3RJdGVtQXRJbmRleChpbmRleCkge1xuICAgICAgICAgICAgdmFyIGl0ZW0gPSBfYWxsSXRlbUVsZW1lbnRzW2luZGV4XTtcbiAgICAgICAgICAgIGlmIChpdGVtICYmIF9pc0l0ZW1TZWxlY3RlZChpdGVtKSkge1xuICAgICAgICAgICAgICAgIF9uZXdTZWxlY3Rpb24uc3BsaWNlKF9uZXdTZWxlY3Rpb24uaW5kZXhPZihpbmRleCksIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3Vuc2VsZWN0SXRlbXNXaXRoaW5SYW5nZShfcmVmNSkge1xuICAgICAgICAgICAgdmFyIHN0YXJ0ID0gX3JlZjUuc3RhcnQsXG4gICAgICAgICAgICAgICAgZW5kID0gX3JlZjUuZW5kLFxuICAgICAgIC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pb24gX2NsaWNrRWxlbWVudEhhbmRsZXIoZSkge1xuICAgICAgICAgICAgX3VwZGF0ZVNlbGVjdGlvbi5jYWxsKHRoaXMsIGUsIF91cGRhdGVET00pO1xuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX2luZGV4T2ZJdGVtKGl0ZW0pIHtcbiAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHBhcnNlSW50KGl0ZW0uZ2V0QXR0cmlidXRlKCdkYXRhLXNsaXJzLWluZGV4JykpO1xuICAgICAgICAgICAgfSBjYXRjaCAoZSkge1xuICAgICAgICAgICAgICAgIHRocm93IEVycm9yKCdJbmRleCBkb2VzblxcJ3QgZXhpc3QuIFNvbWV0aGluZyB3ZW50IGRyZWFkZnVsbHkgd3JvbmcuJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfaXNWYWxpZENsaWNrTW9kZSh2YWx1ZSkge1xuICAgICAgICAgICAgdmFyIGlzVmFsaWQgPSBmYWxzZTtcblxuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZSA9PT0gJ3VuZGVmaW5lZCcgfHwgdmFsdWUgPT09ICcnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBmb3IgKHZhciBtb2RlIGluIF9jbGlja01vZGVzKSB7XG4gICAgICAgICAgICAgICAgaWYgKHZhbHVlID09PSBfY2xpY2tNb2Rlc1ttb2RlXSkge1xuICAgICAgICAgICAgICAgICAgICBpc1ZhbGlkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHJldHVybiBpc1ZhbGlkO1xuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3NlbGVjdEl0ZW0oaXRlbSkge1xuICAgICAgICAgICAgaWYgKGl0ZW0gJiYgIV9pc0l0ZW1TZWxlY3RlZChpdGVtKSkge1xuICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IF9pbmRleE9mSXRlbShpdGVtKTtcbiAgICAgICAgICAgICAgICBfbmV3U2VsZWN0aW9uLnB1c2goaW5kZXgpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBfdXBkYXRlRE9NKF9uZXdTZWxlY3Rpb24pO1xuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3Vuc2VsZWN0SXRlbShpdGVtKSB7XG4gICAgICAgICAgICBpZiAoaXRlbSkge1xuICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IF9pbmRleE9mSXRlbShpdGVtKTtcbiAgICAgICAgICAgICAgICBfdW5zZWxlY3RJdGVtQXRJbmRleChpbmRleCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIF91cGRhdGVET00oX25ld1NlbGVjdGlvbik7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfZGlzYWJsZVJhbmdlU2VsZWN0aW9uKCkge1xuICAgICAgICAgICAgX3VucmVnaXN0ZXJFdmVudHMoeyByYW5nZUV2ZW50OiB0cnVlLCBjbGlja0V2ZW50OiBmYWxzZSB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF9yZXNldERPTSgpIHtcbiAgICAgICAgICAgIHZhciBfaXRlcmF0b3JOb3JtYWxDb21wbGV0aW9uMiA9IHRydWU7XG4gICAgICAgICAgICB2YXIgX2RpZEl0ZXJhdG9yRXJyb3IyID0gZmFsc2U7XG4gICAgICAgICAgICB2YXIgX2l0ZXJhdG9yRXJyb3IyID0gdW5kZWZpbmVkO1xuXG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIGZvciAodmFyIF9pdGVyYXRvcjIgPSBfYWxsSXRlbUVsZW1lbnRzW1N5bWJvbC5pdGVyYXRvcl0oKSwgX3N0ZXAyOyAhKF9pdGVyYXRvck5vcm1hbENvbXBsZXRpb24yID0gKF9zdGVwMiA9IF9pdGVyYXRvcjIubmV4dCgpKS5kb25lKTsgX2l0ZXJhdG9yTm9ybWFsQ29tcGxldGlvbjIgPSB0cnVlKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpdGVtID0gX3N0ZXAyLnZhbHVlO1xuXG4gICAgICAgICAgICAgICAgICAgIGl0ZW0ucmVtb3ZlQXR0cmlidXRlKCdkYXRhLXNsaXJzLWluZGV4Jyk7XG4gICAgICAgICAgICAgICAgICAgIGl0ZW0ucmVtb3ZlQXR0cmlidXRlKCdkYXRhLXNsaXJzLXNlbGVjdGVkJyk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKF9zZWxlY3RlZENsYXNzTmFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRlbS5jbGFzc0xpc3QucmVtb3ZlKF9zZWxlY3RlZENsYXNzTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBfZGlkSXRlcmF0b3JFcnJvcjIgPSB0cnVlO1xuICAgICAgICAgICAgICAgIF9pdGVyYXRvckVycm9yMiA9IGVycjtcbiAgICAgICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFfaXRlcmF0b3JOb3JtYWxDb21wbGV0aW9uMiAmJiBfaXRlcmF0b3IyLnJldHVybikge1xuICAgICAgICAgICAgICAgICAgICAgICAgX2l0ZXJhdG9yMi5yZXR1cm4oKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChfZGlkSXRlcmF0b3JFcnJvcjIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IF9pdGVyYXRvckVycm9yMjtcbiAgICAgICAgICAgICAgICAgIC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ICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaW5zdGFuY2UgPSB7XG4gICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICBpbml0OiBfaW5pdCxcbiAgICAgICAgICAgIHNldENsaWNrTW9kZTogX3NldENsaWNrTW9kZSxcbiAgICAgICAgICAgIHNlbGVjdEl0ZW06IF9zZWxlY3RJdGVtLFxuICAgICAgICAgICAgdW5zZWxlY3RJdGVtOiBfdW5zZWxlY3RJdGVtLFxuICAgICAgICAgICAgZGlzYWJsZVJhbmdlU2VsZWN0aW9uOiBfZGlzYWJsZVJhbmdlU2VsZWN0aW9uLFxuICAgICAgICAgICAgdW5yZWdpc3RlckV2ZW50czogX3VucmVnaXN0ZXJFdmVudHMsXG4gICAgICAgICAgICB1cGRhdGVGb3JOZXdJdGVtczogX3VwZGF0ZUZvck5ld0l0ZW1zLFxuICAgICAgICAgICAgY2xlYXJBbGxTZWxlY3Rpb25zOiBfY2xlYXJBbGxTZWxlY3Rpb25zSGFuZGxlcixcbiAgICAgICAgICAgIHJlc2V0OiBfcmVzZXRcbiAgICAgICAgfTtcblxuICAgICAgICBfaW5zdGFuY2VzLnB1c2goaW5zdGFuY2UpO1xuXG4gICAgICAgIHJldHVybiBpbnN0YW5jZTtcbiAgICB9LFxuICAgIGdldEluc3RhbmNlOiBmdW5jdGlvbiBnZXRJbnN0YW5jZShpZCkge1xuICAgICAgICByZXR1cm4gX2luc3RhbmNlcy5maW5kKGZ1bmN0aW9uIChpbnN0YW5jZSkge1xuICAgICAgICAgICAgcmV0dXJuIGluc3RhbmNlLmlkID09PSBpZDtcbiAgICAgICAgfSk7XG4gICAgfSxcbiAgICByZW1vdmVJbnN0YW5jZTogZnVuY3Rpb24gcmVtb3ZlSW5zdGFuY2UoaWQpIHtcbiAgICAgICAgdmFyIGluc3RhbmNlID0gdGhpcy5nZXRJbnN0YW5jZShpZCk7XG5cbiAgICAgICAgaWYgKGluc3RhbmNlK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BQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ=="); +eval("\n\n__webpack_require__(117);\n\nfunction _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }\n\nvar _instances = [];\n\nvar _clickModes = {\n CTRL_CLICK_TO_SELECT: 1,\n CLICK_TO_SELECT: 2\n};\n\nvar SimpleListItemRangeSelector = {\n createInstance: function createInstance(id) {\n var _clickMode = void 0;\n var _allItemElements = [];\n var _lastClickedIndexWithoutShift = void 0;\n var _rangeSelectionEnabled = true;\n var _newSelection = [];\n var _containerNode = void 0;\n var _itemsSelector = void 0;\n var _selectedClassName = void 0;\n var _resetSelector = void 0;\n var _onSelectionChanged = function _onSelectionChanged() {};\n var _debug = false;\n\n function _init(_ref) {\n var clickMode = _ref.clickMode,\n containerNode = _ref.containerNode,\n childSelector = _ref.childSelector,\n resetSelector = _ref.resetSelector,\n selectedClassName = _ref.selectedClassName,\n onSelectionChanged = _ref.onSelectionChanged,\n _ref$rangeSelectionEn = _ref.rangeSelectionEnabled,\n rangeSelectionEnabled = _ref$rangeSelectionEn === undefined ? true : _ref$rangeSelectionEn,\n debug = _ref.debug;\n\n\n if (containerNode) {\n _containerNode = containerNode;\n\n if (childSelector) {\n _itemsSelector = childSelector;\n } else {\n _itemsSelector = 'li';\n console.warn('No childSelector was specified. Defaulted to \"li\"');\n }\n\n _allItemElements = containerNode.querySelectorAll(_itemsSelector);\n\n if (_allItemElements) {\n _setClickMode(clickMode, SimpleListItemRangeSelector.clickModes.CTRL_CLICK_TO_SELECT);\n\n if (onSelectionChanged && typeof onSelectionChanged === 'function') {\n _onSelectionChanged = onSelectionChanged;\n }\n\n _selectedClassName = selectedClassName;\n _resetSelector = resetSelector;\n _debug = debug;\n\n _registerEvents({ resetEvent: resetSelector, rangeEvent: rangeSelectionEnabled });\n } else {\n throw Error('Items were not found using ' + _itemsSelector + ' selector.');\n }\n } else {\n throw Error('You need to specify a valid containerNode');\n }\n }\n\n function _ctrlKeyUsed(e) {\n var isMacUser = navigator.platform.indexOf('Mac') !== -1;\n\n if (isMacUser && e.metaKey) return true;else if (!isMacUser && e.ctrlKey) return true;\n\n return false;\n }\n\n function _setClickMode(clickMode, defaultMode) {\n if (_isValidClickMode(clickMode)) {\n _clickMode = clickMode;\n } else {\n _clickMode = defaultMode;\n console.warn('Invalid clickMode was specified. Defaulted to \"' + defaultMode.toString() + '\"');\n }\n }\n\n function _registerEvents() {\n var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref2$resetEvent = _ref2.resetEvent,\n resetEvent = _ref2$resetEvent === undefined ? false : _ref2$resetEvent,\n _ref2$rangeEvent = _ref2.rangeEvent,\n rangeEvent = _ref2$rangeEvent === undefined ? true : _ref2$rangeEvent;\n\n if (resetEvent && _resetSelector) {\n var resetElem = document.querySelector(_resetSelector);\n resetElem.addEventListener('click', _clearAllSelectionsHandler);\n }\n\n if (rangeEvent) {\n _rangeSelectionEnabled = true;\n _containerNode.addEventListener('selectstart', _preventDefaultHandler);\n }\n\n [].concat(_toConsumableArray(_allItemElements)).forEach(function (elem, index) {\n elem.setAttribute('data-slirs-index', index.toString());\n elem.addEventListener('click', _clickElementHandler);\n });\n }\n\n function _unregisterEvents() {\n var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref3$resetEvent = _ref3.resetEvent,\n resetEvent = _ref3$resetEvent === undefined ? false : _ref3$resetEvent,\n _ref3$rangeEvent = _ref3.rangeEvent,\n rangeEvent = _ref3$rangeEvent === undefined ? true : _ref3$rangeEvent,\n _ref3$clickEvent = _ref3.clickEvent,\n clickEvent = _ref3$clickEvent === undefined ? true : _ref3$clickEvent;\n\n if (resetEvent && _resetSelector) {\n var resetElem = document.querySelector(_resetSelector);\n resetElem.removeEventListener('click', _clearAllSelectionsHandler);\n }\n\n if (rangeEvent) {\n _rangeSelectionEnabled = false;\n _containerNode.removeEventListener('selectstart', _preventDefaultHandler);\n }\n\n if (clickEvent) {\n [].concat(_toConsumableArray(_allItemElements)).forEach(function (elem) {\n elem.removeEventListener('click', _clickElementHandler);\n });\n }\n }\n\n function _updateDOM(selection, notify) {\n var selectedItems = [];\n var sortedSelection = selection.concat().sort();\n\n var _iteratorNormalCompletion = true;\n var _didIteratorError = false;\n var _iteratorError = undefined;\n\n try {\n for (var _iterator = _allItemElements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var item = _step.value;\n\n var index = _indexOfItem(item);\n if (sortedSelection.includes(index)) {\n selectedItems.push(item);\n if (!_isItemSelected(item)) {\n item.setAttribute('data-slirs-selected', '1');\n if (_selectedClassName) {\n item.classList.add(_selectedClassName);\n }\n }\n } else {\n if (_isItemSelected(item)) {\n item.removeAttribute('data-slirs-selected');\n if (_selectedClassName) {\n item.classList.remove(_selectedClassName);\n }\n }\n }\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n\n if (notify) {\n _onSelectionChanged(selectedItems);\n }\n }\n\n function _updateSelection(e, updateDOM) {\n var item = this;\n var selectedItemIndex = _indexOfItem(item);\n\n if (!e.shiftKey || !_rangeSelectionEnabled) {\n _lastClickedIndexWithoutShift = selectedItemIndex;\n\n if (_isItemSelected(item)) {\n if (_clickMode === _clickModes.CTRL_CLICK_TO_SELECT && !_ctrlKeyUsed(e)) {\n // if user clicks without CTRL key, clear everything and select the one they clicked on\n _newSelection = [];\n _newSelection.push(selectedItemIndex);\n } else {\n // CTRL clicking or clicking in CLICK_TO_SELECT mode will unselect the item\n _newSelection.splice(_newSelection.indexOf(selectedItemIndex), 1);\n }\n } else {\n if (_clickMode === _clickModes.CTRL_CLICK_TO_SELECT && !_ctrlKeyUsed(e)) {\n // clear all selected items first if not using CTRL key\n _newSelection = [];\n }\n\n _newSelection.push(selectedItemIndex);\n }\n } else {\n var firstSelectedItem = document.querySelector(_itemsSelector + '[data-slirs-selected=\"1\"]');\n\n if (!firstSelectedItem) {\n // first item selected had shift modified applied so just select it normally\n _newSelection.push(selectedItemIndex);\n _lastClickedIndexWithoutShift = selectedItemIndex;\n updateDOM(_newSelection, true);\n return;\n }\n\n var firstSelectedItemIndex = _indexOfItem(firstSelectedItem);\n\n if (_debug) {\n console.log(\"first selected item: \", firstSelectedItemIndex, \" current selected item: \", selectedItemIndex, \" last selected item without shift: \", _lastClickedIndexWithoutShift);\n }\n\n if (firstSelectedItemIndex === selectedItemIndex) {\n // multiple items are selected currently and user wants to reduce range to just the selected item\n _unselectItemsWithinRange({\n start: selectedItemIndex + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n } else if (firstSelectedItemIndex < selectedItemIndex) {\n if (selectedItemIndex > _lastClickedIndexWithoutShift) {\n // user wants to add the next items up until selected item to complete a forward range\n _selectItemsWithinRange({ start: _lastClickedIndexWithoutShift + 1, end: selectedItemIndex });\n // the user may be reducing the range as a result, so clear selection after the current selected item\n _unselectItemsWithinRange({\n start: selectedItemIndex + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n // if a previous selection is before the last clicked index without a shift, we need to clear it\n _unselectItemsWithinRange({ start: _lastClickedIndexWithoutShift - 1, end: 0, mode: 'reverse' });\n } else {\n\n // user is selecting from the selected item to the last clicked item without shift\n _selectItemsWithinRange({ start: selectedItemIndex, end: _lastClickedIndexWithoutShift - 1 });\n // the user is reducing the selection above the last clicked index without shift, so we need to clear selection before the current selected item\n _unselectItemsWithinRange({ start: selectedItemIndex - 1, end: 0, mode: 'reverse' });\n // clear items after the last clicked index without shift\n _unselectItemsWithinRange({\n start: _lastClickedIndexWithoutShift + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n }\n } else {\n // user is selecting range upwards, so select between the last clicked index without shift and the selected item\n _selectItemsWithinRange({ start: selectedItemIndex, end: _lastClickedIndexWithoutShift });\n // clear items after the last clicked index without shift\n _unselectItemsWithinRange({\n start: _lastClickedIndexWithoutShift + 1,\n end: _allItemElements.length,\n mode: 'forward'\n });\n }\n }\n\n updateDOM(_newSelection, true);\n }\n\n function _selectItemsWithinRange(_ref4) {\n var start = _ref4.start,\n end = _ref4.end;\n\n if (start < 0 || end < start) return;\n\n for (var i = start; i <= end; i++) {\n var item = _allItemElements[i];\n if (item && !_isItemSelected(item)) {\n var index = _indexOfItem(item);\n _newSelection.push(index);\n }\n }\n }\n\n function _unselectItemAtIndex(index) {\n var item = _allItemElements[index];\n if (item && _isItemSelected(item)) {\n _newSelection.splice(_newSelection.indexOf(index), 1);\n }\n }\n\n function _unselectItemsWithinRange(_ref5) {\n var start = _ref5.start,\n end = _ref5.end,\n mode = _ref5.mode;\n\n if (start < 0) return;\n\n if (mode === 'reverse' && end <= start) {\n for (var i = start; i >= end; i--) {\n _unselectItemAtIndex(i);\n }\n } else if (mode === 'forward' && end > start) {\n for (var _i = start; _i <= end; _i++) {\n _unselectItemAtIndex(_i);\n }\n }\n }\n\n function _isItemSelected(item) {\n return item.hasAttribute('data-slirs-selected', '1');\n }\n\n function _clearAllSelectionsHandler() {\n _newSelection = [];\n _updateDOM(_newSelection, false);\n }\n\n function _preventDefaultHandler(e) {\n e.preventDefault();\n return false;\n }\n\n function _clickElementHandler(e) {\n _updateSelection.call(this, e, _updateDOM);\n }\n\n function _indexOfItem(item) {\n try {\n return parseInt(item.getAttribute('data-slirs-index'));\n } catch (e) {\n throw Error('Index doesn\\'t exist. Something went dreadfully wrong.');\n }\n }\n\n function _isValidClickMode(value) {\n var isValid = false;\n\n if (typeof value === 'undefined' || value === '') {\n return false;\n }\n\n for (var mode in _clickModes) {\n if (value === _clickModes[mode]) {\n isValid = true;\n }\n }\n\n return isValid;\n }\n\n function _selectItem(item) {\n if (item && !_isItemSelected(item)) {\n var index = _indexOfItem(item);\n _newSelection.push(index);\n }\n\n _updateDOM(_newSelection, false);\n }\n\n function _unselectItem(item) {\n if (item) {\n var index = _indexOfItem(item);\n _unselectItemAtIndex(index);\n }\n\n _updateDOM(_newSelection, false);\n }\n\n function _disableRangeSelection() {\n _unregisterEvents({ rangeEvent: true, clickEvent: false });\n }\n\n function _resetDOM() {\n var _iteratorNormalCompletion2 = true;\n var _didIteratorError2 = false;\n var _iteratorError2 = undefined;\n\n try {\n for (var _iterator2 = _allItemElements[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {\n var item = _step2.value;\n\n item.removeAttribute('data-slirs-index');\n item.removeAttribute('data-slirs-selected');\n\n if (_selectedClassName) {\n item.classList.remove(_selectedClassName);\n }\n }\n } catch (err) {\n _didIteratorError2 = true;\n _iteratorError2 = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion2 && _iterator2.return) {\n _iterator2.return();\n }\n } finally {\n if (_didIteratorError2) {\n throw _iteratorError2;\n }\n }\n }\n }\n\n function _reset() {\n _newSelection = [];\n _unregisterEvents({ resetEvent: true, rangeEvent: true, clickEvent: true });\n _resetDOM();\n }\n\n function _updateForNewItems(containerNode) {\n if (_debug) {\n console.log(\"Going to do update for new items\");\n }\n\n _containerNode = containerNode;\n\n if (_containerNode) {\n _allItemElements = _containerNode.querySelectorAll(_itemsSelector);\n\n [].concat(_toConsumableArray(_allItemElements)).forEach(function (elem, index) {\n elem.setAttribute('data-slirs-index', index.toString());\n elem.addEventListener('click', _clickElementHandler);\n });\n }\n }\n\n var instance = {\n id: id,\n init: _init,\n setClickMode: _setClickMode,\n selectItem: _selectItem,\n unselectItem: _unselectItem,\n disableRangeSelection: _disableRangeSelection,\n unregisterEvents: _unregisterEvents,\n updateForNewItems: _updateForNewItems,\n clearAllSelections: _clearAllSelectionsHandler,\n reset: _reset\n };\n\n _instances.push(instance);\n\n return instance;\n },\n getInstance: function getInstance(id) {\n return _instances.find(function (instance) {\n return instance.id === id;\n });\n },\n removeInstance: function removeInstance(id) {\n var instance = this.getInstance(id);\n\n if (instance) {\n instance.reset();\n var indexToRemove = _instances.indexOf(instance);\n _instances.splice(indexToRemove, 1);\n } else {\n throw Error('Instance cannot be found at Id' + id);\n }\n },\n\n clickModes: _clickModes\n};\n\nmodule.exports = SimpleListItemRangeSelector;//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaW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ZGUgPSBjb250YWluZXJOb2RlO1xuXG4gICAgICAgICAgICAgICAgaWYgKGNoaWxkU2VsZWN0b3IpIHtcbiAgICAgICAgICAgICAgICAgICAgX2l0ZW1zU2VsZWN0b3IgPSBjaGlsZFNlbGVjdG9yO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIF9pdGVtc1NlbGVjdG9yID0gJ2xpJztcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdObyBjaGlsZFNlbGVjdG9yIHdhcyBzcGVjaWZpZWQuIERlZmF1bHRlZCB0byBcImxpXCInKTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICBfYWxsSXRlbUVsZW1lbnRzID0gY29udGFpbmVyTm9kZS5xdWVyeVNlbGVjdG9yQWxsKF9pdGVtc1NlbGVjdG9yKTtcblxuICAgICAgICAgICAgICAgIGlmIChfYWxsSXRlbUVsZW1lbnRzKSB7XG4gICAgICAgICAgICAgICAgICAgIF9zZXRDbGlja01vZGUoY2xpY2tNb2RlLCBTaW1wbGVMaXN0SXRlbVJhbmdlU2VsZWN0b3IuY2xpY2tNb2Rlcy5DVFJMX0NMSUNLX1RPX1NFTEVDVCk7XG5cbiAgICAgICAgICAgICAgICAgICAgaWYgKG9uU2VsZWN0aW9uQ2hhbmdlZCAmJiB0eXBlb2Ygb25TZWxlY3Rpb25DaGFuZ2VkID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBfb25TZWxlY3Rpb25DaGFuZ2VkID0gb25TZWxlY3Rpb25DaGFuZ2VkO1xuICAgICAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAgICAgX3NlbGVjdGVkQ2xhc3NOYW1lID0gc2VsZWN0ZWRDbGFzc05hbWU7XG4gICAgICAgICAgICAgICAgICAgIF9yZXNldFNlbGVjdG9yID0gcmVzZXRTZWxlY3RvcjtcbiAgICAgICAgICAgICAgICAgICAg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QsXG4gICAgICAgICAgICAgICAgX3JlZjMkY2xpY2tFdmVudCA9IF9yZWYzLmNsaWNrRXZlbnQsXG4gICAgICAgICAgICAgICAgY2xpY2tFdmVudCA9IF9yZWYzJGNsaWNrRXZlbnQgPT09IHVuZGVmaW5lZCA/IHRydWUgOiBfcmVmMyRjbGlja0V2ZW50O1xuXG4gICAgICAgICAgICBpZiAocmVzZXRFdmVudCAmJiBfcmVzZXRTZWxlY3Rvcikge1xuICAgICAgICAgICAgICAgIHZhciByZXNldEVsZW0gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKF9yZXNldFNlbGVjdG9yKTtcbiAgICAgICAgICAgICAgICByZXNldEVsZW0ucmVtb3ZlRXZlbnRMaXN0ZW5lcignY2xpY2snLCBfY2xlYXJBbGxTZWxlY3Rpb25zSGFuZGxlcik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChyYW5nZUV2ZW50KSB7XG4gICAgICAgICAgICAgICAgX3JhbmdlU2VsZWN0aW9uRW5hYmxlZCA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIF9jb250YWluZXJOb2RlLnJlbW92ZUV2ZW50TGlzdGVuZXIoJ3NlbGVjdHN0YXJ0JywgX3ByZXZlbnREZWZhdWx0SGFuZGxlcik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChjbGlja0V2ZW50KSB7XG4gICAgICAgICAgICAgICAgW10uY29uY2F0KF90b0NvbnN1bWFibGVBcnJheShfYWxsSXRlbUVsZW1lbnRzKSkuZm9yRWFjaChmdW5jdGlvbiAoZWxlbSkge1xuICAgICAgICAgICAgICAgICAgICBlbGVtLnJlbW92ZUV2ZW50TGlzdGVuZXIoJ2NsaWNrJywgX2NsaWNrRWxlbWVudEhhbmRsZXIpO1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZURPTShzZWxlY3Rpb24sIG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RDbGFzc05hbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaXRlbS5jbGFzc0xpc3QuYWRkKF9zZWxlY3RlZENsYXNzTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9pc0l0ZW1TZWxlY3RlZChpdGVtKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGl0ZW0ucmVtb3ZlQXR0cmlidXRlKCdkYXRhLXNsaXJzLXNlbGVjdGVkJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKF9zZWxlY3RlZENsYXNzTmFtZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpdGVtLmNsYXNzTGlzdC5yZW1vdmUoX3NlbGVjdGVkQ2xhc3NOYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGNhdGNoIChlcnIpIHtcbiAgICAgICAgICAgICAgICBfZGlkSXRlcmF0b3JFcnJvciA9IHRydWU7XG4gICAgICAgICAgICAgICAgX2l0ZXJhdG9yRXJyb3IgPSBlcnI7XG4gICAgICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgICAgIHRyeSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghX2l0ZXJhdG9yTm9ybWFsQ29tcGxldGlvbiAmJiBfaXRlcmF0b3IucmV0dXJuKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBfaXRlcmF0b3IucmV0dXJuKCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9IGZpbmFsbHkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoX2R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aChzZWxlY3RlZEl0ZW1JbmRleCk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBDVFJMIGNsaWNraW5nIG9yIGNsaWNraW5nIGluIENMSUNLX1RPX1NFTEVDVCBtb2RlIHdpbGwgdW5zZWxlY3QgdGhlIGl0ZW1cbiAgICAgICAgICAgICAgICAgICAgICAgIF9uZXdTZWxlY3Rpb24uc3BsaWNlKF9uZXdTZWxlY3Rpb24uaW5kZXhPZihzZWxlY3RlZEl0ZW1JbmRleCksIDEpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKF9jbGlja01vZGUgPT09IF9jbGlja01vZGVzLkNUUkxfQ0xJQ0tfVE9fU0VMRUNUICYmICFfY3RybEtleVVzZWQoZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGNsZWFyIGFsbCBzZWxlY3RlZCBpdGVtcyBmaXJzdCBpZiBub3QgdXNpbmcgQ1RSTCBrZXlcbiAgICAgICAgICAgICAgICAgICAgICAgIF9uZXdTZWxlY3Rpb24gPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIF9uZXdTZWxlY3Rpb24ucHVzaChzZWxlY3RlZEl0ZW1JbmRleCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICB2YXIgZmlyc3RTZWxlY3RlZEl0ZW0gPSBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKF9pdGVtc1NlbGVjdG9yICsgJ1tkYXRhLXNsaXJzLXNlbGVjdGVkPVwiMVwiXScpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCFmaXJzdFNlbGVjdGVkSXRlbSkge1xuICAgICAgICAgICAgICAgICAgICAvLyBmaXJzdCBpdGVtIHNlbGVjdGVkIGhhZCB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AgICAgICAgICAgICAgICAgICAgICAgc3RhcnQ6IF9sYXN0Q2xpY2tlZEluZGV4V2l0aG91dFNoaWZ0ICsgMSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGVuZDogX2FsbEl0ZW1FbGVtZW50cy5sZW5ndGgsXG4gICAgICAgICAgICAgICAgICAgICAgICBtb2RlOiAnZm9yd2FyZCdcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICB1cGRhdGVET00oX25ld1NlbGVjdGlvbiwgdHJ1ZSk7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfc2VsZWN0SXRlbXNXaXRoaW5SYW5nZShfcmVmNCkge1xuICAgICAgICAgICAgdmFyIHN0YXJ0ID0gX3JlZjQuc3RhcnQsXG4gICAgICAgICAgICAgICAgZW5kID0gX3JlZjQuZW5kO1xuXG4gICAgICAgICAgICBpZiAoc3RhcnQgPCAwIHx8IGVuZCA8IHN0YXJ0KSByZXR1cm47XG5cbiAgICAgICAgICAgIGZvciAodmFyIGkgPSBzdGFydDsgaSA8PSBlbmQ7IGkrKykge1xuICAgICAgICAgICAgICAgIHZhciBpdGVtID0gX2FsbEl0ZW1FbGVtZW50c1tpXTtcbiAgICAgICAgICAgICAgICBpZiAoaXRlbSAmJiAhX2lzSXRlbVNlbGVjdGVkKGl0ZW0pKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IF9pbmRleE9mSXRlbShpdGVtKTtcbiAgICAgICAgICAgICAgICAgICAgX25ld1NlbGVjdGlvbi5wdXNoKGluZGV4KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfdW5zZWxlY3RJdGVtQXRJbmRleChpbmRleCkge1xuICAgICAgICAgICAgdmFyIGl0ZW0gPSBfYWxsSXRlbUVsZW1lbnRzW2luZGV4XTtcbiAgICAgICAgICAgIGlmIChpdGVtICYmIF9pc0l0ZW1TZWxlY3RlZChpdGVtKSkge1xuICAgICAgICAgICAgICAgIF9uZXdTZWxlY3Rpb24uc3BsaWNlKF9uZXdTZWxlY3Rpb24uaW5kZXhPZihpbmRleCksIDEpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3Vuc2VsZWN0SXRlbXNXaXRoaW5SYW5nZShfcmVmNSkge1xuICAgICAgICAgICAgdmFyIHN0YXJ0ID0gX3JlZjUuc3RhcnQsXG4gICAgICAgICAgICAgICAgZW5kID0gX3JlZjUuZW5kLFxuICAgICAgICAgICAgICAgIG1vZGUgPSBfcmVmNS5tb2RlO1xuXG4gICAgICAgICAgICBpZiAoc3RhcnQgPCAwKSByZXR1cm47XG5cbiAgICAgICAgICAgIGlmIChtb2RlID09PSAncmV2ZXJzZScgJiYgZW5kIDw9IHN0YXJ0KSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IHN0YXJ0OyBpID49IGVuZDsgaS0tKSB7XG4gICAgICAgICAgICAgICAgICAgIF91bnNlbGVjdEl0ZW1BdEluZGV4KGkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAobW9kZSA9PT0gJ2ZvcndhcmQnICYmIGVuZCA+IHN0YXJ0KSB7XG4gICAgICAgICAgICAgICAgZm9yICh2YXIgX2kgPSBzdGFydDsgX2kgPD0gZW5kOyBfaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgIF91bnNlbGVjdEl0ZW1BdEluZGV4KF9pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfaXNJdGVtU2VsZWN0ZWQoaXRlbSkge1xuICAgICAgICAgICAgcmV0dXJuIGl0ZW0uaGFzQXR0cmlidXRlKCdkYXRhLXNsaXJzLXNlbGVjdGVkJywgJzEnKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF9jbGVhckFsbFNlbGVjdGlvbnNIYW5kbGVyKCkge1xuICAgICAgICAgICAgX25ld1NlbGVjdGlvbiA9IFtdO1xuICAgICAgICAgICAgX3VwZGF0ZURPTShfbmV3U2VsZWN0aW9uLCBmYWxzZSk7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfcHJldmVudERlZmF1bHRIYW5kbGVyKGUpIHtcbiAgICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKTtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF9jbGlja0VsZW1lbnRIYW5kbGVyKGUpIHtcbiAgICAgICAgICAgIF91cGRhdGVTZWxlY3Rpb24uY2FsbCh0aGlzLCBlLCBfdXBkYXRlRE9NKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF9pbmRleE9mSXRlbShpdGVtKSB7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUludChpdGVtLmdldEF0dHJpYnV0ZSgnZGF0YS1zbGlycy1pbmRleCcpKTtcbiAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcignSW5kZXggZG9lc25cXCd0IGV4aXN0LiBTb21ldGhpbmcgd2VudCBkcmVhZGZ1bGx5IHdyb25nLicpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX2lzVmFsaWRDbGlja01vZGUodmFsdWUpIHtcbiAgICAgICAgICAgIHZhciBpc1ZhbGlkID0gZmFsc2U7XG5cbiAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICd1bmRlZmluZWQnIHx8IHZhbHVlID09PSAnJykge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgZm9yICh2YXIgbW9kZSBpbiBfY2xpY2tNb2Rlcykge1xuICAgICAgICAgICAgICAgIGlmICh2YWx1ZSA9PT0gX2NsaWNrTW9kZXNbbW9kZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgaXNWYWxpZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICByZXR1cm4gaXNWYWxpZDtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF9zZWxlY3RJdGVtKGl0ZW0pIHtcbiAgICAgICAgICAgIGlmIChpdGVtICYmICFfaXNJdGVtU2VsZWN0ZWQoaXRlbSkpIHtcbiAgICAgICAgICAgICAgICB2YXIgaW5kZXggPSBfaW5kZXhPZkl0ZW0oaXRlbSk7XG4gICAgICAgICAgICAgICAgX25ld1NlbGVjdGlvbi5wdXNoKGluZGV4KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgX3VwZGF0ZURPTShfbmV3U2VsZWN0aW9uLCBmYWxzZSk7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfdW5zZWxlY3RJdGVtKGl0ZW0pIHtcbiAgICAgICAgICAgIGlmIChpdGVtKSB7XG4gICAgICAgICAgICAgICAgdmFyIGluZGV4ID0gX2luZGV4T2ZJdGVtKGl0ZW0pO1xuICAgICAgICAgICAgICAgIF91bnNlbGVjdEl0ZW1BdEluZGV4KGluZGV4KTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgX3VwZGF0ZURPTShfbmV3U2VsZWN0aW9uLCBmYWxzZSk7XG4gICAgICAgIH1cblxuICAgICAgICBmdW5jdGlvbiBfZGlzYWJsZVJhbmdlU2VsZWN0aW9uKCkge1xuICAgICAgICAgICAgX3VucmVnaXN0ZXJFdmVudHMoeyByYW5nZUV2ZW50OiB0cnVlLCBjbGlja0V2ZW50OiBmYWxzZSB9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN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XG4gICAgICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFfaXRlcmF0b3JOb3JtYWxDb21wbGV0aW9uMiAmJiBfaXRlcmF0b3IyLnJldHVybikge1xuICAgICAgICAgICAgICAgICAgICAgICAgX2l0ZXJhdG9yMi5yZXR1cm4oKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChfZGlkSXRlcmF0b3JFcnJvcjIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IF9pdGVyYXRvckVycm9yMjtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGZ1bmN0aW9uIF9yZXNldCgpIHtcbiAgICAgICAgICAgIF9uZXdTZWxlY3Rpb24gPSBbXTtcbiAgICAgICAgICAgIF91bnJlZ2lzdGVyRXZlbnRzKHsgcmVzZXRFdmVudDogdHJ1ZSwgcmFuZ2VFdmVudDogdHJ1ZSwgY2xpY2tFdmVudDogdHJ1ZSB9KTtcbiAgICAgICAgICAgIF9yZXNldERPTSgpO1xuICAgICAgICB9XG5cbiAgICAgICAgZnVuY3Rpb24gX3VwZGF0ZUZvck5ld0l0ZW1zKGNvbnRhaW5lck5vZGUpIHtcbiAgICAgICAgICAgIGlmIChfZGVidWcpIHtcbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIkdvaW5nIHRvIGRvIHVwZGF0ZSBmb3IgbmV3IGl0ZW1zXCIpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBfY29udGFpbmVyTm9kZSA9IGNvbnRhaW5lck5vZGU7XG5cbiAgICAgICAgICAgIGlmIChfY29udGFpbmVyTm9kZSkge1xuICAgICAgICAgICAgICAgIF9hbGxJdGVtRWxlbWVudHMgPSBfY29udGFpbmVyTm9kZS5xdWVyeVNlbGVjdG9yQWxsKF9pdGVtc1NlbGVjdG9yKTtcblxuICAgICAgICAgICAgICAgIFtdLmNvbmNhdChfdG9Db25zdW1hYmxlQXJyYXkoX2FsbEl0ZW1FbGVtZW50cykpLmZvckVhY2goZnVuY3Rpb24gKGVsZW0sIGluZGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIGVsZW0uc2V0QXR0cmlidXRlKCdkYXRhLXNsaXJzLWluZGV4JywgaW5kZXgudG9TdHJpbmcoKSk7XG4gICAgICAgICAgICAgICAgICAgIGVsZW0uYWRkRXZlbnRMaXN0ZW5lcignY2xpY2snLCBfY2xpY2tFbGVtZW50SGFuZGxlcik7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgaW5zdGFuY2UgPSB7XG4gICAgICAgICAgICBpZDogaWQsXG4gICAgICAgICAgICBpbml0OiBfaW5pdCxcbiAgICAgICAgICAgIHNldENsaWNrTW9kZTogX3NldENsaWNrTW9kZSxcbiAgICAgICAgICAgIHNlbGVjdEl0ZW06IF9zZWxlY3RJdGVtLFxuICAgICAgICAgICAgdW5zZWxlY3RJdGVtOiBfdW5zZWxlY3RJdGVtLFxuICAgICAgICAgICAgZGlzYWJsZVJhbmdlU2VsZWN0aW9uOiBfZGlzYWJsZVJhbmdlU2VsZWN0aW9uLFxuICAgICAgICAgICAgdW5yZWdpc3RlckV2ZW50czogX3VucmVnaXN0ZXJFdmVudHMsXG4gICAgICAgICAgICB1cGRhdGVGb3JOZXdJdGVtczogX3VwZGF0ZUZvck5ld0l0ZW1zLFxuICAgICAgICAgICAgY2xlYXJBbGxTZWxlY3Rpb25zOiBfY2xlYXJBbGxTZWxlY3Rpb25zSGFuZGxlcixcbiAgICAgICAgICAgIHJlc2V0OiBfcmVzZXRcbiAgICAgICAgfTtcblxuICAgICAgICBfaW5zdGFuY2VzLnB1c2goaW5zdGFuY2UpO1xuXG4gICAgICAgIHJldHVybiBpbnN0Y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QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJzb3VyY2VSb290IjoiIn0="); /***/ }), /* 117 */ diff --git a/dist/simple-list-item-range-selector.js b/dist/simple-list-item-range-selector.js index f36603b..137c3fa 100644 --- a/dist/simple-list-item-range-selector.js +++ b/dist/simple-list-item-range-selector.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.SimpleListItemRangeSelector=n():t.SimpleListItemRangeSelector=n()}(this,function(){return function(t){function n(e){if(r[e])return r[e].exports;var i=r[e]={i:e,l:!1,exports:{}};return t[e].call(i.exports,i,i.exports,n),i.l=!0,i.exports}var r={};return n.m=t,n.c=r,n.i=function(t){return t},n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:e})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=299)}([function(t,n,r){var e=r(2),i=r(24),o=r(12),u=r(13),c=r(25),f=function(t,n,r){var a,s,l,h,v=t&f.F,p=t&f.G,d=t&f.S,y=t&f.P,g=t&f.B,m=p?e:d?e[n]||(e[n]={}):(e[n]||{}).prototype,b=p?i:i[n]||(i[n]={}),w=b.prototype||(b.prototype={});p&&(r=n);for(a in r)s=!v&&m&&void 0!==m[a],l=(s?m:r)[a],h=g&&s?c(l,e):y&&"function"==typeof l?c(Function.call,l):l,m&&u(m,a,l,t&f.U),b[a]!=l&&o(b,a,h),y&&w[a]!=l&&(w[a]=l)};e.core=i,f.F=1,f.G=2,f.S=4,f.P=8,f.B=16,f.W=32,f.U=64,f.R=128,t.exports=f},function(t,n,r){var e=r(4);t.exports=function(t){if(!e(t))throw TypeError(t+" is not an object!");return t}},function(t,n){var r=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,r){var e=r(57)("wks"),i=r(39),o=r(2).Symbol,u="function"==typeof o;(t.exports=function(t){return e[t]||(e[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=e},function(t,n,r){t.exports=!r(3)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,n,r){var e=r(1),i=r(93),o=r(23),u=Object.defineProperty;n.f=r(6)?Object.defineProperty:function(t,n,r){if(e(t),n=o(n,!0),e(r),i)try{return u(t,n,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(t[n]=r.value),t}},function(t,n,r){var e=r(30),i=Math.min;t.exports=function(t){return t>0?i(e(t),9007199254740991):0}},function(t,n,r){var e=r(19);t.exports=function(t){return Object(e(t))}},function(t,n){var r={}.hasOwnProperty;t.exports=function(t,n){return r.call(t,n)}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,r){var e=r(7),i=r(29);t.exports=r(6)?function(t,n,r){return e.f(t,n,i(1,r))}:function(t,n,r){return t[n]=r,t}},function(t,n,r){var e=r(2),i=r(12),o=r(10),u=r(39)("src"),c=Function.toString,f=(""+c).split("toString");r(24).inspectSource=function(t){return c.call(t)},(t.exports=function(t,n,r,c){var a="function"==typeof r;a&&(o(r,"name")||i(r,"name",n)),t[n]!==r&&(a&&(o(r,u)||i(r,u,t[n]?""+t[n]:f.join(String(n)))),t===e?t[n]=r:c?t[n]?t[n]=r:i(t,n,r):(delete t[n],i(t,n,r)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[u]||c.call(this)})},function(t,n,r){var e=r(0),i=r(3),o=r(19),u=function(t,n,r,e){var i=String(o(t)),u="<"+n;return""!==r&&(u+=" "+r+'="'+String(e).replace(/"/g,""")+'"'),u+">"+i+""};t.exports=function(t,n){var r={};r[t]=n(u),e(e.P+e.F*i(function(){var n=""[t]('"');return n!==n.toLowerCase()||n.split('"').length>3}),"String",r)}},function(t,n,r){var e=r(46),i=r(19);t.exports=function(t){return e(i(t))}},function(t,n,r){var e=r(47),i=r(29),o=r(15),u=r(23),c=r(10),f=r(93),a=Object.getOwnPropertyDescriptor;n.f=r(6)?a:function(t,n){if(t=o(t),n=u(n,!0),f)try{return a(t,n)}catch(t){}if(c(t,n))return i(!e.f.call(t,n),t[n])}},function(t,n,r){var e=r(10),i=r(9),o=r(74)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),e(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n){var r={}.toString;t.exports=function(t){return r.call(t).slice(8,-1)}},function(t,n){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,r){var e=r(3);t.exports=function(t,n){return!!t&&e(function(){n?t.call(null,function(){},1):t.call(null)})}},function(t,n,r){var e=r(25),i=r(46),o=r(9),u=r(8),c=r(118);t.exports=function(t,n){var r=1==t,f=2==t,a=3==t,s=4==t,l=6==t,h=5==t||l,v=n||c;return function(n,c,p){for(var d,y,g=o(n),m=i(g),b=e(c,p,3),w=u(m.length),x=0,S=r?v(n,w):f?v(n,0):void 0;w>x;x++)if((h||x in m)&&(d=m[x],y=b(d,x,g),t))if(r)S[x]=y;else if(y)switch(t){case 3:return!0;case 5:return d;case 6:return x;case 2:S.push(d)}else if(s)return!1;return l?-1:a||s?s:S}}},function(t,n,r){var e=r(0),i=r(24),o=r(3);t.exports=function(t,n){var r=(i.Object||{})[t]||Object[t],u={};u[t]=n(r),e(e.S+e.F*o(function(){r(1)}),"Object",u)}},function(t,n,r){var e=r(4);t.exports=function(t,n){if(!e(t))return t;var r,i;if(n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;if("function"==typeof(r=t.valueOf)&&!e(i=r.call(t)))return i;if(!n&&"function"==typeof(r=t.toString)&&!e(i=r.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n){var r=t.exports={version:"2.4.0"};"number"==typeof __e&&(__e=r)},function(t,n,r){var e=r(11);t.exports=function(t,n,r){if(e(t),void 0===n)return t;switch(r){case 1:return function(r){return t.call(n,r)};case 2:return function(r,e){return t.call(n,r,e)};case 3:return function(r,e,i){return t.call(n,r,e,i)}}return function(){return t.apply(n,arguments)}}},function(t,n,r){var e=r(109),i=r(0),o=r(57)("metadata"),u=o.store||(o.store=new(r(112))),c=function(t,n,r){var i=u.get(t);if(!i){if(!r)return;u.set(t,i=new e)}var o=i.get(n);if(!o){if(!r)return;i.set(n,o=new e)}return o},f=function(t,n,r){var e=c(n,r,!1);return void 0!==e&&e.has(t)},a=function(t,n,r){var e=c(n,r,!1);return void 0===e?void 0:e.get(t)},s=function(t,n,r,e){c(r,e,!0).set(t,n)},l=function(t,n){var r=c(t,n,!1),e=[];return r&&r.forEach(function(t,n){e.push(n)}),e},h=function(t){return void 0===t||"symbol"==typeof t?t:String(t)},v=function(t){i(i.S,"Reflect",t)};t.exports={store:u,map:c,has:f,get:a,set:s,keys:l,key:h,exp:v}},function(t,n,r){"use strict";if(r(6)){var e=r(32),i=r(2),o=r(3),u=r(0),c=r(58),f=r(81),a=r(25),s=r(31),l=r(29),h=r(12),v=r(36),p=r(30),d=r(8),y=r(38),g=r(23),m=r(10),b=r(106),w=r(45),x=r(4),S=r(9),_=r(66),E=r(33),O=r(17),F=r(34).f,A=r(83),P=r(39),M=r(5),I=r(21),j=r(48),N=r(75),T=r(84),L=r(42),k=r(54),R=r(37),C=r(59),W=r(86),D=r(7),U=r(16),B=D.f,G=U.f,V=i.RangeError,K=i.TypeError,z=i.Uint8Array,Y=Array.prototype,q=f.ArrayBuffer,J=f.DataView,X=I(0),$=I(2),H=I(3),Z=I(4),Q=I(5),tt=I(6),nt=j(!0),rt=j(!1),et=T.values,it=T.keys,ot=T.entries,ut=Y.lastIndexOf,ct=Y.reduce,ft=Y.reduceRight,at=Y.join,st=Y.sort,lt=Y.slice,ht=Y.toString,vt=Y.toLocaleString,pt=M("iterator"),dt=M("toStringTag"),yt=P("typed_constructor"),gt=P("def_constructor"),mt=c.CONSTR,bt=c.TYPED,wt=c.VIEW,xt=I(1,function(t,n){return At(N(t,t[gt]),n)}),St=o(function(){return 1===new z(new Uint16Array([1]).buffer)[0]}),_t=!!z&&!!z.prototype.set&&o(function(){new z(1).set({})}),Et=function(t,n){if(void 0===t)throw K("Wrong length!");var r=+t,e=d(t);if(n&&!b(r,e))throw V("Wrong length!");return e},Ot=function(t,n){var r=p(t);if(r<0||r%n)throw V("Wrong offset!");return r},Ft=function(t){if(x(t)&&bt in t)return t;throw K(t+" is not a typed array!")},At=function(t,n){if(!(x(t)&&yt in t))throw K("It is not a typed array constructor!");return new t(n)},Pt=function(t,n){return Mt(N(t,t[gt]),n)},Mt=function(t,n){for(var r=0,e=n.length,i=At(t,e);e>r;)i[r]=n[r++];return i},It=function(t,n,r){B(t,n,{get:function(){return this._d[r]}})},jt=function(t){var n,r,e,i,o,u,c=S(t),f=arguments.length,s=f>1?arguments[1]:void 0,l=void 0!==s,h=A(c);if(void 0!=h&&!_(h)){for(u=h.call(c),e=[],n=0;!(o=u.next()).done;n++)e.push(o.value);c=e}for(l&&f>2&&(s=a(s,arguments[2],2)),n=0,r=d(c.length),i=At(this,r);r>n;n++)i[n]=l?s(c[n],n):c[n];return i},Nt=function(){for(var t=0,n=arguments.length,r=At(this,n);n>t;)r[t]=arguments[t++];return r},Tt=!!z&&o(function(){vt.call(new z(1))}),Lt=function(){return vt.apply(Tt?lt.call(Ft(this)):Ft(this),arguments)},kt={copyWithin:function(t,n){return W.call(Ft(this),t,n,arguments.length>2?arguments[2]:void 0)},every:function(t){return Z(Ft(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return C.apply(Ft(this),arguments)},filter:function(t){return Pt(this,$(Ft(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return Q(Ft(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return tt(Ft(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){X(Ft(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return rt(Ft(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return nt(Ft(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return at.apply(Ft(this),arguments)},lastIndexOf:function(t){return ut.apply(Ft(this),arguments)},map:function(t){return xt(Ft(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return ct.apply(Ft(this),arguments)},reduceRight:function(t){return ft.apply(Ft(this),arguments)},reverse:function(){for(var t,n=this,r=Ft(n).length,e=Math.floor(r/2),i=0;i1?arguments[1]:void 0)},sort:function(t){return st.call(Ft(this),t)},subarray:function(t,n){var r=Ft(this),e=r.length,i=y(t,e);return new(N(r,r[gt]))(r.buffer,r.byteOffset+i*r.BYTES_PER_ELEMENT,d((void 0===n?e:y(n,e))-i))}},Rt=function(t,n){return Pt(this,lt.call(Ft(this),t,n))},Ct=function(t){Ft(this);var n=Ot(arguments[1],1),r=this.length,e=S(t),i=d(e.length),o=0;if(i+n>r)throw V("Wrong length!");for(;o255?255:255&e),i.v[p](r*n+i.o,e,St)},M=function(t,n){B(t,n,{get:function(){return A(this,n)},set:function(t){return P(this,n,t)},enumerable:!0})};b?(y=r(function(t,r,e,i){s(t,y,a,"_d");var o,u,c,f,l=0,v=0;if(x(r)){if(!(r instanceof q||"ArrayBuffer"==(f=w(r))||"SharedArrayBuffer"==f))return bt in r?Mt(y,r):jt.call(y,r);o=r,v=Ot(e,n);var p=r.byteLength;if(void 0===i){if(p%n)throw V("Wrong length!");if((u=p-v)<0)throw V("Wrong length!")}else if((u=d(i)*n)+v>p)throw V("Wrong length!");c=u/n}else c=Et(r,!0),u=c*n,o=new q(u);for(h(t,"_d",{b:o,o:v,l:u,e:c,v:new J(o)});l0?e:r)(t)}},function(t,n){t.exports=function(t,n,r,e){if(!(t instanceof n)||void 0!==e&&e in t)throw TypeError(r+": incorrect invocation!");return t}},function(t,n){t.exports=!1},function(t,n,r){var e=r(1),i=r(99),o=r(62),u=r(74)("IE_PROTO"),c=function(){},f=function(){var t,n=r(61)("iframe"),e=o.length;for(n.style.display="none",r(64).appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write("