function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _defineProperty(e,t,i){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}jQuery(function(e){var t=_glsr_deactivate,i=Backbone.Model.extend({defaults:{details:"",name:"",reason:"",slug:"",version:""}}),n=Backbone.Collection.extend({model:i}),o=Backbone.View.extend({className:"glsr-dp-overlay",isBusy:!1,model:null,target:null,template:null,events:{click:"closeOverlay","click .expand-info":"expandDetails","click .glsr-dp-reason":"selectReason","click .submit":"submit",'input input[name="reason"]':"updateModel",'input textarea[name="details"]':"updateModel"},initialize:function(e){_.extend(this,_.pick(e,"target")),this.template=wp.template("glsr-deativate")},render:function(){var e=_.extend({},this.model.toJSON(),t,{action:this.target.attr("href")});return this.$el.html(this.template(e)),this.containFocus(),this},closeOverlay:function(t){var i=this;(27===event.keyCode||e(t.target).is(".close")||e(t.target).is(".deactivate")||e(t.target).is(".glsr-dp-backdrop"))&&(e("body").addClass("closing-overlay"),this.$el.fadeOut(130,function(){e("body").removeClass("closing-overlay"),e("body").removeClass("modal-open"),i.remove(),i.unbind(),i.target&&i.target.trigger("focus")}))},containFocus:function(){var t=this;_.delay(function(){return e(".glsr-dp-overlay").trigger("focus")},100),this.$el.on("keydown.glsr",function(e){var i=t.$el.find(".glsr-dp-header button").first(),n=t.$el.find(".glsr-dp-footer a").last();9===e.which&&(i[0]===e.target&&e.shiftKey?(n.trigger("focus"),e.preventDefault()):n[0]!==e.target||e.shiftKey||(i.trigger("focus"),e.preventDefault()))})},expandDetails:function(){this.$("#glsr-dp-info").slideToggle("fast")},onChange:function(e){this.isBusy||this.updateModel(e.currentTarget)},selectReason:function(t){var i=e(t.currentTarget),n=i.data("placeholder"),o=this.$(".glsr-dp-help"),a=i.find("input").val(),r=["feature-missing"],s=["confused","looking-for-different","not-working"];this.$(".glsr-dp-reason").removeClass("is-selected"),this.$(".glsr-dp-details textarea").attr("placeholder",n),this.$(".glsr-dp-details")[""===n?"slideUp":"slideDown"]("fast"),i.toggleClass("is-selected"),~[].concat(r,s).indexOf(a)?(o.find(".is-info")[~r.indexOf(a)?"show":"hide"](),o.find(".is-warning")[~s.indexOf(a)?"show":"hide"](),o.slideDown("fast")):o.slideUp("fast")},submit:function(i){var n=this;i.preventDefault();var o=_defineProperty({},t.ajax.prefix,_.extend({},this.model.toJSON(),{_action:"deactivate",_nonce:t.ajax.nonce}));e(i.currentTarget).addClass("is-busy").prop("disabled",!0).text(t.l10n.processing),wp.ajax.post(t.ajax.action,o).always(function(){window.location.href=n.target.attr("href")})},updateModel:function(e){this.isBusy||(this.isBusy=!0,this.model.set(e.target.name,e.target.value,{validate:!1}),this.isBusy=!1)}});new(Backbone.View.extend({el:"#the-list",collection:null,overlay:e("#glsr-dp-overlay"),events:{"click a[data-deactivate]":"openOverlay"},initialize:function(){this.collection=new n(t.plugins)},openOverlay:function(t){var i=e(t.target),n=i.data("deactivate"),a=this.collection.findWhere({slug:n});if(a){var r=new o({model:a,target:i});t.preventDefault(),e("body").addClass("modal-open"),r.render(),this.overlay.html(r.el)}}}))});
