/* Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved. For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license */ !function(){function t(t){return t.type==CKEDITOR.NODE_TEXT&&0=9&&13>=e||e>=8192&&8202>=e||R.test(t)}function o(t){var e=r.getSelection().getRanges()[0],a=r.editable();return e&&!t?(t=e.clone(),t.collapse(!0)):(t=r.createRange(),t.setStartAt(a,CKEDITOR.POSITION_AFTER_START)),t.setEndAt(a,CKEDITOR.POSITION_BEFORE_END),t}function g(t,e){var a=e.replace(m,function(t){return t=t.split(""),CKEDITOR.tools.array.map(t,function(t,e){return 0===e%2?" ":t}).join("")});return t.document.createText(a)}var d=new CKEDITOR.style(CKEDITOR.tools.extend({attributes:{"data-cke-highlight":1},fullMatch:1,ignoreReadonly:1,childRule:function(){return 0}},r.config.find_highlight,!0));s.prototype={next:function(){return this.move()},back:function(){return this.move(!0)},move:function(t){var e=this.textNode;if(null===e)return n.call(this);if(this._.matchBoundary=!1,e&&t&&0e.length){var a=this._.walker.textNode;if(!a)return null;t.setStartAfter(a)}else a=e[0],e=e[e.length-1],t.setStart(a.textNode,a.offset),t.setEnd(e.textNode,e.offset+1);return t},updateFromDomRange:function(t){var e=new s(t);this._.cursors=[];do t=e.next(),t.character&&this._.cursors.push(t);while(t.character);this._.rangeLength=this._.cursors.length},setMatched:function(){this._.isMatched=!0},clearMatched:function(){this._.isMatched=!1},isMatched:function(){return this._.isMatched},highlight:function(){if(!(1>this._.cursors.length)){this._.highlightRange&&this.removeHighlight();var t=this.toDomRange(),e=t.createBookmark();d.applyToRange(t,r),t.moveToBookmark(e),this._.highlightRange=t,e=t.startContainer,e.type!=CKEDITOR.NODE_ELEMENT&&(e=e.getParent()),e.scrollIntoView(),this.updateFromDomRange(t)}},removeHighlight:function(){if(this._.highlightRange){var t=this._.highlightRange.createBookmark();d.removeFromRange(this._.highlightRange,r),this._.highlightRange.moveToBookmark(t),this.updateFromDomRange(this._.highlightRange),this._.highlightRange=null}},isReadOnly:function(){return this._.highlightRange?this._.highlightRange.startContainer.isReadOnly():0},moveBack:function(){var t=this._.walker.back(),e=this._.cursors;return t.hitMatchBoundary&&(this._.cursors=e=[]),e.unshift(t),e.length>this._.rangeLength&&e.pop(),t},moveNext:function(){var t=this._.walker.next(),e=this._.cursors;return t.hitMatchBoundary&&(this._.cursors=e=[]),e.push(t),e.length>this._.rangeLength&&e.shift(),t},getEndCharacter:function(){var t=this._.cursors;return 1>t.length?null:t[t.length-1].character},getNextCharacterRange:function(t){var e,a;return a=this._.cursors,a=(e=a[a.length-1])&&e.textNode?new s(l(e)):this._.walker,new u(a,t)},getCursors:function(){return this._.cursors}};var f=function(t,e){var a=[-1];e&&(t=t.toLowerCase());for(var n=0;no;o++)s=this.getContentElement(i[r],h[o][r]),c=this.getContentElement(i[l],h[o][l]),c.setValue(s.getValue())}}})},onShow:function(){C.searchRange=o();var t=this._.currentTabId,e=this.getParentEditor().getSelection().getSelectedText(),a=this.getContentElement(t,"find"==t?"txtFindFind":"txtFindReplace");a.setValue(e),a.select(),this[("find"==t&&this._.editor.readOnly?"hide":"show")+"Page"]("replace")},onHide:function(){var t;C.matchRange&&C.matchRange.isMatched()&&(C.matchRange.removeHighlight(),(t=C.matchRange.toDomRange())&&r.getSelection().selectRanges([t]),r.focus()),delete C.matchRange},onFocus:function(){return"replace"==this._.currentTabId?this.getContentElement("replace","txtFindReplace"):this.getContentElement("find","txtFindFind")}}})}();