!function(e){formintorjs.define(["admin/settings/multi-setting","text!tpl/fields.html"],function(t,i){return t.extend({multiple:!1,events:{"click .wpmudev-add-option":"add_option","click .wpmudev-action--kill":"delete_option","keyup .wpmudev-item--label .wpmudev-input":"update_label","keyup .wpmudev-item--value .wpmudev-input":"update_value"},className:"wpmudev-option",render:function(){this.$el.html(""),this.$el.append(this.get_label_html()),this.$el.append(this.get_field_html());var e=this.get_saved_value()||[];_.isEmpty(e)||this.$el.find(".wpmudev-multivalue").addClass("wpmudev-has_options"),this.trigger("rendered",this.get_value()),this.on_render()},get_field_html:function(){var t=this.get_values_html();return Forminator.Utils.template(e(i).find("#settings-field-multiple-tpl").html())({childs:t})},get_values_html:function(){var e=this.get_saved_value()||[];return _.map(e,this.get_value_html,this).join("")},get_value_html:function(t,a){this.get_saved_value();return Forminator.Utils.template(e(i).find("#settings-field-multiple-row-tpl").html())({row:t,index:a})},update_label:function(t){var i=e(t.target).closest(".wpmudev-multivalue--item").data("index"),a=e(t.target).val(),l=this.get_saved_value()||[];l[i].label=a,this.save_value(l),this.trigger("updated",l)},update_value:function(t){var i=e(t.target).closest(".wpmudev-multivalue--item").data("index"),a=e(t.target).val(),l=this.get_saved_value()||[];l[i].value=a,this.save_value(l),this.trigger("updated",l)},add_option:function(e){var t=this.get_saved_value()||[];t.push({label:"",value:""}),this.save_value(t),this.trigger("updated",t),this.render()},delete_option:function(t){var i=e(t.target).closest(".wpmudev-multivalue--item").data("index"),a=this.get_saved_value()||[];a.splice(i,1),this.save_value(a),this.trigger("updated",a),this.render()},move_option:function(e,t){var i=this.get_saved_value()||[],a=e.data("index");i.splice(t,0,i.splice(a,1)[0]),this.save_value(i),this.trigger("updated",i),this.render()},on_render:function(){var t=this;setTimeout(function(){e(".wpmudev-multivalue--items").sortable({update:function(e,i){t.move_option(i.item,i.item.index())}})},100)}})})}(jQuery);