import{d as u}from"./delegate.89c887b8.js";import{p as f,t as k,a as b,b as c,d as l,g as p,c as g,w as L}from"./usage.9e37022f.js";class O{constructor(t,e){if(k(t,b.OUTBOUND_LINK_TRACKER),!window.addEventListener)return;const r={events:["click"],linkSelector:"a, area",shouldTrackOutboundLink:this.shouldTrackOutboundLink,fieldsObj:{},attributePrefix:"ga-"};this.opts=c(r,e),this.tracker=t,this.handleLinkInteractions=this.handleLinkInteractions.bind(this),this.delegates={},this.opts.events.forEach(i=>{this.delegates[i]=u(document,i,this.opts.linkSelector,this.handleLinkInteractions,{composed:!0,useCapture:!0})})}handleLinkInteractions(t,e){if(this.opts.shouldTrackOutboundLink(e,l)){const r=e.getAttribute("href")||e.getAttribute("xlink:href"),i=l(r),d={transport:"beacon",eventCategory:"Outbound Link",eventAction:t.type,eventLabel:i.href},h=c({},this.opts.fieldsObj,p(e,this.opts.attributePrefix)),a=g(d,h,this.tracker,this.opts.hitFilter,e,t);if(!navigator.sendBeacon&&m(t,e)){const n=()=>{if(window.removeEventListener("click",n),!t.defaultPrevented){t.preventDefault();const o=a.hitCallback;a.hitCallback=L(function(){typeof o=="function"&&o(),location.href=r})}this.tracker.send("event",a)};window.addEventListener("click",n)}else this.tracker.send("event",a)}}shouldTrackOutboundLink(t,e){const r=t.getAttribute("href")||t.getAttribute("xlink:href"),i=e(r);return i.hostname!=location.hostname&&i.protocol.slice(0,4)=="http"}remove(){Object.keys(this.delegates).forEach(t=>{this.delegates[t].destroy()})}}f("outboundLinkTracker",O);function m(s,t){return!(s.type!="click"||t.target=="_blank"||s.metaKey||s.ctrlKey||s.shiftKey||s.altKey||s.which>1)}
