/*
 Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
 For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
(function(){CKEDITOR.plugins.add("stylescombo",{requires:"richcombo",lang:"af,ar,az,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,es-mx,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,oc,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn",init:function(c){var l=c.config,h=c.lang.stylescombo,f={},k=[],m=[];c.on("stylesSet",function(a){if(a=a.data.styles){for(var b,d,e,g=0,n=a.length;g<n;g++)(b=a[g],c.blockless&&b.element in
CKEDITOR.dtd.$block||"string"==typeof b.type&&!CKEDITOR.style.customHandlers[b.type]||(d=b.name,b=new CKEDITOR.style(b),c.filter.customConfig&&!c.filter.check(b)))||(b._name=d,b._.enterMode=l.enterMode,b._.type=e=b.assignedTo||b.type,b._.weight=g+1E3*(e==CKEDITOR.STYLE_OBJECT?1:e==CKEDITOR.STYLE_BLOCK?2:3),f[d]=b,k.push(b),m.push(b));k.sort(function(a,b){return a._.weight-b._.weight})}});c.on("stylesRemove",function(a){a=a.data&&a.data.type;var b=void 0===a,d;for(d in f){var e=f[d];(b||e.type===a)&&
c.removeStyle(e)}});c.ui.addRichCombo("Styles",{label:h.label,title:h.panelTitle,toolbar:"styles,10",allowedContent:m,panel:{css:[CKEDITOR.skin.getPath("editor")].concat(l.contentsCss),multiSelect:!0,attributes:{"aria-label":h.panelTitle}},init:function(){var a,b,c,e,g,f;g=0;for(f=k.length;g<f;g++)a=k[g],b=a._name,e=a._.type,e!=c&&(this.startGroup(h["panelTitle"+String(e)]),c=e),this.add(b,a.type==CKEDITOR.STYLE_OBJECT?b:a.buildPreview(),b);this.commit()},onClick:function(a){c.focus();c.fire("saveSnapshot");
a=f[a];var b=c.elementPath();if(a.group&&a.removeStylesFromSameGroup(c))c.applyStyle(a);else c[a.checkActive(b,c)?"removeStyle":"applyStyle"](a);c.fire("saveSnapshot")},onRender:function(){c.on("selectionChange",function(a){var b=this.getValue();a=a.data.path.elements;for(var d=0,e=a.length,g;d<e;d++){g=a[d];for(var h in f)if(f[h].checkElementRemovable(g,!0,c)){h!=b&&this.setValue(h);return}}this.setValue("")},this)},onOpen:function(){var a=c.getSelection(),a=a.getSelectedElement()||a.getStartElement()||
c.editable(),a=c.elementPath(a),b=[0,0,0,0];this.showAll();this.unmarkAll();for(var d in f){var e=f[d],g=e._.type;e.checkApplicable(a,c,c.activeFilter)?b[g]++:this.hideItem(d);e.checkActive(a,c)&&this.mark(d)}b[CKEDITOR.STYLE_BLOCK]||this.hideGroup(h["panelTitle"+String(CKEDITOR.STYLE_BLOCK)]);b[CKEDITOR.STYLE_INLINE]||this.hideGroup(h["panelTitle"+String(CKEDITOR.STYLE_INLINE)]);b[CKEDITOR.STYLE_OBJECT]||this.hideGroup(h["panelTitle"+String(CKEDITOR.STYLE_OBJECT)]);d=document.querySelector(".cke_panel.cke_combopanel");
a=document.querySelector(".cke_inner.cke_maximized");d&&a?d.classList.add("lfr-maximized"):d.classList.remove("lfr-maximized")},refresh:function(){var a=c.elementPath();if(a){for(var b in f)if(f[b].checkApplicable(a,c,c.activeFilter))return;this.setState(CKEDITOR.TRISTATE_DISABLED)}},reset:function(){f={};k=[]}})}})})();