text: function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}!function(e){e.fn.keywordmap=function(){return this.each(function(){var n=e(this),r="keywordmap",o=[],a=n.attr("data-target");return!!n.data(r)||(n.data(r,!0),t.setTextarea(n,a),t.toggle(n),n.find("input").on("change paste keyup",function(){o=e(this).val().split(","),t.mark(n,o)}),e(".field-name-"+a).find("textarea").on("change paste keyup",function(){t.setTextarea(n,a),t.mark(n,o)}),void(null!==localStorage.getItem("kwm-disabled")&&n.find(".field-content").addClass("kwm-disabled")))})};var t=function(){var n={};return n.clear=function(e){e.find(".keywordmap-tags [data-tag]").removeClass("active"),e.find(".keywordmap-tags [data-tag] .tag-label").attr("style",""),e.find(".keywordmap-tags .kwt-count").remove(),e.find(".keywordmap").unmark()},n.mark=function(e,n){t.clear(e),e.find(".keywordmap-tags .kwt-count").remove(),e.find(".keywordmap").mark(n,{separateWordSearch:!1,diacritics:!1,accuracy:{value:"exactly",limiters:["-","#",",",".","!","?","(",")","[","]"]},done:function(){t.setTags(e),t.setTextareaColor(e,n)}})},n.toggle=function(t){t.find(".kwm-toggle").click(function(){e(this).parent().hasClass("kwm-disabled")?(e(this).parent().removeClass("kwm-disabled"),localStorage.removeItem("kwm-disabled")):(e(this).parent().addClass("kwm-disabled"),localStorage.setItem("kwm-disabled","1"))})},n.setTextareaColor=function(t,n){e.each(n,function(n,r){var o=t.find("mark").filter(function(){return e(this).text().toLowerCase()==r.toLowerCase()});o.each(function(t){var n=e(this).text().toLowerCase(),r=e('[data-tag="'+n+'"] .tag-label').attr("style");e(this).attr("style",r)})})},n.setTags=function(n){var r=new ColorHash;n.find("[data-tag]").each(function(o){var a=e(this),i=e(this).attr("data-tag"),s=r.hsl(i),c=n.find("mark").filter(function(){return e(this).text().trim().toLowerCase()==i.toLowerCase()}),u=c.length;u>0&&(t.setTagColor(a,i,s),u>1&&t.setTagCount(a,i,u))})},n.setTagColor=function(e,t,n){e.addClass("active"),e.find(".tag-label").css("background-color","hsl("+n[0]+", "+100*n[1]+"%, "+100*n[2]+"%)")},n.setTagCount=function(e,t,n){e.find("button").html(t+'<span class="kwt-count">'+n+"</span>")},n.setTextarea=function(t,n){var r=e(".field-name-"+n).find("textarea"),o=t.find(".keywordmap");r.length&&(r=r.val().replace(/\n/g,"<br>"),o.html(r))},n}()}(jQuery),!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.ColorHash=e()}}(function(){return function e(t,n,r){function o(i,s){if(!n[i]){if(!t[i]){var c="function"==typeof require&&require;if(!s&&c)return c(i,!0);if(a)return a(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var f=n[i]={exports:{}};t[i][0].call(f.exports,function(e){var n=t[i][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,t,n){var r=function(e){var t=131,n=137,r=0;e+="x";for(var o=parseInt(9007199254740991/n),a=0;a<e.length;a++)r>o&&(r=parseInt(r/n)),r=r*t+e.charCodeAt(a);return r};t.exports=r},{}],2:[function(e,t,n){var r=e("./bkdr-hash"),o=function(e){var t="#";return e.forEach(function(e){e<16&&(t+=0),t+=e.toString(16)}),t},a=function(e,t,n){e/=360;var r=n<.5?n*(1+t):n+t-n*t,o=2*n-r;return[e+1/3,e,e-1/3].map(function(e){return e<0&&e++,e>1&&e--,e=e<1/6?o+6*(r-o)*e:e<.5?r:e<2/3?o+6*(r-o)*(2/3-e):o,Math.round(255*e)})},i=function(e){e=e||{};var t=[e.lightness,e.saturation].map(function(e){return e=e||[.35,.5,.65],"[object Array]"===Object.prototype.toString.call(e)?e.concat():[e]});this.L=t[0],this.S=t[1],this.hash=e.hash||r};i.prototype.hsl=function(e){var t,n,r,o=this.hash(e);return t=o%359,o=parseInt(o/360),n=this.S[o%this.S.length],o=parseInt(o/this.S.length),r=this.L[o%this.L.length],[t,n,r]},i.prototype.rgb=function(e){var t=this.hsl(e);return a.apply(this,t)},i.prototype.hex=function(e){var t=this.rgb(e);return o(t)},t.exports=i},{"./bkdr-hash":1}]},{},[2])(2)});var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t,n){"function"==typeof define&&define.amd?define(["jquery"],function(r){return e(t,n,r)}):"object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports?module.exports=e(t,n,require("jquery")):e(t,n,jQuery)}(function(e,t,n){var r=function(){function n(t){_classCallCheck(this,n),this.ctx=t,this.ie=!1;var r=e.navigator.userAgent;(r.indexOf("MSIE")>-1||r.indexOf("Trident")>-1)&&(this.ie=!0)}return _createClass(n,[{key:"log",value:function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"debug",e=this.opt.log;this.opt.debug&&"object"===("undefined"==typeof e?"undefined":_typeof(e))&&"function"==typeof e[n]&&e[n]("mark.js: "+t)}},{key:"escapeStr",value:function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}},{key:"createRegExp",value:function(e){return e=this.escapeStr(e),Object.keys(this.opt.synonyms).length&&(e=this.createSynonymsRegExp(e)),this.opt.ignoreJoiners&&(e=this.setupIgnoreJoinersRegExp(e)),this.opt.diacritics&&(e=this.createDiacriticsRegExp(e)),e=this.createMergedBlanksRegExp(e),this.opt.ignoreJoiners&&(e=this.createIgnoreJoinersRegExp(e)),e=this.createAccuracyRegExp(e)}},{key:"createSynonymsRegExp",value:function(e){var t=this.opt.synonyms,n=this.opt.caseSensitive?"":"i";for(var r in t)if(t.hasOwnProperty(r)){var o=t[r],a=this.escapeStr(r),i=this.escapeStr(o);""!==a&&""!==i&&(e=e.replace(new RegExp("("+a+"|"+i+")","gm"+n),"("+a+"|"+i+")"))}return e}},{key:"setupIgnoreJoinersRegExp",value:function(e){return e.replace(/[^(|)\\]/g,function(e,t,n){var r=n.charAt(t+1);return/[(|)\\]/.test(r)||""===r?e:e+"\0"})}},{key:"createIgnoreJoinersRegExp",value:function(e){return e.split("\0").join("[\\u00ad|\\u200b|\\u200c|\\u200d]?")}},{key:"createDiacriticsRegExp",value:function(e){var t=this.opt.caseSensitive?"":"i",n=this.opt.caseSensitive?["aàáâãäåāąă","AÀÁÂÃÄÅĀĄĂ","cçćč","CÇĆČ","dđď","DĐĎ","eèéêëěēę","EÈÉÊËĚĒĘ","iìíîïī","IÌÍÎÏĪ","lł","LŁ","nñňń","NÑŇŃ","oòóôõöøō","OÒÓÔÕÖØŌ","rř","RŘ","sšśșş","SŠŚȘŞ","tťțţ","TŤȚŢ","uùúûüůū","UÙÚÛÜŮŪ","yÿý","YŸÝ","zžżź","ZŽŻŹ"]:["aàáâãäåāąăAÀÁÂÃÄÅĀĄĂ","cçćčCÇĆČ","dđďDĐĎ","eèéêëěēęEÈÉÊËĚĒĘ","iìíîïīIÌÍÎÏĪ","lłLŁ","nñňńNÑŇŃ","oòóôõöøōOÒÓÔÕÖØŌ","rřRŘ","sšśșşSŠŚȘŞ","tťțţTŤȚŢ","uùúûüůūUÙÚÛÜŮŪ","yÿýYŸÝ","zžżźZŽŻŹ"],r=[];return e.split("").forEach(function(o){n.every(function(n){if(n.indexOf(o)!==-1){if(r.indexOf(n)>-1)return!1;e=e.replace(new RegExp("["+n+"]","gm"+t),"["+n+"]"),r.push(n)}return!0})}),e}},{key:"createMergedBlanksRegExp",value:function(e){return e.replace(/[\s]+/gim,"[\\s]+")}},{key:"createAccuracyRegExp",value:function(e){var t=this,n="!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~¡¿",r=this.opt.accuracy,o="string"==typeof r?r:r.value,a="string"==typeof r?[]:r.limiters,i="";switch(a.forEach(function(e){i+="|"+t.escapeStr(e)}),o){case"partially":default:return"()("+e+")";case"complementary":return i="\\s"+(i?i:this.escapeStr(n)),"()([^"+i+"]*"+e+"[^"+i+"]*)";case"exactly":return"(^|\\s"+i+")("+e+")(?=$|\\s"+i+")"}}},{key:"getSeparatedKeywords",value:function(e){var t=this,n=[];return e.forEach(function(e){t.opt.separateWordSearch?e.split(" ").forEach(function(e){e.trim()&&n.indexOf(e)===-1&&n.push(e)}):e.trim()&&n.indexOf(e)===-1&&n.push(e)}),{keywords:n.sort(function(e,t){return t.length-e.length}),length:n.length}}},{key:"getTextNodes",value:function(e){var t=this,n="",r=[];this.iterator.forEachNode(NodeFilter.SHOW_TEXT,function(e){r.push({start:n.length,end:(n+=e.textContent).length,node:e})},function(e){return t.matchesExclude(e.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},function(){e({value:n,nodes:r})})}},{key:"matchesExclude",value:function(e){return o.matches(e,this.opt.exclude.concat(["script","style","title","head","html"]))}},{key:"wrapRangeInTextNode",value:function(e,n,r){var o=this.opt.element?this.opt.element:"mark",a=e.splitText(n),i=a.splitText(r-n),s=t.createElement(o);return s.setAttribute("data-markjs","true"),this.opt.className&&s.setAttribute("class",this.opt.className),s.textContent=a.textContent,a.parentNode.replaceChild(s,a),i}},{key:"wrapRangeInMappedTextNode",value:function(e,t,n,r,o){var a=this;e.nodes.every(function(i,s){var c=e.nodes[s+1];if("undefined"==typeof c||c.start>t){var u=function(){if(!r(i.node))return{v:!1};var c=t-i.start,u=(n>i.end?i.end:n)-i.start,f=e.value.substr(0,i.start),l=e.value.substr(u+i.start);return i.node=a.wrapRangeInTextNode(i.node,c,u),e.value=f+l,e.nodes.forEach(function(t,n){n>=s&&(e.nodes[n].start>0&&n!==s&&(e.nodes[n].start-=u),e.nodes[n].end-=u)}),n-=u,o(i.node.previousSibling,i.start),n>i.end?void(t=i.end):{v:!1}}();if("object"===("undefined"==typeof u?"undefined":_typeof(u)))return u.v}return!0})}},{key:"wrapMatches",value:function(e,t,n,r,o){var a=this,i=0===t?0:t+1;this.getTextNodes(function(t){t.nodes.forEach(function(t){t=t.node;for(var o=void 0;null!==(o=e.exec(t.textContent))&&""!==o[i];)if(n(o[i],t)){var s=o.index;if(0!==i)for(var c=1;c<i;c++)s+=o[c].length;t=a.wrapRangeInTextNode(t,s,s+o[i].length),r(t.previousSibling),e.lastIndex=0}}),o()})}},{key:"wrapMatchesAcrossElements",value:function(e,t,n,r,o){var a=this,i=0===t?0:t+1;this.getTextNodes(function(t){for(var s=void 0;null!==(s=e.exec(t.value))&&""!==s[i];){var c=s.index;if(0!==i)for(var u=1;u<i;u++)c+=s[u].length;var f=c+s[i].length;a.wrapRangeInMappedTextNode(t,c,f,function(e){return n(s[i],e)},function(t,n){e.lastIndex=n,r(t)})}o()})}},{key:"unwrapMatches",value:function(e){for(var n=e.parentNode,r=t.createDocumentFragment();e.firstChild;)r.appendChild(e.removeChild(e.firstChild));n.replaceChild(r,e),this.ie?this.normalizeTextNode(n):n.normalize()}},{key:"normalizeTextNode",value:function(e){if(e){if(3===e.nodeType)for(;e.nextSibling&&3===e.nextSibling.nodeType;)e.nodeValue+=e.nextSibling.nodeValue,e.parentNode.removeChild(e.nextSibling);else this.normalizeTextNode(e.firstChild);this.normalizeTextNode(e.nextSibling)}}},{key:"markRegExp",value:function(e,t){var n=this;this.opt=t,this.log('Searching with expression "'+e+'"');var r=0,o="wrapMatches",a=function(e){r++,n.opt.each(e)};this.opt.acrossElements&&(o="wrapMatchesAcrossElements"),this[o](e,this.opt.ignoreGroups,function(e,t){return n.opt.filter(t,e,r)},a,function(){0===r&&n.opt.noMatch(e),n.opt.done(r)})}},{key:"mark",value:function(e,t){var n=this;this.opt=t;var r=0,o="wrapMatches",a=this.getSeparatedKeywords("string"==typeof e?[e]:e),i=a.keywords,s=a.length,c=this.opt.caseSensitive?"":"i",u=function e(t){var a=new RegExp(n.createRegExp(t),"gm"+c),u=0;n.log('Searching with expression "'+a+'"'),n[o](a,1,function(e,o){return n.opt.filter(o,t,r,u)},function(e){u++,r++,n.opt.each(e)},function(){0===u&&n.opt.noMatch(t),i[s-1]===t?n.opt.done(r):e(i[i.indexOf(t)+1])})};this.opt.acrossElements&&(o="wrapMatchesAcrossElements"),0===s?this.opt.done(r):u(i[0])}},{key:"unmark",value:function(e){var t=this;this.opt=e;var n=this.opt.element?this.opt.element:"*";n+="[data-markjs]",this.opt.className&&(n+="."+this.opt.className),this.log('Removal selector "'+n+'"'),this.iterator.forEachNode(NodeFilter.SHOW_ELEMENT,function(e){t.unwrapMatches(e)},function(e){var r=o.matches(e,n),a=t.matchesExclude(e);return!r||a?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},this.opt.done)}},{key:"opt",set:function(t){this._opt=_extends({},{element:"",className:"",exclude:[],iframes:!1,iframesTimeout:5e3,separateWordSearch:!0,diacritics:!0,synonyms:{},accuracy:"partially",acrossElements:!1,caseSensitive:!1,ignoreJoiners:!1,ignoreGroups:0,each:function(){},noMatch:function(){},filter:function(){return!0},done:function(){},debug:!1,log:e.console},t)},get:function(){return this._opt}},{key:"iterator",get:function(){return this._iterator||(this._iterator=new o(this.ctx,this.opt.iframes,this.opt.exclude,this.opt.iframesTimeout)),this._iterator}}]),n}(),o=function(){function e(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:5e3;_classCallCheck(this,e),this.ctx=t,this.iframes=n,this.exclude=r,this.iframesTimeout=o}return _createClass(e,[{key:"getContexts",value:function(){var e=void 0,n=[];return e="undefined"!=typeof this.ctx&&this.ctx?NodeList.prototype.isPrototypeOf(this.ctx)?Array.prototype.slice.call(this.ctx):Array.isArray(this.ctx)?this.ctx:"string"==typeof this.ctx?Array.prototype.slice.call(t.querySelectorAll(this.ctx)):[this.ctx]:[],e.forEach(function(e){var t=n.filter(function(t){return t.contains(e)}).length>0;n.indexOf(e)!==-1||t||n.push(e)}),n}},{key:"getIframeContents",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=void 0;try{var o=e.contentWindow;if(r=o.document,!o||!r)throw new Error("iframe inaccessible")}catch(e){n()}r&&t(r)}},{key:"isIframeBlank",value:function(e){var t="about:blank",n=e.getAttribute("src").trim(),r=e.contentWindow.location.href;return r===t&&n!==t&&n}},{key:"observeIframeLoad",value:function(e,t,n){var r=this,o=!1,a=null,i=function i(){if(!o){o=!0,clearTimeout(a);try{r.isIframeBlank(e)||(e.removeEventListener("load",i),r.getIframeContents(e,t,n))}catch(e){n()}}};e.addEventListener("load",i),a=setTimeout(i,this.iframesTimeout)}},{key:"onIframeReady",value:function(e,t,n){try{"complete"===e.contentWindow.document.readyState?this.isIframeBlank(e)?this.observeIframeLoad(e,t,n):this.getIframeContents(e,t,n):this.observeIframeLoad(e,t,n)}catch(e){n()}}},{key:"waitForIframes",value:function(e,t){var n=this,r=0;this.forEachIframe(e,function(){return!0},function(e){r++,n.waitForIframes(e.querySelector("html"),function(){--r||t()})},function(e){e||t()})}},{key:"forEachIframe",value:function(t,n,r){var o=this,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},i=t.querySelectorAll("iframe"),s=i.length,c=0;i=Array.prototype.slice.call(i);var u=function(){--s<=0&&a(c)};s||u(),i.forEach(function(t){e.matches(t,o.exclude)?u():o.onIframeReady(t,function(e){n(t)&&(c++,r(e)),u()},u)})}},{key:"createIterator",value:function(e,n,r){return t.createNodeIterator(e,n,r,!1)}},{key:"createInstanceOnIframe",value:function(t){return new e(t.querySelector("html"),this.iframes)}},{key:"compareNodeIframe",value:function(e,t,n){var r=e.compareDocumentPosition(n),o=Node.DOCUMENT_POSITION_PRECEDING;if(r&o){if(null===t)return!0;var a=t.compareDocumentPosition(n),i=Node.DOCUMENT_POSITION_FOLLOWING;if(a&i)return!0}return!1}},{key:"getIteratorNode",value:function(e){var t=e.previousNode(),n=void 0;return n=null===t?e.nextNode():e.nextNode()&&e.nextNode(),{prevNode:t,node:n}}},{key:"checkIframeFilter",value:function(e,t,n,r){var o=!1,a=!1;return r.forEach(function(e,t){e.val===n&&(o=t,a=e.handled)}),this.compareNodeIframe(e,t,n)?(o!==!1||a?o===!1||a||(r[o].handled=!0):r.push({val:n,handled:!0}),!0):(o===!1&&r.push({val:n,handled:!1}),!1)}},{key:"handleOpenIframes",value:function(e,t,n,r){var o=this;e.forEach(function(e){e.handled||o.getIframeContents(e.val,function(e){o.createInstanceOnIframe(e).forEachNode(t,n,r)})})}},{key:"iterateThroughNodes",value:function(e,t,n,r,o){for(var a=this,i=this.createIterator(t,e,r),s=[],c=[],u=void 0,f=void 0,l=function(){var e=a.getIteratorNode(i);return f=e.prevNode,u=e.node};l();)this.iframes&&this.forEachIframe(t,function(e){return a.checkIframeFilter(u,f,e,s)},function(t){a.createInstanceOnIframe(t).forEachNode(e,n,r)}),c.push(u);c.forEach(function(e){n(e)}),this.iframes&&this.handleOpenIframes(s,e,n,r),o()}},{key:"forEachNode",value:function(e,t,n){var r=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(){},a=this.getContexts(),i=a.length;i||o(),a.forEach(function(a){var s=function(){r.iterateThroughNodes(e,a,t,n,function(){--i<=0&&o()})};r.iframes?r.waitForIframes(a,s):s()})}}],[{key:"matches",value:function(e,t){var n="string"==typeof t?[t]:t,r=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.webkitMatchesSelector;if(r){var o=!1;return n.every(function(t){return!r.call(e,t)||(o=!0,!1)}),o}return!1}}]),e}();return n.fn.mark=function(e,t){return new r(this.get()).mark(e,t),this},n.fn.markRegExp=function(e,t){return new r(this.get()).markRegExp(e,t),this},n.fn.unmark=function(e){return new r(this.get()).unmark(e),this},n},window,document);