"use strict";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})(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){e=_toPrimitive(e,"string");return"symbol"==_typeof(e)?e:e+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0===r)return("string"===t?String:Number)(e);t=r.call(e,t||"default");if("object"!=_typeof(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}var MailboxTable=function(){return _createClass(function e(t){var r=t.tableId,n=t.searchInputId,t=t.selectAllId;_classCallCheck(this,e),this.table=document.getElementById(r),this.searchInput=document.getElementById(n),this.selectAllCheckbox=document.getElementById(t),this.tbody=this.table.querySelector("tbody"),this.initEvents()},[{key:"rowChecks",get:function(){return this.tbody.querySelectorAll(".rowCheck")}},{key:"tableRows",get:function(){return this.tbody.querySelectorAll("tr")}},{key:"initEvents",value:function(){var t=this;this.selectAllCheckbox.addEventListener("change",function(){t.rowChecks.forEach(function(e){return e.checked=t.selectAllCheckbox.checked})}),this.tbody.addEventListener("change",function(e){e.target.classList.contains("rowCheck")&&(e=_toConsumableArray(t.rowChecks).every(function(e){return e.checked}),t.selectAllCheckbox.checked=e)}),this.searchInput.addEventListener("input",function(){var n=t.searchInput.value.trim().toLowerCase().split(/\s+/);t.tableRows.forEach(function(e){var t=e.textContent.toLowerCase(),r=n.every(function(e){return t.includes(e)});e.style.display=r?"":"none"})})}}])}();document.addEventListener("DOMContentLoaded",function(){new MailboxTable({tableId:"mailboxSearch",searchInputId:"searchInput",selectAllId:"selectAll"})});