!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.MatchHeight=e():t.MatchHeight=e()}(self,(function(){return(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{default:()=>h});function n(t){for(var e="",n=0;n<t;n+=1)e+="-";return e}function r(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return Array.prototype.slice.call(e.querySelectorAll(t))}function o(t){return"string"==typeof t?r(t):t instanceof Element?[t]:t?Array.prototype.slice.call(t):[]}function a(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var u=function(){function t(){var e,n=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this.reset.bind(this),"loading"!==document.readyState?e():document.addEventListener("DOMContentLoaded",e),window.addEventListener("resize",(function(){return n.update()})),this.groupCounter=1}var e,u;return e=t,(u=[{key:"findElements",value:function(){this.groups=this.group(r("[data-match-height]"))}},{key:"group",value:function(t){return t.reduce((function(t,e){var n=e.getAttribute("data-match-height"),r=e.closest("[data-match-height-group]");return r&&(n=r.getAttribute("data-match-height-group")+"-"+n),t[n]=(t[n]||[]).concat(e),t}),{})}},{key:"isEnabled",value:function(t){if(!t||!t[0])return!1;var e=t[0],n=e.closest("[data-match-height-enable]");if(n){var r=n.getAttribute("data-match-height-enable");return"true"===r||"false"!==r&&window.matchMedia(r).matches}var o=e.closest("[data-match-height-disable]");if(o){var a=o.getAttribute("data-match-height-disable");return"true"!==a&&("false"===a||!window.matchMedia(a).matches)}return!0}},{key:"match",value:function(t){var e=t.reduce((function(t,e){return e.style.height="",Math.max(t,e.offsetHeight)}),0);t.forEach((function(t){return t.style.height="".concat(e,"px")}))}},{key:"update",value:function(t){var e=this.getGroups(t);for(var n in e){var r=e[n];this.isEnabled(r)?this.match(r):r.forEach((function(t){return t.style.height=""}))}}},{key:"reset",value:function(){this.findElements(),this.update()}},{key:"getNewGroupID",value:function(){var t="group-".concat(this.groupCounter);return this.groupCounter+=1,t}},{key:"getGroupID",value:function(t){var e=(t=o(t)).shift();if(!e)return null;var n=e.getAttribute("data-match-height"),r=e.closest("[data-match-height-group]");return r&&(n=r.getAttribute("data-match-height-group")+"-"+n),n}},{key:"getGroups",value:function(t){return t?("string"==typeof t&&this.groups[t]?e=t:(t=o(t),e=this.getGroupID(t)),this.groups[e]?(n={},r=e,a=this.groups[e],r in n?Object.defineProperty(n,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[r]=a,n):{}):this.groups;var e,n,r,a}},{key:"getControl",value:function(t){var e=(t=o(t)).shift();return e?e.closest("[data-match-height-enable], [data-match-height-disable]"):null}},{key:"add",value:function(t,e){t=o(t),e=e||this.getNewGroupID(),t.forEach((function(t){return t.setAttribute("data-match-height",e)})),this.groups[e]=(this.groups[e]||[]).concat(t),this.update(e)}},{key:"remove",value:function(t){if("string"==typeof t&&this.groups[t])delete this.groups[t];else{var e,n=this,r=o(t),a=[];r.forEach((function(t){var e=n.getGroupID(t);t.removeAttribute("data-match-height"),n.groups[e]=n.groups[e].filter((function(e){return e&&e!==t})),n.groups[e].length?a.push(e):(delete n.groups[e],a=a.filter((function(t){return t!==e})))})),(e=a,e.filter((function(t,e,n){return n.indexOf(t)===e}))).forEach((function(t){return n.update(t)}))}}},{key:"debug",value:function(t){var e,r=this.getGroups(t);if(e=r,0!==Object.getOwnPropertyNames(e).length){for(var o in r)if(a(r,o)){var i=r[o],u=this.getControl(i),c={};c.isEnabled=this.isEnabled(i),c.control=u,c.enable=u?u.getAttribute("data-match-height-enable"):void 0,c.disable=u?u.getAttribute("data-match-height-disable"):void 0,c.groupID=o,c.group=i,console.log("\n---------------------------".concat(n(o.length),'-\n🐛 Match Height Debugger: "').concat(o,'"\n---------------------------').concat(n(o.length),"-\n\n👇 Click into the object below to inspect your elements.\n\n")),console.log(c),console.log("\n")}}else console.log("\n😢 Oh no! Match Height couldn't find a matching group for \"".concat(t,"\".\n\n--------------------------------------------------------------------------------------------\nℹ️ NOTE: Make sure the elements you're trying to debug have a [data-match-height] attribute.\n--------------------------------------------------------------------------------------------\n\n"))}}])&&i(e.prototype,u),t}();!function(t){var e=t.Element.prototype;"function"!=typeof e.matches&&(e.matches=e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||function(t){for(var e=this,n=(e.document||e.ownerDocument).querySelectorAll(t),r=0;n[r]&&n[r]!==e;)++r;return Boolean(n[r])}),"function"!=typeof e.closest&&(e.closest=function(t){for(var e=this;e&&1===e.nodeType;){if(e.matches(t))return e;e=e.parentNode}return null})}(window);var c=new u;window.MatchHeight=c,"undefined"!=typeof $&&($.fn.matchHeight=function(){window.MatchHeight.add(this)});const h=c;return e.default})()}));
//# sourceMappingURL=match-height.js.map