!function(){"use strict";function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(r=o.key,i=void 0,"symbol"==typeof(i=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(r,"string"))?i:String(i)),o)}var r,i}function e(t){return e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},e(t)}function n(t,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},n(t,e)}function o(t,e,r){return o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,o){var r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return o&&n(i,o.prototype),i},o.apply(null,arguments)}function r(t){var i="function"==typeof Map?new Map:void 0;return r=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,s)}function s(){return o(t,arguments,e(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),n(s,t)},r(t)}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}window.customElements.define("joomla-toolbar-button",function(e){var o,r;function s(){var t;if(t=e.call(this)||this,!Joomla)throw new Error("Joomla API is not properly initiated");return t.onChange=t.onChange.bind(i(t)),t.executeTask=t.executeTask.bind(i(t)),t}r=e,(o=s).prototype=Object.create(r.prototype),o.prototype.constructor=o,n(o,r);var u,c,a,l=s.prototype;return l.connectedCallback=function(){this.buttonElement=this.querySelector("button, a"),this.buttonElement.addEventListener("click",this.executeTask);var t=this.form||"adminForm";if(this.formElement=document.getElementById(t),this.disabled=!1,this.listSelection&&this.setDisabled(!0),this.listSelection){if(!this.formElement)throw new Error('The form "'+t+'" is required to perform the task, but the form was not found on the page.');this.formElement.boxchecked.addEventListener("change",this.onChange)}},l.disconnectedCallback=function(){this.formElement.boxchecked&&this.formElement.boxchecked.removeEventListener("change",this.onChange),this.buttonElement.removeEventListener("click",this.executeTask)},l.onChange=function(t){var e=t.target;this.setDisabled(e.value<1)},l.setDisabled=function(t){this.disabled=!!t,this.buttonElement&&(this.disabled?"BUTTON"===this.buttonElement.nodeName?this.buttonElement.disabled=!0:this.buttonElement.classList.add("disabled"):"BUTTON"===this.buttonElement.nodeName?this.buttonElement.disabled=!1:this.buttonElement.classList.remove("disabled"))},l.executeTask=function(){return!this.disabled&&(!(this.confirmMessage&&!confirm(this.confirmMessage))&&(this.task&&Joomla.submitbutton(this.task,this.form,this.formValidation),!0))},u=s,(c=[{key:"task",get:function(){return this.getAttribute("task")}},{key:"listSelection",get:function(){return this.hasAttribute("list-selection")}},{key:"form",get:function(){return this.getAttribute("form")}},{key:"formValidation",get:function(){return this.hasAttribute("form-validation")}},{key:"confirmMessage",get:function(){return this.getAttribute("confirm-message")}}])&&t(u.prototype,c),a&&t(u,a),Object.defineProperty(u,"prototype",{writable:!1}),s}(r(HTMLElement)))}();