/**
 * Copyright (c) 2013 - 2019 fusionCSS. All rights reserved.
 * @link http://fusionCSS.com
 * @version 3.3.0
 */
!function(){var n=null;function r(t,e,a){e.val(""),$("#"+e.attr("id")+"_tagInputWidget .tag").remove();for(var l=a.split(e.attr("data-delimiter")),i=0;i<l.length;i++)d(t,e,l[i],!1);return e}function d(t,e,a,l){if((a=a.trim()).length){var i=a.split(e.attr("data-delimiter")),n=e.val().split(e.attr("data-delimiter")),r=$("#"+e.attr("id")+"_tagInput");""==n[0]&&(n=new Array);for(var d=0;d<i.length;d++)a=i[d],s=a,-1<(g=e).val().split(g.attr("data-delimiter")).indexOf(s)?0===i.length&&r.addClass("invalidTag"):(r.removeClass("invalidTag").val(""),$(t.tagHTML.replace(/\{value\}/g,String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"))).insertBefore(r),l?r.focus():r.blur(),n.push(a),e.val(n.join(e.attr("data-delimiter"))))}var g,s}function g(t,e,a){var l=e.attr("data-delimiter"),i=e.val().split(l),a=i.indexOf(a);-1<a&&(i.splice(a,1),r(t,e,i.join(l)))}$.fn.extend({setTags:function(t){return r(this,t)},enableTagInput:function(t){var i=$.extend({tagHTML:'<div class="chip tag"><span class="tagValue">{value}</span><i class="tagDelete">x</i></div>',widgetHTML:'<div id="{id}_tagInputWidget" class="tagInputWidget"><input id="{id}_tagInput" class="tagInput" value="" placeholder="{placeholder}" /></div>'},t);return this.each(function(){var a=$(this),e=a.attr("id"),l=a.attr("data-delimiter");a.attr("data-init-done")||(a.attr("data-init-done","1").hide(),$(i.widgetHTML.replace(/\{id\}/g,e).replace(/\{placeholder\}/g,a.attr("data-placeholder"))).insertAfter(a),r(i,a,a.val()),$("#"+e+"_tagInputWidget").on("click",function(t){$(t.target).closest(".tagDelete").length?(t.preventDefault(),g(i,a,$(t.target).closest(".tag").find(".tagValue").text())):$("#"+e+"_tagInput").focus()}),$("#"+e+"_tagInput").on("blur",function(t){d(i,a,$("#"+e+"_tagInput").val(),!0)}).on("keydown",function(t){var e=$(this);if(e.removeClass("invalidTag"),"Enter"===t.key||t.key===l)t.preventDefault(),d(i,a,e.val(),!0);else if("Backspace"===t.key&&""===e.val())t.preventDefault(),g(i,a,e.closest(".tagInputWidget").find(".tag").last().find(".tagValue").text()),e.focus();else if((t.ctrlKey||t.metaKey)&&"c"===t.key&&0===e.val().length){t.preventDefault(),n||(n=$('<textarea style="position:absolute; left:-9999px; top:0">'),$("body").append(n)),n.val(a.val()).focus()[0].setSelectionRange(0,n.val().length);try{document.execCommand("copy")}catch(t){}e.focus()}}))})}})}();