!function(){"use strict";function e(e){return e&&1===e.nodeType&&"false"===e.contentEditable}var t=function(e){var n=e,r=function(){return n};return{get:r,set:function(e){n=e},clone:function(){return t(r())}}},n=tinymce.util.Tools.resolve("tinymce.PluginManager"),r=tinymce.util.Tools.resolve("tinymce.util.Tools"),a={findAndReplaceDOMText:function(t,n,r,a,i){function o(e,t){if(t=t||0,!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");var n=e.index;if(t>0){var r=e[t];if(!r)throw new Error("Invalid capture group");n+=e[0].indexOf(r),e[0]=r}return[n,n+e[0].length,[e[0]]]}function d(t){var n;if(3===t.nodeType)return t.data;if(f[t.nodeName]&&!u[t.nodeName])return"";if(n="",e(t))return"\n";if((u[t.nodeName]||p[t.nodeName])&&(n+="\n"),t=t.firstChild)do{n+=d(t)}while(t=t.nextSibling);return n}var c,l,s,u,f,p,g=[],h=0;if(s=n.ownerDocument,u=i.getBlockElements(),f=i.getWhiteSpaceElements(),p=i.getShortEndedElements(),l=d(n)){if(t.global)for(;c=t.exec(l);)g.push(o(c,a));else c=l.match(t),g.push(o(c,a));return g.length&&(h=g.length,function(t,n,r){var a,i,o,d,c=[],l=0,s=t,g=n.shift(),h=0;e:for(;;){if((u[s.nodeName]||p[s.nodeName]||e(s))&&l++,3===s.nodeType&&(!i&&s.length+l>=g[1]?(i=s,d=g[1]-l):a&&c.push(s),!a&&s.length+l>g[0]&&(a=s,o=g[0]-l),l+=s.length),a&&i){if(s=r({startNode:a,startNodeIndex:o,endNode:i,endNodeIndex:d,innerNodes:c,match:g[2],matchIndex:h}),l-=i.length-d,a=null,i=null,c=[],g=n.shift(),h++,!g)break}else if(f[s.nodeName]&&!u[s.nodeName]||!s.firstChild){if(s.nextSibling){s=s.nextSibling;continue}}else if(!e(s)){s=s.firstChild;continue}for(;;){if(s.nextSibling){s=s.nextSibling;break}if(s.parentNode===t)break e;s=s.parentNode}}}(n,g,function(e){var t;if("function"!=typeof e){var n=e.nodeType?e:s.createElement(e);t=function(e,t){var r=n.cloneNode(!1);return r.setAttribute("data-mce-index",t),e&&r.appendChild(s.createTextNode(e)),r}}else t=e;return function(e){var n,r,a,i=e.startNode,o=e.endNode,d=e.matchIndex;if(i===o){var c=i;a=c.parentNode,e.startNodeIndex>0&&(n=s.createTextNode(c.data.substring(0,e.startNodeIndex)),a.insertBefore(n,c));var l=t(e.match[0],d);return a.insertBefore(l,c),e.endNodeIndex0},p=function(e,t,n){var a,d,c,l;for(d=r.toArray(e.getBody().getElementsByTagName("span")),a=0;a0},h=function(e,t){return d(e,t.get()-1).length>0},m={done:p,find:function(e,t,n,r,i){n=(n=n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")).replace(/\s/g,"\\s"),n=i?"\\b"+n+"\\b":n;var o=function(e,t,n){var r,i;return i=e.dom.create("span",{"data-mce-bogus":1}),i.className="mce-match-marker",r=e.getBody(),p(e,t,!1),a.findAndReplaceDOMText(n,r,i,!1,e.schema)}(e,t,new RegExp(n,r?"g":"gi"));return o&&(t.set(-1),t.set(c(e,t,!0))),o},next:s,prev:u,replace:function(e,t,n,a,d){var c,p,m,v,x,b,N=t.get();for(a=!1!==a,m=e.getBody(),p=r.grep(r.toArray(m.getElementsByTagName("span")),f),c=0;ct.get()&&p[c].setAttribute("data-mce-index",x-1)}return t.set(N),a?(b=g(e,t),s(e,t)):(b=h(e,t),u(e,t)),!d&&b},hasNext:g,hasPrev:h},v=function(e,t){return{done:function(n){return m.done(e,t,n)},find:function(n,r,a){return m.find(e,t,n,r,a)},next:function(){return m.next(e,t)},prev:function(){return m.prev(e,t)},replace:function(n,r,a){return m.replace(e,t,n,r,a)}}},x=function(e,t){function n(){d.statusbar.find("#next").disabled(!1===m.hasNext(e,t)),d.statusbar.find("#prev").disabled(!1===m.hasPrev(e,t))}function a(){e.windowManager.alert("Could not find the specified string.",function(){d.find("#find")[0].focus()})}var i,o={};e.undoManager.add(),i=r.trim(e.selection.getContent({format:"text"}));var d=e.windowManager.open({layout:"flex",pack:"center",align:"center",onClose:function(){e.focus(),m.done(e,t),e.undoManager.add()},onSubmit:function(r){var i,c,l,s;return r.preventDefault(),c=d.find("#case").checked(),s=d.find("#words").checked(),(l=d.find("#find").value()).length?o.text===l&&o.caseState===c&&o.wholeWord===s?m.hasNext(e,t)?(m.next(e,t),void n()):void a():((i=m.find(e,t,l,c,s))||a(),d.statusbar.items().slice(1).disabled(0===i),n(),void(o={text:l,caseState:c,wholeWord:s})):(m.done(e,t,!1),void d.statusbar.items().slice(1).disabled(!0))},buttons:[{text:"Find",subtype:"primary",onclick:function(){d.submit()}},{text:"Replace",disabled:!0,onclick:function(){m.replace(e,t,d.find("#replace").value())||(d.statusbar.items().slice(1).disabled(!0),t.set(-1),o={})}},{text:"Replace all",disabled:!0,onclick:function(){m.replace(e,t,d.find("#replace").value(),!0,!0),d.statusbar.items().slice(1).disabled(!0),o={}}},{type:"spacer",flex:1},{text:"Prev",name:"prev",disabled:!0,onclick:function(){m.prev(e,t),n()}},{text:"Next",name:"next",disabled:!0,onclick:function(){m.next(e,t),n()}}],title:"Find and replace",items:{type:"form",padding:20,labelGap:30,spacing:10,items:[{type:"textbox",name:"find",size:40,label:"Find",value:i},{type:"textbox",name:"replace",size:40,label:"Replace with"},{type:"checkbox",name:"case",text:"Match case",label:" "},{type:"checkbox",name:"words",text:"Whole words",label:" "}]}})},b=function(e,t){e.addCommand("SearchReplace",function(){x(e,t)})},N=function(e,t){return function(){x(e,t)}},y=function(e,t){e.addMenuItem("searchreplace",{text:"Find and replace",shortcut:"Meta+F",onclick:N(e,t),separator:"before",context:"edit"}),e.addButton("searchreplace",{tooltip:"Find and replace",onclick:N(e,t)}),e.shortcuts.add("Meta+F","",N(e,t))};n.add("searchreplace",function(e){var n=t(-1);return b(e,n),y(e,n),v(e,n)})}();