const c=window.Element.prototype,d=c.matches||c.matchesSelector||c.webkitMatchesSelector||c.mozMatchesSelector||c.msMatchesSelector||c.oMatchesSelector;function h(o,r){if(o&&o.nodeType==1&&r){if(typeof r=="string"||r.nodeType==1)return o==r||p(o,r);if("length"in r){for(let e=0,t;t=r[e];e++)if(o==t||p(o,t))return!0}}return!1}function p(o,r){if(typeof r!="string")return!1;if(d)return d.call(o,r);const e=o.parentNode.querySelectorAll(r);for(let t=0,n;n=e[t];t++)if(n==o)return!0;return!1}function y(o){const r=[];for(;o&&o.parentNode&&o.parentNode.nodeType==1;)o=o.parentNode,r.push(o);return r}function g(o,r,e=!1){if(!(o&&o.nodeType==1&&r))return;const t=(e?[o]:[]).concat(y(o));for(let n=0,i;i=t[n];n++)if(h(i,r))return i}function S(o,r,e,t,n={}){const i=function(f){let a;if(n.composed&&typeof f.composedPath=="function"){const l=f.composedPath();for(let u=0,s;s=l[u];u++)s.nodeType==1&&h(s,e)&&(a=s)}else a=g(f.target,e,!0);a&&t.call(a,f,a)};return o.addEventListener(r,i,n.useCapture),{destroy:function(){o.removeEventListener(r,i,n.useCapture)}}}export{S as d};
