!function(t,n,i){var e=window.matchMedia;"undefined"!=typeof module&&module.exports?module.exports=i(e):"function"==typeof define&&define.amd?define(function(){return n[t]=i(e)}):n[t]=i(e)}("enquire",this,function(t){"use strict";function n(t,n){var i,e=0,s=t.length;for(e;s>e&&(i=n(t[e],e),i!==!1);e++);}function i(t){return"[object Array]"===Object.prototype.toString.apply(t)}function e(t){return"function"==typeof t}function s(t){this.options=t,!t.deferSetup&&this.setup()}function o(n,i){this.query=n,this.isUnconditional=i,this.handlers=[],this.mql=t(n);var e=this;this.listener=function(t){e.mql=t,e.assess()},this.mql.addListener(this.listener)}function r(){if(!t)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!t("only all").matches}return s.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(t){return this.options===t||this.options.match===t}},o.prototype={addHandler:function(t){var n=new s(t);this.handlers.push(n),this.matches()&&n.on()},removeHandler:function(t){var i=this.handlers;n(i,function(n,e){return n.equals(t)?(n.destroy(),!i.splice(e,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){n(this.handlers,function(t){t.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var t=this.matches()?"on":"off";n(this.handlers,function(n){n[t]()})}},r.prototype={register:function(t,s,r){var h=this.queries,u=r&&this.browserIsIncapable;return h[t]||(h[t]=new o(t,u)),e(s)&&(s={match:s}),i(s)||(s=[s]),n(s,function(n){e(n)&&(n={match:n}),h[t].addHandler(n)}),this},unregister:function(t,n){var i=this.queries[t];return i&&(n?i.removeHandler(n):(i.clear(),delete this.queries[t])),this}},new r});
