wishthis/node_modules/fomantic-ui/dist/components/dropdown.min.js
2022-04-08 12:55:35 +02:00

11 lines
No EOL
58 KiB
JavaScript

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