/* jce - 2.9.32 | 2022-11-01 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2022 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
!function(){function debounce(callback,time){var timer,func;return func=function(){var args=arguments;clearTimeout(timer),timer=setTimeout(function(){callback.apply(this,args)},time)},func.stop=function(){clearTimeout(timer)},func}function cleanContent(ed,content){return content.replace(/<br data-mce-bogus="1"([^>]+)>/gi,"")}function hasCustomEditorInit(ed){return!(!window.widgetkit||ed.id.indexOf("wk_")===-1)||ed.id.indexOf("sppb-editor-")!==-1}var DOM=tinymce.DOM,Event=tinymce.dom.Event;tinymce.create("tinymce.plugins.SourcePlugin",{init:function(ed,url){function isEditorActive(){return 0==DOM.hasClass(ed.getElement(),"wf-no-editor")}var self=this;self.editor=ed,ed.onSetContent.add(function(ed,o){self.setContent(ed.getContent(),!0)}),ed.onInit.add(function(ed){if(0!=isEditorActive()){var activeTab=ed.settings.active_tab||"";"wf-editor-source"===activeTab&&(DOM.hide(ed.getContainer()),DOM.hide(ed.getElement()),window.setTimeout(function(){self.toggle()},10))}}),this.ControlManager=new tinymce.ControlManager(ed)},getSourceEditor:function(){var ed=this.editor,textarea=DOM.get(ed.id+"_editor_source_textarea");return textarea||null},setContent:function(v){var editor=this.getSourceEditor();return!!editor&&(editor.value=v)},insertContent:function(v){var editor=this.getSourceEditor();if(editor)if(editor.focus(),document.selection){var rng=document.selection.createRange();rng.text=v}else editor.setRangeText(v,editor.selectionStart,editor.selectionEnd,"end");return!1},getContent:function(){var editor=this.getSourceEditor();return editor?editor.value:null},hide:function(){var ed=this.editor;DOM.hide(ed.id+"_editor_source")},save:function(content,debounced){var ed=this.editor,el=ed.getElement();if(!el)return content;content=tinymce.is(content)?content:this.getContent();var args={content:content,no_events:!0,format:"raw"};return ed.onWfEditorSave.dispatch(ed,args),/TEXTAREA|INPUT/i.test(el.nodeName)?el.value=args.content:el.innerHTML=args.content,debounced&&ed.onWfEditorChange.dispatch(ed,args),args.content},toggle:function(){var ed=this.editor,self=this,s=ed.settings,element=ed.getElement(),container=element.parentNode,header=DOM.getPrev(element,".wf-editor-header"),div=DOM.get(ed.id+"_editor_source"),textarea=DOM.get(ed.id+"_editor_source_textarea"),ifrHeight=parseInt(DOM.get(ed.id+"_ifr").style.height,10)||s.height,o=tinymce.util.Storage.getHash("TinyMCE_"+ed.id+"_size");o&&o.height&&(ifrHeight=o.height);var content=tinymce.is(element.value)?element.value:element.innerHTML;if(content=cleanContent(ed,content),div)DOM.show(div),textarea.value=content;else{div=DOM.add(container,"div",{role:"textbox",id:ed.id+"_editor_source",class:"wf-editor-source"});var skin=s.skin_class||"defaultSkin";DOM.addClass(div,skin),textarea=DOM.create("textarea",{id:ed.id+"_editor_source_textarea"}),DOM.add(div,textarea),textarea.value=content;var statusbar=DOM.add(div,"div",{id:ed.id+"_editor_source_statusbar",class:"mceStatusbar mceLast"},'<div class="mcePathRow"></div><div tabindex="-1" class="mceResize" id="'+ed.id+'_editor_source_resize"><span class="mceIcon mce_resize"></span></div>'),resize=DOM.get(ed.id+"_editor_source_resize");if(Event.add(resize,"click",function(e){e.preventDefault()}),Event.add(resize,"mousedown",function(e){function resizeTo(w,h){w=Math.max(w,300),h=Math.max(h,200),textarea.style.height=h+"px",container.style.maxWidth=w+"px",ed.settings.container_width=w,ed.settings.container_height=h+statusbar.offsetHeight,h-=ed.settings.interface_height||0,ed.theme.resizeTo(w,h)}function resizeOnMove(e){e.preventDefault(),w=sw+(e.screenX-sx),h=sh+(e.screenY-sy),resizeTo(w,h),DOM.addClass(resize,"wf-editor-source-resizing")}function endResize(e){e.preventDefault(),Event.remove(DOM.doc,"mousemove",mm1),Event.remove(DOM.doc,"mouseup",mu1),w=sw+(e.screenX-sx),h=sh+(e.screenY-sy),resizeTo(w,h),DOM.removeClass(resize,"wf-editor-source-resizing")}var mm1,mu1,sx,sy,sw,sh,w,h;return e.preventDefault(),DOM.hasClass(resize,"wf-editor-source-resizing")?(endResize(e),!1):(sx=e.screenX,sy=e.screenY,sw=w=container.offsetWidth,sh=h=textarea.clientHeight,mm1=Event.add(DOM.doc,"mousemove",resizeOnMove),void(mu1=Event.add(DOM.doc,"mouseup",endResize)))}),hasCustomEditorInit(ed)){var keyup=debounce(function(e){var value=textarea.value;value=value.replace(/^\s*|\s*$/g,""),self.save(value,!0)},300);DOM.bind(textarea,"input blur",function(){keyup()})}}DOM.removeClass(container,"mce-loading");var height=ed.settings.container_height||sessionStorage.getItem("wf-editor-container-height")||ifrHeight+statusbar.offsetHeight;if(DOM.hasClass(container,"mce-fullscreen")){var vp=DOM.getViewPort();height=vp.h-header.offsetHeight-statusbar.offsetHeight-4}DOM.setStyles(textarea,{height:height})},getSelection:function(){return document.getSelection()},getCursorPos:function(){return 0}}),tinymce.PluginManager.add("source",tinymce.plugins.SourcePlugin)}();