New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

choices.js

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

choices.js - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

assets/scripts/src/lib/polyfills.js

4

assets/scripts/dist/choices.min.js

@@ -1,2 +0,2 @@

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

@@ -1,2 +0,2 @@

export const addItem = (value, label, id, choiceId) => {
export const addItem = (value, label, id, choiceId, activateOptions) => {
return {

@@ -8,2 +8,3 @@ type: 'ADD_ITEM',

choiceId,
activateOptions,
}

@@ -10,0 +11,0 @@ };

'use strict';
import './lib/polyfills.js';
import { addItem, removeItem, highlightItem, addChoice, filterChoices, activateChoices, addGroup, clearAll } from './actions/index';

@@ -28,2 +29,3 @@ import { isScrolledIntoView, getAdjacentEl, findAncestor, wrap, isType, isElement, strToEl, extend, getWidthOfInput, debounce } from './lib/utils.js';

items: [],
choices: [],
maxItemCount: -1,

@@ -72,3 +74,3 @@ addItems: true,

callbackOnRemoveItem: (id, value, passedInput) => {},
callbackOnRender: () => {},
callbackOnRender: (state) => {},
};

@@ -94,4 +96,8 @@

// Assing preset choices from passed object
this.presetChoices = this.config.choices;
// Assign preset items from passed object first
this.presetItems = this.config.items;
// Then add any values passed from attribute

