"use strict";(()=>{var Mt=Object.defineProperty;var At=(n,t,e)=>t in n?Mt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var b=(n,t,e)=>At(n,typeof t!="symbol"?t+"":t,e);function Lt(n){if(n.startsWith("re:")){let a=n.slice(3);if(!a)throw new Error("Empty regex pattern");return new RegExp(a)}let e="__DOUBLE_ASTERISK_TOKEN__",r="__SINGLE_ASTERISK_TOKEN__",s=n.replace(/\*\*/g,e).replace(/\*/g,r).replace(/[.+?^${}()|[\]\\]/g,"\\$&");s=s.replace(new RegExp(`/${e}/`,"g"),"/(?:.+/)?"),s=s.replace(new RegExp(e,"g"),".*"),s=s.replace(/\//g,"\\/");let o=s.replace(new RegExp(r,"g"),"[^/]+");return new RegExp("^"+o+"$")}function U(n,t){for(let e of t)try{if(Lt(e).test(n))return e}catch(r){console.error(`Invalid pattern: ${e}`,r)}return null}function nt(n,t){let e=null;return(...r)=>{e&&clearTimeout(e),e=setTimeout(()=>n(...r),t)}}function it(n){try{let t=window.location.hostname,e=new URL(n).hostname;return e!==t&&e!==""}catch{return!1}}function v(n,t){if(!n)return t;try{let e=JSON.parse(n);return Array.isArray(t)&&!Array.isArray(e)?t:e}catch(e){return console.error("Error parsing JSON:",e),t}}async function st(n){let t=n.getAttribute("src");if(!t)return console.error("Script src attribute is missing"),null;let e=t.split("/script.js")[0];if(!e)return console.error("Please provide a valid analytics host"),null;let r=n.getAttribute("data-site-id")||n.getAttribute("site-id");if(!r)return console.error("Please provide a valid site ID using the data-site-id attribute"),null;let i=n.getAttribute("data-namespace")||"rybbit",s=v(n.getAttribute("data-skip-patterns"),[]),o=v(n.getAttribute("data-mask-patterns"),[]),a=v(n.getAttribute("data-replay-mask-text-selectors"),[]),d=n.getAttribute("data-debounce")?Math.max(0,parseInt(n.getAttribute("data-debounce"))):500,u=n.getAttribute("data-replay-batch-size")?Math.max(1,parseInt(n.getAttribute("data-replay-batch-size"))):250,g=n.getAttribute("data-replay-batch-interval")?Math.max(1e3,parseInt(n.getAttribute("data-replay-batch-interval"))):5e3,c=n.getAttribute("data-replay-block-class")||void 0,l=n.getAttribute("data-replay-block-selector")||void 0,p=n.getAttribute("data-replay-ignore-class")||void 0,C=n.getAttribute("data-replay-ignore-selector")||void 0,T=n.getAttribute("data-replay-mask-text-class")||void 0,w=n.getAttribute("data-replay-mask-all-inputs"),St=w!==null?w!=="false":void 0,Q=n.getAttribute("data-replay-mask-input-options"),Et=Q?v(Q,{password:!0,email:!0}):void 0,Y=n.getAttribute("data-replay-collect-fonts"),Ct=Y!==null?Y!=="false":void 0,Z=n.getAttribute("data-replay-sampling"),wt=Z?v(Z,{}):void 0,tt=n.getAttribute("data-replay-slim-dom-options"),Pt=tt?v(tt,{}):void 0,et=n.getAttribute("data-replay-sample-rate"),It=et?Math.min(100,Math.max(0,parseInt(et,10))):void 0,h={namespace:i,analyticsHost:e,siteId:r,debounceDuration:d,sessionReplayBatchSize:u,sessionReplayBatchInterval:g,sessionReplayMaskTextSelectors:a,skipPatterns:s,maskPatterns:o,autoTrackPageview:!0,autoTrackSpa:!0,trackQuerystring:!0,trackOutbound:!0,enableWebVitals:!1,trackErrors:!1,enableSessionReplay:!1,trackButtonClicks:!1,trackCopy:!1,trackFormInteractions:!1,sessionReplayBlockClass:c,sessionReplayBlockSelector:l,sessionReplayIgnoreClass:p,sessionReplayIgnoreSelector:C,sessionReplayMaskTextClass:T,sessionReplayMaskAllInputs:St,sessionReplayMaskInputOptions:Et,sessionReplayCollectFonts:Ct,sessionReplaySampling:wt,sessionReplaySlimDOMOptions:Pt,sessionReplaySampleRate:It};try{let N=`${e}/site/tracking-config/${r}`,rt=await fetch(N,{method:"GET",credentials:"omit"});if(rt.ok){let m=await rt.json();return{...h,autoTrackPageview:m.trackInitialPageView??h.autoTrackPageview,autoTrackSpa:m.trackSpaNavigation??h.autoTrackSpa,trackQuerystring:m.trackUrlParams??h.trackQuerystring,trackOutbound:m.trackOutbound??h.trackOutbound,enableWebVitals:m.webVitals??h.enableWebVitals,trackErrors:m.trackErrors??h.trackErrors,enableSessionReplay:m.sessionReplay??h.enableSessionReplay,trackButtonClicks:m.trackButtonClicks??h.trackButtonClicks,trackCopy:m.trackCopy??h.trackCopy,trackFormInteractions:m.trackFormInteractions??h.trackFormInteractions}}else return console.warn("Failed to fetch tracking config from API, using defaults"),h}catch(N){return console.warn("Error fetching tracking config:",N),h}}var at="rybbit-replay-sampled";function Bt(n){if(n>=100)return!0;if(n<=0)return!1;try{let t=sessionStorage.getItem(at);if(t!==null)return t==="1";let e=Math.random()*100{let r=document.createElement("script");r.src=`${this.config.analyticsHost}/replay.js`,r.async=!1,r.onload=()=>{t()},r.onerror=()=>e(new Error("Failed to load rrweb")),document.head.appendChild(r)})}startRecording(){if(!(this.isRecording||!window.rrweb||!this.config.enableSessionReplay))try{let t={mousemove:!1,mouseInteraction:{MouseUp:!1,MouseDown:!1,Click:!0,ContextMenu:!1,DblClick:!0,Focus:!0,Blur:!0,TouchStart:!1,TouchEnd:!1},scroll:500,input:"last",media:800},e={script:!1,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},r={emit:i=>{this.addEvent({type:i.type,data:i.data,timestamp:i.timestamp||Date.now()})},recordCanvas:!1,checkoutEveryNms:6e4,checkoutEveryNth:500,blockClass:this.config.sessionReplayBlockClass??"rr-block",blockSelector:this.config.sessionReplayBlockSelector??null,ignoreClass:this.config.sessionReplayIgnoreClass??"rr-ignore",ignoreSelector:this.config.sessionReplayIgnoreSelector??null,maskTextClass:this.config.sessionReplayMaskTextClass??"rr-mask",maskAllInputs:this.config.sessionReplayMaskAllInputs??!0,maskInputOptions:this.config.sessionReplayMaskInputOptions??{password:!0,email:!0},collectFonts:this.config.sessionReplayCollectFonts??!0,sampling:this.config.sessionReplaySampling??t,slimDOMOptions:this.config.sessionReplaySlimDOMOptions??e};this.config.sessionReplayMaskTextSelectors&&this.config.sessionReplayMaskTextSelectors.length>0&&(r.maskTextSelector=this.config.sessionReplayMaskTextSelectors.join(", ")),this.stopRecordingFn=window.rrweb.record(r),this.isRecording=!0,this.setupBatchTimer()}catch{}}stopRecording(){this.isRecording&&(this.stopRecordingFn&&this.stopRecordingFn(),this.isRecording=!1,this.clearBatchTimer(),this.eventBuffer.length>0&&this.flushEvents())}isActive(){return this.isRecording}addEvent(t){this.eventBuffer.push(t),this.eventBuffer.length>=this.config.sessionReplayBatchSize&&this.flushEvents()}setupBatchTimer(){this.clearBatchTimer(),this.batchTimer=window.setInterval(()=>{this.eventBuffer.length>0&&this.flushEvents()},this.config.sessionReplayBatchInterval)}clearBatchTimer(){this.batchTimer&&(clearInterval(this.batchTimer),this.batchTimer=void 0)}async flushEvents(){if(this.eventBuffer.length===0)return;let t=[...this.eventBuffer];this.eventBuffer=[];let e={userId:this.userId,events:t,metadata:{pageUrl:window.location.href,viewportWidth:screen.width,viewportHeight:screen.height,language:navigator.language}};try{await this.sendBatch(e)}catch{this.eventBuffer.unshift(...t)}}updateUserId(t){this.userId=t}onPageChange(){this.isRecording&&this.flushEvents()}cleanup(){this.stopRecording()}};var I=class{constructor(t){this.customUserId=null;this.config=t,this.loadUserId(),t.enableSessionReplay&&this.initializeSessionReplay()}loadUserId(){try{let t=localStorage.getItem(`${this.config.namespace}-user-id`);t&&(this.customUserId=t)}catch{}}async initializeSessionReplay(){try{this.sessionReplayRecorder=new P(this.config,this.customUserId||"",t=>this.sendSessionReplayBatch(t)),await this.sessionReplayRecorder.initialize()}catch(t){console.error("Failed to initialize session replay:",t)}}async sendSessionReplayBatch(t){try{await fetch(`${this.config.analyticsHost}/session-replay/record/${this.config.siteId}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),mode:"cors",keepalive:!1})}catch(e){throw console.error("Failed to send session replay batch:",e),e}}createBasePayload(){let t=new URL(window.location.href),e=t.pathname;if(t.hash&&t.hash.startsWith("#/")&&(e=t.hash.substring(1)),U(e,this.config.skipPatterns))return null;let r=U(e,this.config.maskPatterns);r&&(e=r);let i={site_id:this.config.siteId,hostname:t.hostname,pathname:e,querystring:this.config.trackQuerystring?t.search:"",screenWidth:screen.width,screenHeight:screen.height,language:navigator.language,page_title:document.title,referrer:document.referrer};return this.customUserId&&(i.user_id=this.customUserId),i}async sendTrackingData(t){try{await fetch(`${this.config.analyticsHost}/track`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),mode:"cors",keepalive:!0})}catch(e){console.error("Failed to send tracking data:",e)}}track(t,e="",r={}){if(t==="custom_event"&&(!e||typeof e!="string")){console.error("Event name is required and must be a string for custom events");return}let i=this.createBasePayload();if(!i)return;let o={...i,type:t,event_name:e,properties:["custom_event","outbound","error","button_click","copy","form_submit","input_change"].includes(t)?JSON.stringify(r):void 0};this.sendTrackingData(o)}trackPageview(){this.track("pageview")}trackEvent(t,e={}){this.track("custom_event",t,e)}trackOutbound(t,e="",r="_self"){this.track("outbound","",{url:t,text:e,target:r})}trackWebVitals(t){let e=this.createBasePayload();if(!e)return;let r={...e,type:"performance",event_name:"web-vitals",...t};this.sendTrackingData(r)}trackError(t,e={}){let r=window.location.origin,i=e.filename||"",s=t.stack||"";if(i)try{if(new URL(i).origin!==r)return}catch{}else if(s&&!s.includes(r))return;let o={message:t.message?.substring(0,500)||"Unknown error",stack:s.substring(0,2e3)||""};if(i&&(o.fileName=i),e.lineno){let a=typeof e.lineno=="string"?parseInt(e.lineno,10):e.lineno;a&&a!==0&&(o.lineNumber=a)}if(e.colno){let a=typeof e.colno=="string"?parseInt(e.colno,10):e.colno;a&&a!==0&&(o.columnNumber=a)}for(let a in e)!["lineno","colno"].includes(a)&&e[a]!==void 0&&(o[a]=e[a]);this.track("error",t.name||"Error",o)}trackButtonClick(t){this.track("button_click","",t)}trackCopy(t){this.track("copy","",t)}trackFormSubmit(t){this.track("form_submit","",t)}trackInputChange(t){this.track("input_change","",t)}identify(t,e){if(typeof t!="string"||t.trim()===""){console.error("User ID must be a non-empty string");return}this.customUserId=t.trim();try{localStorage.setItem(`${this.config.namespace}-user-id`,this.customUserId)}catch{console.warn("Could not persist user ID to localStorage")}this.sendIdentifyEvent(this.customUserId,e,!0),this.sessionReplayRecorder&&this.sessionReplayRecorder.updateUserId(this.customUserId)}setTraits(t){if(!t||typeof t!="object"){console.error("Traits must be an object");return}let e=this.customUserId;if(!e){console.warn("Cannot set traits without identifying user first. Call identify() first.");return}this.sendIdentifyEvent(e,t,!1)}async sendIdentifyEvent(t,e,r=!0){try{await fetch(`${this.config.analyticsHost}/identify`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({site_id:this.config.siteId,user_id:t,traits:e,is_new_identify:r}),mode:"cors",keepalive:!0})}catch(i){console.error("Failed to send identify event:",i)}}clearUserId(){this.customUserId=null;try{localStorage.removeItem(`${this.config.namespace}-user-id`)}catch{}}getUserId(){return this.customUserId}startSessionReplay(){this.sessionReplayRecorder?this.sessionReplayRecorder.startRecording():console.warn("Session replay not initialized")}stopSessionReplay(){this.sessionReplayRecorder&&this.sessionReplayRecorder.stopRecording()}isSessionReplayActive(){return this.sessionReplayRecorder?.isActive()??!1}onPageChange(){this.sessionReplayRecorder&&this.sessionReplayRecorder.onPageChange()}cleanup(){this.sessionReplayRecorder&&this.sessionReplayRecorder.cleanup()}};var mt=-1,R=n=>{addEventListener("pageshow",(t=>{t.persisted&&(mt=t.timeStamp,n(t))}),!0)},f=(n,t,e,r)=>{let i,s;return o=>{t.value>=0&&(o||r)&&(s=t.value-(i??0),(s||i===void 0)&&(i=t.value,t.delta=s,t.rating=((a,d)=>a>d[1]?"poor":a>d[0]?"needs-improvement":"good")(t.value,e),n(t)))}},J=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},K=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStartK()?.activationStart??0,y=(n,t=-1)=>{let e=K(),r="navigate";return mt>=0?r="back-forward-cache":e&&(document.prerendering||S()>0?r="prerender":document.wasDiscarded?r="restore":e.type&&(r=e.type.replace(/_/g,"-"))),{name:n,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},D=new WeakMap;function q(n,t){return D.get(n)||D.set(n,new t),D.get(n)}var H=class{constructor(){b(this,"t");b(this,"i",0);b(this,"o",[])}h(t){if(t.hadRecentInput)return;let e=this.o[0],r=this.o.at(-1);this.i&&e&&r&&t.startTime-r.startTime<1e3&&t.startTime-e.startTime<5e3?(this.i+=t.value,this.o.push(t)):(this.i=t.value,this.o=[t]),this.t?.(t)}},E=(n,t,e={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(n)){let r=new PerformanceObserver((i=>{Promise.resolve().then((()=>{t(i.getEntries())}))}));return r.observe({type:n,buffered:!0,...e}),r}}catch{}},G=n=>{let t=!1;return()=>{t||(n(),t=!0)}},k=-1,ft=new Set,ot=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,W=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let t of ft)t();isFinite(k)||(k=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",W,!0))}},A=()=>{if(k<0){let n=S();k=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((e=>e.name==="hidden"&&e.startTime>n))[0]?.startTime)??ot(),addEventListener("visibilitychange",W,!0),addEventListener("prerenderingchange",W,!0),R((()=>{setTimeout((()=>{k=ot()}))}))}return{get firstHiddenTime(){return k},onHidden(n){ft.add(n)}}},L=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},ct=[1800,3e3],X=(n,t={})=>{L((()=>{let e=A(),r,i=y("FCP"),s=E("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime{i=y("FCP"),r=f(n,i,ct,t.reportAllChanges),J((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},lt=[.1,.25],yt=(n,t={})=>{let e=A();X(G((()=>{let r,i=y("CLS",0),s=q(t,H),o=d=>{for(let u of d)s.h(u);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=E("layout-shift",o);a&&(r=f(n,i,lt,t.reportAllChanges),e.onHidden((()=>{o(a.takeRecords()),r(!0)})),R((()=>{s.i=0,i=y("CLS",0),r=f(n,i,lt,t.reportAllChanges),J((()=>r()))})),setTimeout(r))})))},bt=0,F=1/0,M=0,xt=n=>{for(let t of n)t.interactionId&&(F=Math.min(F,t.interactionId),M=Math.max(M,t.interactionId),bt=M?(M-F)/7+1:0)},z,ut=()=>z?bt:performance.interactionCount??0,Ot=()=>{"interactionCount"in performance||z||(z=E("event",xt,{type:"event",buffered:!0,durationThreshold:0}))},dt=0,V=class{constructor(){b(this,"u",[]);b(this,"l",new Map);b(this,"m");b(this,"p")}v(){dt=ut(),this.u.length=0,this.l.clear()}L(){let t=Math.min(this.u.length-1,Math.floor((ut()-dt)/50));return this.u[t]}h(t){if(this.m?.(t),!t.interactionId&&t.entryType!=="first-input")return;let e=this.u.at(-1),r=this.l.get(t.interactionId);if(r||this.u.length<10||t.duration>e.P){if(r?t.duration>r.P?(r.entries=[t],r.P=t.duration):t.duration===r.P&&t.startTime===r.entries[0].startTime&&r.entries.push(t):(r={id:t.interactionId,entries:[t],P:t.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort(((i,s)=>s.P-i.P)),this.u.length>10){let i=this.u.splice(10);for(let s of i)this.l.delete(s.id)}this.p?.(r)}}},vt=n=>{let t=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=G(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),t((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},pt=[200,500],kt=(n,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let e=A();L((()=>{Ot();let r,i=y("INP"),s=q(t,V),o=d=>{vt((()=>{for(let g of d)s.h(g);let u=s.L();u&&u.P!==i.value&&(i.value=u.P,i.entries=u.entries,r())}))},a=E("event",o,{durationThreshold:t.durationThreshold??40});r=f(n,i,pt,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),e.onHidden((()=>{o(a.takeRecords()),r(!0)})),R((()=>{s.v(),i=y("INP"),r=f(n,i,pt,t.reportAllChanges)})))}))},$=class{constructor(){b(this,"m")}h(t){this.m?.(t)}},ht=[2500,4e3],Rt=(n,t={})=>{L((()=>{let e=A(),r,i=y("LCP"),s=q(t,$),o=d=>{t.reportAllChanges||(d=d.slice(-1));for(let u of d)s.h(u),u.startTime{o(a.takeRecords()),a.disconnect(),r(!0)})),u=g=>{g.isTrusted&&(vt(d),removeEventListener(g.type,u,{capture:!0}))};for(let g of["keydown","click","visibilitychange"])addEventListener(g,u,{capture:!0});R((g=>{i=y("LCP"),r=f(n,i,ht,t.reportAllChanges),J((()=>{i.value=performance.now()-g.timeStamp,r(!0)}))}))}}))},gt=[800,1800],j=n=>{document.prerendering?L((()=>j(n))):document.readyState!=="complete"?addEventListener("load",(()=>j(n)),!0):setTimeout(n)},Tt=(n,t={})=>{let e=y("TTFB"),r=f(n,e,gt,t.reportAllChanges);j((()=>{let i=K();i&&(e.value=Math.max(i.responseStart-S(),0),e.entries=[i],r(!0),R((()=>{e=y("TTFB",0),r=f(n,e,gt,t.reportAllChanges),r(!0)})))}))};var B=class{constructor(t){this.data={lcp:null,cls:null,inp:null,fcp:null,ttfb:null};this.sent=!1;this.timeout=null;this.onReadyCallback=null;this.onReadyCallback=t}initialize(){try{Rt(this.collectMetric.bind(this)),yt(this.collectMetric.bind(this)),kt(this.collectMetric.bind(this)),X(this.collectMetric.bind(this)),Tt(this.collectMetric.bind(this)),this.timeout=setTimeout(()=>{this.sent||this.sendData()},2e4),window.addEventListener("beforeunload",()=>{this.sent||this.sendData()})}catch(t){console.warn("Error initializing web vitals tracking:",t)}}collectMetric(t){if(this.sent)return;let e=t.name.toLowerCase();this.data[e]=t.value,Object.values(this.data).every(i=>i!==null)&&this.sendData()}sendData(){this.sent||(this.sent=!0,this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.onReadyCallback&&this.onReadyCallback(this.data))}getData(){return{...this.data}}};var x=class{constructor(t,e){this.tracker=t,this.config=e}initialize(){document.addEventListener("click",this.handleClick.bind(this),!0)}handleClick(t){let e=t.target;this.config.trackButtonClicks&&this.isButton(e)&&this.trackButtonClick(e)}isButton(t){if(t.tagName==="BUTTON"||t.getAttribute("role")==="button")return!0;if(t.tagName==="INPUT"){let i=t.type?.toLowerCase();if(i==="submit"||i==="button")return!0}let e=t.parentElement,r=0;for(;e&&r<3;){if(e.tagName==="BUTTON"||e.getAttribute("role")==="button")return!0;e=e.parentElement,r++}return!1}trackButtonClick(t){let e=this.findButton(t);if(!e||e.hasAttribute("data-rybbit-event"))return;let r={text:this.getElementText(e),...this.extractDataAttributes(e)};this.tracker.trackButtonClick(r)}extractDataAttributes(t){let e={};for(let r of t.attributes)if(r.name.startsWith("data-rybbit-prop-")){let i=r.name.replace("data-rybbit-prop-","");e[i]=r.value}return e}findButton(t){if(t.tagName==="BUTTON"||t.getAttribute("role")==="button")return t;if(t.tagName==="INPUT"){let i=t.type?.toLowerCase();if(i==="submit"||i==="button")return t}let e=t.parentElement,r=0;for(;e&&r<3;){if(e.tagName==="BUTTON"||e.getAttribute("role")==="button")return e;e=e.parentElement,r++}return null}getElementText(t){return t.textContent?.trim().substring(0,100)||void 0}cleanup(){document.removeEventListener("click",this.handleClick.bind(this),!0)}};var O=class{constructor(t){this.tracker=t}initialize(){document.addEventListener("copy",this.handleCopy.bind(this))}handleCopy(){let t=window.getSelection();if(!t||t.isCollapsed)return;let e=t.toString(),r=e.length;if(r===0)return;let i=t.anchorNode,s=i instanceof HTMLElement?i:i?.parentElement;if(!s)return;let o={text:e.substring(0,500),...r>500&&{textLength:r},sourceElement:s.tagName.toLowerCase()};this.tracker.trackCopy(o)}cleanup(){document.removeEventListener("copy",this.handleCopy.bind(this))}};var _=class{constructor(t,e){this.tracker=t,this.config=e,this.boundHandleSubmit=this.handleSubmit.bind(this),this.boundHandleChange=this.handleChange.bind(this)}initialize(){document.addEventListener("submit",this.boundHandleSubmit,!0),document.addEventListener("change",this.boundHandleChange,!0)}cleanup(){document.removeEventListener("submit",this.boundHandleSubmit,!0),document.removeEventListener("change",this.boundHandleChange,!0)}handleSubmit(t){let e=t.target;if(e.tagName!=="FORM")return;let r={formId:e.id||"",formName:e.name||"",formAction:e.action||"",method:(e.method||"get").toUpperCase(),fieldCount:e.elements.length,...this.extractDataAttributes(e)};this.tracker.trackFormSubmit(r)}handleChange(t){let e=t.target,r=e.tagName.toUpperCase();if(!["INPUT","SELECT","TEXTAREA"].includes(r))return;if(r==="INPUT"){let s=e.type?.toLowerCase();if(s==="hidden"||s==="password")return}let i={element:r.toLowerCase(),inputType:r==="INPUT"?e.type?.toLowerCase():void 0,inputName:e.name||e.id||"",formId:e.form?.id||void 0,...this.extractDataAttributes(e)};this.tracker.trackInputChange(i)}extractDataAttributes(t){let e={};for(let r of t.attributes)if(r.name.startsWith("data-rybbit-prop-")){let i=r.name.replace("data-rybbit-prop-","");e[i]=r.value}return e}};(async function(){let n=document.currentScript;if(!n){console.error("Could not find current script tag");return}let t=n.getAttribute("data-namespace")||"rybbit",e=`disable-${t}`;if(window.__RYBBIT_OPTOUT__||localStorage.getItem(e)!==null){window[t]={pageview:()=>{},event:()=>{},error:()=>{},trackOutbound:()=>{},identify:()=>{},setTraits:()=>{},clearUserId:()=>{},getUserId:()=>null,startSessionReplay:()=>{},stopSessionReplay:()=>{},isSessionReplayActive:()=>!1};return}let r=await st(n);if(!r)return;let i=new I(r);r.enableWebVitals&&new B(l=>{i.trackWebVitals(l)}).initialize();let s=null,o=null,a=null;r.trackButtonClicks&&(s=new x(i,r),s.initialize()),r.trackCopy&&(o=new O(i),o.initialize()),r.trackFormInteractions&&(a=new _(i,r),a.initialize()),r.trackErrors&&(window.addEventListener("error",c=>{i.trackError(c.error||new Error(c.message),{filename:c.filename,lineno:c.lineno,colno:c.colno})}),window.addEventListener("unhandledrejection",c=>{let l=c.reason instanceof Error?c.reason:new Error(String(c.reason));i.trackError(l,{type:"unhandledrejection"})}));let d=()=>i.trackPageview(),u=r.debounceDuration>0?nt(d,r.debounceDuration):d;function g(){if(document.addEventListener("click",function(c){let l=c.target;for(;l&&l!==document.documentElement;){if(l.hasAttribute("data-rybbit-event")){let p=l.getAttribute("data-rybbit-event");if(p){let C={};for(let T of l.attributes)if(T.name.startsWith("data-rybbit-prop-")){let w=T.name.replace("data-rybbit-prop-","");C[w]=T.value}i.trackEvent(p,C)}break}l=l.parentElement}if(r.trackOutbound){let p=c.target.closest("a");p?.href&&it(p.href)&&i.trackOutbound(p.href,p.innerText||p.textContent||"",p.target||"_self")}}),r.autoTrackSpa){let c=history.pushState,l=history.replaceState;history.pushState=function(...p){c.apply(this,p),u(),i.onPageChange()},history.replaceState=function(...p){l.apply(this,p),u(),i.onPageChange()},window.addEventListener("popstate",()=>{u(),i.onPageChange()}),window.addEventListener("hashchange",()=>{u(),i.onPageChange()})}}window[r.namespace]={pageview:()=>i.trackPageview(),event:(c,l={})=>i.trackEvent(c,l),error:(c,l={})=>i.trackError(c,l),trackOutbound:(c,l="",p="_self")=>i.trackOutbound(c,l,p),identify:(c,l)=>i.identify(c,l),setTraits:c=>i.setTraits(c),clearUserId:()=>i.clearUserId(),getUserId:()=>i.getUserId(),startSessionReplay:()=>i.startSessionReplay(),stopSessionReplay:()=>i.stopSessionReplay(),isSessionReplayActive:()=>i.isSessionReplayActive()},g(),window.addEventListener("beforeunload",()=>{s?.cleanup(),o?.cleanup(),i.cleanup()}),r.autoTrackPageview&&i.trackPageview()})();})();