window.addEventListener("elementor/init",(()=>{var t=window.elementor.modules.controls.BaseData.extend({onReady:function(){var t=this.getControlValue();this.initFieldsData(t)},initFieldsData:function(t){let e=t.payment_button_text_1,n=t.payment_button_text_2,i=t.payment_button_text_3,a=t.sorted;var r=this;jQuery(this.ui.payment_button_text_1).val(e),jQuery(this.ui.payment_button_text_2).val(n),jQuery(this.ui.payment_button_text_3).val(i),jQuery(this.ui.fieldsContainer).empty(),a.split(",").forEach((function(t){var e={id:"",label:""};switch(t){case"currency":e={id:t,label:"Currency"};break;case"totalPrice":e={id:t,label:"Price"};break;case"frequency":e={id:t,label:"Frequency"};break;case"customText1":e={id:t,label:"Custom text 1"};break;case"customText2":e={id:t,label:"Custom text 2"};break;case"customText3":e={id:t,label:"Custom text 3"}}r.addElement(e)})),this.prepareSortedField()},prepareSortedField:function(){this.ui.fieldsContainer.sortable(),this.ui.fieldsContainer.disableSelection(),this.ui.hiddenInput.change()},ui:function(){return{fieldsContainer:"#fields-sorted-container",hiddenInput:'input[data-setting="price"]',customTextInput:'input[data-setting="payment_button_text"]',payment_button_text_1:'input[data-custom-text-number="1"]',payment_button_text_2:'input[data-custom-text-number="2"]',payment_button_text_3:'input[data-custom-text-number="3"]',separatorTextInput:'input[data-setting="payment_button_separator_text"]'}},events:function(){return{"sortout @ui.fieldsContainer":"onSortEnd","change @ui.hiddenInput":"onHiddenChange","keyup @ui.customTextInput":"onCustomTextChange","keyup @ui.separatorTextInput":"onSeparatorTextChange"}},onCustomTextChange:function(t){var e=this.getControlValue(),n=jQuery(t.currentTarget).val(),i=jQuery(t.currentTarget).attr("data-custom-text-number");n.length<=0?this.deleteElement({id:"customText"+i}):this.addElement({id:"customText"+i,label:"Custom text"+i}),jQuery(this.ui.fieldsContainer).sortable("refresh");var a=jQuery(this.ui.fieldsContainer).sortable("toArray");this.ui.hiddenInput.val(a.toString());var r={sorted:a.toString()};switch(i){case"1":r.payment_button_text_1=n;break;case"2":r.payment_button_text_2=n;break;case"3":r.payment_button_text_3=n}this.setValue({...e,...r})},deleteElement:function(t){jQuery("#"+t.id).remove(),this.ui.hiddenInput.change()},addElement:function(t){var e=jQuery('<div id="'+t.id+'"class="ui-state-default">'+t.label+"</div>");jQuery("#fields-sorted-container").find("#"+t.id).length<=0&&jQuery(this.ui.fieldsContainer).append(e)},onSortEnd:function(t){var e=this.ui.fieldsContainer.sortable("toArray");this.ui.hiddenInput.val(e.toString()),this.ui.hiddenInput.val(e.toString()),this.ui.hiddenInput.change()},onHiddenChange:function(){var t=this.getControlValue(),e=this.ui.fieldsContainer.sortable("toArray");t={...t,sorted:e.toString()};this.setValue(t)},onBeforeDestroy:function(){}});window.elementor.addControlView("fieldssorted",t)}));