import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{C as t,t as n}from"./esm-Dg7vifPm.js";var r=e((()=>{n()}));function i(e){var t=e;return!!(t.ctrlKey||t.shiftKey||t.metaKey||t.button&&t.button==1)}function a(e,t){return!!(e.target===`_blank`&&t)}function o(e,n,r,o){var s=this,c=[];return e?(c=e instanceof Element?[e]:`toArray`in e?e.toArray():e,c.forEach(function(e){e.addEventListener(`click`,function(c){var l=n instanceof Function?n(e):n,u=r instanceof Function?r(e):r,d=e.getAttribute(`href`)||e.getAttributeNS(`http://www.w3.org/1999/xlink`,`href`)||e.getAttribute(`xlink:href`)||e.getElementsByTagName(`a`)[0]?.getAttribute(`href`),f=t(s.track(l,u,o??{}),s.settings.timeout??500);!a(e,d)&&!i(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 s(e,n,r,i){var a=this;return e?(e instanceof HTMLFormElement&&(e=[e]),e.forEach(function(e){if(!(e 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(e):n,c=r instanceof Function?r(e):r;t(a.track(s,c,i??{}),a.settings.timeout??500).catch(console.error).then(function(){e.submit()}).catch(console.error)},s=window.jQuery||window.Zepto;s?s(e).submit(o):e.addEventListener(`submit`,o,!1)}),this):this}e((()=>{r()}))();export{s as form,o as link};
//# sourceMappingURL=auto-track-CtD7BRzV.js.map