import{p as o,t as l,a as c,b as p,c as u}from"./usage.9e37022f.js";const a=[];class h{static add(t,e,i){n(t,e).add(i)}static remove(t,e,i){n(t,e).remove(i)}constructor(t,e){this.context=t,this.methodName=e,this.isTask=/Task$/.test(e),this.originalMethodReference=this.isTask?t.get(e):t[e],this.methodChain=[],this.boundMethodChain=[],this.wrappedMethod=(...i)=>this.boundMethodChain[this.boundMethodChain.length-1](...i),this.isTask?t.set(e,this.wrappedMethod):t[e]=this.wrappedMethod}add(t){this.methodChain.push(t),this.rebindMethodChain()}remove(t){const e=this.methodChain.indexOf(t);e>-1&&(this.methodChain.splice(e,1),this.methodChain.length>0?this.rebindMethodChain():this.destroy())}rebindMethodChain(){this.boundMethodChain=[];for(let t,e=0;t=this.methodChain[e];e++){const i=this.boundMethodChain[e-1]||this.originalMethodReference.bind(this.context);this.boundMethodChain.push(t(i))}}destroy(){const t=a.indexOf(this);t>-1&&(a.splice(t,1),this.isTask?this.context.set(this.methodName,this.originalMethodReference):this.context[this.methodName]=this.originalMethodReference)}}function n(s,t){let e=a.filter(i=>i.context==s&&i.methodName==t)[0];return e||(e=new h(s,t),a.push(e)),e}class C{constructor(t,e){if(l(t,c.URL_CHANGE_TRACKER),!history.pushState||!window.addEventListener)return;const i={shouldTrackUrlChange:this.shouldTrackUrlChange,trackReplaceState:!1,fieldsObj:{},hitFilter:null};this.opts=p(i,e),this.tracker=t,this.path=d(),this.pushStateOverride=this.pushStateOverride.bind(this),this.replaceStateOverride=this.replaceStateOverride.bind(this),this.handlePopState=this.handlePopState.bind(this),h.add(history,"pushState",this.pushStateOverride),h.add(history,"replaceState",this.replaceStateOverride),window.addEventListener("popstate",this.handlePopState)}pushStateOverride(t){return(...e)=>{t(...e),this.handleUrlChange(!0)}}replaceStateOverride(t){return(...e)=>{t(...e),this.handleUrlChange(!1)}}handlePopState(){this.handleUrlChange(!0)}handleUrlChange(t){setTimeout(()=>{const e=this.path,i=d();if(e!=i&&this.opts.shouldTrackUrlChange.call(this,i,e)&&(this.path=i,this.tracker.set({page:i,title:document.title}),t||this.opts.trackReplaceState)){const r={transport:"beacon"};this.tracker.send("pageview",u(r,this.opts.fieldsObj,this.tracker,this.opts.hitFilter))}},0)}shouldTrackUrlChange(t,e){return!!(t&&e)}remove(){h.remove(history,"pushState",this.pushStateOverride),h.remove(history,"replaceState",this.replaceStateOverride),window.removeEventListener("popstate",this.handlePopState)}}o("urlChangeTracker",C);function d(){return location.pathname+location.search}
