!function(){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(t){for(var r=1;arguments.length>r;r++){var e=arguments[r];for(var i in e)({}).hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},t.apply(null,arguments)}var r="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:r;"undefined"==typeof self&&(e.self=e),"undefined"==typeof File&&(e.File=function(){});var i=null==e?void 0:e.document;null!=e&&e.XMLHttpRequest&&new e.XMLHttpRequest;var n=null!=r?r:{};function a(t,r){return-1!==t.indexOf(r)}var l=function(t){return t.trim()},o=Object.prototype,s=o.hasOwnProperty,u=o.toString,c=Array.isArray||function(t){return"[object Array]"===u.call(t)},v=t=>"function"==typeof t,h=t=>void 0===t,f=t=>"[object String]"==u.call(t),d=t=>null===t,_=t=>h(t)||d(t),m=t=>"[object Number]"==u.call(t)&&t==t,b=t=>t instanceof FormData,p=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,a={k(e){if(r&&(n.POSTHOG_DEBUG||i)&&!h(r.console)&&r.console){for(var a=("__rrweb_original__"in r.console[e]?r.console[e].__rrweb_original__:r.console[e]),l=arguments.length,o=new Array(l>1?l-1:0),s=1;l>s;s++)o[s-1]=arguments[s];a(t,...o)}},debug(){for(var t=arguments.length,r=new Array(t),e=0;t>e;e++)r[e]=arguments[e];a.k("debug",...r)},info(){for(var t=arguments.length,r=new Array(t),e=0;t>e;e++)r[e]=arguments[e];a.k("log",...r)},warn(){for(var t=arguments.length,r=new Array(t),e=0;t>e;e++)r[e]=arguments[e];a.k("warn",...r)},error(){for(var t=arguments.length,r=new Array(t),e=0;t>e;e++)r[e]=arguments[e];a.k("error",...r)},critical(){for(var r=arguments.length,e=new Array(r),i=0;r>i;i++)e[i]=arguments[i];console.error(t,...e)},uninitializedWarning(t){a.error("You must initialize PostHog before calling "+t)},createLogger:(r,e)=>p(t+" "+r,e)};return a},g=p("[PostHog.js]"),y=g.createLogger;function k(t,r){if(!_(t))if(c(t))t.forEach(r);else if(b(t))t.forEach(((t,e)=>r(t,e)));else for(var e in t)s.call(t,e)&&r(t[e],e)}var w=function(t){for(var r=arguments.length,e=new Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];for(var n of e)for(var a in n)void 0!==n[a]&&(t[a]=n[a]);return t};function A(t){for(var r=Object.keys(t),e=r.length,i=new Array(e);e--;)i[e]=[r[e],t[r[e]]];return i}function x(t,r,e,i){var{capture:n=!1,passive:a=!0}=null!=i?i:{};null==t||t.addEventListener(r,e,{capture:n,passive:a})}var E=1,O=3,C=11;function j(t){return!!t&&t.nodeType===E}function D(t,r){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===r.toLowerCase()}function L(t){return!!t&&t.nodeType===C&&j(t.host)}function T(t){return t?l(t).split(/\s+/):[]}function R(t){var r="";switch(typeof t.className){case"string":r=t.className;break;case"object":r=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:r=""}return T(r)}function M(t){var r="";return B(t)&&!F(t)&&t.childNodes&&t.childNodes.length&&k(t.childNodes,(function(t){var e,i;(function(t){return!!t&&t.nodeType===O})(t)&&t.textContent&&(r+=null!==(e=_(i=t.textContent)?null:l(i).split(/(\s+)/).filter((t=>Y(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))&&void 0!==e?e:"")})),l(r)}var I=["a","button","form","input","select","textarea","label"];function S(t){var r=t.parentNode;return!(!r||!j(r))&&r}var z=[".ph-no-deadclick",".ph-no-capture"];var H=t=>!t||D(t,"html")||!j(t),P=(t,e)=>{if(!r||H(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,n=[t],a=t;a.parentNode&&!D(a,"body");)if(L(a.parentNode))n.push(a.parentNode.host),a=a.parentNode.host;else{var l=S(a);if(!l)break;if(I.indexOf(l.tagName.toLowerCase())>-1)i=!0;else{var o=r.getComputedStyle(l);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}n.push(l),a=l}return{parentIsUsefulElement:i,targetElementList:n}};function B(t){for(var r=t;r.parentNode&&!D(r,"body");r=r.parentNode){var e=R(r);if(a(e,"ph-sensitive")||a(e,"ph-no-capture"))return!1}if(a(R(t),"ph-include"))return!0;var i=t.type||"";if(f(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var n=t.name||t.id||"";return!f(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function F(t){return!!(D(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||D(t,"select")||D(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var N="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",U=new RegExp("^(?:"+N+")$"),V=new RegExp(N),W="\\d{3}-?\\d{2}-?\\d{4}",q=new RegExp("^("+W+")$"),G=new RegExp("("+W+")");function Y(t,r){if(void 0===r&&(r=!0),_(t))return!1;if(f(t)){if(t=l(t),(r?U:V).test((t||"").replace(/[- ]/g,"")))return!1;if((r?q:G).test(t))return!1}return!0}function Z(t){var r=M(t);return Y(r=(r+" "+J(t)).trim())?r:""}function J(t){var r="";return t&&t.childNodes&&t.childNodes.length&&k(t.childNodes,(function(t){var e;if(t&&"span"===(null==(e=t.tagName)?void 0:e.toLowerCase()))try{var i=M(t);r=(r+" "+i).trim(),t.childNodes&&t.childNodes.length&&(r=(r+" "+J(t)).trim())}catch(t){g.error("[AutoCapture]",t)}})),r}function K(t){return t.replace(/"|\\"/g,'\\"')}function Q(t){var r=t.attr__class;return r?c(r)?r:T(r):void 0}function X(t,r){return r.length>t?r.slice(0,t)+"...":r}function tt(t){if(t.previousElementSibling)return t.previousElementSibling;var r=t;do{r=r.previousSibling}while(r&&!j(r));return r}function rt(e,n){var l,o,{e:s,maskAllElementAttributes:u,maskAllText:c,elementAttributeIgnoreList:v}=n;if(!j(e))return{props:{}};for(var d=[e],_=e;_.parentNode&&!D(_,"body");)if(L(_.parentNode))d.push(_.parentNode.host),_=_.parentNode.host;else{if(!j(_.parentNode))break;d.push(_.parentNode),_=_.parentNode}var m,b,p,g,y=[],x={},E=!1,O=!1;if(k(d,(t=>{var r=B(t);if(D(t,"a")){var e=t.getAttribute("href");E=r&&!!e&&Y(e)&&e}a(R(t),"ph-no-capture")&&(O=!0),y.push(function(t,r,e,i){var n=t.tagName.toLowerCase(),a={tag_name:n};I.indexOf(n)>-1&&!e&&(a.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?X(1024,Z(t)):X(1024,M(t)));var l=R(t);l.length>0&&(a.classes=l.filter((function(t){return""!==t}))),k(t.attributes,(function(e){var n;if((!F(t)||-1!==["name","id","class","aria-label"].indexOf(e.name))&&(null==i||!i.includes(e.name))&&!r&&Y(e.value)&&(!f(n=e.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var l=e.value;"class"===e.name&&(l=T(l).join(" ")),a["attr__"+e.name]=X(1024,l)}}));for(var o=1,s=1,u=t;u=tt(u);)o++,u.tagName===t.tagName&&s++;return a.nth_child=o,a.nth_of_type=s,a}(t,u,c,v));var i=function(t){if(!B(t))return{};var r={};return k(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var e=t.name.replace("data-ph-capture-attribute-",""),i=t.value;e&&i&&Y(i)&&(r[e]=i)}})),r}(t);w(x,i)})),O)return{props:{},explicitNoCapture:O};if(c||(y[0].$el_text=D(e,"a")||D(e,"button")?Z(e):M(e)),E){var C,S;y[0].attr__href=E;var z=null==(b=E,p=null==i?void 0:i.createElement("a"),C=h(p)?null:(p.href=b,p))?void 0:C.host,H=null==r||null==(S=r.location)?void 0:S.host;z&&H&&z!==H&&(m=E)}return{props:w({$event_type:s.type,$ce_version:1},{$elements:y},{$elements_chain:(g=y,function(r){return r.map((r=>{var e,i,n="";if(r.tag_name&&(n+=r.tag_name),r.attr_class)for(var a of(r.attr_class.sort(),r.attr_class))n+="."+a.replace(/"/g,"");var l=t({},r.text?{text:r.text}:{},{"nth-child":null!==(e=r.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(i=r.nth_of_type)&&void 0!==i?i:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),o={};return A(l).sort(((t,r)=>{var[e]=t,[i]=r;return e.localeCompare(i)})).forEach((t=>{var[r,e]=t;return o[K(r.toString())]=K(e.toString())})),(n+=":")+A(o).map((t=>{var[r,e]=t;return r+'="'+e+'"'})).join("")})).join(";")}(function(t){return t.map((t=>{var r,e,i={text:null==(r=t.$el_text)?void 0:r.slice(0,400),tag_name:t.tag_name,href:null==(e=t.attr__href)?void 0:e.slice(0,2048),attr_class:Q(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return A(t).filter((t=>{var[r]=t;return 0===r.indexOf("attr__")})).forEach((t=>{var[r,e]=t;return i.attributes[r]=e})),i}))}(g)))},null!=(l=y[0])&&l.$el_text?{$el_text:null==(o=y[0])?void 0:o.$el_text}:{},m&&"click"===s.type?{$external_click_url:m}:{},x)}}y("[AutoCapture]");var et={};function it(t){return function(t,e){var i=et[t];if(i)return i;var n,a=e[t];if(v(n=a)&&-1!==n.toString().indexOf("[native code]")&&!r.Zone)return et[t]=a.bind(e);var l=e.document;if(l&&v(l.createElement))try{var o=l.createElement("iframe");o.hidden=!0,l.head.appendChild(o);var s=o.contentWindow;s&&s[t]&&(a=s[t]),l.head.removeChild(o)}catch(r){g.warn("Could not create sandbox iframe for "+t+" check, bailing to assignableWindow."+t+": ",r)}return a&&v(a)?et[t]=a.bind(e):a}("MutationObserver",t)}function nt(t,r){return m(t)&&t>=r}class at{St(t){var r,e,i,n,a,l=this.Ct((null==t?void 0:t.__onCapture)||this.It.bind(this));return{element_attribute_ignorelist:null!==(r=null==t?void 0:t.element_attribute_ignorelist)&&void 0!==r?r:l.element_attribute_ignorelist,scroll_threshold_ms:null!==(e=null==t?void 0:t.scroll_threshold_ms)&&void 0!==e?e:l.scroll_threshold_ms,selection_change_threshold_ms:null!==(i=null==t?void 0:t.selection_change_threshold_ms)&&void 0!==i?i:l.selection_change_threshold_ms,mutation_threshold_ms:null!==(n=null==t?void 0:t.mutation_threshold_ms)&&void 0!==n?n:l.mutation_threshold_ms,capture_clicks_with_modifier_keys:null!==(a=null==t?void 0:t.capture_clicks_with_modifier_keys)&&void 0!==a?a:l.capture_clicks_with_modifier_keys,css_selector_ignorelist:null==t?void 0:t.css_selector_ignorelist,__onCapture:l.__onCapture}}constructor(t,r){this.Tt=[],this.Ct=t=>({element_attribute_ignorelist:[],scroll_threshold_ms:100,selection_change_threshold_ms:100,mutation_threshold_ms:2500,capture_clicks_with_modifier_keys:!1,__onCapture:t}),this.Mt=t=>{var r=function(t){var r,e,i=h((r=t).target)?r.srcElement||null:null!=(e=r.target)&&e.shadowRoot?r.composedPath()[0]||null:r.target||null;return i?{node:i,originalEvent:t,timestamp:Date.now()}:null}(t);d(r)||this._t(r)||this.Tt.push(r),this.Tt.length&&h(this.Lt)&&(this.Lt=n.setTimeout((()=>{this.Et()}),1e3))},this.Ot=()=>{var t=Date.now();t%50==0&&this.Tt.forEach((r=>{h(r.scrollDelayMs)&&(r.scrollDelayMs=t-r.timestamp)}))},this.Rt=()=>{this.Nt=Date.now()},this.At=()=>{"visible"===(null==i?void 0:i.visibilityState)&&(this.Pt=Date.now())},this.instance=t,this.qt=this.St(r),this._onCapture=this.qt.__onCapture}start(t){this.Dt(),this.Ft(),this.jt(),this.Ht(),this.Ut(t)}Ut(t){if(!this.Bt){var r=it(n);this.Bt=new r((t=>{this.Vt(t)})),this.Bt.observe(t,{attributes:!0,characterData:!0,childList:!0,subtree:!0})}}stop(){var t;null==(t=this.Bt)||t.disconnect(),this.Bt=void 0,n.removeEventListener("click",this.Mt),n.removeEventListener("scroll",this.Ot,{capture:!0}),n.removeEventListener("selectionchange",this.Rt),null==i||i.removeEventListener("visibilitychange",this.At)}Vt(t){this.Wt=Date.now()}Dt(){x(n,"click",this.Mt)}Ft(){x(n,"scroll",this.Ot,{capture:!0})}jt(){x(n,"selectionchange",this.Rt)}Ht(){x(i,"visibilitychange",this.At)}_t(t){return!(t&&(this.qt.capture_clicks_with_modifier_keys||!((e=t.originalEvent).ctrlKey||e.metaKey||e.altKey||e.shiftKey))&&!((i=t.node)instanceof Element&&("__POSTHOG_TOOLBAR__"===i.id||null!=i.closest&&i.closest(".toolbar-global-fade-container")))&&!this.Tt.some((r=>r.node===t.node&&1e3>Math.abs(r.timestamp-t.timestamp)))&&!D(t.node,"html")&&j(t.node)&&!function(t){if(!r||H(t))return!1;var{targetElementList:e}=P(t);return e.some((t=>D(t,"a")))}(t.node)&&function(t,e){var i;if(!r||H(t))return!1;var n="[object Boolean]"===u.call(e)?z:null!==(i=null==e?void 0:e.css_selector_ignorelist)&&void 0!==i?i:z,{targetElementList:a}=P(t);return!function(t,r){if(h(r))return!0;var e,i=function(t){if(r.some((r=>t.matches(r))))return{v:!0}};for(var n of t)if(e=i(n))return e.v;return!1}(a,n)}(t.node,{css_selector_ignorelist:this.qt.css_selector_ignorelist}));var e,i}Et(){if(this.Tt.length){clearTimeout(this.Lt),this.Lt=void 0;var t=this.Tt;for(var r of(this.Tt=[],t)){var e;r.mutationDelayMs=null!==(e=r.mutationDelayMs)&&void 0!==e?e:this.Wt&&this.Wt>=r.timestamp?this.Wt-r.timestamp:void 0,r.absoluteDelayMs=Date.now()-r.timestamp,r.selectionChangedDelayMs=this.Nt&&this.Nt>=r.timestamp?this.Nt-r.timestamp:void 0,r.visibilityChangedDelayMs=this.Pt?Math.abs(r.timestamp-this.Pt):void 0;var i=nt(r.scrollDelayMs,this.qt.scroll_threshold_ms),a=nt(r.selectionChangedDelayMs,this.qt.selection_change_threshold_ms),l=nt(r.mutationDelayMs,this.qt.mutation_threshold_ms),o=nt(r.absoluteDelayMs,1.1*this.qt.mutation_threshold_ms),s=m(r.scrollDelayMs)&&this.qt.scroll_threshold_ms>r.scrollDelayMs,u=m(r.mutationDelayMs)&&this.qt.mutation_threshold_ms>r.mutationDelayMs,c=m(r.selectionChangedDelayMs)&&this.qt.selection_change_threshold_ms>r.selectionChangedDelayMs,v=m(r.visibilityChangedDelayMs)&&this.qt.selection_change_threshold_ms>r.visibilityChangedDelayMs;if(!(s||u||c||v)){var f=nt(r.visibilityChangedDelayMs,this.qt.selection_change_threshold_ms);i||l||o||a||f?this._onCapture(r,{$dead_click_last_mutation_timestamp:this.Wt,$dead_click_event_timestamp:r.timestamp,$dead_click_scroll_timeout:i,$dead_click_mutation_timeout:l,$dead_click_absolute_timeout:o,$dead_click_selection_changed_timeout:a,$dead_click_visibility_changed_timeout:f}):this.qt.mutation_threshold_ms>r.absoluteDelayMs&&this.Tt.push(r)}}this.Tt.length&&h(this.Lt)&&(this.Lt=n.setTimeout((()=>{this.Et()}),1e3))}}It(r,e){this.instance.capture("$dead_click",t({},e,rt(r.node,{e:r.originalEvent,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist}).props,{$dead_click_scroll_delay_ms:r.scrollDelayMs,$dead_click_mutation_delay_ms:r.mutationDelayMs,$dead_click_absolute_delay_ms:r.absoluteDelayMs,$dead_click_selection_changed_delay_ms:r.selectionChangedDelayMs,$dead_click_visibility_changed_delay_ms:r.visibilityChangedDelayMs}),{timestamp:new Date(r.timestamp)})}}n.__PosthogExtensions__=n.__PosthogExtensions__||{},n.__PosthogExtensions__.initDeadClicksAutocapture=(t,r)=>new at(t,r)}(); //# sourceMappingURL=dead-clicks-autocapture.js.map