!function(t){formintorjs.define(["admin/addons/view"],function(i){var a=Backbone.View.extend({el:".sui-wrap.wpmudev-forminator-forminator-integrations",currentTab:"forminator-integrations",events:{"change .forminator-addon-toggle-enabled":"toggle_state","click .connect-integration":"connect_integration","click .forminator-integrations-wrapper .sui-vertical-tab a":"go_to_tab","change .forminator-integrations-wrapper .sui-sidenav-hide-lg select":"go_to_tab","change .forminator-integrations-wrapper .sui-sidenav-hide-lg.integration-nav":"go_to_tab","keyup input.sui-form-control":"required_settings"},initialize:function(i){if(t(this.el).length>0)return this.listenTo(Forminator.Events,"forminator:addons:reload",this.render_addons_page),this.render()},render:function(){this.render_addons_page(),this.update_tab()},render_addons_page:function(){var i=this,a={};this.$el.find("#forminator-integrations-display").html('<div role="alert" id="forminator-addons-preloader" class="sui-notice sui-active" style="display: block;" aria-live="assertive"><div class="sui-notice-content"><div class="sui-notice-message"><span class="sui-notice-icon sui-icon-loader sui-loading" aria-hidden="true"></span><p>Fetching integration list…</p></div></div></div>'),a.action="forminator_addon_get_addons",a._ajax_nonce=Forminator.Data.addonNonce,a.data={},t.post({url:Forminator.Data.ajaxUrl,type:"post",data:a}).done(function(t){t&&t.success&&i.$el.find("#forminator-integrations-page").html(t.data.data)}).always(function(){i.$el.find("#forminator-addons-preloader").remove()})},connect_integration:function(a){a.preventDefault();var e=t(a.target);e.hasClass("connect-integration")||(e=e.closest(".connect-integration"));var n=e.data("nonce"),r=e.data("slug"),o=e.data("multi-global-id"),s=e.data("title"),d=e.data("image"),l=e.data("imagex2"),u=e.data("action"),c=e.data("form-id"),f=e.data("multi-id");Forminator.Integrations_Popup.open(function(){new i({slug:r,nonce:n,action:u,form_id:c,multi_id:f,global_id:o,el:t(this)})},{title:s,image:d,image_x2:l})},go_to_tab:function(i){i.preventDefault();var a=t(i.target),e=a.attr("href"),n="";if(_.isUndefined(e)){n=a.val()}else n=e.replace("#","",e);_.isEmpty(n)||(this.currentTab=n),this.update_tab(),i.stopPropagation()},update_tab_select:function(){this.$el.hasClass("wpmudev-forminator-forminator-integrations")&&(this.$el.find(".sui-sidenav-hide-lg select").val(this.currentTab),this.$el.find(".sui-sidenav-hide-lg select").trigger("sui:change"))},update_tab:function(){this.$el.hasClass("wpmudev-forminator-forminator-integrations")&&(this.clear_tabs(),this.$el.find("[data-tab-id="+this.currentTab+"]").addClass("current"),this.$el.find(".wpmudev-settings--box#"+this.currentTab).show())},clear_tabs:function(){this.$el.hasClass("wpmudev-forminator-forminator-integrations")&&(this.$el.find(".sui-vertical-tab ").removeClass("current"),this.$el.find(".wpmudev-settings--box").hide())},required_settings:function(i){var a=t(i.target),e=a.parent(),n=e.find(".sui-error-message"),r=a.closest("div[data-nav]"),o=r.find(".sui-box-footer"),s=o.find(".wpmudev-action-done");this.$el.hasClass("wpmudev-forminator-forminator-settings")&&(a.hasClass("forminator-required")&&!a.val()&&e.hasClass("sui-form-field")&&(e.addClass("sui-form-field-error"),n.show()),a.hasClass("forminator-required")&&a.val()&&e.hasClass("sui-form-field")&&(e.removeClass("sui-form-field-error"),n.hide()),r.find("input.sui-form-control").hasClass("forminator-required")&&(0===r.find("div.sui-form-field-error").length?s.prop("disabled",!1):s.prop("disabled",!0))),i.stopPropagation()}});jQuery(document).ready(function(){new a})})}(jQuery);