import{n as e}from"./callback.IJmGbeOo.js";function t(e){var t=e;return!!(t.ctrlKey||t.shiftKey||t.metaKey||t.button&&t.button==1)}function n(e,t){return!!(e.target===`_blank`&&t)}function r(r,i,a,o){var s=this,c=[];return r?(c=r instanceof Element?[r]:`toArray`in r?r.toArray():r,c.forEach(function(r){r.addEventListener(`click`,function(c){var l=i instanceof Function?i(r):i,u=a instanceof Function?a(r):a,d=r.getAttribute(`href`)||r.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||r.getAttribute(`xlink:href`)||r.getElementsByTagName(`a`)[0]?.getAttribute(`href`),f=e(s.track(l,u,o??{}),s.settings.timeout??500);!n(r,d)&&!t(c)&&d&&(c.preventDefault?c.preventDefault():c.returnValue=!1,f.catch(console.error).then(function(){window.location.href=d}).catch(console.error))},!1)}),this):this}function i(t,n,r,i){var a=this;return t?(t instanceof HTMLFormElement&&(t=[t]),t.forEach(function(t){if(!(t instanceof Element))throw TypeError(`Must pass HTMLElement to trackForm/trackSubmit.`);var o=function(o){o.preventDefault?o.preventDefault():o.returnValue=!1;var s=n instanceof Function?n(t):n,c=r instanceof Function?r(t):r;e(a.track(s,c,i??{}),a.settings.timeout??500).catch(console.error).then(function(){t.submit()}).catch(console.error)},s=window.jQuery||window.Zepto;s?s(t).submit(o):t.addEventListener(`submit`,o,!1)}),this):this}export{i as form,r as link};