UNPKG

@kingfrank/vue-tags-input

Version:

A Vue 3 tags input autocomplete component with mix-mode support.

823 lines 92.5 kB
import { ref as it, onMounted as bt, onBeforeMount as wt, createElementBlock as yt, openBlock as Tt } from "vue"; var nt = "&#8203;"; function X(t, e) { (e == null || e > t.length) && (e = t.length); for (var i = 0, n = new Array(e); i < e; i++) n[i] = t[i]; return n; } function st(t) { return function(e) { if (Array.isArray(e)) return X(e); }(t) || function(e) { if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e); }(t) || function(e, i) { if (e) { if (typeof e == "string") return X(e, i); var n = Object.prototype.toString.call(e).slice(8, -1); if (n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return X(e, i); } }(t) || function() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); } var C = { isEnabled: function() { var t; return (t = window.TAGIFY_DEBUG) === null || t === void 0 || t; }, log: function() { for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++) e[i] = arguments[i]; var n; this.isEnabled() && (n = console).log.apply(n, ["[Tagify]:"].concat(st(e))); }, warn: function() { for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++) e[i] = arguments[i]; var n; this.isEnabled() && (n = console).warn.apply(n, ["[Tagify]:"].concat(st(e))); } }, H = function(t, e, i, n) { return t = "" + t, e = "" + e, n && (t = t.trim(), e = e.trim()), i ? t == e : t.toLowerCase() == e.toLowerCase(); }, at = function(t, e) { return t && Array.isArray(t) && t.map(function(i) { return tt(i, e); }); }; function tt(t, e) { var i, n = {}; for (i in t) e.indexOf(i) < 0 && (n[i] = t[i]); return n; } function J(t) { return new DOMParser().parseFromString(t.trim(), "text/html").body.firstElementChild; } function ot(t, e) { for (e = e || "previous"; t = t[e + "Sibling"]; ) if (t.nodeType == 3) return t; } function P(t) { return typeof t == "string" ? t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/`|'/g, "&#039;") : t; } function E(t) { var e = Object.prototype.toString.call(t).split(" ")[1].slice(0, -1); return t === Object(t) && e != "Array" && e != "Function" && e != "RegExp" && e != "HTMLUnknownElement"; } function w(t, e, i) { var n, s; function a(o, r) { for (var l in r) if (r.hasOwnProperty(l)) { if (E(r[l])) { E(o[l]) ? a(o[l], r[l]) : o[l] = Object.assign({}, r[l]); continue; } if (Array.isArray(r[l])) { o[l] = Object.assign([], r[l]); continue; } o[l] = r[l]; } } return n = t, ((s = Object) != null && typeof Symbol < "u" && s[Symbol.hasInstance] ? s[Symbol.hasInstance](n) : n instanceof s) || (t = {}), a(t, e), i && a(t, i), t; } function rt() { var t = [], e = {}, i = !0, n = !1, s = void 0; try { for (var a, o = arguments[Symbol.iterator](); !(i = (a = o.next()).done); i = !0) { var r = a.value, l = !0, d = !1, u = void 0; try { for (var c, g = r[Symbol.iterator](); !(l = (c = g.next()).done); l = !0) { var p = c.value; E(p) ? e[p.value] || (t.push(p), e[p.value] = 1) : t.includes(p) || t.push(p); } } catch (h) { d = !0, u = h; } finally { try { l || g.return == null || g.return(); } finally { if (d) throw u; } } } } catch (h) { n = !0, s = h; } finally { try { i || o.return == null || o.return(); } finally { if (n) throw s; } } return t; } function W(t) { return String.prototype.normalize ? typeof t == "string" ? t.normalize("NFD").replace(/[\u0300-\u036f]/g, "") : void 0 : t; } var lt = function() { return /(?=.*chrome)(?=.*android)/i.test(navigator.userAgent); }; function dt() { return ("10000000-1000-4000-8000" + -1e11).replace(/[018]/g, function(t) { return (t ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> t / 4).toString(16); }); } function j(t) { var e, i = ft.call(this, t), n = t == null || (e = t.classList) === null || e === void 0 ? void 0 : e.contains(this.settings.classNames.tag); return i && n; } function ut(t) { return ft.call(this, t) && t?.closest(this.settings.classNames.tagSelector); } function ft(t) { var e; return (t == null || (e = t.closest) === null || e === void 0 ? void 0 : e.call(t, this.settings.classNames.namespaceSelector)) === this.DOM.scope; } function mt(t, e) { var i = window.getSelection(); return e = e || i.getRangeAt(0), typeof t == "string" && (t = document.createTextNode(t)), e && (e.deleteContents(), e.insertNode(t)), t; } function v(t, e, i) { return t ? (e && (t.__tagifyTagData = i ? e : w({}, t.__tagifyTagData || {}, e)), t.__tagifyTagData) : (C.warn("tag element doesn't exist", { tagElm: t, data: e }), e); } function A(t) { if (t && t.parentNode) { var e = t, i = window.getSelection(), n = i.getRangeAt(0); i.rangeCount && (n.setStartAfter(e), n.collapse(!0), i.removeAllRanges(), i.addRange(n)); } } function vt(t, e) { t.forEach(function(i) { if (v(i.previousSibling) || !i.previousSibling) { var n = document.createTextNode("​"); i.before(n), e && A(n); } }); } var G = { delimiters: ",", pattern: null, tagTextProp: "value", maxTags: 1 / 0, callbacks: {}, addTagOnBlur: !0, addTagOn: ["blur", "tab", "enter"], onChangeAfterBlur: !0, duplicates: !1, whitelist: [], blacklist: [], enforceWhitelist: !1, userInput: !0, focusable: !0, focusInputOnRemove: !0, keepInvalidTags: !1, createInvalidTags: !0, mixTagsAllowedAfter: /,|\.|\:|\s/, mixTagsInterpolator: ["[[", "]]"], backspace: !0, skipInvalid: !1, pasteAsTags: !0, editTags: { clicks: 2, keepInvalid: !0 }, transformTag: function() { }, trim: !0, a11y: { focusableTags: !1 }, mixMode: { insertAfterTag: " " }, autoComplete: { enabled: !0, rightKey: !1, tabKey: !1 }, classNames: { namespace: "tagify", mixMode: "tagify--mix", selectMode: "tagify--select", input: "tagify__input", focus: "tagify--focus", tagNoAnimation: "tagify--noAnim", tagInvalid: "tagify--invalid", tagNotAllowed: "tagify--notAllowed", scopeLoading: "tagify--loading", hasMaxTags: "tagify--hasMaxTags", hasNoTags: "tagify--noTags", empty: "tagify--empty", inputInvalid: "tagify__input--invalid", dropdown: "tagify__dropdown", dropdownWrapper: "tagify__dropdown__wrapper", dropdownHeader: "tagify__dropdown__header", dropdownFooter: "tagify__dropdown__footer", dropdownItem: "tagify__dropdown__item", dropdownItemActive: "tagify__dropdown__item--active", dropdownItemHidden: "tagify__dropdown__item--hidden", dropdownItemSelected: "tagify__dropdown__item--selected", dropdownInital: "tagify__dropdown--initial", tag: "tagify__tag", tagText: "tagify__tag-text", tagX: "tagify__tag__removeBtn", tagLoading: "tagify__tag--loading", tagEditing: "tagify__tag--editable", tagFlash: "tagify__tag--flash", tagHide: "tagify__tag--hide" }, dropdown: { classname: "", enabled: 2, maxItems: 10, searchKeys: ["value", "searchBy"], fuzzySearch: !0, caseSensitive: !1, accentedSearch: !0, includeSelectedTags: !1, escapeHTML: !0, highlightFirst: !0, closeOnSelect: !0, clearOnSelect: !0, position: "all", appendTarget: null }, hooks: { beforeRemoveTag: function() { return Promise.resolve(); }, beforePaste: function() { return Promise.resolve(); }, suggestionClick: function() { return Promise.resolve(); }, beforeKeyDown: function() { return Promise.resolve(); } } }; function Ot(t, e, i) { return e in t ? Object.defineProperty(t, e, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = i, t; } function xt(t) { for (var e = 1; e < arguments.length; e++) { var i = arguments[e] != null ? arguments[e] : {}, n = Object.keys(i); typeof Object.getOwnPropertySymbols == "function" && (n = n.concat(Object.getOwnPropertySymbols(i).filter(function(s) { return Object.getOwnPropertyDescriptor(i, s).enumerable; }))), n.forEach(function(s) { Ot(t, s, i[s]); }); } return t; } function Dt(t, e) { return e = e ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(e)) : function(i, n) { var s = Object.keys(i); if (Object.getOwnPropertySymbols) { var a = Object.getOwnPropertySymbols(i); s.push.apply(s, a); } return s; }(Object(e)).forEach(function(i) { Object.defineProperty(t, i, Object.getOwnPropertyDescriptor(e, i)); }), t; } function $(t, e) { (e == null || e > t.length) && (e = t.length); for (var i = 0, n = new Array(e); i < e; i++) n[i] = t[i]; return n; } function St(t, e, i) { return e in t ? Object.defineProperty(t, e, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = i, t; } function It(t) { return function(e) { if (Array.isArray(e)) return $(e); }(t) || function(e) { if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e); }(t) || function(e, i) { if (e) { if (typeof e == "string") return $(e, i); var n = Object.prototype.toString.call(e).slice(8, -1); if (n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return $(e, i); } }(t) || function() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); } function Mt() { for (var t in this.dropdown = {}, this._dropdown) this.dropdown[t] = typeof this._dropdown[t] == "function" ? this._dropdown[t].bind(this) : this._dropdown[t]; this.dropdown.refs(), this.DOM.dropdown.__tagify = this; } var q, R, Et = (q = function(t) { for (var e = 1; e < arguments.length; e++) { var i = arguments[e] != null ? arguments[e] : {}, n = Object.keys(i); typeof Object.getOwnPropertySymbols == "function" && (n = n.concat(Object.getOwnPropertySymbols(i).filter(function(s) { return Object.getOwnPropertyDescriptor(i, s).enumerable; }))), n.forEach(function(s) { St(t, s, i[s]); }); } return t; }({}, { events: { binding: function() { var t = !(arguments.length > 0 && arguments[0] !== void 0) || arguments[0], e = this.dropdown.events.callbacks, i = this.listeners.dropdown = this.listeners.dropdown || { position: this.dropdown.position.bind(this, null), onKeyDown: e.onKeyDown.bind(this), onMouseOver: e.onMouseOver.bind(this), onMouseLeave: e.onMouseLeave.bind(this), onClick: e.onClick.bind(this), onScroll: e.onScroll.bind(this) }, n = t ? "addEventListener" : "removeEventListener"; this.settings.dropdown.position != "manual" && (document[n]("scroll", i.position, !0), window[n]("resize", i.position), window[n]("keydown", i.onKeyDown)), this.DOM.dropdown[n]("mouseover", i.onMouseOver), this.DOM.dropdown[n]("mouseleave", i.onMouseLeave), this.DOM.dropdown[n]("mousedown", i.onClick), this.DOM.dropdown.content[n]("scroll", i.onScroll); }, callbacks: { onKeyDown: function(t) { var e = this; if (this.state.hasFocus && !this.state.composing) { var i = this.settings, n = i.dropdown.includeSelectedTags, s = this.DOM.dropdown.querySelector(i.classNames.dropdownItemActiveSelector), a = this.dropdown.getSuggestionDataByNode(s), o = i.mode == "mix", r = i.mode == "select"; i.hooks.beforeKeyDown(t, { tagify: this }).then(function(l) { switch (t.key) { case "ArrowDown": case "ArrowUp": case "Down": case "Up": t.preventDefault(); var d = e.dropdown.getAllSuggestionsRefs(), u = t.key == "ArrowUp" || t.key == "Up"; s && (s = e.dropdown.getNextOrPrevOption(s, !u)), s && s.matches(i.classNames.dropdownItemSelector) || (s = d[u ? d.length - 1 : 0]), e.dropdown.highlightOption(s, !0); break; case "PageUp": case "PageDown": var c; t.preventDefault(); var g = e.dropdown.getAllSuggestionsRefs(), p = Math.floor(e.DOM.dropdown.content.clientHeight / ((c = g[0]) === null || c === void 0 ? void 0 : c.offsetHeight)) || 1, h = t.key === "PageUp"; if (s) { var f = g.indexOf(s), m = h ? Math.max(0, f - p) : Math.min(g.length - 1, f + p); s = g[m]; } else s = g[0]; e.dropdown.highlightOption(s, !0); break; case "Home": case "End": t.preventDefault(); var y = e.dropdown.getAllSuggestionsRefs(); s = y[t.key === "Home" ? 0 : y.length - 1], e.dropdown.highlightOption(s, !0); break; case "Escape": case "Esc": e.dropdown.hide(); break; case "ArrowRight": if (e.state.actions.ArrowLeft || i.autoComplete.rightKey) return; case "Tab": var D = !i.autoComplete.rightKey || !i.autoComplete.tabKey; if (!o && !r && s && D && !e.state.editing && a) { t.preventDefault(); var S = e.dropdown.getMappedValue(a); return e.state.autoCompleteData = a, e.input.autocomplete.set.call(e, S), !1; } return !0; case "Enter": t.preventDefault(), e.state.actions.selectOption = !0, setTimeout(function() { return e.state.actions.selectOption = !1; }, 100), i.hooks.suggestionClick(t, { tagify: e, tagData: a, suggestionElm: s }).then(function() { if (s) { var b = n ? s : e.dropdown.getNextOrPrevOption(s, !u); e.dropdown.selectOption(s, t, function() { if (b) { var _ = b.getAttribute("value"); b = e.dropdown.getSuggestionNodeByValue(_), e.dropdown.highlightOption(b); } }); } else e.dropdown.hide(), o || e.addTags(e.state.inputText.trim(), !0); }).catch(function(b) { return C.warn(b); }); break; case "Backspace": if (o || e.state.editing.scope) return; var I = e.input.raw.call(e); I != "" && I.charCodeAt(0) != 8203 || (i.backspace === !0 ? e.removeTags() : i.backspace == "edit" && setTimeout(e.editTag.bind(e), 0)); } }); } }, onMouseOver: function(t) { var e = t.target.closest(this.settings.classNames.dropdownItemSelector); this.dropdown.highlightOption(e); }, onMouseLeave: function(t) { this.dropdown.highlightOption(); }, onClick: function(t) { var e = this; if (t.button == 0 && t.target != this.DOM.dropdown && t.target != this.DOM.dropdown.content) { var i = t.target.closest(this.settings.classNames.dropdownItemSelector), n = this.dropdown.getSuggestionDataByNode(i); this.state.actions.selectOption = !0, setTimeout(function() { return e.state.actions.selectOption = !1; }, 100), this.settings.hooks.suggestionClick(t, { tagify: this, tagData: n, suggestionElm: i }).then(function() { i ? e.dropdown.selectOption(i, t) : e.dropdown.hide(); }).catch(function(s) { return C.warn(s); }); } }, onScroll: function(t) { var e = t.target, i = e.scrollTop / (e.scrollHeight - e.parentNode.clientHeight) * 100; this.trigger("dropdown:scroll", { percentage: Math.round(i) }); } } }, refilter: function(t) { t = t || this.state.dropdown.query || "", this.suggestedListItems = this.dropdown.filterListItems(t), this.dropdown.fill(), this.suggestedListItems.length || this.dropdown.hide(), this.trigger("dropdown:updated", this.DOM.dropdown); }, getSuggestionDataByNode: function(t) { for (var e, i = t && t.getAttribute("value"), n = this.suggestedListItems.length; n--; ) { if (E(e = this.suggestedListItems[n]) && e.value == i) return e; if (e == i) return { value: e }; } }, getSuggestionNodeByValue: function(t) { return this.dropdown.getAllSuggestionsRefs().find(function(e) { return e.getAttribute("value") === t; }); }, getNextOrPrevOption: function(t) { var e = !(arguments.length > 1 && arguments[1] !== void 0) || arguments[1], i = this.dropdown.getAllSuggestionsRefs(), n = i.findIndex(function(s) { return s === t; }); return e ? i[n + 1] : i[n - 1]; }, highlightOption: function(t, e) { var i, n = this.settings.classNames.dropdownItemActive; if (this.state.ddItemElm && (this.state.ddItemElm.classList.remove(n), this.state.ddItemElm.removeAttribute("aria-selected")), !t) return this.state.ddItemData = null, this.state.ddItemElm = null, void this.input.autocomplete.suggest.call(this); i = this.dropdown.getSuggestionDataByNode(t), this.state.ddItemData = i, this.state.ddItemElm = t, t.classList.add(n), t.setAttribute("aria-selected", !0), e && (t.parentNode.scrollTop = t.clientHeight + t.offsetTop - t.parentNode.clientHeight), this.settings.autoComplete && (this.input.autocomplete.suggest.call(this, i), this.dropdown.position()); }, selectOption: function(t, e, i) { var n = this, s = this.settings, a = s.dropdown.includeSelectedTags, o = s.dropdown, r = o.clearOnSelect, l = o.closeOnSelect; if (!t) return this.addTags(this.state.inputText, !0), void (l && this.dropdown.hide()); e = e || {}; var d = t.getAttribute("value"), u = d == "noMatch", c = s.mode == "mix", g = this.suggestedListItems.find(function(h) { var f; return ((f = h.value) !== null && f !== void 0 ? f : h) == d; }); if (this.trigger("dropdown:select", { data: g, elm: t, event: e }), g || u) { if (this.state.editing) { var p = this.normalizeTags([g])[0]; g = s.transformTag.call(this, p) || p, this.onEditTagDone(null, w({ __isValid: !0 }, g)); } else this[c ? "addMixTags" : "addTags"]([g || this.input.raw.call(this)], r); (c || this.DOM.input.parentNode) && (setTimeout(function() { n.DOM.input.focus(), n.toggleFocusClass(!0); }), l && setTimeout(this.dropdown.hide.bind(this)), a ? i && i() : (t.addEventListener("transitionend", function() { n.dropdown.fillHeaderFooter(), setTimeout(function() { t.remove(), n.dropdown.refilter(), i && i(); }, 100); }, { once: !0 }), t.classList.add(this.settings.classNames.dropdownItemHidden))); } else l && setTimeout(this.dropdown.hide.bind(this)); }, selectAll: function(t) { this.suggestedListItems.length = 0, this.dropdown.hide(), this.dropdown.filterListItems(""); var e = this.dropdown.filterListItems(""); return t || (e = this.state.dropdown.suggestions), this.addTags(e, !0), this; }, filterListItems: function(t, e) { var i, n, s, a, o, r, l = function() { var b, _, k = void 0, L = void 0; b = h[S], n = ((_ = Object) != null && typeof Symbol < "u" && _[Symbol.hasInstance] ? _[Symbol.hasInstance](b) : b instanceof _) ? h[S] : { value: h[S] }; var T, O = Object.keys(n).some(function(x) { return D.includes(x); }) ? D : ["value"]; c.fuzzySearch && !e.exact ? (a = O.reduce(function(x, M) { return x + " " + (n[M] || ""); }, "").toLowerCase().trim(), c.accentedSearch && (a = W(a), r = W(r)), k = a.indexOf(r) == 0, L = a === r, T = a, s = r.toLowerCase().split(" ").every(function(x) { return T.includes(x.toLowerCase()); })) : (k = !0, s = O.some(function(x) { var M = "" + (n[x] || ""); return c.accentedSearch && (M = W(M), r = W(r)), c.caseSensitive || (M = M.toLowerCase()), L = M === r, e.exact ? M === r : M.indexOf(r) == 0; })), o = !c.includeSelectedTags && i.isTagDuplicate(E(n) ? n.value : n), s && !o && (L && k ? p.push(n) : c.sortby == "startsWith" && k ? g.unshift(n) : g.push(n)); }, d = this, u = this.settings, c = u.dropdown, g = (e = e || {}, []), p = [], h = u.whitelist, f = c.maxItems >= 0 ? c.maxItems : 1 / 0, m = c.includeSelectedTags, y = typeof c.sortby == "function", D = c.searchKeys, S = 0; if (!(t = u.mode == "select" && this.value.length && this.value[0][u.tagTextProp] == t ? "" : t) || !D.length) { g = m ? h : h.filter(function(b) { return !d.isTagDuplicate(E(b) ? b.value : b); }); var I = y ? c.sortby(g, r) : g.slice(0, f); return this.state.dropdown.suggestions = I, I; } for (r = c.caseSensitive ? "" + t : ("" + t).toLowerCase(); S < h.length; S++) i = this, l(); return this.state.dropdown.suggestions = p.concat(g), I = y ? c.sortby(p.concat(g), r) : p.concat(g).slice(0, f), this.state.dropdown.suggestions = I, I; }, getMappedValue: function(t) { var e = this.settings.dropdown.mapValueTo; return e ? typeof e == "function" ? e(t) : t[e] || t.value : t.value; }, createListHTML: function(t) { var e = this; return w([], t).map(function(i, n) { typeof i != "string" && typeof i != "number" || (i = { value: i }); var s = e.dropdown.getMappedValue(i); return s = typeof s == "string" && e.settings.dropdown.escapeHTML ? P(s) : s, e.settings.templates.dropdownItem.apply(e, [Dt(xt({}, i), { mappedValue: s }), e]); }).join(""); } }), R = (R = { refs: function() { this.DOM.dropdown = this.parseTemplate("dropdown", [this.settings]), this.DOM.dropdown.content = this.DOM.dropdown.querySelector("[data-selector='tagify-suggestions-wrapper']"); }, getHeaderRef: function() { return this.DOM.dropdown.querySelector("[data-selector='tagify-suggestions-header']"); }, getFooterRef: function() { return this.DOM.dropdown.querySelector("[data-selector='tagify-suggestions-footer']"); }, getAllSuggestionsRefs: function() { return It(this.DOM.dropdown.content.querySelectorAll(this.settings.classNames.dropdownItemSelector)); }, show: function(t) { var e, i, n, s = this, a = this.settings, o = a.mode == "mix" && !a.enforceWhitelist, r = !a.whitelist || !a.whitelist.length, l = a.dropdown.position == "manual"; if (t = t === void 0 ? this.state.inputText : t, !(r && !o && !a.templates.dropdownItemNoMatch || a.dropdown.enabled === !1 || this.state.isLoading || this.settings.readonly)) { if (clearTimeout(this.dropdownHide__bindEventsTimeout), this.suggestedListItems = this.dropdown.filterListItems(t), t && !this.suggestedListItems.length && (this.trigger("dropdown:noMatch", t), a.templates.dropdownItemNoMatch && (n = a.templates.dropdownItemNoMatch.call(this, { value: t }))), !n) { if (this.suggestedListItems.length) t && o && !this.state.editing.scope && !H(this.suggestedListItems[0].value, t) && this.suggestedListItems.unshift({ value: t }); else { if (!t || !o || this.state.editing.scope) return this.input.autocomplete.suggest.call(this), void this.dropdown.hide(); this.suggestedListItems = [{ value: t }]; } i = "" + (E(e = this.suggestedListItems[0]) ? e.value : e), a.autoComplete && i && i.indexOf(t) == 0 && this.input.autocomplete.suggest.call(this, e); } this.dropdown.fill(n), a.dropdown.highlightFirst && this.dropdown.highlightOption(this.DOM.dropdown.content.querySelector(a.classNames.dropdownItemSelector)), this.state.dropdown.visible || setTimeout(this.dropdown.events.binding.bind(this)), this.state.dropdown.visible = t || !0, this.state.dropdown.query = t, this.setStateSelection(), l || setTimeout(function() { s.dropdown.position(), s.dropdown.render(); }), setTimeout(function() { s.trigger("dropdown:show", s.DOM.dropdown); }); } }, hide: function(t) { var e = this, i = this.DOM, n = i.scope, s = i.dropdown, a = this.settings.dropdown.position == "manual" && !t; if (s && document.body.contains(s) && !a) return window.removeEventListener("resize", this.dropdown.position), this.dropdown.events.binding.call(this, !1), n.setAttribute("aria-expanded", !1), s.parentNode.removeChild(s), setTimeout(function() { e.state.dropdown.visible = !1; }, 100), this.state.dropdown.query = this.state.ddItemData = this.state.ddItemElm = this.state.selection = null, this.state.tag && this.state.tag.value.length && (this.state.flaggedTags[this.state.tag.baseOffset] = this.state.tag), this.trigger("dropdown:hide", s), this; }, toggle: function(t) { this.dropdown[this.state.dropdown.visible && !t ? "hide" : "show"](); }, getAppendTarget: function() { var t = this.settings.dropdown; return typeof t.appendTarget == "function" ? t.appendTarget() : t.appendTarget; }, render: function() { var t, e, i, n = this, s = (t = this.DOM.dropdown, (i = t.cloneNode(!0)).style.cssText = "position:fixed; top:-9999px; opacity:0", document.body.appendChild(i), e = i.clientHeight, i.parentNode.removeChild(i), e), a = this.settings, o = this.dropdown.getAppendTarget(); return a.dropdown.enabled === !1 || (this.DOM.scope.setAttribute("aria-expanded", !0), document.body.contains(this.DOM.dropdown) || (this.DOM.dropdown.classList.add(a.classNames.dropdownInital), this.dropdown.position(s), o.appendChild(this.DOM.dropdown), setTimeout(function() { return n.DOM.dropdown.classList.remove(a.classNames.dropdownInital); }))), this; }, fill: function(t) { t = typeof t == "string" ? t : this.dropdown.createListHTML(t || this.suggestedListItems); var e, i = this.settings.templates.dropdownContent.call(this, t); this.DOM.dropdown.content.innerHTML = (e = i) ? e.replace(/\>[\r\n ]+\</g, "><").split(/>\s+</).join("><").trim() : ""; }, fillHeaderFooter: function() { var t = this.dropdown.filterListItems(this.state.dropdown.query), e = this.parseTemplate("dropdownHeader", [t]), i = this.parseTemplate("dropdownFooter", [t]), n = this.dropdown.getHeaderRef(), s = this.dropdown.getFooterRef(); e && n?.parentNode.replaceChild(e, n), i && s?.parentNode.replaceChild(i, s); }, position: function(t) { var e = this.settings.dropdown, i = this.dropdown.getAppendTarget(); if (e.position != "manual" && i) { var n, s, a, o, r, l, d, u, c, g, p = this.DOM.dropdown, h = e.RTL, f = i === document.body, m = i === this.DOM.scope, y = f ? window.pageYOffset : i.scrollTop, D = document.fullscreenElement || document.webkitFullscreenElement || document.documentElement, S = D.clientHeight, I = Math.max(D.clientWidth || 0, window.innerWidth || 0), b = I > 480 ? e.position : "all", _ = this.DOM[b == "input" ? "input" : "scope"]; if (t = t || p.clientHeight, this.state.dropdown.visible) { if (b == "text" ? (a = (n = function() { var T = document.getSelection(); if (T.rangeCount) { var O, x, M = T.getRangeAt(0), B = M.startContainer, z = M.startOffset; if (z > 0) return (x = document.createRange()).setStart(B, z - 1), x.setEnd(B, z), { left: (O = x.getBoundingClientRect()).right, top: O.top, bottom: O.bottom }; if (B.getBoundingClientRect) return B.getBoundingClientRect(); } return { left: -9999, top: -9999 }; }()).bottom, s = n.top, o = n.left, r = "auto") : (l = function(T) { var O = 0, x = 0; for (T = T.parentNode; T && T != D; ) O += T.offsetTop || 0, x += T.offsetLeft || 0, T = T.parentNode; return { top: O, left: x }; }(i), n = _.getBoundingClientRect(), s = m ? -1 : n.top - l.top, a = (m ? n.height : n.bottom - l.top) - 1, o = m ? -1 : n.left - l.left, r = n.width + "px"), !f) { var k = function() { for (var T = 0, O = e.appendTarget.parentNode; O; ) T += O.scrollTop || 0, O = O.parentNode; return T; }(); s += k, a += k; } var L; s = Math.floor(s), a = Math.ceil(a), u = I - o < 120, c = ((d = (L = e.placeAbove) !== null && L !== void 0 ? L : S - n.bottom < t) ? s : a) + y, g = o + (h && n.width || 0) + window.pageXOffset, g = b == "text" && u ? "right: 0;" : "left: ".concat(g, "px;"), p.style.cssText = "".concat(g, " top: ").concat(c, "px; min-width: ").concat(r, "; max-width: ").concat(r), p.setAttribute("placement", d ? "top" : "bottom"), p.setAttribute("position", b); } } } }) != null ? R : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(q, Object.getOwnPropertyDescriptors(R)) : function(t, e) { var i = Object.keys(t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(t); i.push.apply(i, n); } return i; }(Object(R)).forEach(function(t) { Object.defineProperty(q, t, Object.getOwnPropertyDescriptor(R, t)); }), q), F = "@yaireo/tagify/", Nt = { empty: "empty", exceed: "number of tags exceeded", pattern: "pattern mismatch", duplicate: "already exists", notAllowed: "not allowed" }, _t = { wrapper: function(t, e) { return '<tags class="'.concat(e.classNames.namespace, " ").concat(e.mode ? "".concat(e.classNames[e.mode + "Mode"]) : "", " ").concat(t.className, `" `).concat(e.readonly ? "readonly" : "", ` `).concat(e.disabled ? "disabled" : "", ` `).concat(e.required ? "required" : "", ` `).concat(e.mode === "select" ? "spellcheck='false'" : "", ` tabIndex="-1"> `).concat(this.settings.templates.input.call(this), ` `).concat(nt, ` </tags>`); }, input: function() { var t = this.settings, e = t.placeholder || nt; return "<span ".concat(!t.readonly && t.userInput ? "contenteditable" : "", ' data-can-editable tabIndex="0" data-placeholder="').concat(e, '" aria-placeholder="').concat(t.placeholder || "", `" class="`).concat(t.classNames.input, `" role="textbox" autocapitalize="false" autocorrect="off" aria-autocomplete="both" aria-multiline="`).concat(t.mode == "mix", '"></span>'); }, tag: function(t, e) { var i = e.settings; return '<tag title="'.concat(t.title || t.value, `" contenteditable='false' tabIndex="`).concat(i.a11y.focusableTags ? 0 : -1, `" class="`).concat(i.classNames.tag, " ").concat(t.class || "", `" `).concat(this.getAttributes(t), `> <x title='' tabIndex="`).concat(i.a11y.focusableTags ? 0 : -1, '" class="').concat(i.classNames.tagX, `" role='button' aria-label='remove tag'></x> <div> <span `).concat(i.mode === "select" && i.userInput ? "contenteditable='true'" : "", ` autocapitalize="false" autocorrect="off" spellcheck='false' class="`).concat(i.classNames.tagText, '">').concat(t[i.tagTextProp] || t.value, `</span> </div> </tag>`); }, dropdown: function(t) { var e = t.dropdown, i = e.position == "manual"; return '<div class="'.concat(i ? "" : t.classNames.dropdown, " ").concat(e.classname, '" role="listbox" aria-labelledby="dropdown" dir="').concat(e.RTL ? "rtl" : "", `"> <div data-selector='tagify-suggestions-wrapper' class="`).concat(t.classNames.dropdownWrapper, `"></div> </div>`); }, dropdownContent: function(t) { var e = this.settings.templates, i = this.state.dropdown.suggestions; return ` `.concat(e.dropdownHeader.call(this, i), ` `).concat(t, ` `).concat(e.dropdownFooter.call(this, i), ` `); }, dropdownItem: function(t) { return "<div ".concat(this.getAttributes(t), ` class='`).concat(this.settings.classNames.dropdownItem, " ").concat(this.isTagDuplicate(t.value) ? this.settings.classNames.dropdownItemSelected : "", " ").concat(t.class || "", `' tabindex="0" role="option">`).concat(t.mappedValue || t.value, "</div>"); }, dropdownHeader: function(t) { return `<header data-selector='tagify-suggestions-header' class="`.concat(this.settings.classNames.dropdownHeader, '"></header>'); }, dropdownFooter: function(t) { var e = t.length - this.settings.dropdown.maxItems; return e > 0 ? `<footer data-selector='tagify-suggestions-footer' class="`.concat(this.settings.classNames.dropdownFooter, `"> `).concat(e, ` more items. Refine your search. </footer>`) : ""; }, dropdownItemNoMatch: null }; function ct(t, e) { (e == null || e > t.length) && (e = t.length); for (var i = 0, n = new Array(e); i < e; i++) n[i] = t[i]; return n; } function gt(t, e) { return e != null && typeof Symbol < "u" && e[Symbol.hasInstance] ? !!e[Symbol.hasInstance](t) : t instanceof e; } function At(t, e) { return function(i) { if (Array.isArray(i)) return i; }(t) || function(i, n) { var s = i == null ? null : typeof Symbol < "u" && i[Symbol.iterator] || i["@@iterator"]; if (s != null) { var a, o, r = [], l = !0, d = !1; try { for (s = s.call(i); !(l = (a = s.next()).done) && (r.push(a.value), !n || r.length !== n); l = !0) ; } catch (u) { d = !0, o = u; } finally { try { l || s.return == null || s.return(); } finally { if (d) throw o; } } return r; } }(t, e) || function(i, n) { if (i) { if (typeof i == "string") return ct(i, n); var s = Object.prototype.toString.call(i).slice(8, -1); if (s === "Object" && i.constructor && (s = i.constructor.name), s === "Map" || s === "Set") return Array.from(s); if (s === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)) return ct(i, n); } }(t, e) || function() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); } function Q(t, e) { (e == null || e > t.length) && (e = t.length); for (var i = 0, n = new Array(e); i < e; i++) n[i] = t[i]; return n; } function V(t, e, i) { return e in t ? Object.defineProperty(t, e, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = i, t; } function ht(t, e) { return e != null && typeof Symbol < "u" && e[Symbol.hasInstance] ? !!e[Symbol.hasInstance](t) : t instanceof e; } function Ct(t, e) { return e = e ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(e)) : function(i, n) { var s = Object.keys(i); if (Object.getOwnPropertySymbols) { var a = Object.getOwnPropertySymbols(i); s.push.apply(s, a); } return s; }(Object(e)).forEach(function(i) { Object.defineProperty(t, i, Object.getOwnPropertyDescriptor(e, i)); }), t; } function Y(t) { return function(e) { if (Array.isArray(e)) return Q(e); }(t) || function(e) { if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e); }(t) || function(e, i) { if (e) { if (typeof e == "string") return Q(e, i); var n = Object.prototype.toString.call(e).slice(8, -1); if (n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Q(e, i); } }(t) || function() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }(); } var kt = { customBinding: function() { var t = this; this.customEventsList.forEach(function(e) { t.on(e, t.settings.callbacks[e]); }); }, binding: function() { var t, e = !(arguments.length > 0 && arguments[0] !== void 0) || arguments[0], i = this.settings, n = this.events.callbacks, s = e ? "addEventListener" : "removeEventListener"; if (!(this.state.mainEvents && e || i.disabled || i.readonly)) { for (var a in this.state.mainEvents = e, e && !this.listeners.main && (this.events.bindGlobal.call(this), this.settings.isJQueryPlugin && jQuery(this.DOM.originalInput).on("tagify.removeAllTags", this.removeAllTags.bind(this))), t = this.listeners.main = this.listeners.main || { keydown: ["input", n.onKeydown.bind(this)], click: ["scope", n.onClickScope.bind(this)], dblclick: i.mode != "select" && ["scope", n.onDoubleClickScope.bind(this)], paste: ["input", n.onPaste.bind(this)], drop: ["input", n.onDrop.bind(this)], compositionstart: ["input", n.onCompositionStart.bind(this)], compositionend: ["input", n.onCompositionEnd.bind(this)] }) t[a] && this.DOM[t[a][0]][s](a, t[a][1]); var o = this.listeners.main.inputMutationObserver || new MutationObserver(n.onInputDOMChange.bind(this)); o.disconnect(), i.mode == "mix" && o.observe(this.DOM.input, { childList: !0 }), this.events.bindOriginaInputListener.call(this), e && (this.listeners.main = void 0); } }, bindOriginaInputListener: function(t) { var e = (t || 0) + 500; this.listeners.main && (clearInterval(this.listeners.main.originalInputValueObserverInterval), this.listeners.main.originalInputValueObserverInterval = setInterval(this.events.callbacks.observeOriginalInputValue.bind(this), e)); }, bindGlobal: function(t) { var e, i = this.events.callbacks, n = t ? "removeEventListener" : "addEventListener"; if (this.listeners && (t || !this.listeners.global)) { this.listeners.global = this.listeners.global || [{ type: this.isIE ? "keydown" : "input", target: this.DOM.input, cb: i[this.isIE ? "onInputIE" : "onInput"].bind(this) }, { type: "keydown", target: window, cb: i.onWindowKeyDown.bind(this) }, { type: "focusin", target: this.DOM.scope, cb: i.onFocusBlur.bind(this) }, { type: "focusout", target: this.DOM.scope, cb: i.onFocusBlur.bind(this) }, { type: "click", target: document, cb: i.onClickAnywhere.bind(this), useCapture: !0 }]; var s = !0, a = !1, o = void 0; try { for (var r, l = this.listeners.global[Symbol.iterator](); !(s = (r = l.next()).done); s = !0) (e = r.value).target[n](e.type, e.cb, !!e.useCapture); } catch (d) { a = !0, o = d; } finally { try { s || l.return == null || l.return(); } finally { if (a) throw o; } } t && (this.listeners.global = void 0); } }, unbindGlobal: function() { this.events.bindGlobal.call(this, !0); }, callbacks: { onFocusBlur: function(t) { var e, i, n = this.settings, s = ut.call(this, t.relatedTarget), a = j.call(this, t.target), o = t.target.classList.contains(n.classNames.tagX), r = t.type == "focusin", l = t.type == "focusout"; o && n.mode != "mix" && n.focusInputOnRemove && this.DOM.input.focus(), s && r && !a && !o && this.toggleFocusClass(this.state.hasFocus = +/* @__PURE__ */ new Date()); var d = t.target ? this.trim(this.DOM.input.textContent) : "", u = (i = this.value) === null || i === void 0 || (e = i[0]) === null || e === void 0 ? void 0 : e[n.tagTextProp], c = n.dropdown.enabled >= 0, g = { relatedTarget: t.relatedTarget }, p = this.state.actions.selectOption && (c || !n.dropdown.closeOnSelect), h = this.state.actions.addNew && c; if (l) { if (t.relatedTarget === this.DOM.scope) return this.dropdown.hide(), void this.DOM.input.focus(); this.postUpdate(), n.onChangeAfterBlur && this.triggerChangeEvent(); } if (!(p || h || o)) if (this.state.hasFocus = !(!r && !s) && +/* @__PURE__ */ new Date(), this.toggleFocusClass(this.state.hasFocus), n.mode != "mix") { if (r) { if (!n.focusable) return; var f = n.dropdown.enabled === 0 && !this.state.dropdown.visible, m = this.DOM.scope.querySelector(this.settings.classNames.tagTextSelector); return this.trigger("focus", g), void (f && !a && (this.dropdown.show(this.value.length ? "" : void 0), n.mode === "select" && this.setRangeAtStartEnd(!1, m))); } if (l) { if (this.trigger("blur", g), this.loading(!1), n.mode == "select") { if (this.value.length) { var y = this.getTagElms()[0]; d = this.trim(y.textContent); } u === d && (d = ""); } d && !this.state.actions.selectOption && n.addTagOnBlur && n.addTagOn.includes("blur") && this.addTags(d, !0); } s || (this.DOM.input.removeAttribute("style"), this.dropdown.hide()); } else r ? this.trigger("focus", g) : l && (this.trigger("blur", g), this.loading(!1), this.dropdown.hide(), this.state.dropdown.visible = void 0, this.setStateSelection()); }, onCompositionStart: function(t) { this.state.composing = !0; }, onCompositionEnd: function(t) { this.state.composing = !1; }, onWindowKeyDown: function(t) { var e, i = this.settings, n = document.activeElement, s = ut.call(this, n) && this.DOM.scope.contains(n), a = n === this.DOM.input, o = s && n.hasAttribute("readonly"), r = this.DOM.scope.querySelector(this.settings.classNames.tagTextSelector), l = this.state.dropdown.visible; if ((t.key === "Tab" && l || this.state.hasFocus || s && !o) && !a) { e = n.nextElementSibling; var d = t.target.classList.contains(i.classNames.tagX); switch (t.key) { case "Backspace": i.readonly || this.state.editing || (this.removeTags(n), (e || this.DOM.input).focus()); break; case "Enter": if (d) return void this.removeTags(t.target.parentNode); i.a11y.focusableTags && j.call(this, n) && setTimeout(this.editTag.bind(this), 0, n); break; case "ArrowDown": this.state.dropdown.visible || i.mode == "mix" || this.dropdown.show(); break; case "Tab": r?.focus(); } } }, onKeydown: function(t) { var e = this, i = this.settings; if (!this.state.composing && i.userInput) { i.mode == "select" && i.enforceWhitelist && this.value.length && t.key != "Tab" && t.preventDefault(); var n = this.trim(t.target.textContent); this.trigger("keydown", { event: t }), i.hooks.beforeKeyDown(t, { tagify: this }).then(function(s) { if (i.mode == "mix") { switch (t.key) { case "Left": case "ArrowLeft": e.state.actions.ArrowLeft = !0; break; case "Delete": case "Backspace": if (e.state.editing) return; var a = document.getSelection(), o = t.key == "Delete" && a.anchorOffset == (a.anchorNode.length || 0), r = a.anchorNode.previousSibling, l = a.anchorNode.nodeType == 1 || !a.anchorOffset && r && r.nodeType == 1 && a.anchorNode.previousSibling; (function(D) { var S = document.createElement("div"); D.replace(/\&#?[0-9a-z]+;/gi, function(I) { return S.innerHTML = I, S.innerText; }); })(e.DOM.input.innerHTML); var d, u, c, g = e.getTagElms(), p = a.anchorNode.length === 1 && a.anchorNode.nodeValue == "​"; if (i.backspace == "edit" && l) return d = a.anchorNode.nodeType == 1 ? null : a.anchorNode.previousElementSibling, setTimeout(e.editTag.bind(e), 0, d), void t.preventDefault(); if (lt() && ht(l, Element)) return c = ot(l), l.hasAttribute("readonly") || l.remove(), e.DOM.input.focus(), void setTimeout(function() { A(c), e.DOM.input.click(); }); if (a.anchorNode.nodeName == "BR") return; if ((o || l) && a.anchorNode.nodeType == 1 ? u = a.anchorOffset == 0 ? o ? g[0] : null : g[Math.min(g.length, a.anchorOffset) - 1] : o ? u = a.anchorNode.nextElementSibling : ht(l, Element) && (u = l), a.anchorNode.nodeType == 3 && !a.anchorNode.nodeValue && a.anchorNode.previousElementSibling && t.preventDefault(), (l || o) && !i.backspace || a.type != "Range" && !a.anchorOffset && a.anchorNode == e.DOM.input && t.key != "Delete") return void t.preventDefault(); if (a.type != "Range" && u && u.hasAttribute("readonly")) return void A(ot(u)); t.key == "Delete" && p && v(a.anchorNode.nextSibling) && e.removeTags(a.anchorNode.nextSibling); break; case "Enter": t.preventDefault(); var h = window.getSelection(); h.getRangeAt(0).insertNode(document.createElement("br")), h.collapseToEnd(); } return !0; } var f = i.dropdown.position == "manual"; switch (t.key) { case "Backspace": i.mode == "select" && i.enforceWhitelist && e.value.length ? e.removeTags() : e.state.dropdown.visible && i.dropdown.position != "manual" || t.target.textContent != "" && n.charCodeAt(0) != 8203 || (i.backspace === !0 ? e.removeTags() : i.backspace == "edit" && setTimeout(e.editTag.bind(e), 0)); break; case "Esc": case "Escape": if (e.state.dropdown.visible) return; t.target.blur(); break; case "Down": case "ArrowDown": e.state.dropdown.visible || e.dropdown.show(); break; case "ArrowRight": var m = e.state.inputSuggestion || e.state.ddItemData; if (m && i.autoComplete.rightKey) return void e.addTags([m], !0); break; case "Tab": return !0; case "Enter": if (e.state.dropdown.visible && !f) return; t.preventDefault(); var y = e.state.autoCompleteData || n; setTimeout(function() { e.state.dropdown.visible && !f || e.state.actions.selectOption || !i.addTagOn.includes(t.key.toLowerCase()) || (e.addTags([y], !0), e.state.autoCompleteData = null); }); } }).catch(function(s) { return s; }); } }, onInput: function(t) { this.postUpdate(); var e = this.settings; if (e.mode == "mix") return this.events.callbacks.onMixTagsInput.call(this, t); var i = this.input.normalize.call(this, void 0, { trim: !1 }), n = i.length >= e.dropdown.enabled, s = { value: i, inputElm: this.DOM.input }, a = this.validateTag({ value: i }); e.mode == "select" && this.toggleScopeValidation(a), s.isValid = a, this.state.inputText != i && (this.input.set.call(this, i, !1), i.search(e.delimiters) != -1 ? this.addTags(i) && this.input.set.call(this) : e.dropdown.enabled >= 0 && this.dropdown[n ? "show" : "hide"](i), this.trigger("input", s)); }, onMixTagsInput: function(t) { var e, i, n, s, a, o, r, l, d = this, u = this.settings, c = this.value.length, g = this.getTagElms(), p = document.createDocumentFragment(), h = window.getSelection().getRangeAt(0), f = [].map.call(g, function(m) { return v(m).value; }); if (t.inputType == "deleteContentBackward" && lt() && this.events.callbacks.onKeydown.call(this, { target: t.target, key: "Backspace" }), vt(this.getTagElms()), this.value.slice().forEach(function(m) { m.readonly && !f.includes(m.value) && p.appendChild(d.createTagElem(m)); }), p.childNodes.length && (h.insertNode(p), this.setRangeAtStartEnd(!1, p.lastChild)), g.length != c) return this.value = [].map.call(this.getTagElms(), function(m) { return v(m); }), void this.update({ withoutChangeEvent: !0 }); if (this.hasMaxTags()) return !0; if (window.getSelection && (o = window.getSelection()).rangeCount > 0 && o.anchorNode.nodeType == 3) { if ((h = o.getRangeAt(0).cloneRange()).collapse(!0), h.setStart(o.focusNode, 0), n = (e = h.toString().slice(0, h.endOffset)).split(u.pattern).length - 1, (i = e.match(u.pattern)) && (s = e.slice(e.lastIndexOf(i[i.length - 1]))), s) { if (this.state.actions.ArrowLeft = !1, this.state.tag = { prefix: s.match(u.pattern)[0], value: s.replace(u.pattern, "") }, this.state.tag.baseOffset = o.baseOffset - this.state.tag.value.length, l = this.state.tag.value.match(u.delimiters)) return this.state.tag.value = this.state.tag.value.replace(u.delimiters, ""), this.state.tag.delimiters = l[0], this.addTags(this.state.tag.value, u.dropdown.clearOnSelect), void this.dropdown.hide(); a = this.state.tag.value.length >= u.dropdown.enabled; try { r = (r = this.state.flaggedTags[this.state.tag.baseOffset]).prefix == this.state.tag.prefix && r.value[0] == this.state.tag.value[0], this.state.flaggedTags[this.state.tag.baseOffset] && !this.state.tag.value && delete this.state.flaggedTags[this.state.tag.baseOffset]; } catch { } (r || n < this.state.mixMode.matchedPatternCount) && (a = !1); } else this.state.flaggedTags = {}; this.state.mixMode.matchedPatternCount = n; } setTimeout(function() { d.update({ withoutChangeEvent: !0 }), d.trigger("input", w({}, d.state.tag, { textContent: d.DOM.input.textContent })), d.state.tag && d.dropdown[a ? "show" : "hide"](d.state.tag.value); }, 10); }, onInputIE: function(t) { var e = this; setTimeout(function() { e.events.callbacks.onInput.call(e, t); }); }, observeOriginalInputValue: function() { this.DOM.originalInput.parentNode || this.destroy(), this.DOM.originalInput.value != this.DOM.originalInput.tagifyValue && this.loadOriginalValues(); }, onClickAnywhere: function(t) { if (t.target != this.DOM.scope && !this.DOM.scope.contains(t.target)) { this.toggleFocusClass(!1), this.state.hasFocus = !1; var e = t.target.closest(this.settings.classNames.dropdownSelector); e?.__tagify != this && this.dropdown.hide(); } }, onClickScope: function(t) { var e = this.settings, i = t.target.closest("." + e.classNames.tag); t.target, this.DOM.scope; var n = +/* @__PURE__ */ new Date() - this.state.hasFocus; if (!t.target.classList.contains(e.classNames.tagX)) return i && !this.state.editing ? (this.trigger("click", { tag: i, index: this.getNodeIndex(i), data: v(i), event: t }), void (e.editTags !== 1 && e.editTags.clicks !== 1 && e.mode != "select" || this.events.callbacks.onDoubleClickScope.call(this, t))) : void (t.target == this.DOM.input && (e.mode == "mix" && this.fixFirefoxLastTagNoCaret(), n > 500 || !e.focusable) ? this.state.dropdown.visible ? this.dropdown.hide() : e.dropdown.enabled === 0 && e.mode != "mix" && this.dropdown.show(this.value.length ? "" : void 0) : e.mode != "select" || e.dropdown.enabled !== 0 || this.state.dropdown.visible || (this.events.callbacks.onDoubleClickScope.call(this, Ct(function(s) { for (var a = 1; a < arguments.length; a++) { var o = arguments[a] != null ? arguments[a] : {}, r = Object.keys(o); typeof Object.getOwnPropertySymbols == "function" && (r = r.concat(Object.getOwnPropertySymbols(o).filter(function(l) { retur