var wpLink;!function(a){var n,t,e,i,l={},r={},s="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){l.wrap=a("#wp-link-wrap"),l.dialog=a("#wp-link"),l.backdrop=a("#wp-link-backdrop"),l.submit=a("#wp-link-submit"),l.close=a("#wp-link-close"),l.url=a("#url-field"),l.nonce=a("#_ajax_linking_nonce"),l.title=a("#link-title-field"),l.openInNewTab=a("#link-target-checkbox"),l.search=a("#search-field"),r.search=new e(a("#search-results")),r.recent=new e(a("#most-recent-results")),r.elements=l.dialog.find(".query-results"),l.queryNotice=a("#query-notice-message"),l.queryNoticeTextDefault=l.queryNotice.find(".query-notice-default"),l.queryNoticeTextHint=l.queryNotice.find(".query-notice-hint"),l.dialog.keydown(wpLink.keydown),l.dialog.keyup(wpLink.keyup),l.submit.click(function(e){e.preventDefault(),wpLink.update()}),l.close.add(l.backdrop).add("#wp-link-cancel a").click(function(e){e.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),r.elements.on("river-select",wpLink.updateFields),l.search.on("focus.wplink",function(){l.queryNoticeTextDefault.hide(),l.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){l.queryNoticeTextDefault.show(),l.queryNoticeTextHint.addClass("screen-reader-text").hide()}),l.search.keyup(function(){var e=this;window.clearTimeout(t),t=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)})},open:function(e){a(document.body).addClass("modal-open"),wpLink.range=null,e&&(window.wpActiveEditor=e),window.wpActiveEditor&&(this.textarea=a("#"+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()),l.wrap.show(),l.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",l.wrap))},isMCE:function(){return n&&!n.isHidden()},refresh:function(){r.search.refresh(),r.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),s?l.url.focus().blur():l.url.focus()[0].select(),r.recent.ul.children().length||r.recent.ajax()},mceRefresh:function(){var e;(e=n.dom.getParent(n.selection.getNode(),"A"))?(l.url.val(n.dom.getAttrib(e,"href")),l.title.val(n.dom.getAttrib(e,"title")),l.openInNewTab.prop("checked","_blank"===n.dom.getAttrib(e,"target")),l.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){a(document.body).removeClass("modal-open"),wpLink.isMCE()?n.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),l.backdrop.hide(),l.wrap.hide(),a(document).trigger("wplink-close",l.wrap)},getAttrs:function(){return{href:l.url.val(),title:l.title.val(),target:l.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,l=wpLink.textarea;l&&(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?(l.focus(),wpLink.range.text=e+wpLink.range.text+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):void 0!==l.selectionStart&&(t=l.selectionStart,n=l.selectionEnd,i=t+(e=e+l.value.substring(t,n)+"").length,t==n&&(i-="".length),l.value=l.value.substring(0,t)+e+l.value.substring(n,l.value.length),l.selectionStart=l.selectionEnd=i),wpLink.close(),l.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){l.url.val(t.children(".item-permalink").val()),l.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)?l.url.val("mailto:"+e):e&&/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i.test(e)?l.url.val(e.replace(/&|?38;/gi,"&")):l.url.val("http://"),l.title.val(""),l.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var e,t=a(this),i=t.val();2':"",n+='',n+='',n+=this.title||wpLinkL10n.noTitle,n+=''+this.info+"",l=!l}):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