!function(e){formintorjs.define(["admin/settings/toggle-container","text!tpl/fields.html"],function(t,n){return t.extend({multiple:!1,events:{"click .wpmudev-add-answer":"add_answer","click .wpmudev-nav--action":"open_menu","click .wpmudev-action--add_field a":"add_field","click .wpmudev-action--kill_field a":"kill_field","click .wpmudev-action--kill_answer a":"kill_answer","change .wpmudev-answer-value":"update_value","change .wpmudev-answer-placeholder":"update_placeholder"},className:"wpmudev-option",init:function(){this.answers=this.model.get("answers")},render:function(){this.$el.html(""),this.$el.append(this.get_label_html()),this.$el.append(this.get_field_html()),this.answers.length>0&&(this.answers.get_max_element_id(),this.$el.find(".wpmudev-multianswer").addClass("wpmudev-has_answers")),this.trigger("rendered",this.get_value()),this.on_render()},get_values_html:function(){var e=this;return this.answers.map(function(t,n){return e.get_value_html(t,n)}).join(" ")},get_value_html:function(t,i){this.get_saved_value();return Forminator.Utils.template(e(n).find("#settings-field-answer-list-row-tpl").html())({row:t.toJSON(),index:i})},get_field_html:function(){var t=this.get_values_html();return Forminator.Utils.template(e(n).find("#settings-field-answer-list-tpl").html())({childs:t})},open_menu:function(t){t.preventDefault(),t.stopPropagation(),e(t.target).closest(".wpmudev-answer").find(".wpmudev-answer--nav").toggleClass("wpmudev-is_active")},add_field:function(t){t.preventDefault(),t.stopPropagation();var n=this.get_model(e(t.target));value=e(t.target).val(),n.set("use_extra",!0),this.render()},kill_field:function(t){t.preventDefault(),t.stopPropagation();var n=this.get_model(e(t.target));value=e(t.target).val(),n.set("use_extra",!1),n.set("extra",""),this.render()},add_answer:function(e){e.preventDefault();var t=this.answers.get_next_element_id(),n=new Forminator.Models.Answer({element_id:"answer-"+t});this.answers.add(n,{silent:!0}),this.render()},kill_answer:function(t){t.preventDefault();var n=e(t.target),i=this.get_model(n);this.answers.remove(i,{silent:!0}),this.render()},get_index:function(e){return e.closest(".wpmudev-answer").data("index")},get_model:function(e){var t=this.get_index(e);return this.answers.get_by_index(t)},move_option:function(e,t){var n=this.get_model(e),i=this.answers.model_index(n);this.answers.move_to(t,i),this.render()},update_value:function(t){var n=this.get_model(e(t.target));value=e(t.target).val(),n.set("title",value)},update_placeholder:function(t){var n=this.get_model(e(t.target));value=e(t.target).val(),n.set("extra",value)},on_render:function(){var t=this;setTimeout(function(){var n=e(".wpmudev-multianswer--list li:last-child").find(".wpmudev-input"),i=n.val();_.isEmpty(i)&&n.focus(),e(".wpmudev-multianswer--list").sortable({handle:".wpmudev-answer--move",update:function(e,n){t.move_option(n.item,n.item.index())}})},100)}})})}(jQuery);