/*
 (C) 2024 - Joomla! Extensions Store
 @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
jQuery(function($){if(jPagebuilderEnabled){$(jPagebuilderEditorIntegrationElement).hide();$(".jpagebuilder-integration-component").show();$(".jpagebuilder-integration-button-editor").addClass("is-active")}else{$(".jpagebuilder-integration-component").hide();$(jPagebuilderEditorIntegrationElement).show();$(".jpagebuilder-integration-button-joomla").addClass("is-active")}if(document.querySelector("script[type=importmap]"))import("editor-api").then(editorApiModule=>{window.jpagebuilderEditorReference=
editorApiModule.JoomlaEditor}).catch(error=>{console.error("An error occurred while loading the module: ",error)});$("[action-switch-builder]").on("click",function(event){event.preventDefault();$("[action-switch-builder]").removeClass("is-active");$(this).addClass("is-active");var action=$(this).data("action");var $container=$(this).parents(".jpagebuilder-integrations").parent();if(action==="editor"){$(".jpagebuilder-integration-component").empty().append('<div class="jpagebuilder-builder-loading"><svg version="1.1" id="L7" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><path fill="#444" d="M31.6,3.5C5.9,13.6-6.6,42.7,3.5,68.4c10.1,25.7,39.2,38.3,64.9,28.1l-3.1-7.9c-21.3,8.4-45.4-2-53.8-23.3 c-8.4-21.3,2-45.4,23.3-53.8L31.6,3.5z"><animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="2s" from="0 50 50" to="360 50 50" repeatCount="indefinite"></animateTransform></path><path fill="#444" d="M42.3,39.6c5.7-4.3,13.9-3.1,18.1,2.7c4.3,5.7,3.1,13.9-2.7,18.1l4.1,5.5c8.8-6.5,10.6-19,4.1-27.7 c-6.5-8.8-19-10.6-27.7-4.1L42.3,39.6z"><animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="1s" from="0 50 50" to="-360 50 50" repeatCount="indefinite"></animateTransform></path><path fill="#444" d="M82,35.7C74.1,18,53.4,10.1,35.7,18S10.1,46.6,18,64.3l7.6-3.4c-6-13.5,0-29.3,13.5-35.3s29.3,0,35.3,13.5 L82,35.7z"><animateTransform attributeName="transform" attributeType="XML" type="rotate" dur="2s" from="0 50 50" to="360 50 50" repeatCount="indefinite"></animateTransform></path></svg></div>');
$("#jform_attribs_jpagebuilder_active").val("0");if(typeof WFEditor!=="undefined")$(".wf-editor",$container).each(function(){var value=this.nodeName==="TEXTAREA"?this.value:this.innerHTML;const editor=this.id;if(typeof window.jpagebuilderEditorReference!=="undefined"&&window.jpagebuilderEditorReference.getActive()){var editorReference=window.jpagebuilderEditorReference.get(this.id);editorReference.setValue(value)}else Joomla.editors.instances[this.id].setValue(value);$(this).parent(".wf-editor-container").show()});
if($("div.jpagebuilder-integration-component div.jpagebuilder-builder-loading").length)$("#toolbar-apply button").trigger("click")}else{if(typeof WFEditor!=="undefined")$(".wf-editor",$container).each(function(){const editor=this.id;if(typeof window.jpagebuilderEditorReference!=="undefined"&&window.jpagebuilderEditorReference.getActive()){var editorReference=window.jpagebuilderEditorReference.get(this.id);this.value=editorReference.getValue()}else this.value=Joomla.editors.instances[this.id].getValue();
$(this).parent(".wf-editor-container").hide()});$(jPagebuilderEditorIntegrationElement).hide();$(".jpagebuilder-integration-component").show();$("#jform_attribs_jpagebuilder_active").val("1");if($("div.jpagebuilder-integration-component div.jpagebuilder-builder-loading").length)$("#toolbar-apply button").trigger("click")}})});
