/* 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,e){var i=t.config.autocomplete_commitKeystrokes||CKEDITOR.config.autocomplete_commitKeystrokes;this.editor=t,this.throttle=void 0!==e.throttle?e.throttle:20,this.view=this.getView(),this.model=this.getModel(e.dataCallback),this.model.itemsLimit=e.itemsLimit,this.textWatcher=this.getTextWatcher(e.textTestCallback),this.commitKeystrokes=CKEDITOR.tools.array.isArray(i)?i.slice():[i],this._listeners=[],this.outputTemplate=void 0!==e.outputTemplate?new CKEDITOR.template(e.outputTemplate):null,e.itemTemplate&&(this.view.itemTemplate=new CKEDITOR.template(e.itemTemplate)),"ready"===this.editor.status?this.attach():this.editor.on("instanceReady",function(){this.attach()},this),t.on("destroy",function(){this.destroy()},this)}function e(t){this.itemTemplate=new CKEDITOR.template('
  • {name}
  • '),this.editor=t}function i(t){this.dataCallback=t,this.isActive=!1,this.itemsLimit=0}function s(t){return CKEDITOR.tools.array.reduce(CKEDITOR.tools.object.keys(t),function(e,i){return e[i]=CKEDITOR.tools.htmlEncode(t[i]),e},{})}CKEDITOR.plugins.add("autocomplete",{requires:"textwatcher",onLoad:function(){CKEDITOR.document.appendStyleSheet(this.path+"skins/default.css")},isSupportedEnvironment:function(){return!CKEDITOR.env.ie||8a&&t>s&&!l?i.top-s:e.top>i.top?Math.max(i.bottom,e.top):(n=i.bottom+s>o+n,s>a&&t>s||!n?Math.min(e.bottom,i.bottom):i.top-s)}({editorViewportRect:function(t){var e=t.editable();return CKEDITOR.env.iOS&&!e.isInline()?t.window.getFrame().getParent().getClientRect(!0):e.isInline()?e.getClientRect(!0):t.window.getFrame().getClientRect(!0)}(this.editor),caretRect:t,viewHeight:this.element.getSize("height"),scrollPositionY:e.getScrollPosition().y,windowHeight:i.height});t=function(t){var e=t.leftPosition,i=t.viewWidth;return t=t.windowWidth,e+i>t?t-i:e}({leftPosition:t.left,viewWidth:this.element.getSize("width"),windowWidth:i.width}),this.element.setStyles({left:t+"px",top:e+"px"})},scrollElementTo:function(t){t.scrollIntoParent(this.element)},updateItems:function(t){var e,i=new CKEDITOR.dom.documentFragment(this.document);for(e=0;ei;i++)if(e[i].id==t)return i;return-1},getItemById:function(t){return t=this.getIndexById(t),~t&&this.data[t]||null},hasData:function(){return Boolean(this.data&&this.data.length)},setItem:function(t){if(0>this.getIndexById(t))throw Error("Item with given id does not exist");this.selectedItemId=t},select:function(t){this.fire("change-selectedItemId",t)},selectFirst:function(){this.hasData()&&this.select(this.data[0].id)},selectLast:function(){this.hasData()&&this.select(this.data[this.data.length-1].id)},selectNext:function(){if(null==this.selectedItemId)this.selectFirst();else{var t=this.getIndexById(this.selectedItemId);0>t||t+1==this.data.length?this.selectFirst():this.select(this.data[t+1].id)}},selectPrevious:function(){if(null==this.selectedItemId)this.selectLast();else{var t=this.getIndexById(this.selectedItemId);0>=t?this.selectLast():this.select(this.data[t-1].id)}},setActive:function(t){this.isActive=t,this.fire("change-isActive",t)},setQuery:function(t,e){var i=this,s=CKEDITOR.tools.getNextId();this.lastRequestId=s,this.query=t,this.range=e,this.selectedItemId=this.data=null,this.dataCallback({query:t,range:e},function(t){s==i.lastRequestId&&(i.data=i.itemsLimit?t.slice(0,i.itemsLimit):t,i.fire("change-data",i.data))})}},CKEDITOR.event.implementOn(i.prototype),CKEDITOR.plugins.autocomplete=t,t.view=e,t.model=i,CKEDITOR.config.autocomplete_commitKeystrokes=[9,13]}();