var wpLink;!function(l){var n,t,e,i,r={},s={},a="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){r.wrap=l("#wp-link-wrap"),r.dialog=l("#wp-link"),r.backdrop=l("#wp-link-backdrop"),r.submit=l("#wp-link-submit"),r.close=l("#wp-link-close"),r.url=l("#url-field"),r.nonce=l("#_ajax_linking_nonce"),r.title=l("#link-title-field"),r.openInNewTab=l("#link-target-checkbox"),r.search=l("#search-field"),s.search=new e(l("#search-results")),s.recent=new e(l("#most-recent-results")),s.elements=r.dialog.find(".query-results"),r.queryNotice=l("#query-notice-message"),r.queryNoticeTextDefault=r.queryNotice.find(".query-notice-default"),r.queryNoticeTextHint=r.queryNotice.find(".query-notice-hint"),r.dialog.keydown(wpLink.keydown),r.dialog.keyup(wpLink.keyup),r.submit.click(function(e){e.preventDefault(),wpLink.update()}),r.close.add(r.backdrop).add("#wp-link-cancel a").click(function(e){e.preventDefault(),wpLink.close()}),l("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),s.elements.on("river-select",wpLink.updateFields),r.search.on("focus.wplink",function(){r.queryNoticeTextDefault.hide(),r.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){r.queryNoticeTextDefault.show(),r.queryNoticeTextHint.addClass("screen-reader-text").hide()}),r.search.keyup(function(){var e=this;window.clearTimeout(t),t=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)})},open:function(e){wpLink.range=null,e&&(window.wpActiveEditor=e),window.wpActiveEditor&&(this.textarea=l("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e=tinymce.get(wpActiveEditor),(n=e&&!e.isHidden()?e:null)&&tinymce.isIE&&(n.windowManager.bookmark=n.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),r.wrap.show(),r.backdrop.show(),wpLink.refresh(),l(document).trigger("wplink-open",r.wrap))},isMCE:function(){return n&&!n.isHidden()},refresh:function(){s.search.refresh(),s.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),a?r.url.focus().blur():r.url.focus()[0].select(),s.recent.ul.children().length||s.recent.ajax()},mceRefresh:function(){var e;(e=n.dom.getParent(n.selection.getNode(),"A"))?(r.url.val(n.dom.getAttrib(e,"href")),r.title.val(n.dom.getAttrib(e,"title")),r.openInNewTab.prop("checked","_blank"===n.dom.getAttrib(e,"target")),r.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){wpLink.isMCE()?n.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),r.backdrop.hide(),r.wrap.hide(),l(document).trigger("wplink-close",r.wrap)},getAttrs:function(){return{href:r.url.val(),title:r.title.val(),target:r.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,r=wpLink.textarea;r&&(i=wpLink.getAttrs(),(n=document.createElement("a")).href=i.href,"javascript:"!==n.protocol&&"data:"!==n.protocol||(i.href=""),i.href&&"http://"!=i.href&&(e='/g,">").replace(/"/g,""")+'"'),i.target&&(e+=' rel="noopener" target="'+i.target+'"'),e+=">",document.selection&&wpLink.range?(r.focus(),wpLink.range.text=e+wpLink.range.text+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):void 0!==r.selectionStart&&(t=r.selectionStart,n=r.selectionEnd,i=t+(e=e+r.value.substring(t,n)+"").length,t==n&&(i-="".length),r.value=r.value.substring(0,t)+e+r.value.substring(n,r.value.length),r.selectionStart=r.selectionEnd=i),wpLink.close(),r.focus()))},mceUpdate:function(){var e,t=wpLink.getAttrs();wpLink.close(),n.focus(),tinymce.isIE&&n.selection.moveToBookmark(n.windowManager.bookmark),e=n.dom.getParent(n.selection.getNode(),"a[href]");var i=document.createElement("a");i.href=t.href,"javascript:"!==i.protocol&&"data:"!==i.protocol||(t.href=""),t.href&&"http://"!=t.href?(e?n.dom.setAttribs(e,t):n.execCommand("mceInsertLink",!1,t),n.selection.collapse()):n.execCommand("unlink")},updateFields:function(e,t){r.url.val(t.children(".item-permalink").val()),r.title.val(t.hasClass("no-title")?"":t.children(".item-title").text())},setDefaultValues:function(){var e=n&&n.selection.getContent();e&&/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(e)?r.url.val("mailto:"+e):e&&/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i.test(e)?r.url.val(e.replace(/&|�?38;/gi,"&")):r.url.val("http://"),r.title.val(""),r.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var e,t=l(this),i=t.val();2':"
  • ",n+='',n+='',n+=this.title||wpLinkL10n.noTitle,n+=''+this.info+"
  • ",r=!r}):t&&(n+='
  • '+wpLinkL10n.noMatchesFound+"
  • "),this.ul[t?"html":"append"](n)},maybeLoad:function(){var i=this,n=this.element,e=n.scrollTop()+n.height();!this.query.ready()||e