@@ -127,3 +133,3 @@ if(this.passedElement.value) {

// If element has already been initalised with Choices
if(this.passedElement.getAttribute('data-choice') === 'active') return
if(this.passedElement.getAttribute('data-choice') === 'active') return;

@@ -437,3 +443,2 @@ // Let's go

this.containerOuter.classList.remove(this.config.classNames.loadingState);
// this.input.placeholder = "";
results.forEach((result, index) => {

@@ -661,3 +666,3 @@ // Select first choice in list if single select input

if(e.target !== this.input) return;
const keyString = String.fromCharCode(event.keyCode);
const keyString = String.fromCharCode(e.keyCode);

@@ -703,3 +708,3 @@ // We are typing into a text input and have a value, we want to show a dropdown

// Check that we have a value to search and the input was an alphanumeric character
if(this.input.value && choices.length && /[\b\a-zA-Z0-9-_ ]/.test(keyString)) {
if(this.input.value && this.input.value.length > 1) {
const handleFilter = () => {

@@ -1014,7 +1019,7 @@ const newValue = this.input.value.trim();

*/
_addItem(value, label, choiceId = -1, callback = this.config.callbackOnAddItem) {
_addItem(value, label, choiceId = -1) {
const items = this.store.getItems();
let passedValue = value.trim();
let passedLabel = label || passedValue;
let passedOptionId = choiceId || -1;
let passedOptionId = parseInt(choiceId) || -1;

@@ -1041,3 +1046,4 @@ // If a prepended value has been passed, prepend it

// Run callback if it is a function
if(callback){
if(this.config.callbackOnAddItem){
const callback = this.config.callbackOnAddItem;
if(isType('Function', callback)) {

@@ -1272,6 +1278,19 @@ callback(id, passedValue, this.passedElement);

const passedOptions = Array.from(this.passedElement.options);
passedOptions.forEach((option) => {
const isDisabled = option.disabled || option.parentNode.disabled;
this._addChoice(option.selected, isDisabled, option.value, option.innerHTML);
let allChoices = [];
// Create array of options from option elements
passedOptions.forEach((o) => {
allChoices.push({
value: o.value,
label: o.innerHTML,
selected: o.selected,
disabled: o.disabled || o.parentNode.disabled
});
});
allChoices
.concat(this.presetChoices)
.forEach((o) => {
this._addChoice(o.selected ? o.selected : false, o.disabled ? o.disabled : false, o.value, o.label);
});
}

@@ -1302,20 +1321,21 @@ } else if(this.passedElement.type === 'text') {

groups.forEach((group, i) => {
// Grab options that are children of this group
const groupChoices = choices.filter((choice) => {
if(this.passedElement.type === 'select-one') {
return choice.groupId === group.id
} else {
return choice.groupId === group.id && !choice.selected;
}
});
groups
.forEach((group, i) => {
// Grab options that are children of this group
const groupChoices = choices.filter((choice) => {
if(this.passedElement.type === 'select-one') {
return choice.groupId === group.id
} else {
return choice.groupId === group.id && !choice.selected;
}
});
if(groupChoices.length >= 1) {
const dropdownGroup = this._getTemplate('choiceGroup', group);
if(groupChoices.length >= 1) {
const dropdownGroup = this._getTemplate('choiceGroup', group);
groupFragment.appendChild(dropdownGroup);
groupFragment.appendChild(dropdownGroup);
this.renderChoices(groupChoices, groupFragment);
}
});
this.renderChoices(groupChoices, groupFragment);
}
});

@@ -1336,11 +1356,12 @@ return groupFragment;

choices.forEach((choice, i) => {
const dropdownItem = this._getTemplate('choice', choice);
choices
.forEach((choice, i) => {
const dropdownItem = this._getTemplate('choice', choice);
if(this.passedElement.type === 'select-one') {
choicesFragment.appendChild(dropdownItem);
} else if(!choice.selected) {
choicesFragment.appendChild(dropdownItem);
}
});
if(this.passedElement.type === 'select-one') {
choicesFragment.appendChild(dropdownItem);
} else if(!choice.selected) {
choicesFragment.appendChild(dropdownItem);
}
});

@@ -1425,3 +1446,3 @@ return choicesFragment;

if(choiceListFragment.children && choiceListFragment.children.length) {
if(choiceListFragment.childNodes) {
// If we actually have anything to add to our dropdown

@@ -1459,3 +1480,3 @@ // append it and highlight the first choice

if(isType('Function', this.config.callbackOnRender)) {
this.config.callbackOnRender();
this.config.callbackOnRender(this.currentState);
} else {

@@ -1462,0 +1483,0 @@ console.error('callbackOnRender: Callback is not a function');

@@ -469,4 +469,4 @@ export const hasClass = (elem, className) => {

export const sortByAlpha = (a, b) => {
const labelA = a.label.toLowerCase();
const labelB = b.label.toLowerCase();
const labelA = (a.label || a.value).toLowerCase();
const labelB = (b.label || b.value).toLowerCase();

@@ -473,0 +473,0 @@ if (labelA < labelB) return -1;

@@ -18,6 +18,15 @@ import { sortByAlpha } from './../lib/utils.js';

case 'ADD_ITEM':
let newState = state;
// If all choices need to be activated
if(action.activateOptions) {
newState = state.map((choice) => {
choice.active = action.active;
return choice;
}).sort(sortByAlpha);
}
// When an item is added and it has an associated choice,
// we want to disable it so it can't be chosen again
if(action.choiceId > -1) {
return state.map((choice) => {
newState = state.map((choice) => {
if(choice.id === parseInt(action.choiceId)) {

@@ -28,6 +37,6 @@ choice.selected = true;

});
} else {
return state;
}
return newState;
case 'REMOVE_ITEM':

@@ -34,0 +43,0 @@ // When an item is removed and it has an associated choice,

@@ -0,1 +1,3 @@

import { sortByAlpha } from './../lib/utils.js';
const groups = (state = [], action) => {

@@ -9,3 +11,3 @@ switch (action.type) {

disabled: action.disabled,
}];
}].sort(sortByAlpha);;

@@ -12,0 +14,0 @@ default:

{
"name": "choices.js",
"version": "1.0.0",
"version": "1.0.1",
"description": "A vanilla JS customisable text input/select box plugin",

@@ -36,2 +36,3 @@ "main": "./assets/scripts/dist/choices.min.js",

"csso": "^1.7.0",
"es6-promise": "^3.2.1",
"eslint": "^2.4.0",

@@ -53,3 +54,4 @@ "fuse.js": "^2.2.0",

"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
"webpack-dev-server": "^1.14.1",
"whatwg-fetch": "^1.0.0"
},

@@ -56,0 +58,0 @@ "dependencies": {

# Choices.js [![Build Status](https://travis-ci.org/jshjohnson/Choices.svg?branch=master)](https://travis-ci.org/jshjohnson/Choices)
A lightweight, configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.
[Demo](https://joshuajohnson.co.uk/Choices/)
## Setup

@@ -27,2 +29,3 @@

items: [],
options: [],
maxItemCount: -1,

@@ -68,2 +71,9 @@ addItems: true,

},
sortFunction: (a, b) => {
const labelA = (a.label || a.value).toLowerCase();
const labelB = (b.label || b.value).toLowerCase();
if (labelA < labelB) return -1;
if (labelA > labelB) return 1;
return 0;
},
callbackOnInit: () => {},

@@ -78,4 +88,5 @@ callbackOnAddItem: (id, value, passedInput) => {},

## Installation
Coming to NPM soon.
`npm install choices.js --save-dev`
## Terminology

@@ -90,5 +101,8 @@ | Word | Definition |

### items
<strong>Type:</strong> <strong>Default:</strong> `[]`
<strong>Usage:</strong> Add pre-selected items to input.
<strong>Type:</strong> `Array` <strong>Default:</strong> `[]`
<strong>Usage:</strong> Add pre-selected items (see terminology) to text input.
<strong>Input types affected:</strong> `text`
Pass an array of strings:

@@ -113,5 +127,31 @@

### choices
<strong>Type:</strong> `Array` <strong>Default:</strong> `[]`
<strong>Usage:</strong> Add choices (see terminology) to select input.
<strong>Input types affected:</strong> `select-one`, `select-multiple`
Pass an array of objects:
```
[{
value: 'Option 1',
label: 'Option 1',
selected: true,
disabled: false,
},
{
value: 'Option 2',
label: 'Option 2',
selected: false,
disabled: true,
}]
```
### maxItemCount
<strong>Type:</strong> `Number` <strong>Default:</strong>`-1`
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> The amount of items a user can input/select ("-1" indicates no limit).

@@ -122,2 +162,4 @@

<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> Whether a user can add items to the passed input's value.

@@ -128,2 +170,4 @@

<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Whether a user can remove items (only affects text and multiple select input types).

@@ -134,2 +178,4 @@

<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Whether a button should show that, when clicked, will remove an item (only affects text and multiple select input types).

@@ -140,2 +186,4 @@

<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> Whether a user can edit selected items (only affects text input types).

@@ -148,12 +196,18 @@

<strong>Usage:</strong> What divides each value (only affects text input types).
<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> What divides each value.
### duplicates
<strong>Type:</strong> `Boolean` <strong>Default:</strong>`true`
<strong>Usage:</strong> Whether a user can input a duplicate item (only affects text input types).
<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> Whether a user can input a duplicate item.
### paste
<strong>Type:</strong> `Boolean` <strong>Default:</strong>`true`
<strong>Input types affected:</strong> `text`, `select-multiple`.
<strong>Usage:</strong> Whether a user can paste into the input.

@@ -164,2 +218,4 @@

<strong>Input types affected:</strong> `select-one`, `select-multiple`.
<strong>Usage:</strong> Whether a user can filter options by searching (only affects select input types).

@@ -170,7 +226,11 @@

<strong>Usage:</strong> A filter that will need to pass for a user to successfully add an item (only affects text input types).
<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> A filter that will need to pass for a user to successfully add an item.
### placeholder
<strong>Type:</strong> `Boolean` <strong>Default:</strong>`true`
<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Whether the input should show a placeholder. Used in conjunction with `placeholderValue`. If `placeholder` is set to true and no value is passed to `placeholderValue`, the passed input's placeholder attribute will be used as the placeholder value.

@@ -181,2 +241,4 @@

<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> The value of the inputs placeholder.

@@ -187,2 +249,4 @@

<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Prepend a value to each item added to input (only affects text input types).

@@ -193,2 +257,4 @@

<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Append a value to each item added to input (only affects text input types).

@@ -199,2 +265,4 @@

<strong>Input types affected:</strong> `select-one`, `select-multiple`
<strong>Usage:</strong> The loading text that is shown when options are populated via an AJAX callback.

@@ -233,7 +301,28 @@

<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Classes added to HTML generated by Choices. By default classnames follow the [BEM](http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/) notation.
### sortFunction
<strong>Type:</strong> `Function` <strong>Default:</strong>
```js
(a, b) => {
const labelA = (a.label || a.value).toLowerCase();
const labelB = (b.label || b.value).toLowerCase();
if (labelA < labelB) return -1;
if (labelA > labelB) return 1;
return 0;
}
```
<strong>Input types affected:</strong> `select-one`, `select-multiple`
<strong>Usage:</strong> Function to sort options and groups. By default options and groups are sorted alphabetically.
### callbackOnInit
<strong>Type:</strong> `Function` <strong>Default:</strong>`() => {}`
<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Function to run once Choices initialises.

@@ -244,2 +333,4 @@

<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Function to run each time an item is added.

@@ -250,2 +341,4 @@

<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Function to run each time an item is removed.

@@ -275,2 +368,4 @@

### highlightAll();
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Highlight each chosen item (selected items can be removed).

@@ -280,2 +375,4 @@

### unhighlightAll();
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Un-highlight each chosen item.

@@ -285,2 +382,4 @@

### removeItemsByValue(value);
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Remove each item by a given value.

@@ -290,2 +389,4 @@

### removeActiveItems(excludedId);
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Remove each selectable item.

@@ -295,2 +396,4 @@

### removeHighlightedItems();
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Remove each item the user has selected.

@@ -300,2 +403,4 @@

### showDropdown();
<strong>Input types affected:</strong> `select-one`, `select-multiple`
<strong>Usage:</strong> Show option list dropdown (only affects select inputs).

@@ -305,2 +410,4 @@

### hideDropdown();
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Hide option list dropdown (only affects select inputs).

@@ -310,2 +417,4 @@

### toggleDropdown();
<strong>Input types affected:</strong> `text`, `select-multiple`
<strong>Usage:</strong> Toggle dropdown between showing/hidden.

@@ -315,6 +424,10 @@

### setValue(args);
<strong>Usage:</strong> Set value of input based on an array of objects or strings. This behaves exactly the same as passing items via the `items` option but can be called after initialising Choices on an text input (only affects text inputs).
<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> Set value of input based on an array of objects or strings. This behaves exactly the same as passing items via the `items` option but can be called after initialising Choices on an text input.
### clearValue();
<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> Clear value of input.

@@ -324,6 +437,10 @@

### clearInput();
<strong>Usage:</strong> Clear input of any user inputted text (only affects text inputs).
<strong>Input types affected:</strong> `text`
<strong>Usage:</strong> Clear input of any user inputted text.
### disable();
<strong>Input types affected:</strong> `text`, `select-one`, `select-multiple`
<strong>Usage:</strong> Disable input from selecting further options.

@@ -333,2 +450,4 @@

### ajax(fn);
<strong>Input types affected:</strong> `select-one`, `select-multiple`
<strong>Usage:</strong> Populate options via a callback.

@@ -335,0 +454,0 @@

@@ -20,3 +20,2 @@ var webpack = require('karma-webpack');

type: 'html',
subdir: 'report-html'
}]

@@ -23,0 +22,0 @@ },

@@ -0,82 +1,5 @@

import 'whatwg-fetch';
import 'es6-promise';
import Choices from '../../assets/scripts/src/choices.js';
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
if (!Array.from) {
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
};
var toInteger = function (value) {
var number = Number(value);
if (isNaN(number)) { return 0; }
if (number === 0 || !isFinite(number)) { return number; }
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function (value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
// The length property of the from method is 1.
return function from(arrayLike/*, mapFn, thisArg */) {
// 1. Let C be the this value.
var C = this;
// 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike);
// 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
// 4. If mapfn is undefined, then let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
if (typeof mapFn !== 'undefined') {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
}
// 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length);
// 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
// 16. Let k be 0.
var k = 0;
// 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k += 1;
}
// 18. Let putStatus be Put(A, "length", len, true).
A.length = len;
// 20. Return A.
return A;
};
}());
}
describe('Choices', function() {

@@ -108,2 +31,8 @@

it('should not re-initialise if passed element again', function() {
const reinitialise = new Choices(this.choices.passedElement);
spyOn(reinitialise, '_createTemplates');
expect(reinitialise._createTemplates).not.toHaveBeenCalled();
})
it('should have a blank state', function() {

@@ -118,3 +47,27 @@ const blankState = {

it('should expose public methods', function(){
it('should have config options', function() {
expect(this.choices.config.items).toEqual(jasmine.any(Array));
expect(this.choices.config.maxItemCount).toEqual(jasmine.any(Number));
expect(this.choices.config.addItems).toEqual(jasmine.any(Boolean));
expect(this.choices.config.removeItems).toEqual(jasmine.any(Boolean));
expect(this.choices.config.removeItemButton).toEqual(jasmine.any(Boolean));
expect(this.choices.config.editItems).toEqual(jasmine.any(Boolean));
expect(this.choices.config.duplicateItems).toEqual(jasmine.any(Boolean));
expect(this.choices.config.delimiter).toEqual(jasmine.any(String));
expect(this.choices.config.paste).toEqual(jasmine.any(Boolean));
expect(this.choices.config.search).toEqual(jasmine.any(Boolean));
expect(this.choices.config.regexFilter).toEqual(null);
expect(this.choices.config.placeholder).toEqual(jasmine.any(Boolean));
expect(this.choices.config.placeholderValue).toEqual(null);
expect(this.choices.config.prependValue).toEqual(null);
expect(this.choices.config.appendValue).toEqual(null);
expect(this.choices.config.loadingText).toEqual(jasmine.any(String));
expect(this.choices.config.classNames).toEqual(jasmine.any(Object));
expect(this.choices.config.callbackOnInit).toEqual(jasmine.any(Function));
expect(this.choices.config.callbackOnAddItem).toEqual(jasmine.any(Function));
expect(this.choices.config.callbackOnRemoveItem).toEqual(jasmine.any(Function));
expect(this.choices.config.callbackOnRender).toEqual(jasmine.any(Function));
});
it('should expose public methods', function() {
expect(this.choices.init).toEqual(jasmine.any(Function));

@@ -201,3 +154,3 @@ expect(this.choices.destroy).toEqual(jasmine.any(Function));

expect(this.choices.input.placeholder).toEqual(this.input.placeholder);
})
});
});

@@ -210,3 +163,13 @@

this.input.multiple = false;
this.input.placeholder = 'Placeholder text';
for (let i = 1; i < 4; i++) {
const option = document.createElement('option');
option.value = `Value ${i}`;
option.innerHTML = `Value ${i}`;
this.input.appendChild(option);
}
document.body.appendChild(this.input);

@@ -216,2 +179,64 @@

});
it('should open the choice list on focussing', function() {
this.choices.input.focus();
expect(this.choices.dropdown.classList).toContain('is-active');
});
it('should select the first choice', function() {
expect(this.choices.currentState.items[0].value).toContain('Value 1');
});
it('should highlight the choices on keydown', function() {
this.choices.input.focus();
for (var i = 0; i < 2; i++) {
// Key down to third choice
this.choices._onKeyDown({
target: this.choices.input,
keyCode: 40,
ctrlKey: false,
preventDefault: () => {}
});
}
expect(this.choices.highlightPosition).toBe(2);
});
it('should select choice on enter key press', function() {
this.choices.input.focus();
// Key down to second choice
this.choices._onKeyDown({
target: this.choices.input,
keyCode: 40,
ctrlKey: false,
preventDefault: () => {}
});
// Key down to select choice
this.choices._onKeyDown({
target: this.choices.input,
keyCode: 13,
ctrlKey: false
});
expect(this.choices.currentState.items.length).toBe(2);
});
it('should filter choices when searching', function() {
this.choices.input.focus();
this.choices.input.value = 'Value 3';
// Key down to search
this.choices._onKeyUp({
target: this.choices.input,
keyCode: 13,
ctrlKey: false
});
const mostAccurateResult = this.choices.currentState.choices[0];
expect(this.choices.isSearching && mostAccurateResult.value === 'Value 3').toBeTruthy;
});
});

@@ -225,3 +250,3 @@

for (var i = 1; i < 4; i++) {
for (let i = 1; i < 4; i++) {
const option = document.createElement('option');

@@ -241,3 +266,10 @@

this.choices = new Choices(this.input);
this.choices = new Choices(this.input, {
placeholderValue: 'Placeholder text',
choices: [
{value: 'One', label: 'Label One', selected: true, disabled: false},
{value: 'Two', label: 'Label Two', disabled: true},
{value: 'Three', label: 'Label Three'},
],
});;
});

@@ -249,6 +281,49 @@

it('should add any unselected options as choices', function() {
expect(this.choices.currentState.choices.length).toBeGreaterThan(1);
it('should add options defined in the config + pre-defined options', function() {
expect(this.choices.currentState.choices.length).toEqual(6);
});
it('should add a placeholder (set in config) to the search input', function() {
expect(this.choices.input.placeholder).toEqual('Placeholder text');
});
});
describe('should handle AJAX-populated choices', function() {
beforeEach(function() {
this.input = document.createElement('select');
this.input.className = 'js-choices';
this.input.multiple = false;
this.input.placeholder = 'Placeholder text';
for (let i = 1; i < 4; i++) {
const option = document.createElement('option');
option.value = `Value ${i}`;
option.innerHTML = `Value ${i}`;
this.input.appendChild(option);
}
document.body.appendChild(this.input);
this.choices = new Choices(this.input);
spyOn(this.choices, 'ajax');
this.choices.ajax((callback) => {
fetch('https://restcountries.eu/rest/v1/all')
.then((response) => {
response.json().then((data) => {
callback(data, 'alpha2Code', 'name');
});
})
.catch((error) => {
console.log(error);
});
});
});
it('should call ajax()', function() {
expect(this.choices.ajax).toHaveBeenCalledWith(jasmine.any(Function));
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc