!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.domDelegate=e()}}(function(){return function e(t,r,n){function o(s,a){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(i)return i(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){var r=t[s][1][e];return o(r?r:e)},h,h.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)o(n[s]);return o}({1:[function(e,t,r){"use strict";function n(e){this.listenerMap=[{},{}],e&&this.root(e),this.handle=n.prototype.handle.bind(this)}function o(e,t){return e.toLowerCase()===t.tagName.toLowerCase()}function i(e,t){return this.rootElement===window?t===document:this.rootElement===t}function s(e,t){return e===t.id}t.exports=n,n.prototype.root=function(e){var t,r=this.listenerMap;if(this.rootElement){for(t in r[1])r[1].hasOwnProperty(t)&&this.rootElement.removeEventListener(t,this.handle,!0);for(t in r[0])r[0].hasOwnProperty(t)&&this.rootElement.removeEventListener(t,this.handle,!1)}if(!e||!e.addEventListener)return this.rootElement&&delete this.rootElement,this;this.rootElement=e;for(t in r[1])r[1].hasOwnProperty(t)&&this.rootElement.addEventListener(t,this.handle,!0);for(t in r[0])r[0].hasOwnProperty(t)&&this.rootElement.addEventListener(t,this.handle,!1);return this},n.prototype.captureForType=function(e){return["blur","error","focus","load","resize","scroll"].indexOf(e)!==-1},n.prototype.on=function(e,t,r,n){var l,f,h,u;if(!e)throw new TypeError("Invalid event type: "+e);if("function"==typeof t&&(n=r,r=t,t=null),void 0===n&&(n=this.captureForType(e)),"function"!=typeof r)throw new TypeError("Handler must be a type of Function");return l=this.rootElement,f=this.listenerMap[n?1:0],f[e]||(l&&l.addEventListener(e,this.handle,n),f[e]=[]),t?/^[a-z]+$/i.test(t)?(u=t,h=o):/^#[a-z0-9\-_]+$/i.test(t)?(u=t.slice(1),h=s):(u=t,h=a):(u=null,h=i.bind(this)),f[e].push({selector:t,handler:r,matcher:h,matcherParam:u}),this},n.prototype.off=function(e,t,r,n){var o,i,s,a,l;if("function"==typeof t&&(n=r,r=t,t=null),void 0===n)return this.off(e,t,r,!0),this.off(e,t,r,!1),this;if(s=this.listenerMap[n?1:0],!e){for(l in s)s.hasOwnProperty(l)&&this.off(l,t,r);return this}if(a=s[e],!a||!a.length)return this;for(o=a.length-1;o>=0;o--)i=a[o],t&&t!==i.selector||r&&r!==i.handler||a.splice(o,1);return a.length||(delete s[e],this.rootElement&&this.rootElement.removeEventListener(e,this.handle,n)),this},n.prototype.handle=function(e){var t,r,n,o,i,s,a,l=e.type,f=[],h="ftLabsDelegateIgnore";if(e[h]!==!0){switch(a=e.target,3===a.nodeType&&(a=a.parentNode),n=this.rootElement,o=e.eventPhase||(e.target!==e.currentTarget?3:2)){case 1:f=this.listenerMap[1][l];break;case 2:this.listenerMap[0]&&this.listenerMap[0][l]&&(f=f.concat(this.listenerMap[0][l])),this.listenerMap[1]&&this.listenerMap[1][l]&&(f=f.concat(this.listenerMap[1][l]));break;case 3:f=this.listenerMap[0][l]}for(r=f.length;a&&r;){for(t=0;t<r&&(i=f[t],i);t++)if(i.matcher.call(a,i.matcherParam,a)&&(s=this.fire(e,a,i)),s===!1)return e[h]=!0,void e.preventDefault();if(a===n)break;r=f.length,a=a.parentElement}}},n.prototype.fire=function(e,t,r){return r.handler.call(t,e,t)};var a=function(e){if(e){var t=e.prototype;return t.matches||t.matchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector||t.msMatchesSelector||t.oMatchesSelector}}(Element);n.prototype.destroy=function(){this.off(),this.root()}},{}],2:[function(e,t,r){"use strict";var n=e("./delegate");t.exports=function(e){return new n(e)},t.exports.Delegate=n},{"./delegate":1}]},{},[2])(2)});