(()=>{"use strict";const e=function(e){return(e=e.toLowerCase()).trim()};function t(e){const t=document.querySelectorAll(".edd-email-tags-list-item");if(!t.length)return;const n=".edd-email-tags-filter-search",o=".edd-email-tags-list-button",i=document.activeElement;if(!i||!i.matches(n)&&!i.matches(o))return;let c,r=!1;if(i.matches(n)){if("up"===e)return;c=_.find(t,(e=>"none"!==e.style.display)),r=!0}else c=i.parentElement;for(;!r;)c="down"===e?c.nextElementSibling:c.previousElementSibling,r=!c||"none"!==c.style.display;c?c.querySelector(o).focus():"up"===e&&document.querySelector(n).focus()}document.addEventListener("DOMContentLoaded",(function(){const n=document.querySelector(".edd-email-tags-inserter");n&&(n.addEventListener("click",tb_position),function(){const e=document.querySelectorAll(".edd-email-tags-list-button");e&&_.each(e,(function(e){e.addEventListener("click",(function(){tb_remove(),window.send_to_editor(e.dataset.to_insert)}))}))}(),function(){const t=document.querySelector(".edd-email-tags-filter-search");t&&t.addEventListener("input",(function(t){!function(t=""){const n=document.querySelectorAll(".edd-email-tags-list-item"),o=function(t,n){const o=e(n),i=function(t){return-1!==e(t).indexOf(o)};return _.filter(t,(function(e){return i(e.title)||_.some(e.keywords,i)}))}(eddEmailTagsInserter.items,t);_.each(n,(function(e){const t=_.findWhere(o,{tag:e.dataset.tag});e.style.display=t?"block":"none"}))}(t.target.value)}))}(),document.addEventListener("keydown",(function(e){const n=e.key||e.keyCode;n&&("ArrowDown"!==n&&40!==n?"ArrowUp"!==n&&38!==n||t("up"):t("down"))})),function(){const e=document.querySelector(".edd-email-tags-inserter");e&&e.addEventListener("click",(()=>{setTimeout((()=>{const e=document.querySelector(".edd-email-tags-filter-search");e&&(e.value="",e.dispatchEvent(new Event("input")),e.focus())}),10)}))}())}))})();