Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aria-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aria-autocomplete - npm Package Compare versions

Comparing version 1.2.0-beta.4 to 1.2.0-beta.5

4

CHANGELOG.md

@@ -5,3 +5,3 @@ # Changelog

## [1.2.0] - 2020-10-01
## [1.2.0] - 2020-10-30

@@ -16,2 +16,4 @@ ### Added

- `onAsyncBeforeSend` callback option, to allow adjustments to the xhr object before it is sent (e.g. adding auth headers)
- `onAsyncComplete` callback option, that fires after async call successfully completes and all items have rendered
- for all async related callbacks, and when the `source` is a function, there is now an additional final param that indicates if it is the first/starting call.

@@ -18,0 +20,0 @@ ### Fixed

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

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(window,(function(){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=2)}([function(t,e,i){window,t.exports=function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";var s;function n(t,e){if(t)for(var i in e){var s="number"==typeof e[i]?e[i]+"px":e[i];t.style[i]=s+""}}i.r(e),i.d(e,"InputAutoWidth",(function(){return r}));var r=function(){function t(t,e){this.cache={},this.options=e,this.input=t,this.trigger(),this.eventHandler=this.trigger.bind(this),this.input.addEventListener("blur",this.eventHandler),this.input.addEventListener("input",this.eventHandler),this.input.addEventListener("keyup",this.eventHandler),this.input.addEventListener("keydown",this.eventHandler)}return t.prototype.measureString=function(t){return t?this.cache&&"number"==typeof this.cache[t]?this.cache[t]:(s||(n(s=document.createElement("span"),{position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}),document.body.appendChild(s)),s.textContent=t,function(t,e,i){if(t&&e){var s=getComputedStyle(t),r={};if(i&&i.length)for(var o=0,l=i.length;o<l;o+=1)r[i[o]]=s[i[o]];else r=s;n(e,r)}}(this.input,s,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),s.offsetWidth||s.clientWidth):0},t.prototype.trigger=function(t){if(void 0===t&&(t={}),!t.metaKey&&!t.altKey){var e,i,s=this.input.value;if(t.type&&"keydown"===t.type.toLowerCase()){var n=t.keyCode,r=46===n,o=8===n;if(r||o){var l=function(t){var e={};if("selectionStart"in t)e.start=t.selectionStart,e.length=t.selectionEnd-e.start;else if(document.selection){t.focus();var i=document.selection.createRange(),s=i.text.length;i.moveStart("character",-t.value.length),e.start=i.text.length-s,e.length=s}return e}(this.input);l.length?s=s.substring(0,l.start)+s.substring(l.start+l.length):o&&l.start?s=s.substring(0,l.start-1)+s.substring(l.start+1):r&&void 0!==l.start&&(s=s.substring(0,l.start)+s.substring(l.start+1))}else if((e=n)>=48&&e<=57||e>=65&&e<=90||e>=96&&e<=111||e>=186&&e<=222||32===e||8===e||46===e){var a=String.fromCharCode(n);s+=a=t.shiftKey?a.toUpperCase():a.toLowerCase()}}!s&&(i=this.input.getAttribute("placeholder"))&&(s=i);var h=this.measureString(s)+4;this.options&&this.options.cache&&this.cache&&(this.cache[s]=h);var u=this.options&&this.options.minWidth;"number"==typeof u&&h<u&&(h=u);var c=this.options&&this.options.maxWidth;"number"==typeof c&&h>c&&(h=c),h!==this.currentWidth&&(this.currentWidth=h,this.input.style.width=h+"px")}},t.prototype.destroy=function(){this.input.removeEventListener("blur",this.eventHandler),this.input.removeEventListener("input",this.eventHandler),this.input.removeEventListener("keyup",this.eventHandler),this.input.removeEventListener("keydown",this.eventHandler),this.input=this.cache=null},t}();e.default=r}])},function(t,e){var i=Element.prototype;i.matches||(i.matches=i.msMatchesSelector||i.webkitMatchesSelector),i.closest||(i.closest=function(t){var e=this;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null})},function(t,e,i){"use strict";i.r(e),i.d(e,"AriaAutocomplete",(function(){return M}));var s=i(0),n=i.n(s),r=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function o(t,e){if(t&&1===t.nodeType&&"string"==typeof e)!function(t,e){for(var i=t.getAttribute&&t.getAttribute("class")||"",s=" "+i+" ",n=0,o=e.split(" "),l=o.length;n<l;n+=1)s=s.replace(" "+o[n]+" "," ");var a;i!==(s=null==(a=s)?"":(a+"").replace(r,""))&&t.setAttribute("class",s)}(t,e);else if(t&&"number"==typeof t.length)for(var i=0,s=t.length;i<s;i+=1)o(t[i],e)}var l=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function a(t,e){if(t&&1===t.nodeType&&"string"==typeof e)!function(t,e){for(var i=t.getAttribute&&t.getAttribute("class")||"",s=" "+i+" ",n="",r=0,o=e.split(" "),a=o.length;r<a;r+=1)""!==o[r]&&-1===s.indexOf(" "+o[r]+" ")&&(n+=" "+o[r]);var h;i!==(n=null==(h=i+n)?"":(h+"").replace(l,""))&&t.setAttribute("class",n)}(t,e);else if(t&&"number"==typeof t.length)for(var i=0,s=t.length;i<s;i+=1)a(t[i],e)}var h=function(t){for(var e in void 0===t&&(t={}),this.sourceMapping={},this.alsoSearchIn=[],this.delay=100,this.minLength=1,this.maxResults=9999,this.showAllControl=!1,this.confirmOnBlur=!0,this.multiple=!1,this.autoGrow=!1,this.maxItems=9999,this.multipleSeparator=",",this.deleteOnBackspace=!1,this.asyncQueryParam="q",this.asyncMaxResultsParam="limit",this.noResultsText="No results",this.cssNameSpace="aria-autocomplete",this.srDeleteText="delete",this.srDeletedText="deleted",this.srShowAllText="Show all",this.srSelectedText="selected",this.srListLabelText="Search suggestions",this.srAssistiveText="When results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.",this.srResultsText=function(t){return t+" "+(1===t?"result":"results")+" available."},t)t.hasOwnProperty(e)&&void 0!==t[e]&&(this[e]=t[e])},u="_ariaAutocompleteCleanedLabel",c="_ariaAutocompleteSelectedOption",p=8,d=13,f=27,m=32,v=35,b=36,g=38,y=40,S=46,A=function(){function t(t){this.list=t.list,this.input=t.input,this.wrapper=t.wrapper,this.options=t.options,this.selected=t.selected,this.open=this.open.bind(t),this.close=this.close.bind(t),this.enable=this.enable.bind(t),this.disable=this.disable.bind(t),this.filter=this.filter.bind(t),this.destroy=this.destroy.bind(t),t.element.ariaAutocomplete=this}return t.prototype.open=function(){this.show.call(this)},t.prototype.close=function(){this.hide.call(this)},t.prototype.enable=function(){this.enable.call(this)},t.prototype.disable=function(){this.disable.call(this)},t.prototype.filter=function(t){this.filter.call(this,t)},t.prototype.destroy=function(){this.destroy.call(this)},t}(),w=0,E=function(t,e){w+=1,this.ELEMENT=t;var i=e||t||"";this.PREFIX=i+"aria-autocomplete-"+w,this.LIST=this.PREFIX+"-list",this.BUTTON=this.PREFIX+"-button",this.OPTION=this.PREFIX+"-option",this.WRAPPER=this.PREFIX+"-wrapper",this.INPUT=e||this.PREFIX+"-input",this.SR_ASSISTANCE=this.PREFIX+"-sr-assistance",this.OPTION_SELECTED=this.PREFIX+"-option-selected",this.SR_ANNOUNCEMENTS=this.PREFIX+"-sr-announcements"};i(1);function x(t){return null==t?"":(t+"").trim()}var T=/&/g,O=/\s\s+/g,_=/[\u2018\u2019',:\u2013-]/g,I=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function C(t,e){return void 0===e&&(e=!1),t=x(t).toLowerCase().replace(_,"").replace(T,"and").replace(O," "),e&&(t=t.replace(I,"\\$&")),t}function N(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i={};return t.forEach((function(t){for(var e in t)t.hasOwnProperty(e)&&void 0!==t[e]&&(i[e]=t[e])})),i}function L(t,e){if("createEvent"in document){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!0),t.dispatchEvent(i)}else t.fireEvent("on"+e)}function P(t){return t&&t.children?Array.prototype.slice.call(t.children):[]}function k(t,e,i){e=!!e,t&&("INPUT"===t.nodeName&&"checked"in t&&t.checked!==e&&(t.checked=e,L(t,"change")),"OPTION"===t.nodeName&&"selected"in t&&t.selected!==e&&(t.selected=e,clearTimeout(i.elementChangeEventTimer),i.elementChangeEventTimer=setTimeout((function(){L(t.closest("select"),"change")}),1)))}function F(t,e,i){void 0===e&&(e={}),void 0===i&&(i=!0);var s=[],n=e.value,r=e.label;return t.forEach((function(t){var e={};"string"==typeof t?e.value=e.label=t:((e=N(t)).value=(e[n]||e.value||e.label||"").toString(),e.label=(e[r]||e.label||e.value||"").toString()),!1!==i&&(e[u]=C(e.label)),s.push(e)})),s}function R(t,e,i){if("string"==typeof t)return function(t,e,i){return i!==u&&(t=C(t,!1)),-1!==t.search(e)}(t,e,i);if(Array.isArray(t))for(var s=0,n=t.length;s<n;s+=1)if(R(t[s],e))return!0;return!1}var D=function(){function t(t,e){t&&this.init(t,e)}return t.prototype.triggerOptionCallback=function(t,e,i){if(void 0===e&&(e=[]),void 0===i&&(i=this.api),"function"==typeof this.options[t])return this.options[t].apply(i,e)},t.prototype.show=function(t){if(t)return o(t,this.cssNameSpace+"--hide hide hidden"),t.removeAttribute("aria-hidden"),void t.removeAttribute("hidden");if(this.input.setAttribute("aria-expanded","true"),this.showAll){var e=(!!this.forceShowAll).toString();this.showAll.setAttribute("aria-expanded",e)}this.menuOpen||(this.show(this.list),this.menuOpen=!0,this.triggerOptionCallback("onOpen",[this.list]),this.documentClickBound||(this.documentClickBound=!0,document.addEventListener("click",this.documentClick)))},t.prototype.hide=function(t){if(t)return a(t,this.cssNameSpace+"--hide hide hidden"),t.setAttribute("aria-hidden","true"),void t.setAttribute("hidden","hidden");this.currentSelectedIndex=-1,this.input.setAttribute("aria-expanded","false"),this.showAll&&this.showAll.setAttribute("aria-expanded","false"),this.menuOpen&&(this.hide(this.list),this.menuOpen=!1,this.triggerOptionCallback("onClose",[this.list]))},t.prototype.enable=function(){if(this.disabled){this.disabled=!1,this.input.disabled=!1;var t=this.cssNameSpace;o(this.input,t+"__input--disabled disabled"),o(this.wrapper,t+"__wrapper--disabled disabled"),this.showAll&&(this.showAll.setAttribute("tabindex","0"),o(this.showAll,t+"__show-all--disabled disabled"))}this.enableDeletions()},t.prototype.disable=function(t){if(void 0===t&&(t=!1),!this.disabled){this.disabled=!0,this.input.disabled=!0;var e=this.cssNameSpace;a(this.input,e+"__input--disabled disabled"),a(this.wrapper,e+"__wrapper--disabled disabled"),this.showAll&&(this.showAll.setAttribute("tabindex","-1"),a(this.showAll,e+"__show-all--disabled disabled"))}t&&this.disableDeletions()},t.prototype.enableDeletions=function(){var t=this;this.deletionsDisabled&&(this.deletionsDisabled=!1,o(this.wrapper,this.cssNameSpace+"__wrapper--deletions-disabled"),this.getSelectedElems().forEach((function(e){o(e,t.cssNameSpace+"__selected--disabled"),e.setAttribute("tabindex","0")})))},t.prototype.disableDeletions=function(){var t=this;this.deletionsDisabled||(this.deletionsDisabled=!0,a(this.wrapper,this.cssNameSpace+"__wrapper--deletions-disabled"),this.getSelectedElems().forEach((function(e){a(e,t.cssNameSpace+"__selected--disabled"),e.setAttribute("tabindex","-1")})))},t.prototype.triggerAutoGrow=function(){this.autoGrow&&this.inputAutoWidth&&"function"==typeof this.inputAutoWidth.trigger&&this.inputAutoWidth.trigger()},t.prototype.setInputValue=function(t,e){void 0===e&&(e=!1),this.input.value=this.term=t,e&&(this.inputPollingValue=t),this.triggerAutoGrow()},t.prototype.indexOfValueIn=function(t,e,i){if(void 0===e&&(e=this.input.value),void 0===i&&(i="label"),t.length&&(e=x(e).toLowerCase()))for(var s=0,n=t.length;s<n;s+=1)if(x(t[s][i]).toLowerCase()===e)return s;return-1},t.prototype.announce=function(t,e){var i=this;void 0===e&&(e=400),this.srAnnouncements&&t&&"string"==typeof t&&(0!==e?(clearTimeout(this.announcementTimer),this.announcementTimer=setTimeout((function(){i.srAnnouncements.textContent=t}),e)):this.srAnnouncements.textContent=t)},t.prototype.isSelectedElem=function(t){var e=t&&t[c];return this.multiple&&e&&"object"==typeof e},t.prototype.getSelectedElems=function(){for(var t=[],e=0,i=this.wrapper.childNodes.length;e<i;e+=1){var s=this.wrapper.childNodes[e];1===s.nodeType&&this.isSelectedElem(s)&&t.push(s)}return t},t.prototype.removeEntryFromSelected=function(t){if(!this.deletionsDisabled){var e=this.selected.indexOf(t);if(-1===e)for(var i=0,s=this.selected.length;i<s;i+=1)if(this.selected[i].value===t.value){e=i;break}if(e>-1&&this.selected[e]){var n=N(this.selected[e]),r=n.label;k(n.element,!1,this),this.selected.splice(e,1),this.triggerOptionCallback("onDelete",[n]),this.setSourceElementValues(),this.buildMultiSelected(),this.triggerAutoGrow(),this.announce(r+" "+this.options.srDeletedText,0)}}},t.prototype.createSelectedElemFrom=function(t){var e=t.label,i=document.createElement("span");return i.setAttribute("aria-label",this.options.srDeleteText+" "+e),i.setAttribute("class",this.cssNameSpace+"__selected"),i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i[c]=t,i.textContent=e,i},t.prototype.buildMultiSelected=function(){var t=this;if(this.multiple){this.multiple&&this.selected.length>=this.options.maxItems?this.disable():this.enable();var e=this.getSelectedElems();if(this.selected.length||e.length){var i=[];e.forEach((function(e){for(var s=e[c],n=0,r=t.selected.length;n<r;n+=1){var o=t.selected[n];if(o===s||o.value===s.value)return void i.push(e)}t.wrapper.removeChild(e)}));var s=document.createDocumentFragment();this.selected.forEach((function(e){for(var n=0,r=i.length;n<r;n+=1){var o=i[n][c];if(o===e||o.value===e.value)return}s.appendChild(t.createSelectedElemFrom(e))})),s.childNodes&&s.childNodes.length&&this.wrapper.insertBefore(s,this.list);var n=this.getSelectedElems().map((function(e,i){var s=t.ids.OPTION_SELECTED+"-"+i;return e.setAttribute("id",s),s}));n.push(this.ids.LIST),this.input.setAttribute("aria-owns",n.join(" ")),this.autoGrow&&this.selected.length?this.input.removeAttribute("placeholder"):this.options.placeholder&&this.input.setAttribute("placeholder",this.options.placeholder)}}},t.prototype.setInputDescription=function(){var t=this.input.getAttribute("aria-describedby"),e=x(t),i=e.replace(this.ids.SR_ASSISTANCE,"");this.input.value.length||(i=i+" "+this.ids.SR_ASSISTANCE),(i=x(i))?i!==e&&this.input.setAttribute("aria-describedby",i):t&&this.input.removeAttribute("aria-describedby")},t.prototype.resetOptionAttributes=function(t){void 0===t&&(t=P(this.list));var e=this.cssNameSpace+"__option--focused focused focus";t.forEach((function(t){t.setAttribute("aria-selected","false"),o(t,e)}))},t.prototype.setOptionFocus=function(t,e){var i=P(this.list);if(this.resetOptionAttributes(i),e<0||!i.length)return this.currentSelectedIndex=-1,void(t&&t.target!==this.input&&this.input.focus());if(e>=i.length)return this.currentSelectedIndex=i.length-1,void this.setOptionFocus(t,this.currentSelectedIndex);var s=i[e];if(s&&"string"==typeof s.getAttribute("tabindex"))return this.currentSelectedIndex=e,a(s,this.cssNameSpace+"__option--focused focused focus"),s.setAttribute("aria-selected","true"),void s.focus();this.currentSelectedIndex=-1},t.prototype.setSourceElementValues=function(){for(var t=[],e=0,i=this.selected.length;e<i;e+=1){var s=this.selected[e];t.push(s.value),k(s.element,!0,this)}if(this.elementIsInput){var n=t.join(this.options.multipleSeparator);n!==this.element.value&&(this.element.value=n,L(this.element,"change"))}!this.selected.length&&this.elementIsSelect&&(this.element.value=""),this.triggerOptionCallback("onChange",[this.selected])},t.prototype.handleOptionSelect=function(t,e,i){if(void 0===i&&(i=!0),!("number"!=typeof e||e<0||this.multiple&&this.selected.length>=this.options.maxItems)&&this.filteredSource.length&&this.filteredSource[e]){for(var s=N(this.filteredSource[e]),n=!1,r=0,o=this.selected.length;r<o;r+=1)if(this.selected[r].value===s.value){n=!0;break}n||this.multiple||this.selected.splice(0),n||(this.selected.push(s),this.setSourceElementValues(),this.buildMultiSelected()),this.setInputValue(this.multiple?"":s.label,!0),this.triggerOptionCallback("onConfirm",[s]),this.announce(s.label+" "+this.options.srSelectedText,0),this.disabled||!1===i||this.input.focus(),this.hide()}},t.prototype.removeSelectedFromResults=function(t){var e=this;if(!this.multiple||!this.selected.length)return t;var i=[];return t.forEach((function(t){for(var s=e.selected,n=0,r=s.length;n<r;n+=1)if(t.label===s[n].label&&t.value===s[n].value)return;i.push(t)})),i},t.prototype.setListOptions=function(t){var e=[],i=this.options.sourceMapping,s=this.removeSelectedFromResults(t),n=this.triggerOptionCallback("onResponse",s);this.filteredSource=n?F(n,i):s;for(var r,l=this.ids.OPTION,h=this.cssNameSpace,u=h+"__option",c=this.filteredSource.length,p="function"==typeof this.options.onItemRender,d=this.forceShowAll?9999:this.options.maxResults,f=d<c?d:c,m=0;m<f;m+=1){var v=this.filteredSource[m],b=p&&this.triggerOptionCallback("onItemRender",[v])||v.label;e.push('<li tabindex="-1" aria-selected="false" role="option" class="'+u+'" id="'+l+"--"+m+'" aria-posinset="'+(m+1)+'" aria-setsize="'+f+'">'+b+"</li>")}e.length?(a(this.list,h+"__list--has-results"),o(this.list,h+"__list--no-results")):(o(this.list,h+"__list--has-results"),a(this.list,h+"__list--no-results"));var g=this.options.noResultsText;!e.length&&"string"==typeof g&&g.length&&(r=g,e.push('<li class="'+u+" "+u+'--no-results">'+g+"</li>")),this.cancelFilterPrep(),r||(r=this.triggerOptionCallback("srResultsText",[f])),this.announce(r);var y=e.join("");if(this.currentListHtml!==y?(this.currentListHtml=y,this.list.innerHTML=y):this.resetOptionAttributes(),!e.length)return this.hide(),void(this.forceShowAll=!1);this.show(),this.forceShowAll=!1},t.prototype.handleAsync=function(t,e){var i=this;void 0===e&&(e=!1),this.xhr&&"function"==typeof this.xhr.abort&&this.xhr.abort();var s=new XMLHttpRequest,n=this.forceShowAll,r=e?null:this.api,o=this.multiple?this.selected.length:0,l=n||e||9999===this.options.maxResults,a=this.source+(/\?/.test(this.source)?"&":"?")+encodeURIComponent(this.options.asyncQueryParam)+"="+encodeURIComponent(t)+"&"+encodeURIComponent(this.options.asyncMaxResultsParam)+"="+(l?9999:o+this.options.maxResults);a=this.triggerOptionCallback("onAsyncPrep",[a],r)||a,s.open("GET",a),s.onload=function(){if(s.readyState===s.DONE&&s.status>=200&&s.status<300){i.forceShowAll=n;var o=F(i.triggerOptionCallback("onAsyncSuccess",[t,s],r)||s.responseText,i.options.sourceMapping,!1);e?(i.prepSelectedFromArray(o),i.setInputStartingStates(!1)):i.setListOptions(o)}},s.onerror=function(){i.triggerOptionCallback("onAsyncError",[t,s],r)},e||(this.xhr=s),this.triggerOptionCallback("onAsyncBeforeSend",[s],r),s.send()},t.prototype.filter=function(t){var e=this;if("string"==typeof t){var i=this.forceShowAll;if(!i){var s=this.triggerOptionCallback("onSearch",[t]);"string"==typeof s&&(t=s)}if(this.term=t,"string"==typeof this.source&&this.source.length)return this.handleAsync(t),void(this.forceShowAll=!1);if("function"!=typeof this.source){t||(i=!0);var n=[];if(this.source&&this.source.length){var r=[u];if(!i){t=C(t,!0);var o=this.options.alsoSearchIn;Array.isArray(o)&&o.length&&(r=function(t){var e=[];return t.forEach((function(t){if("string"==typeof t){for(var i=x(t),s="label"!==i,n=0,r=e.length;s&&n<r;n+=1)s=e[r]!==i;s&&e.push(i)}})),e}(r.concat(o)))}this.source.forEach((function(e){(i||function(t,e,i){for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];if(("string"==typeof n||Array.isArray(n))&&i.indexOf(s)>-1&&R(n,e,s))return!0}return!1}(e,t,r))&&n.push(e)}))}this.setListOptions(n)}else{var l=function(t){var i=F(t,e.options.sourceMapping);e.setListOptions(i)},a=this.source.call(this.api,this.term,l);a&&"function"==typeof a.then&&a.then((function(t){return l(t)}))}}else this.cancelFilterPrep()},t.prototype.cancelFilterPrep=function(){clearTimeout(this.filterTimer),o(this.wrapper,this.cssNameSpace+"__wrapper--loading loading"),o(this.input,this.cssNameSpace+"__input--loading loading"),this.filtering=!1},t.prototype.filterPrep=function(t,e,i){var s=this;void 0===e&&(e=!1),void 0===i&&(i=!1);var n=this.forceShowAll,r=n||i?0:this.options.delay;this.cancelFilterPrep(),this.filtering=!0,this.filterTimer=setTimeout((function(){var i=s.input.value;if(s.inputPollingValue=i,(n||""===i||e&&!s.multiple&&s.selected.length&&x(s.selected[0].label)===x(i))&&(i=""),s.setInputDescription(),!n&&i.length<s.options.minLength)s.hide();else{var r;try{var o=t;r=t&&"keydown"===t.type&&(o.altKey||o.ctrlKey||o.metaKey)}catch(t){}var l=""!==i&&i===s.term;!l||l&&!s.menuOpen&&!r?(a(s.wrapper,s.cssNameSpace+"__wrapper--loading loading"),a(s.input,s.cssNameSpace+"__input--loading loading"),s.currentSelectedIndex=-1,s.filter(i)):s.cancelFilterPrep()}}),r)},t.prototype.filterPrepShowAll=function(t){var e=this;this.disabled||(clearTimeout(this.showAllPrepTimer),this.showAllPrepTimer=setTimeout((function(){e.componentBlurTimer&&clearTimeout(e.componentBlurTimer),t.preventDefault(),e.forceShowAll=!0,e.filterPrep(t,!1,!0)}),0))},t.prototype.handleComponentBlur=function(t,e){var i=this;void 0===e&&(e=!1),clearTimeout(this.componentBlurTimer);var s=e?0:100;this.componentBlurTimer=setTimeout((function(){var t=document.activeElement;if(e||!t||i.showAll&&i.showAll===t||i.isSelectedElem(t)||!i.wrapper.contains(t)){if(i.xhr&&"function"==typeof i.xhr.abort&&i.xhr.abort(),!e&&i.options.confirmOnBlur&&i.menuOpen){var s=i.currentSelectedIndex;"number"==typeof s&&-1!==s||(s=i.indexOfValueIn.call(i,i.filteredSource)),i.handleOptionSelect({},s,!1)}if(i.cancelFilterPrep(),i.hide(),!i.multiple&&-1===i.indexOfValueIn.call(i,i.selected)){i.selected.length&&i.removeEntryFromSelected(i.selected[0]);var n=i.elementIsInput||i.elementIsSelect,r=i.element;n&&""!==r.value&&(r.value="",L(r,"change")),i.setInputValue("",!0)}i.multiple&&i.setInputValue("",!0),i.documentClickBound&&(i.documentClickBound=!1,document.removeEventListener("click",i.documentClick)),i.triggerOptionCallback("onBlur",[i.wrapper]),i.isFocused=!1}}),s)},t.prototype.handleUpKey=function(t){t.preventDefault(),!this.disabled&&this.menuOpen&&"number"==typeof this.currentSelectedIndex&&this.setOptionFocus(t,this.currentSelectedIndex-1)},t.prototype.handleDownKey=function(t){if(t.preventDefault(),this.menuOpen||(this.forceShowAll=this.options.minLength<1,(this.forceShowAll||this.input.value.length>=this.options.minLength)&&this.filterPrep(t)),this.menuOpen&&!this.filtering){var e=this.currentSelectedIndex;"number"!=typeof e||e<0?this.setOptionFocus(t,0):this.setOptionFocus(t,e+1)}},t.prototype.handleEndKey=function(t){if(!this.disabled&&this.menuOpen&&t.target!==this.input){var e=P(this.list);e.length&&(t.preventDefault(),this.setOptionFocus(t,e.length-1))}},t.prototype.handleHomeKey=function(t){!this.disabled&&this.menuOpen&&t.target!==this.input&&(t.preventDefault(),this.setOptionFocus(t,0))},t.prototype.handleEnterKey=function(t){var e=t.target;this.isSelectedElem(e)?this.removeEntryFromSelected(e[c]):this.disabled||(this.showAll&&e===this.showAll?this.filterPrepShowAll(t):(this.menuOpen&&(t.preventDefault(),this.currentSelectedIndex>-1&&this.handleOptionSelect(t,this.currentSelectedIndex)),e===this.input&&this.filterPrep(t,!1,!0)))},t.prototype.handleKeyDownDefault=function(t){var e=t.keyCode,i=t.target===this.input;if(e===m&&!i||this.isSelectedElem(t.target)&&e===S)return t.preventDefault(),void this.handleEnterKey(t);if(!this.disabled){var s=this.selected&&this.selected.length;if(this.options.deleteOnBackspace&&e===p&&""===this.input.value&&s&&i&&this.multiple)this.removeEntryFromSelected(this.selected[s-1]);else{var n=function(t){return t>=48&&t<=57||t>=65&&t<=90||t>=96&&t<=111||t>=186&&t<=222||32===t||8===t||46===t}(e),r=!i&&n;r&&this.input.focus(),(r||i&&n)&&this.filterPrep(t)}}},t.prototype.prepKeyDown=function(t){switch(t.keyCode){case g:this.handleUpKey(t);break;case y:this.handleDownKey(t);break;case v:this.handleEndKey(t);break;case b:this.handleHomeKey(t);break;case d:this.handleEnterKey(t);break;case f:this.handleComponentBlur(t,!0);break;default:this.handleKeyDownDefault(t)}},t.prototype.cancelPolling=function(){clearTimeout(this.pollingTimer)},t.prototype.startPolling=function(){var t=this;this.filtering||this.input.value===this.inputPollingValue||this.filterPrep({}),this.pollingTimer=setTimeout((function(){t.startPolling()}),200)},t.prototype.bindEvents=function(){var t=this;this.wrapper.addEventListener("focusout",(function(e){t.handleComponentBlur(e,!1)})),this.wrapper.addEventListener("focusin",(function(e){t.list.contains(e.target)||(t.currentSelectedIndex=-1),t.isFocused||t.triggerOptionCallback("onFocus",[t.wrapper]),t.isFocused=!0})),this.wrapper.addEventListener("keydown",(function(e){t.prepKeyDown(e)})),this.wrapper.addEventListener("click",(function(e){e.target!==t.wrapper?t.isSelectedElem(e.target)&&t.removeEntryFromSelected(e.target[c]):t.input.focus()}));var e=this.cssNameSpace+"__wrapper--focused focused focus",i=this.cssNameSpace+"__input--focused focused focus";this.input.addEventListener("blur",(function(){o(t.wrapper,e),o(t.input,i),t.cancelPolling()})),this.input.addEventListener("input",(function(e){document.activeElement===t.input&&t.filterPrep(e)})),this.input.addEventListener("click",(function(e){!t.menuOpen&&t.input.value.length>=t.options.minLength&&t.filterPrep(e,!0)})),this.input.addEventListener("focusin",(function(s){a(t.wrapper,e),a(t.input,i),t.startPolling(),t.disabled||t.menuOpen||t.filterPrep(s,!0)})),this.showAll&&this.showAll.addEventListener("click",(function(e){t.filterPrepShowAll(e)})),this.list.addEventListener("mouseenter",(function(e){t.resetOptionAttributes()})),this.list.addEventListener("click",(function(e){if(e.target!==t.list){var i=P(t.list);if(i.length){var s=i.indexOf(e.target);t.handleOptionSelect(e,s)}}})),this.autoGrow&&(this.inputAutoWidth=new n.a(this.input))},t.prototype.prepListSourceCheckboxes=function(){this.multiple=!0,this.source=[];for(var t=this.element.querySelectorAll('input[type="checkbox"]'),e=0,i=t.length;e<i;e+=1){var s=t[e];if(s.value){var n={element:s,value:s.value},r=s.closest("label");!r&&s.id&&(r=document.querySelector('[for="'+s.id+'"]')),r&&(n.label=r.textContent),n.label||(n.label=n.value),n[u]=C(n.label),this.source.push(n),s.checked&&this.selected.push(n)}}},t.prototype.prepListSourceDdl=function(){var t=this.element.multiple;t&&!this.multiple&&(this.multiple=!0),!t&&this.multiple&&this.options.maxItems>1&&(this.options.maxItems=1),this.source=[];for(var e=this.element.querySelectorAll("option"),i=0,s=e.length;i<s;i+=1){var n=e[i];if(n.value){var r={element:n,value:n.value,label:n.textContent};r[u]=C(r.label),this.source.push(r),n.selected&&this.selected.push(r)}}},t.prototype.prepSelectedFromArray=function(t){var e=this,i=this.elementIsInput&&this.element.value;if(i&&t&&t.length){var s=this.options.multiple,n=this.options.multipleSeparator;(s?i.split(n):[i]).forEach((function(i){if(-1===e.indexOfValueIn(e.selected,i,"value")){var s=e.indexOfValueIn(t,i,"value");s>-1&&e.selected.push(t[s])}}))}},t.prototype.prepListSourceArray=function(){this.source=F(this.source,this.options.sourceMapping),this.prepSelectedFromArray(this.source)},t.prototype.prepListSourceAsync=function(){var t=this.element;this.elementIsInput&&t.value&&this.handleAsync(t.value,!0)},t.prototype.prepListSourceFunction=function(){var t=this,e=this.element;if(this.elementIsInput&&e.value){var i=function(e){var i=F(e,t.options.sourceMapping);t.prepSelectedFromArray(i),t.setInputStartingStates(!1)},s=this.source.call(void 0,e.value,i);s&&"function"==typeof s.then&&s.then((function(t){return i(t)}))}},t.prototype.prepListSource=function(){return"function"==typeof this.source?this.prepListSourceFunction():"string"==typeof this.source&&this.source.length?this.prepListSourceAsync():Array.isArray(this.source)&&this.source.length?this.prepListSourceArray():this.elementIsSelect?this.prepListSourceDdl():void(this.element.querySelector('input[type="checkbox"]')&&this.prepListSourceCheckboxes())},t.prototype.setInputStartingStates=function(t){if(void 0===t&&(t=!0),t){if(this.ids.ELEMENT){var e=document.querySelector('[for="'+this.ids.ELEMENT+'"]');e&&(e._ariaAutocompleteLabelOriginallyFor=this.ids.ELEMENT,e.setAttribute("for",this.ids.INPUT))}var i=this.element.getAttribute("aria-describedby");i&&this.input.setAttribute("aria-describedby",i);var s=this.element.getAttribute("aria-labelledby");s&&this.input.setAttribute("aria-labelledby",s)}this.selected.length&&(this.multiple?(this.buildMultiSelected(),this.triggerAutoGrow()):this.setInputValue(this.selected[0].label||"",!0)),this.setInputDescription(),this.element.disabled&&this.disable(!0)},t.prototype.setHtml=function(){var t=this.options,e=this.cssNameSpace,i=t.wrapperClassName?" "+t.wrapperClassName:"",s=['<div id="'+this.ids.WRAPPER+'" class="'+e+"__wrapper"+i+'">'],n=t.name?' name="'+t.name+'"':"",r=t.inputClassName?" "+t.inputClassName:"",o=t.placeholder?' placeholder="'+t.placeholder+'" aria-placeholder="'+t.placeholder+'"':"";s.push('<input type="text" autocomplete="off" aria-expanded="false" aria-autocomplete="list" role="combobox" id="'+this.ids.INPUT+'" aria-owns="'+this.ids.LIST+'" class="'+e+"__input"+r+'"'+n+o+" />"),t.showAllControl&&s.push('<span role="button" aria-label="'+t.srShowAllText+'" class="'+e+'__show-all" tabindex="0" id="'+this.ids.BUTTON+'" aria-expanded="false"></span>');var l=t.srListLabelText,a=t.listClassName?" "+t.listClassName:"",h=l?' aria-label="'+l+'"':"";s.push('<ul id="'+this.ids.LIST+'" class="'+e+"__list"+a+'" role="listbox" aria-hidden="true" hidden="hidden"'+h+"></ul>"),s.push('<span class="sr-only '+e+"__sr-only "+e+'__sr-assistance" id="'+this.ids.SR_ASSISTANCE+'">'+t.srAssistiveText+"</span>"),s.push('<span class="sr-only '+e+"__sr-only "+e+'__sr-announcements" id="'+this.ids.SR_ANNOUNCEMENTS+'" aria-live="polite" aria-atomic="true"></span>'),s.push("</div>"),this.element.insertAdjacentHTML("afterend",s.join(""))},t.prototype.destroy=function(){var t=this,e=document.querySelector('[for="'+this.ids.INPUT+'"]');e&&e._ariaAutocompleteLabelOriginallyFor&&(e.setAttribute("for",e._ariaAutocompleteLabelOriginallyFor),delete e._ariaAutocompleteLabelOriginallyFor),this.documentClickBound&&document.removeEventListener("click",this.documentClick),this.autoGrow&&this.inputAutoWidth&&this.inputAutoWidth.destroy(),this.element.parentNode.removeChild(this.wrapper),delete this.element.ariaAutocomplete,this.show(this.element),clearTimeout(this.filterTimer),clearTimeout(this.pollingTimer),clearTimeout(this.showAllPrepTimer),clearTimeout(this.announcementTimer),clearTimeout(this.componentBlurTimer),clearTimeout(this.elementChangeEventTimer),["element","list","input","wrapper","showAll","srAnnouncements"].forEach((function(e){return t[e]=null}))},t.prototype.init=function(t,e){this.selected=[],this.element=t,this.ids=new E(t.id,e.id),this.elementIsInput="INPUT"===t.nodeName,this.elementIsSelect="SELECT"===t.nodeName,this.options=new h(e),this.source=this.options.source,this.multiple=this.options.multiple,this.autoGrow=this.options.autoGrow,this.cssNameSpace=this.options.cssNameSpace,this.documentClick=this.handleComponentBlur.bind(this),this.setHtml(),this.list=document.getElementById(this.ids.LIST),this.input=document.getElementById(this.ids.INPUT),this.wrapper=document.getElementById(this.ids.WRAPPER),this.showAll=document.getElementById(this.ids.BUTTON),this.srAnnouncements=document.getElementById(this.ids.SR_ANNOUNCEMENTS),this.prepListSource();var i=[];this.options.showAllControl&&i.push(this.cssNameSpace+"__wrapper--show-all"),this.autoGrow&&i.push(this.cssNameSpace+"__wrapper--autogrow"),this.multiple&&i.push(this.cssNameSpace+"__wrapper--multiple"),i.length&&a(this.wrapper,i.join(" ")),this.hide(this.list),this.hide(this.element),this.setInputStartingStates(),this.bindEvents(),this.api=new A(this),this.triggerOptionCallback("onReady",[this.wrapper])},t}();function M(t,e){return t&&t.ariaAutocomplete&&t.ariaAutocomplete.open?t.ariaAutocomplete:new D(t,e).api}e.default=M}])}));
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(window,(function(){return function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=2)}([function(t,e,i){window,t.exports=function(t){var e={};function i(s){if(e[s])return e[s].exports;var n=e[s]={i:s,l:!1,exports:{}};return t[s].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(s,n,function(e){return t[e]}.bind(null,n));return s},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";var s;function n(t,e){if(t)for(var i in e){var s="number"==typeof e[i]?e[i]+"px":e[i];t.style[i]=s+""}}i.r(e),i.d(e,"InputAutoWidth",(function(){return r}));var r=function(){function t(t,e){this.cache={},this.options=e,this.input=t,this.trigger(),this.eventHandler=this.trigger.bind(this),this.input.addEventListener("blur",this.eventHandler),this.input.addEventListener("input",this.eventHandler),this.input.addEventListener("keyup",this.eventHandler),this.input.addEventListener("keydown",this.eventHandler)}return t.prototype.measureString=function(t){return t?this.cache&&"number"==typeof this.cache[t]?this.cache[t]:(s||(n(s=document.createElement("span"),{position:"absolute",top:-99999,left:-99999,width:"auto",padding:0,whiteSpace:"pre"}),document.body.appendChild(s)),s.textContent=t,function(t,e,i){if(t&&e){var s=getComputedStyle(t),r={};if(i&&i.length)for(var o=0,l=i.length;o<l;o+=1)r[i[o]]=s[i[o]];else r=s;n(e,r)}}(this.input,s,["letterSpacing","fontSize","fontFamily","fontWeight","textTransform"]),s.offsetWidth||s.clientWidth):0},t.prototype.trigger=function(t){if(void 0===t&&(t={}),!t.metaKey&&!t.altKey){var e,i,s=this.input.value;if(t.type&&"keydown"===t.type.toLowerCase()){var n=t.keyCode,r=46===n,o=8===n;if(r||o){var l=function(t){var e={};if("selectionStart"in t)e.start=t.selectionStart,e.length=t.selectionEnd-e.start;else if(document.selection){t.focus();var i=document.selection.createRange(),s=i.text.length;i.moveStart("character",-t.value.length),e.start=i.text.length-s,e.length=s}return e}(this.input);l.length?s=s.substring(0,l.start)+s.substring(l.start+l.length):o&&l.start?s=s.substring(0,l.start-1)+s.substring(l.start+1):r&&void 0!==l.start&&(s=s.substring(0,l.start)+s.substring(l.start+1))}else if((e=n)>=48&&e<=57||e>=65&&e<=90||e>=96&&e<=111||e>=186&&e<=222||32===e||8===e||46===e){var a=String.fromCharCode(n);s+=a=t.shiftKey?a.toUpperCase():a.toLowerCase()}}!s&&(i=this.input.getAttribute("placeholder"))&&(s=i);var h=this.measureString(s)+4;this.options&&this.options.cache&&this.cache&&(this.cache[s]=h);var u=this.options&&this.options.minWidth;"number"==typeof u&&h<u&&(h=u);var c=this.options&&this.options.maxWidth;"number"==typeof c&&h>c&&(h=c),h!==this.currentWidth&&(this.currentWidth=h,this.input.style.width=h+"px")}},t.prototype.destroy=function(){this.input.removeEventListener("blur",this.eventHandler),this.input.removeEventListener("input",this.eventHandler),this.input.removeEventListener("keyup",this.eventHandler),this.input.removeEventListener("keydown",this.eventHandler),this.input=this.cache=null},t}();e.default=r}])},function(t,e){var i=Element.prototype;i.matches||(i.matches=i.msMatchesSelector||i.webkitMatchesSelector),i.closest||(i.closest=function(t){var e=this;do{if(e.matches(t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null})},function(t,e,i){"use strict";i.r(e),i.d(e,"AriaAutocomplete",(function(){return M}));var s=i(0),n=i.n(s),r=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function o(t,e){if(t&&1===t.nodeType&&"string"==typeof e)!function(t,e){for(var i=t.getAttribute&&t.getAttribute("class")||"",s=" "+i+" ",n=0,o=e.split(" "),l=o.length;n<l;n+=1)s=s.replace(" "+o[n]+" "," ");var a;i!==(s=null==(a=s)?"":(a+"").replace(r,""))&&t.setAttribute("class",s)}(t,e);else if(t&&"number"==typeof t.length)for(var i=0,s=t.length;i<s;i+=1)o(t[i],e)}var l=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function a(t,e){if(t&&1===t.nodeType&&"string"==typeof e)!function(t,e){for(var i=t.getAttribute&&t.getAttribute("class")||"",s=" "+i+" ",n="",r=0,o=e.split(" "),a=o.length;r<a;r+=1)""!==o[r]&&-1===s.indexOf(" "+o[r]+" ")&&(n+=" "+o[r]);var h;i!==(n=null==(h=i+n)?"":(h+"").replace(l,""))&&t.setAttribute("class",n)}(t,e);else if(t&&"number"==typeof t.length)for(var i=0,s=t.length;i<s;i+=1)a(t[i],e)}var h=function(t){for(var e in void 0===t&&(t={}),this.sourceMapping={},this.alsoSearchIn=[],this.delay=100,this.minLength=1,this.maxResults=9999,this.showAllControl=!1,this.confirmOnBlur=!0,this.multiple=!1,this.autoGrow=!1,this.maxItems=9999,this.multipleSeparator=",",this.deleteOnBackspace=!1,this.asyncQueryParam="q",this.asyncMaxResultsParam="limit",this.noResultsText="No results",this.cssNameSpace="aria-autocomplete",this.srDeleteText="delete",this.srDeletedText="deleted",this.srShowAllText="Show all",this.srSelectedText="selected",this.srListLabelText="Search suggestions",this.srAssistiveText="When results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.",this.srResultsText=function(t){return t+" "+(1===t?"result":"results")+" available."},t)t.hasOwnProperty(e)&&void 0!==t[e]&&(this[e]=t[e])},u="_ariaAutocompleteCleanedLabel",c="_ariaAutocompleteSelectedOption",p=8,d=13,f=27,m=32,v=35,b=36,g=38,y=40,S=46,A=function(){function t(t){this.list=t.list,this.input=t.input,this.wrapper=t.wrapper,this.options=t.options,this.selected=t.selected,this.open=this.open.bind(t),this.close=this.close.bind(t),this.enable=this.enable.bind(t),this.disable=this.disable.bind(t),this.filter=this.filter.bind(t),this.destroy=this.destroy.bind(t),t.element.ariaAutocomplete=this}return t.prototype.open=function(){this.show.call(this)},t.prototype.close=function(){this.hide.call(this)},t.prototype.enable=function(){this.enable.call(this)},t.prototype.disable=function(t){this.disable.call(this,t)},t.prototype.filter=function(t){this.filter.call(this,t)},t.prototype.destroy=function(){this.destroy.call(this)},t}(),w=0,E=function(t,e){w+=1,this.ELEMENT=t;var i=e||t||"";this.PREFIX=i+"aria-autocomplete-"+w,this.LIST=this.PREFIX+"-list",this.BUTTON=this.PREFIX+"-button",this.OPTION=this.PREFIX+"-option",this.WRAPPER=this.PREFIX+"-wrapper",this.INPUT=e||this.PREFIX+"-input",this.SR_ASSISTANCE=this.PREFIX+"-sr-assistance",this.OPTION_SELECTED=this.PREFIX+"-option-selected",this.SR_ANNOUNCEMENTS=this.PREFIX+"-sr-announcements"};i(1);function x(t){return null==t?"":(t+"").trim()}var T=/&/g,O=/\s\s+/g,_=/[\u2018\u2019',:\u2013-]/g,I=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function C(t,e){return void 0===e&&(e=!1),t=x(t).toLowerCase().replace(_,"").replace(T,"and").replace(O," "),e&&(t=t.replace(I,"\\$&")),t}function N(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i={};return t.forEach((function(t){for(var e in t)t.hasOwnProperty(e)&&void 0!==t[e]&&(i[e]=t[e])})),i}function L(t,e){if("createEvent"in document){var i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!0),t.dispatchEvent(i)}else t.fireEvent("on"+e)}function P(t){return t&&t.children?Array.prototype.slice.call(t.children):[]}function k(t,e,i){e=!!e,t&&("INPUT"===t.nodeName&&"checked"in t&&t.checked!==e&&(t.checked=e,L(t,"change")),"OPTION"===t.nodeName&&"selected"in t&&t.selected!==e&&(t.selected=e,clearTimeout(i.elementChangeEventTimer),i.elementChangeEventTimer=setTimeout((function(){L(t.closest("select"),"change")}),1)))}function F(t,e,i){if(void 0===e&&(e={}),void 0===i&&(i=!0),!Array.isArray(t))return t?[t]:[];var s=[],n=e.value,r=e.label;return t.forEach((function(t){var e={};"string"==typeof t?e.value=e.label=t:((e=N(t)).value=(e[n]||e.value||e.label||"").toString(),e.label=(e[r]||e.label||e.value||"").toString()),!1!==i&&(e[u]=C(e.label)),s.push(e)})),s}function R(t,e,i){if("string"==typeof t)return function(t,e,i){return i!==u&&(t=C(t,!1)),-1!==t.search(e)}(t,e,i);if(Array.isArray(t))for(var s=0,n=t.length;s<n;s+=1)if(R(t[s],e))return!0;return!1}var D=function(){function t(t,e){t&&this.init(t,e)}return t.prototype.triggerOptionCallback=function(t,e,i){if(void 0===e&&(e=[]),void 0===i&&(i=this.api),"function"==typeof this.options[t])return this.options[t].apply(i,e)},t.prototype.show=function(t){if(t)return o(t,this.cssNameSpace+"--hide hide hidden"),t.removeAttribute("aria-hidden"),void t.removeAttribute("hidden");if(this.input.setAttribute("aria-expanded","true"),this.showAll){var e=(!!this.forceShowAll).toString();this.showAll.setAttribute("aria-expanded",e)}this.menuOpen||(this.show(this.list),this.menuOpen=!0,this.triggerOptionCallback("onOpen",[this.list]),this.documentClickBound||(this.documentClickBound=!0,document.addEventListener("click",this.documentClick)))},t.prototype.hide=function(t){if(t)return a(t,this.cssNameSpace+"--hide hide hidden"),t.setAttribute("aria-hidden","true"),void t.setAttribute("hidden","hidden");this.currentSelectedIndex=-1,this.input.setAttribute("aria-expanded","false"),this.showAll&&this.showAll.setAttribute("aria-expanded","false"),this.menuOpen&&(this.hide(this.list),this.menuOpen=!1,this.triggerOptionCallback("onClose",[this.list]))},t.prototype.enable=function(){if(this.disabled){this.disabled=!1,this.input.disabled=!1;var t=this.cssNameSpace;o(this.input,t+"__input--disabled disabled"),o(this.wrapper,t+"__wrapper--disabled disabled"),this.showAll&&(this.showAll.setAttribute("tabindex","0"),o(this.showAll,t+"__show-all--disabled disabled"))}this.enableDeletions()},t.prototype.disable=function(t){if(void 0===t&&(t=!1),!this.disabled){this.disabled=!0,this.input.disabled=!0;var e=this.cssNameSpace;a(this.input,e+"__input--disabled disabled"),a(this.wrapper,e+"__wrapper--disabled disabled"),this.showAll&&(this.showAll.setAttribute("tabindex","-1"),a(this.showAll,e+"__show-all--disabled disabled"))}t&&this.disableDeletions()},t.prototype.enableDeletions=function(){var t=this;this.deletionsDisabled&&(this.deletionsDisabled=!1,o(this.wrapper,this.cssNameSpace+"__wrapper--deletions-disabled"),this.getSelectedElems().forEach((function(e){o(e,t.cssNameSpace+"__selected--disabled"),e.setAttribute("tabindex","0")})))},t.prototype.disableDeletions=function(){var t=this;this.deletionsDisabled||(this.deletionsDisabled=!0,a(this.wrapper,this.cssNameSpace+"__wrapper--deletions-disabled"),this.getSelectedElems().forEach((function(e){a(e,t.cssNameSpace+"__selected--disabled"),e.setAttribute("tabindex","-1")})))},t.prototype.triggerAutoGrow=function(){this.autoGrow&&this.inputAutoWidth&&"function"==typeof this.inputAutoWidth.trigger&&this.inputAutoWidth.trigger()},t.prototype.setInputValue=function(t,e){void 0===e&&(e=!1),this.input.value=this.term=t,e&&(this.inputPollingValue=t),this.triggerAutoGrow()},t.prototype.indexOfValueIn=function(t,e,i){if(void 0===e&&(e=this.input.value),void 0===i&&(i="label"),t.length&&(e=x(e).toLowerCase()))for(var s=0,n=t.length;s<n;s+=1)if(x(t[s][i]).toLowerCase()===e)return s;return-1},t.prototype.announce=function(t,e){var i=this;void 0===e&&(e=400),this.srAnnouncements&&t&&"string"==typeof t&&(0!==e?(clearTimeout(this.announcementTimer),this.announcementTimer=setTimeout((function(){i.srAnnouncements.textContent=t}),e)):this.srAnnouncements.textContent=t)},t.prototype.isSelectedElem=function(t){var e=t&&t[c];return this.multiple&&e&&"object"==typeof e},t.prototype.getSelectedElems=function(){for(var t=[],e=0,i=this.wrapper.childNodes.length;e<i;e+=1){var s=this.wrapper.childNodes[e];1===s.nodeType&&this.isSelectedElem(s)&&t.push(s)}return t},t.prototype.removeEntryFromSelected=function(t){if(!this.deletionsDisabled){var e=this.selected.indexOf(t);if(-1===e)for(var i=0,s=this.selected.length;i<s;i+=1)if(this.selected[i].value===t.value){e=i;break}if(e>-1&&this.selected[e]){var n=N(this.selected[e]),r=n.label;k(n.element,!1,this),this.selected.splice(e,1),this.triggerOptionCallback("onDelete",[n]),this.setSourceElementValues(),this.buildMultiSelected(),this.triggerAutoGrow(),this.announce(r+" "+this.options.srDeletedText,0)}}},t.prototype.createSelectedElemFrom=function(t){var e=t.label,i=document.createElement("span");return i.setAttribute("aria-label",this.options.srDeleteText+" "+e),i.setAttribute("class",this.cssNameSpace+"__selected"),i.setAttribute("role","button"),i.setAttribute("tabindex","0"),i[c]=t,i.textContent=e,i},t.prototype.buildMultiSelected=function(){var t=this;if(this.multiple){this.multiple&&this.selected.length>=this.options.maxItems?this.disable():this.enable();var e=this.getSelectedElems();if(this.selected.length||e.length){var i=[];e.forEach((function(e){for(var s=e[c],n=0,r=t.selected.length;n<r;n+=1){var o=t.selected[n];if(o===s||o.value===s.value)return void i.push(e)}t.wrapper.removeChild(e)}));var s=document.createDocumentFragment();this.selected.forEach((function(e){for(var n=0,r=i.length;n<r;n+=1){var o=i[n][c];if(o===e||o.value===e.value)return}s.appendChild(t.createSelectedElemFrom(e))})),s.childNodes&&s.childNodes.length&&this.wrapper.insertBefore(s,this.list);var n=this.getSelectedElems().map((function(e,i){var s=t.ids.OPTION_SELECTED+"-"+i;return e.setAttribute("id",s),s}));n.push(this.ids.LIST),this.input.setAttribute("aria-owns",n.join(" ")),this.autoGrow&&this.selected.length?this.input.removeAttribute("placeholder"):this.options.placeholder&&this.input.setAttribute("placeholder",this.options.placeholder)}}},t.prototype.setInputDescription=function(){var t=this.input.getAttribute("aria-describedby"),e=x(t),i=e.replace(this.ids.SR_ASSISTANCE,"");this.input.value.length||(i=i+" "+this.ids.SR_ASSISTANCE),(i=x(i))?i!==e&&this.input.setAttribute("aria-describedby",i):t&&this.input.removeAttribute("aria-describedby")},t.prototype.resetOptionAttributes=function(t){void 0===t&&(t=P(this.list));var e=this.cssNameSpace+"__option--focused focused focus";t.forEach((function(t){t.setAttribute("aria-selected","false"),o(t,e)}))},t.prototype.setOptionFocus=function(t,e){var i=P(this.list);if(this.resetOptionAttributes(i),e<0||!i.length)return this.currentSelectedIndex=-1,void(t&&t.target!==this.input&&this.input.focus());if(e>=i.length)return this.currentSelectedIndex=i.length-1,void this.setOptionFocus(t,this.currentSelectedIndex);var s=i[e];if(s&&"string"==typeof s.getAttribute("tabindex"))return this.currentSelectedIndex=e,a(s,this.cssNameSpace+"__option--focused focused focus"),s.setAttribute("aria-selected","true"),void s.focus();this.currentSelectedIndex=-1},t.prototype.setSourceElementValues=function(){for(var t=[],e=0,i=this.selected.length;e<i;e+=1){var s=this.selected[e];t.push(s.value),k(s.element,!0,this)}if(this.elementIsInput){var n=t.join(this.options.multipleSeparator);n!==this.element.value&&(this.element.value=n,L(this.element,"change"))}!this.selected.length&&this.elementIsSelect&&(this.element.value=""),this.triggerOptionCallback("onChange",[this.selected])},t.prototype.handleOptionSelect=function(t,e,i){if(void 0===i&&(i=!0),!("number"!=typeof e||e<0||this.multiple&&this.selected.length>=this.options.maxItems)&&this.filteredSource.length&&this.filteredSource[e]){for(var s=N(this.filteredSource[e]),n=!1,r=0,o=this.selected.length;r<o;r+=1)if(this.selected[r].value===s.value){n=!0;break}n||this.multiple||this.selected.splice(0),n||(this.selected.push(s),this.setSourceElementValues(),this.buildMultiSelected()),this.setInputValue(this.multiple?"":s.label,!0),this.triggerOptionCallback("onConfirm",[s]),this.announce(s.label+" "+this.options.srSelectedText,0),this.disabled||!1===i||this.input.focus(),this.hide()}},t.prototype.removeSelectedFromResults=function(t){var e=this;if(!this.multiple||!this.selected.length)return t;var i=[];return t.forEach((function(t){for(var s=e.selected,n=0,r=s.length;n<r;n+=1)if(t.label===s[n].label&&t.value===s[n].value)return;i.push(t)})),i},t.prototype.setListOptions=function(t){var e=[],i=this.options.sourceMapping,s=this.removeSelectedFromResults(t),n=this.triggerOptionCallback("onResponse",[s]);this.filteredSource=Array.isArray(n)?F(n,i):s;for(var r,l=this.ids.OPTION,h=this.cssNameSpace,u=h+"__option",c=this.filteredSource.length,p="function"==typeof this.options.onItemRender,d=this.forceShowAll?9999:this.options.maxResults,f=d<c?d:c,m=0;m<f;m+=1){var v=this.filteredSource[m],b=p&&this.triggerOptionCallback("onItemRender",[v])||v.label;e.push('<li tabindex="-1" aria-selected="false" role="option" class="'+u+'" id="'+l+"--"+m+'" aria-posinset="'+(m+1)+'" aria-setsize="'+f+'">'+b+"</li>")}e.length?(a(this.list,h+"__list--has-results"),o(this.list,h+"__list--no-results")):(o(this.list,h+"__list--has-results"),a(this.list,h+"__list--no-results"));var g=this.options.noResultsText;!e.length&&"string"==typeof g&&g.length&&(r=g,e.push('<li class="'+u+" "+u+'--no-results">'+g+"</li>")),this.cancelFilterPrep(),r||(r=this.triggerOptionCallback("srResultsText",[f])),r&&this.announce(r);var y=e.join("");if(this.currentListHtml!==y?(this.currentListHtml=y,this.list.innerHTML=y):this.resetOptionAttributes(),!e.length)return this.hide(),void(this.forceShowAll=!1);this.show(),this.forceShowAll=!1},t.prototype.handleAsync=function(t,e){var i=this;void 0===e&&(e=!1),this.xhr&&"function"==typeof this.xhr.abort&&this.xhr.abort();var s=new XMLHttpRequest,n=this.forceShowAll,r=e?null:this.api,o=this.multiple?this.selected.length:0,l=n||e||9999===this.options.maxResults,a=this.source+(/\?/.test(this.source)?"&":"?")+encodeURIComponent(this.options.asyncQueryParam)+"="+encodeURIComponent(t)+"&"+encodeURIComponent(this.options.asyncMaxResultsParam)+"="+(l?9999:o+this.options.maxResults),h=this.triggerOptionCallback("onAsyncPrep",[a,s,e],r);h&&"string"==typeof h&&(a=h),s.open("GET",a),s.onload=function(){if(s.readyState===s.DONE&&s.status>=200&&s.status<300){i.forceShowAll=n;var o=F(i.triggerOptionCallback("onAsyncSuccess",[t,s,e],r)||s.responseText,i.options.sourceMapping,!1);e?(i.prepSelectedFromArray(o),i.setInputStartingStates(!1)):i.setListOptions(o),i.triggerOptionCallback("onAsyncComplete",[t,s,e],r)}},s.onerror=function(){i.triggerOptionCallback("onAsyncError",[t,s,e],r)},e||(this.xhr=s),this.triggerOptionCallback("onAsyncBeforeSend",[t,s,e],r),s.send()},t.prototype.filter=function(t){var e=this;if("string"==typeof t){var i=this.forceShowAll;if(!i){var s=this.triggerOptionCallback("onSearch",[t]);"string"==typeof s&&(t=s)}if(this.term=t,"string"==typeof this.source&&this.source.length)return this.handleAsync(t),void(this.forceShowAll=!1);if("function"!=typeof this.source){t||(i=!0);var n=[];if(this.source&&this.source.length){var r=[u];if(!i){t=C(t,!0);var o=this.options.alsoSearchIn;Array.isArray(o)&&o.length&&(r=function(t){var e=[];return t.forEach((function(t){if("string"==typeof t){for(var i=x(t),s="label"!==i,n=0,r=e.length;s&&n<r;n+=1)s=e[r]!==i;s&&e.push(i)}})),e}(r.concat(o)))}this.source.forEach((function(e){(i||function(t,e,i){for(var s in t)if(t.hasOwnProperty(s)){var n=t[s];if(("string"==typeof n||Array.isArray(n))&&i.indexOf(s)>-1&&R(n,e,s))return!0}return!1}(e,t,r))&&n.push(e)}))}this.setListOptions(n)}else{var l=function(t){var i=F(t,e.options.sourceMapping);e.setListOptions(i)},a=this.source.call(this.api,this.term,l,!1);a&&"function"==typeof a.then&&a.then((function(t){return l(t)}))}}else this.cancelFilterPrep()},t.prototype.cancelFilterPrep=function(){clearTimeout(this.filterTimer),o(this.wrapper,this.cssNameSpace+"__wrapper--loading loading"),o(this.input,this.cssNameSpace+"__input--loading loading"),this.filtering=!1},t.prototype.filterPrep=function(t,e,i){var s=this;void 0===e&&(e=!1),void 0===i&&(i=!1);var n=this.forceShowAll,r=n||i?0:this.options.delay;this.cancelFilterPrep(),this.filtering=!0,this.filterTimer=setTimeout((function(){var i=s.input.value;if(s.inputPollingValue=i,(n||""===i||e&&!s.multiple&&s.selected.length&&x(s.selected[0].label)===x(i))&&(i=""),s.setInputDescription(),!n&&i.length<s.options.minLength)s.hide();else{var r;try{var o=t;r=t&&"keydown"===t.type&&(o.altKey||o.ctrlKey||o.metaKey)}catch(t){}var l=""!==i&&i===s.term;!l||l&&!s.menuOpen&&!r?(a(s.wrapper,s.cssNameSpace+"__wrapper--loading loading"),a(s.input,s.cssNameSpace+"__input--loading loading"),s.currentSelectedIndex=-1,s.filter(i)):s.cancelFilterPrep()}}),r)},t.prototype.filterPrepShowAll=function(t){var e=this;this.disabled||(clearTimeout(this.showAllPrepTimer),this.showAllPrepTimer=setTimeout((function(){e.componentBlurTimer&&clearTimeout(e.componentBlurTimer),t.preventDefault(),e.forceShowAll=!0,e.filterPrep(t,!1,!0)}),0))},t.prototype.handleComponentBlur=function(t,e){var i=this;void 0===e&&(e=!1),clearTimeout(this.componentBlurTimer);var s=e?0:100;this.componentBlurTimer=setTimeout((function(){var t=document.activeElement;if(e||!t||i.showAll&&i.showAll===t||i.isSelectedElem(t)||!i.wrapper.contains(t)){if(i.xhr&&"function"==typeof i.xhr.abort&&i.xhr.abort(),!e&&i.options.confirmOnBlur&&i.menuOpen){var s=i.currentSelectedIndex;"number"==typeof s&&-1!==s||(s=i.indexOfValueIn.call(i,i.filteredSource)),i.handleOptionSelect({},s,!1)}if(i.cancelFilterPrep(),i.hide(),!i.multiple&&-1===i.indexOfValueIn.call(i,i.selected)){i.selected.length&&i.removeEntryFromSelected(i.selected[0]);var n=i.elementIsInput||i.elementIsSelect,r=i.element;n&&""!==r.value&&(r.value="",L(r,"change")),i.setInputValue("",!0)}i.multiple&&i.setInputValue("",!0),i.documentClickBound&&(i.documentClickBound=!1,document.removeEventListener("click",i.documentClick)),i.triggerOptionCallback("onBlur",[i.wrapper]),i.isFocused=!1}}),s)},t.prototype.handleUpKey=function(t){t.preventDefault(),!this.disabled&&this.menuOpen&&"number"==typeof this.currentSelectedIndex&&this.setOptionFocus(t,this.currentSelectedIndex-1)},t.prototype.handleDownKey=function(t){if(t.preventDefault(),this.menuOpen||(this.forceShowAll=this.options.minLength<1,(this.forceShowAll||this.input.value.length>=this.options.minLength)&&this.filterPrep(t)),this.menuOpen&&!this.filtering){var e=this.currentSelectedIndex;"number"!=typeof e||e<0?this.setOptionFocus(t,0):this.setOptionFocus(t,e+1)}},t.prototype.handleEndKey=function(t){if(!this.disabled&&this.menuOpen&&t.target!==this.input){var e=P(this.list);e.length&&(t.preventDefault(),this.setOptionFocus(t,e.length-1))}},t.prototype.handleHomeKey=function(t){!this.disabled&&this.menuOpen&&t.target!==this.input&&(t.preventDefault(),this.setOptionFocus(t,0))},t.prototype.handleEnterKey=function(t){var e=t.target;this.isSelectedElem(e)?this.removeEntryFromSelected(e[c]):this.disabled||(this.showAll&&e===this.showAll?this.filterPrepShowAll(t):(this.menuOpen&&(t.preventDefault(),this.currentSelectedIndex>-1&&this.handleOptionSelect(t,this.currentSelectedIndex)),e===this.input&&this.filterPrep(t,!1,!0)))},t.prototype.handleKeyDownDefault=function(t){var e=t.keyCode,i=t.target===this.input;if(e===m&&!i||this.isSelectedElem(t.target)&&e===S)return t.preventDefault(),void this.handleEnterKey(t);if(!this.disabled){var s=this.selected&&this.selected.length;if(this.options.deleteOnBackspace&&e===p&&""===this.input.value&&s&&i&&this.multiple)this.removeEntryFromSelected(this.selected[s-1]);else{var n=function(t){return t>=48&&t<=57||t>=65&&t<=90||t>=96&&t<=111||t>=186&&t<=222||32===t||8===t||46===t}(e),r=!i&&n;r&&this.input.focus(),(r||i&&n)&&this.filterPrep(t)}}},t.prototype.prepKeyDown=function(t){switch(t.keyCode){case g:this.handleUpKey(t);break;case y:this.handleDownKey(t);break;case v:this.handleEndKey(t);break;case b:this.handleHomeKey(t);break;case d:this.handleEnterKey(t);break;case f:this.handleComponentBlur(t,!0);break;default:this.handleKeyDownDefault(t)}},t.prototype.cancelPolling=function(){clearTimeout(this.pollingTimer)},t.prototype.startPolling=function(){var t=this;this.filtering||this.input.value===this.inputPollingValue||this.filterPrep({}),this.pollingTimer=setTimeout((function(){t.startPolling()}),200)},t.prototype.bindEvents=function(){var t=this;this.wrapper.addEventListener("focusout",(function(e){t.handleComponentBlur(e,!1)})),this.wrapper.addEventListener("focusin",(function(e){t.list.contains(e.target)||(t.currentSelectedIndex=-1),t.isFocused||t.triggerOptionCallback("onFocus",[t.wrapper]),t.isFocused=!0})),this.wrapper.addEventListener("keydown",(function(e){t.prepKeyDown(e)})),this.wrapper.addEventListener("click",(function(e){e.target!==t.wrapper?t.isSelectedElem(e.target)&&t.removeEntryFromSelected(e.target[c]):t.input.focus()}));var e=this.cssNameSpace+"__wrapper--focused focused focus",i=this.cssNameSpace+"__input--focused focused focus";this.input.addEventListener("blur",(function(){o(t.wrapper,e),o(t.input,i),t.cancelPolling()})),this.input.addEventListener("input",(function(e){document.activeElement===t.input&&t.filterPrep(e)})),this.input.addEventListener("click",(function(e){!t.menuOpen&&t.input.value.length>=t.options.minLength&&t.filterPrep(e,!0)})),this.input.addEventListener("focusin",(function(s){a(t.wrapper,e),a(t.input,i),t.startPolling(),t.disabled||t.menuOpen||t.filterPrep(s,!0)})),this.showAll&&this.showAll.addEventListener("click",(function(e){t.filterPrepShowAll(e)})),this.list.addEventListener("mouseenter",(function(e){t.resetOptionAttributes()})),this.list.addEventListener("click",(function(e){if(e.target!==t.list){var i=P(t.list);if(i.length){var s=i.indexOf(e.target);t.handleOptionSelect(e,s)}}})),this.autoGrow&&(this.inputAutoWidth=new n.a(this.input))},t.prototype.prepListSourceCheckboxes=function(){this.multiple=!0,this.source=[];for(var t=this.element.querySelectorAll('input[type="checkbox"]'),e=0,i=t.length;e<i;e+=1){var s=t[e];if(s.value){var n={element:s,value:s.value},r=s.closest("label");!r&&s.id&&(r=document.querySelector('[for="'+s.id+'"]')),r&&(n.label=r.textContent),n.label||(n.label=n.value),n[u]=C(n.label),this.source.push(n),s.checked&&this.selected.push(n)}}},t.prototype.prepListSourceDdl=function(){var t=this.element.multiple;t&&!this.multiple&&(this.multiple=!0),!t&&this.multiple&&this.options.maxItems>1&&(this.options.maxItems=1),this.source=[];for(var e=this.element.querySelectorAll("option"),i=0,s=e.length;i<s;i+=1){var n=e[i];if(n.value){var r={element:n,value:n.value,label:n.textContent};r[u]=C(r.label),this.source.push(r),n.selected&&this.selected.push(r)}}},t.prototype.prepSelectedFromArray=function(t){var e=this,i=this.elementIsInput&&this.element.value;if(i&&t&&t.length){var s=this.options.multiple,n=this.options.multipleSeparator;(s?i.split(n):[i]).forEach((function(i){if(-1===e.indexOfValueIn(e.selected,i,"value")){var s=e.indexOfValueIn(t,i,"value");s>-1&&e.selected.push(t[s])}}))}},t.prototype.prepListSourceArray=function(){this.source=F(this.source,this.options.sourceMapping),this.prepSelectedFromArray(this.source)},t.prototype.prepListSourceAsync=function(){var t=this.element;this.elementIsInput&&t.value&&this.handleAsync(t.value,!0)},t.prototype.prepListSourceFunction=function(){var t=this,e=this.element;if(this.elementIsInput&&e.value){var i=function(e){var i=F(e,t.options.sourceMapping);t.prepSelectedFromArray(i),t.setInputStartingStates(!1)},s=this.source.call(void 0,e.value,i,!0);s&&"function"==typeof s.then&&s.then((function(t){return i(t)}))}},t.prototype.prepListSource=function(){return"function"==typeof this.source?this.prepListSourceFunction():"string"==typeof this.source&&this.source.length?this.prepListSourceAsync():Array.isArray(this.source)&&this.source.length?this.prepListSourceArray():this.elementIsSelect?this.prepListSourceDdl():void(this.element.querySelector('input[type="checkbox"]')&&this.prepListSourceCheckboxes())},t.prototype.setInputStartingStates=function(t){if(void 0===t&&(t=!0),t){if(this.ids.ELEMENT){var e=document.querySelector('[for="'+this.ids.ELEMENT+'"]');e&&(e._ariaAutocompleteLabelOriginallyFor=this.ids.ELEMENT,e.setAttribute("for",this.ids.INPUT))}var i=this.element.getAttribute("aria-describedby");i&&this.input.setAttribute("aria-describedby",i);var s=this.element.getAttribute("aria-labelledby");s&&this.input.setAttribute("aria-labelledby",s)}this.selected.length&&(this.multiple?(this.buildMultiSelected(),this.triggerAutoGrow()):this.setInputValue(this.selected[0].label||"",!0)),this.setInputDescription(),this.element.disabled&&this.disable(!0)},t.prototype.setHtml=function(){var t=this.options,e=this.cssNameSpace,i=t.wrapperClassName?" "+t.wrapperClassName:"",s=['<div id="'+this.ids.WRAPPER+'" class="'+e+"__wrapper"+i+'">'],n=t.name?' name="'+t.name+'"':"",r=t.inputClassName?" "+t.inputClassName:"",o=t.placeholder?' placeholder="'+t.placeholder+'" aria-placeholder="'+t.placeholder+'"':"";s.push('<input type="text" autocomplete="off" aria-expanded="false" aria-autocomplete="list" role="combobox" id="'+this.ids.INPUT+'" aria-owns="'+this.ids.LIST+'" class="'+e+"__input"+r+'"'+n+o+" />"),t.showAllControl&&s.push('<span role="button" aria-label="'+t.srShowAllText+'" class="'+e+'__show-all" tabindex="0" id="'+this.ids.BUTTON+'" aria-expanded="false"></span>');var l=t.srListLabelText,a=t.listClassName?" "+t.listClassName:"",h=l?' aria-label="'+l+'"':"";s.push('<ul id="'+this.ids.LIST+'" class="'+e+"__list"+a+'" role="listbox" aria-hidden="true" hidden="hidden"'+h+"></ul>"),s.push('<span class="sr-only '+e+"__sr-only "+e+'__sr-assistance" id="'+this.ids.SR_ASSISTANCE+'">'+t.srAssistiveText+"</span>"),s.push('<span class="sr-only '+e+"__sr-only "+e+'__sr-announcements" id="'+this.ids.SR_ANNOUNCEMENTS+'" aria-live="polite" aria-atomic="true"></span>'),s.push("</div>"),this.element.insertAdjacentHTML("afterend",s.join(""))},t.prototype.destroy=function(){var t=this,e=document.querySelector('[for="'+this.ids.INPUT+'"]');e&&e._ariaAutocompleteLabelOriginallyFor&&(e.setAttribute("for",e._ariaAutocompleteLabelOriginallyFor),delete e._ariaAutocompleteLabelOriginallyFor),this.documentClickBound&&document.removeEventListener("click",this.documentClick),this.autoGrow&&this.inputAutoWidth&&this.inputAutoWidth.destroy(),this.element.parentNode.removeChild(this.wrapper),delete this.element.ariaAutocomplete,this.show(this.element),clearTimeout(this.filterTimer),clearTimeout(this.pollingTimer),clearTimeout(this.showAllPrepTimer),clearTimeout(this.announcementTimer),clearTimeout(this.componentBlurTimer),clearTimeout(this.elementChangeEventTimer),["element","list","input","wrapper","showAll","srAnnouncements"].forEach((function(e){return t[e]=null}))},t.prototype.init=function(t,e){this.selected=[],this.element=t,this.ids=new E(t.id,e.id),this.elementIsInput="INPUT"===t.nodeName,this.elementIsSelect="SELECT"===t.nodeName,this.options=new h(e),this.source=this.options.source,this.multiple=this.options.multiple,this.autoGrow=this.options.autoGrow,this.cssNameSpace=this.options.cssNameSpace,this.documentClick=this.handleComponentBlur.bind(this),this.setHtml(),this.list=document.getElementById(this.ids.LIST),this.input=document.getElementById(this.ids.INPUT),this.wrapper=document.getElementById(this.ids.WRAPPER),this.showAll=document.getElementById(this.ids.BUTTON),this.srAnnouncements=document.getElementById(this.ids.SR_ANNOUNCEMENTS),this.prepListSource();var i=[];this.options.showAllControl&&i.push(this.cssNameSpace+"__wrapper--show-all"),this.autoGrow&&i.push(this.cssNameSpace+"__wrapper--autogrow"),this.multiple&&i.push(this.cssNameSpace+"__wrapper--multiple"),i.length&&a(this.wrapper,i.join(" ")),this.hide(this.list),this.hide(this.element),this.setInputStartingStates(),this.bindEvents(),this.api=new A(this),this.triggerOptionCallback("onReady",[this.wrapper])},t}();function M(t,e){return t&&t.ariaAutocomplete&&t.ariaAutocomplete.open?t.ariaAutocomplete:new D(t,e).api}e.default=M}])}));

@@ -33,6 +33,7 @@ export interface IAriaAutocompleteOptions {

onSearch?(value: string): string | void;
onAsyncPrep?(url: string): string | void;
onAsyncBeforeSend?(xhr: XMLHttpRequest): void;
onAsyncSuccess?(query: string, xhr: XMLHttpRequest): any[] | void;
onAsyncError?(query: string, xhr: XMLHttpRequest): void;
onAsyncPrep?(url: string, xhr: XMLHttpRequest, isFirstCall: boolean): string | void;
onAsyncBeforeSend?(query: string, xhr: XMLHttpRequest, isFirstCall: boolean): void;
onAsyncSuccess?(query: string, xhr: XMLHttpRequest, isFirstCall: boolean): any[] | void;
onAsyncComplete?(query: string, xhr: XMLHttpRequest, isFirstCall: boolean): void;
onAsyncError?(query: string, xhr: XMLHttpRequest, isFirstCall: boolean): void;
onResponse?(options: any[]): any[] | void;

@@ -59,4 +60,4 @@ onItemRender?(sourceEntry: any): string | void;

enable(): void;
disable(disableDeletions: boolean): void;
filter(val: string): void;
disable(disableDeletions?: boolean): void;
filter(value: string): void;
destroy(): void;

@@ -63,0 +64,0 @@ }

{
"name": "aria-autocomplete",
"version": "1.2.0-beta.4",
"version": "1.2.0-beta.5",
"description": "Accessible, extensible, JavaScript autocomplete with multi-select",

@@ -5,0 +5,0 @@ "main": "dist/aria-autocomplete.min.js",

@@ -90,3 +90,3 @@ # Aria Autocomplete

* @example ['Afghanistan', 'Albania', 'Algeria', ...more]
* @example (query, render) => render(arrayToUse)
* @example (query, render, isFirstCall) => render(arrayToUse)
*/

@@ -253,6 +253,9 @@ source: string[] | any[] | string | Function;

/**
* Callback before async call is made - receives the URL.
* Can be used to format the endpoint URL by returning a String
* Callback before async call is made - receives the URL, and the XHR object.
* Can be used to format the endpoint URL by returning a String,
* and for changes to the XHR object.
* Note: this is before the onload and onerror functions are attached
* and before the `open` method is called
*/
onAsyncPrep: (url: string) => string | void;
onAsyncPrep: (url: string, xhr: XMLHttpRequest, isFirstCall: boolean) => string | void;

@@ -263,14 +266,25 @@ /**

*/
onAsyncBeforeSend: (xhr: XMLHttpRequest) => void;
onAsyncBeforeSend: (query: string, xhr: XMLHttpRequest, isFirstCall: boolean) => void;
/**
* Callback after async call completes - receives the xhr object.
* Callback after async call succeeds, but before results render - receives the xhr object.
* Can be used to format the results by returning an Array
*/
onAsyncSuccess: (xhr: XMLHttpRequest) => any[] | void;
onAsyncSuccess: (query: string, xhr: XMLHttpRequest, isFirstCall: boolean) => any[] | void;
/**
* Callback prior to rendering - receives the options that are going
* to render. Can be used to format the results by returning an Array
* Callback after async call completes successfully, and after the results have rendered.
*/
onAsyncComplete: (query: string, xhr: XMLHttpRequest, isFirstCall: boolean) => void;
/**
* Callback after async call succeeds, but before results render - receives the xhr object.
* Can be used to format the results by returning an Array
*/
onAsyncError: (query: string, xhr: XMLHttpRequest, isFirstCall: boolean) => any[] | void;
/**
* Callback prior to rendering - receives the options that are going to render.
* Can be used to format the results by returning an Array
*/
onResponse: (options: any[]) => any[] | void;

@@ -277,0 +291,0 @@

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