text: !function(t){function e(t,e){if(!t)return console.warn("Tagify: ","invalid input element ",t),this;if(this.settings=this.extend({},e,this.DEFAULTS),this.settings.readonly=t.hasAttribute("readonly"),this.legacyFixes(),t.pattern)try{this.settings.pattern=new RegExp(t.pattern)}catch(t){}if(e&&e.delimiters)try{this.settings.delimiters=new RegExp("["+e.delimiters+"]")}catch(t){}this.id=Math.random().toString(36).substr(2,9),this.value=[],this.DOM={},this.extend(this,new this.EventDispatcher),this.build(t),this.events()}t.fn.tagify=function(i){return this.each(function(){var s,n=t(this);if(n.data("tagify"))return this;(s=new e(n[0],i)).isJQueryPlugin=!0,n.data("tagify",s)})},e.prototype={DEFAULTS:{delimiters:",",pattern:"",callbacks:{},duplicates:!1,enforceWhitelist:!1,autocomplete:!0,whitelist:[],blacklist:[],maxTags:1/0,suggestionsMinChars:2,maxSuggestions:10},legacyFixes:function(){var t=this.settings;t.hasOwnProperty("enforeWhitelist")&&!t.hasOwnProperty("enforceWhitelist")&&(t.enforceWhitelist=t.enforeWhitelist,delete t.enforeWhitelist,console.warn("Please update your Tagify settings. The 'enforeWhitelist' property is deprecated and you should be using 'enforceWhitelist'."))},build:function(t){var e=t.value,i='<div><input list="tagifySuggestions'+this.id+'" class="placeholder"/><span>'+t.placeholder+"</span></div>";this.DOM.originalInput=t,this.DOM.scope=document.createElement("tags"),t.className&&(this.DOM.scope.className=t.className),this.DOM.scope.innerHTML=i,this.DOM.input=this.DOM.scope.querySelector("input"),this.settings.readonly&&this.DOM.scope.classList.add("readonly"),t.parentNode.insertBefore(this.DOM.scope,t),this.DOM.scope.appendChild(t),this.settings.autocomplete&&this.settings.whitelist.length&&("suggestions"in this?this.suggestions.init():this.DOM.datalist=this.buildDataList()),e&&this.addTags(e).forEach(function(t){t&&t.classList.add("tagify--noAnim")})},destroy:function(){this.DOM.scope.parentNode.appendChild(this.DOM.originalInput),this.DOM.scope.parentNode.removeChild(this.DOM.scope)},extend:function(t,e,i){function s(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])}return t instanceof Object||(t={}),i?(s(t,i),s(t,e)):s(t,e),t},EventDispatcher:function(){var e=document.createTextNode("");this.off=e.removeEventListener.bind(e),this.on=e.addEventListener.bind(e),this.trigger=function(i,s){var n;if(i)if(this.isJQueryPlugin)t(this.DOM.originalInput).triggerHandler(i,[s]);else{try{n=new CustomEvent(i,{detail:s})}catch(t){(n=document.createEvent("Event")).initEvent("toggle",!1,!1)}e.dispatchEvent(n)}}},events:function(){var e=this,i={paste:["onPaste","input"],focus:["onFocusBlur","input"],blur:["onFocusBlur","input"],input:["onInput","input"],keydown:["onKeydown","input"],click:["onClickScope","scope"]},s=["add","remove","duplicate","maxTagsExceed","blacklisted","notWhitelisted"];for(var n in i)this.DOM[i[n][1]].addEventListener(n,this.callbacks[i[n][0]].bind(this));s.forEach(function(t){e.on(t,e.settings.callbacks[t])}),this.isJQueryPlugin&&t(this.DOM.originalInput).on("tagify.removeAllTags",this.removeAllTags.bind(this))},callbacks:{onFocusBlur:function(t){var e=t.target.value.trim();"focus"==t.type?t.target.className="input":"blur"==t.type&&e?this.addTags(e).length&&(t.target.value=""):(t.target.className="input placeholder",this.DOM.input.removeAttribute("style"))},onKeydown:function(t){var e,i=t.target.value,s=this;if("Backspace"!=t.key||""!=i&&8203!=i.charCodeAt(0)||(e=(e=this.DOM.scope.querySelectorAll("tag:not(.tagify--hide)"))[e.length-1],this.removeTag(e)),"Escape"==t.key&&(t.target.value="",t.target.blur()),"Enter"==t.key)return t.preventDefault(),this.addTags(i).length&&(t.target.value=""),!1;this.noneDatalistInput&&clearTimeout(this.noneDatalistInput),this.noneDatalistInput=setTimeout(function(){s.noneDatalistInput=null},50)},onInput:function(t){var e,i=t.target.value,s=(i[i.length-1],!this.noneDatalistInput&&i.length>1),n=i.length>=this.settings.suggestionsMinChars;t.target.style.width=7*(t.target.value.length+1)+"px",-1!=i.slice().search(this.settings.delimiters)||s?this.addTags(i).length&&(t.target.value=""):this.settings.autocomplete&&this.settings.whitelist.length&&(e=this.DOM.input.parentNode.contains(this.DOM.datalist),!n&&e?this.DOM.input.parentNode.removeChild(this.DOM.datalist):n&&!e&&this.DOM.input.parentNode.appendChild(this.DOM.datalist))},onPaste:function(t){var e=this;this.noneDatalistInput&&clearTimeout(this.noneDatalistInput),this.noneDatalistInput=setTimeout(function(){e.noneDatalistInput=null},50)},onClickScope:function(t){"TAGS"==t.target.tagName&&this.DOM.input.focus(),"X"==t.target.tagName&&this.removeTag(t.target.parentNode)}},buildDataList:function(){var t,e="",i=document.createElement("datalist");for(i.id="tagifySuggestions"+this.id,i.innerHTML="<label>                                 select from the list:                                 <select>                                     <option value=''></option>                                     [OPTIONS]                                 </select>                             </label>",t=this.settings.whitelist.length;t--;)e+="<option>"+this.settings.whitelist[t]+"</option>";return i.innerHTML=i.innerHTML.replace("[OPTIONS]",e),i},getNodeIndex:function(t){for(var e=0;t=t.previousSibling;)3==t.nodeType&&/^\s*$/.test(t.data)||e++;return e},isTagDuplicate:function(t){return this.value.some(function(e){return t.toLowerCase()===e.value.toLowerCase()})},markTagByValue:function(t,e){var i,s;if(!e)for(s=(i=this.DOM.scope.querySelectorAll("tag")).length;s--;)i[s].textContent.toLowerCase().includes(t.toLowerCase())&&(e=i[s]);return!!e&&(e.classList.add("tagify--mark"),setTimeout(function(){e.classList.remove("tagify--mark")},2e3),!0)},isTagBlacklisted:function(t){return t=t.split(" "),this.settings.blacklist.filter(function(e){return-1!=t.indexOf(e)}).length},isTagWhitelisted:function(t){return-1!=this.settings.whitelist.indexOf(t)},addTags:function(t){function e(t){var e,i=t.value.trim(),s=this.value.length>=this.settings.maxTags;return i?this.settings.pattern&&!this.settings.pattern.test(i)?"pattern":this.isTagDuplicate(i)&&(this.trigger("duplicate",i),!this.settings.duplicates)?"duplicate":!!(!this.isTagBlacklisted(i)&&(!this.settings.enforceWhitelist||this.isTagWhitelisted(i))&&!s)||(t.class=t.class?t.class+" tagify--notAllowed":"tagify--notAllowed",s?e="maxTagsExceed":this.isTagBlacklisted(i)?e="blacklisted":this.settings.enforceWhitelist&&!this.isTagWhitelisted(i)&&(e="notWhitelisted"),this.trigger(e,{value:i,index:this.value.length}),"notAllowed"):"empty"}function i(t){this.DOM.scope.insertBefore(t,this.DOM.input.parentNode)}var s=this,n=[];return this.DOM.input.removeAttribute("style"),(t=function(t){var e=this.settings.whitelist[0]instanceof Object,i=t instanceof Array&&"value"in t[0],s=t;if(i)return s;if(!i&&"string"==typeof t&&e){var n=this.settings.whitelist.filter(function(e){return e.value.toLowerCase()==t.toLowerCase()});n[0]&&(i=!0,s=n)}if(!i){if(!(t=t.trim()))return[];s=t.split(this.settings.delimiters).map(function(t){return{value:t.trim()}})}return s.filter(function(t){return t})}.call(this,t)).forEach(function(t){var a=e.call(s,t);if(!0===a||"notAllowed"==a){var r=s.createTagElem(t);i.call(s,r),"notAllowed"==a?setTimeout(function(){s.removeTag(r,!0)},1e3):(s.value.push(t),s.update(),s.trigger("add",s.extend({},t,{index:s.value.length,tag:r})),n.push(r))}}),n},createTagElem:function(t){var e=document.createElement("tag");return e.innerHTML="<x></x><div><span title='"+t.value+"'>"+t.value+" </span></div>",function(t,e){var i,s=Object.keys(e);for(i=s.length;i--;){var n=s[i];if(!e.hasOwnProperty(n))return;t.setAttribute(n,e[n])}}(e,t),e},removeTag:function(t,e){var i,s=this.getNodeIndex(t);t&&(t.style.width=parseFloat(window.getComputedStyle(t).width)+"px",document.body.clientTop,t.classList.add("tagify--hide"),setTimeout(function(){t.parentNode.removeChild(t)},400),e||(i=this.value.splice(s,1)[0],this.update(),this.trigger("remove",this.extend({},i,{index:s,tag:t}))))},removeAllTags:function(){this.value=[],this.update(),Array.prototype.slice.call(this.DOM.scope.querySelectorAll("tag")).forEach(function(t){t.parentNode.removeChild(t)})},update:function(){var t=this.value.map(function(t){return t.value}).join(",");this.DOM.originalInput.value=t}}}(jQuery);