/* 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 d(a,b){var c=a.config.autocomplete_commitKeystrokes||CKEDITOR.config.autocomplete_commitKeystrokes;this.editor=a;this.throttle=void 0!==b.throttle?b.throttle:20;this.followingSpace=b.followingSpace;this.view=this.getView();this.model=this.getModel(b.dataCallback);this.model.itemsLimit=b.itemsLimit;this.textWatcher=this.getTextWatcher(b.textTestCallback);this.commitKeystrokes=CKEDITOR.tools.array.isArray(c)?c.slice():[c];this._listeners=[];this.outputTemplate=void 0!==b.outputTemplate? new CKEDITOR.template(b.outputTemplate):null;b.itemTemplate&&(this.view.itemTemplate=new CKEDITOR.template(b.itemTemplate));if("ready"===this.editor.status)this.attach();else this.editor.on("instanceReady",function(){this.attach()},this);a.on("destroy",function(){this.destroy()},this)}function g(a){this.itemTemplate=new CKEDITOR.template('\x3cli data-id\x3d"{id}"\x3e{name}\x3c/li\x3e');this.editor=a}function f(a){this.dataCallback=a;this.isActive=!1;this.itemsLimit=0}function h(a){return CKEDITOR.tools.array.reduce(CKEDITOR.tools.object.keys(a), function(b,c){b[c]=CKEDITOR.tools.htmlEncode(a[c]);return b},{})}function l(a){var b=a.getSelection().getRanges()[0].getNextNode(function(a){return Boolean(a.type==CKEDITOR.NODE_TEXT&&a.getText())});b&&b.getText().match(/^\s+/)&&(a=a.createRange(),a.setStart(b,0),a.setEnd(b,1),a.deleteContents())}CKEDITOR.plugins.add("autocomplete",{requires:"textwatcher",onLoad:function(){CKEDITOR.document.appendStyleSheet(this.path+"skins/default.css")},isSupportedEnvironment:function(){return!CKEDITOR.env.ie|| 8f&&ec.top)return Math.max(c.bottom,b.top);d=c.bottom+e>g+d;return e>f&&ea?a-c:b}({leftPosition:a.left,viewWidth:this.element.getSize("width"),windowWidth:c.width});this.element.setStyles({left:a+"px",top:b+"px"})},scrollElementTo:function(a){a.scrollIntoParent(this.element)},updateItems:function(a){var b,c=new CKEDITOR.dom.documentFragment(this.document);for(b=0;bthis.getIndexById(a))throw Error("Item with given id does not exist");this.selectedItemId= a},select:function(a){this.fire("change-selectedItemId",a)},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 a=this.getIndexById(this.selectedItemId);0>a||a+1==this.data.length?this.selectFirst():this.select(this.data[a+1].id)}},selectPrevious:function(){if(null==this.selectedItemId)this.selectLast();else{var a=this.getIndexById(this.selectedItemId); 0>=a?this.selectLast():this.select(this.data[a-1].id)}},setActive:function(a){this.isActive=a;this.fire("change-isActive",a)},setQuery:function(a,b){var c=this,d=CKEDITOR.tools.getNextId();this.lastRequestId=d;this.query=a;this.range=b;this.selectedItemId=this.data=null;this.dataCallback({query:a,range:b},function(a){d==c.lastRequestId&&(c.data=c.itemsLimit?a.slice(0,c.itemsLimit):a,c.fire("change-data",c.data))})}};CKEDITOR.event.implementOn(f.prototype);CKEDITOR.plugins.autocomplete=d;d.view=g; d.model=f;CKEDITOR.config.autocomplete_commitKeystrokes=[9,13]})();