!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]&&arguments[0];this.wizardMode=t,this.nonce=this.content.data("nonce"),this.addTranslationManagerButton=this.content.find(".js-add-translation-manager"),this.addTranslationManagerButton.on("click",function(t){return e.openAddTranslationManagerDialog()}),this.managersList=this.$(".js-translation-managers-list"),this.noTranslationManagersMessage=this.$(".js-no-translation-managers"),this.content.find(".js-remove-translation-manager").off("click").on("click",function(t){return e.removeTranslationManager(t)}),this.error=this.content.find(".js-error-message"),this.showOrHideList(),this.setButtonText(),this.wizardMode&&(this.hideHeading(),this.noTranslationManagersMessage.hide())}},{key:"hideHeading",value:function(){this.content.find("h2").hide()}},{key:"openAddTranslationManagerDialog",value:function(){var e=this;this.addNewTranslationManagerDialog||(this.addNewTranslationManagerDialog=new o.default(this.$,this.content,function(t){return e.translationManagerAdded(t)})),this.addNewTranslationManagerDialog.open()}},{key:"translationManagerAdded",value:function(e){var t=this;this.addNewTranslationManagerDialog.close(),this.managersList.prepend(e),this.showOrHideList(),this.setButtonText(),this.content.find(".js-remove-translation-manager").off("click").on("click",function(e){return t.removeTranslationManager(e)}),this.refreshPageIfYouAddedYourself(),this.notifyObservers()}},{key:"showOrHideList",value:function(){this.getManagerCount()?(this.managersList.show(),this.noTranslationManagersMessage.hide()):(this.managersList.hide(),this.wizardMode||this.noTranslationManagersMessage.show())}},{key:"setButtonText",value:function(){this.getManagerCount()?this.addTranslationManagerButton.html(this.addTranslationManagerButton.data("add-text")).removeClass("button-primary").addClass("button-secondary alignright"):this.addTranslationManagerButton.html(this.addTranslationManagerButton.data("set-text")).removeClass("button-secondary alignright").addClass("button-primary")}},{key:"getManagerCount",value:function(){return this.managersList.find("li").length}},{key:"removeTranslationManager",value:function(e){var t=this,n=this.$(e.target).closest("li"),i=n.data("user_id");this.$.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"wpml_remove_translation_manager",nonce:this.nonce,user_id:i},success:function(e){return t.userRemoved(e,n)}})}},{key:"userRemoved",value:function(e,t){var n=this;e.success?t.fadeOut(300,function(){t.remove(),n.showOrHideList(),n.setButtonText(),n.refreshPageIfYouRemoveYourself(t.data("user_id")),n.notifyObservers()}):this.showError(e.data)}},{key:"showError",value:function(e){var t=this;this.error.text(e),this.error.show(),setTimeout(function(){t.error.fadeOut()},5e3)}},{key:"refreshPageIfYouRemoveYourself",value:function(e){0===this.observers.length&&this.content.data("current-user-id")===e&&location.reload()}},{key:"refreshPageIfYouAddedYourself",value:function(){0===this.observers.length&&(this.content.data("current-user-id")===this.managersList.find("li:first").data("user_id")&&location.reload())}},{key:"addObserver",value:function(e){this.observers.push(e)}},{key:"notifyObservers",value:function(){this.observers.forEach(function(e){return e.onTranslationManagerChange()})}}]),e}();t.default=a},function(e,t,n){"use strict";var i=function(e){return e&&e.__esModule?e:{default:e}}(n(4));jQuery(function(){new i.default(jQuery,jQuery(".js-translation-managers")).init()})},function(e,t,n){e.exports=n(5)}]);