!function(e,s){"use strict";var i="Taggle";"function"==typeof define&&define.amd?define([],function(){var t=s();return e[i]=t}):"object"==typeof module&&module.exports?module.exports=e[i]=s():e[i]=s()}(this,function(){"use strict";function t(){}var s={additionalTagClasses:"",allowDuplicates:!1,saveOnBlur:!1,clearOnBlur:!0,duplicateTagClass:"",containerFocusClass:"active",focusInputOnContainerClick:!0,hiddenInputName:"taggles[]",tags:[],delimeter:",",delimiter:"",attachTagId:!1,allowedTags:[],disallowedTags:[],trimTags:!0,maxTags:null,tabIndex:1,placeholder:"Enter tags...",submitKeys:[188,9,13],preserveCase:!1,inputFormatter:t,tagFormatter:t,onBeforeTagAdd:t,onTagAdd:t,onBeforeTagRemove:function(){return!0},onTagRemove:t};function i(t){for(var e=t,s=1,i=arguments.length;sparseInt(this.input.style.width,10)&&(this.input.style.width=e+"px")},e.prototype._createTag=function(t,e){var s=document.createElement("li"),i=document.createElement("button"),n=document.createElement("input"),a=document.createElement("span");t=this._formatTag(t),l(i,"×"),i.className="close",i.setAttribute("type","button");var r=this._remove.bind(this,i);h(i,"click",r),l(a,t),a.className="taggle_text",s.className="taggle "+this.settings.additionalTagClasses,n.type="hidden",n.value=t,n.name=this.settings.hiddenInputName,s.appendChild(a),s.appendChild(i),s.appendChild(n);var o=this.settings.tagFormatter(s);if(void 0!==o&&(s=o),!(s instanceof HTMLElement)||"li"!==s.localName&&"LI"!==s.tagName)throw new Error("tagFormatter must return an li element");return this.settings.attachTagId&&(this._id+=1,t={text:t,id:this._id}),this.tag.values.splice(e,0,t),this.tag.elements.splice(e,0,s),this._closeEvents.splice(e,0,r),this._closeButtons.splice(e,0,i),s},e.prototype._showPlaceholder=function(){this.placeholder&&(this.placeholder.style.opacity=1)},e.prototype._remove=function(s,i){var n,t,a,r=this;function e(t){if(!t){var e=r._closeEvents[a];o(r._closeButtons[a],"click",e),s.parentNode.removeChild(s),r.tag.elements.splice(a,1),r.tag.values.splice(a,1),r._closeEvents.splice(a,1),r._closeButtons.splice(a,1),r.settings.onTagRemove(i,n),r._focusInput()}}"li"!==s.tagName.toLowerCase()&&(s=s.parentNode),t="a"===s.tagName.toLowerCase()?s.parentNode:s,a=this.tag.elements.indexOf(t),n=this.tag.values[a],this.settings.onBeforeTagRemove(i,n,e)&&e()},e.prototype._formatTag=function(t){return this.settings.preserveCase?t:t.toLowerCase()},e.prototype._isIndexInRange=function(t){return 0<=t&&t<=this.tag.values.length-1},e.prototype.getTags=function(){return{elements:this.getTagElements(),values:this.getTagValues()}},e.prototype.getTagElements=function(){return[].slice.apply(this.tag.elements)},e.prototype.getTagValues=function(){return[].slice.apply(this.tag.values)},e.prototype.getInput=function(){return this.input},e.prototype.getContainer=function(){return this.container},e.prototype.add=function(t,e){var s;if(s=t,Array.isArray?Array.isArray(s):"[object Array]"===Object.prototype.toString.call(s))for(var i=e,n=0,a=t.length;n