Choices/assets/scripts/dist/choices.min.js
2016-06-27 14:57:33 +01:00

2 lines
46 KiB
JavaScript

!function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var i={};return e.m=t,e.c=i,e.p="/assets/scripts/dist/",e(0)}([function(t,e,i){t.exports=i(1)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Choices=void 0;var r=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=i(2),c=i(3),l=i(4),u=n(l),h=i(5),d=n(h),p=e.Choices=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?"[data-choice]":arguments[0],i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(o(this,t),(0,c.isType)("String",e)){var n=document.querySelectorAll(e);if(n.length>1)for(var s=1;s<n.length;s++){var r=n[s];new t(r,i)}}var a={items:[],maxItemCount:-1,addItems:!0,removeItems:!0,removeItemButton:!1,editItems:!1,duplicateItems:!0,delimiter:",",paste:!0,searchOptions:!0,regexFilter:null,placeholder:!0,placeholderValue:null,prependValue:null,appendValue:null,loadingText:"Loading...",templates:{},classNames:{containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemChoice:"choices__item--choice",group:"choices__group",groupHeading:"choices__heading",button:"choices__button",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",hiddenState:"is-hidden",flippedState:"is-flipped",selectedState:"is-selected"},callbackOnInit:function(){},callbackOnAddItem:function(t,e,i){},callbackOnRemoveItem:function(t,e,i){}};this.options=(0,c.extend)(a,i),this.store=new d.default(this.render),this.initialised=!1,this.currentState={},this.prevState={},this.currentValue="",this.passedElement=(0,c.isType)("String",e)?document.querySelector(e):e,this.highlightPosition=0,this.canSearch=this.options.searchOptions,this.presetItems=this.options.items,""!==this.passedElement.value&&(this.presetItems=this.presetItems.concat(this.passedElement.value.split(this.options.delimiter))),this.init=this.init.bind(this),this.render=this.render.bind(this),this.destroy=this.destroy.bind(this),this.disable=this.disable.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onPaste=this._onPaste.bind(this),this._onInput=this._onInput.bind(this);var l="querySelector"in document&&"addEventListener"in document&&"classList"in document.createElement("div");l||console.error("Choices: Your browser doesn't support Choices");var u=this.passedElement&&["select-one","select-multiple","text"].includes(this.passedElement.type);u?this.init():console.error("Choices: Incompatible input passed")}return r(t,[{key:"init",value:function(t){this.initialised!==!0&&(this.initialised=!0,this._createTemplates(),this._createInput(),this.store.subscribe(this.render),this.render(),this._addEventListeners(),(t=this.options.callbackOnInit)&&((0,c.isType)("Function",t)?t():console.error("callbackOnInit: Callback is not a function")))}},{key:"destroy",value:function(){this.passedElement.classList.remove(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="",this.passedElement.removeAttribute("style","display:none;"),this.passedElement.removeAttribute("aria-hidden"),this.containerOuter.outerHTML=this.passedElement.outerHTML,this.passedElement=null,this.userOptions=null,this.options=null,this.store=null,this._removeEventListeners()}},{key:"selectItem",value:function(t){if(t){var e=t.id;return this.store.dispatch((0,a.selectItem)(e,!0)),this}}},{key:"deselectItem",value:function(t){if(t){var e=t.id;return this.store.dispatch((0,a.selectItem)(e,!1)),this}}},{key:"highlightAll",value:function(){var t=this,e=this.store.getItems();return e.forEach(function(e){t.selectItem(e)}),this}},{key:"deselectAll",value:function(){var t=this,e=this.store.getItems();return e.forEach(function(e){t.deselectItem(e)}),this}},{key:"removeItemsByValue",value:function(t){return void(t&&(0,c.isType)("String",t)||console.error("removeItemsByValue: No value was passed to be removed"))}},{key:"removeActiveItems",value:function(t){var e=this,i=this.store.getItemsFilteredByActive();return i.forEach(function(i){i.active&&t!==i.id&&e._removeItem(i)}),this}},{key:"removeSelectedItems",value:function(){var t=this,e=this.store.getItemsFilteredByActive();return e.forEach(function(e){e.selected&&e.active&&t._removeItem(e)}),this}},{key:"showDropdown",value:function(){this.containerOuter.classList.add(this.options.classNames.openState),this.dropdown.classList.add(this.options.classNames.activeState);var t=this.dropdown.getBoundingClientRect(),e=t.top+t.height>=document.body.offsetHeight;return e?this.containerOuter.classList.add(this.options.classNames.flippedState):this.containerOuter.classList.remove(this.options.classNames.flippedState),this}},{key:"hideDropdown",value:function(){var t=this.containerOuter.classList.contains(this.options.classNames.flippedState);return this.containerOuter.classList.remove(this.options.classNames.openState),this.dropdown.classList.remove(this.options.classNames.activeState),t&&this.containerOuter.classList.remove(this.options.classNames.flippedState),this}},{key:"toggleDropdown",value:function(){var t=this.dropdown.classList.contains(this.options.classNames.activeState);return t?this.hideDropdown():this.showDropdown(),this}},{key:"setValue",value:function(t){var e=this,i=[].concat(s(t));return i.forEach(function(t,i){if((0,c.isType)("Object",t)){if(!t.value)return;"text"!==e.passedElement.type?e._addChoice(!0,!1,t.value,t.label,-1):e._addItem(t.value,t.label,t.id)}else(0,c.isType)("String",t)&&("text"!==e.passedElement.type?e._addChoice(!0,!1,t,t,-1):e._addItem(t))}),this}},{key:"clearValue",value:function(){return this.store.dispatch((0,a.clearAll)()),this}},{key:"disable",value:function(){return this.passedElement.disabled=!0,this.initialised&&(this.input.disabled=!0,this.containerOuter.classList.add(this.options.classNames.disabledState)),this}},{key:"ajax",value:function(t){var e=this;this.containerOuter.classList.add("is-loading");var i=this._getTemplate("item",{id:-1,value:"Loading",label:this.options.loadingText,active:!0});this.itemList.appendChild(i);var n=function(t,i,n){t&&t.length&&(e.containerOuter.classList.remove("is-loading"),e.input.placeholder="",t.forEach(function(t,s){0===s&&e._addItem(t[i],t[n],s),e._addChoice(!1,!1,t[i],t[n])}))};return t(n),this}},{key:"clearInput",value:function(){return this.input.value&&(this.input.value=""),"select-one"!==this.passedElement.type&&(this.input.style.width=(0,c.getWidthOfInput)(this.input)),this}},{key:"_handleEnter",value:function(t,e){var i=!0;if(this.options.addItems?this.options.maxItemCount&&this.options.maxItemCount>0&&this.options.maxItemCount<=this.itemList.children.length?i=!1:this.options.duplicateItems===!1&&this.passedElement.value&&(i=!t.some(function(t){return t.value===e})):i=!1,i){var n=!0;this.options.regexFilter&&(n=this._regexFilter(e)),n&&(this.toggleDropdown(),this._addItem(e),this.clearInput(this.passedElement))}}},{key:"_handleBackspace",value:function(t){if(this.options.removeItems&&t){var e=t[t.length-1],i=t.some(function(t){return t.selected===!0});this.options.editItems&&!i&&e?(this.input.value=e.value,this._removeItem(e)):(i||this.selectItem(e),this.removeSelectedItems())}}},{key:"_onKeyDown",value:function(t){if(t.target===this.input){var e=t.ctrlKey||t.metaKey,i=46,n=8,s=13,o=65,r=27,l=38,u=40,h=this.store.getItemsFilteredByActive(),d=(this.store.getChoicesFilteredByActive(),this.input===document.activeElement),p=this.dropdown.classList.contains(this.options.classNames.activeState),f=this.itemList&&this.itemList.children,v=String.fromCharCode(event.keyCode);switch("text"!==this.passedElement.type&&/[a-zA-Z0-9-_ ]/.test(v)&&!p&&this.showDropdown(),this.canSearch=this.options.searchOptions,t.keyCode){case o:e&&f&&(this.canSearch=!1,this.options.removeItems&&!this.input.value&&this.input===document.activeElement&&this.highlightAll(this.itemList.children));break;case s:if(t.target.value&&"text"===this.passedElement.type){var m=this.input.value;this._handleEnter(h,m)}if(p){var g=this.dropdown.querySelector("."+this.options.classNames.highlightedState);if(g){var y=g.getAttribute("data-value"),b=g.innerHTML,_=g.getAttribute("data-id");this._addItem(y,b,_),this.clearInput(this.passedElement),"select-one"===this.passedElement.type&&(this.isSearching=!1,this.store.dispatch((0,a.activateChoices)()),this.toggleDropdown())}}break;case r:p&&this.toggleDropdown();break;case u:case l:if(p){var E=this.dropdown.querySelector("."+this.options.classNames.highlightedState),I=t.keyCode===u?1:-1,w=void 0;this.canSearch=!1,w=E?(0,c.getAdjacentEl)(E,"[data-option-selectable]",I):this.dropdown.querySelector("[data-option-selectable]"),w&&((0,c.isScrolledIntoView)(w,this.choiceList,I)||this._scrollToChoice(w,I),this._highlightChoice(w)),t.preventDefault()}break;case i:case n:d&&!t.target.value&&"select-one"!==this.passedElement.type&&(this._handleBackspace(h),t.preventDefault())}}}},{key:"_onKeyUp",value:function(t){var e=this;if(t.target===this.input){var i=String.fromCharCode(event.keyCode);if("text"===this.passedElement.type){var n=this.dropdown.classList.contains(this.options.classNames.activeState),s=void 0;if(this.input.value){var o=this.store.getItemsFilteredByActive(),r=!o.some(function(t){return t.value===e.input.value});s=this.options.maxItemCount&&this.options.maxItemCount>0&&this.options.maxItemCount<=this.itemList.children.length?this._getTemplate("notice","Only "+this.options.maxItemCount+" options can be added."):this.options.duplicateItems||r?this._getTemplate("notice",'Add "'+this.input.value+'"'):this._getTemplate("notice","Only unique values can be added."),(this.options.regexFilter&&this._regexFilter(this.input.value)||!this.options.regexFilter)&&(this.dropdown.innerHTML=s.outerHTML,this.dropdown.classList.contains(this.options.classNames.activeState)||this.showDropdown())}else n&&this.hideDropdown()}if(this.canSearch&&this.input===document.activeElement){var c=this.store.getChoices(),l=c.some(function(t){return t.active!==!0});if(this.input.value&&c.length&&/[a-zA-Z0-9-_ ]/.test(i)){var h=function(){var t=e.input.value.trim(),i=e.currentValue.trim();if(t.length>=1&&t!==i+" "){var n=e.store.getChoicesFiltedBySelectable(),s=t,o=new u.default(n,{keys:["label","value"],shouldSort:!0,include:"score"}),r=o.search(s);e.currentValue=t,e.highlightPosition=0,e.isSearching=!0,e.store.dispatch((0,a.filterChoices)(r))}};h()}else l&&(this.isSearching=!1,this.store.dispatch((0,a.activateChoices)()))}}}},{key:"_onInput",value:function(t){"select-one"!==this.passedElement.type&&(this.input.style.width=(0,c.getWidthOfInput)(this.input))}},{key:"_onMouseDown",value:function(t){var e=this;if(2!==t.button){var i=this.store.getItemsFilteredByActive();if(this.containerOuter.contains(t.target))!function(){t.preventDefault();var n=!!t.shiftKey;"text"===e.passedElement.type||e.dropdown.classList.contains(e.options.classNames.activeState)||e.showDropdown(),e.input!==document.activeElement&&e.input.focus(),t.target.hasAttribute("data-button")?e.options.removeItems&&e.options.removeItemButton&&!function(){var n=t.target.parentNode.getAttribute("data-id"),s=i.find(function(t){return t.id===parseInt(n)});e._removeItem(s)}():t.target.hasAttribute("data-item")?e.options.removeItems&&!function(){var s=t.target.getAttribute("data-id");i.forEach(function(t){t.id!==parseInt(s)||t.selected?n||e.deselectItem(t):e.selectItem(t)})}():t.target.hasAttribute("data-option")&&!function(){var i=e.store.getChoicesFilteredByActive(),n=t.target.getAttribute("data-id"),s=i.find(function(t){return t.id===parseInt(n)});s.selected||s.disabled||(e._addItem(s.value,s.label,s.id),"select-one"===e.passedElement.type&&(e.input.value="",e.isSearching=!1,e.store.dispatch((0,a.activateChoices)(!0)),e.toggleDropdown()))}()}();else{var n=this.dropdown.classList.contains(this.options.classNames.activeState),s=i.some(function(t){return t.selected===!0});s&&this.unhighlightAll(),this.containerOuter.classList.remove(this.options.classNames.focusState),n&&this.toggleDropdown()}}}},{key:"_onMouseOver",value:function(t){(t.target===this.dropdown||(0,c.findAncestor)(t.target,this.options.classNames.listDropdown))&&t.target.hasAttribute("data-option")&&this._highlightChoice(t.target)}},{key:"_onPaste",value:function(t){t.target===this.input&&(this.options.paste||t.preventDefault())}},{key:"_onFocus",value:function(t){var e=this.dropdown.classList.contains(this.options.classNames.activeState);t.target!==this.input||e||(this.containerOuter.classList.add(this.options.classNames.focusState),"select-one"!==this.passedElement.type&&"select-multiple"!==this.passedElement.type||this.showDropdown())}},{key:"_onBlur",value:function(t){var e=this.dropdown.classList.contains(this.options.classNames.activeState);t.target!==this.input||e?this.hideDropdown():this.containerOuter.classList.remove(this.options.classNames.focusState)}},{key:"_regexFilter",value:function(t){if(t){var e=new RegExp(this.options.regexFilter,"i");return e.test(t)}}},{key:"_scrollToChoice",value:function(t,e){var i=this;if(t){var n=this.choiceList.offsetHeight,s=t.offsetHeight,o=t.offsetTop+s,r=this.choiceList.scrollTop+n,a=e>0?this.choiceList.scrollTop+o-r:t.offsetTop,c=function l(t,e,n){var s=!1,o=void 0,r=void 0,a=4;n>0?(o=(e-i.choiceList.scrollTop)/a,r=o>1?o:1,i.choiceList.scrollTop=i.choiceList.scrollTop+r,i.choiceList.scrollTop<e&&(s=!0)):(o=(i.choiceList.scrollTop-e)/a,r=o>1?o:1,i.choiceList.scrollTop=i.choiceList.scrollTop-r,i.choiceList.scrollTop>e&&(s=!0)),s&&requestAnimationFrame(function(t){l(t,e,n)})};requestAnimationFrame(function(t){c(t,a,e)})}}},{key:"_highlightChoice",value:function(t){var e=this,i=Array.from(this.dropdown.querySelectorAll("[data-option-selectable]"));if(i&&i.length){var n=Array.from(this.dropdown.querySelectorAll("."+this.options.classNames.highlightedState));if(n.forEach(function(t){t.classList.remove(e.options.classNames.highlightedState)}),t)t.classList.add(this.options.classNames.highlightedState),this.highlightPosition=i.indexOf(t);else{var s=void 0;s=i.length>this.highlightPosition?i[this.highlightPosition]:i[i.length-1],s||(s=i[0]),s.classList.add(this.options.classNames.highlightedState)}}}},{key:"_addItem",value:function(t,e){var i=arguments.length<=2||void 0===arguments[2]?-1:arguments[2],n=arguments.length<=3||void 0===arguments[3]?this.options.callbackOnAddItem:arguments[3],s=this.store.getItems(),o=t.trim(),r=e||o,l=i||-1;this.options.prependValue&&(o=this.options.prependValue+o.toString()),this.options.appendValue&&(o+=this.options.appendValue.toString());var u=s?s.length+1:1;return this.store.dispatch((0,a.addItem)(o,r,u,l)),"select-one"===this.passedElement.type&&this.removeActiveItems(u),n&&((0,c.isType)("Function",n)?n(u,o,this.passedElement):console.error("callbackOnAddItem: Callback is not a function")),this}},{key:"_removeItem",value:function(t){var e=arguments.length<=1||void 0===arguments[1]?this.options.callbackOnRemoveItem:arguments[1];if(!t||!(0,c.isType)("Object",t))return void console.error("removeItem: No item object was passed to be removed");var i=t.id,n=(t.value,t.choiceId);return this.store.dispatch((0,a.removeItem)(i,n)),e?void((0,c.isType)("Function",e)||console.error("callbackOnRemoveItem: Callback is not a function")):this}},{key:"_addChoice",value:function(t,e,i,n){var s=arguments.length<=4||void 0===arguments[4]?-1:arguments[4];if(i){n||(n=i);var o=this.store.getChoices(),r=o?o.length+1:1;this.store.dispatch((0,a.addChoice)(i,n,r,s,e)),t&&!e&&this._addItem(i,n,r)}}},{key:"_addGroup",value:function(t,e,i){var n=this,s=Array.from(t.getElementsByTagName("OPTION")),o=e;s?(this.store.dispatch((0,a.addGroup)(t.label,o,!0,t.disabled)),s.forEach(function(t,e){var i=t.disabled||t.parentNode.disabled;n._addChoice(t.selected,i,t.value,t.innerHTML,o)})):this.store.dispatch((0,a.addGroup)(t.label,t.id,!1,t.disabled))}},{key:"_getTemplate",value:function(t){if(t){for(var e=this.options.templates,i=arguments.length,n=Array(i>1?i-1:0),s=1;i>s;s++)n[s-1]=arguments[s];return e[t].apply(e,n)}}},{key:"_createTemplates",value:function(){var t=this,e=this.options.classNames,i={containerOuter:function(){return(0,c.strToEl)('<div class="'+e.containerOuter+'" data-type="'+t.passedElement.type+'"></div>')},containerInner:function(){return(0,c.strToEl)('<div class="'+e.containerInner+'"></div>')},itemList:function(){return(0,c.strToEl)('<div class="'+e.list+" "+("select-one"===t.passedElement.type?e.listSingle:e.listItems)+'"></div>')},choiceList:function(){return(0,c.strToEl)('<div class="'+e.list+'"></div>')},input:function(){return(0,c.strToEl)('<input type="text" class="'+e.input+" "+e.inputCloned+'">')},dropdown:function(){return(0,c.strToEl)('<div class="'+e.list+" "+e.listDropdown+'"></div>')},notice:function(t,i){return(0,c.strToEl)('<div class="'+e.item+" "+e.itemChoice+'">'+t+"</div>")},selectOption:function(t){return(0,c.strToEl)('<option value="'+t.value+'" selected>'+t.label.trim()+"</option>")},option:function(t){return(0,c.strToEl)('\n <div class="'+e.item+" "+e.itemChoice+" "+(t.disabled?e.itemDisabled:e.itemSelectable)+'" data-option '+(t.disabled?"data-option-disabled":"data-option-selectable")+' data-id="'+t.id+'" data-value="'+t.value+'">\n '+t.label+"\n </div>\n ")},optgroup:function(t){return(0,c.strToEl)('\n <div class="'+e.group+" "+(t.disabled?e.itemDisabled:"")+'" data-group data-id="'+t.id+'" data-value="'+t.value+'">\n <div class="'+e.groupHeading+'">'+t.value+"</div>\n </div>\n ")},item:function(i){return t.options.removeItemButton&&"select-one"!==t.passedElement.type?(0,c.strToEl)('\n <div class="'+e.item+" "+(i.selected?e.selectedState:"")+" "+(i.disabled?"":e.itemSelectable)+'" data-item data-id="'+i.id+'" data-value="'+i.value+'" data-deletable>\n '+i.label+'\n <button class="'+e.button+'" data-button>Remove item</button>\n </div>\n '):(0,c.strToEl)('\n <div class="'+e.item+" "+(i.selected?e.selectedState:e.itemSelectable)+'" data-item data-id="'+i.id+'" data-value="'+i.value+'">\n '+i.label+"\n </div>\n ")}};this.options.templates=(0,c.extend)(this.options.templates,i)}},{key:"_createInput",value:function(){var t=this,e=this._getTemplate("containerOuter"),i=this._getTemplate("containerInner"),n=this._getTemplate("itemList"),s=this._getTemplate("choiceList"),o=this._getTemplate("input"),r=this._getTemplate("dropdown");if(this.containerOuter=e,this.containerInner=i,this.input=o,this.choiceList=s,this.itemList=n,this.dropdown=r,this.passedElement.classList.add(this.options.classNames.input,this.options.classNames.hiddenState),this.passedElement.tabIndex="-1",this.passedElement.setAttribute("style","display:none;"),this.passedElement.setAttribute("aria-hidden","true"),this.passedElement.removeAttribute("data-choice"),(0,c.wrap)(this.passedElement,i),(0,c.wrap)(i,e),this.options.placeholder&&(this.options.placeholderValue||this.passedElement.placeholder)){var a=this.options.placeholderValue||this.passedElement.placeholder;o.placeholder=a,"select-one"!==this.passedElement.type&&(o.style.width=(0,c.getWidthOfInput)(o))}if(this.options.addItems||this.disable(),e.appendChild(i),e.appendChild(r),i.appendChild(n),r.appendChild(s),"select-multiple"===this.passedElement.type||"text"===this.passedElement.type?i.appendChild(o):this.options.searchOptions&&r.insertBefore(o,r.firstChild),"select-multiple"===this.passedElement.type||"select-one"===this.passedElement.type){this.highlightPosition=0;var l=Array.from(this.passedElement.getElementsByTagName("OPTGROUP"));if(this.isSearching=!1,l&&l.length)l.forEach(function(e,i){var n=0===i;t._addGroup(e,i,n)});else{var u=Array.from(this.passedElement.options);u.forEach(function(e){var i=e.disabled||e.parentNode.disabled;t._addChoice(e.selected,i,e.value,e.innerHTML)})}}else"text"===this.passedElement.type&&this.presetItems.forEach(function(e){if((0,c.isType)("Object",e)){if(!e.value)return;t._addItem(e.value,e.label,e.id)}else(0,c.isType)("String",e)&&t._addItem(e)})}},{key:"renderGroups",value:function(t,e,i){var n=this,s=i||document.createDocumentFragment();return t.forEach(function(t,i){var o=e.filter(function(e){return"select-one"===n.passedElement.type?e.groupId===t.id:e.groupId===t.id&&!e.selected});if(o.length>=1){var r=n._getTemplate("optgroup",t);s.appendChild(r),n.renderOptions(o,s)}}),s}},{key:"renderOptions",value:function(t,e){var i=this,n=e||document.createDocumentFragment();return t.forEach(function(t,e){var s=i._getTemplate("option",t);"select-one"===i.passedElement.type?n.appendChild(s):t.selected||n.appendChild(s)}),n}},{key:"renderItems",value:function(t,e){var i=this,n=e||document.createDocumentFragment(),s=this.store.getItemsReducedToValues(t);return"text"===this.passedElement.type?this.passedElement.setAttribute("value",s.join(this.options.delimiter)):!function(){var e=document.createDocumentFragment();t.forEach(function(t){var n=i._getTemplate("selectOption",t);e.appendChild(n)}),i.passedElement.innerHTML="",i.passedElement.appendChild(e)}(),t.forEach(function(t){var e=i._getTemplate("item",t);n.appendChild(e)}),n}},{key:"render",value:function(){if(this.currentState=this.store.getState(),this.currentState!==this.prevState){if(!(this.currentState.options===this.prevState.options&&this.currentState.groups===this.prevState.groups||"select-multiple"!==this.passedElement.type&&"select-one"!==this.passedElement.type)){var t=this.store.getGroupsFilteredByActive(),e=this.store.getChoicesFilteredByActive(),i=document.createDocumentFragment();if(this.choiceList.innerHTML="",t.length>=1&&this.isSearching!==!0?i=this.renderGroups(t,e,i):e.length>=1&&(i=this.renderOptions(e,i)),i.children.length)this.choiceList.appendChild(i),this._highlightChoice();else{var n=this.isSearching?this._getTemplate("notice","No results found"):this._getTemplate("notice","No choices to choose from");this.choiceList.appendChild(n)}}if(this.currentState.items!==this.prevState.items){var s=this.store.getItemsFilteredByActive();if(s){var o=this.renderItems(s);this.itemList.innerHTML="",o.children.length&&this.itemList.appendChild(o)}}this.prevState=this.currentState}}},{key:"_addEventListeners",value:function(){document.addEventListener("keyup",this._onKeyUp),document.addEventListener("keydown",this._onKeyDown),document.addEventListener("mousedown",this._onMouseDown),document.addEventListener("mouseover",this._onMouseOver),this.input.addEventListener("input",this._onInput),this.input.addEventListener("paste",this._onPaste),this.input.addEventListener("focus",this._onFocus),this.input.addEventListener("blur",this._onBlur)}},{key:"_removeEventListeners",value:function(){document.removeEventListener("keyup",this._onKeyUp),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("mousedown",this._onMouseDown),document.removeEventListener("mouseover",this._onMouseOver),this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("paste",this._onPaste),this.input.removeEventListener("focus",this._onFocus),this.input.removeEventListener("blur",this._onBlur)}}]),t}();window.Choices=t.exports=p},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.addItem=function(t,e,i,n){return{type:"ADD_ITEM",value:t,label:e,id:i,choiceId:n}},e.removeItem=function(t,e){return{type:"REMOVE_ITEM",id:t,choiceId:e}},e.selectItem=function(t,e){return{type:"SELECT_ITEM",id:t,selected:e}},e.addChoice=function(t,e,i,n,s){return{type:"ADD_CHOICE",value:t,label:e,id:i,groupId:n,disabled:s}},e.filterChoices=function(t){return{type:"FILTER_CHOICES",results:t}},e.activateChoices=function(){var t=arguments.length<=0||void 0===arguments[0]?!0:arguments[0];return{type:"ACTIVATE_OPTIONS",active:t}},e.addGroup=function(t,e,i,n){return{type:"ADD_GROUP",value:t,id:e,active:i,disabled:n}},e.clearAll=function(){return{type:"CLEAR_ALL"}}},function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=(e.hasClass=function(t,e){return new RegExp(" "+e+" ").test(" "+t.className+" ")},e.capitalise=function(t){return t.replace(/\w\S*/g,function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()})},e.isType=function(t,e){var i=Object.prototype.toString.call(e).slice(8,-1);return void 0!==e&&null!==e&&i===t}),n=(e.extend=function o(){for(var t={},e=!1,n=arguments.length,s=function(n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e&&i("Object",n[s])?t[s]=o(!0,t[s],n[s]):t[s]=n[s])},r=0;n>r;r++){var a=arguments[r];i("Object",a)?s(a):console.error("Custom options must be an object")}return t},e.whichTransitionEvent=function(){var t,e=document.createElement("fakeelement"),i={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in i)if(void 0!==e.style[t])return i[t]},e.whichAnimationEvent=function(){var t,e=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}),s=(e.getParentsUntil=function(t,e,i){for(var n=[];t&&t!==document;t=t.parentNode){if(e){var s=e.charAt(0);if("."===s&&t.classList.contains(e.substr(1)))break;if("#"===s&&t.id===e.substr(1))break;if("["===s&&t.hasAttribute(e.substr(1,e.length-1)))break;if(t.tagName.toLowerCase()===e)break}if(i){var o=i.charAt(0);"."===o&&t.classList.contains(i.substr(1))&&n.push(t),"#"===o&&t.id===i.substr(1)&&n.push(t),"["===o&&t.hasAttribute(i.substr(1,i.length-1))&&n.push(t),t.tagName.toLowerCase()===i&&n.push(t)}else n.push(t)}return 0===n.length?null:n},e.wrap=function(t,e){return e=e||document.createElement("div"),t.nextSibling?t.parentNode.insertBefore(e,t.nextSibling):t.parentNode.appendChild(e),e.appendChild(t)},e.getSiblings=function(t){for(var e=[],i=t.parentNode.firstChild;i;i=i.nextSibling)1===i.nodeType&&i!==t&&e.push(i);return e},e.findAncestor=function(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t},e.debounce=function(t,e,i){var n;return function(){var s=this,o=arguments,r=function(){n=null,i||t.apply(s,o)},a=i&&!n;clearTimeout(n),n=setTimeout(r,e),a&&t.apply(s,o)}},e.getElemDistance=function(t){var e=0;if(t.offsetParent)do e+=t.offsetTop,t=t.offsetParent;while(t);return e>=0?e:0},e.getElementOffset=function(t,e){var i=e;return i>1&&(i=1),i>0&&(i=0),Math.max(t.offsetHeight*i)},e.getAdjacentEl=function(t,e){var i=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(t&&e){var n=t.parentNode.parentNode,s=Array.from(n.querySelectorAll(e)),o=s.indexOf(t),r=i>0?1:-1;return s[o+r]}},e.getScrollPosition=function(t){return"bottom"===t?Math.max((window.scrollY||window.pageYOffset)+(window.innerHeight||document.documentElement.clientHeight)):window.scrollY||window.pageYOffset},e.isInView=function(t,e,i){return this.getScrollPosition(e)>this.getElemDistance(t)+this.getElementOffset(t,i)},e.isScrolledIntoView=function(t,e){var i=arguments.length<=2||void 0===arguments[2]?1:arguments[2];if(t){var n=void 0;return n=i>0?e.scrollTop+e.offsetHeight>=t.offsetTop+t.offsetHeight:t.offsetTop>=e.scrollTop}},e.stripHTML=function(t){var e=document.createElement("DIV");return e.innerHTML=t,e.textContent||e.innerText||""},e.addAnimation=function(t,e){var i=n(),s=function o(){t.classList.remove(e),t.removeEventListener(i,o,!1)};t.classList.add(e),t.addEventListener(i,s,!1)},e.getRandomNumber=function(t,e){return Math.floor(Math.random()*(e-t)+t)},e.strToEl=function(){var t=document.createElement("div");return function(e){var i;for(t.innerHTML=e,i=t.children[0];t.firstChild;)t.removeChild(t.firstChild);return i}}());e.getWidthOfInput=function(t){var e=t.value||t.placeholder,i=t.offsetWidth;if(e){var n=s("<span>"+e+"</span>");n.style.position="absolute",n.style.padding="0",n.style.top="-9999px",n.style.left="-9999px",n.style.width="auto",n.style.whiteSpace="pre",document.body.appendChild(n),e&&n.offsetWidth!==t.offsetWidth&&(i=n.offsetWidth+4),document.body.removeChild(n)}return i+"px"}},function(t,e,i){!function(e){"use strict";function i(){console.log.apply(console,arguments)}function n(t,e){var i,n,s,o;for(this.list=t,this.options=e=e||{},i=0,o=["sort","shouldSort","verbose","tokenize"],n=o.length;n>i;i++)s=o[i],this.options[s]=s in e?e[s]:c[s];for(i=0,o=["searchFn","sortFn","keys","getFn","include"],n=o.length;n>i;i++)s=o[i],this.options[s]=e[s]||c[s]}function s(t,e,i){var n,r,a,c,l,u;if(e){if(a=e.indexOf("."),-1!==a?(n=e.slice(0,a),r=e.slice(a+1)):n=e,c=t[n],null!==c&&void 0!==c)if(r||"string"!=typeof c&&"number"!=typeof c)if(o(c))for(l=0,u=c.length;u>l;l++)s(c[l],r,i);else r&&s(c,r,i);else i.push(c)}else i.push(t);return i}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}function r(t,e){e=e||{},this.options=e,this.options.location=e.location||r.defaultOptions.location,this.options.distance="distance"in e?e.distance:r.defaultOptions.distance,this.options.threshold="threshold"in e?e.threshold:r.defaultOptions.threshold,this.options.maxPatternLength=e.maxPatternLength||r.defaultOptions.maxPatternLength,this.pattern=e.caseSensitive?t:t.toLowerCase(),this.patternLen=t.length,this.patternLen<=this.options.maxPatternLength&&(this.matchmask=1<<this.patternLen-1,this.patternAlphabet=this._calculatePatternAlphabet())}var a=/ +/g,c={id:null,caseSensitive:!1,include:[],shouldSort:!0,searchFn:r,sortFn:function(t,e){return t.score-e.score},getFn:s,keys:[],verbose:!1,tokenize:!1};n.VERSION="2.2.0",n.prototype.set=function(t){return this.list=t,t},n.prototype.search=function(t){this.options.verbose&&i("\nSearch term:",t,"\n"),this.pattern=t,this.results=[],this.resultMap={},this._keyMap=null,this._prepareSearchers(),this._startSearch(),this._computeScore(),this._sort();var e=this._format();return e},n.prototype._prepareSearchers=function(){var t=this.options,e=this.pattern,i=t.searchFn,n=e.split(a),s=0,o=n.length;if(this.options.tokenize)for(this.tokenSearchers=[];o>s;s++)this.tokenSearchers.push(new i(n[s],t));this.fullSeacher=new i(e,t)},n.prototype._startSearch=function(){var t,e,i,n,s=this.options,o=s.getFn,r=this.list,a=r.length,c=this.options.keys,l=c.length,u=null;if("string"==typeof r[0])for(i=0;a>i;i++)this._analyze("",r[i],i,i);else for(this._keyMap={},i=0;a>i;i++)for(u=r[i],n=0;l>n;n++){if(t=c[n],"string"!=typeof t){if(e=1-t.weight||1,this._keyMap[t.name]={weight:e},t.weight<=0||t.weight>1)throw new Error("Key weight has to be > 0 and <= 1");t=t.name}else this._keyMap[t]={weight:1};this._analyze(t,o(u,t,[]),u,i)}},n.prototype._analyze=function(t,e,n,s){var r,c,l,u,h,d,p,f,v,m,g,y,b,_,E,I=this.options,w=!1;if(void 0!==e&&null!==e)if(c=[],"string"==typeof e){if(r=e.split(a),I.verbose&&i("---------\nKey:",t),
I.verbose&&i("Record:",r),this.options.tokenize){for(l=this.tokenSearchers,u=l.length,_=0;_<this.tokenSearchers.length;_++){for(m=this.tokenSearchers[_],g=[],E=0;E<r.length;E++)y=r[E],b=m.search(y),b.isMatch?(w=!0,g.push(b.score),c.push(b.score)):(g.push(1),c.push(1));I.verbose&&i("Token scores:",g)}for(d=c[0],f=c.length,_=1;f>_;_++)d+=c[_];d/=f,I.verbose&&i("Token score average:",d)}v=this.fullSeacher.search(e),I.verbose&&i("Full text score:",v.score),p=v.score,void 0!==d&&(p=(p+d)/2),I.verbose&&i("Score average:",p),(w||v.isMatch)&&(h=this.resultMap[s],h?h.output.push({key:t,score:p,matchedIndices:v.matchedIndices}):(this.resultMap[s]={item:n,output:[{key:t,score:p,matchedIndices:v.matchedIndices}]},this.results.push(this.resultMap[s])))}else if(o(e))for(_=0;_<e.length;_++)this._analyze(t,e[_],n,s)},n.prototype._computeScore=function(){var t,e,n,s,o,r,a,c,l,u=this._keyMap,h=this.results;for(this.options.verbose&&i("\n\nComputing score:\n"),t=0;t<h.length;t++){for(n=0,s=h[t].output,o=s.length,c=1,e=0;o>e;e++)r=s[e].score,a=u?u[s[e].key].weight:1,l=r*a,1!==a?c=Math.min(c,l):(n+=l,s[e].nScore=l);1===c?h[t].score=n/o:h[t].score=c,this.options.verbose&&i(h[t])}},n.prototype._sort=function(){var t=this.options;t.shouldSort&&(t.verbose&&i("\n\nSorting...."),this.results.sort(t.sortFn))},n.prototype._format=function(){var t,e,n,s,o,r=this.options,a=r.getFn,c=[],l=this.results,u=r.include;for(r.verbose&&i("\n\nOutput:\n\n",l),s=r.id?function(t){l[t].item=a(l[t].item,r.id,[])[0]}:function(){},o=function(t){var e,i,n,s,o,r=l[t];if(u.length>0){if(e={item:r.item},-1!==u.indexOf("matches"))for(n=r.output,e.matches=[],i=0;i<n.length;i++)s=n[i],o={indices:s.matchedIndices},s.key&&(o.key=s.key),e.matches.push(o);-1!==u.indexOf("score")&&(e.score=l[t].score)}else e=r.item;return e},e=0,n=l.length;n>e;e++)s(e),t=o(e),c.push(t);return c},r.defaultOptions={location:0,distance:100,threshold:.6,maxPatternLength:32},r.prototype._calculatePatternAlphabet=function(){var t={},e=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]=0;for(e=0;e<this.patternLen;e++)t[this.pattern.charAt(e)]|=1<<this.pattern.length-e-1;return t},r.prototype._bitapScore=function(t,e){var i=t/this.patternLen,n=Math.abs(this.options.location-e);return this.options.distance?i+n/this.options.distance:n?1:i},r.prototype.search=function(t){var e,i,n,s,o,r,c,l,u,h,d,p,f,v,m,g,y,b,_,E,I,w,S=this.options;if(t=S.caseSensitive?t:t.toLowerCase(),this.pattern===t)return{isMatch:!0,score:0,matchedIndices:[[0,t.length-1]]};if(this.patternLen>S.maxPatternLength){if(y=t.match(new RegExp(this.pattern.replace(a,"|"))),b=!!y)for(E=[],e=0,I=y.length;I>e;e++)w=y[e],E.push([t.indexOf(w),w.length-1]);return{isMatch:b,score:b?.5:1,matchedIndices:E}}for(s=S.location,n=t.length,o=S.threshold,r=t.indexOf(this.pattern,s),_=[],e=0;n>e;e++)_[e]=0;for(-1!=r&&(o=Math.min(this._bitapScore(0,r),o),r=t.lastIndexOf(this.pattern,s+this.patternLen),-1!=r&&(o=Math.min(this._bitapScore(0,r),o))),r=-1,m=1,g=[],u=this.patternLen+n,e=0;e<this.patternLen;e++){for(c=0,l=u;l>c;)this._bitapScore(e,s+l)<=o?c=l:u=l,l=Math.floor((u-c)/2+c);for(u=l,h=Math.max(1,s-l+1),d=Math.min(s+l,n)+this.patternLen,p=Array(d+2),p[d+1]=(1<<e)-1,i=d;i>=h;i--)if(v=this.patternAlphabet[t.charAt(i-1)],v&&(_[i-1]=1),0===e?p[i]=(p[i+1]<<1|1)&v:p[i]=(p[i+1]<<1|1)&v|((f[i+1]|f[i])<<1|1)|f[i+1],p[i]&this.matchmask&&(m=this._bitapScore(e,i-1),o>=m)){if(o=m,r=i-1,g.push(r),!(r>s))break;h=Math.max(1,2*s-r)}if(this._bitapScore(e+1,s)>o)break;f=p}return E=this._getMatchedIndices(_),{isMatch:r>=0,score:0===m?.001:m,matchedIndices:E}},r.prototype._getMatchedIndices=function(t){for(var e,i=[],n=-1,s=-1,o=0,r=r=t.length;r>o;o++)e=t[o],e&&-1===n?n=o:e||-1===n||(s=o-1,i.push([n,s]),n=-1);return t[o-1]&&i.push([n,o-1]),i},t.exports=n}(this)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Store=void 0;var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),r=i(6),a=i(19),c=n(a),l=e.Store=function(){function t(){s(this,t),this.store=(0,r.createStore)(c.default,window.devToolsExtension?window.devToolsExtension():void 0)}return o(t,[{key:"getState",value:function(){return this.store.getState()}},{key:"dispatch",value:function(t){this.store.dispatch(t)}},{key:"subscribe",value:function(t){this.store.subscribe(t)}},{key:"getItems",value:function(){var t=this.store.getState();return t.items}},{key:"getItemsFilteredByActive",value:function(){var t=this.getItems(),e=t.filter(function(t){return t.active===!0},[]);return e}},{key:"getItemsReducedToValues",value:function(){var t=arguments.length<=0||void 0===arguments[0]?this.getItems():arguments[0],e=t.reduce(function(t,e){return t.push(e.value),t},[]);return e}},{key:"getChoices",value:function(){var t=this.store.getState();return t.choices}},{key:"getChoicesFilteredByActive",value:function(){var t=this.getChoices(),e=t.filter(function(t){return t.active===!0},[]);return e}},{key:"getChoicesFiltedBySelectable",value:function(){var t=this.getChoices(),e=t.filter(function(t){return t.selected===!1&&t.disabled!==!0},[]);return e}},{key:"getGroups",value:function(){var t=this.store.getState();return t.groups}},{key:"getGroupsFilteredByActive",value:function(){var t=this.getGroups(),e=this.getChoices(),i=t.filter(function(t){var i=t.active===!0&&t.disabled===!1,n=e.some(function(t){return t.active===!0&&t.disabled===!1});return!(!i||!n)},[]);return i}}]),t}();t.exports=l},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.compose=e.applyMiddleware=e.bindActionCreators=e.combineReducers=e.createStore=void 0;var s=i(7),o=n(s),r=i(14),a=n(r),c=i(16),l=n(c),u=i(17),h=n(u),d=i(18),p=n(d),f=i(15);n(f);e.createStore=o.default,e.combineReducers=a.default,e.bindActionCreators=l.default,e.applyMiddleware=h.default,e.compose=p.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e,i){function n(){g===m&&(g=m.slice())}function o(){return v}function a(t){if("function"!=typeof t)throw new Error("Expected listener to be a function.");var e=!0;return n(),g.push(t),function(){if(e){e=!1,n();var i=g.indexOf(t);g.splice(i,1)}}}function u(t){if(!(0,r.default)(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if("undefined"==typeof t.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(y)throw new Error("Reducers may not dispatch actions.");try{y=!0,v=f(v,t)}finally{y=!1}for(var e=m=g,i=0;i<e.length;i++)e[i]();return t}function h(t){if("function"!=typeof t)throw new Error("Expected the nextReducer to be a function.");f=t,u({type:l.INIT})}function d(){var t,e=a;return t={subscribe:function(t){function i(){t.next&&t.next(o())}if("object"!=typeof t)throw new TypeError("Expected the observer to be an object.");i();var n=e(i);return{unsubscribe:n}}},t[c.default]=function(){return this},t}var p;if("function"==typeof e&&"undefined"==typeof i&&(i=e,e=void 0),"undefined"!=typeof i){if("function"!=typeof i)throw new Error("Expected the enhancer to be a function.");return i(s)(t,e)}if("function"!=typeof t)throw new Error("Expected the reducer to be a function.");var f=t,v=e,m=[],g=m,y=!1;return u({type:l.INIT}),p={dispatch:u,subscribe:a,getState:o,replaceReducer:h},p[c.default]=d,p}e.__esModule=!0,e.ActionTypes=void 0,e.default=s;var o=i(8),r=n(o),a=i(12),c=n(a),l=e.ActionTypes={INIT:"@@redux/INIT"}},function(t,e,i){function n(t){if(!r(t)||d.call(t)!=a||o(t))return!1;var e=s(t);if(null===e)return!0;var i=u.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==h}var s=i(9),o=i(10),r=i(11),a="[object Object]",c=Object.prototype,l=Function.prototype.toString,u=c.hasOwnProperty,h=l.call(Object),d=c.toString;t.exports=n},function(t,e){function i(t){return n(Object(t))}var n=Object.getPrototypeOf;t.exports=i},function(t,e){function i(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(i){}return e}t.exports=i},function(t,e){function i(t){return!!t&&"object"==typeof t}t.exports=i},function(t,e,i){(function(e){"use strict";t.exports=i(13)(e||window||this)}).call(e,function(){return this}())},function(t,e){"use strict";t.exports=function(t){var e,i=t.Symbol;return"function"==typeof i?i.observable?e=i.observable:(e=i("observable"),i.observable=e):e="@@observable",e}},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){var i=e&&e.type,n=i&&'"'+i.toString()+'"'||"an action";return"Given action "+n+', reducer "'+t+'" returned undefined. To ignore an action, you must explicitly return the previous state.'}function o(t){Object.keys(t).forEach(function(e){var i=t[e],n=i(void 0,{type:a.ActionTypes.INIT});if("undefined"==typeof n)throw new Error('Reducer "'+e+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');var s="@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".");if("undefined"==typeof i(void 0,{type:s}))throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+a.ActionTypes.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined.")})}function r(t){for(var e=Object.keys(t),i={},n=0;n<e.length;n++){var r=e[n];"function"==typeof t[r]&&(i[r]=t[r])}var a,c=Object.keys(i);try{o(i)}catch(l){a=l}return function(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=arguments[1];if(a)throw a;for(var n=!1,o={},r=0;r<c.length;r++){var l=c[r],u=i[l],h=t[l],d=u(h,e);if("undefined"==typeof d){var p=s(l,e);throw new Error(p)}o[l]=d,n=n||d!==h}return n?o:t}}e.__esModule=!0,e.default=r;var a=i(7),c=i(8),l=(n(c),i(15));n(l)},function(t,e){"use strict";function i(t){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(t);try{throw new Error(t)}catch(e){}}e.__esModule=!0,e.default=i},function(t,e){"use strict";function i(t,e){return function(){return e(t.apply(void 0,arguments))}}function n(t,e){if("function"==typeof t)return i(t,e);if("object"!=typeof t||null===t)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===t?"null":typeof t)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');for(var n=Object.keys(t),s={},o=0;o<n.length;o++){var r=n[o],a=t[r];"function"==typeof a&&(s[r]=i(a,e))}return s}e.__esModule=!0,e.default=n},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(){for(var t=arguments.length,e=Array(t),i=0;t>i;i++)e[i]=arguments[i];return function(t){return function(i,n,s){var r=t(i,n,s),c=r.dispatch,l=[],u={getState:r.getState,dispatch:function(t){return c(t)}};return l=e.map(function(t){return t(u)}),c=a.default.apply(void 0,l)(r.dispatch),o({},r,{dispatch:c})}}}e.__esModule=!0;var o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t};e.default=s;var r=i(18),a=n(r)},function(t,e){"use strict";function i(){for(var t=arguments.length,e=Array(t),i=0;t>i;i++)e[i]=arguments[i];if(0===e.length)return function(t){return t};var n=function(){var t=e[e.length-1],i=e.slice(0,-1);return{v:function(){return i.reduceRight(function(t,e){return e(t)},t.apply(void 0,arguments))}}}();return"object"==typeof n?n.v:void 0}e.__esModule=!0,e.default=i},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0});var s=i(6),o=i(20),r=n(o),a=i(21),c=n(a),l=i(22),u=n(l),h=(0,s.combineReducers)({items:r.default,groups:c.default,choices:u.default}),d=function(t,e){return"CLEAR_ALL"===e.type&&(t=void 0),h(t,e)};e.default=d},function(t,e){"use strict";function i(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],e=arguments[1];switch(e.type){case"ADD_ITEM":var n=[].concat(i(t),[{id:e.id,choiceId:e.choiceId,value:e.value,label:e.label,active:!0,selected:!1}]);return n.map(function(t){return t.selected&&(t.selected=!1),t});case"REMOVE_ITEM":return t.map(function(t){return t.id===e.id&&(t.active=!1),t});case"SELECT_ITEM":return t.map(function(t){return t.id===e.id&&(t.selected=e.selected),t});default:return t}};e.default=n},function(t,e){"use strict";function i(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],e=arguments[1];switch(e.type){case"ADD_GROUP":return[].concat(i(t),[{id:e.id,value:e.value,active:e.active,disabled:e.disabled}]);default:return t}};e.default=n},function(t,e){"use strict";function i(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)}Object.defineProperty(e,"__esModule",{value:!0});var n=function(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0],e=arguments[1];switch(e.type){case"ADD_CHOICE":return[].concat(i(t),[{id:e.id,groupId:e.groupId,value:e.value,label:e.label,disabled:e.disabled,selected:!1,active:!0,score:9999}]);case"ADD_ITEM":return e.choiceId>-1?t.map(function(t){return t.id===parseInt(e.choiceId)&&(t.selected=!0),t}):t;case"REMOVE_ITEM":return e.choiceId>-1?t.map(function(t){return t.id===parseInt(e.choiceId)&&(t.selected=!1),t}):t;case"FILTER_CHOICES":var n=e.results,s=t.map(function(t,e){return t.active=n.some(function(e){return e.item.id===t.id?(t.score=e.score,!0):void 0}),t}).sort(function(t,e){return t.score-e.score});return s;case"ACTIVATE_CHOICES":return t.map(function(t){return t.active=e.active,t});default:return t}};e.default=n}]);