wishthis/node_modules/fomantic-ui/dist/components/dropdown.min.js
2022-05-29 11:24:36 +02:00

11 lines
No EOL
58 KiB
JavaScript

/*
* # Fomantic UI - 2.8.8
* https://github.com/fomantic/Fomantic-UI
* http://fomantic-ui.com/
*
* Copyright 2021 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
!function(te,ne,ie,ae){"use strict";te.isFunction=te.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},ne=void 0!==ne&&ne.Math==Math?ne:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),te.fn.dropdown=function(B){var K,W=te(this),Q=te(ie),Y=W.selector||"",$="ontouchstart"in ie.documentElement,X=$?"touchstart":"click",G=(new Date).getTime(),J=[],Z=B,_="string"==typeof Z,ee=[].slice.call(arguments,1);return W.each(function(n){var d,e,t,i,a,s,o,r,l,h,f=te.isPlainObject(B)?te.extend(!0,{},te.fn.dropdown.settings,B):te.extend({},te.fn.dropdown.settings),g=f.className,v=f.message,c=f.fields,p=f.keys,b=f.metadata,u=f.namespace,m=f.regExp,w=f.selector,C=f.error,y=f.templates,x="."+u,S="module-"+u,A=te(this),T=te(f.context),L=A.find(w.text),I=A.find(w.search),D=A.find(w.sizer),k=A.find(w.input),q=A.find(w.icon),O=A.find(w.clearIcon),R=0<A.prev().find(w.text).length?A.prev().find(w.text):A.prev(),V=A.children(w.menu),E=V.find(w.item),M=f.hideDividers?E.parent().children(w.divider):te(),z=!1,F=!1,P=!1,N=!1,H=this,j=!1,U=A.data(S);h={initialize:function(){h.debug("Initializing dropdown",f),h.is.alreadySetup()?h.setup.reference():(f.ignoreDiacritics&&!String.prototype.normalize&&(f.ignoreDiacritics=!1,h.error(C.noNormalize,H)),h.setup.layout(),f.values&&(h.set.initialLoad(),h.change.values(f.values),h.remove.initialLoad()),h.refreshData(),h.save.defaults(),h.restore.selected(),h.create.id(),h.bind.events(),h.observeChanges(),h.instantiate())},instantiate:function(){h.verbose("Storing instance of dropdown",h),U=h,A.data(S,h)},destroy:function(){h.verbose("Destroying previous dropdown",A),h.remove.tabbable(),h.remove.active(),V.transition("stop all"),V.removeClass(g.visible).addClass(g.hidden),A.off(x).removeData(S),V.off(x),Q.off(a),h.disconnect.menuObserver(),h.disconnect.selectObserver(),h.disconnect.classObserver()},observeChanges:function(){"MutationObserver"in ne&&(o=new MutationObserver(h.event.select.mutation),r=new MutationObserver(h.event.menu.mutation),l=new MutationObserver(h.event.class.mutation),h.debug("Setting up mutation observer",o,r,l),h.observe.select(),h.observe.menu(),h.observe.class())},disconnect:{menuObserver:function(){r&&r.disconnect()},selectObserver:function(){o&&o.disconnect()},classObserver:function(){l&&l.disconnect()}},observe:{select:function(){h.has.input()&&o&&o.observe(A[0],{childList:!0,subtree:!0})},menu:function(){h.has.menu()&&r&&r.observe(V[0],{childList:!0,subtree:!0})},class:function(){h.has.search()&&l&&l.observe(A[0],{attributes:!0})}},create:{id:function(){s=(Math.random().toString(16)+"000000000").substr(2,8),a="."+s,h.verbose("Creating unique id for element",s)},userChoice:function(e){var n,i,a;return!!(e=e||h.get.userValues())&&(e=Array.isArray(e)?e:[e],te.each(e,function(e,t){!1===h.get.item(t)&&(a=f.templates.addition(h.add.variables(v.addResult,t)),i=te("<div />").html(a).attr("data-"+b.value,t).attr("data-"+b.text,t).addClass(g.addition).addClass(g.item),f.hideAdditions&&i.addClass(g.hidden),n=n===ae?i:n.add(i),h.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=h.get.userValues();t&&(h.debug("Adding user labels",t),te.each(t,function(e,t){h.verbose("Adding custom user value"),h.add.label(t,t)}))},menu:function(){V=te("<div />").addClass(g.menu).appendTo(A)},sizer:function(){D=te("<span />").addClass(g.sizer).insertAfter(I)}},search:function(e){e=e!==ae?e:h.get.query(),h.verbose("Searching for query",e),!1===f.fireOnInit&&h.is.initialLoad()?h.verbose("Skipping callback on initial load",f.onSearch):h.has.minCharacters(e)&&!1!==f.onSearch.call(H,e)?h.filter(e):h.hide(null,!0)},select:{firstUnfiltered:function(){h.verbose("Selecting first non-filtered element"),h.remove.selectedItem(),E.not(w.unselectable).not(w.addition+w.hidden).eq(0).addClass(g.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(w.item).not(w.unselectable).eq(0),n=e.prevAll(w.item).not(w.unselectable).eq(0);0<t.length?(h.verbose("Moving selection to",t),t.addClass(g.selected)):(h.verbose("Moving selection to",n),n.addClass(g.selected))}},setup:{api:function(){var e={debug:f.debug,urlData:{value:h.get.value(),query:h.get.query()},on:!1};h.verbose("First request, initializing API"),A.api(e)},layout:function(){A.is("select")&&(h.setup.select(),h.setup.returnedObject()),h.has.menu()||h.create.menu(),h.is.clearable()&&!h.has.clearItem()&&(h.verbose("Adding clear icon"),O=te("<i />").addClass("remove icon").insertBefore(L)),h.is.search()&&!h.has.search()&&(h.verbose("Adding search input"),I=te("<input />").addClass(g.search).prop("autocomplete",h.is.chrome()?"fomantic-search":"off").insertBefore(L)),h.is.multiple()&&h.is.searchSelection()&&!h.has.sizer()&&h.create.sizer(),f.allowTab&&h.set.tabbable()},select:function(){var e=h.get.selectValues();h.debug("Dropdown initialized on a select",e),A.is("select")&&(k=A),0<k.parent(w.dropdown).length?(h.debug("UI dropdown already exists. Creating dropdown menu only"),A=k.closest(w.dropdown),h.has.menu()||h.create.menu(),V=A.children(w.menu),h.setup.menu(e)):(h.debug("Creating entire dropdown from select"),A=te("<div />").attr("class",k.attr("class")).addClass(g.selection).addClass(g.dropdown).html(y.dropdown(e,c,f.preserveHTML,f.className)).insertBefore(k),k.hasClass(g.multiple)&&!1===k.prop("multiple")&&(h.error(C.missingMultiple),k.prop("multiple",!0)),k.is("[multiple]")&&h.set.multiple(),k.prop("disabled")&&(h.debug("Disabling dropdown"),A.addClass(g.disabled)),k.removeAttr("required").removeAttr("class").detach().prependTo(A)),h.refresh()},menu:function(e){V.html(y.menu(e,c,f.preserveHTML,f.className)),E=V.find(w.item),M=f.hideDividers?E.parent().children(w.divider):te()},reference:function(){h.debug("Dropdown behavior was called on select, replacing with closest dropdown"),A=A.parent(w.dropdown),U=A.data(S),H=A.get(0),h.refresh(),h.setup.returnedObject()},returnedObject:function(){var e=W.slice(0,n),t=W.slice(n+1);W=e.add(A).add(t)}},refresh:function(){h.refreshSelectors(),h.refreshData()},refreshItems:function(){E=V.find(w.item),M=f.hideDividers?E.parent().children(w.divider):te()},refreshSelectors:function(){h.verbose("Refreshing selector cache"),L=A.find(w.text),I=A.find(w.search),k=A.find(w.input),q=A.find(w.icon),R=0<A.prev().find(w.text).length?A.prev().find(w.text):A.prev(),V=A.children(w.menu),E=V.find(w.item),M=f.hideDividers?E.parent().children(w.divider):te()},refreshData:function(){h.verbose("Refreshing cached metadata"),E.removeData(b.text).removeData(b.value)},clearData:function(){h.verbose("Clearing metadata"),E.removeData(b.text).removeData(b.value),A.removeData(b.defaultText).removeData(b.defaultValue).removeData(b.placeholderText)},clearItems:function(){V.empty(),h.refreshItems()},toggle:function(){h.verbose("Toggling menu visibility"),h.is.active()?h.hide():h.show()},show:function(e,t){if(e=te.isFunction(e)?e:function(){},(j||N)&&h.is.remote()&&h.is.noApiCache()&&h.clearItems(),!h.can.show()&&h.is.remote()&&(h.debug("No API results retrieved, searching before show"),h.queryRemote(h.get.query(),h.show,[e,t])),h.can.show()&&!h.is.active()){if(h.debug("Showing dropdown"),!h.has.message()||h.has.maxSelections()||h.has.allResultsFiltered()||h.remove.message(),h.is.allFiltered())return!0;!1!==f.onShow.call(H)&&h.animate.show(function(){h.can.click()&&h.bind.intent(),h.has.search()&&!t&&h.focusSearch(),h.set.visible(),e.call(H)})}},hide:function(e,t){e=te.isFunction(e)?e:function(){},h.is.active()&&!h.is.animatingOutward()?(h.debug("Hiding dropdown"),!1!==f.onHide.call(H)&&h.animate.hide(function(){h.remove.visible(),h.is.focusedOnSearch()&&!0!==t&&I.blur(),e.call(H)})):h.can.click()&&h.unbind.intent(),j=N=!1},hideOthers:function(){h.verbose("Finding other dropdowns to hide"),W.not(A).has(w.menu+"."+g.visible).dropdown("hide")},hideMenu:function(){h.verbose("Hiding menu instantaneously"),h.remove.active(),h.remove.visible(),V.transition("hide")},hideSubMenus:function(){var e=V.children(w.item).find(w.menu);h.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){h.bind.keyboardEvents(),h.bind.inputEvents(),h.bind.mouseEvents()},keyboardEvents:function(){h.verbose("Binding keyboard events"),A.on("keydown"+x,h.event.keydown),h.has.search()&&A.on(h.get.inputEvent()+x,w.search,h.event.input),h.is.multiple()&&Q.on("keydown"+a,h.event.document.keydown)},inputEvents:function(){h.verbose("Binding input change events"),A.on("change"+x,w.input,h.event.change)},mouseEvents:function(){h.verbose("Binding mouse events"),h.is.multiple()&&A.on(X+x,w.label,h.event.label.click).on(X+x,w.remove,h.event.remove.click),h.is.searchSelection()?(A.on("mousedown"+x,h.event.mousedown).on("mouseup"+x,h.event.mouseup).on("mousedown"+x,w.menu,h.event.menu.mousedown).on("mouseup"+x,w.menu,h.event.menu.mouseup).on(X+x,w.icon,h.event.icon.click).on(X+x,w.clearIcon,h.event.clearIcon.click).on("focus"+x,w.search,h.event.search.focus).on(X+x,w.search,h.event.search.focus).on("blur"+x,w.search,h.event.search.blur).on(X+x,w.text,h.event.text.focus),h.is.multiple()&&A.on(X+x,h.event.click).on(X+x,h.event.search.focus)):("click"==f.on?A.on(X+x,w.icon,h.event.icon.click).on(X+x,h.event.test.toggle):"hover"==f.on?A.on("mouseenter"+x,h.delay.show).on("mouseleave"+x,h.delay.hide):A.on(f.on+x,h.toggle),A.on("mousedown"+x,h.event.mousedown).on("mouseup"+x,h.event.mouseup).on("focus"+x,h.event.focus).on(X+x,w.clearIcon,h.event.clearIcon.click),h.has.menuSearch()?A.on("blur"+x,w.search,h.event.search.blur):A.on("blur"+x,h.event.blur)),V.on(($?"touchstart":"mouseenter")+x,w.item,h.event.item.mouseenter).on("mouseleave"+x,w.item,h.event.item.mouseleave).on("click"+x,w.item,h.event.item.click)},intent:function(){h.verbose("Binding hide intent event to document"),$&&Q.on("touchstart"+a,h.event.test.touch).on("touchmove"+a,h.event.test.touch),Q.on(X+a,h.event.test.hide)}},unbind:{intent:function(){h.verbose("Removing hide intent event from document"),$&&Q.off("touchstart"+a).off("touchmove"+a),Q.off(X+a)}},filter:function(e){function t(){h.is.multiple()&&h.filterActive(),(e||!e&&0==h.get.activeItem().length)&&h.select.firstUnfiltered(),h.has.allResultsFiltered()?f.onNoResults.call(H,n)?f.allowAdditions?f.hideAdditions&&(h.verbose("User addition with no menu, setting empty style"),h.set.empty(),h.hideMenu()):(h.verbose("All items filtered, showing message",n),h.add.message(v.noResults)):(h.verbose("All items filtered, hiding dropdown",n),h.hideMenu()):(h.remove.empty(),h.remove.message()),f.allowAdditions&&h.add.userSuggestion(h.escape.htmlEntities(e)),h.is.searchSelection()&&h.can.show()&&h.is.focusedOnSearch()&&h.show()}var n=e!==ae?e:h.get.query();f.useLabels&&h.has.maxSelections()||(f.apiSettings?h.can.useAPI()?h.queryRemote(n,function(){f.filterRemoteData&&h.filterItems(n);var e=k.val();Array.isArray(e)||(e=e&&""!==e?e.split(f.delimiter):[]),h.is.multiple()&&te.each(e,function(e,t){E.filter('[data-value="'+t+'"]').addClass(g.filtered)}),h.focusSearch(!0),t()}):h.error(C.noAPI):(h.filterItems(n),t()))},queryRemote:function(e,a,s){Array.isArray(s)||(s=[s]);var t={errorDuration:!1,cache:"local",throttle:f.throttle,urlData:{query:e},onError:function(){h.add.message(v.serverError),j=N=!1,a.apply(null,s)},onFailure:function(){h.add.message(v.serverError),j=N=!1,a.apply(null,s)},onSuccess:function(e){var t=e[c.remoteValues];Array.isArray(t)||(t=[]),h.remove.message();var n={};if(n[c.values]=t,h.setup.menu(n),0!==t.length||f.allowAdditions){var i=h.is.multiple()?h.get.values():h.get.value();""!==i&&(h.verbose("Value(s) present after click icon, select value(s) in items"),h.set.selected(i,null,null,!0))}else h.add.message(v.noResults);j=N=!1,a.apply(null,s)}};A.api("get request")||h.setup.api(),t=te.extend(!0,{},t,f.apiSettings),A.api("setting",t).api("query")},filterItems:function(e){var i=h.remove.diacritics(e!==ae?e:h.get.query()),a=null,t=h.escape.string(i),n=(f.ignoreSearchCase?"i":"")+"gm",s=new RegExp("^"+t,n);h.has.query()&&(a=[],h.verbose("Searching for matching values",i),E.each(function(){var e,t,n=te(this);if(n.hasClass(g.unfilterable))return a.push(this),!0;if("both"===f.match||"text"===f.match){if(-1!==(e=h.remove.diacritics(String(h.get.choiceText(n,!1)))).search(s))return a.push(this),!0;if("exact"===f.fullTextSearch&&h.exactSearch(i,e))return a.push(this),!0;if(!0===f.fullTextSearch&&h.fuzzySearch(i,e))return a.push(this),!0}if("both"===f.match||"value"===f.match){if(-1!==(t=h.remove.diacritics(String(h.get.choiceValue(n,e)))).search(s))return a.push(this),!0;if("exact"===f.fullTextSearch&&h.exactSearch(i,t))return a.push(this),!0;if(!0===f.fullTextSearch&&h.fuzzySearch(i,t))return a.push(this),!0}})),h.debug("Showing only matched items",i),h.remove.filteredItem(),a&&E.not(a).addClass(g.filtered),h.has.query()?!0===f.hideDividers?M.addClass(g.hidden):"empty"===f.hideDividers&&M.removeClass(g.hidden).filter(function(){var e=te(this).nextUntil(w.item);return 0===(e.length?e:te(this)).nextUntil(w.divider).filter(w.item+":not(."+g.filtered+")").length}).addClass(g.hidden):M.removeClass(g.hidden)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=f.ignoreSearchCase?e.toLowerCase():e,t=f.ignoreSearchCase?t.toLowerCase():t,n<i)return!1;if(i===n)return e===t;e:for(var a=0,s=0;a<i;a++){for(var o=e.charCodeAt(a);s<n;)if(t.charCodeAt(s++)===o)continue e;return!1}return!0},exactSearch:function(e,t){return e=f.ignoreSearchCase?e.toLowerCase():e,-1<(t=f.ignoreSearchCase?t.toLowerCase():t).indexOf(e)},filterActive:function(){f.useLabels&&E.filter("."+g.active).addClass(g.filtered)},focusSearch:function(e){h.has.search()&&!h.is.focusedOnSearch()&&(e?(A.off("focus"+x,w.search),I.focus(),A.on("focus"+x,w.search,h.event.search.focus)):I.focus())},blurSearch:function(){h.has.search()&&I.blur()},forceSelection:function(){var e=E.not(g.filtered).filter("."+g.selected).eq(0),t=E.not(g.filtered).filter("."+g.active).eq(0),n=0<e.length?e:t,i=0<n.length;f.allowAdditions||i&&!h.is.multiple()?(h.debug("Forcing partial selection to selected item",n),h.event.item.click.call(n,{},!0)):h.remove.searchTerm()},change:{values:function(e){f.allowAdditions||h.clear(),h.debug("Creating dropdown with specified values",e);var t={};t[c.values]=e,h.setup.menu(t),te.each(e,function(e,t){if(1==t.selected&&(h.debug("Setting initial selection to",t[c.value]),h.set.selected(t[c.value]),!h.is.multiple()))return!1}),h.has.selectInput()&&(h.disconnect.selectObserver(),k.html(""),k.append("<option disabled selected value></option>"),te.each(e,function(e,t){var n=f.templates.deQuote(t[c.value]),i=f.templates.escape(t[c.name]||"",f.preserveHTML);k.append('<option value="'+n+'">'+i+"</option>")}),h.observe.select())}},event:{change:function(){P||(h.debug("Input changed, updating selection"),h.set.selected())},focus:function(){f.showOnFocus&&!z&&h.is.hidden()&&!t&&(j=!0,h.show())},blur:function(e){t=ie.activeElement===this,z||t||(h.remove.activeLabel(),h.hide())},mousedown:function(){h.is.searchSelection()?i=!0:z=!0},mouseup:function(){h.is.searchSelection()?i=!1:z=!1},click:function(e){te(e.target).is(A)&&(h.is.focusedOnSearch()?h.show():h.focusSearch())},search:{focus:function(e){z=!0,h.is.multiple()&&h.remove.activeLabel(),j||h.is.active()||!(f.showOnFocus||"focus"!==e.type&&"focusin"!==e.type)||(j=!0,h.search())},blur:function(e){t=ie.activeElement===this,h.is.searchSelection()&&!i&&(F||t||(f.forceSelection?h.forceSelection():f.allowAdditions||h.remove.searchTerm(),h.hide())),i=!1}},clearIcon:{click:function(e){h.clear(),h.is.searchSelection()&&h.remove.searchTerm(),h.hide(),e.stopPropagation()}},icon:{click:function(e){N=!0,h.has.search()?h.is.active()?h.blurSearch():f.showOnFocus?h.focusSearch():h.toggle():h.toggle(),e.stopPropagation()}},text:{focus:function(e){z=!0,h.focusSearch()}},input:function(e){(h.is.multiple()||h.is.searchSelection())&&h.set.filtered(),clearTimeout(h.timer),h.timer=setTimeout(h.search,f.delay.search)},label:{click:function(e){var t=te(this),n=A.find(w.label),i=n.filter("."+g.active),a=t.nextAll("."+g.active),s=t.prevAll("."+g.active),o=0<a.length?t.nextUntil(a).add(i).add(t):t.prevUntil(s).add(i).add(t);e.shiftKey?(i.removeClass(g.active),o.addClass(g.active)):e.ctrlKey?t.toggleClass(g.active):(i.removeClass(g.active),t.addClass(g.active)),f.onLabelSelect.apply(this,n.filter("."+g.active)),e.stopPropagation()}},remove:{click:function(e){var t=te(this).parent();t.hasClass(g.active)?h.remove.activeLabels():h.remove.activeLabels(t),e.stopPropagation()}},test:{toggle:function(e){var t=h.is.multiple()?h.show:h.toggle;h.is.bubbledLabelClick(e)||h.is.bubbledIconClick(e)||(h.is.multiple()&&(!h.is.multiple()||h.is.active())||(j=!0),h.determine.eventOnElement(e,t)&&e.preventDefault())},touch:function(e){h.determine.eventOnElement(e,function(){"touchstart"==e.type?h.timer=setTimeout(function(){h.hide()},f.delay.touch):"touchmove"==e.type&&clearTimeout(h.timer)}),e.stopPropagation()},hide:function(e){h.determine.eventInModule(e,h.hide)&&H.id&&te(e.target).attr("for")===H.id&&e.preventDefault()}},class:{mutation:function(e){e.forEach(function(e){"class"===e.attributeName&&h.check.disabled()})}},select:{mutation:function(e){h.debug("<select> modified, recreating menu"),h.is.selectMutation(e)&&(h.disconnect.selectObserver(),h.refresh(),h.setup.select(),h.set.selected(),h.observe.select())}},menu:{mutation:function(e){var t=e[0],n=t.addedNodes?te(t.addedNodes[0]):te(!1),i=t.removedNodes?te(t.removedNodes[0]):te(!1),a=n.add(i),s=a.is(w.addition)||0<a.closest(w.addition).length,o=a.is(w.message)||0<a.closest(w.message).length;s||o?(h.debug("Updating item selector cache"),h.refreshItems()):(h.debug("Menu modified, updating selector cache"),h.refresh())},mousedown:function(){F=!0},mouseup:function(){F=!1}},item:{mouseenter:function(e){var t=te(e.target),n=te(this),i=n.children(w.menu),a=n.siblings(w.item).children(w.menu),s=0<i.length;0<i.find(t).length||!s||(clearTimeout(h.itemTimer),h.itemTimer=setTimeout(function(){h.verbose("Showing sub-menu",i),te.each(a,function(){h.animate.hide(!1,te(this))}),h.animate.show(!1,i)},f.delay.show),e.preventDefault())},mouseleave:function(e){var t=te(this).children(w.menu);0<t.length&&(clearTimeout(h.itemTimer),h.itemTimer=setTimeout(function(){h.verbose("Hiding sub-menu",t),h.animate.hide(!1,t)},f.delay.hide))},click:function(e,t){var n=te(this),i=te(e?e.target:""),a=n.find(w.menu),s=h.get.choiceText(n),o=h.get.choiceValue(n,s),r=0<a.length,l=0<a.find(i).length;"input"!==ie.activeElement.tagName.toLowerCase()&&te(ie.activeElement).blur(),l||r&&!f.allowCategorySelection||(h.is.searchSelection()&&(f.allowAdditions&&h.remove.userAddition(),h.remove.searchTerm(),h.is.focusedOnSearch()||1==t||h.focusSearch(!0)),f.useLabels||(h.remove.filteredItem(),h.set.scrollPosition(n)),h.determine.selectAction.call(this,s,o))}},document:{keydown:function(e){var t=e.which;if(h.is.inObject(t,p)){var n=A.find(w.label),i=n.filter("."+g.active),a=(i.data(b.value),n.index(i)),s=n.length,o=0<i.length,r=1<i.length,l=0===a,c=a+1==s,u=h.is.searchSelection(),d=h.is.focusedOnSearch(),v=h.is.focused(),m=d&&0===h.get.caretPosition(!1),f=m&&0!==h.get.caretPosition(!0);if(u&&!o&&!d)return;t==p.leftArrow?!v&&!m||o?o&&(e.shiftKey?h.verbose("Adding previous label to selection"):(h.verbose("Selecting previous label"),n.removeClass(g.active)),l&&!r?i.addClass(g.active):i.prev(w.siblingLabel).addClass(g.active).end(),e.preventDefault()):(h.verbose("Selecting previous label"),n.last().addClass(g.active)):t==p.rightArrow?(v&&!o&&n.first().addClass(g.active),o&&(e.shiftKey?h.verbose("Adding next label to selection"):(h.verbose("Selecting next label"),n.removeClass(g.active)),c?u?d?n.removeClass(g.active):h.focusSearch():r?i.next(w.siblingLabel).addClass(g.active):i.addClass(g.active):i.next(w.siblingLabel).addClass(g.active),e.preventDefault())):t==p.deleteKey||t==p.backspace?o?(h.verbose("Removing active labels"),c&&u&&!d&&h.focusSearch(),i.last().next(w.siblingLabel).addClass(g.active),h.remove.activeLabels(i),e.preventDefault()):!m||f||o||t!=p.backspace||(h.verbose("Removing last label on input backspace"),i=n.last().addClass(g.active),h.remove.activeLabels(i)):i.removeClass(g.active)}}},keydown:function(e){var t=e.which;if(h.is.inObject(t,p)){var n,i=E.not(w.unselectable).filter("."+g.selected).eq(0),a=V.children("."+g.active).eq(0),s=0<i.length?i:a,o=0<s.length?s.siblings(":not(."+g.filtered+")").addBack():V.children(":not(."+g.filtered+")"),r=s.children(w.menu),l=s.closest(w.menu),c=l.hasClass(g.visible)||l.hasClass(g.animating)||0<l.parent(w.menu).length,u=0<r.length,d=0<s.length,v=0<s.not(w.unselectable).length,m=t==p.delimiter&&f.allowAdditions&&h.is.multiple();if(f.allowAdditions&&f.hideAdditions&&(t==p.enter||m)&&v&&(h.verbose("Selecting item from keyboard shortcut",s),h.event.item.click.call(s,e),h.is.searchSelection()&&h.remove.searchTerm(),h.is.multiple()&&e.preventDefault()),h.is.visible()){if(t!=p.enter&&!m||(t==p.enter&&d&&u&&!f.allowCategorySelection?(h.verbose("Pressed enter on unselectable category, opening sub menu"),t=p.rightArrow):v&&(h.verbose("Selecting item from keyboard shortcut",s),h.event.item.click.call(s,e),h.is.searchSelection()&&(h.remove.searchTerm(),h.is.multiple()&&I.focus())),e.preventDefault()),d&&(t==p.leftArrow&&l[0]!==V[0]&&(h.verbose("Left key pressed, closing sub-menu"),h.animate.hide(!1,l),s.removeClass(g.selected),l.closest(w.item).addClass(g.selected),e.preventDefault()),t==p.rightArrow&&u&&(h.verbose("Right key pressed, opening sub-menu"),h.animate.show(!1,r),s.removeClass(g.selected),r.find(w.item).eq(0).addClass(g.selected),e.preventDefault())),t==p.upArrow){if(n=d&&c?s.prevAll(w.item+":not("+w.unselectable+")").eq(0):E.eq(0),o.index(n)<0)return h.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();h.verbose("Up key pressed, changing active item"),s.removeClass(g.selected),n.addClass(g.selected),h.set.scrollPosition(n),f.selectOnKeydown&&h.is.single()&&h.set.selectedItem(n),e.preventDefault()}if(t==p.downArrow){if(0===(n=d&&c?n=s.nextAll(w.item+":not("+w.unselectable+")").eq(0):E.eq(0)).length)return h.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();h.verbose("Down key pressed, changing active item"),E.removeClass(g.selected),n.addClass(g.selected),h.set.scrollPosition(n),f.selectOnKeydown&&h.is.single()&&h.set.selectedItem(n),e.preventDefault()}t==p.pageUp&&(h.scrollPage("up"),e.preventDefault()),t==p.pageDown&&(h.scrollPage("down"),e.preventDefault()),t==p.escape&&(h.verbose("Escape key pressed, closing dropdown"),h.hide())}else m&&e.preventDefault(),t!=p.downArrow||h.is.visible()||(h.verbose("Down key pressed, showing dropdown"),h.show(),e.preventDefault())}else h.has.search()||h.set.selectedLetter(String.fromCharCode(t))}},trigger:{change:function(){var e=k[0];if(e){var t=ie.createEvent("HTMLEvents");h.verbose("Triggering native change event"),t.initEvent("change",!0,!1),e.dispatchEvent(t)}}},determine:{selectAction:function(e,t){d=!0,h.verbose("Determining action",f.action),te.isFunction(h.action[f.action])?(h.verbose("Triggering preset action",f.action,e,t),h.action[f.action].call(H,e,t,this)):te.isFunction(f.action)?(h.verbose("Triggering user action",f.action,e,t),f.action.call(H,e,t,this)):h.error(C.action,f.action),d=!1},eventInModule:function(e,t){var n=te(e.target),i=0<n.closest(ie.documentElement).length,a=0<n.closest(A).length;return t=te.isFunction(t)?t:function(){},i&&!a?(h.verbose("Triggering event",t),t(),!0):(h.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(e,t){var n=te(e.target),i=n.closest(w.siblingLabel),a=ie.body.contains(e.target),s=0===A.find(i).length||!(h.is.multiple()&&f.useLabels),o=0===n.closest(V).length;return t=te.isFunction(t)?t:function(){},a&&s&&o?(h.verbose("Triggering event",t),t(),!0):(h.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(e,t,n){t=t!==ae?t:e,h.can.activate(te(n))&&(h.set.selected(t,te(n)),h.is.multiple()||h.hideAndClear())},select:function(e,t,n){t=t!==ae?t:e,h.can.activate(te(n))&&(h.set.value(t,e,te(n)),h.is.multiple()||h.hideAndClear())},combo:function(e,t,n){t=t!==ae?t:e,h.set.selected(t,te(n)),h.hideAndClear()},hide:function(e,t,n){h.set.value(t,e,te(n)),h.hideAndClear()}},get:{id:function(){return s},defaultText:function(){return A.data(b.defaultText)},defaultValue:function(){return A.data(b.defaultValue)},placeholderText:function(){return"auto"!=f.placeholder&&"string"==typeof f.placeholder?f.placeholder:A.data(b.placeholderText)||""},text:function(){return f.preserveHTML?L.html():L.text()},query:function(){return String(I.val()).trim()},searchWidth:function(e){return e=e!==ae?e:I.val(),D.text(e),Math.ceil(D.width()+1)},selectionCount:function(){var e=h.get.values();return h.is.multiple()?Array.isArray(e)?e.length:0:""!==h.get.value()?1:0},transition:function(e){return"auto"===f.transition?h.is.upward(e)?"slide up":"slide down":f.transition},userValues:function(){var e=h.get.values();return!!e&&(e=Array.isArray(e)?e:[e],te.grep(e,function(e){return!1===h.get.item(e)}))},uniqueArray:function(n){return te.grep(n,function(e,t){return te.inArray(e,n)===t})},caretPosition:function(e){var t,n,i=I.get(0);return e&&"selectionEnd"in i?i.selectionEnd:!e&&"selectionStart"in i?i.selectionStart:ie.selection?(i.focus(),n=(t=ie.selection.createRange()).text.length,e?n:(t.moveStart("character",-i.value.length),t.text.length-n)):void 0},value:function(){var e=0<k.length?k.val():A.data(b.value),t=Array.isArray(e)&&1===e.length&&""===e[0];return e===ae||t?"":e},values:function(e){var t=h.get.value();return""===t?"":!h.has.selectInput()&&h.is.multiple()?"string"==typeof t?(e?t:h.escape.htmlEntities(t)).split(f.delimiter):"":t},remoteValues:function(){var e=h.get.values(),i=!1;return e&&("string"==typeof e&&(e=[e]),te.each(e,function(e,t){var n=h.read.remoteData(t);h.verbose("Restoring value from session data",n,t),n&&((i=i||{})[t]=n)})),i},choiceText:function(e,t){if(t=t!==ae?t:f.preserveHTML,e)return 0<e.find(w.menu).length&&(h.verbose("Retrieving text of element with sub-menu"),(e=e.clone()).find(w.menu).remove(),e.find(w.menuIcon).remove()),e.data(b.text)!==ae?e.data(b.text):t?e.html()&&e.html().trim():e.text()&&e.text().trim()},choiceValue:function(e,t){return t=t||h.get.choiceText(e),!!e&&(e.data(b.value)!==ae?String(e.data(b.value)):"string"==typeof t?String(f.ignoreSearchCase?t.toLowerCase():t).trim():String(t))},inputEvent:function(){var e=I[0];return!!e&&(e.oninput!==ae?"input":e.onpropertychange!==ae?"propertychange":"keyup")},selectValues:function(){var o={},r=[],l=[];return A.find("option").each(function(){var e=te(this),t=e.html(),n=e.attr("disabled"),i=e.attr("value")!==ae?e.attr("value"):t,a=e.data(b.text)!==ae?e.data(b.text):t,s=e.parent("optgroup");"auto"===f.placeholder&&""===i?o.placeholder=t:(s.length===r.length&&s[0]===r[0]||(l.push({type:"header",divider:f.headerDivider,name:s.attr("label")||""}),r=s),l.push({name:t,value:i,text:a,disabled:n}))}),f.placeholder&&"auto"!==f.placeholder&&(h.debug("Setting placeholder value to",f.placeholder),o.placeholder=f.placeholder),f.sortSelect?(!0===f.sortSelect?l.sort(function(e,t){return e.name.localeCompare(t.name)}):"natural"===f.sortSelect?l.sort(function(e,t){return e.name.toLowerCase().localeCompare(t.name.toLowerCase())}):te.isFunction(f.sortSelect)&&l.sort(f.sortSelect),o[c.values]=l,h.debug("Retrieved and sorted values from select",o)):(o[c.values]=l,h.debug("Retrieved values from select",o)),o},activeItem:function(){return E.filter("."+g.active)},selectedItem:function(){var e=E.not(w.unselectable).filter("."+g.selected);return 0<e.length?e:E.eq(0)},itemWithAdditions:function(e){var t=h.get.item(e),n=h.create.userChoice(e);return n&&0<n.length&&(t=0<t.length?t.add(n):n),t},item:function(i,a){var e,s,o=!1;return i=i!==ae?i:h.get.values()!==ae?h.get.values():h.get.text(),e=(s=h.is.multiple()&&Array.isArray(i))?0<i.length:i!==ae&&null!==i,a=""===i||!1===i||!0===i||(a||!1),e&&E.each(function(){var e=te(this),t=h.get.choiceText(e),n=h.get.choiceValue(e,t);if(null!==n&&n!==ae)if(s)-1!==te.inArray(h.escape.htmlEntities(String(n)),i.map(function(e){return String(e)}))&&(o=o?o.add(e):e);else if(a){if(h.verbose("Ambiguous dropdown value using strict type check",e,i),n===i)return o=e,!0}else if(f.ignoreCase&&(n=n.toLowerCase(),i=i.toLowerCase()),h.escape.htmlEntities(String(n))===h.escape.htmlEntities(String(i)))return h.verbose("Found select item by value",n,i),o=e,!0}),o},displayType:function(){return A.hasClass("column")?"flex":f.displayType}},check:{maxSelections:function(e){return!f.maxSelections||((e=e!==ae?e:h.get.selectionCount())>=f.maxSelections?(h.debug("Maximum selection count reached"),f.useLabels&&(E.addClass(g.filtered),h.add.message(v.maxSelections)),!0):(h.verbose("No longer at maximum selection count"),h.remove.message(),h.remove.filteredItem(),h.is.searchSelection()&&h.filterItems(),!1))},disabled:function(){I.attr("tabindex",h.is.disabled()?-1:0)}},restore:{defaults:function(e){h.clear(e),h.restore.defaultText(),h.restore.defaultValue()},defaultText:function(){var e=h.get.defaultText();e===h.get.placeholderText?(h.debug("Restoring default placeholder text",e),h.set.placeholderText(e)):(h.debug("Restoring default text",e),h.set.text(e))},placeholderText:function(){h.set.placeholderText()},defaultValue:function(){var e=h.get.defaultValue();e!==ae&&(h.debug("Restoring default value",e),""!==e?(h.set.value(e),h.set.selected()):(h.remove.activeItem(),h.remove.selectedItem()))},labels:function(){f.allowAdditions&&(f.useLabels||(h.error(C.labels),f.useLabels=!0),h.debug("Restoring selected values"),h.create.userLabels()),h.check.maxSelections()},selected:function(){h.restore.values(),h.is.multiple()?(h.debug("Restoring previously selected values and labels"),h.restore.labels()):h.debug("Restoring previously selected values")},values:function(){h.set.initialLoad(),f.apiSettings&&f.saveRemoteData&&h.get.remoteValues()?h.restore.remoteValues():h.set.selected();var e=h.get.value();!e||""===e||Array.isArray(e)&&0===e.length?k.addClass(g.noselection):k.removeClass(g.noselection),h.remove.initialLoad()},remoteValues:function(){var e=h.get.remoteValues();h.debug("Recreating selected from session data",e),e&&(h.is.single()?te.each(e,function(e,t){h.set.text(t)}):te.each(e,function(e,t){h.add.label(e,t)}))}},read:{remoteData:function(e){var t;if(ne.Storage!==ae)return(t=sessionStorage.getItem(e))!==ae&&t;h.error(C.noStorage)}},save:{defaults:function(){h.save.defaultText(),h.save.placeholderText(),h.save.defaultValue()},defaultValue:function(){var e=h.get.value();h.verbose("Saving default value as",e),A.data(b.defaultValue,e)},defaultText:function(){var e=h.get.text();h.verbose("Saving default text as",e),A.data(b.defaultText,e)},placeholderText:function(){var e;!1!==f.placeholder&&L.hasClass(g.placeholder)&&(e=h.get.text(),h.verbose("Saving placeholder text as",e),A.data(b.placeholderText,e))},remoteData:function(e,t){ne.Storage!==ae?(h.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e)):h.error(C.noStorage)}},clear:function(e){h.is.multiple()&&f.useLabels?h.remove.labels(A.find(w.label),e):(h.remove.activeItem(),h.remove.selectedItem(),h.remove.filteredItem()),h.set.placeholderText(),h.clearValue(e)},clearValue:function(e){h.set.value("",null,null,e)},scrollPage:function(e,t){var n,i,a=t||h.get.selectedItem(),s=a.closest(w.menu),o=s.outerHeight(),r=s.scrollTop(),l=E.eq(0).outerHeight(),c=Math.floor(o/l),u=(s.prop("scrollHeight"),"up"==e?r-l*c:r+l*c),d=E.not(w.unselectable);i="up"==e?d.index(a)-c:d.index(a)+c,0<(n=("up"==e?0<=i:i<d.length)?d.eq(i):"up"==e?d.first():d.last()).length&&(h.debug("Scrolling page",e,n),a.removeClass(g.selected),n.addClass(g.selected),f.selectOnKeydown&&h.is.single()&&h.set.selectedItem(n),s.scrollTop(u))},set:{filtered:function(){var e=h.is.multiple(),t=h.is.searchSelection(),n=e&&t,i=t?h.get.query():"",a="string"==typeof i&&0<i.length,s=h.get.searchWidth(),o=""!==i;e&&a&&(h.verbose("Adjusting input width",s,f.glyphWidth),I.css("width",s)),a||n&&o?(h.verbose("Hiding placeholder text"),L.addClass(g.filtered)):e&&(!n||o)||(h.verbose("Showing placeholder text"),L.removeClass(g.filtered))},empty:function(){A.addClass(g.empty)},loading:function(){A.addClass(g.loading)},placeholderText:function(e){e=e||h.get.placeholderText(),h.debug("Setting placeholder text",e),h.set.text(e),L.addClass(g.placeholder)},tabbable:function(){h.is.searchSelection()?(h.debug("Added tabindex to searchable dropdown"),I.val(""),h.check.disabled(),V.attr("tabindex",-1)):(h.debug("Added tabindex to dropdown"),A.attr("tabindex")===ae&&(A.attr("tabindex",0),V.attr("tabindex",-1)))},initialLoad:function(){h.verbose("Setting initial load"),e=!0},activeItem:function(e){f.allowAdditions&&0<e.filter(w.addition).length?e.addClass(g.filtered):e.addClass(g.active)},partialSearch:function(e){var t=h.get.query().length;I.val(e.substr(0,t))},scrollPosition:function(e,t){var n,i,a,s,o,r;n=(e=e||h.get.selectedItem()).closest(w.menu),i=e&&0<e.length,t=t!==ae&&t,0===h.get.activeItem().length&&(t=!1),e&&0<n.length&&i&&(e.position().top,n.addClass(g.loading),a=(s=n.scrollTop())-n.offset().top+e.offset().top,t||(r=s+n.height()<a+5,o=a-5<s),h.debug("Scrolling to active item",a),(t||o||r)&&n.scrollTop(a),n.removeClass(g.loading))},text:function(e){"combo"===f.action?(h.debug("Changing combo button text",e,R),f.preserveHTML?R.html(e):R.text(e)):"activate"===f.action&&(e!==h.get.placeholderText()&&L.removeClass(g.placeholder),h.debug("Changing text",e,L),L.removeClass(g.filtered),f.preserveHTML?L.html(e):L.text(e))},selectedItem:function(e){var t=h.get.choiceValue(e),n=h.get.choiceText(e,!1),i=h.get.choiceText(e,!0);h.debug("Setting user selection to item",e),h.remove.activeItem(),h.set.partialSearch(n),h.set.activeItem(e),h.set.selected(t,e),h.set.text(i)},selectedLetter:function(e){var t,n=E.filter("."+g.selected),i=0<n.length&&h.has.firstLetter(n,e),a=!1;i&&(t=n.nextAll(E).eq(0),h.has.firstLetter(t,e)&&(a=t)),a||E.each(function(){if(h.has.firstLetter(te(this),e))return a=te(this),!1}),a&&(h.verbose("Scrolling to next value with letter",e),h.set.scrollPosition(a),n.removeClass(g.selected),a.addClass(g.selected),f.selectOnKeydown&&h.is.single()&&h.set.selectedItem(a))},direction:function(e){"auto"==f.direction?(e?h.is.upward(e)&&h.remove.upward(e):h.remove.upward(),h.can.openDownward(e)?h.remove.upward(e):h.set.upward(e),h.is.leftward(e)||h.can.openRightward(e)||h.set.leftward(e)):"upward"==f.direction&&h.set.upward(e)},upward:function(e){(e||A).addClass(g.upward)},leftward:function(e){(e||V).addClass(g.leftward)},value:function(e,t,n,i){e===ae||""===e||Array.isArray(e)&&0===e.length?k.addClass(g.noselection):k.removeClass(g.noselection);var a=h.escape.value(e),s=0<k.length,o=h.get.values(),r=e!==ae?String(e):e;if(s){if(!f.allowReselection&&r==o&&(h.verbose("Skipping value update already same value",e,o),!h.is.initialLoad()))return;h.is.single()&&h.has.selectInput()&&h.can.extendSelect()&&(h.debug("Adding user option",e),h.add.optionValue(e)),h.debug("Updating input value",a,o),P=!0,k.val(a),!1===f.fireOnInit&&h.is.initialLoad()?h.debug("Input native change event ignored on initial load"):!0!==i&&h.trigger.change(),P=!1}else h.verbose("Storing value in metadata",a,k),a!==o&&A.data(b.value,r);!1===f.fireOnInit&&h.is.initialLoad()?h.verbose("No callback on initial load",f.onChange):!0!==i&&f.onChange.call(H,e,t,n)},active:function(){A.addClass(g.active)},multiple:function(){A.addClass(g.multiple)},visible:function(){A.addClass(g.visible)},exactly:function(e,t){h.debug("Setting selected to exact values"),h.clear(),h.set.selected(e,t)},selected:function(e,r,l,c){var u=h.is.multiple();(r=f.allowAdditions?r||h.get.itemWithAdditions(e):r||h.get.item(e))&&(h.debug("Setting selected menu item to",r),h.is.multiple()&&h.remove.searchWidth(),h.is.single()?(h.remove.activeItem(),h.remove.selectedItem()):f.useLabels&&h.remove.selectedItem(),r.each(function(){var e=te(this),t=h.get.choiceText(e),n=h.get.choiceValue(e,t),i=e.hasClass(g.filtered),a=e.hasClass(g.active),s=e.hasClass(g.addition),o=u&&1==r.length;u?!a||s?(f.apiSettings&&f.saveRemoteData&&h.save.remoteData(t,n),f.useLabels?(h.add.label(n,t,o),h.add.value(n,t,e),h.set.activeItem(e),h.filterActive(),h.select.nextAvailable(r)):(h.add.value(n,t,e),h.set.text(h.add.variables(v.count)),h.set.activeItem(e))):i||!f.useLabels&&!d||(h.debug("Selected active value, removing label"),h.remove.selected(n)):(f.apiSettings&&f.saveRemoteData&&h.save.remoteData(t,n),c||h.set.text(t),h.set.value(n,t,e,l),e.addClass(g.active).addClass(g.selected))}),c||h.remove.searchTerm())}},add:{label:function(e,t,n){var i,a=h.is.searchSelection()?I:L,s=h.escape.value(e);f.ignoreCase&&(s=s.toLowerCase()),i=te("<a />").addClass(g.label).attr("data-"+b.value,s).html(y.label(s,t,f.preserveHTML,f.className)),i=f.onLabelCreate.call(i,s,t),h.has.label(e)?h.debug("User selection already exists, skipping",s):(f.label.variation&&i.addClass(f.label.variation),!0===n?(h.debug("Animating in label",i),i.addClass(g.hidden).insertBefore(a).transition({animation:f.label.transition,debug:f.debug,verbose:f.verbose,duration:f.label.duration})):(h.debug("Adding selection label",i),i.insertBefore(a)))},message:function(e){var t=V.children(w.message),n=f.templates.message(h.add.variables(e));0<t.length?t.html(n):t=te("<div/>").html(n).addClass(g.message).appendTo(V)},optionValue:function(e){var t=h.escape.value(e);0<k.find('option[value="'+h.escape.string(t)+'"]').length||(h.disconnect.selectObserver(),h.is.single()&&(h.verbose("Removing previous user addition"),k.find("option."+g.addition).remove()),te("<option/>").prop("value",t).addClass(g.addition).html(e).appendTo(k),h.verbose("Adding user addition as an <option>",e),h.observe.select())},userSuggestion:function(e){var t,n=V.children(w.addition),i=h.get.item(e),a=i&&i.not(w.addition).length,s=0<n.length;f.useLabels&&h.has.maxSelections()||(""===e||a?n.remove():(s?(n.data(b.value,e).data(b.text,e).attr("data-"+b.value,e).attr("data-"+b.text,e).removeClass(g.filtered),f.hideAdditions||(t=f.templates.addition(h.add.variables(v.addResult,e)),n.html(t)),h.verbose("Replacing user suggestion with new value",n)):((n=h.create.userChoice(e)).prependTo(V),h.verbose("Adding item choice to menu corresponding with user choice addition",n)),f.hideAdditions&&!h.is.allFiltered()||n.addClass(g.selected).siblings().removeClass(g.selected),h.refreshItems()))},variables:function(e,t){var n,i,a=-1!==e.search("{count}"),s=-1!==e.search("{maxCount}"),o=-1!==e.search("{term}");return h.verbose("Adding templated variables to message",e),a&&(n=h.get.selectionCount(),e=e.replace("{count}",n)),s&&(n=h.get.selectionCount(),e=e.replace("{maxCount}",f.maxSelections)),o&&(i=t||h.get.query(),e=e.replace("{term}",i)),e},value:function(e,t,n){var i,a=h.get.values(!0);h.has.value(e)?h.debug("Value already selected"):""!==e?(i=Array.isArray(a)?(i=a.concat([e]),h.get.uniqueArray(i)):[e],h.has.selectInput()?h.can.extendSelect()&&(h.debug("Adding value to select",e,i,k),h.add.optionValue(e)):(i=i.join(f.delimiter),h.debug("Setting hidden input to delimited value",i,k)),!1===f.fireOnInit&&h.is.initialLoad()?h.verbose("Skipping onadd callback on initial load",f.onAdd):f.onAdd.call(H,e,t,n),h.set.value(i,t,n),h.check.maxSelections()):h.debug("Cannot select blank values from multiselect")}},remove:{active:function(){A.removeClass(g.active)},activeLabel:function(){A.find(w.label).removeClass(g.active)},empty:function(){A.removeClass(g.empty)},loading:function(){A.removeClass(g.loading)},initialLoad:function(){e=!1},upward:function(e){(e||A).removeClass(g.upward)},leftward:function(e){(e||V).removeClass(g.leftward)},visible:function(){A.removeClass(g.visible)},activeItem:function(){E.removeClass(g.active)},filteredItem:function(){f.useLabels&&h.has.maxSelections()||(f.useLabels&&h.is.multiple()?E.not("."+g.active).removeClass(g.filtered):E.removeClass(g.filtered),f.hideDividers&&M.removeClass(g.hidden),h.remove.empty())},optionValue:function(e){var t=h.escape.value(e),n=k.find('option[value="'+h.escape.string(t)+'"]');0<n.length&&n.hasClass(g.addition)&&(o&&(o.disconnect(),h.verbose("Temporarily disconnecting mutation observer")),n.remove(),h.verbose("Removing user addition as an <option>",t),o&&o.observe(k[0],{childList:!0,subtree:!0}))},message:function(){V.children(w.message).remove()},searchWidth:function(){I.css("width","")},searchTerm:function(){h.verbose("Cleared search term"),I.val(""),h.set.filtered()},userAddition:function(){E.filter(w.addition).remove()},selected:function(e,t,i){if(!(t=f.allowAdditions?t||h.get.itemWithAdditions(e):t||h.get.item(e)))return!1;t.each(function(){var e=te(this),t=h.get.choiceText(e),n=h.get.choiceValue(e,t);h.is.multiple()?f.useLabels?(h.remove.value(n,t,e,i),h.remove.label(n)):(h.remove.value(n,t,e,i),0===h.get.selectionCount()?h.set.placeholderText():h.set.text(h.add.variables(v.count))):h.remove.value(n,t,e,i),e.removeClass(g.filtered).removeClass(g.active),f.useLabels&&e.removeClass(g.selected)})},selectedItem:function(){E.removeClass(g.selected)},value:function(e,t,n,i){var a,s=h.get.values();e=h.escape.htmlEntities(e),h.has.selectInput()?(h.verbose("Input is <select> removing selected option",e),a=h.remove.arrayValue(e,s),h.remove.optionValue(e)):(h.verbose("Removing from delimited values",e),a=(a=h.remove.arrayValue(e,s)).join(f.delimiter)),!1===f.fireOnInit&&h.is.initialLoad()?h.verbose("No callback on initial load",f.onRemove):f.onRemove.call(H,e,t,n),h.set.value(a,t,n,i),h.check.maxSelections()},arrayValue:function(t,e){return Array.isArray(e)||(e=[e]),e=te.grep(e,function(e){return t!=e}),h.verbose("Removed value from delimited string",t,e),e},label:function(e,t){var n=h.escape.value(e),i=A.find(w.label).filter("[data-"+b.value+'="'+h.escape.string(f.ignoreCase?n.toLowerCase():n)+'"]');h.verbose("Removing label",i),i.remove()},activeLabels:function(e){e=e||A.find(w.label).filter("."+g.active),h.verbose("Removing active label selections",e),h.remove.labels(e)},labels:function(e,a){e=e||A.find(w.label),h.verbose("Removing labels",e),e.each(function(){var e=te(this),t=e.data(b.value),n=t!==ae?String(t):t,i=h.is.userValue(n);!1!==f.onLabelRemove.call(e,t)?(h.remove.message(),i?(h.remove.value(n,n,h.get.item(n),a),h.remove.label(n)):h.remove.selected(n,!1,a)):h.debug("Label remove callback cancelled removal")})},tabbable:function(){h.is.searchSelection()?(h.debug("Searchable dropdown initialized"),I.removeAttr("tabindex")):(h.debug("Simple selection dropdown initialized"),A.removeAttr("tabindex")),V.removeAttr("tabindex")},diacritics:function(e){return f.ignoreDiacritics?e.normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}},has:{menuSearch:function(){return h.has.search()&&0<I.closest(V).length},clearItem:function(){return 0<O.length},search:function(){return 0<I.length},sizer:function(){return 0<D.length},selectInput:function(){return k.is("select")},minCharacters:function(e){return f.minCharacters&&!N?(e=e!==ae?String(e):String(h.get.query())).length>=f.minCharacters:!(N=!1)},firstLetter:function(e,t){var n;return!(!e||0===e.length||"string"!=typeof t)&&(n=h.get.choiceText(e,!1),(t=t.toLowerCase())==String(n).charAt(0).toLowerCase())},input:function(){return 0<k.length},items:function(){return 0<E.length},menu:function(){return 0<V.length},subMenu:function(e){return 0<(e||V).find(w.menu).length},message:function(){return 0!==V.children(w.message).length},label:function(e){var t=h.escape.value(e),n=A.find(w.label);return f.ignoreCase&&(t=t.toLowerCase()),0<n.filter("[data-"+b.value+'="'+h.escape.string(t)+'"]').length},maxSelections:function(){return f.maxSelections&&h.get.selectionCount()>=f.maxSelections},allResultsFiltered:function(){var e=E.not(w.addition);return e.filter(w.unselectable).length===e.length},userSuggestion:function(){return 0<V.children(w.addition).length},query:function(){return""!==h.get.query()},value:function(e){return f.ignoreCase?h.has.valueIgnoringCase(e):h.has.valueMatchingCase(e)},valueMatchingCase:function(e){var t=h.get.values(!0);return!!(Array.isArray(t)?t&&-1!==te.inArray(e,t):t==e)},valueIgnoringCase:function(n){var e=h.get.values(!0),i=!1;return Array.isArray(e)||(e=[e]),te.each(e,function(e,t){if(String(n).toLowerCase()==String(t).toLowerCase())return!(i=!0)}),i}},is:{active:function(){return A.hasClass(g.active)},animatingInward:function(){return V.transition("is inward")},animatingOutward:function(){return V.transition("is outward")},bubbledLabelClick:function(e){return te(e.target).is("select, input")&&0<A.closest("label").length},bubbledIconClick:function(e){return 0<te(e.target).closest(q).length},chrome:function(){return!(!ne.chrome||!ne.chrome.webstore&&!ne.chrome.runtime)},alreadySetup:function(){return A.is("select")&&A.parent(w.dropdown).data(S)!==ae&&0===A.prev().length},animating:function(e){return e?e.transition&&e.transition("is animating"):V.transition&&V.transition("is animating")},leftward:function(e){return(e||V).hasClass(g.leftward)},clearable:function(){return A.hasClass(g.clearable)||f.clearable},disabled:function(){return A.hasClass(g.disabled)},focused:function(){return ie.activeElement===A[0]},focusedOnSearch:function(){return ie.activeElement===I[0]},allFiltered:function(){return(h.is.multiple()||h.has.search())&&!(0==f.hideAdditions&&h.has.userSuggestion())&&!h.has.message()&&h.has.allResultsFiltered()},hidden:function(e){return!h.is.visible(e)},initialLoad:function(){return e},inObject:function(n,e){var i=!1;return te.each(e,function(e,t){if(t==n)return i=!0}),i},multiple:function(){return A.hasClass(g.multiple)},remote:function(){return f.apiSettings&&h.can.useAPI()},noApiCache:function(){return f.apiSettings&&!f.apiSettings.cache},single:function(){return!h.is.multiple()},selectMutation:function(e){var n=!1;return te.each(e,function(e,t){if(te(t.target).is("select")||te(t.addedNodes).is("select"))return!(n=!0)}),n},search:function(){return A.hasClass(g.search)},searchSelection:function(){return h.has.search()&&1===I.parent(w.dropdown).length},selection:function(){return A.hasClass(g.selection)},userValue:function(e){return-1!==te.inArray(e,h.get.userValues())},upward:function(e){return(e||A).hasClass(g.upward)},visible:function(e){return e?e.hasClass(g.visible):V.hasClass(g.visible)},verticallyScrollableContext:function(){var e=T.get(0)!==ne&&T.css("overflow-y");return"auto"==e||"scroll"==e},horizontallyScrollableContext:function(){var e=T.get(0)!==ne&&T.css("overflow-X");return"auto"==e||"scroll"==e}},can:{activate:function(e){return!!f.useLabels||(!h.has.maxSelections()||!(!h.has.maxSelections()||!e.hasClass(g.active)))},openDownward:function(e){var t,n,i=e||V,a=!0;return i.addClass(g.loading),n={context:{offset:T.get(0)===ne?{top:0,left:0}:T.offset(),scrollTop:T.scrollTop(),height:T.outerHeight()},menu:{offset:i.offset(),height:i.outerHeight()}},h.is.verticallyScrollableContext()&&(n.menu.offset.top+=n.context.scrollTop),h.has.subMenu(i)&&(n.menu.height+=i.find(w.menu).first().outerHeight()),a=(t={above:n.context.scrollTop<=n.menu.offset.top-n.context.offset.top-n.menu.height,below:n.context.scrollTop+n.context.height>=n.menu.offset.top-n.context.offset.top+n.menu.height}).below?(h.verbose("Dropdown can fit in context downward",t),!0):t.below||t.above?(h.verbose("Dropdown cannot fit below, opening upward",t),!1):(h.verbose("Dropdown cannot fit in either direction, favoring downward",t),!0),i.removeClass(g.loading),a},openRightward:function(e){var t,n,i=e||V,a=!0;return i.addClass(g.loading),n={context:{offset:T.get(0)===ne?{top:0,left:0}:T.offset(),scrollLeft:T.scrollLeft(),width:T.outerWidth()},menu:{offset:i.offset(),width:i.outerWidth()}},h.is.horizontallyScrollableContext()&&(n.menu.offset.left+=n.context.scrollLeft),(t=n.menu.offset.left-n.context.offset.left+n.menu.width>=n.context.scrollLeft+n.context.width)&&(h.verbose("Dropdown cannot fit in context rightward",t),a=!1),i.removeClass(g.loading),a},click:function(){return $||"click"==f.on},extendSelect:function(){return f.allowAdditions||f.apiSettings},show:function(){return!h.is.disabled()&&(h.has.items()||h.has.message())},useAPI:function(){return te.fn.api!==ae}},animate:{show:function(e,t){var n,i=t||V,a=t?function(){}:function(){h.hideSubMenus(),h.hideOthers(),h.set.active()};e=te.isFunction(e)?e:function(){},h.verbose("Doing menu show animation",i),h.set.direction(t),n=f.transition.showMethod||h.get.transition(t),h.is.selection()&&h.set.scrollPosition(h.get.selectedItem(),!0),(h.is.hidden(i)||h.is.animating(i))&&("none"===n?(a(),i.transition({displayType:h.get.displayType()}).transition("show"),e.call(H)):te.fn.transition!==ae&&A.transition("is supported")?i.transition({animation:n+" in",debug:f.debug,verbose:f.verbose,duration:f.transition.showDuration||f.duration,queue:!0,onStart:a,displayType:h.get.displayType(),onComplete:function(){e.call(H)}}):h.error(C.noTransition,n))},hide:function(e,t){var n=t||V,i=t?function(){}:function(){h.can.click()&&h.unbind.intent(),h.remove.active()},a=f.transition.hideMethod||h.get.transition(t);e=te.isFunction(e)?e:function(){},(h.is.visible(n)||h.is.animating(n))&&(h.verbose("Doing menu hide animation",n),"none"===a?(i(),n.transition({displayType:h.get.displayType()}).transition("hide"),e.call(H)):te.fn.transition!==ae&&A.transition("is supported")?n.transition({animation:a+" out",duration:f.transition.hideDuration||f.duration,debug:f.debug,verbose:f.verbose,queue:!1,onStart:i,displayType:h.get.displayType(),onComplete:function(){e.call(H)}}):h.error(C.transition))}},hideAndClear:function(){h.remove.searchTerm(),h.has.maxSelections()||(h.has.search()?h.hide(function(){h.remove.filteredItem()}):h.hide())},delay:{show:function(){h.verbose("Delaying show event to ensure user intent"),clearTimeout(h.timer),h.timer=setTimeout(h.show,f.delay.show)},hide:function(){h.verbose("Delaying hide event to ensure user intent"),clearTimeout(h.timer),h.timer=setTimeout(h.hide,f.delay.hide)}},escape:{value:function(e){var t=Array.isArray(e),n="string"==typeof e,i=!n&&!t,a=n&&-1!==e.search(m.quote),s=[];return i||!a?e:(h.debug("Encoding quote values for use in select",e),t?(te.each(e,function(e,t){s.push(t.replace(m.quote,"&quot;"))}),s):e.replace(m.quote,"&quot;"))},string:function(e){return(e=String(e)).replace(m.escape,"\\$&")},htmlEntities:function(e){var t={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?(e=e.replace(/&(?![a-z0-9#]{1,6};)/,"&amp;")).replace(/[<>"'`]/g,function(e){return t[e]}):e}},setting:function(e,t){if(h.debug("Changing setting",e,t),te.isPlainObject(e))te.extend(!0,f,e);else{if(t===ae)return f[e];te.isPlainObject(f[e])?te.extend(!0,f[e],t):f[e]=t}},internal:function(e,t){if(te.isPlainObject(e))te.extend(!0,h,e);else{if(t===ae)return h[e];h[e]=t}},debug:function(){!f.silent&&f.debug&&(f.performance?h.performance.log(arguments):(h.debug=Function.prototype.bind.call(console.info,console,f.name+":"),h.debug.apply(console,arguments)))},verbose:function(){!f.silent&&f.verbose&&f.debug&&(f.performance?h.performance.log(arguments):(h.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),h.verbose.apply(console,arguments)))},error:function(){f.silent||(h.error=Function.prototype.bind.call(console.error,console,f.name+":"),h.error.apply(console,arguments))},performance:{log:function(e){var t,n;f.performance&&(n=(t=(new Date).getTime())-(G||t),G=t,J.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:H,"Execution Time":n})),clearTimeout(h.performance.timer),h.performance.timer=setTimeout(h.performance.display,500)},display:function(){var e=f.name+":",n=0;G=!1,clearTimeout(h.performance.timer),te.each(J,function(e,t){n+=t["Execution Time"]}),e+=" "+n+"ms",Y&&(e+=" '"+Y+"'"),(console.group!==ae||console.table!==ae)&&0<J.length&&(console.groupCollapsed(e),console.table?console.table(J):te.each(J,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),J=[]}},invoke:function(i,e,t){var a,s,n,o=U;return e=e||ee,t=H||t,"string"==typeof i&&o!==ae&&(i=i.split(/[\. ]/),a=i.length-1,te.each(i,function(e,t){var n=e!=a?t+i[e+1].charAt(0).toUpperCase()+i[e+1].slice(1):i;if(te.isPlainObject(o[n])&&e!=a)o=o[n];else{if(o[n]!==ae)return s=o[n],!1;if(!te.isPlainObject(o[t])||e==a)return o[t]!==ae?s=o[t]:h.error(C.method,i),!1;o=o[t]}})),te.isFunction(s)?n=s.apply(t,e):s!==ae&&(n=s),Array.isArray(K)?K.push(n):K!==ae?K=[K,n]:n!==ae&&(K=n),s}},_?(U===ae&&h.initialize(),h.invoke(Z)):(U!==ae&&U.invoke("destroy"),h.initialize())}),K!==ae?K:W},te.fn.dropdown.settings={silent:!1,debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",values:!1,clearable:!1,apiSettings:!1,selectOnKeydown:!0,minCharacters:0,filterRemoteData:!1,saveRemoteData:!0,throttle:200,context:ne,direction:"auto",keepOnScreen:!0,match:"both",fullTextSearch:!1,ignoreDiacritics:!1,hideDividers:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,forceSelection:!0,allowAdditions:!1,ignoreCase:!1,ignoreSearchCase:!0,hideAdditions:!0,maxSelections:!1,useLabels:!0,delimiter:",",showOnFocus:!0,allowReselection:!1,allowTab:!0,allowCategorySelection:!1,fireOnInit:!1,transition:"auto",duration:200,displayType:!1,glyphWidth:1.037,headerDivider:!0,label:{transition:"scale",duration:200,variation:!1},delay:{hide:300,show:200,search:20,touch:50},onChange:function(e,t,n){},onAdd:function(e,t,n){},onRemove:function(e,t,n){},onSearch:function(e){},onLabelSelect:function(e){},onLabelCreate:function(e,t){return te(this)},onLabelRemove:function(e){return!0},onNoResults:function(e){return!0},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add <b>{term}</b>",count:"{count} selected",maxSelections:"Max {maxCount} selections",noResults:"No results found.",serverError:"There was an error contacting the server"},error:{action:"You called a dropdown action that was not defined",alreadySetup:"Once a select has been initialized behaviors must be called on the created ui dropdown",labels:"Allowing user additions currently requires the use of labels.",missingMultiple:"<select> requires multiple property to be set to correctly preserve multiple values",method:"The method you called is not defined.",noAPI:"The API module is required to load resources remotely",noStorage:"Saving remote data requires session storage",noTransition:"This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>",noNormalize:'"ignoreDiacritics" setting will be ignored. Browser does not support String().normalize(). You may consider including <https://cdn.jsdelivr.net/npm/unorm@1.4.1/lib/unorm.min.js> as a polyfill.'},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s:=@]/g,quote:/"/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholder",text:"text",value:"value"},fields:{remoteValues:"results",values:"values",disabled:"disabled",name:"name",description:"description",descriptionVertical:"descriptionVertical",value:"value",text:"text",type:"type",image:"image",imageClass:"imageClass",icon:"icon",iconClass:"iconClass",class:"class",divider:"divider"},keys:{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40},selector:{addition:".addition",divider:".divider, .header",dropdown:".ui.dropdown",hidden:".hidden",icon:"> .dropdown.icon",input:'> input[type="hidden"], > select',item:".item",label:"> .label",remove:"> .label > .delete.icon",siblingLabel:".label",menu:".menu",message:".message",menuIcon:".dropdown.icon",search:"input.search, .menu > .search > input, .menu input.search",sizer:"> span.sizer",text:"> .text:not(.icon)",unselectable:".disabled, .filtered",clearIcon:"> .remove.icon"},className:{active:"active",addition:"addition",animating:"animating",description:"description",descriptionVertical:"vertical",disabled:"disabled",empty:"empty",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",icon:"icon",image:"image",item:"item",label:"ui label",loading:"loading",menu:"menu",message:"message",multiple:"multiple",placeholder:"default",sizer:"sizer",search:"search",selected:"selected",selection:"selection",text:"text",upward:"upward",leftward:"left",visible:"visible",clearable:"clearable",noselection:"noselection",delete:"delete",header:"header",divider:"divider",groupIcon:"",unfilterable:"unfilterable"}},te.fn.dropdown.settings.templates={deQuote:function(e,t){return String(e).replace(/"/g,t?"&quot;":"")},escape:function(e,t){if(t)return e;var n={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};return/[&<>"'`]/.test(e)?(e=e.replace(/&(?![a-z0-9#]{1,6};)/,"&amp;")).replace(/[<>"'`]/g,function(e){return n[e]}):e},dropdown:function(e,t,n,i){var a=e.placeholder||!1,s="",o=te.fn.dropdown.settings.templates.escape;return s+='<i class="dropdown icon"></i>',s+=a?'<div class="default text">'+o(a,n)+"</div>":'<div class="text"></div>',s+='<div class="'+i.menu+'">',s+=te.fn.dropdown.settings.templates.menu(e,t,n,i),s+="</div>"},menu:function(e,u,d,v){var t=e[u.values]||[],m="",f=te.fn.dropdown.settings.templates.escape,h=te.fn.dropdown.settings.templates.deQuote;return te.each(t,function(e,t){var n=t[u.type]?t[u.type]:"item",i=-1!==n.indexOf("menu");if("item"===n||i){var a=t[u.text]?' data-text="'+h(t[u.text],!0)+'"':"",s=t[u.disabled]?v.disabled+" ":"",o=t[u.descriptionVertical]?v.descriptionVertical+" ":"",r=""!=f(t[u.description]||"",d);m+='<div class="'+s+o+(t[u.class]?h(t[u.class]):v.item)+'" data-value="'+h(t[u.value],!0)+'"'+a+">",i&&(m+='<i class="'+(-1!==n.indexOf("left")?"left":"")+' dropdown icon"></i>'),t[u.image]&&(m+='<img class="'+(t[u.imageClass]?h(t[u.imageClass]):v.image)+'" src="'+h(t[u.image])+'">'),t[u.icon]&&(m+='<i class="'+h(t[u.icon])+" "+(t[u.iconClass]?h(t[u.iconClass]):v.icon)+'"></i>'),r&&(m+='<span class="'+v.description+'">'+f(t[u.description]||"",d)+"</span>",m+=i?"":'<span class="'+v.text+'">'),i&&(m+='<span class="'+v.text+'">'),m+=f(t[u.name]||"",d),i?(m+="</span>",m+='<div class="'+n+'">',m+=te.fn.dropdown.settings.templates.menu(t,u,d,v),m+="</div>"):r&&(m+="</span>"),m+="</div>"}else if("header"===n){var l=f(t[u.name]||"",d),c=t[u.icon]?h(t[u.icon]):v.groupIcon;""===l&&""===c||(m+='<div class="'+(t[u.class]?h(t[u.class]):v.header)+'">',""!==c&&(m+='<i class="'+c+" "+(t[u.iconClass]?h(t[u.iconClass]):v.icon)+'"></i>'),m+=l,m+="</div>"),t[u.divider]&&(m+='<div class="'+v.divider+'"></div>')}}),m},label:function(e,t,n,i){return(0,te.fn.dropdown.settings.templates.escape)(t,n)+'<i class="'+i.delete+' icon"></i>'},message:function(e){return e},addition:function(e){return e}}}(jQuery,window,document);