!function(e){formintorjs.define(["text!admin/templates/fields.html"],function(t){return Backbone.View.extend({events:{"click .wpmudev-form-field":"activate_field"},mainTpl:Forminator.Utils.template(e(t).find("#builder-field-main-tpl").html()),className:"wpmudev-form-col",initialize:function(e){return this.field=this.model,this.layout=e.layout,this.field.off("forminator:field:settings:updated"),this.field.on("forminator:field:settings:updated",this.render,this),this.render()},render:function(){var e={field:this.field.toJSON(),condition:this.get_condition_markup()};this.$el.attr("id","wpmudev-field-"+this.field.cid),this.$el.html(""),this.$el.append(this.mainTpl(e)),this.$el.addClass("wpmudev-form-col-"+this.field.get("cols")),this.render_content()},get_condition_markup:function(){if(!_.isUndefined(this.field.get("conditions"))&&this.field.get("conditions").length>0){var e="show"===this.field.get("condition_action")?Forminator.l10n.sidebar.shown:Forminator.l10n.sidebar.hidden,t=Forminator.Utils.get_fields(this.layout.get("wrappers")),i=this.field.get("conditions");if(0===i.length)return!1;var n,o="",r=i.get_by_index(0),l=_.where(t,{element_id:r.get("element_id")})[0];if(void 0===l)return void i.remove(r,{silent:!0});if(l.hasOptions&&l.values.length>0){var s=_.where(l.values,{value:r.get("value")})[0];if(s||(s=_.where(l.values,{label:r.get("value")})[0]),!s)return i.remove(r,{silent:!0}),void Forminator.Events.trigger("sidebar:settings:updated",this.field);n=s.label}else n=r.get("value");if(i.length>1){var a=Forminator.Utils.template(" + {{ total }} {{ more_label }}"),d=i.length-1;o=a({total:d,more_label:1===d?Forminator.l10n.conditions.more_condition:Forminator.l10n.conditions.more_conditions})}_.isEmpty(n)&&(n="null");return Forminator.Utils.template("{{ action }} {{ Forminator.l10n.sidebar.if }} <strong>{{ label }}</strong> {{ rule }} <strong>{{ valueLabel }}</strong> {{ moreConditions }}")({action:e,label:l.label,rule:Forminator.l10n.conditions[r.get("rule")],valueLabel:n,moreConditions:o})}},render_content:function(){var t=_.where(Forminator.Data.fields,{slug:this.field.get("type")})[0],i=_.isUndefined(t.markup)?"":t.markup;this.contentTpl=Forminator.Utils.template(i);var n=this.field.toJSON();return this.$el.find(".wpmudev-form-field--section").append(this.contentTpl({field:n})),Forminator.Utils.append_select2(e(this.$el),this.model),this},activate_field:function(t){if(!(e(t.target).closest(".select2").length>0)&&"checkbox"!==e(t.target).attr("type")&&"radio"!==e(t.target).attr("type")){var i=this.$el.find(".wpmudev-form-field");e(".wpmudev-form-field").not(i).each(function(){e(this).removeClass("wpmudev-is_active")}),i.toggleClass("wpmudev-is_active"),i.hasClass("wpmudev-is_active")?Forminator.Events.trigger("forminator:sidebar:open:settings",this.field):Forminator.Events.trigger("forminator:sidebar:close:settings")}}})})}(jQuery);