@molin.ai/shop-ai 0.4.21 → 0.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -417,7 +417,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
417
417
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function oh(t,e){if(t){if(typeof t=="string")return Wl(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Wl(t,e):void 0}}function Wl(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function ai(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=oh(t))||e&&t&&typeof t.length=="number"){r&&(t=r);var i=0,n=function(){};return{s:n,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(l){throw l},f:n}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
418
418
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,a=!0,o=!1;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){o=!0,s=l},f:function(){try{a||r.return==null||r.return()}finally{if(o)throw s}}}}var oi={DEBUG:!1,LIB_VERSION:"1.95.1"},M0=Array.isArray,wd=Object.prototype,xd=wd.hasOwnProperty,Yn=wd.toString,We=M0||function(t){return Yn.call(t)==="[object Array]"},jp=function(t){return Yn.call(t)==="[object Uint8Array]"},jt=function(t){return typeof t=="function"},Pr=function(t){return t===Object(t)&&!We(t)},D0=function(t){if(Pr(t)){for(var e in t)if(xd.call(t,e))return!1;return!0}return!1},ve=function(t){return t===void 0},St=function(t){return Yn.call(t)=="[object String]"},Ft=function(t){return t===null},cr=function(t){return Yn.call(t)=="[object Number]"},Zl=function(t){return Yn.call(t)==="[object Boolean]"},Sd=Array.prototype,Gp=Sd.forEach,Hp=Sd.indexOf,O=typeof window<"u"?window:void 0,qp=O?.navigator,K=O?.document,Ge=qp?.userAgent,tt=O??{},Up="[PostHog.js]",j={_log:function(t){if(O&&(oi.DEBUG||tt.POSTHOG_DEBUG)&&!ve(O.console)&&O.console){for(var e=("__rrweb_original__"in O.console[t])?O.console[t].__rrweb_original__:O.console[t],r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];e.apply(void 0,[Up].concat(i))}},info:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];j._log.apply(j,["log"].concat(e))},warn:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];j._log.apply(j,["warn"].concat(e))},error:function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];j._log.apply(j,["error"].concat(e))},critical:function(){for(var t,e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];(t=console).error.apply(t,[Up].concat(r))},uninitializedWarning:function(t){j.error("You must initialize PostHog before calling ".concat(t))}},lh={},Ga=function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function Ji(t,e,r){if(We(t)){if(Gp&&t.forEach===Gp)t.forEach(e,r);else if("length"in t&&t.length===+t.length){for(var i=0,n=t.length;i<n;i++)if(i in t&&e.call(r,t[i],i)===lh)return}}}function Ce(t,e,r){if(!Ft(t)&&!ve(t)){if(We(t))return Ji(t,e,r);for(var i in t)if(xd.call(t,i)&&e.call(r,t[i],i)===lh)return}}var Ye=function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i<e;i++)r[i-1]=arguments[i];return Ji(r,function(n){for(var s in n)n[s]!==void 0&&(t[s]=n[s])}),t};function xe(t,e){return t.indexOf(e)!==-1}function Ra(t){for(var e=Object.keys(t),r=e.length,i=new Array(r);r--;)i[r]=[e[r],t[e[r]]];return i}var kd=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},Wp=function(t){try{return t()}catch{return}},Ed=function(t){return function(){try{for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return t.apply(this,r)}catch(n){j.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),j.critical(n)}}},Yl=function(t){var e={};return Ce(t,function(r,i){St(r)&&r.length>0&&(e[i]=r)}),e},F0=["$performance_raw"];function $0(t,e){return r=t,i=function(s,a){return a&&F0.indexOf(a)>-1?s:St(s)&&!Ft(e)?s.slice(0,e):s},n=new Set,function s(a,o){return a!==Object(a)?i?i(a,o):a:n.has(a)?void 0:(n.add(a),We(a)?(l=[],Ji(a,function(h){l.push(s(h))})):(l={},Ce(a,function(h,c){n.has(h)||(l[c]=s(h,c))})),l);var l}(r);var r,i,n}function hh(t){var e,r,i,n,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,l=0,h="",c=[];if(!t)return t;t=O0(t);do e=(s=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>18&63,r=s>>12&63,i=s>>6&63,n=63&s,c[l++]=a.charAt(e)+a.charAt(r)+a.charAt(i)+a.charAt(n);while(o<t.length);switch(h=c.join(""),t.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h}var O0=function(t){var e,r,i,n,s="";for(e=r=0,i=(t=(t+"").replace(/\r\n/g,`
|
|
419
419
|
`).replace(/\r/g,`
|
|
420
|
-
`)).length,n=0;n<i;n++){var a=t.charCodeAt(n),o=null;a<128?r++:o=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),Ft(o)||(r>e&&(s+=t.substring(e,r)),s+=o,e=r=n+1)}return r>e&&(s+=t.substring(e,t.length)),s},qn=function(){function t(e){return e&&(e.preventDefault=t.preventDefault,e.stopPropagation=t.stopPropagation),e}return t.preventDefault=function(){this.returnValue=!1},t.stopPropagation=function(){this.cancelBubble=!0},function(e,r,i,n,s){if(e)if(e.addEventListener&&!n)e.addEventListener(r,i,!!s);else{var a="on"+r,o=e[a];e[a]=function(l,h,c){return function(u){if(u=u||t(O?.event)){var f,p=!0;jt(c)&&(f=c(u));var m=h.call(l,u);return f!==!1&&m!==!1||(p=!1),p}}}(e,i,o)}else j.error("No valid element provided to register_event")}}();function Un(t,e){var r=function(){if(!K)return e("document not found");var i=K.createElement("script");i.type="text/javascript",i.src=t,i.onload=function(a){return e(void 0,a)},i.onerror=function(a){return e(a)};var n,s=K.querySelectorAll("body > script");s.length>0?(n=s[0].parentNode)===null||n===void 0||n.insertBefore(i,s[0]):K.body.appendChild(i)};K!=null&&K.body?r():K?.addEventListener("DOMContentLoaded",r)}function ch(t){return t?Ga(t).split(/\s+/):[]}function Ha(t){var e="";switch(Hl(t.className)){case"string":e=t.className;break;case"object":e=("baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return ch(e)}function qa(t){var e="";return La(t)&&!Ad(t)&&t.childNodes&&t.childNodes.length&&Ce(t.childNodes,function(r){Pd(r)&&r.textContent&&(e+=Ga(r.textContent).split(/(\s+)/).filter(Wi).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),Ga(e)}function Zp(t){return!!t&&t.nodeType===1}function si(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Pd(t){return!!t&&t.nodeType===3}function Yp(t){return!!t&&t.nodeType===11}var Vl=["a","button","form","input","select","textarea","label"];function La(t){for(var e=t;e.parentNode&&!si(e,"body");e=e.parentNode){var r=Ha(e);if(xe(r,"ph-sensitive")||xe(r,"ph-no-capture"))return!1}if(xe(Ha(t),"ph-include"))return!0;var i=t.type||"";if(St(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var n=t.name||t.id||"";return!(St(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 Ad(t){return!!(si(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||si(t,"select")||si(t,"textarea")||t.getAttribute("contenteditable")==="true")}function Wi(t){return!(Ft(t)||ve(t)||St(t)&&(t=Ga(t),/^(?:(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}))$/.test((t||"").replace(/[- ]/g,""))||/(^\d{3}-?\d{2}-?\d{4}$)/.test(t)))}function Jp(t){var e=qa(t);return Wi(e="".concat(e," ").concat(Cd(t)).trim())?e:""}function Cd(t){var e="";return t&&t.childNodes&&t.childNodes.length&&Ce(t.childNodes,function(r){var i;if(r&&((i=r.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{var n=qa(r);e="".concat(e," ").concat(n).trim(),r.childNodes&&r.childNodes.length&&(e="".concat(e," ").concat(Cd(r)).trim())}catch(s){j.error(s)}}),e}function R0(t){return function(e){var r=e.map(function(i){var n,s,a="";if(i.tag_name&&(a+=i.tag_name),i.attr_class){i.attr_class.sort();var o,l=ai(i.attr_class);try{for(l.s();!(o=l.n()).done;){var h=o.value;a+=".".concat(h.replace(/"/g,""))}}catch(f){l.e(f)}finally{l.f()}}var c=ne(ne(ne(ne({},i.text?{text:i.text}:{}),{},{"nth-child":(n=i.nth_child)!==null&&n!==void 0?n:0,"nth-of-type":(s=i.nth_of_type)!==null&&s!==void 0?s:0},i.href?{href:i.href}:{}),i.attr_id?{attr_id:i.attr_id}:{}),i.attributes),u={};return Ra(c).sort(function(f,p){var m=zt(f,1)[0],g=zt(p,1)[0];return m.localeCompare(g)}).forEach(function(f){var p=zt(f,2),m=p[0],g=p[1];return u[Xp(m.toString())]=Xp(g.toString())}),a+=":",a+=Ra(c).map(function(f){var p=zt(f,2),m=p[0],g=p[1];return"".concat(m,'="').concat(g,'"')}).join("")});return r.join(";")}(function(e){return e.map(function(r){var i,n,s={text:(i=r.$el_text)===null||i===void 0?void 0:i.slice(0,400),tag_name:r.tag_name,href:(n=r.attr__href)===null||n===void 0?void 0:n.slice(0,2048),attr_class:L0(r),attr_id:r.attr__id,nth_child:r.nth_child,nth_of_type:r.nth_of_type,attributes:{}};return Ra(r).filter(function(a){return zt(a,1)[0].indexOf("attr__")===0}).forEach(function(a){var o=zt(a,2),l=o[0],h=o[1];return s.attributes[l]=h}),s})}(t))}function Xp(t){return t.replace(/"|\\"/g,'\\"')}function L0(t){var e=t.attr__class;return e?We(e)?e:ch(e):void 0}var B0=function(){function t(e){Oe(this,t),this.clicks=[],this.enabled=e}return Re(t,[{key:"isRageClick",value:function(e,r,i){if(!this.enabled)return!1;var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(r-n.y)<30&&i-n.timestamp<1e3){if(this.clicks.push({x:e,y:r,timestamp:i}),this.clicks.length===3)return!0}else this.clicks=[{x:e,y:r,timestamp:i}];return!1}}]),t}(),Td="$people_distinct_id",Ba="__alias",Gn="__timers",Kp="$autocapture_disabled_server_side",Jl="$session_recording_enabled_server_side",Qp="$console_log_recording_enabled_server_side",ed="$session_recording_recorder_version_server_side",td="$session_recording_network_payload_capture",Ua="$sesid",Va="$session_is_sampled",Zi="$enabled_feature_flags",Xl="$early_access_features",Yi="$stored_person_properties",kr="$stored_group_properties",Kl="$surveys",Wa="$flag_call_reported",Ql="$user_state",eh="$posthog_quota_limited",th="$client_session_props",V0=[Td,Ba,"__cmpns",Gn,Jl,Ua,Zi,Ql,eh,Xl,kr,Yi,Kl,Wa,th];function Nl(t,e){return e.length>t?e.slice(0,t)+"...":e}var Er={_initializedTokens:[],_isDisabledServerSide:null,_isAutocaptureEnabled:!1,_setIsAutocaptureEnabled:function(t){var e,r=Ft(this._isDisabledServerSide)?!((e=t.persistence)===null||e===void 0||!e.props[Kp]):this._isDisabledServerSide,i=!!t.config.autocapture;this._isAutocaptureEnabled=i&&!r},_previousElementSibling:function(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Zp(e));return e},_getAugmentPropertiesFromElement:function(t){if(!La(t))return{};var e={};return Ce(t.attributes,function(r){if(r.name.indexOf("data-ph-capture-attribute")===0){var i=r.name.replace("data-ph-capture-attribute-",""),n=r.value;i&&n&&Wi(n)&&(e[i]=n)}}),e},_getPropertiesFromElement:function(t,e,r){var i,n=t.tagName.toLowerCase(),s={tag_name:n};Vl.indexOf(n)>-1&&!r&&(n.toLowerCase()==="a"||n.toLowerCase()==="button"?s.$el_text=Nl(1024,Jp(t)):s.$el_text=Nl(1024,qa(t)));var a=Ha(t);a.length>0&&(s.classes=a.filter(function(u){return u!==""}));var o=(i=this.config)===null||i===void 0?void 0:i.element_attribute_ignorelist;Ce(t.attributes,function(u){var f;if((!Ad(t)||["name","id","class"].indexOf(u.name)!==-1)&&(o==null||!o.includes(u.name))&&!e&&Wi(u.value)&&(f=u.name,!St(f)||f.substring(0,10)!=="_ngcontent"&&f.substring(0,7)!=="_nghost")){var p=u.value;u.name==="class"&&(p=ch(p).join(" ")),s["attr__"+u.name]=Nl(1024,p)}});for(var l=1,h=1,c=t;c=this._previousElementSibling(c);)l++,c.tagName===t.tagName&&h++;return s.nth_child=l,s.nth_of_type=h,s},_getDefaultProperties:function(t){return{$event_type:t,$ce_version:1}},_extractCustomPropertyValue:function(t){var e=[];return Ce(K?.querySelectorAll(t.css_selector),function(r){var i;["input","select"].indexOf(r.tagName.toLowerCase())>-1?i=r.value:r.textContent&&(i=r.textContent),Wi(i)&&e.push(i)}),e.join(", ")},_getCustomProperties:function(t){var e=this,r={};return Ce(this._customProperties,function(i){Ce(i.event_selectors,function(n){Ce(K?.querySelectorAll(n),function(s){xe(t,s)&&La(s)&&(r[i.name]=e._extractCustomPropertyValue(i))})})}),r},_getEventTarget:function(t){return ve(t.target)?t.srcElement||null:(e=t.target)!==null&&e!==void 0&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e},_captureEvent:function(t,e){var r,i=this,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"$autocapture",s=this._getEventTarget(t);if(Pd(s)&&(s=s.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,e,"$rageclick"),s&&function(g,d){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!O||!g||si(g,"html")||!Zp(g))return!1;if(y!=null&&y.url_allowlist){var v=O.location.href,b=y.url_allowlist;if(b&&!b.some(function(E){return v.match(E)}))return!1}if(y!=null&&y.dom_event_allowlist){var _=y.dom_event_allowlist;if(_&&!_.some(function(E){return d.type===E}))return!1}if(y!=null&&y.element_allowlist){var S=y.element_allowlist;if(S&&!S.some(function(E){return g.tagName.toLowerCase()===E}))return!1}if(y!=null&&y.css_selector_allowlist){var T=y.css_selector_allowlist;if(T&&!T.some(function(E){return g.matches(E)}))return!1}for(var x=!1,w=[g],M=!0,k=g;k.parentNode&&!si(k,"body");)if(Yp(k.parentNode))w.push(k.parentNode.host),k=k.parentNode.host;else{if(!(M=k.parentNode||!1))break;if(Vl.indexOf(M.tagName.toLowerCase())>-1)x=!0;else{var I=O.getComputedStyle(M);I&&I.getPropertyValue("cursor")==="pointer"&&(x=!0)}w.push(M),k=M}var P=O.getComputedStyle(g);if(P&&P.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0;var A=g.tagName.toLowerCase();switch(A){case"html":return!1;case"form":return d.type==="submit";case"input":case"select":case"textarea":return d.type==="change"||d.type==="click";default:return x?d.type==="click":d.type==="click"&&(Vl.indexOf(A)>-1||g.getAttribute("contenteditable")==="true")}}(s,t,this.config)){for(var a,o,l=[s],h=s;h.parentNode&&!si(h,"body");)Yp(h.parentNode)?(l.push(h.parentNode.host),h=h.parentNode.host):(l.push(h.parentNode),h=h.parentNode);var c,u=[],f={},p=!1;if(Ce(l,function(g){var d=La(g);g.tagName.toLowerCase()==="a"&&(c=g.getAttribute("href"),c=d&&Wi(c)&&c),xe(Ha(g),"ph-no-capture")&&(p=!0),u.push(i._getPropertiesFromElement(g,e.config.mask_all_element_attributes,e.config.mask_all_text));var y=i._getAugmentPropertiesFromElement(g);Ye(f,y)}),e.config.mask_all_text||(s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?u[0].$el_text=Jp(s):u[0].$el_text=qa(s)),c&&(u[0].attr__href=c),p)return!1;var m=Ye(this._getDefaultProperties(t.type),e.elementsChainAsString?{$elements_chain:R0(u)}:{$elements:u},(a=u[0])!==null&&a!==void 0&&a.$el_text?{$el_text:(o=u[0])===null||o===void 0?void 0:o.$el_text}:{},this._getCustomProperties(l),f);return e.capture(n,m),!0}},_navigate:function(t){O&&(O.location.href=t)},_addDomEventHandlers:function(t){var e=this;if(O&&K){var r=function(i){i=i||O?.event,e._captureEvent(i,t)};qn(K,"submit",r,!1,!0),qn(K,"change",r,!1,!0),qn(K,"click",r,!1,!0)}},_customProperties:[],rageclicks:null,config:void 0,init:function(t){var e;Zl(t.__autocapture)||(this.config=t.__autocapture),(e=this.config)!==null&&e!==void 0&&e.url_allowlist&&(this.config.url_allowlist=this.config.url_allowlist.map(function(r){return new RegExp(r)})),this.rageclicks=new B0(t.config.rageclick)},afterDecideResponse:function(t,e){var r=e.config.token;this._initializedTokens.indexOf(r)>-1?j.info('autocapture already initialized for token "'+r+'"'):(e.persistence&&e.persistence.register(Y({},Kp,!!t.autocapture_opt_out)),this._isDisabledServerSide=!!t.autocapture_opt_out,this._setIsAutocaptureEnabled(e),this._initializedTokens.push(r),t&&t.config&&t.config.enable_collect_everything&&this._isAutocaptureEnabled?(t.custom_properties&&(this._customProperties=t.custom_properties),this._addDomEventHandlers(e)):e.__autocapture=!1)},enabledForProject:function(t,e,r){if(!t)return!0;e=ve(e)?10:e,r=ve(r)?10:r;for(var i=0,n=0;n<t.length;n++)i+=t.charCodeAt(n);return i%e<r},isBrowserSupported:function(){return jt(K?.querySelectorAll)}};(function(t){for(var e in t)jt(t[e])&&(t[e]=t[e].bind(t))})(Er),function(t){for(var e in t)jt(t[e])&&(t[e]=Ed(t[e]))}(Er);var zl="$active_feature_flags",Ma="$override_feature_flags",rd="$feature_flag_payloads",id=function(t){var e,r={},i=ai(Ra(t||{}));try{for(i.s();!(e=i.n()).done;){var n=zt(e.value,2),s=n[0],a=n[1];a&&(r[s]=a)}}catch(o){i.e(o)}finally{i.f()}return r},N0=function(){function t(e){Oe(this,t),this.instance=e,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return Re(t,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var e=this.instance.get_property(Zi),r=this.instance.get_property(Ma);if(!r)return e||{};for(var i=Ye({},e),n=Object.keys(r),s=0;s<n.length;s++)r[n[s]]===!1?delete i[n[s]]:i[n[s]]=r[n[s]];return this._override_warning||(j.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:r,finalFlags:i}),this._override_warning=!0),i}},{key:"getFlagPayloads",value:function(){return this.instance.get_property(rd)||{}}},{key:"reloadFeatureFlags",value:function(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}},{key:"setAnonymousDistinctId",value:function(e){this.$anon_distinct_id=e}},{key:"setReloadingPaused",value:function(e){this.reloadFeatureFlagsInAction=e}},{key:"resetRequestQueue",value:function(){this.reloadFeatureFlagsQueued=!1}},{key:"_startReloadTimer",value:function(){var e=this;this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout(function(){!e.reloadFeatureFlagsInAction&&e.reloadFeatureFlagsQueued&&(e.reloadFeatureFlagsQueued=!1,e._reloadFeatureFlagsRequest())},5)}},{key:"_reloadFeatureFlagsRequest",value:function(){var e=this;if(!this.instance.config.advanced_disable_feature_flags){this.setReloadingPaused(!0);var r=this.instance.config.token,i=this.instance.get_property(Yi),n=this.instance.get_property(kr),s=hh(JSON.stringify({token:r,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i,group_properties:n,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0}));this.instance._send_request(this.instance.config.api_host+"/decide/?v=3",{data:s},{method:"POST"},this.instance._prepare_callback(function(a){e.$anon_distinct_id=void 0,e.receivedFeatureFlags(a),e.setReloadingPaused(!1),e._startReloadTimer()}))}}},{key:"getFeatureFlag",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0){var i,n=this.getFlagVariants()[e],s="".concat(n),a=this.instance.get_property(Wa)||{};return(r.send_event||!("send_event"in r))&&(!(e in a)||!a[e].includes(s))&&(We(a[e])?a[e].push(s):a[e]=[s],(i=this.instance.persistence)===null||i===void 0||i.register(Y({},Wa,a)),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:n})),n}j.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}},{key:"getFeatureFlagPayload",value:function(e){return this.getFlagPayloads()[e]}},{key:"isFeatureEnabled",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,r);j.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}},{key:"addFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers.push(e)}},{key:"removeFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(function(r){return r!==e})}},{key:"receivedFeatureFlags",value:function(e){if(this.instance.persistence){this.instance.decideEndpointWasHit=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads();(function(n,s){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=n.featureFlags,h=n.featureFlagPayloads;if(l)if(We(l)){var c,u={};if(l)for(var f=0;f<l.length;f++)u[l[f]]=!0;s&&s.register((Y(c={},zl,l),Y(c,Zi,u),c))}else{var p,m=l,g=h;n.errorsWhileComputingFlags&&(m=ne(ne({},a),m),g=ne(ne({},o),g)),s&&s.register((Y(p={},zl,Object.keys(id(m))),Y(p,Zi,m||{}),Y(p,rd,g||{}),p))}})(e,this.instance.persistence,r,i),this._fireFeatureFlagsCallbacks()}}},{key:"override",value:function(e){if(!this.instance.__loaded||!this.instance.persistence)return j.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=!1,e===!1)this.instance.persistence.unregister(Ma);else if(We(e)){for(var r={},i=0;i<e.length;i++)r[e[i]]=!0;this.instance.persistence.register(Y({},Ma,r))}else this.instance.persistence.register(Y({},Ma,e))}},{key:"onFeatureFlags",value:function(e){var r=this;if(this.addFeatureFlagsHandler(e),this.instance.decideEndpointWasHit){var i=this._prepareFeatureFlagsForCallbacks(),n=i.flags,s=i.flagVariants;e(n,s)}return function(){return r.removeFeatureFlagsHandler(e)}}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,r){var i,n,s=Y({},"$feature_enrollment/".concat(e),r);this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:r,$set:s}),this.setPersonPropertiesForFlags(s,!1);var a=ne(ne({},this.getFlagVariants()),{},Y({},e,r));(i=this.instance.persistence)===null||i===void 0||i.register((Y(n={},zl,Object.keys(id(a))),Y(n,Zi,a),n)),this._fireFeatureFlagsCallbacks()}},{key:"getEarlyAccessFeatures",value:function(e){var r=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.instance.get_property(Xl);if(n&&!i)return e(n);this.instance._send_request("".concat(this.instance.config.api_host,"/api/early_access_features/?token=").concat(this.instance.config.token),{},{method:"GET"},function(s){var a,o=s.earlyAccessFeatures;return(a=r.instance.persistence)===null||a===void 0||a.register(Y({},Xl,o)),e(o)})}},{key:"_prepareFeatureFlagsForCallbacks",value:function(){var e=this.getFlags(),r=this.getFlagVariants();return{flags:e.filter(function(i){return r[i]}),flagVariants:Object.keys(r).filter(function(i){return r[i]}).reduce(function(i,n){return i[n]=r[n],i},{})}}},{key:"_fireFeatureFlagsCallbacks",value:function(){var e=this._prepareFeatureFlagsForCallbacks(),r=e.flags,i=e.flagVariants;this.featureFlagEventHandlers.forEach(function(n){return n(r,i)})}},{key:"setPersonPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],i=this.instance.get_property(Yi)||{};this.instance.register(Y({},Yi,ne(ne({},i),e))),r&&this.instance.reloadFeatureFlags()}},{key:"resetPersonPropertiesForFlags",value:function(){this.instance.unregister(Yi)}},{key:"setGroupPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],i=this.instance.get_property(kr)||{};Object.keys(i).length!==0&&Object.keys(i).forEach(function(n){i[n]=ne(ne({},i[n]),e[n]),delete e[n]}),this.instance.register(Y({},kr,ne(ne({},i),e))),r&&this.instance.reloadFeatureFlags()}},{key:"resetGroupPropertiesForFlags",value:function(e){if(e){var r=this.instance.get_property(kr)||{};this.instance.register(Y({},kr,ne(ne({},r),{},Y({},e,{}))))}else this.instance.unregister(kr)}}]),t}();Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return cr(t)&&isFinite(t)&&Math.floor(t)===t});var nd="0123456789abcdef",z0=function(){function t(e){if(Oe(this,t),this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}return Re(t,[{key:"toString",value:function(){for(var e="",r=0;r<this.bytes.length;r++)e=e+nd.charAt(this.bytes[r]>>>4)+nd.charAt(15&this.bytes[r]),r!==3&&r!==5&&r!==7&&r!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}},{key:"clone",value:function(){return new t(this.bytes.slice(0))}},{key:"equals",value:function(e){return this.compareTo(e)===0}},{key:"compareTo",value:function(e){for(var r=0;r<16;r++){var i=this.bytes[r]-e.bytes[r];if(i!==0)return Math.sign(i)}return 0}}],[{key:"fromFieldsV7",value:function(e,r,i,n){if(!Number.isInteger(e)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||e<0||r<0||i<0||n<0||e>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|r>>>8,s[7]=r,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=n>>>24,s[13]=n>>>16,s[14]=n>>>8,s[15]=n,new t(s)}}]),t}(),j0=function(){function t(){Oe(this,t),Y(this,"timestamp",0),Y(this,"counter",0),Y(this,"random",new G0)}return Re(t,[{key:"generate",value:function(){var e=this.generateOrAbort();if(ve(e)){this.timestamp=0;var r=this.generateOrAbort();if(ve(r))throw new Error("Could not generate UUID after timestamp reset");return r}return e}},{key:"generateOrAbort",value:function(){var e=Date.now();if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return z0.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}},{key:"resetCounter",value:function(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}]),t}(),Id=function(t){if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<t.length;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};O&&!ve(O.crypto)&&crypto.getRandomValues&&(Id=function(t){return crypto.getRandomValues(t)});var sd,G0=function(){function t(){Oe(this,t),Y(this,"buffer",new Uint32Array(8)),Y(this,"cursor",1/0)}return Re(t,[{key:"nextUint32",value:function(){return this.cursor>=this.buffer.length&&(Id(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}]),t}(),ni=function(){return H0().toString()},H0=function(){return(sd||(sd=new j0)).generate()},q0="Thu, 01 Jan 1970 00:00:00 GMT",Nn="",U0=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,W0=function(t){var e=t.match(U0);return e?e[0]:""};function Z0(t,e){if(e){var r=function(n){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:K;if(Nn)return Nn;if(!s||["localhost","127.0.0.1"].includes(n))return"";for(var a=n.split("."),o=Math.min(a.length,8),l="dmn_chk_"+ni(),h=new RegExp("(^|;)\\s*"+l+"=1");!Nn&&o--;){var c=a.slice(o).join("."),u=l+"=1;domain=."+c;s.cookie=u,h.test(s.cookie)&&(s.cookie=u+";expires="+q0,Nn=c)}return Nn}(t);if(!r){var i=W0(t);i!==r&&j.info("Warning: cookie subdomain discovery mismatch",i,r),r=i}return r?"; domain=."+r:""}return""}var Jt={is_supported:function(){return!!K},error:function(t){j.error("cookieStore error: "+t)},get:function(t){if(K){try{for(var e=t+"=",r=K.cookie.split(";").filter(function(s){return s.length}),i=0;i<r.length;i++){for(var n=r[i];n.charAt(0)==" ";)n=n.substring(1,n.length);if(n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length,n.length))}}catch{}return null}},parse:function(t){var e;try{e=JSON.parse(Jt.get(t))||{}}catch{}return e},set:function(t,e,r,i,n){if(K)try{var s="",a="",o=Z0(K.location.hostname,i);if(r){var l=new Date;l.setTime(l.getTime()+24*r*60*60*1e3),s="; expires="+l.toUTCString()}n&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+o+a;return h.length>3686.4&&j.warn("cookieStore warning: large cookie, len="+h.length),K.cookie=h,h}catch{return}},remove:function(t,e){try{Jt.set(t,"",-1,e)}catch{return}}},jl=null,Le={is_supported:function(){if(!Ft(jl))return jl;var t=!0;if(ve(O))t=!1;else try{var e="__mplssupport__";Le.set(e,"xyz"),Le.get(e)!=='"xyz"'&&(t=!1),Le.remove(e)}catch{t=!1}return t||j.error("localStorage unsupported; falling back to cookie store"),jl=t,t},error:function(t){j.error("localStorage error: "+t)},get:function(t){try{return O?.localStorage.getItem(t)}catch(e){Le.error(e)}return null},parse:function(t){try{return JSON.parse(Le.get(t))||{}}catch{}return null},set:function(t,e){try{O?.localStorage.setItem(t,JSON.stringify(e))}catch(r){Le.error(r)}},remove:function(t){try{O?.localStorage.removeItem(t)}catch(e){Le.error(e)}}},Y0=["distinct_id",Ua,Va],Hn=ne(ne({},Le),{},{parse:function(t){try{var e={};try{e=Jt.parse(t)||{}}catch{}var r=Ye(e,JSON.parse(Le.get(t)||"{}"));return Le.set(t,r),r}catch{}return null},set:function(t,e,r,i,n){try{Le.set(t,e);var s={};Y0.forEach(function(a){e[a]&&(s[a]=e[a])}),Object.keys(s).length&&Jt.set(t,s,r,i,n)}catch(a){Le.error(a)}},remove:function(t,e){try{O?.localStorage.removeItem(t),Jt.remove(t,e)}catch(r){Le.error(r)}}}),Da={},J0={is_supported:function(){return!0},error:function(t){j.error("memoryStorage error: "+t)},get:function(t){return Da[t]||null},parse:function(t){return Da[t]||null},set:function(t,e){Da[t]=e},remove:function(t){delete Da[t]}},ri=null,Xe={is_supported:function(){if(!Ft(ri))return ri;if(ri=!0,ve(O))ri=!1;else try{var t="__support__";Xe.set(t,"xyz"),Xe.get(t)!=='"xyz"'&&(ri=!1),Xe.remove(t)}catch{ri=!1}return ri},error:function(t){j.error("sessionStorage error: ",t)},get:function(t){try{return O?.sessionStorage.getItem(t)}catch(e){Xe.error(e)}return null},parse:function(t){try{return JSON.parse(Xe.get(t))||null}catch{}return null},set:function(t,e){try{O?.sessionStorage.setItem(t,JSON.stringify(e))}catch(r){Xe.error(r)}},remove:function(t){try{O?.sessionStorage.removeItem(t)}catch(e){Xe.error(e)}}},X0=["localhost","127.0.0.1"],Md=function(t){var e=K?.createElement("a");return ve(e)?null:(e.href=t,e)},K0=function(t,e){return!!function(r){try{new RegExp(r)}catch{return!1}return!0}(e)&&new RegExp(e).test(t)},ad=function(t,e){for(var r,i=((t.split("#")[0]||"").split("?")[1]||"").split("&"),n=0;n<i.length;n++){var s=i[n].split("=");if(s[0]===e){r=s;break}}if(!We(r)||r.length<2)return"";var a=r[1];try{a=decodeURIComponent(a)}catch{j.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Za=function(t,e){var r=t.match(new RegExp(e+"=([^&]*)"));return r?r[1]:null},He={campaignParams:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gbraid","wbraid","fbclid","msclkid"].concat(t||[]),r={};return Ce(e,function(i){var n=K?ad(K.URL,i):"";n.length&&(r[i]=n)}),r},searchEngine:function(){var t=K?.referrer;return t?t.search("https?://(.*)google.([^/?]*)")===0?"google":t.search("https?://(.*)bing.com")===0?"bing":t.search("https?://(.*)yahoo.com")===0?"yahoo":t.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null},searchInfo:function(){var t=He.searchEngine(),e=t!="yahoo"?"q":"p",r={};if(!Ft(t)){r.$search_engine=t;var i=K?ad(K.referrer,e):"";i.length&&(r.ph_keyword=i)}return r},browser:function(t,e,r){return e=e||"",r||xe(t," OPR/")?xe(t,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":xe(t,"IEMobile")||xe(t,"WPDesktop")?"Internet Explorer Mobile":xe(t,"SamsungBrowser/")?"Samsung Internet":xe(t,"Edge")||xe(t,"Edg/")?"Microsoft Edge":xe(t,"FBIOS")?"Facebook Mobile":xe(t,"Chrome")?"Chrome":xe(t,"CriOS")?"Chrome iOS":xe(t,"UCWEB")||xe(t,"UCBrowser")?"UC Browser":xe(t,"FxiOS")?"Firefox iOS":xe(e,"Apple")||function(i){return xe(i,"Safari")&&!xe(i,"Chrome")&&!xe(i,"Android")}(t)?xe(t,"Mobile")?"Mobile Safari":"Safari":xe(t,"Android")?"Android Mobile":xe(t,"Konqueror")||xe(t,"konqueror")?"Konqueror":xe(t,"Firefox")?"Firefox":xe(t,"MSIE")||xe(t,"Trident/")?"Internet Explorer":xe(t,"Gecko")?"Mozilla":""},browserVersion:function(t,e,r){var i={"Internet Explorer Mobile":[/rv:(\d+(\.\d+)?)/],"Microsoft Edge":[/Edge?\/(\d+(\.\d+)?)/],Chrome:[/Chrome\/(\d+(\.\d+)?)/],"Chrome iOS":[/CriOS\/(\d+(\.\d+)?)/],"UC Browser":[/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/],Safari:[/Version\/(\d+(\.\d+)?)/],"Mobile Safari":[/Version\/(\d+(\.\d+)?)/],Opera:[/(Opera|OPR)\/(\d+(\.\d+)?)/],Firefox:[/Firefox\/(\d+(\.\d+)?)/],"Firefox iOS":[/FxiOS\/(\d+(\.\d+)?)/],Konqueror:[/Konqueror[:/]?(\d+(\.\d+)?)/i],BlackBerry:[/BlackBerry (\d+(\.\d+)?)/,/Version\/(\d+(\.\d+)?)/],"Android Mobile":[/android\s(\d+(\.\d+)?)/],"Samsung Internet":[/SamsungBrowser\/(\d+(\.\d+)?)/],"Internet Explorer":[/(rv:|MSIE )(\d+(\.\d+)?)/],Mozilla:[/rv:(\d+(\.\d+)?)/]}[He.browser(t,e,r)];if(ve(i))return null;for(var n=0;n<i.length;n++){var s=i[n],a=t.match(s);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},os:function(t){if(/Windows/i.test(t)){if(/Phone/.test(t)||/WPDesktop/.test(t))return{os_name:"Windows Phone",os_version:""};var e=/Windows NT ([0-9.]+)/i.exec(t);return e&&e[1]?{os_name:"Windows",os_version:e[1]}:{os_name:"Windows",os_version:""}}if(/(iPhone|iPad|iPod)/.test(t)){var r=/OS (\d+)_(\d+)_?(\d+)?/i.exec(t);return r&&r[1]?{os_name:"iOS",os_version:[r[1],r[2],r[3]||"0"].join(".")}:{os_name:"iOS",os_version:""}}if(/Android/.test(t)){var i=/Android (\d+)\.(\d+)\.?(\d+)?/i.exec(t);return i&&i[1]?{os_name:"Android",os_version:[i[1],i[2],i[3]||"0"].join(".")}:{os_name:"Android",os_version:""}}if(/(BlackBerry|PlayBook|BB10)/i.test(t))return{os_name:"BlackBerry",os_version:""};if(/Mac/i.test(t)){var n=/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i.exec(t);return n&&n[1]?{os_name:"Mac OS X",os_version:[n[1],n[2],n[3]||"0"].join(".")}:{os_name:"Mac OS X",os_version:""}}return/Linux/.test(t)?{os_name:"Linux",os_version:""}:/CrOS/.test(t)?{os_name:"Chrome OS",os_version:""}:{os_name:"",os_version:""}},device:function(t){return/Windows Phone/i.test(t)||/WPDesktop/.test(t)?"Windows Phone":/iPad/.test(t)?"iPad":/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":/Android/.test(t)&&!/Mobile/.test(t)?"Android Tablet":/Android/.test(t)?"Android":""},deviceType:function(t){var e=this.device(t);return e==="iPad"||e==="Android Tablet"?"Tablet":e?"Mobile":"Desktop"},referrer:function(){return K?.referrer||"$direct"},referringDomain:function(){var t;return K!=null&&K.referrer&&((t=Md(K.referrer))===null||t===void 0?void 0:t.host)||"$direct"},properties:function(){if(!Ge)return{};var t=He.os(Ge),e=t.os_name,r=t.os_version;return Ye(Yl({$os:e,$os_version:r,$browser:He.browser(Ge,navigator.vendor,tt.opera),$device:He.device(Ge),$device_type:He.deviceType(Ge)}),{$current_url:O?.location.href,$host:O?.location.host,$pathname:O?.location.pathname,$raw_user_agent:Ge.length>1e3?Ge.substring(0,997)+"...":Ge,$browser_version:He.browserVersion(Ge,navigator.vendor,tt.opera),$browser_language:He.browserLanguage(),$screen_height:O?.screen.height,$screen_width:O?.screen.width,$viewport_height:O?.innerHeight,$viewport_width:O?.innerWidth,$lib:"web",$lib_version:oi.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:kd()/1e3})},people_properties:function(){if(!Ge)return{};var t=He.os(Ge),e=t.os_name,r=t.os_version;return Ye(Yl({$os:e,$os_version:r,$browser:He.browser(Ge,navigator.vendor,tt.opera)}),{$browser_version:He.browserVersion(Ge,navigator.vendor,tt.opera)})}},Q0=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],od=function(){function t(e){Oe(this,t);var r="";e.token&&(r=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),this.props={},this.campaign_params_saved=!1,this.custom_campaign_params=e.custom_campaign_params||[],e.persistence_name?this.name="ph_"+e.persistence_name:this.name="ph_"+r+"_posthog",Q0.indexOf(e.persistence.toLowerCase())===-1&&(j.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i=e.persistence.toLowerCase();i==="localstorage"&&Le.is_supported()?this.storage=Le:i==="localstorage+cookie"&&Hn.is_supported()?this.storage=Hn:i==="sessionstorage"&&Xe.is_supported()?this.storage=Xe:i==="memory"?this.storage=J0:i==="cookie"?this.storage=Jt:Hn.is_supported()?this.storage=Hn:this.storage=Jt,this.user_state="anonymous",this.load(),this.update_config(e),this.save()}return Re(t,[{key:"properties",value:function(){var e={};return Ce(this.props,function(r,i){if(i===Zi&&Pr(r))for(var n=Object.keys(r),s=0;s<n.length;s++)e["$feature/".concat(n[s])]=r[n[s]];else o=i,l=!1,(Ft(a=V0)?l:Hp&&a.indexOf===Hp?a.indexOf(o)!=-1:(Ce(a,function(h){if(l||(l=h===o))return lh}),l))||(e[i]=r);var a,o,l}),e}},{key:"load",value:function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=Ye({},e))}}},{key:"save",value:function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure)}},{key:"remove",value:function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}},{key:"clear",value:function(){this.remove(),this.props={}}},{key:"register_once",value:function(e,r,i){var n=this;if(Pr(e)){ve(r)&&(r="None"),this.expire_days=ve(i)?this.default_expiry:i;var s=!1;if(Ce(e,function(a,o){n.props.hasOwnProperty(o)&&n.props[o]!==r||(n.props[o]=a,s=!0)}),s)return this.save(),!0}return!1}},{key:"register",value:function(e,r){var i=this;if(Pr(e)){this.expire_days=ve(r)?this.default_expiry:r;var n=!1;if(Ce(e,function(s,a){e.hasOwnProperty(a)&&i.props[a]!==s&&(i.props[a]=s,n=!0)}),n)return this.save(),!0}return!1}},{key:"unregister",value:function(e){e in this.props&&(delete this.props[e],this.save())}},{key:"update_campaign_params",value:function(){this.campaign_params_saved||(this.register(He.campaignParams(this.custom_campaign_params)),this.campaign_params_saved=!0)}},{key:"update_search_keyword",value:function(){this.register(He.searchInfo())}},{key:"update_referrer_info",value:function(){this.register({$referrer:this.props.$referrer||He.referrer(),$referring_domain:this.props.$referring_domain||He.referringDomain()})}},{key:"get_referrer_info",value:function(){return Yl({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}},{key:"safe_merge",value:function(e){return Ce(this.props,function(r,i){i in e||(e[i]=r)}),e}},{key:"update_config",value:function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)}},{key:"set_disabled",value:function(e){this.disabled=e,this.disabled?this.remove():this.save()}},{key:"set_cross_subdomain",value:function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())}},{key:"get_cross_subdomain",value:function(){return!!this.cross_subdomain}},{key:"set_secure",value:function(e){e!==this.secure&&(this.secure=e,this.remove(),this.save())}},{key:"set_event_timer",value:function(e,r){var i=this.props[Gn]||{};i[e]=r,this.props[Gn]=i,this.save()}},{key:"remove_event_timer",value:function(e){var r=(this.props[Gn]||{})[e];return ve(r)||(delete this.props[Gn][e],this.save()),r}},{key:"get_user_state",value:function(){return this.props[Ql]||"anonymous"}},{key:"set_user_state",value:function(e){this.props[Ql]=e,this.save()}},{key:"get_quota_limits",value:function(){return this.props[eh]||{}}},{key:"set_quota_limits",value:function(e){this.props[eh]=e,this.save()}}]),t}(),ld=2,ey=4,Dd=3,ty=6,ry=0,iy="rrweb/console@1",ny=Re(function t(e){var r,i,n=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Oe(this,t),Y(this,"bucketSize",100),Y(this,"refillRate",10),Y(this,"mutationBuckets",{}),Y(this,"loggedTracker",{}),Y(this,"refillBuckets",function(){Object.keys(n.mutationBuckets).forEach(function(a){n.mutationBuckets[a]=n.mutationBuckets[a]+n.refillRate,n.mutationBuckets[a]>=n.bucketSize&&delete n.mutationBuckets[a]})}),Y(this,"getNodeOrRelevantParent",function(a){var o=n.rrweb.mirror.getNode(a);if(o?.nodeName!=="svg"&&o instanceof Element){var l=o.closest("svg");if(l)return[n.rrweb.mirror.getId(l),l]}return[a,o]}),Y(this,"numberOfChanges",function(a){var o,l,h,c,u,f,p,m;return((o=(l=a.removes)===null||l===void 0?void 0:l.length)!==null&&o!==void 0?o:0)+((h=(c=a.attributes)===null||c===void 0?void 0:c.length)!==null&&h!==void 0?h:0)+((u=(f=a.texts)===null||f===void 0?void 0:f.length)!==null&&u!==void 0?u:0)+((p=(m=a.adds)===null||m===void 0?void 0:m.length)!==null&&p!==void 0?p:0)}),Y(this,"throttleMutations",function(a){if(a.type!==Dd||a.data.source!==ry)return a;var o=a.data,l=n.numberOfChanges(o);o.attributes&&(o.attributes=o.attributes.filter(function(c){var u,f,p,m=zt(n.getNodeOrRelevantParent(c.id),2),g=m[0],d=m[1];return n.mutationBuckets[g]===0?!1:(n.mutationBuckets[g]=(u=n.mutationBuckets[g])!==null&&u!==void 0?u:n.bucketSize,n.mutationBuckets[g]=Math.max(n.mutationBuckets[g]-1,0),n.mutationBuckets[g]===0&&(n.loggedTracker[g]||(n.loggedTracker[g]=!0,(f=(p=n.options).onBlockedNode)===null||f===void 0||f.call(p,g,d))),c)}));var h=n.numberOfChanges(o);return h!==0||l===h?a:void 0}),this.rrweb=e,this.options=s,this.refillRate=(r=this.options.refillRate)!==null&&r!==void 0?r:this.refillRate,this.bucketSize=(i=this.options.bucketSize)!==null&&i!==void 0?i:this.bucketSize,setInterval(function(){n.refillBuckets()},1e3)}),Fd=function(t){return t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t}(Fd||{}),sy={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:function(t){return t},recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6},ay=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],oy=["/s/","/e/","/i/vo/e/"];function hd(t,e,r,i){var n=e?.["content-length"];return n&&parseInt(n)>r?"".concat(i," body too large to record"):t}var Yt,ly=function(t,e){var r,i,n,s=t.session_recording,a=s.recordHeaders!==!1&&e.recordHeaders,o=s.recordBody!==!1&&e.recordBody,l=s.recordPerformance!==!1&&e.recordPerformance,h=(r=s,n=Math.min(1e6,(i=r.payloadSizeLimitBytes)!==null&&i!==void 0?i:1e6),function(f){return f!=null&&f.requestBody&&(f.requestBody=hd(f.requestBody,f.requestHeaders,n,"Request")),f!=null&&f.responseBody&&(f.responseBody=hd(f.responseBody,f.responseHeaders,n,"Response")),f}),c=function(f){return h(function(g){var d=Md(g.name);if(!(d&&d.pathname&&oy.includes(d.pathname)))return g}((p=f,Object.keys((m=p.requestHeaders)!==null&&m!==void 0?m:{}).forEach(function(g){var d;ay.includes(g.toLowerCase())&&((d=p.requestHeaders)===null||d===void 0||delete d[g])}),p)));var p,m},u=jt(t.session_recording.maskNetworkRequestFn);return u&&jt(t.session_recording.maskCapturedNetworkRequestFn)&&j.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),u&&(t.session_recording.maskCapturedNetworkRequestFn=function(f){var p=t.session_recording.maskNetworkRequestFn({url:f.name});return ne(ne({},f),{},{name:p?.url})}),s.maskRequestFn=jt(t.session_recording.maskCapturedNetworkRequestFn)?function(f){var p,m,g,d=c(f);return d&&(p=(m=(g=t.session_recording).maskCapturedNetworkRequestFn)===null||m===void 0?void 0:m.call(g,d))!==null&&p!==void 0?p:void 0}:void 0,s.maskRequestFn||(s.maskRequestFn=c),ne(ne(ne({},sy),s),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})},hy="/s/",cd=3e5;(function(t){t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet"})(Yt||(Yt={}));var cy=[Yt.MouseMove,Yt.MouseInteraction,Yt.Scroll,Yt.ViewportResize,Yt.Input,Yt.TouchMove,Yt.MediaInteraction,Yt.Drag],uy=function(){function t(e){var r=this;if(Oe(this,t),Y(this,"isIdle",!1),Y(this,"_linkedFlagSeen",!1),Y(this,"_lastActivityTimestamp",Date.now()),Y(this,"windowId",null),Y(this,"sessionId",null),Y(this,"_linkedFlag",null),Y(this,"_sampleRate",null),Y(this,"_minimumDuration",null),Y(this,"_forceAllowLocalhostNetworkCapture",!1),this.instance=e,this._captureStarted=!1,this._endpoint=hy,this.stopRrweb=void 0,this.receivedDecide=!1,O?.addEventListener("beforeunload",function(){r._flushBuffer()}),!this.instance.sessionManager)throw j.error("Session recording started without valid sessionManager"),new Error("Session recording started without valid sessionManager. This is a bug.");this.buffer=this.clearBuffer()}return Re(t,[{key:"started",get:function(){return this._captureStarted}},{key:"sessionManager",get:function(){if(!this.instance.sessionManager)throw j.error("Session recording started without valid sessionManager"),new Error("Session recording started without valid sessionManager. This is a bug.");return this.instance.sessionManager}},{key:"isSampled",get:function(){return cr(this._sampleRate)?this.instance.get_property(Va):null}},{key:"sessionDuration",get:function(){var e,r,i=(e=this.buffer)===null||e===void 0?void 0:e.data[((r=this.buffer)===null||r===void 0?void 0:r.data.length)-1],n=this.sessionManager.checkAndGetSessionAndWindowId(!0).sessionStartTimestamp;return i?i.timestamp-n:null}},{key:"isRecordingEnabled",get:function(){var e=!!this.instance.get_property(Jl),r=!this.instance.config.disable_session_recording;return O&&e&&r}},{key:"isConsoleLogCaptureEnabled",get:function(){var e=!!this.instance.get_property(Qp),r=this.instance.config.enable_recording_console_log;return r??e}},{key:"recordingVersion",get:function(){var e,r=this.instance.get_property(ed);return((e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recorderVersion)||r||"v1"}},{key:"networkPayloadCapture",get:function(){var e,r,i=this.instance.get_property(td),n={recordHeaders:(e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recordHeaders,recordBody:(r=this.instance.config.session_recording)===null||r===void 0?void 0:r.recordBody},s=n?.recordHeaders||i?.recordHeaders,a=n?.recordBody||i?.recordBody,o=this.instance.config.capture_performance||i?.capturePerformance;return s||a||o?{recordHeaders:s,recordBody:a,recordPerformance:o}:void 0}},{key:"status",get:function(){return this.receivedDecide?this.isRecordingEnabled?St(this._linkedFlag)&&!this._linkedFlagSeen?"buffering":Zl(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"disabled":"buffering"}},{key:"startRecordingIfEnabled",value:function(){this.isRecordingEnabled?this.startCaptureAndTrySendingQueuedSnapshots():(this.stopRecording(),this.clearBuffer())}},{key:"stopRecording",value:function(){this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1)}},{key:"makeSamplingDecision",value:function(e){var r,i=this.sessionId!==e;if(cr(this._sampleRate)){var n,s=this.isSampled;i||!Zl(s)?n=Math.random()<this._sampleRate:n=s,n||j.warn("[SessionSampling] Sample rate (".concat(this._sampleRate,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),(r=this.instance.persistence)===null||r===void 0||r.register(Y({},Va,n))}else{var a;(a=this.instance.persistence)===null||a===void 0||a.register(Y({},Va,null))}}},{key:"afterDecideResponse",value:function(e){var r,i,n,s,a,o,l,h,c=this;this.instance.persistence&&this.instance.persistence.register((Y(h={},Jl,!!e.sessionRecording),Y(h,Qp,(a=e.sessionRecording)===null||a===void 0?void 0:a.consoleLogRecordingEnabled),Y(h,ed,(o=e.sessionRecording)===null||o===void 0?void 0:o.recorderVersion),Y(h,td,ne({capturePerformance:e.capturePerformance},(l=e.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture)),h));var u=(r=e.sessionRecording)===null||r===void 0?void 0:r.sampleRate;this._sampleRate=ve(u)||Ft(u)?null:parseFloat(u);var f,p=(i=e.sessionRecording)===null||i===void 0?void 0:i.minimumDurationMilliseconds;if(this._minimumDuration=ve(p)?null:p,this._linkedFlag=((n=e.sessionRecording)===null||n===void 0?void 0:n.linkedFlag)||null,(s=e.sessionRecording)!==null&&s!==void 0&&s.endpoint&&(this._endpoint=(f=e.sessionRecording)===null||f===void 0?void 0:f.endpoint),cr(this._sampleRate)&&this.sessionManager.onSessionId(function(g){c.makeSamplingDecision(g)}),St(this._linkedFlag)){var m=this._linkedFlag;this.instance.onFeatureFlags(function(g){c._linkedFlagSeen=g.includes(m)})}this.receivedDecide=!0,this.startRecordingIfEnabled()}},{key:"log",value:function(e){var r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(r=this.instance.sessionRecording)===null||r===void 0||r.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:kd()})}},{key:"startCaptureAndTrySendingQueuedSnapshots",value:function(){this._startCapture()}},{key:"_startCapture",value:function(){var e=this;if(!ve(Object.assign)&&!this._captureStarted&&!this.instance.config.disable_session_recording){this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId();var r=this.recordingVersion==="v2"?"recorder-v2.js":"recorder.js";this.instance.__loaded_recorder_version!==this.recordingVersion?Un(this.instance.config.api_host+"/static/".concat(r,"?v=").concat(oi.LIB_VERSION),function(i){if(i)return j.error("Could not load ".concat(r),i);e._onScriptLoaded()}):this._onScriptLoaded()}}},{key:"_isInteractiveEvent",value:function(e){var r;return e.type===Dd&&cy.indexOf((r=e.data)===null||r===void 0?void 0:r.source)!==-1}},{key:"_updateWindowAndSessionIds",value:function(e){var r=this._isInteractiveEvent(e);if(r||this.isIdle||e.timestamp-this._lastActivityTimestamp>cd&&(this.isIdle=!0,this._tryAddCustomEvent("sessionIdle",{reason:"user inactivity",timeSinceLastActive:e.timestamp-this._lastActivityTimestamp,threshold:cd})),r&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),this._tryTakeFullSnapshot())),!this.isIdle){var i=this.sessionManager.checkAndGetSessionAndWindowId(!r,e.timestamp),n=i.windowId,s=i.sessionId,a=this.sessionId!==s,o=this.windowId!==n;[ld,ey].indexOf(e.type)===-1&&(o||a)&&this._tryTakeFullSnapshot(),this.windowId=n,this.sessionId=s}}},{key:"_tryRRwebMethod",value:function(e){if(!this._captureStarted)return!1;try{return e(),!0}catch(r){return j.error("[Session-Recording] using rrweb when not started.",r),!1}}},{key:"_tryAddCustomEvent",value:function(e,r){var i=this;return this._tryRRwebMethod(function(){var n;return(n=i.rrwebRecord)===null||n===void 0?void 0:n.addCustomEvent(e,r)})}},{key:"_tryTakeFullSnapshot",value:function(){var e=this;return this._tryRRwebMethod(function(){var r;return(r=e.rrwebRecord)===null||r===void 0?void 0:r.takeFullSnapshot()})}},{key:"_onScriptLoaded",value:function(){var e,r=this,i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1};this.rrwebRecord=O.rrweb?O.rrweb.record:O.rrwebRecord;for(var n=this.instance.config.session_recording,s=0,a=Object.entries(n||{});s<a.length;s++){var o=zt(a[s],2),l=o[0],h=o[1];l in i&&(i[l]=h)}this.rrwebRecord?(this.mutationRateLimiter=(e=this.mutationRateLimiter)!==null&&e!==void 0?e:new ny(this.rrwebRecord,{onBlockedNode:function(c,u){var f="Too many mutations on node '".concat(c,"'. Rate limiting. This could be due to SVG animations or something similar");j.info(f,{node:u}),r.log("[PostHog Recorder] "+f,"warn")}}),this.stopRrweb=this.rrwebRecord(ne({emit:function(c){r.onRRwebEmit(c)},plugins:this._gatherRRWebPlugins()},i)),this.instance._addCaptureHook(function(c){try{if(c==="$pageview"){var u=O?r._maskUrl(O.location.href):"";if(!u)return;r._tryAddCustomEvent("$pageview",{href:u})}}catch(f){j.error("Could not add $pageview to rrweb session",f)}}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1):j.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}},{key:"_gatherRRWebPlugins",value:function(){var e=[];return tt.rrwebConsoleRecord&&this.isConsoleLogCaptureEnabled&&e.push(tt.rrwebConsoleRecord.getRecordConsolePlugin()),this.networkPayloadCapture&&jt(tt.getRecordNetworkPlugin)&&(!X0.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?e.push(tt.getRecordNetworkPlugin(ly(this.instance.config,this.networkPayloadCapture))):j.info("[SessionReplay-NetworkCapture] not started because we are on localhost.")),e}},{key:"onRRwebEmit",value:function(e){if(e&&Pr(e)){if(e.type===Fd.Meta){var r=this._maskUrl(e.data.href);if(!r)return;e.data.href=r}var i=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(i){var n=function(o){var l=o;if(l&&Pr(l)&&l.type===ty&&Pr(l.data)&&l.data.plugin===iy){l.data.payload.payload.length>10&&(l.data.payload.payload=l.data.payload.payload.slice(0,10),l.data.payload.payload.push("...[truncated]"));for(var h=[],c=0;c<l.data.payload.payload.length;c++)l.data.payload.payload[c]&&l.data.payload.payload[c].length>2e3?h.push(l.data.payload.payload[c].slice(0,2e3)+"...[truncated]"):h.push(l.data.payload.payload[c]);return l.data.payload.payload=h,o}return o}(i),s=JSON.stringify(n).length;if(this._updateWindowAndSessionIds(n),!this.isIdle){var a={$snapshot_bytes:s,$snapshot_data:n,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(a):this.clearBuffer()}}}}},{key:"_maskUrl",value:function(e){var r=this.instance.config.session_recording;if(r.maskNetworkRequestFn){var i,n={url:e};return(i=n=r.maskNetworkRequestFn(n))===null||i===void 0?void 0:i.url}return e}},{key:"clearBuffer",value:function(){return this.buffer=void 0,{size:0,data:[],sessionId:this.sessionId,windowId:this.windowId}}},{key:"_flushBuffer",value:function(){var e=this;this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var r=this._minimumDuration,i=this.sessionDuration,n=cr(i)&&i>=0,s=cr(r)&&n&&i<r;return this.status==="buffering"||s?(this.flushBufferTimer=setTimeout(function(){e._flushBuffer()},2e3),this.buffer||this.clearBuffer()):this.buffer&&this.buffer.data.length!==0?(this._captureSnapshot({$snapshot_bytes:this.buffer.size,$snapshot_data:this.buffer.data,$session_id:this.buffer.sessionId,$window_id:this.buffer.windowId}),this.clearBuffer()):this.buffer||this.clearBuffer()}},{key:"_captureSnapshotBuffered",value:function(e){var r,i=this,n=2+(((r=this.buffer)===null||r===void 0?void 0:r.data.length)||0);(!this.buffer||this.buffer.size+e.$snapshot_bytes+n>943718.4||this.buffer.sessionId&&this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),Ft(this.buffer.sessionId)&&!Ft(this.sessionId)&&(this.buffer.sessionId=this.sessionId,this.buffer.windowId=this.windowId),this.buffer.size+=e.$snapshot_bytes,this.buffer.data.push(e.$snapshot_data),this.flushBufferTimer||(this.flushBufferTimer=setTimeout(function(){i._flushBuffer()},2e3))}},{key:"_captureSnapshot",value:function(e){this.instance.capture("$snapshot",e,{transport:"XHR",method:"POST",endpoint:this._endpoint,_noTruncate:!0,_batchKey:"recordings",_metrics:{rrweb_full_snapshot:e.$snapshot_data.type===ld}})}}]),t}(),py=function(){function t(e){Oe(this,t),this.instance=e,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}return Re(t,[{key:"call",value:function(){var e=this,r=hh(JSON.stringify({token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(Yi),group_properties:this.instance.get_property(kr),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0}));this.instance._send_request("".concat(this.instance.config.api_host,"/decide/?v=3"),{data:r,verbose:!0},{method:"POST"},function(i){return e.parseDecideResponse(i)})}},{key:"parseDecideResponse",value:function(e){var r,i=this;if(this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer(),e?.status!==0){if(!K||!K.body)return j.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){i.parseDecideResponse(e)},500);this.instance.toolbar.afterDecideResponse(e),(r=this.instance.sessionRecording)===null||r===void 0||r.afterDecideResponse(e),Er.afterDecideResponse(e,this.instance),this.instance._afterDecideResponse(e),this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(e);var n=O?.extendPostHogWithSurveys;e.surveys&&!n&&Un(this.instance.config.api_host+"/static/surveys.js",function(c){if(c)return j.error("Could not load surveys script",c);O.extendPostHogWithSurveys(i.instance)});var s=O?.extendPostHogWithExceptionAutoCapture;if(e.autocaptureExceptions&&e.autocaptureExceptions&&ve(s)&&Un(this.instance.config.api_host+"/static/exception-autocapture.js",function(c){if(c)return j.error("Could not load exception autocapture script",c);O.extendPostHogWithExceptionAutocapture(i.instance,e)}),e.siteApps)if(this.instance.config.opt_in_site_apps){var a,o=this.instance.config.api_host,l=ai(e.siteApps);try{var h=function(){var c=a.value,u=c.id,f=c.url,p=[o,o[o.length-1]==="/"&&f[0]==="/"?f.substring(1):f].join("");tt["__$$ph_site_app_".concat(u)]=i.instance,Un(p,function(m){m&&j.error("Error while initializing PostHog app with config id ".concat(u),m)})};for(l.s();!(a=l.n()).done;)h()}catch(c){l.e(c)}finally{l.f()}}else e.siteApps.length>0&&j.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}else j.error("Failed to fetch feature flags from PostHog.")}}]),t}(),dy=["https://app.posthog.com","https://eu.posthog.com"],fy=["source"],my=O!=null&&O.location?Za(O.location.hash,"__posthog")||Za(location.hash,"state"):null,gy=function(){function t(e){Oe(this,t),this.instance=e}return Re(t,[{key:"afterDecideResponse",value:function(e){var r=e.toolbarParams||e.editorParams||(e.toolbarVersion?{toolbarVersion:e.toolbarVersion}:{});e.isAuthenticated&&r.toolbarVersion&&r.toolbarVersion.indexOf("toolbar")===0&&this.loadToolbar(ne({},r))}},{key:"maybeLoadToolbar",value:function(){var e,r,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!O||!K)return!1;i=(e=i)!==null&&e!==void 0?e:O.location,s=(r=s)!==null&&r!==void 0?r:O.history;try{if(!n){try{O.localStorage.setItem("test","test"),O.localStorage.removeItem("test")}catch{return!1}n=O?.localStorage}var a,o=my||Za(i.hash,"__posthog")||Za(i.hash,"state"),l=o?Wp(function(){return JSON.parse(atob(decodeURIComponent(o)))})||Wp(function(){return JSON.parse(decodeURIComponent(o))}):null;return l&&l.action==="ph_authorize"?((a=l).source="url",a&&Object.keys(a).length>0&&(l.desiredHash?i.hash=l.desiredHash:s?s.replaceState("",K.title,i.pathname+i.search):i.hash="")):((a=JSON.parse(n.getItem("_postHogToolbarParams")||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}},{key:"loadToolbar",value:function(e){var r=this;if(!O||tt._postHogToolbarLoaded)return!1;tt._postHogToolbarLoaded=!0;var i=this.instance.config.api_host,n=3e5,s=Math.floor(Date.now()/n)*n,a="".concat(i).concat(i.endsWith("/")?"":"/","static/toolbar.js?t=").concat(s),o=!dy.includes(this.instance.config.api_host)&&this.instance.config.advanced_disable_toolbar_metrics,l=ne(ne({token:this.instance.config.token},e),{},{apiURL:i},o?{instrument:!1}:{});l.source;var h=T0(l,fy);return O.localStorage.setItem("_postHogToolbarParams",JSON.stringify(h)),Un(a,function(c){c?j.error("Failed to load toolbar",c):(tt.ph_load_toolbar||tt.ph_load_editor)(l,r.instance)}),qn(O,"turbolinks:load",function(){tt._postHogToolbarLoaded=!1,r.loadToolbar(l)}),!0}},{key:"_loadEditor",value:function(e){return this.loadToolbar(e)}},{key:"maybeLoadEditor",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(e,r,i)}}]),t}(),yy="__ph_opt_in_out_";function vy(t,e){Od(!0,t,e)}function by(t,e){Od(!1,t,e)}function _y(t,e){return $d(t,e)==="1"}function ud(t,e){return!!function(r){if(r&&r.respectDnt){var i=r&&r.window||O,n=i?.navigator,s=!1;return Ce([n?.doNotTrack,n.msDoNotTrack,i.doNotTrack],function(a){xe([!0,1,"1","yes"],a)&&(s=!0)}),s}return!1}(e)||$d(t,e)==="0"}function wy(t,e){uh(e=e||{}).remove(ph(t,e),!!e.crossSubdomainCookie)}function uh(t){return(t=t||{}).persistenceType==="localStorage"?Le:t.persistenceType==="localStorage+cookie"?Hn:Jt}function ph(t,e){return((e=e||{}).persistencePrefix||yy)+t}function $d(t,e){return uh(e).get(ph(t,e))}function Od(t,e,r){St(e)&&e.length?(uh(r=r||{}).set(ph(e,r),t?1:0,cr(r.cookieExpiration)?r.cookieExpiration:null,r.crossSubdomainCookie,r.secureCookie),r.capture&&t&&r.capture(r.captureEventName||"$opt_in",r.captureProperties||{},{send_instantly:!0})):j.error("gdpr."+(t?"optIn":"optOut")+" called with an invalid token")}var Rd=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:3e3;Oe(this,t),this.isPolling=!0,this._event_queue=[],this._empty_queue_count=0,this._poller=void 0,this._pollInterval=e}return Re(t,[{key:"setPollInterval",value:function(e){this._pollInterval=e,this.isPolling&&this.poll()}},{key:"poll",value:function(){}},{key:"unload",value:function(){}},{key:"getTime",value:function(){return new Date().getTime()}}]),t}(),xy=function(t){bd(r,Rd);var e=_d(r);function r(i){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3e3;return Oe(this,r),(n=e.call(this,s)).handlePollRequest=i,n}return Re(r,[{key:"enqueue",value:function(i,n,s){this._event_queue.push({url:i,data:n,options:s}),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var i=this;clearTimeout(this._poller),this._poller=setTimeout(function(){if(i._event_queue.length>0){var n=i.formatQueue(),s=function(o){var l=n[o],h=l.url,c=l.data,u=l.options;Ce(c,function(f,p){c[p].offset=Math.abs(c[p].timestamp-i.getTime()),delete c[p].timestamp}),i.handlePollRequest(h,c,u)};for(var a in n)s(a);i._event_queue.length=0,i._empty_queue_count=0}else i._empty_queue_count++;i._empty_queue_count>4&&(i.isPolling=!1,i._empty_queue_count=0),i.isPolling&&i.poll()},this._pollInterval)}},{key:"unload",value:function(){var i=this;clearTimeout(this._poller);var n=this._event_queue.length>0?this.formatQueue():{};this._event_queue.length=0;var s=Object.values(n);[].concat(Ul(s.filter(function(a){return a.url.indexOf("/e")===0})),Ul(s.filter(function(a){return a.url.indexOf("/e")!==0}))).map(function(a){var o=a.url,l=a.data,h=a.options;i.handlePollRequest(o,l,ne(ne({},h),{},{transport:"sendBeacon"}))})}},{key:"formatQueue",value:function(){var i={};return Ce(this._event_queue,function(n){var s=n.url,a=n.data,o=n.options,l=(o?o._batchKey:null)||s;ve(i[l])&&(i[l]={data:[],url:s,options:o}),o&&i[l].options&&i[l].options._metrics&&!i[l].options._metrics.rrweb_full_snapshot&&(i[l].options._metrics.rrweb_full_snapshot=o._metrics.rrweb_full_snapshot),i[l].data.push(a)}),i}}]),r}(),kt=Uint8Array,at=Uint16Array,Xi=Uint32Array,dh=new kt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fh=new kt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),pd=new kt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ld=function(t,e){for(var r=new at(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];var n=new Xi(r[30]);for(i=1;i<30;++i)for(var s=r[i];s<r[i+1];++s)n[s]=s-r[i]<<5|i;return[r,n]},Bd=Ld(dh,2),Sy=Bd[0],rh=Bd[1];Sy[28]=258,rh[258]=28;for(ih=Ld(fh,0)[1],Ya=new at(32768),Ie=0;Ie<32768;++Ie)xr=(43690&Ie)>>>1|(21845&Ie)<<1,xr=(61680&(xr=(52428&xr)>>>2|(13107&xr)<<2))>>>4|(3855&xr)<<4,Ya[Ie]=((65280&xr)>>>8|(255&xr)<<8)>>>1;var xr,ih,Ya,Ie,Wn=function(t,e,r){for(var i=t.length,n=0,s=new at(e);n<i;++n)++s[t[n]-1];var a,o=new at(e);for(n=0;n<e;++n)o[n]=o[n-1]+s[n-1]<<1;if(r){a=new at(1<<e);var l=15-e;for(n=0;n<i;++n)if(t[n])for(var h=n<<4|t[n],c=e-t[n],u=o[t[n]-1]++<<c,f=u|(1<<c)-1;u<=f;++u)a[Ya[u]>>>l]=h}else for(a=new at(i),n=0;n<i;++n)a[n]=Ya[o[t[n]-1]++]>>>15-t[n];return a},li=new kt(288);for(Ie=0;Ie<144;++Ie)li[Ie]=8;for(Ie=144;Ie<256;++Ie)li[Ie]=9;for(Ie=256;Ie<280;++Ie)li[Ie]=7;for(Ie=280;Ie<288;++Ie)li[Ie]=8;var Ja=new kt(32);for(Ie=0;Ie<32;++Ie)Ja[Ie]=5;var ii,ky=Wn(li,9,0),Ey=Wn(Ja,5,0),Vd=function(t){return(t/8>>0)+(7&t&&1)},Nd=function(t,e,r){(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length);var i=new(t instanceof at?at:t instanceof Xi?Xi:kt)(r-e);return i.set(t.subarray(e,r)),i},hr=function(t,e,r){r<<=7&e;var i=e/8>>0;t[i]|=r,t[i+1]|=r>>>8},zn=function(t,e,r){r<<=7&e;var i=e/8>>0;t[i]|=r,t[i+1]|=r>>>8,t[i+2]|=r>>>16},Gl=function(t,e){for(var r=[],i=0;i<t.length;++i)t[i]&&r.push({s:i,f:t[i]});var n=r.length,s=r.slice();if(!n)return[new kt(0),0];if(n==1){var a=new kt(r[0].s+1);return a[r[0].s]=1,[a,1]}r.sort(function(S,T){return S.f-T.f}),r.push({s:-1,f:25001});var o=r[0],l=r[1],h=0,c=1,u=2;for(r[0]={s:-1,f:o.f+l.f,l:o,r:l};c!=n-1;)o=r[r[h].f<r[u].f?h++:u++],l=r[h!=c&&r[h].f<r[u].f?h++:u++],r[c++]={s:-1,f:o.f+l.f,l:o,r:l};var f=s[0].s;for(i=1;i<n;++i)s[i].s>f&&(f=s[i].s);var p=new at(f+1),m=Py(r[c-1],p,0);if(m>e){i=0;var g=0,d=m-e,y=1<<d;for(s.sort(function(S,T){return p[T.s]-p[S.s]||S.f-T.f});i<n;++i){var v=s[i].s;if(!(p[v]>e))break;g+=y-(1<<m-p[v]),p[v]=e}for(g>>>=d;g>0;){var b=s[i].s;p[b]<e?g-=1<<e-p[b]++-1:++i}for(;i>=0&&g;--i){var _=s[i].s;p[_]==e&&(--p[_],++g)}m=e}return[new kt(p),m]},Py=function t(e,r,i){return e.s==-1?Math.max(t(e.l,r,i+1),t(e.r,r,i+1)):r[e.s]=i},dd=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new at(++e),i=0,n=t[0],s=1,a=function(l){r[i++]=l},o=1;o<=e;++o)if(t[o]==n&&o!=e)++s;else{if(!n&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(n),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(n);s=1,n=t[o]}return[r.subarray(0,i),e]},jn=function(t,e){for(var r=0,i=0;i<e.length;++i)r+=t[i]*e[i];return r},Na=function(t,e,r){var i=r.length,n=Vd(e+2);t[n]=255&i,t[n+1]=i>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var s=0;s<i;++s)t[n+s+4]=r[s];return 8*(n+4+i)},fd=function(t,e,r,i,n,s,a,o,l,h,c){hr(e,c++,r),++n[256];for(var u=Gl(n,15),f=u[0],p=u[1],m=Gl(s,15),g=m[0],d=m[1],y=dd(f),v=y[0],b=y[1],_=dd(g),S=_[0],T=_[1],x=new at(19),w=0;w<v.length;++w)x[31&v[w]]++;for(w=0;w<S.length;++w)x[31&S[w]]++;for(var M=Gl(x,7),k=M[0],I=M[1],P=19;P>4&&!k[pd[P-1]];--P);var A,E,F,$,D=h+5<<3,C=jn(n,li)+jn(s,Ja)+a,R=jn(n,f)+jn(s,g)+a+14+3*P+jn(x,k)+(2*x[16]+3*x[17]+7*x[18]);if(D<=C&&D<=R)return Na(e,c,t.subarray(l,l+h));if(hr(e,c,1+(R<C)),c+=2,R<C){A=Wn(f,p,0),E=f,F=Wn(g,d,0),$=g;var B=Wn(k,I,0);for(hr(e,c,b-257),hr(e,c+5,T-1),hr(e,c+10,P-4),c+=14,w=0;w<P;++w)hr(e,c+3*w,k[pd[w]]);c+=3*P;for(var U=[v,S],Z=0;Z<2;++Z){var X=U[Z];for(w=0;w<X.length;++w){var H=31&X[w];hr(e,c,B[H]),c+=k[H],H>15&&(hr(e,c,X[w]>>>5&127),c+=X[w]>>>12)}}}else A=ky,E=li,F=Ey,$=Ja;for(w=0;w<o;++w)if(i[w]>255){H=i[w]>>>18&31,zn(e,c,A[H+257]),c+=E[H+257],H>7&&(hr(e,c,i[w]>>>23&31),c+=dh[H]);var ie=31&i[w];zn(e,c,F[ie]),c+=$[ie],ie>3&&(zn(e,c,i[w]>>>5&8191),c+=fh[ie])}else zn(e,c,A[i[w]]),c+=E[i[w]];return zn(e,c,A[256]),c+E[256]},Ay=new Xi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Cy=new kt(0),Ty=function(){for(var t=new Xi(256),e=0;e<256;++e){for(var r=e,i=9;--i;)r=(1&r&&3988292384)^r>>>1;t[e]=r}return t}(),Iy=function(){var t=4294967295;return{p:function(e){for(var r=t,i=0;i<e.length;++i)r=Ty[255&r^e[i]]^r>>>8;t=r},d:function(){return 4294967295^t}}},My=function(t,e,r,i,n){return function(s,a,o,l,h,c){var u=s.length,f=new kt(l+u+5*(1+Math.floor(u/7e3))+h),p=f.subarray(l,f.length-h),m=0;if(!a||u<8)for(var g=0;g<=u;g+=65535){var d=g+65535;d<u?m=Na(p,m,s.subarray(g,d)):(p[g]=c,m=Na(p,m,s.subarray(g,u)))}else{for(var y=Ay[a-1],v=y>>>13,b=8191&y,_=(1<<o)-1,S=new at(32768),T=new at(_+1),x=Math.ceil(o/3),w=2*x,M=function(ot){return(s[ot]^s[ot+1]<<x^s[ot+2]<<w)&_},k=new Xi(25e3),I=new at(288),P=new at(32),A=0,E=0,F=(g=0,0),$=0,D=0;g<u;++g){var C=M(g),R=32767&g,B=T[C];if(S[R]=B,T[C]=R,$<=g){var U=u-g;if((A>7e3||F>24576)&&U>423){m=fd(s,p,0,k,I,P,E,F,D,g-D,m),F=A=E=0,D=g;for(var Z=0;Z<286;++Z)I[Z]=0;for(Z=0;Z<30;++Z)P[Z]=0}var X=2,H=0,ie=b,oe=R-B&32767;if(U>2&&C==M(g-oe))for(var se=Math.min(v,U)-1,te=Math.min(32767,g),ke=Math.min(258,U);oe<=te&&--ie&&R!=B;){if(s[g+X]==s[g+X-oe]){for(var fe=0;fe<ke&&s[g+fe]==s[g+fe-oe];++fe);if(fe>X){if(X=fe,H=oe,fe>se)break;var Me=Math.min(oe,fe-2),Ee=0;for(Z=0;Z<Me;++Z){var J=g-oe+Z+32768&32767,Ze=J-S[J]+32768&32767;Ze>Ee&&(Ee=Ze,B=J)}}}oe+=(R=B)-(B=S[R])+32768&32767}if(H){k[F++]=268435456|rh[X]<<18|ih[H];var Et=31&rh[X],Pt=31&ih[H];E+=dh[Et]+fh[Pt],++I[257+Et],++P[Pt],$=g+X,++A}else k[F++]=s[g],++I[s[g]]}}m=fd(s,p,c,k,I,P,E,F,D,g-D,m),c||(m=Na(p,m,Cy))}return Nd(f,0,l+Vd(m)+h)}(t,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,r,i,!n)},nh=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8},Dy=function(t,e){var r=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&nh(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),r){t[3]=8;for(var i=0;i<=r.length;++i)t[i+10]=r.charCodeAt(i)}},Fy=function(t){return 10+(t.filename&&t.filename.length+1||0)};function $y(t,e){e===void 0&&(e={});var r=Iy(),i=t.length;r.p(t);var n=My(t,e,Fy(e),8),s=n.length;return Dy(n,e),nh(n,s-8,r.d()),nh(n,s-4,i),n}function Oy(t,e){var r=t.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var i=new kt(t.length+(t.length>>>1)),n=0,s=function(h){i[n++]=h},a=0;a<r;++a){if(n+5>i.length){var o=new kt(n+8+(r-a<<1));o.set(i),i=o}var l=t.charCodeAt(a);l<128||e?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++a))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return Nd(i,0,n)}(function(t){t.GZipJS="gzip-js",t.Base64="base64"})(ii||(ii={}));var zd=function(t,e,r){var i=e||{};i.ip=r.ip?1:0,i._=new Date().getTime().toString(),i.ver=oi.LIB_VERSION;var n=t.split("?");if(n.length>1){var s,a=ai(n[1].split("&"));try{for(a.s();!(s=a.n()).done;){var o=s.value.split("=")[0];ve(i[o])||delete i[o]}}catch(h){a.e(h)}finally{a.f()}}var l=t.indexOf("?")>-1?"&":"?";return t+l+function(h){var c,u,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",p=[];return Ce(h,function(m,g){ve(m)||ve(g)||g==="undefined"||(c=encodeURIComponent(m.toString()),u=encodeURIComponent(g),p[p.length]=u+"="+c)}),p.join(f)}(i)},mh=function t(e,r){if(r.blob&&e.buffer)return new Blob([jp(e)?e:e.buffer],{type:"text/plain"});if(r.sendBeacon||r.blob){var i=t(e,{method:"POST"});return new Blob([i],{type:"application/x-www-form-urlencoded"})}return r.method!=="POST"?null:(n=We(e)||jp(e)?"data="+encodeURIComponent(e):"data="+encodeURIComponent(e.data),"compression"in e&&e.compression&&(n+="&compression="+e.compression),n);var n},jd=function(t){var e=t.url,r=t.data,i=t.headers,n=t.options,s=t.callback,a=t.retriesPerformedSoFar,o=t.retryQueue,l=t.onXHRError,h=t.timeout,c=h===void 0?6e4:h,u=t.onResponse;cr(a)&&a>0&&(e=zd(e,{retry_count:a},{}));var f=new XMLHttpRequest;f.open(n.method||"GET",e,!0);var p=mh(r,n);Ce(i,function(m,g){f.setRequestHeader(g,m)}),n.method!=="POST"||n.blob||f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.timeout=c,f.withCredentials=!0,f.onreadystatechange=function(){if(f.readyState===4)if(u?.(f),f.status===200){if(s){var m;try{m=JSON.parse(f.responseText)}catch(g){return void j.error(g)}s(m)}}else jt(l)&&l(f),(f.status<400||f.status>500)&&o.enqueue({url:e,data:r,options:n,headers:i,retriesPerformedSoFar:(a||0)+1,callback:s}),s?.({status:0})},f.send(p)},Ry=18e5,Ly=function(t){bd(r,Rd);var e=_d(r);function r(i,n){var s;return Oe(this,r),(s=e.call(this)).isPolling=!1,s.queue=[],s.areWeOnline=!0,s.onXHRError=i,s.rateLimiter=n,!ve(O)&&"onLine"in O.navigator&&(s.areWeOnline=O.navigator.onLine,O.addEventListener("online",function(){s._handleWeAreNowOnline()}),O.addEventListener("offline",function(){s.areWeOnline=!1})),s}return Re(r,[{key:"enqueue",value:function(i){var n=i.retriesPerformedSoFar||0;if(!(n>=10)){var s=function(l){var h=3e3*Math.pow(2,l),c=h/2,u=Math.min(Ry,h),f=(Math.random()-.5)*(u-c);return Math.ceil(u+f)}(n),a=new Date(Date.now()+s);this.queue.push({retryAt:a,requestData:i});var o="Enqueued failed request for retry in ".concat(s);navigator.onLine||(o+=" (Browser is offline)"),j.warn(o),this.isPolling||(this.isPolling=!0,this.poll())}}},{key:"poll",value:function(){var i=this;this._poller&&clearTimeout(this._poller),this._poller=setTimeout(function(){i.areWeOnline&&i.queue.length>0&&i.flush(),i.poll()},this._pollInterval)}},{key:"flush",value:function(){var i=new Date(Date.now()),n=this.queue.filter(function(l){return l.retryAt<i});if(n.length>0){this.queue=this.queue.filter(function(l){return l.retryAt>=i});var s,a=ai(n);try{for(a.s();!(s=a.n()).done;){var o=s.value.requestData;this._executeXhrRequest(o)}}catch(l){a.e(l)}finally{a.f()}}}},{key:"unload",value:function(){this._poller&&(clearTimeout(this._poller),this._poller=void 0);var i,n=ai(this.queue);try{for(n.s();!(i=n.n()).done;){var s=i.value.requestData,a=s.url,o=s.data,l=s.options;if(this.rateLimiter.isRateLimited(l._batchKey))j.warn("[RetryQueue] is quota limited. Dropping request.");else try{O?.navigator.sendBeacon(a,mh(o,ne(ne({},l),{},{sendBeacon:!0})))}catch(h){j.error(h)}}}catch(h){n.e(h)}finally{n.f()}this.queue=[]}},{key:"_executeXhrRequest",value:function(i){var n=i.url,s=i.data,a=i.options,o=i.headers,l=i.callback,h=i.retriesPerformedSoFar;this.rateLimiter.isRateLimited(a._batchKey)||jd({url:n,data:s||{},options:a||{},headers:o||{},retriesPerformedSoFar:h||0,callback:l,retryQueue:this,onXHRError:this.onXHRError,onResponse:this.rateLimiter.checkForLimiting})}},{key:"_handleWeAreNowOnline",value:function(){this.areWeOnline=!0,this.flush()}}]),r}(),Fa=1800,md=60,By=864e5,Vy=function(){function t(e,r,i,n){Oe(this,t),Y(this,"_sessionIdChangedHandlers",[]),this.config=e,this.persistence=r,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||ni,this._windowIdGenerator=n||ni;var s=e.persistence_name||e.token,a=e.session_idle_timeout_seconds||Fa;if(cr(a)?a>Fa?j.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):a<md&&j.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(j.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),a=Fa),this._sessionTimeoutMs=1e3*Math.min(Math.max(a,md),Fa),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var o=Xe.parse(this._window_id_storage_key),l=Xe.parse(this._primary_window_exists_storage_key);o&&!l?this._windowId=o:Xe.remove(this._window_id_storage_key),Xe.set(this._primary_window_exists_storage_key,!0)}this._listenToReloadWindow()}return Re(t,[{key:"onSessionId",value:function(e){var r=this;return ve(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),function(){r._sessionIdChangedHandlers=r._sessionIdChangedHandlers.filter(function(i){return i!==e})}}},{key:"_canUseSessionStorage",value:function(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&Xe.is_supported()}},{key:"_setWindowId",value:function(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Xe.set(this._window_id_storage_key,e))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:this._canUseSessionStorage()?Xe.parse(this._window_id_storage_key):null}},{key:"_setSessionId",value:function(e,r,i){e===this._sessionId&&r===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=r,this._sessionId=e,this.persistence.register(Y({},Ua,[r,e,i])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[Ua];return We(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}},{key:"resetSessionId",value:function(){this._setSessionId(null,null,null)}},{key:"_listenToReloadWindow",value:function(){var e=this;O?.addEventListener("beforeunload",function(){e._canUseSessionStorage()&&Xe.remove(e._primary_window_exists_storage_key)})}},{key:"checkAndGetSessionAndWindowId",value:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||new Date().getTime(),i=zt(this._getSessionId(),3),n=i[0],s=i[1],a=i[2],o=this._getWindowId(),l=a&&a>0&&Math.abs(r-a)>By,h=!1,c=!s,u=!e&&Math.abs(r-n)>this._sessionTimeoutMs;c||u||l?(s=this._sessionIdGenerator(),o=this._windowIdGenerator(),a=r,h=!0):o||(o=this._windowIdGenerator(),h=!0);var f=n===0||!e||l?r:n,p=a===0?new Date().getTime():a;return this._setWindowId(o),this._setSessionId(s,f,p),h&&this._sessionIdChangedHandlers.forEach(function(m){return m(s,o)}),{sessionId:s,windowId:o,sessionStartTimestamp:p}}}]),t}(),Ny=Re(function t(e,r,i,n){Oe(this,t),this.name="posthog-js",this.setupOnce=function(s){s(function(a){var o,l,h,c,u;if(a.level!=="error"||!e.__loaded)return a;a.tags||(a.tags={});var f=e.config.ui_host||e.config.api_host;a.tags["PostHog Person URL"]=f+"/person/"+e.get_distinct_id(),e.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=((o=a.exception)===null||o===void 0?void 0:o.values)||[],m={$exception_message:(l=p[0])===null||l===void 0?void 0:l.value,$exception_type:(h=p[0])===null||h===void 0?void 0:h.type,$exception_personURL:f+"/person/"+e.get_distinct_id(),$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:(c=p[0])===null||c===void 0?void 0:c.value,$sentry_exception_type:(u=p[0])===null||u===void 0?void 0:u.type,$sentry_tags:a.tags};return r&&i&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+i+"&query="+a.event_id),e.capture("$exception",m),a})}}),zy=function(t){Promise&&Promise.resolve||j.warn("This browser does not have Promise support, and can not use the segment integration");var e=function(r,i){r.event.userId||r.event.anonymousId===t.get_distinct_id()||t.reset(),r.event.userId&&r.event.userId!==t.get_distinct_id()&&(t.register({distinct_id:r.event.userId}),t.reloadFeatureFlags());var n=t._calculate_event_properties(i,r.event.properties);return r.event.properties=Object.assign({},n,r.event.properties),r};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:function(r){return e(r,r.event.event)},page:function(r){return e(r,"$pageview")},identify:function(r){return e(r,"$identify")},screen:function(r){return e(r,"$screen")}}},jy=function(){function t(){var e=this;Oe(this,t),Y(this,"_hasSeenPageView",!1),Y(this,"_updateScrollData",function(){var r,i,n,s;e._pageViewData||(e._pageViewData=e._createPageViewData());var a=e._pageViewData,o=e._scrollY(),l=e._scrollHeight(),h=e._contentY(),c=e._contentHeight();a.lastScrollY=o,a.maxScrollY=Math.max(o,(r=a.maxScrollY)!==null&&r!==void 0?r:0),a.maxScrollHeight=Math.max(l,(i=a.maxScrollHeight)!==null&&i!==void 0?i:0),a.lastContentY=h,a.maxContentY=Math.max(h,(n=a.maxContentY)!==null&&n!==void 0?n:0),a.maxContentHeight=Math.max(c,(s=a.maxContentHeight)!==null&&s!==void 0?s:0)})}return Re(t,[{key:"_createPageViewData",value:function(){var e;return{pathname:(e=O?.location.pathname)!==null&&e!==void 0?e:""}}},{key:"doPageView",value:function(){var e,r;return this._hasSeenPageView?(r=this._pageViewData,this._pageViewData=this._createPageViewData()):(this._hasSeenPageView=!0,r=void 0,this._pageViewData||(this._pageViewData=this._createPageViewData())),setTimeout(this._updateScrollData,0),ne({$prev_pageview_pathname:(e=r)===null||e===void 0?void 0:e.pathname},this._calculatePrevPageScrollProperties(r))}},{key:"doPageLeave",value:function(){var e=this._pageViewData;return ne({$prev_pageview_pathname:e?.pathname},this._calculatePrevPageScrollProperties(e))}},{key:"_calculatePrevPageScrollProperties",value:function(e){if(!e||e.maxScrollHeight==null||e.lastScrollY==null||e.maxScrollY==null||e.maxContentHeight==null||e.lastContentY==null||e.maxContentY==null)return{};var r=e.maxScrollHeight,i=e.lastScrollY,n=e.maxScrollY,s=e.maxContentHeight,a=e.lastContentY,o=e.maxContentY;return r=Math.ceil(r),i=Math.ceil(i),n=Math.ceil(n),s=Math.ceil(s),a=Math.ceil(a),o=Math.ceil(o),{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:r<=1?1:$a(i/r,0,1),$prev_pageview_max_scroll:n,$prev_pageview_max_scroll_percentage:r<=1?1:$a(n/r,0,1),$prev_pageview_last_content:a,$prev_pageview_last_content_percentage:s<=1?1:$a(a/s,0,1),$prev_pageview_max_content:o,$prev_pageview_max_content_percentage:s<=1?1:$a(o/s,0,1)}}},{key:"startMeasuringScrollPosition",value:function(){O?.addEventListener("scroll",this._updateScrollData),O?.addEventListener("scrollend",this._updateScrollData),O?.addEventListener("resize",this._updateScrollData)}},{key:"stopMeasuringScrollPosition",value:function(){O?.removeEventListener("scroll",this._updateScrollData),O?.removeEventListener("scrollend",this._updateScrollData),O?.removeEventListener("resize",this._updateScrollData)}},{key:"_scrollHeight",value:function(){return O?Math.max(0,O.document.documentElement.scrollHeight-O.document.documentElement.clientHeight):0}},{key:"_scrollY",value:function(){return O&&(O.scrollY||O.pageYOffset||O.document.documentElement.scrollTop)||0}},{key:"_contentHeight",value:function(){return O?.document.documentElement.scrollHeight||0}},{key:"_contentY",value:function(){var e=O?.document.documentElement.clientHeight||0;return this._scrollY()+e}}]),t}();function $a(t,e,r){return Math.max(e,Math.min(t,r))}var Zn,gh,Je,Gy={icontains:function(t){return!!O&&O.location.href.toLowerCase().indexOf(t.toLowerCase())>-1},regex:function(t){return!!O&&K0(O.location.href,t)},exact:function(t){return O?.location.href===t}},Hy=function(){function t(e){Oe(this,t),this.instance=e}return Re(t,[{key:"getSurveys",value:function(e){var r=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.instance.get_property(Kl);if(n&&!i)return e(n);this.instance._send_request("".concat(this.instance.config.api_host,"/api/surveys/?token=").concat(this.instance.config.token),{},{method:"GET"},function(s){var a,o=s.surveys||[];return(a=r.instance.persistence)===null||a===void 0||a.register(Y({},Kl,o)),e(o)})}},{key:"getActiveMatchingSurveys",value:function(e){var r=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(function(n){var s=n.filter(function(a){return!(!a.start_date||a.end_date)}).filter(function(a){var o,l,h,c;if(!a.conditions)return!0;var u=(o=a.conditions)===null||o===void 0||!o.url||Gy[(l=(h=a.conditions)===null||h===void 0?void 0:h.urlMatchType)!==null&&l!==void 0?l:"icontains"](a.conditions.url),f=(c=a.conditions)===null||c===void 0||!c.selector||K?.querySelector(a.conditions.selector);return u&&f}).filter(function(a){if(!a.linked_flag_key&&!a.targeting_flag_key)return!0;var o=!a.linked_flag_key||r.instance.featureFlags.isFeatureEnabled(a.linked_flag_key),l=!a.targeting_flag_key||r.instance.featureFlags.isFeatureEnabled(a.targeting_flag_key);return o&&l});return e(s)},i)}}]),t}(),qy=6e4,Uy=function(){function t(){var e=this;Oe(this,t),Y(this,"limits",{}),Y(this,"checkForLimiting",function(r){try{var i=r.responseText;if(!i||!i.length)return;(JSON.parse(i).quota_limited||[]).forEach(function(n){j.info("[RateLimiter] ".concat(n||"events"," is quota limited.")),e.limits[n]=new Date().getTime()+qy})}catch(n){return void j.error(n)}})}return Re(t,[{key:"isRateLimited",value:function(e){var r=this.limits[e||"events"]||!1;return r!==!1&&new Date().getTime()<r}}]),t}(),Wy=function(){return ne({initialPathName:O?.location.pathname||"",referringDomain:He.referringDomain()},He.campaignParams())},Zy=function(){function t(e,r,i){var n=this;Oe(this,t),Y(this,"_onSessionIdCallback",function(s){var a=n._getStoredProps();if(!a||a.sessionId!==s){var o={sessionId:s,props:n._sessionSourceParamGenerator()};n._persistence.register(Y({},th,o))}}),this._sessionIdManager=e,this._persistence=r,this._sessionSourceParamGenerator=i||Wy,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}return Re(t,[{key:"_getStoredProps",value:function(){return this._persistence.props[th]}},{key:"getSessionProps",value:function(){var e,r=(e=this._getStoredProps())===null||e===void 0?void 0:e.props;return r?{$client_session_initial_referring_host:r.referringDomain,$client_session_initial_pathname:r.initialPathName,$client_session_initial_utm_source:r.utm_source,$client_session_initial_utm_campaign:r.utm_campaign,$client_session_initial_utm_medium:r.utm_medium,$client_session_initial_utm_content:r.utm_content,$client_session_initial_utm_term:r.utm_term}:{}}}]),t}(),Yy=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"],Jy=function(t,e){if(!t)return!1;var r=t.toLowerCase();return Yy.concat(e||[]).some(function(i){var n=i.toLowerCase();return r.includes?r.includes(n):r.indexOf(n)!==-1})};(function(t){t[t.INIT_MODULE=0]="INIT_MODULE",t[t.INIT_SNIPPET=1]="INIT_SNIPPET"})(Zn||(Zn={}));var sh=function(){},Oa={},pt="posthog",za=O?.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,Gd=!za&&Ge?.indexOf("MSIE")===-1&&Ge?.indexOf("Mozilla")===-1,gd=function(){var t,e,r;return{api_host:"https://app.posthog.com",api_method:"POST",api_transport:"XHR",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:(e=K?.location,r=e?.hostname,!!St(r)&&r.split(".").slice(-2).join(".")!=="herokuapp.com"),persistence:"localStorage+cookie",persistence_name:"",cookie_name:"",loaded:sh,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:!0,debug:!1,verbose:!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_cookie:!1,enable_recording_console_log:void 0,secure_cookie:(O==null||(t=O.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_blacklist:[],respect_dnt:!1,sanitize_properties:null,xhr_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,on_xhr_error:function(i){var n="Bad HTTP status: "+i.status+" "+i.statusText;j.error(n)},get_device_id:function(i){return i},_onCapture:sh,capture_performance:void 0,name:"posthog",callback_fn:"posthog._jsc",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800}},ah=function(t,e,r,i){var n,s=r!==pt&&Je?r?Je[r]:void 0:Je,a={initComplete:!1,syncCode:!1},o=function(l){return function(h){a[l]||(a[l]=!0,a.initComplete&&a.syncCode&&i?.(h))}};if(s&&gh===Zn.INIT_MODULE)n=s;else{if(s&&!We(s))return void j.error("You have already initialized "+r);n=new yh}return n._init(t,e,r,o("initComplete")),n.toolbar.maybeLoadToolbar(),n.sessionRecording=new uy(n),n.sessionRecording.startRecordingIfEnabled(),n.config.__preview_measure_pageview_stats&&n.pageViewManager.startMeasuringScrollPosition(),n.__autocapture=n.config.autocapture,Er._setIsAutocaptureEnabled(n),Er._isAutocaptureEnabled&&(n.__autocapture=n.config.autocapture,Er.enabledForProject(n.config.token,100,100)?Er.isBrowserSupported()?Er.init(n):(n.__autocapture=!1,j.info("Disabling Automatic Event Collection because this browser is not supported")):(n.__autocapture=!1,j.info("Not in active bucket: disabling Automatic Event Collection."))),oi.DEBUG=oi.DEBUG||n.config.debug,!ve(s)&&We(s)&&(n._execute_array.call(n.people,s.people),n._execute_array(s)),o("syncCode")(n),n},Xy=function(){function t(){Oe(this,t),Y(this,"__forceAllowLocalhost",!1)}return Re(t,[{key:"_forceAllowLocalhost",get:function(){return this.__forceAllowLocalhost},set:function(e){j.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}]),t}(),yh=function(){function t(){var e=this;Oe(this,t),Y(this,"webPerformance",new Xy),this.config=gd(),this.compression={},this.decideEndpointWasHit=!1,this.SentryIntegration=Ny,this.segmentIntegration=function(){return zy(e)},this.__captureHooks=[],this.__request_queue=[],this.__loaded=!1,this.__loaded_recorder_version=void 0,this.__autocapture=void 0,this._jsc=function(){},this.analyticsDefaultEndpoint="/e/",this.elementsChainAsString=!1,this.featureFlags=new N0(this),this.toolbar=new gy(this),this.pageViewManager=new jy,this.surveys=new Hy(this),this.rateLimiter=new Uy,this.people={set:function(r,i,n){var s=St(r)?Y({},r,i):r;e.setPersonProperties(s),n?.({})},set_once:function(r,i,n){var s=St(r)?Y({},r,i):r;e.setPersonProperties(void 0,s),n?.({})}}}return Re(t,[{key:"init",value:function(e,r,i){if(ve(i))j.critical("You must name your new library: init(token, config, name)");else{if(i!==pt){var n=ah(e,r,i,function(s){Je[i]=s,s._loaded()});return Je[i]=n,n}j.critical("You must initialize the main posthog object right after you include the PostHog js snippet")}}},{key:"_init",value:function(e){var r,i,n,s=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0,l=arguments.length>3?arguments[3]:void 0;this.__loaded=!0,this.config={},this._triggered_notifs=[];var h,c={segmentRegister:!1,syncCode:!1},u=function(S){return function(){c[S]||(c[S]=!0,c.segmentRegister&&c.syncCode&&l?.(s))}};if(this.set_config(Ye({},gd(),a,{name:o,token:e,callback_fn:(o===pt?o:pt+"."+o)+"._jsc"})),this._jsc=function(){},(O!=null&&(r=O.rrweb)!==null&&r!==void 0&&r.record||O!=null&&O.rrwebRecord)&&(this.__loaded_recorder_version=O==null||(h=O.rrweb)===null||h===void 0?void 0:h.version),this.persistence=new od(this.config),this._requestQueue=new xy(this._handle_queued_event.bind(this)),this._retryQueue=new Ly(this.config.on_xhr_error,this.rateLimiter),this.__captureHooks=[],this.__request_queue=[],this.sessionManager=new Vy(this.config,this.persistence),this.sessionPropsManager=new Zy(this.sessionManager,this.persistence),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new od(ne(ne({},this.config),{},{persistence:"sessionStorage"})),this._gdpr_init(),a.segment?(this.config.get_device_id=function(){return a.segment.user().anonymousId()},a.segment.user().id()&&(this.register({distinct_id:a.segment.user().id()}),this.persistence.set_user_state("identified")),a.segment.register(this.segmentIntegration()).then(u("segmentRegister"))):u("segmentRegister")(),((i=a.bootstrap)===null||i===void 0?void 0:i.distinctID)!==void 0){var f,p,m=this.config.get_device_id(ni()),g=(f=a.bootstrap)!==null&&f!==void 0&&f.isIdentifiedID?m:a.bootstrap.distinctID;this.persistence.set_user_state((p=a.bootstrap)!==null&&p!==void 0&&p.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:a.bootstrap.distinctID,$device_id:g})}if(this._hasBootstrappedFeatureFlags()){var d,y,v=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlags)||{}).filter(function(S){var T,x;return!((T=a.bootstrap)===null||T===void 0||(x=T.featureFlags)===null||x===void 0||!x[S])}).reduce(function(S,T){var x,w;return S[T]=((x=a.bootstrap)===null||x===void 0||(w=x.featureFlags)===null||w===void 0?void 0:w[T])||!1,S},{}),b=Object.keys(((y=a.bootstrap)===null||y===void 0?void 0:y.featureFlagPayloads)||{}).filter(function(S){return v[S]}).reduce(function(S,T){var x,w,M,k;return(x=a.bootstrap)!==null&&x!==void 0&&(w=x.featureFlagPayloads)!==null&&w!==void 0&&w[T]&&(S[T]=(M=a.bootstrap)===null||M===void 0||(k=M.featureFlagPayloads)===null||k===void 0?void 0:k[T]),S},{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:b})}if(!this.get_distinct_id()){var _=this.config.get_device_id(ni());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_user_state("anonymous")}O==null||(n=O.addEventListener)===null||n===void 0||n.call(O,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),u("syncCode")()}},{key:"_afterDecideResponse",value:function(e){var r;if(this.compression={},e.supportedCompression&&!this.config.disable_compression){var i,n={},s=ai(e.supportedCompression);try{for(s.s();!(i=s.n()).done;)n[i.value]=!0}catch(a){s.e(a)}finally{s.f()}this.compression=n}(r=e.analytics)!==null&&r!==void 0&&r.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),e.elementsChainAsString&&(this.elementsChainAsString=e.elementsChainAsString)}},{key:"_loaded",value:function(){var e=this.config.advanced_disable_decide;e||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(r){j.critical("`loaded` function failed",r)}this._start_queue_if_opted_in(),this.config.capture_pageview&&K&&this.capture("$pageview",{title:K.title},{send_instantly:!0}),e||(new py(this).call(),this.featureFlags.resetRequestQueue())}},{key:"_start_queue_if_opted_in",value:function(){var e;this.has_opted_out_capturing()||this.config.request_batching&&((e=this._requestQueue)===null||e===void 0||e.poll())}},{key:"_dom_loaded",value:function(){var e=this;this.has_opted_out_capturing()||Ji(this.__request_queue,function(r){e._send_request.apply(e,Ul(r))}),this.__request_queue=[],this._start_queue_if_opted_in()}},{key:"_prepare_callback",value:function(e,r){if(ve(e))return null;if(za)return function(a){e(a,r)};var i=this._jsc,n=""+Math.floor(1e8*Math.random()),s=this.config.callback_fn+"["+n+"]";return i[n]=function(a){delete i[n],e(a,r)},s}},{key:"_handle_unload",value:function(){var e,r;this.config.request_batching?(this.config.capture_pageview&&this.config.capture_pageleave&&this.capture("$pageleave"),(e=this._requestQueue)===null||e===void 0||e.unload(),(r=this._retryQueue)===null||r===void 0||r.unload()):this.config.capture_pageview&&this.config.capture_pageleave&&this.capture("$pageleave",null,{transport:"sendBeacon"})}},{key:"_handle_queued_event",value:function(e,r,i){var n=JSON.stringify(r);this.__compress_and_send_json_request(e,n,i||Oa,sh)}},{key:"__compress_and_send_json_request",value:function(e,r,i,n){var s=function(h,c,u){return h===ii.GZipJS?[$y(Oy(c),{mtime:0}),ne(ne({},u),{},{blob:!0,urlQueryArgs:{compression:ii.GZipJS}})]:[{data:hh(c)},u]}(this.compression[ii.GZipJS]?ii.GZipJS:ii.Base64,r,i),a=zt(s,2),o=a[0],l=a[1];this._send_request(e,o,l,n)}},{key:"_send_request",value:function(e,r,i,n){if(this.__loaded&&this._retryQueue&&!this.rateLimiter.isRateLimited(i._batchKey))if(Gd)this.__request_queue.push([e,r,i,n]);else{var s={method:this.config.api_method,transport:this.config.api_transport,verbose:this.config.verbose};i=Ye(s,i||{}),za||(i.method="GET");var a=O&&"sendBeacon"in O.navigator&&i.transport==="sendBeacon";if(e=zd(e,i.urlQueryArgs||{},{ip:this.config.ip}),a)try{O?.navigator.sendBeacon(e,mh(r,ne(ne({},i),{},{sendBeacon:!0})))}catch{}else if(za||!K)try{jd({url:e,data:r,headers:this.config.xhr_headers,options:i,callback:n,retriesPerformedSoFar:0,retryQueue:this._retryQueue,onXHRError:this.config.on_xhr_error,onResponse:this.rateLimiter.checkForLimiting})}catch(c){j.error(c)}else{var o,l=K.createElement("script");l.type="text/javascript",l.async=!0,l.defer=!0,l.src=e;var h=K.getElementsByTagName("script")[0];(o=h.parentNode)===null||o===void 0||o.insertBefore(l,h)}}}},{key:"_execute_array",value:function(e){var r,i=this,n=[],s=[],a=[];Ji(e,function(l){l&&(r=l[0],We(r)?a.push(l):jt(l)?l.call(i):We(l)&&r==="alias"?n.push(l):We(l)&&r.indexOf("capture")!==-1&&jt(i[r])?a.push(l):s.push(l))});var o=function(l,h){Ji(l,function(c){if(We(c[0])){var u=h;Ce(c,function(f){u=u[f[0]].apply(u,f.slice(1))})}else this[c[0]].apply(this,c.slice(1))},h)};o(n,this),o(s,this),o(a,this)}},{key:"_hasBootstrappedFeatureFlags",value:function(){var e,r;return((e=this.config.bootstrap)===null||e===void 0?void 0:e.featureFlags)&&Object.keys((r=this.config.bootstrap)===null||r===void 0?void 0:r.featureFlags).length>0||!1}},{key:"push",value:function(e){this._execute_array([e])}},{key:"capture",value:function(e,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Oa;if(!this.__loaded||!this.sessionPersistence||!this._requestQueue)return j.uninitializedWarning("posthog.capture");if(!function(c){var u=!1;try{var f=c.config.token,p=c.config.respect_dnt,m=c.config.opt_out_capturing_persistence_type,g=c.config.opt_out_capturing_cookie_prefix||void 0,d=c.config.window;f&&(u=ud(f,{respectDnt:p,persistenceType:m,persistencePrefix:g,window:d}))}catch(y){j.error("Unexpected error when checking capturing opt-out status: "+y)}return u}(this)){var n=(i=i||Oa).transport;if(n&&(i.transport=n),!ve(e)&&St(e)){if(!Ge||!Jy(Ge,this.config.custom_blocked_useragents)){this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info();var s={uuid:ni(),event:e,properties:this._calculate_event_properties(e,r||{})};e==="$identify"&&(s.$set=i.$set,s.$set_once=i.$set_once),(s=$0(s,i._noTruncate?null:this.config.properties_string_max_length)).timestamp=i.timestamp||new Date;var a=ne(ne({},s.properties.$set),s.$set);D0(a)||this.setPersonPropertiesForFlags(a),j.info("send",s);var o=JSON.stringify(s),l=this.config.api_host+(i.endpoint||this.analyticsDefaultEndpoint),h=i!==Oa;return!this.config.request_batching||h&&!i._batchKey||i.send_instantly?this.__compress_and_send_json_request(l,o,i):this._requestQueue.enqueue(l,s,i),this._invokeCaptureHooks(e,s),s}}else j.error("No event name provided to posthog.capture")}}},{key:"_addCaptureHook",value:function(e){this.__captureHooks.push(e)}},{key:"_invokeCaptureHooks",value:function(e,r){this.config._onCapture(e,r),Ce(this.__captureHooks,function(i){return i(e)})}},{key:"_calculate_event_properties",value:function(e,r){if(!this.persistence||!this.sessionPersistence)return r;var i=this.persistence.remove_event_timer(e),n=ne({},r);if(n.token=this.config.token,e==="$snapshot"){var s=ne(ne({},this.persistence.properties()),this.sessionPersistence.properties());return n.distinct_id=s.distinct_id,n}var a=He.properties();if(this.sessionManager){var o=this.sessionManager.checkAndGetSessionAndWindowId(),l=o.sessionId,h=o.windowId;n.$session_id=l,n.$window_id=h}if(this.sessionPropsManager&&this.config.__preview_send_client_session_params&&(e==="$pageview"||e==="$pageleave"||e==="$autocapture")){var c=this.sessionPropsManager.getSessionProps();n=Ye(n,c)}if(this.config.__preview_measure_pageview_stats){var u={};e==="$pageview"?u=this.pageViewManager.doPageView():e==="$pageleave"&&(u=this.pageViewManager.doPageLeave()),n=Ye(n,u)}if(e==="$pageview"&&K&&(n.title=K.title),e==="$performance_event"){var f=this.persistence.properties();return n.distinct_id=f.distinct_id,n.$current_url=a.$current_url,n}if(!ve(i)){var p=new Date().getTime()-i;n.$duration=parseFloat((p/1e3).toFixed(3))}n=Ye({},He.properties(),this.persistence.properties(),this.sessionPersistence.properties(),n);var m=this.config.property_blacklist;We(m)?Ce(m,function(d){delete n[d]}):j.error("Invalid value for property_blacklist config: "+m);var g=this.config.sanitize_properties;return g&&(n=g(n,e)),n}},{key:"register",value:function(e,r){var i;(i=this.persistence)===null||i===void 0||i.register(e,r)}},{key:"register_once",value:function(e,r,i){var n;(n=this.persistence)===null||n===void 0||n.register_once(e,r,i)}},{key:"register_for_session",value:function(e){var r;(r=this.sessionPersistence)===null||r===void 0||r.register(e)}},{key:"unregister",value:function(e){var r;(r=this.persistence)===null||r===void 0||r.unregister(e)}},{key:"unregister_for_session",value:function(e){var r;(r=this.sessionPersistence)===null||r===void 0||r.unregister(e)}},{key:"_register_single",value:function(e,r){this.register(Y({},e,r))}},{key:"getFeatureFlag",value:function(e,r){return this.featureFlags.getFeatureFlag(e,r)}},{key:"getFeatureFlagPayload",value:function(e){var r=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(r)}catch{return r}}},{key:"isFeatureEnabled",value:function(e,r){return this.featureFlags.isFeatureEnabled(e,r)}},{key:"reloadFeatureFlags",value:function(){this.featureFlags.reloadFeatureFlags()}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,r)}},{key:"getEarlyAccessFeatures",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(e,r)}},{key:"onFeatureFlags",value:function(e){return this.featureFlags.onFeatureFlags(e)}},{key:"onSessionId",value:function(e){var r,i;return(r=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(e))!==null&&r!==void 0?r:function(){}}},{key:"getSurveys",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(e,r)}},{key:"getActiveMatchingSurveys",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(e,r)}},{key:"identify",value:function(e,r,i){if(!this.__loaded||!this.persistence)return j.uninitializedWarning("posthog.identify");if(e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))j.critical('The string "'.concat(e,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else{var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==n&&e!==this.get_property(Ba)&&(this.unregister(Ba),this.register({distinct_id:e}));var a=this.persistence.get_user_state()==="anonymous";e!==n&&a?(this.persistence.set_user_state("identified"),this.setPersonPropertiesForFlags(r||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:r||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(n)):(r||i)&&this.setPersonProperties(r,i),e!==n&&(this.reloadFeatureFlags(),this.unregister(Wa))}else j.error("Unique user id has not been set in posthog.identify")}},{key:"setPersonProperties",value:function(e,r){(e||r)&&(this.setPersonPropertiesForFlags(e||{}),this.capture("$set",{$set:e||{},$set_once:r||{}}))}},{key:"group",value:function(e,r,i){if(e&&r){var n=this.getGroups();n[e]!==r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ne(ne({},n),{},Y({},e,r))}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:r,$group_set:i}),this.setGroupPropertiesForFlags(Y({},e,i))),n[e]===r||i||this.reloadFeatureFlags()}else j.error("posthog.group requires a group type and group key")}},{key:"resetGroups",value:function(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}},{key:"setPersonPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,r)}},{key:"resetPersonPropertiesForFlags",value:function(){this.featureFlags.resetPersonPropertiesForFlags()}},{key:"setGroupPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setGroupPropertiesForFlags(e,r)}},{key:"resetGroupPropertiesForFlags",value:function(e){this.featureFlags.resetGroupPropertiesForFlags(e)}},{key:"reset",value:function(e){var r,i,n,s;if(!this.__loaded)return j.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");(r=this.persistence)===null||r===void 0||r.clear(),(i=this.sessionPersistence)===null||i===void 0||i.clear(),(n=this.persistence)===null||n===void 0||n.set_user_state("anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId();var o=this.config.get_device_id(ni());this.register_once({distinct_id:o,$device_id:e?o:a},"")}},{key:"get_distinct_id",value:function(){return this.get_property("distinct_id")}},{key:"getGroups",value:function(){return this.get_property("$groups")||{}}},{key:"get_session_id",value:function(){var e,r;return(e=(r=this.sessionManager)===null||r===void 0?void 0:r.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}},{key:"get_session_replay_url",value:function(e){if(!this.sessionManager)return"";var r=this.config.ui_host||this.config.api_host,i=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=i.sessionId,s=i.sessionStartTimestamp,a=r+"/replay/"+n;if(e!=null&&e.withTimestamp&&s){var o,l=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!s)return a;var h=Math.max(Math.floor((new Date().getTime()-s)/1e3)-l,0);a+="?t=".concat(h)}return a}},{key:"alias",value:function(e,r){return e===this.get_property(Td)?(j.critical("Attempting to create alias for existing People user - aborting."),-2):(ve(r)&&(r=this.get_distinct_id()),e!==r?(this._register_single(Ba,e),this.capture("$create_alias",{alias:e,distinct_id:r})):(j.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1))}},{key:"set_config",value:function(e){var r,i,n=ne({},this.config);Pr(e)&&(Ye(this.config,e),this.config.persistence_name||(this.config.persistence_name=this.config.cookie_name),this.config.disable_persistence||(this.config.disable_persistence=this.config.disable_cookie),this.config.api_host=this.config.api_host.replace(/\/$/,""),(r=this.persistence)===null||r===void 0||r.update_config(this.config),(i=this.sessionPersistence)===null||i===void 0||i.update_config(this.config),Le.is_supported()&&Le.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(oi.DEBUG=!0),this.sessionRecording&&!ve(e.disable_session_recording)&&n.disable_session_recording!==e.disable_session_recording&&(e.disable_session_recording?this.sessionRecording.stopRecording():this.sessionRecording.startRecordingIfEnabled()))}},{key:"startSessionRecording",value:function(){this.set_config({disable_session_recording:!1})}},{key:"stopSessionRecording",value:function(){this.set_config({disable_session_recording:!0})}},{key:"sessionRecordingStarted",value:function(){var e;return!((e=this.sessionRecording)===null||e===void 0||!e.started)}},{key:"loadToolbar",value:function(e){return this.toolbar.loadToolbar(e)}},{key:"get_property",value:function(e){var r;return(r=this.persistence)===null||r===void 0?void 0:r.props[e]}},{key:"getSessionProperty",value:function(e){var r;return(r=this.sessionPersistence)===null||r===void 0?void 0:r.props[e]}},{key:"toString",value:function(){var e,r=(e=this.config.name)!==null&&e!==void 0?e:pt;return r!==pt&&(r=pt+"."+r),r}},{key:"_gdpr_init",value:function(){this.config.opt_out_capturing_persistence_type==="localStorage"&&Le.is_supported()&&(!this.has_opted_in_capturing()&&this.has_opted_in_capturing({persistence_type:"cookie"})&&this.opt_in_capturing({enable_persistence:!1}),!this.has_opted_out_capturing()&&this.has_opted_out_capturing({persistence_type:"cookie"})&&this.opt_out_capturing({clear_persistence:!1}),this.clear_opt_in_out_capturing({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_capturing()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_capturing()||!this.config.opt_out_capturing_by_default&&!Jt.get("ph_optout")||(Jt.remove("ph_optout"),this.opt_out_capturing({clear_persistence:this.config.opt_out_persistence_by_default}))}},{key:"_gdpr_update_persistence",value:function(e){var r,i,n,s,a;if(e&&e.clear_persistence)n=!0;else{if(!e||!e.enable_persistence)return;n=!1}this.config.disable_persistence||((r=this.persistence)===null||r===void 0?void 0:r.disabled)===n||(s=this.persistence)===null||s===void 0||s.set_disabled(n),this.config.disable_persistence||((i=this.sessionPersistence)===null||i===void 0?void 0:i.disabled)===n||(a=this.sessionPersistence)===null||a===void 0||a.set_disabled(n)}},{key:"_gdpr_call_func",value:function(e,r){return r=Ye({capture:this.capture.bind(this),persistence_type:this.config.opt_out_capturing_persistence_type,cookie_prefix:this.config.opt_out_capturing_cookie_prefix,cookie_expiration:this.config.cookie_expiration,cross_subdomain_cookie:this.config.cross_subdomain_cookie,secure_cookie:this.config.secure_cookie},r||{}),Le.is_supported()||r.persistence_type!=="localStorage"||(r.persistence_type="cookie"),e(this.config.token,{capture:r.capture,captureEventName:r.capture_event_name,captureProperties:r.capture_properties,persistenceType:r.persistence_type,persistencePrefix:r.cookie_prefix,cookieExpiration:r.cookie_expiration,crossSubdomainCookie:r.cross_subdomain_cookie,secureCookie:r.secure_cookie})}},{key:"opt_in_capturing",value:function(e){e=Ye({enable_persistence:!0},e||{}),this._gdpr_call_func(vy,e),this._gdpr_update_persistence(e)}},{key:"opt_out_capturing",value:function(e){var r=Ye({clear_persistence:!0},e||{});this._gdpr_call_func(by,r),this._gdpr_update_persistence(r)}},{key:"has_opted_in_capturing",value:function(e){return this._gdpr_call_func(_y,e)}},{key:"has_opted_out_capturing",value:function(e){return this._gdpr_call_func(ud,e)}},{key:"clear_opt_in_out_capturing",value:function(e){var r=Ye({enable_persistence:!0},e??{});this._gdpr_call_func(wy,r),this._gdpr_update_persistence(r)}},{key:"debug",value:function(e){e===!1?(O?.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(O?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}}]),t}();(function(t,e){for(var r=0;r<e.length;r++)t.prototype[e[r]]=Ed(t.prototype[e[r]])})(yh,["identify"]);var yd,vd,Sr={},Ky=function(){Je.init=function(t,e,r){if(r)return Je[r]||(Je[r]=Sr[r]=ah(t||"",e||{},r,function(n){Je[r]=Sr[r]=n,n._loaded()})),Je[r];var i=Je;return Sr[pt]?i=Sr[pt]:t&&(i=ah(t,e||{},pt,function(n){Sr[pt]=n,n._loaded()}),Sr[pt]=i),Je=i,gh===Zn.INIT_SNIPPET&&(tt[pt]=Je),Ce(Sr,function(n,s){s!==pt&&(Je[s]=n)}),i}},Qy=function(){function t(){t.done||(t.done=!0,Gd=!1,Ce(Sr,function(e){e._dom_loaded()}))}K!=null&&K.addEventListener&&(K.readyState==="complete"?t():K.addEventListener("DOMContentLoaded",t,!1)),O&&qn(O,"load",t,!0)};(function(t){t.Popover="popover",t.API="api",t.Widget="widget"})(yd||(yd={})),function(t){t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link"}(vd||(vd={}));var Hd=(gh=Zn.INIT_MODULE,Je=new yh,Ky(),Je.init(),Qy(),Je);var qd=Hd.init("phc_OTZ3wJ6VemgVupCRKS5Sbqb9Ks0JYe0hMYZPtLwl0nu",{api_host:"https://eu.posthog.com",ui_host:"https://eu.posthog.com",secure_cookie:document.location.protocol==="https:",persistence:"cookie",autocapture:!1,rageclick:!1,capture_pageview:!0,disable_session_recording:!0},"MolinShopAI");function dt(t,e){if(!qd)throw new Error("Failed to initialize PostHog");qd.capture(t,e)}var Ki,Ka,$t,Be,Qa,Ud,eo,Wd,to,Zd,ro,Yd,io,Jd,no,Xd,so,Kd,ao,Qd,Xa=class extends Fe(Pe){constructor(){super();W(this,Ki);W(this,Qa);W(this,eo);W(this,to);W(this,ro);W(this,io);W(this,no);W(this,so);W(this,ao);W(this,$t,new Ta(this,{url:(r,{resume:i}={})=>{let n=new URL(this.config.wsApiUrl);return n.searchParams.set("widgetId",this.widgetId),n.searchParams.set("resume",i?"1":""),n.searchParams.set("conversationId",r),n.searchParams.set("pageUrl",window.location.href),n},onReconnect:()=>{},onError:r=>{console.error("ws error",r),dt("ShopAssistant: error",{widgetId:this.widgetId,error:"websocket onError"})},onClose:()=>{},onNewMessage:r=>{r.role==="assistant"&&dt("ShopAssistant: user received bot message (streaming started)",{widgetId:this.widgetId,message:r})},onUpdateMessage:r=>{},onMessageDone:r=>{let i={...L(this,$t)?.messages.find(n=>n.id===r.message?.id)};Object.assign(i,r.message),i.role==="assistant"&&dt("ShopAssistant: user received bot message (streaming ended)",{widgetId:this.widgetId,text:i.content??"",message:i,usage_TOKENS_COMPLETION:r.message.usage.TOKENS_COMPLETION})},onMessageError:r=>{console.error("ws message error",r),r.message&&L(this,Be)&&alert(r.message),dt("ShopAssistant: error",{widgetId:this.widgetId,error:"websocket ERROR message type: "+r.message})},persistConversationState:(r,i)=>{let n={conversationId:r,messages:i};localStorage.setItem(L(this,Ki,Ka),JSON.stringify(n))},restoreConversationState:()=>{try{let r=JSON.parse(localStorage.getItem(L(this,Ki,Ka))||"{}");return!(typeof r.conversationId=="string"&&r.conversationId)||!(Array.isArray(r.messages)&&r.messages.every(i=>typeof i=="object"&&i))?void 0:{conversationId:r.conversationId,messages:r.messages}}catch(r){console.error(r)}},onReset:()=>{localStorage.removeItem(L(this,Ki,Ka))}}));W(this,Be,!1);this.widgetId="",this.config}render(){console.assert(this.widgetId,"widget id is required"),console.assert(this.config,"config is required");let r=Object.entries(this.config.bubble.position).filter(([a,o])=>o).map(([a,o])=>`${a}-[${o}]`).reduce((a,o)=>(a[o]=!0,a),{}),i={bottom:"72px"},n=Object.entries(this.config.bubble.position).filter(([a,o])=>o).map(([a,o])=>`sm:${a}-[calc(${[i[a],o].filter(l=>!!l).join("+")})]`).reduce((a,o)=>(a[o]=!0,a),{}),s=n;return ye`
|
|
420
|
+
`)).length,n=0;n<i;n++){var a=t.charCodeAt(n),o=null;a<128?r++:o=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),Ft(o)||(r>e&&(s+=t.substring(e,r)),s+=o,e=r=n+1)}return r>e&&(s+=t.substring(e,t.length)),s},qn=function(){function t(e){return e&&(e.preventDefault=t.preventDefault,e.stopPropagation=t.stopPropagation),e}return t.preventDefault=function(){this.returnValue=!1},t.stopPropagation=function(){this.cancelBubble=!0},function(e,r,i,n,s){if(e)if(e.addEventListener&&!n)e.addEventListener(r,i,!!s);else{var a="on"+r,o=e[a];e[a]=function(l,h,c){return function(u){if(u=u||t(O?.event)){var f,p=!0;jt(c)&&(f=c(u));var m=h.call(l,u);return f!==!1&&m!==!1||(p=!1),p}}}(e,i,o)}else j.error("No valid element provided to register_event")}}();function Un(t,e){var r=function(){if(!K)return e("document not found");var i=K.createElement("script");i.type="text/javascript",i.src=t,i.onload=function(a){return e(void 0,a)},i.onerror=function(a){return e(a)};var n,s=K.querySelectorAll("body > script");s.length>0?(n=s[0].parentNode)===null||n===void 0||n.insertBefore(i,s[0]):K.body.appendChild(i)};K!=null&&K.body?r():K?.addEventListener("DOMContentLoaded",r)}function ch(t){return t?Ga(t).split(/\s+/):[]}function Ha(t){var e="";switch(Hl(t.className)){case"string":e=t.className;break;case"object":e=("baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return ch(e)}function qa(t){var e="";return La(t)&&!Ad(t)&&t.childNodes&&t.childNodes.length&&Ce(t.childNodes,function(r){Pd(r)&&r.textContent&&(e+=Ga(r.textContent).split(/(\s+)/).filter(Wi).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),Ga(e)}function Zp(t){return!!t&&t.nodeType===1}function si(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Pd(t){return!!t&&t.nodeType===3}function Yp(t){return!!t&&t.nodeType===11}var Vl=["a","button","form","input","select","textarea","label"];function La(t){for(var e=t;e.parentNode&&!si(e,"body");e=e.parentNode){var r=Ha(e);if(xe(r,"ph-sensitive")||xe(r,"ph-no-capture"))return!1}if(xe(Ha(t),"ph-include"))return!0;var i=t.type||"";if(St(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var n=t.name||t.id||"";return!(St(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 Ad(t){return!!(si(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||si(t,"select")||si(t,"textarea")||t.getAttribute("contenteditable")==="true")}function Wi(t){return!(Ft(t)||ve(t)||St(t)&&(t=Ga(t),/^(?:(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}))$/.test((t||"").replace(/[- ]/g,""))||/(^\d{3}-?\d{2}-?\d{4}$)/.test(t)))}function Jp(t){var e=qa(t);return Wi(e="".concat(e," ").concat(Cd(t)).trim())?e:""}function Cd(t){var e="";return t&&t.childNodes&&t.childNodes.length&&Ce(t.childNodes,function(r){var i;if(r&&((i=r.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{var n=qa(r);e="".concat(e," ").concat(n).trim(),r.childNodes&&r.childNodes.length&&(e="".concat(e," ").concat(Cd(r)).trim())}catch(s){j.error(s)}}),e}function R0(t){return function(e){var r=e.map(function(i){var n,s,a="";if(i.tag_name&&(a+=i.tag_name),i.attr_class){i.attr_class.sort();var o,l=ai(i.attr_class);try{for(l.s();!(o=l.n()).done;){var h=o.value;a+=".".concat(h.replace(/"/g,""))}}catch(f){l.e(f)}finally{l.f()}}var c=ne(ne(ne(ne({},i.text?{text:i.text}:{}),{},{"nth-child":(n=i.nth_child)!==null&&n!==void 0?n:0,"nth-of-type":(s=i.nth_of_type)!==null&&s!==void 0?s:0},i.href?{href:i.href}:{}),i.attr_id?{attr_id:i.attr_id}:{}),i.attributes),u={};return Ra(c).sort(function(f,p){var m=zt(f,1)[0],g=zt(p,1)[0];return m.localeCompare(g)}).forEach(function(f){var p=zt(f,2),m=p[0],g=p[1];return u[Xp(m.toString())]=Xp(g.toString())}),a+=":",a+=Ra(c).map(function(f){var p=zt(f,2),m=p[0],g=p[1];return"".concat(m,'="').concat(g,'"')}).join("")});return r.join(";")}(function(e){return e.map(function(r){var i,n,s={text:(i=r.$el_text)===null||i===void 0?void 0:i.slice(0,400),tag_name:r.tag_name,href:(n=r.attr__href)===null||n===void 0?void 0:n.slice(0,2048),attr_class:L0(r),attr_id:r.attr__id,nth_child:r.nth_child,nth_of_type:r.nth_of_type,attributes:{}};return Ra(r).filter(function(a){return zt(a,1)[0].indexOf("attr__")===0}).forEach(function(a){var o=zt(a,2),l=o[0],h=o[1];return s.attributes[l]=h}),s})}(t))}function Xp(t){return t.replace(/"|\\"/g,'\\"')}function L0(t){var e=t.attr__class;return e?We(e)?e:ch(e):void 0}var B0=function(){function t(e){Oe(this,t),this.clicks=[],this.enabled=e}return Re(t,[{key:"isRageClick",value:function(e,r,i){if(!this.enabled)return!1;var n=this.clicks[this.clicks.length-1];if(n&&Math.abs(e-n.x)+Math.abs(r-n.y)<30&&i-n.timestamp<1e3){if(this.clicks.push({x:e,y:r,timestamp:i}),this.clicks.length===3)return!0}else this.clicks=[{x:e,y:r,timestamp:i}];return!1}}]),t}(),Td="$people_distinct_id",Ba="__alias",Gn="__timers",Kp="$autocapture_disabled_server_side",Jl="$session_recording_enabled_server_side",Qp="$console_log_recording_enabled_server_side",ed="$session_recording_recorder_version_server_side",td="$session_recording_network_payload_capture",Ua="$sesid",Va="$session_is_sampled",Zi="$enabled_feature_flags",Xl="$early_access_features",Yi="$stored_person_properties",kr="$stored_group_properties",Kl="$surveys",Wa="$flag_call_reported",Ql="$user_state",eh="$posthog_quota_limited",th="$client_session_props",V0=[Td,Ba,"__cmpns",Gn,Jl,Ua,Zi,Ql,eh,Xl,kr,Yi,Kl,Wa,th];function Nl(t,e){return e.length>t?e.slice(0,t)+"...":e}var Er={_initializedTokens:[],_isDisabledServerSide:null,_isAutocaptureEnabled:!1,_setIsAutocaptureEnabled:function(t){var e,r=Ft(this._isDisabledServerSide)?!((e=t.persistence)===null||e===void 0||!e.props[Kp]):this._isDisabledServerSide,i=!!t.config.autocapture;this._isAutocaptureEnabled=i&&!r},_previousElementSibling:function(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Zp(e));return e},_getAugmentPropertiesFromElement:function(t){if(!La(t))return{};var e={};return Ce(t.attributes,function(r){if(r.name.indexOf("data-ph-capture-attribute")===0){var i=r.name.replace("data-ph-capture-attribute-",""),n=r.value;i&&n&&Wi(n)&&(e[i]=n)}}),e},_getPropertiesFromElement:function(t,e,r){var i,n=t.tagName.toLowerCase(),s={tag_name:n};Vl.indexOf(n)>-1&&!r&&(n.toLowerCase()==="a"||n.toLowerCase()==="button"?s.$el_text=Nl(1024,Jp(t)):s.$el_text=Nl(1024,qa(t)));var a=Ha(t);a.length>0&&(s.classes=a.filter(function(u){return u!==""}));var o=(i=this.config)===null||i===void 0?void 0:i.element_attribute_ignorelist;Ce(t.attributes,function(u){var f;if((!Ad(t)||["name","id","class"].indexOf(u.name)!==-1)&&(o==null||!o.includes(u.name))&&!e&&Wi(u.value)&&(f=u.name,!St(f)||f.substring(0,10)!=="_ngcontent"&&f.substring(0,7)!=="_nghost")){var p=u.value;u.name==="class"&&(p=ch(p).join(" ")),s["attr__"+u.name]=Nl(1024,p)}});for(var l=1,h=1,c=t;c=this._previousElementSibling(c);)l++,c.tagName===t.tagName&&h++;return s.nth_child=l,s.nth_of_type=h,s},_getDefaultProperties:function(t){return{$event_type:t,$ce_version:1}},_extractCustomPropertyValue:function(t){var e=[];return Ce(K?.querySelectorAll(t.css_selector),function(r){var i;["input","select"].indexOf(r.tagName.toLowerCase())>-1?i=r.value:r.textContent&&(i=r.textContent),Wi(i)&&e.push(i)}),e.join(", ")},_getCustomProperties:function(t){var e=this,r={};return Ce(this._customProperties,function(i){Ce(i.event_selectors,function(n){Ce(K?.querySelectorAll(n),function(s){xe(t,s)&&La(s)&&(r[i.name]=e._extractCustomPropertyValue(i))})})}),r},_getEventTarget:function(t){return ve(t.target)?t.srcElement||null:(e=t.target)!==null&&e!==void 0&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e},_captureEvent:function(t,e){var r,i=this,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"$autocapture",s=this._getEventTarget(t);if(Pd(s)&&(s=s.parentNode||null),n==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,e,"$rageclick"),s&&function(g,d){var y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!O||!g||si(g,"html")||!Zp(g))return!1;if(y!=null&&y.url_allowlist){var v=O.location.href,b=y.url_allowlist;if(b&&!b.some(function(E){return v.match(E)}))return!1}if(y!=null&&y.dom_event_allowlist){var _=y.dom_event_allowlist;if(_&&!_.some(function(E){return d.type===E}))return!1}if(y!=null&&y.element_allowlist){var S=y.element_allowlist;if(S&&!S.some(function(E){return g.tagName.toLowerCase()===E}))return!1}if(y!=null&&y.css_selector_allowlist){var T=y.css_selector_allowlist;if(T&&!T.some(function(E){return g.matches(E)}))return!1}for(var x=!1,w=[g],M=!0,k=g;k.parentNode&&!si(k,"body");)if(Yp(k.parentNode))w.push(k.parentNode.host),k=k.parentNode.host;else{if(!(M=k.parentNode||!1))break;if(Vl.indexOf(M.tagName.toLowerCase())>-1)x=!0;else{var I=O.getComputedStyle(M);I&&I.getPropertyValue("cursor")==="pointer"&&(x=!0)}w.push(M),k=M}var P=O.getComputedStyle(g);if(P&&P.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0;var A=g.tagName.toLowerCase();switch(A){case"html":return!1;case"form":return d.type==="submit";case"input":case"select":case"textarea":return d.type==="change"||d.type==="click";default:return x?d.type==="click":d.type==="click"&&(Vl.indexOf(A)>-1||g.getAttribute("contenteditable")==="true")}}(s,t,this.config)){for(var a,o,l=[s],h=s;h.parentNode&&!si(h,"body");)Yp(h.parentNode)?(l.push(h.parentNode.host),h=h.parentNode.host):(l.push(h.parentNode),h=h.parentNode);var c,u=[],f={},p=!1;if(Ce(l,function(g){var d=La(g);g.tagName.toLowerCase()==="a"&&(c=g.getAttribute("href"),c=d&&Wi(c)&&c),xe(Ha(g),"ph-no-capture")&&(p=!0),u.push(i._getPropertiesFromElement(g,e.config.mask_all_element_attributes,e.config.mask_all_text));var y=i._getAugmentPropertiesFromElement(g);Ye(f,y)}),e.config.mask_all_text||(s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?u[0].$el_text=Jp(s):u[0].$el_text=qa(s)),c&&(u[0].attr__href=c),p)return!1;var m=Ye(this._getDefaultProperties(t.type),e.elementsChainAsString?{$elements_chain:R0(u)}:{$elements:u},(a=u[0])!==null&&a!==void 0&&a.$el_text?{$el_text:(o=u[0])===null||o===void 0?void 0:o.$el_text}:{},this._getCustomProperties(l),f);return e.capture(n,m),!0}},_navigate:function(t){O&&(O.location.href=t)},_addDomEventHandlers:function(t){var e=this;if(O&&K){var r=function(i){i=i||O?.event,e._captureEvent(i,t)};qn(K,"submit",r,!1,!0),qn(K,"change",r,!1,!0),qn(K,"click",r,!1,!0)}},_customProperties:[],rageclicks:null,config:void 0,init:function(t){var e;Zl(t.__autocapture)||(this.config=t.__autocapture),(e=this.config)!==null&&e!==void 0&&e.url_allowlist&&(this.config.url_allowlist=this.config.url_allowlist.map(function(r){return new RegExp(r)})),this.rageclicks=new B0(t.config.rageclick)},afterDecideResponse:function(t,e){var r=e.config.token;this._initializedTokens.indexOf(r)>-1?j.info('autocapture already initialized for token "'+r+'"'):(e.persistence&&e.persistence.register(Y({},Kp,!!t.autocapture_opt_out)),this._isDisabledServerSide=!!t.autocapture_opt_out,this._setIsAutocaptureEnabled(e),this._initializedTokens.push(r),t&&t.config&&t.config.enable_collect_everything&&this._isAutocaptureEnabled?(t.custom_properties&&(this._customProperties=t.custom_properties),this._addDomEventHandlers(e)):e.__autocapture=!1)},enabledForProject:function(t,e,r){if(!t)return!0;e=ve(e)?10:e,r=ve(r)?10:r;for(var i=0,n=0;n<t.length;n++)i+=t.charCodeAt(n);return i%e<r},isBrowserSupported:function(){return jt(K?.querySelectorAll)}};(function(t){for(var e in t)jt(t[e])&&(t[e]=t[e].bind(t))})(Er),function(t){for(var e in t)jt(t[e])&&(t[e]=Ed(t[e]))}(Er);var zl="$active_feature_flags",Ma="$override_feature_flags",rd="$feature_flag_payloads",id=function(t){var e,r={},i=ai(Ra(t||{}));try{for(i.s();!(e=i.n()).done;){var n=zt(e.value,2),s=n[0],a=n[1];a&&(r[s]=a)}}catch(o){i.e(o)}finally{i.f()}return r},N0=function(){function t(e){Oe(this,t),this.instance=e,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return Re(t,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var e=this.instance.get_property(Zi),r=this.instance.get_property(Ma);if(!r)return e||{};for(var i=Ye({},e),n=Object.keys(r),s=0;s<n.length;s++)r[n[s]]===!1?delete i[n[s]]:i[n[s]]=r[n[s]];return this._override_warning||(j.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:r,finalFlags:i}),this._override_warning=!0),i}},{key:"getFlagPayloads",value:function(){return this.instance.get_property(rd)||{}}},{key:"reloadFeatureFlags",value:function(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}},{key:"setAnonymousDistinctId",value:function(e){this.$anon_distinct_id=e}},{key:"setReloadingPaused",value:function(e){this.reloadFeatureFlagsInAction=e}},{key:"resetRequestQueue",value:function(){this.reloadFeatureFlagsQueued=!1}},{key:"_startReloadTimer",value:function(){var e=this;this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout(function(){!e.reloadFeatureFlagsInAction&&e.reloadFeatureFlagsQueued&&(e.reloadFeatureFlagsQueued=!1,e._reloadFeatureFlagsRequest())},5)}},{key:"_reloadFeatureFlagsRequest",value:function(){var e=this;if(!this.instance.config.advanced_disable_feature_flags){this.setReloadingPaused(!0);var r=this.instance.config.token,i=this.instance.get_property(Yi),n=this.instance.get_property(kr),s=hh(JSON.stringify({token:r,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i,group_properties:n,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0}));this.instance._send_request(this.instance.config.api_host+"/decide/?v=3",{data:s},{method:"POST"},this.instance._prepare_callback(function(a){e.$anon_distinct_id=void 0,e.receivedFeatureFlags(a),e.setReloadingPaused(!1),e._startReloadTimer()}))}}},{key:"getFeatureFlag",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0){var i,n=this.getFlagVariants()[e],s="".concat(n),a=this.instance.get_property(Wa)||{};return(r.send_event||!("send_event"in r))&&(!(e in a)||!a[e].includes(s))&&(We(a[e])?a[e].push(s):a[e]=[s],(i=this.instance.persistence)===null||i===void 0||i.register(Y({},Wa,a)),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:n})),n}j.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}},{key:"getFeatureFlagPayload",value:function(e){return this.getFlagPayloads()[e]}},{key:"isFeatureEnabled",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,r);j.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}},{key:"addFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers.push(e)}},{key:"removeFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(function(r){return r!==e})}},{key:"receivedFeatureFlags",value:function(e){if(this.instance.persistence){this.instance.decideEndpointWasHit=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads();(function(n,s){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=n.featureFlags,h=n.featureFlagPayloads;if(l)if(We(l)){var c,u={};if(l)for(var f=0;f<l.length;f++)u[l[f]]=!0;s&&s.register((Y(c={},zl,l),Y(c,Zi,u),c))}else{var p,m=l,g=h;n.errorsWhileComputingFlags&&(m=ne(ne({},a),m),g=ne(ne({},o),g)),s&&s.register((Y(p={},zl,Object.keys(id(m))),Y(p,Zi,m||{}),Y(p,rd,g||{}),p))}})(e,this.instance.persistence,r,i),this._fireFeatureFlagsCallbacks()}}},{key:"override",value:function(e){if(!this.instance.__loaded||!this.instance.persistence)return j.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=!1,e===!1)this.instance.persistence.unregister(Ma);else if(We(e)){for(var r={},i=0;i<e.length;i++)r[e[i]]=!0;this.instance.persistence.register(Y({},Ma,r))}else this.instance.persistence.register(Y({},Ma,e))}},{key:"onFeatureFlags",value:function(e){var r=this;if(this.addFeatureFlagsHandler(e),this.instance.decideEndpointWasHit){var i=this._prepareFeatureFlagsForCallbacks(),n=i.flags,s=i.flagVariants;e(n,s)}return function(){return r.removeFeatureFlagsHandler(e)}}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,r){var i,n,s=Y({},"$feature_enrollment/".concat(e),r);this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:r,$set:s}),this.setPersonPropertiesForFlags(s,!1);var a=ne(ne({},this.getFlagVariants()),{},Y({},e,r));(i=this.instance.persistence)===null||i===void 0||i.register((Y(n={},zl,Object.keys(id(a))),Y(n,Zi,a),n)),this._fireFeatureFlagsCallbacks()}},{key:"getEarlyAccessFeatures",value:function(e){var r=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.instance.get_property(Xl);if(n&&!i)return e(n);this.instance._send_request("".concat(this.instance.config.api_host,"/api/early_access_features/?token=").concat(this.instance.config.token),{},{method:"GET"},function(s){var a,o=s.earlyAccessFeatures;return(a=r.instance.persistence)===null||a===void 0||a.register(Y({},Xl,o)),e(o)})}},{key:"_prepareFeatureFlagsForCallbacks",value:function(){var e=this.getFlags(),r=this.getFlagVariants();return{flags:e.filter(function(i){return r[i]}),flagVariants:Object.keys(r).filter(function(i){return r[i]}).reduce(function(i,n){return i[n]=r[n],i},{})}}},{key:"_fireFeatureFlagsCallbacks",value:function(){var e=this._prepareFeatureFlagsForCallbacks(),r=e.flags,i=e.flagVariants;this.featureFlagEventHandlers.forEach(function(n){return n(r,i)})}},{key:"setPersonPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],i=this.instance.get_property(Yi)||{};this.instance.register(Y({},Yi,ne(ne({},i),e))),r&&this.instance.reloadFeatureFlags()}},{key:"resetPersonPropertiesForFlags",value:function(){this.instance.unregister(Yi)}},{key:"setGroupPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],i=this.instance.get_property(kr)||{};Object.keys(i).length!==0&&Object.keys(i).forEach(function(n){i[n]=ne(ne({},i[n]),e[n]),delete e[n]}),this.instance.register(Y({},kr,ne(ne({},i),e))),r&&this.instance.reloadFeatureFlags()}},{key:"resetGroupPropertiesForFlags",value:function(e){if(e){var r=this.instance.get_property(kr)||{};this.instance.register(Y({},kr,ne(ne({},r),{},Y({},e,{}))))}else this.instance.unregister(kr)}}]),t}();Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return cr(t)&&isFinite(t)&&Math.floor(t)===t});var nd="0123456789abcdef",z0=function(){function t(e){if(Oe(this,t),this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}return Re(t,[{key:"toString",value:function(){for(var e="",r=0;r<this.bytes.length;r++)e=e+nd.charAt(this.bytes[r]>>>4)+nd.charAt(15&this.bytes[r]),r!==3&&r!==5&&r!==7&&r!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}},{key:"clone",value:function(){return new t(this.bytes.slice(0))}},{key:"equals",value:function(e){return this.compareTo(e)===0}},{key:"compareTo",value:function(e){for(var r=0;r<16;r++){var i=this.bytes[r]-e.bytes[r];if(i!==0)return Math.sign(i)}return 0}}],[{key:"fromFieldsV7",value:function(e,r,i,n){if(!Number.isInteger(e)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||e<0||r<0||i<0||n<0||e>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|r>>>8,s[7]=r,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=n>>>24,s[13]=n>>>16,s[14]=n>>>8,s[15]=n,new t(s)}}]),t}(),j0=function(){function t(){Oe(this,t),Y(this,"timestamp",0),Y(this,"counter",0),Y(this,"random",new G0)}return Re(t,[{key:"generate",value:function(){var e=this.generateOrAbort();if(ve(e)){this.timestamp=0;var r=this.generateOrAbort();if(ve(r))throw new Error("Could not generate UUID after timestamp reset");return r}return e}},{key:"generateOrAbort",value:function(){var e=Date.now();if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return z0.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}},{key:"resetCounter",value:function(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}]),t}(),Id=function(t){if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<t.length;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};O&&!ve(O.crypto)&&crypto.getRandomValues&&(Id=function(t){return crypto.getRandomValues(t)});var sd,G0=function(){function t(){Oe(this,t),Y(this,"buffer",new Uint32Array(8)),Y(this,"cursor",1/0)}return Re(t,[{key:"nextUint32",value:function(){return this.cursor>=this.buffer.length&&(Id(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}]),t}(),ni=function(){return H0().toString()},H0=function(){return(sd||(sd=new j0)).generate()},q0="Thu, 01 Jan 1970 00:00:00 GMT",Nn="",U0=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,W0=function(t){var e=t.match(U0);return e?e[0]:""};function Z0(t,e){if(e){var r=function(n){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:K;if(Nn)return Nn;if(!s||["localhost","127.0.0.1"].includes(n))return"";for(var a=n.split("."),o=Math.min(a.length,8),l="dmn_chk_"+ni(),h=new RegExp("(^|;)\\s*"+l+"=1");!Nn&&o--;){var c=a.slice(o).join("."),u=l+"=1;domain=."+c;s.cookie=u,h.test(s.cookie)&&(s.cookie=u+";expires="+q0,Nn=c)}return Nn}(t);if(!r){var i=W0(t);i!==r&&j.info("Warning: cookie subdomain discovery mismatch",i,r),r=i}return r?"; domain=."+r:""}return""}var Jt={is_supported:function(){return!!K},error:function(t){j.error("cookieStore error: "+t)},get:function(t){if(K){try{for(var e=t+"=",r=K.cookie.split(";").filter(function(s){return s.length}),i=0;i<r.length;i++){for(var n=r[i];n.charAt(0)==" ";)n=n.substring(1,n.length);if(n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length,n.length))}}catch{}return null}},parse:function(t){var e;try{e=JSON.parse(Jt.get(t))||{}}catch{}return e},set:function(t,e,r,i,n){if(K)try{var s="",a="",o=Z0(K.location.hostname,i);if(r){var l=new Date;l.setTime(l.getTime()+24*r*60*60*1e3),s="; expires="+l.toUTCString()}n&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+o+a;return h.length>3686.4&&j.warn("cookieStore warning: large cookie, len="+h.length),K.cookie=h,h}catch{return}},remove:function(t,e){try{Jt.set(t,"",-1,e)}catch{return}}},jl=null,Le={is_supported:function(){if(!Ft(jl))return jl;var t=!0;if(ve(O))t=!1;else try{var e="__mplssupport__";Le.set(e,"xyz"),Le.get(e)!=='"xyz"'&&(t=!1),Le.remove(e)}catch{t=!1}return t||j.error("localStorage unsupported; falling back to cookie store"),jl=t,t},error:function(t){j.error("localStorage error: "+t)},get:function(t){try{return O?.localStorage.getItem(t)}catch(e){Le.error(e)}return null},parse:function(t){try{return JSON.parse(Le.get(t))||{}}catch{}return null},set:function(t,e){try{O?.localStorage.setItem(t,JSON.stringify(e))}catch(r){Le.error(r)}},remove:function(t){try{O?.localStorage.removeItem(t)}catch(e){Le.error(e)}}},Y0=["distinct_id",Ua,Va],Hn=ne(ne({},Le),{},{parse:function(t){try{var e={};try{e=Jt.parse(t)||{}}catch{}var r=Ye(e,JSON.parse(Le.get(t)||"{}"));return Le.set(t,r),r}catch{}return null},set:function(t,e,r,i,n){try{Le.set(t,e);var s={};Y0.forEach(function(a){e[a]&&(s[a]=e[a])}),Object.keys(s).length&&Jt.set(t,s,r,i,n)}catch(a){Le.error(a)}},remove:function(t,e){try{O?.localStorage.removeItem(t),Jt.remove(t,e)}catch(r){Le.error(r)}}}),Da={},J0={is_supported:function(){return!0},error:function(t){j.error("memoryStorage error: "+t)},get:function(t){return Da[t]||null},parse:function(t){return Da[t]||null},set:function(t,e){Da[t]=e},remove:function(t){delete Da[t]}},ri=null,Xe={is_supported:function(){if(!Ft(ri))return ri;if(ri=!0,ve(O))ri=!1;else try{var t="__support__";Xe.set(t,"xyz"),Xe.get(t)!=='"xyz"'&&(ri=!1),Xe.remove(t)}catch{ri=!1}return ri},error:function(t){j.error("sessionStorage error: ",t)},get:function(t){try{return O?.sessionStorage.getItem(t)}catch(e){Xe.error(e)}return null},parse:function(t){try{return JSON.parse(Xe.get(t))||null}catch{}return null},set:function(t,e){try{O?.sessionStorage.setItem(t,JSON.stringify(e))}catch(r){Xe.error(r)}},remove:function(t){try{O?.sessionStorage.removeItem(t)}catch(e){Xe.error(e)}}},X0=["localhost","127.0.0.1"],Md=function(t){var e=K?.createElement("a");return ve(e)?null:(e.href=t,e)},K0=function(t,e){return!!function(r){try{new RegExp(r)}catch{return!1}return!0}(e)&&new RegExp(e).test(t)},ad=function(t,e){for(var r,i=((t.split("#")[0]||"").split("?")[1]||"").split("&"),n=0;n<i.length;n++){var s=i[n].split("=");if(s[0]===e){r=s;break}}if(!We(r)||r.length<2)return"";var a=r[1];try{a=decodeURIComponent(a)}catch{j.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Za=function(t,e){var r=t.match(new RegExp(e+"=([^&]*)"));return r?r[1]:null},He={campaignParams:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gbraid","wbraid","fbclid","msclkid"].concat(t||[]),r={};return Ce(e,function(i){var n=K?ad(K.URL,i):"";n.length&&(r[i]=n)}),r},searchEngine:function(){var t=K?.referrer;return t?t.search("https?://(.*)google.([^/?]*)")===0?"google":t.search("https?://(.*)bing.com")===0?"bing":t.search("https?://(.*)yahoo.com")===0?"yahoo":t.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null},searchInfo:function(){var t=He.searchEngine(),e=t!="yahoo"?"q":"p",r={};if(!Ft(t)){r.$search_engine=t;var i=K?ad(K.referrer,e):"";i.length&&(r.ph_keyword=i)}return r},browser:function(t,e,r){return e=e||"",r||xe(t," OPR/")?xe(t,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":xe(t,"IEMobile")||xe(t,"WPDesktop")?"Internet Explorer Mobile":xe(t,"SamsungBrowser/")?"Samsung Internet":xe(t,"Edge")||xe(t,"Edg/")?"Microsoft Edge":xe(t,"FBIOS")?"Facebook Mobile":xe(t,"Chrome")?"Chrome":xe(t,"CriOS")?"Chrome iOS":xe(t,"UCWEB")||xe(t,"UCBrowser")?"UC Browser":xe(t,"FxiOS")?"Firefox iOS":xe(e,"Apple")||function(i){return xe(i,"Safari")&&!xe(i,"Chrome")&&!xe(i,"Android")}(t)?xe(t,"Mobile")?"Mobile Safari":"Safari":xe(t,"Android")?"Android Mobile":xe(t,"Konqueror")||xe(t,"konqueror")?"Konqueror":xe(t,"Firefox")?"Firefox":xe(t,"MSIE")||xe(t,"Trident/")?"Internet Explorer":xe(t,"Gecko")?"Mozilla":""},browserVersion:function(t,e,r){var i={"Internet Explorer Mobile":[/rv:(\d+(\.\d+)?)/],"Microsoft Edge":[/Edge?\/(\d+(\.\d+)?)/],Chrome:[/Chrome\/(\d+(\.\d+)?)/],"Chrome iOS":[/CriOS\/(\d+(\.\d+)?)/],"UC Browser":[/(UCBrowser|UCWEB)\/(\d+(\.\d+)?)/],Safari:[/Version\/(\d+(\.\d+)?)/],"Mobile Safari":[/Version\/(\d+(\.\d+)?)/],Opera:[/(Opera|OPR)\/(\d+(\.\d+)?)/],Firefox:[/Firefox\/(\d+(\.\d+)?)/],"Firefox iOS":[/FxiOS\/(\d+(\.\d+)?)/],Konqueror:[/Konqueror[:/]?(\d+(\.\d+)?)/i],BlackBerry:[/BlackBerry (\d+(\.\d+)?)/,/Version\/(\d+(\.\d+)?)/],"Android Mobile":[/android\s(\d+(\.\d+)?)/],"Samsung Internet":[/SamsungBrowser\/(\d+(\.\d+)?)/],"Internet Explorer":[/(rv:|MSIE )(\d+(\.\d+)?)/],Mozilla:[/rv:(\d+(\.\d+)?)/]}[He.browser(t,e,r)];if(ve(i))return null;for(var n=0;n<i.length;n++){var s=i[n],a=t.match(s);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},os:function(t){if(/Windows/i.test(t)){if(/Phone/.test(t)||/WPDesktop/.test(t))return{os_name:"Windows Phone",os_version:""};var e=/Windows NT ([0-9.]+)/i.exec(t);return e&&e[1]?{os_name:"Windows",os_version:e[1]}:{os_name:"Windows",os_version:""}}if(/(iPhone|iPad|iPod)/.test(t)){var r=/OS (\d+)_(\d+)_?(\d+)?/i.exec(t);return r&&r[1]?{os_name:"iOS",os_version:[r[1],r[2],r[3]||"0"].join(".")}:{os_name:"iOS",os_version:""}}if(/Android/.test(t)){var i=/Android (\d+)\.(\d+)\.?(\d+)?/i.exec(t);return i&&i[1]?{os_name:"Android",os_version:[i[1],i[2],i[3]||"0"].join(".")}:{os_name:"Android",os_version:""}}if(/(BlackBerry|PlayBook|BB10)/i.test(t))return{os_name:"BlackBerry",os_version:""};if(/Mac/i.test(t)){var n=/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i.exec(t);return n&&n[1]?{os_name:"Mac OS X",os_version:[n[1],n[2],n[3]||"0"].join(".")}:{os_name:"Mac OS X",os_version:""}}return/Linux/.test(t)?{os_name:"Linux",os_version:""}:/CrOS/.test(t)?{os_name:"Chrome OS",os_version:""}:{os_name:"",os_version:""}},device:function(t){return/Windows Phone/i.test(t)||/WPDesktop/.test(t)?"Windows Phone":/iPad/.test(t)?"iPad":/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":/Android/.test(t)&&!/Mobile/.test(t)?"Android Tablet":/Android/.test(t)?"Android":""},deviceType:function(t){var e=this.device(t);return e==="iPad"||e==="Android Tablet"?"Tablet":e?"Mobile":"Desktop"},referrer:function(){return K?.referrer||"$direct"},referringDomain:function(){var t;return K!=null&&K.referrer&&((t=Md(K.referrer))===null||t===void 0?void 0:t.host)||"$direct"},properties:function(){if(!Ge)return{};var t=He.os(Ge),e=t.os_name,r=t.os_version;return Ye(Yl({$os:e,$os_version:r,$browser:He.browser(Ge,navigator.vendor,tt.opera),$device:He.device(Ge),$device_type:He.deviceType(Ge)}),{$current_url:O?.location.href,$host:O?.location.host,$pathname:O?.location.pathname,$raw_user_agent:Ge.length>1e3?Ge.substring(0,997)+"...":Ge,$browser_version:He.browserVersion(Ge,navigator.vendor,tt.opera),$browser_language:He.browserLanguage(),$screen_height:O?.screen.height,$screen_width:O?.screen.width,$viewport_height:O?.innerHeight,$viewport_width:O?.innerWidth,$lib:"web",$lib_version:oi.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:kd()/1e3})},people_properties:function(){if(!Ge)return{};var t=He.os(Ge),e=t.os_name,r=t.os_version;return Ye(Yl({$os:e,$os_version:r,$browser:He.browser(Ge,navigator.vendor,tt.opera)}),{$browser_version:He.browserVersion(Ge,navigator.vendor,tt.opera)})}},Q0=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],od=function(){function t(e){Oe(this,t);var r="";e.token&&(r=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),this.props={},this.campaign_params_saved=!1,this.custom_campaign_params=e.custom_campaign_params||[],e.persistence_name?this.name="ph_"+e.persistence_name:this.name="ph_"+r+"_posthog",Q0.indexOf(e.persistence.toLowerCase())===-1&&(j.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i=e.persistence.toLowerCase();i==="localstorage"&&Le.is_supported()?this.storage=Le:i==="localstorage+cookie"&&Hn.is_supported()?this.storage=Hn:i==="sessionstorage"&&Xe.is_supported()?this.storage=Xe:i==="memory"?this.storage=J0:i==="cookie"?this.storage=Jt:Hn.is_supported()?this.storage=Hn:this.storage=Jt,this.user_state="anonymous",this.load(),this.update_config(e),this.save()}return Re(t,[{key:"properties",value:function(){var e={};return Ce(this.props,function(r,i){if(i===Zi&&Pr(r))for(var n=Object.keys(r),s=0;s<n.length;s++)e["$feature/".concat(n[s])]=r[n[s]];else o=i,l=!1,(Ft(a=V0)?l:Hp&&a.indexOf===Hp?a.indexOf(o)!=-1:(Ce(a,function(h){if(l||(l=h===o))return lh}),l))||(e[i]=r);var a,o,l}),e}},{key:"load",value:function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=Ye({},e))}}},{key:"save",value:function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure)}},{key:"remove",value:function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}},{key:"clear",value:function(){this.remove(),this.props={}}},{key:"register_once",value:function(e,r,i){var n=this;if(Pr(e)){ve(r)&&(r="None"),this.expire_days=ve(i)?this.default_expiry:i;var s=!1;if(Ce(e,function(a,o){n.props.hasOwnProperty(o)&&n.props[o]!==r||(n.props[o]=a,s=!0)}),s)return this.save(),!0}return!1}},{key:"register",value:function(e,r){var i=this;if(Pr(e)){this.expire_days=ve(r)?this.default_expiry:r;var n=!1;if(Ce(e,function(s,a){e.hasOwnProperty(a)&&i.props[a]!==s&&(i.props[a]=s,n=!0)}),n)return this.save(),!0}return!1}},{key:"unregister",value:function(e){e in this.props&&(delete this.props[e],this.save())}},{key:"update_campaign_params",value:function(){this.campaign_params_saved||(this.register(He.campaignParams(this.custom_campaign_params)),this.campaign_params_saved=!0)}},{key:"update_search_keyword",value:function(){this.register(He.searchInfo())}},{key:"update_referrer_info",value:function(){this.register({$referrer:this.props.$referrer||He.referrer(),$referring_domain:this.props.$referring_domain||He.referringDomain()})}},{key:"get_referrer_info",value:function(){return Yl({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}},{key:"safe_merge",value:function(e){return Ce(this.props,function(r,i){i in e||(e[i]=r)}),e}},{key:"update_config",value:function(e){this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie)}},{key:"set_disabled",value:function(e){this.disabled=e,this.disabled?this.remove():this.save()}},{key:"set_cross_subdomain",value:function(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())}},{key:"get_cross_subdomain",value:function(){return!!this.cross_subdomain}},{key:"set_secure",value:function(e){e!==this.secure&&(this.secure=e,this.remove(),this.save())}},{key:"set_event_timer",value:function(e,r){var i=this.props[Gn]||{};i[e]=r,this.props[Gn]=i,this.save()}},{key:"remove_event_timer",value:function(e){var r=(this.props[Gn]||{})[e];return ve(r)||(delete this.props[Gn][e],this.save()),r}},{key:"get_user_state",value:function(){return this.props[Ql]||"anonymous"}},{key:"set_user_state",value:function(e){this.props[Ql]=e,this.save()}},{key:"get_quota_limits",value:function(){return this.props[eh]||{}}},{key:"set_quota_limits",value:function(e){this.props[eh]=e,this.save()}}]),t}(),ld=2,ey=4,Dd=3,ty=6,ry=0,iy="rrweb/console@1",ny=Re(function t(e){var r,i,n=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Oe(this,t),Y(this,"bucketSize",100),Y(this,"refillRate",10),Y(this,"mutationBuckets",{}),Y(this,"loggedTracker",{}),Y(this,"refillBuckets",function(){Object.keys(n.mutationBuckets).forEach(function(a){n.mutationBuckets[a]=n.mutationBuckets[a]+n.refillRate,n.mutationBuckets[a]>=n.bucketSize&&delete n.mutationBuckets[a]})}),Y(this,"getNodeOrRelevantParent",function(a){var o=n.rrweb.mirror.getNode(a);if(o?.nodeName!=="svg"&&o instanceof Element){var l=o.closest("svg");if(l)return[n.rrweb.mirror.getId(l),l]}return[a,o]}),Y(this,"numberOfChanges",function(a){var o,l,h,c,u,f,p,m;return((o=(l=a.removes)===null||l===void 0?void 0:l.length)!==null&&o!==void 0?o:0)+((h=(c=a.attributes)===null||c===void 0?void 0:c.length)!==null&&h!==void 0?h:0)+((u=(f=a.texts)===null||f===void 0?void 0:f.length)!==null&&u!==void 0?u:0)+((p=(m=a.adds)===null||m===void 0?void 0:m.length)!==null&&p!==void 0?p:0)}),Y(this,"throttleMutations",function(a){if(a.type!==Dd||a.data.source!==ry)return a;var o=a.data,l=n.numberOfChanges(o);o.attributes&&(o.attributes=o.attributes.filter(function(c){var u,f,p,m=zt(n.getNodeOrRelevantParent(c.id),2),g=m[0],d=m[1];return n.mutationBuckets[g]===0?!1:(n.mutationBuckets[g]=(u=n.mutationBuckets[g])!==null&&u!==void 0?u:n.bucketSize,n.mutationBuckets[g]=Math.max(n.mutationBuckets[g]-1,0),n.mutationBuckets[g]===0&&(n.loggedTracker[g]||(n.loggedTracker[g]=!0,(f=(p=n.options).onBlockedNode)===null||f===void 0||f.call(p,g,d))),c)}));var h=n.numberOfChanges(o);return h!==0||l===h?a:void 0}),this.rrweb=e,this.options=s,this.refillRate=(r=this.options.refillRate)!==null&&r!==void 0?r:this.refillRate,this.bucketSize=(i=this.options.bucketSize)!==null&&i!==void 0?i:this.bucketSize,setInterval(function(){n.refillBuckets()},1e3)}),Fd=function(t){return t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t}(Fd||{}),sy={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:function(t){return t},recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6},ay=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],oy=["/s/","/e/","/i/vo/e/"];function hd(t,e,r,i){var n=e?.["content-length"];return n&&parseInt(n)>r?"".concat(i," body too large to record"):t}var Yt,ly=function(t,e){var r,i,n,s=t.session_recording,a=s.recordHeaders!==!1&&e.recordHeaders,o=s.recordBody!==!1&&e.recordBody,l=s.recordPerformance!==!1&&e.recordPerformance,h=(r=s,n=Math.min(1e6,(i=r.payloadSizeLimitBytes)!==null&&i!==void 0?i:1e6),function(f){return f!=null&&f.requestBody&&(f.requestBody=hd(f.requestBody,f.requestHeaders,n,"Request")),f!=null&&f.responseBody&&(f.responseBody=hd(f.responseBody,f.responseHeaders,n,"Response")),f}),c=function(f){return h(function(g){var d=Md(g.name);if(!(d&&d.pathname&&oy.includes(d.pathname)))return g}((p=f,Object.keys((m=p.requestHeaders)!==null&&m!==void 0?m:{}).forEach(function(g){var d;ay.includes(g.toLowerCase())&&((d=p.requestHeaders)===null||d===void 0||delete d[g])}),p)));var p,m},u=jt(t.session_recording.maskNetworkRequestFn);return u&&jt(t.session_recording.maskCapturedNetworkRequestFn)&&j.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),u&&(t.session_recording.maskCapturedNetworkRequestFn=function(f){var p=t.session_recording.maskNetworkRequestFn({url:f.name});return ne(ne({},f),{},{name:p?.url})}),s.maskRequestFn=jt(t.session_recording.maskCapturedNetworkRequestFn)?function(f){var p,m,g,d=c(f);return d&&(p=(m=(g=t.session_recording).maskCapturedNetworkRequestFn)===null||m===void 0?void 0:m.call(g,d))!==null&&p!==void 0?p:void 0}:void 0,s.maskRequestFn||(s.maskRequestFn=c),ne(ne(ne({},sy),s),{},{recordHeaders:a,recordBody:o,recordPerformance:l,recordInitialRequests:l})},hy="/s/",cd=3e5;(function(t){t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet"})(Yt||(Yt={}));var cy=[Yt.MouseMove,Yt.MouseInteraction,Yt.Scroll,Yt.ViewportResize,Yt.Input,Yt.TouchMove,Yt.MediaInteraction,Yt.Drag],uy=function(){function t(e){var r=this;if(Oe(this,t),Y(this,"isIdle",!1),Y(this,"_linkedFlagSeen",!1),Y(this,"_lastActivityTimestamp",Date.now()),Y(this,"windowId",null),Y(this,"sessionId",null),Y(this,"_linkedFlag",null),Y(this,"_sampleRate",null),Y(this,"_minimumDuration",null),Y(this,"_forceAllowLocalhostNetworkCapture",!1),this.instance=e,this._captureStarted=!1,this._endpoint=hy,this.stopRrweb=void 0,this.receivedDecide=!1,O?.addEventListener("beforeunload",function(){r._flushBuffer()}),!this.instance.sessionManager)throw j.error("Session recording started without valid sessionManager"),new Error("Session recording started without valid sessionManager. This is a bug.");this.buffer=this.clearBuffer()}return Re(t,[{key:"started",get:function(){return this._captureStarted}},{key:"sessionManager",get:function(){if(!this.instance.sessionManager)throw j.error("Session recording started without valid sessionManager"),new Error("Session recording started without valid sessionManager. This is a bug.");return this.instance.sessionManager}},{key:"isSampled",get:function(){return cr(this._sampleRate)?this.instance.get_property(Va):null}},{key:"sessionDuration",get:function(){var e,r,i=(e=this.buffer)===null||e===void 0?void 0:e.data[((r=this.buffer)===null||r===void 0?void 0:r.data.length)-1],n=this.sessionManager.checkAndGetSessionAndWindowId(!0).sessionStartTimestamp;return i?i.timestamp-n:null}},{key:"isRecordingEnabled",get:function(){var e=!!this.instance.get_property(Jl),r=!this.instance.config.disable_session_recording;return O&&e&&r}},{key:"isConsoleLogCaptureEnabled",get:function(){var e=!!this.instance.get_property(Qp),r=this.instance.config.enable_recording_console_log;return r??e}},{key:"recordingVersion",get:function(){var e,r=this.instance.get_property(ed);return((e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recorderVersion)||r||"v1"}},{key:"networkPayloadCapture",get:function(){var e,r,i=this.instance.get_property(td),n={recordHeaders:(e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recordHeaders,recordBody:(r=this.instance.config.session_recording)===null||r===void 0?void 0:r.recordBody},s=n?.recordHeaders||i?.recordHeaders,a=n?.recordBody||i?.recordBody,o=this.instance.config.capture_performance||i?.capturePerformance;return s||a||o?{recordHeaders:s,recordBody:a,recordPerformance:o}:void 0}},{key:"status",get:function(){return this.receivedDecide?this.isRecordingEnabled?St(this._linkedFlag)&&!this._linkedFlagSeen?"buffering":Zl(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"disabled":"buffering"}},{key:"startRecordingIfEnabled",value:function(){this.isRecordingEnabled?this.startCaptureAndTrySendingQueuedSnapshots():(this.stopRecording(),this.clearBuffer())}},{key:"stopRecording",value:function(){this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1)}},{key:"makeSamplingDecision",value:function(e){var r,i=this.sessionId!==e;if(cr(this._sampleRate)){var n,s=this.isSampled;i||!Zl(s)?n=Math.random()<this._sampleRate:n=s,n||j.warn("[SessionSampling] Sample rate (".concat(this._sampleRate,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),(r=this.instance.persistence)===null||r===void 0||r.register(Y({},Va,n))}else{var a;(a=this.instance.persistence)===null||a===void 0||a.register(Y({},Va,null))}}},{key:"afterDecideResponse",value:function(e){var r,i,n,s,a,o,l,h,c=this;this.instance.persistence&&this.instance.persistence.register((Y(h={},Jl,!!e.sessionRecording),Y(h,Qp,(a=e.sessionRecording)===null||a===void 0?void 0:a.consoleLogRecordingEnabled),Y(h,ed,(o=e.sessionRecording)===null||o===void 0?void 0:o.recorderVersion),Y(h,td,ne({capturePerformance:e.capturePerformance},(l=e.sessionRecording)===null||l===void 0?void 0:l.networkPayloadCapture)),h));var u=(r=e.sessionRecording)===null||r===void 0?void 0:r.sampleRate;this._sampleRate=ve(u)||Ft(u)?null:parseFloat(u);var f,p=(i=e.sessionRecording)===null||i===void 0?void 0:i.minimumDurationMilliseconds;if(this._minimumDuration=ve(p)?null:p,this._linkedFlag=((n=e.sessionRecording)===null||n===void 0?void 0:n.linkedFlag)||null,(s=e.sessionRecording)!==null&&s!==void 0&&s.endpoint&&(this._endpoint=(f=e.sessionRecording)===null||f===void 0?void 0:f.endpoint),cr(this._sampleRate)&&this.sessionManager.onSessionId(function(g){c.makeSamplingDecision(g)}),St(this._linkedFlag)){var m=this._linkedFlag;this.instance.onFeatureFlags(function(g){c._linkedFlagSeen=g.includes(m)})}this.receivedDecide=!0,this.startRecordingIfEnabled()}},{key:"log",value:function(e){var r,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(r=this.instance.sessionRecording)===null||r===void 0||r.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:kd()})}},{key:"startCaptureAndTrySendingQueuedSnapshots",value:function(){this._startCapture()}},{key:"_startCapture",value:function(){var e=this;if(!ve(Object.assign)&&!this._captureStarted&&!this.instance.config.disable_session_recording){this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId();var r=this.recordingVersion==="v2"?"recorder-v2.js":"recorder.js";this.instance.__loaded_recorder_version!==this.recordingVersion?Un(this.instance.config.api_host+"/static/".concat(r,"?v=").concat(oi.LIB_VERSION),function(i){if(i)return j.error("Could not load ".concat(r),i);e._onScriptLoaded()}):this._onScriptLoaded()}}},{key:"_isInteractiveEvent",value:function(e){var r;return e.type===Dd&&cy.indexOf((r=e.data)===null||r===void 0?void 0:r.source)!==-1}},{key:"_updateWindowAndSessionIds",value:function(e){var r=this._isInteractiveEvent(e);if(r||this.isIdle||e.timestamp-this._lastActivityTimestamp>cd&&(this.isIdle=!0,this._tryAddCustomEvent("sessionIdle",{reason:"user inactivity",timeSinceLastActive:e.timestamp-this._lastActivityTimestamp,threshold:cd})),r&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),this._tryTakeFullSnapshot())),!this.isIdle){var i=this.sessionManager.checkAndGetSessionAndWindowId(!r,e.timestamp),n=i.windowId,s=i.sessionId,a=this.sessionId!==s,o=this.windowId!==n;[ld,ey].indexOf(e.type)===-1&&(o||a)&&this._tryTakeFullSnapshot(),this.windowId=n,this.sessionId=s}}},{key:"_tryRRwebMethod",value:function(e){if(!this._captureStarted)return!1;try{return e(),!0}catch(r){return j.error("[Session-Recording] using rrweb when not started.",r),!1}}},{key:"_tryAddCustomEvent",value:function(e,r){var i=this;return this._tryRRwebMethod(function(){var n;return(n=i.rrwebRecord)===null||n===void 0?void 0:n.addCustomEvent(e,r)})}},{key:"_tryTakeFullSnapshot",value:function(){var e=this;return this._tryRRwebMethod(function(){var r;return(r=e.rrwebRecord)===null||r===void 0?void 0:r.takeFullSnapshot()})}},{key:"_onScriptLoaded",value:function(){var e,r=this,i={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1};this.rrwebRecord=O.rrweb?O.rrweb.record:O.rrwebRecord;for(var n=this.instance.config.session_recording,s=0,a=Object.entries(n||{});s<a.length;s++){var o=zt(a[s],2),l=o[0],h=o[1];l in i&&(i[l]=h)}this.rrwebRecord?(this.mutationRateLimiter=(e=this.mutationRateLimiter)!==null&&e!==void 0?e:new ny(this.rrwebRecord,{onBlockedNode:function(c,u){var f="Too many mutations on node '".concat(c,"'. Rate limiting. This could be due to SVG animations or something similar");j.info(f,{node:u}),r.log("[PostHog Recorder] "+f,"warn")}}),this.stopRrweb=this.rrwebRecord(ne({emit:function(c){r.onRRwebEmit(c)},plugins:this._gatherRRWebPlugins()},i)),this.instance._addCaptureHook(function(c){try{if(c==="$pageview"){var u=O?r._maskUrl(O.location.href):"";if(!u)return;r._tryAddCustomEvent("$pageview",{href:u})}}catch(f){j.error("Could not add $pageview to rrweb session",f)}}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1):j.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}},{key:"_gatherRRWebPlugins",value:function(){var e=[];return tt.rrwebConsoleRecord&&this.isConsoleLogCaptureEnabled&&e.push(tt.rrwebConsoleRecord.getRecordConsolePlugin()),this.networkPayloadCapture&&jt(tt.getRecordNetworkPlugin)&&(!X0.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?e.push(tt.getRecordNetworkPlugin(ly(this.instance.config,this.networkPayloadCapture))):j.info("[SessionReplay-NetworkCapture] not started because we are on localhost.")),e}},{key:"onRRwebEmit",value:function(e){if(e&&Pr(e)){if(e.type===Fd.Meta){var r=this._maskUrl(e.data.href);if(!r)return;e.data.href=r}var i=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(i){var n=function(o){var l=o;if(l&&Pr(l)&&l.type===ty&&Pr(l.data)&&l.data.plugin===iy){l.data.payload.payload.length>10&&(l.data.payload.payload=l.data.payload.payload.slice(0,10),l.data.payload.payload.push("...[truncated]"));for(var h=[],c=0;c<l.data.payload.payload.length;c++)l.data.payload.payload[c]&&l.data.payload.payload[c].length>2e3?h.push(l.data.payload.payload[c].slice(0,2e3)+"...[truncated]"):h.push(l.data.payload.payload[c]);return l.data.payload.payload=h,o}return o}(i),s=JSON.stringify(n).length;if(this._updateWindowAndSessionIds(n),!this.isIdle){var a={$snapshot_bytes:s,$snapshot_data:n,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(a):this.clearBuffer()}}}}},{key:"_maskUrl",value:function(e){var r=this.instance.config.session_recording;if(r.maskNetworkRequestFn){var i,n={url:e};return(i=n=r.maskNetworkRequestFn(n))===null||i===void 0?void 0:i.url}return e}},{key:"clearBuffer",value:function(){return this.buffer=void 0,{size:0,data:[],sessionId:this.sessionId,windowId:this.windowId}}},{key:"_flushBuffer",value:function(){var e=this;this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var r=this._minimumDuration,i=this.sessionDuration,n=cr(i)&&i>=0,s=cr(r)&&n&&i<r;return this.status==="buffering"||s?(this.flushBufferTimer=setTimeout(function(){e._flushBuffer()},2e3),this.buffer||this.clearBuffer()):this.buffer&&this.buffer.data.length!==0?(this._captureSnapshot({$snapshot_bytes:this.buffer.size,$snapshot_data:this.buffer.data,$session_id:this.buffer.sessionId,$window_id:this.buffer.windowId}),this.clearBuffer()):this.buffer||this.clearBuffer()}},{key:"_captureSnapshotBuffered",value:function(e){var r,i=this,n=2+(((r=this.buffer)===null||r===void 0?void 0:r.data.length)||0);(!this.buffer||this.buffer.size+e.$snapshot_bytes+n>943718.4||this.buffer.sessionId&&this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),Ft(this.buffer.sessionId)&&!Ft(this.sessionId)&&(this.buffer.sessionId=this.sessionId,this.buffer.windowId=this.windowId),this.buffer.size+=e.$snapshot_bytes,this.buffer.data.push(e.$snapshot_data),this.flushBufferTimer||(this.flushBufferTimer=setTimeout(function(){i._flushBuffer()},2e3))}},{key:"_captureSnapshot",value:function(e){this.instance.capture("$snapshot",e,{transport:"XHR",method:"POST",endpoint:this._endpoint,_noTruncate:!0,_batchKey:"recordings",_metrics:{rrweb_full_snapshot:e.$snapshot_data.type===ld}})}}]),t}(),py=function(){function t(e){Oe(this,t),this.instance=e,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}return Re(t,[{key:"call",value:function(){var e=this,r=hh(JSON.stringify({token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(Yi),group_properties:this.instance.get_property(kr),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0}));this.instance._send_request("".concat(this.instance.config.api_host,"/decide/?v=3"),{data:r,verbose:!0},{method:"POST"},function(i){return e.parseDecideResponse(i)})}},{key:"parseDecideResponse",value:function(e){var r,i=this;if(this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer(),e?.status!==0){if(!K||!K.body)return j.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){i.parseDecideResponse(e)},500);this.instance.toolbar.afterDecideResponse(e),(r=this.instance.sessionRecording)===null||r===void 0||r.afterDecideResponse(e),Er.afterDecideResponse(e,this.instance),this.instance._afterDecideResponse(e),this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(e);var n=O?.extendPostHogWithSurveys;e.surveys&&!n&&Un(this.instance.config.api_host+"/static/surveys.js",function(c){if(c)return j.error("Could not load surveys script",c);O.extendPostHogWithSurveys(i.instance)});var s=O?.extendPostHogWithExceptionAutoCapture;if(e.autocaptureExceptions&&e.autocaptureExceptions&&ve(s)&&Un(this.instance.config.api_host+"/static/exception-autocapture.js",function(c){if(c)return j.error("Could not load exception autocapture script",c);O.extendPostHogWithExceptionAutocapture(i.instance,e)}),e.siteApps)if(this.instance.config.opt_in_site_apps){var a,o=this.instance.config.api_host,l=ai(e.siteApps);try{var h=function(){var c=a.value,u=c.id,f=c.url,p=[o,o[o.length-1]==="/"&&f[0]==="/"?f.substring(1):f].join("");tt["__$$ph_site_app_".concat(u)]=i.instance,Un(p,function(m){m&&j.error("Error while initializing PostHog app with config id ".concat(u),m)})};for(l.s();!(a=l.n()).done;)h()}catch(c){l.e(c)}finally{l.f()}}else e.siteApps.length>0&&j.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}else j.error("Failed to fetch feature flags from PostHog.")}}]),t}(),dy=["https://app.posthog.com","https://eu.posthog.com"],fy=["source"],my=O!=null&&O.location?Za(O.location.hash,"__posthog")||Za(location.hash,"state"):null,gy=function(){function t(e){Oe(this,t),this.instance=e}return Re(t,[{key:"afterDecideResponse",value:function(e){var r=e.toolbarParams||e.editorParams||(e.toolbarVersion?{toolbarVersion:e.toolbarVersion}:{});e.isAuthenticated&&r.toolbarVersion&&r.toolbarVersion.indexOf("toolbar")===0&&this.loadToolbar(ne({},r))}},{key:"maybeLoadToolbar",value:function(){var e,r,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!O||!K)return!1;i=(e=i)!==null&&e!==void 0?e:O.location,s=(r=s)!==null&&r!==void 0?r:O.history;try{if(!n){try{O.localStorage.setItem("test","test"),O.localStorage.removeItem("test")}catch{return!1}n=O?.localStorage}var a,o=my||Za(i.hash,"__posthog")||Za(i.hash,"state"),l=o?Wp(function(){return JSON.parse(atob(decodeURIComponent(o)))})||Wp(function(){return JSON.parse(decodeURIComponent(o))}):null;return l&&l.action==="ph_authorize"?((a=l).source="url",a&&Object.keys(a).length>0&&(l.desiredHash?i.hash=l.desiredHash:s?s.replaceState("",K.title,i.pathname+i.search):i.hash="")):((a=JSON.parse(n.getItem("_postHogToolbarParams")||"{}")).source="localstorage",delete a.userIntent),!(!a.token||this.instance.config.token!==a.token)&&(this.loadToolbar(a),!0)}catch{return!1}}},{key:"loadToolbar",value:function(e){var r=this;if(!O||tt._postHogToolbarLoaded)return!1;tt._postHogToolbarLoaded=!0;var i=this.instance.config.api_host,n=3e5,s=Math.floor(Date.now()/n)*n,a="".concat(i).concat(i.endsWith("/")?"":"/","static/toolbar.js?t=").concat(s),o=!dy.includes(this.instance.config.api_host)&&this.instance.config.advanced_disable_toolbar_metrics,l=ne(ne({token:this.instance.config.token},e),{},{apiURL:i},o?{instrument:!1}:{});l.source;var h=T0(l,fy);return O.localStorage.setItem("_postHogToolbarParams",JSON.stringify(h)),Un(a,function(c){c?j.error("Failed to load toolbar",c):(tt.ph_load_toolbar||tt.ph_load_editor)(l,r.instance)}),qn(O,"turbolinks:load",function(){tt._postHogToolbarLoaded=!1,r.loadToolbar(l)}),!0}},{key:"_loadEditor",value:function(e){return this.loadToolbar(e)}},{key:"maybeLoadEditor",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(e,r,i)}}]),t}(),yy="__ph_opt_in_out_";function vy(t,e){Od(!0,t,e)}function by(t,e){Od(!1,t,e)}function _y(t,e){return $d(t,e)==="1"}function ud(t,e){return!!function(r){if(r&&r.respectDnt){var i=r&&r.window||O,n=i?.navigator,s=!1;return Ce([n?.doNotTrack,n.msDoNotTrack,i.doNotTrack],function(a){xe([!0,1,"1","yes"],a)&&(s=!0)}),s}return!1}(e)||$d(t,e)==="0"}function wy(t,e){uh(e=e||{}).remove(ph(t,e),!!e.crossSubdomainCookie)}function uh(t){return(t=t||{}).persistenceType==="localStorage"?Le:t.persistenceType==="localStorage+cookie"?Hn:Jt}function ph(t,e){return((e=e||{}).persistencePrefix||yy)+t}function $d(t,e){return uh(e).get(ph(t,e))}function Od(t,e,r){St(e)&&e.length?(uh(r=r||{}).set(ph(e,r),t?1:0,cr(r.cookieExpiration)?r.cookieExpiration:null,r.crossSubdomainCookie,r.secureCookie),r.capture&&t&&r.capture(r.captureEventName||"$opt_in",r.captureProperties||{},{send_instantly:!0})):j.error("gdpr."+(t?"optIn":"optOut")+" called with an invalid token")}var Rd=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:3e3;Oe(this,t),this.isPolling=!0,this._event_queue=[],this._empty_queue_count=0,this._poller=void 0,this._pollInterval=e}return Re(t,[{key:"setPollInterval",value:function(e){this._pollInterval=e,this.isPolling&&this.poll()}},{key:"poll",value:function(){}},{key:"unload",value:function(){}},{key:"getTime",value:function(){return new Date().getTime()}}]),t}(),xy=function(t){bd(r,Rd);var e=_d(r);function r(i){var n,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3e3;return Oe(this,r),(n=e.call(this,s)).handlePollRequest=i,n}return Re(r,[{key:"enqueue",value:function(i,n,s){this._event_queue.push({url:i,data:n,options:s}),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var i=this;clearTimeout(this._poller),this._poller=setTimeout(function(){if(i._event_queue.length>0){var n=i.formatQueue(),s=function(o){var l=n[o],h=l.url,c=l.data,u=l.options;Ce(c,function(f,p){c[p].offset=Math.abs(c[p].timestamp-i.getTime()),delete c[p].timestamp}),i.handlePollRequest(h,c,u)};for(var a in n)s(a);i._event_queue.length=0,i._empty_queue_count=0}else i._empty_queue_count++;i._empty_queue_count>4&&(i.isPolling=!1,i._empty_queue_count=0),i.isPolling&&i.poll()},this._pollInterval)}},{key:"unload",value:function(){var i=this;clearTimeout(this._poller);var n=this._event_queue.length>0?this.formatQueue():{};this._event_queue.length=0;var s=Object.values(n);[].concat(Ul(s.filter(function(a){return a.url.indexOf("/e")===0})),Ul(s.filter(function(a){return a.url.indexOf("/e")!==0}))).map(function(a){var o=a.url,l=a.data,h=a.options;i.handlePollRequest(o,l,ne(ne({},h),{},{transport:"sendBeacon"}))})}},{key:"formatQueue",value:function(){var i={};return Ce(this._event_queue,function(n){var s=n.url,a=n.data,o=n.options,l=(o?o._batchKey:null)||s;ve(i[l])&&(i[l]={data:[],url:s,options:o}),o&&i[l].options&&i[l].options._metrics&&!i[l].options._metrics.rrweb_full_snapshot&&(i[l].options._metrics.rrweb_full_snapshot=o._metrics.rrweb_full_snapshot),i[l].data.push(a)}),i}}]),r}(),kt=Uint8Array,at=Uint16Array,Xi=Uint32Array,dh=new kt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fh=new kt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),pd=new kt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ld=function(t,e){for(var r=new at(31),i=0;i<31;++i)r[i]=e+=1<<t[i-1];var n=new Xi(r[30]);for(i=1;i<30;++i)for(var s=r[i];s<r[i+1];++s)n[s]=s-r[i]<<5|i;return[r,n]},Bd=Ld(dh,2),Sy=Bd[0],rh=Bd[1];Sy[28]=258,rh[258]=28;for(ih=Ld(fh,0)[1],Ya=new at(32768),Ie=0;Ie<32768;++Ie)xr=(43690&Ie)>>>1|(21845&Ie)<<1,xr=(61680&(xr=(52428&xr)>>>2|(13107&xr)<<2))>>>4|(3855&xr)<<4,Ya[Ie]=((65280&xr)>>>8|(255&xr)<<8)>>>1;var xr,ih,Ya,Ie,Wn=function(t,e,r){for(var i=t.length,n=0,s=new at(e);n<i;++n)++s[t[n]-1];var a,o=new at(e);for(n=0;n<e;++n)o[n]=o[n-1]+s[n-1]<<1;if(r){a=new at(1<<e);var l=15-e;for(n=0;n<i;++n)if(t[n])for(var h=n<<4|t[n],c=e-t[n],u=o[t[n]-1]++<<c,f=u|(1<<c)-1;u<=f;++u)a[Ya[u]>>>l]=h}else for(a=new at(i),n=0;n<i;++n)a[n]=Ya[o[t[n]-1]++]>>>15-t[n];return a},li=new kt(288);for(Ie=0;Ie<144;++Ie)li[Ie]=8;for(Ie=144;Ie<256;++Ie)li[Ie]=9;for(Ie=256;Ie<280;++Ie)li[Ie]=7;for(Ie=280;Ie<288;++Ie)li[Ie]=8;var Ja=new kt(32);for(Ie=0;Ie<32;++Ie)Ja[Ie]=5;var ii,ky=Wn(li,9,0),Ey=Wn(Ja,5,0),Vd=function(t){return(t/8>>0)+(7&t&&1)},Nd=function(t,e,r){(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length);var i=new(t instanceof at?at:t instanceof Xi?Xi:kt)(r-e);return i.set(t.subarray(e,r)),i},hr=function(t,e,r){r<<=7&e;var i=e/8>>0;t[i]|=r,t[i+1]|=r>>>8},zn=function(t,e,r){r<<=7&e;var i=e/8>>0;t[i]|=r,t[i+1]|=r>>>8,t[i+2]|=r>>>16},Gl=function(t,e){for(var r=[],i=0;i<t.length;++i)t[i]&&r.push({s:i,f:t[i]});var n=r.length,s=r.slice();if(!n)return[new kt(0),0];if(n==1){var a=new kt(r[0].s+1);return a[r[0].s]=1,[a,1]}r.sort(function(S,T){return S.f-T.f}),r.push({s:-1,f:25001});var o=r[0],l=r[1],h=0,c=1,u=2;for(r[0]={s:-1,f:o.f+l.f,l:o,r:l};c!=n-1;)o=r[r[h].f<r[u].f?h++:u++],l=r[h!=c&&r[h].f<r[u].f?h++:u++],r[c++]={s:-1,f:o.f+l.f,l:o,r:l};var f=s[0].s;for(i=1;i<n;++i)s[i].s>f&&(f=s[i].s);var p=new at(f+1),m=Py(r[c-1],p,0);if(m>e){i=0;var g=0,d=m-e,y=1<<d;for(s.sort(function(S,T){return p[T.s]-p[S.s]||S.f-T.f});i<n;++i){var v=s[i].s;if(!(p[v]>e))break;g+=y-(1<<m-p[v]),p[v]=e}for(g>>>=d;g>0;){var b=s[i].s;p[b]<e?g-=1<<e-p[b]++-1:++i}for(;i>=0&&g;--i){var _=s[i].s;p[_]==e&&(--p[_],++g)}m=e}return[new kt(p),m]},Py=function t(e,r,i){return e.s==-1?Math.max(t(e.l,r,i+1),t(e.r,r,i+1)):r[e.s]=i},dd=function(t){for(var e=t.length;e&&!t[--e];);for(var r=new at(++e),i=0,n=t[0],s=1,a=function(l){r[i++]=l},o=1;o<=e;++o)if(t[o]==n&&o!=e)++s;else{if(!n&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(n),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(n);s=1,n=t[o]}return[r.subarray(0,i),e]},jn=function(t,e){for(var r=0,i=0;i<e.length;++i)r+=t[i]*e[i];return r},Na=function(t,e,r){var i=r.length,n=Vd(e+2);t[n]=255&i,t[n+1]=i>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var s=0;s<i;++s)t[n+s+4]=r[s];return 8*(n+4+i)},fd=function(t,e,r,i,n,s,a,o,l,h,c){hr(e,c++,r),++n[256];for(var u=Gl(n,15),f=u[0],p=u[1],m=Gl(s,15),g=m[0],d=m[1],y=dd(f),v=y[0],b=y[1],_=dd(g),S=_[0],T=_[1],x=new at(19),w=0;w<v.length;++w)x[31&v[w]]++;for(w=0;w<S.length;++w)x[31&S[w]]++;for(var M=Gl(x,7),k=M[0],I=M[1],P=19;P>4&&!k[pd[P-1]];--P);var A,E,F,$,D=h+5<<3,C=jn(n,li)+jn(s,Ja)+a,R=jn(n,f)+jn(s,g)+a+14+3*P+jn(x,k)+(2*x[16]+3*x[17]+7*x[18]);if(D<=C&&D<=R)return Na(e,c,t.subarray(l,l+h));if(hr(e,c,1+(R<C)),c+=2,R<C){A=Wn(f,p,0),E=f,F=Wn(g,d,0),$=g;var B=Wn(k,I,0);for(hr(e,c,b-257),hr(e,c+5,T-1),hr(e,c+10,P-4),c+=14,w=0;w<P;++w)hr(e,c+3*w,k[pd[w]]);c+=3*P;for(var U=[v,S],Z=0;Z<2;++Z){var X=U[Z];for(w=0;w<X.length;++w){var H=31&X[w];hr(e,c,B[H]),c+=k[H],H>15&&(hr(e,c,X[w]>>>5&127),c+=X[w]>>>12)}}}else A=ky,E=li,F=Ey,$=Ja;for(w=0;w<o;++w)if(i[w]>255){H=i[w]>>>18&31,zn(e,c,A[H+257]),c+=E[H+257],H>7&&(hr(e,c,i[w]>>>23&31),c+=dh[H]);var ie=31&i[w];zn(e,c,F[ie]),c+=$[ie],ie>3&&(zn(e,c,i[w]>>>5&8191),c+=fh[ie])}else zn(e,c,A[i[w]]),c+=E[i[w]];return zn(e,c,A[256]),c+E[256]},Ay=new Xi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Cy=new kt(0),Ty=function(){for(var t=new Xi(256),e=0;e<256;++e){for(var r=e,i=9;--i;)r=(1&r&&3988292384)^r>>>1;t[e]=r}return t}(),Iy=function(){var t=4294967295;return{p:function(e){for(var r=t,i=0;i<e.length;++i)r=Ty[255&r^e[i]]^r>>>8;t=r},d:function(){return 4294967295^t}}},My=function(t,e,r,i,n){return function(s,a,o,l,h,c){var u=s.length,f=new kt(l+u+5*(1+Math.floor(u/7e3))+h),p=f.subarray(l,f.length-h),m=0;if(!a||u<8)for(var g=0;g<=u;g+=65535){var d=g+65535;d<u?m=Na(p,m,s.subarray(g,d)):(p[g]=c,m=Na(p,m,s.subarray(g,u)))}else{for(var y=Ay[a-1],v=y>>>13,b=8191&y,_=(1<<o)-1,S=new at(32768),T=new at(_+1),x=Math.ceil(o/3),w=2*x,M=function(ot){return(s[ot]^s[ot+1]<<x^s[ot+2]<<w)&_},k=new Xi(25e3),I=new at(288),P=new at(32),A=0,E=0,F=(g=0,0),$=0,D=0;g<u;++g){var C=M(g),R=32767&g,B=T[C];if(S[R]=B,T[C]=R,$<=g){var U=u-g;if((A>7e3||F>24576)&&U>423){m=fd(s,p,0,k,I,P,E,F,D,g-D,m),F=A=E=0,D=g;for(var Z=0;Z<286;++Z)I[Z]=0;for(Z=0;Z<30;++Z)P[Z]=0}var X=2,H=0,ie=b,oe=R-B&32767;if(U>2&&C==M(g-oe))for(var se=Math.min(v,U)-1,te=Math.min(32767,g),ke=Math.min(258,U);oe<=te&&--ie&&R!=B;){if(s[g+X]==s[g+X-oe]){for(var fe=0;fe<ke&&s[g+fe]==s[g+fe-oe];++fe);if(fe>X){if(X=fe,H=oe,fe>se)break;var Me=Math.min(oe,fe-2),Ee=0;for(Z=0;Z<Me;++Z){var J=g-oe+Z+32768&32767,Ze=J-S[J]+32768&32767;Ze>Ee&&(Ee=Ze,B=J)}}}oe+=(R=B)-(B=S[R])+32768&32767}if(H){k[F++]=268435456|rh[X]<<18|ih[H];var Et=31&rh[X],Pt=31&ih[H];E+=dh[Et]+fh[Pt],++I[257+Et],++P[Pt],$=g+X,++A}else k[F++]=s[g],++I[s[g]]}}m=fd(s,p,c,k,I,P,E,F,D,g-D,m),c||(m=Na(p,m,Cy))}return Nd(f,0,l+Vd(m)+h)}(t,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,r,i,!n)},nh=function(t,e,r){for(;r;++e)t[e]=r,r>>>=8},Dy=function(t,e){var r=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=e.level<2?4:e.level==9?2:0,t[9]=3,e.mtime!=0&&nh(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),r){t[3]=8;for(var i=0;i<=r.length;++i)t[i+10]=r.charCodeAt(i)}},Fy=function(t){return 10+(t.filename&&t.filename.length+1||0)};function $y(t,e){e===void 0&&(e={});var r=Iy(),i=t.length;r.p(t);var n=My(t,e,Fy(e),8),s=n.length;return Dy(n,e),nh(n,s-8,r.d()),nh(n,s-4,i),n}function Oy(t,e){var r=t.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var i=new kt(t.length+(t.length>>>1)),n=0,s=function(h){i[n++]=h},a=0;a<r;++a){if(n+5>i.length){var o=new kt(n+8+(r-a<<1));o.set(i),i=o}var l=t.charCodeAt(a);l<128||e?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++a))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return Nd(i,0,n)}(function(t){t.GZipJS="gzip-js",t.Base64="base64"})(ii||(ii={}));var zd=function(t,e,r){var i=e||{};i.ip=r.ip?1:0,i._=new Date().getTime().toString(),i.ver=oi.LIB_VERSION;var n=t.split("?");if(n.length>1){var s,a=ai(n[1].split("&"));try{for(a.s();!(s=a.n()).done;){var o=s.value.split("=")[0];ve(i[o])||delete i[o]}}catch(h){a.e(h)}finally{a.f()}}var l=t.indexOf("?")>-1?"&":"?";return t+l+function(h){var c,u,f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",p=[];return Ce(h,function(m,g){ve(m)||ve(g)||g==="undefined"||(c=encodeURIComponent(m.toString()),u=encodeURIComponent(g),p[p.length]=u+"="+c)}),p.join(f)}(i)},mh=function t(e,r){if(r.blob&&e.buffer)return new Blob([jp(e)?e:e.buffer],{type:"text/plain"});if(r.sendBeacon||r.blob){var i=t(e,{method:"POST"});return new Blob([i],{type:"application/x-www-form-urlencoded"})}return r.method!=="POST"?null:(n=We(e)||jp(e)?"data="+encodeURIComponent(e):"data="+encodeURIComponent(e.data),"compression"in e&&e.compression&&(n+="&compression="+e.compression),n);var n},jd=function(t){var e=t.url,r=t.data,i=t.headers,n=t.options,s=t.callback,a=t.retriesPerformedSoFar,o=t.retryQueue,l=t.onXHRError,h=t.timeout,c=h===void 0?6e4:h,u=t.onResponse;cr(a)&&a>0&&(e=zd(e,{retry_count:a},{}));var f=new XMLHttpRequest;f.open(n.method||"GET",e,!0);var p=mh(r,n);Ce(i,function(m,g){f.setRequestHeader(g,m)}),n.method!=="POST"||n.blob||f.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),f.timeout=c,f.withCredentials=!0,f.onreadystatechange=function(){if(f.readyState===4)if(u?.(f),f.status===200){if(s){var m;try{m=JSON.parse(f.responseText)}catch(g){return void j.error(g)}s(m)}}else jt(l)&&l(f),(f.status<400||f.status>500)&&o.enqueue({url:e,data:r,options:n,headers:i,retriesPerformedSoFar:(a||0)+1,callback:s}),s?.({status:0})},f.send(p)},Ry=18e5,Ly=function(t){bd(r,Rd);var e=_d(r);function r(i,n){var s;return Oe(this,r),(s=e.call(this)).isPolling=!1,s.queue=[],s.areWeOnline=!0,s.onXHRError=i,s.rateLimiter=n,!ve(O)&&"onLine"in O.navigator&&(s.areWeOnline=O.navigator.onLine,O.addEventListener("online",function(){s._handleWeAreNowOnline()}),O.addEventListener("offline",function(){s.areWeOnline=!1})),s}return Re(r,[{key:"enqueue",value:function(i){var n=i.retriesPerformedSoFar||0;if(!(n>=10)){var s=function(l){var h=3e3*Math.pow(2,l),c=h/2,u=Math.min(Ry,h),f=(Math.random()-.5)*(u-c);return Math.ceil(u+f)}(n),a=new Date(Date.now()+s);this.queue.push({retryAt:a,requestData:i});var o="Enqueued failed request for retry in ".concat(s);navigator.onLine||(o+=" (Browser is offline)"),j.warn(o),this.isPolling||(this.isPolling=!0,this.poll())}}},{key:"poll",value:function(){var i=this;this._poller&&clearTimeout(this._poller),this._poller=setTimeout(function(){i.areWeOnline&&i.queue.length>0&&i.flush(),i.poll()},this._pollInterval)}},{key:"flush",value:function(){var i=new Date(Date.now()),n=this.queue.filter(function(l){return l.retryAt<i});if(n.length>0){this.queue=this.queue.filter(function(l){return l.retryAt>=i});var s,a=ai(n);try{for(a.s();!(s=a.n()).done;){var o=s.value.requestData;this._executeXhrRequest(o)}}catch(l){a.e(l)}finally{a.f()}}}},{key:"unload",value:function(){this._poller&&(clearTimeout(this._poller),this._poller=void 0);var i,n=ai(this.queue);try{for(n.s();!(i=n.n()).done;){var s=i.value.requestData,a=s.url,o=s.data,l=s.options;if(this.rateLimiter.isRateLimited(l._batchKey))j.warn("[RetryQueue] is quota limited. Dropping request.");else try{O?.navigator.sendBeacon(a,mh(o,ne(ne({},l),{},{sendBeacon:!0})))}catch(h){j.error(h)}}}catch(h){n.e(h)}finally{n.f()}this.queue=[]}},{key:"_executeXhrRequest",value:function(i){var n=i.url,s=i.data,a=i.options,o=i.headers,l=i.callback,h=i.retriesPerformedSoFar;this.rateLimiter.isRateLimited(a._batchKey)||jd({url:n,data:s||{},options:a||{},headers:o||{},retriesPerformedSoFar:h||0,callback:l,retryQueue:this,onXHRError:this.onXHRError,onResponse:this.rateLimiter.checkForLimiting})}},{key:"_handleWeAreNowOnline",value:function(){this.areWeOnline=!0,this.flush()}}]),r}(),Fa=1800,md=60,By=864e5,Vy=function(){function t(e,r,i,n){Oe(this,t),Y(this,"_sessionIdChangedHandlers",[]),this.config=e,this.persistence=r,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||ni,this._windowIdGenerator=n||ni;var s=e.persistence_name||e.token,a=e.session_idle_timeout_seconds||Fa;if(cr(a)?a>Fa?j.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):a<md&&j.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(j.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),a=Fa),this._sessionTimeoutMs=1e3*Math.min(Math.max(a,md),Fa),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var o=Xe.parse(this._window_id_storage_key),l=Xe.parse(this._primary_window_exists_storage_key);o&&!l?this._windowId=o:Xe.remove(this._window_id_storage_key),Xe.set(this._primary_window_exists_storage_key,!0)}this._listenToReloadWindow()}return Re(t,[{key:"onSessionId",value:function(e){var r=this;return ve(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),function(){r._sessionIdChangedHandlers=r._sessionIdChangedHandlers.filter(function(i){return i!==e})}}},{key:"_canUseSessionStorage",value:function(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&Xe.is_supported()}},{key:"_setWindowId",value:function(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Xe.set(this._window_id_storage_key,e))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:this._canUseSessionStorage()?Xe.parse(this._window_id_storage_key):null}},{key:"_setSessionId",value:function(e,r,i){e===this._sessionId&&r===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=r,this._sessionId=e,this.persistence.register(Y({},Ua,[r,e,i])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[Ua];return We(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}},{key:"resetSessionId",value:function(){this._setSessionId(null,null,null)}},{key:"_listenToReloadWindow",value:function(){var e=this;O?.addEventListener("beforeunload",function(){e._canUseSessionStorage()&&Xe.remove(e._primary_window_exists_storage_key)})}},{key:"checkAndGetSessionAndWindowId",value:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||new Date().getTime(),i=zt(this._getSessionId(),3),n=i[0],s=i[1],a=i[2],o=this._getWindowId(),l=a&&a>0&&Math.abs(r-a)>By,h=!1,c=!s,u=!e&&Math.abs(r-n)>this._sessionTimeoutMs;c||u||l?(s=this._sessionIdGenerator(),o=this._windowIdGenerator(),a=r,h=!0):o||(o=this._windowIdGenerator(),h=!0);var f=n===0||!e||l?r:n,p=a===0?new Date().getTime():a;return this._setWindowId(o),this._setSessionId(s,f,p),h&&this._sessionIdChangedHandlers.forEach(function(m){return m(s,o)}),{sessionId:s,windowId:o,sessionStartTimestamp:p}}}]),t}(),Ny=Re(function t(e,r,i,n){Oe(this,t),this.name="posthog-js",this.setupOnce=function(s){s(function(a){var o,l,h,c,u;if(a.level!=="error"||!e.__loaded)return a;a.tags||(a.tags={});var f=e.config.ui_host||e.config.api_host;a.tags["PostHog Person URL"]=f+"/person/"+e.get_distinct_id(),e.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=((o=a.exception)===null||o===void 0?void 0:o.values)||[],m={$exception_message:(l=p[0])===null||l===void 0?void 0:l.value,$exception_type:(h=p[0])===null||h===void 0?void 0:h.type,$exception_personURL:f+"/person/"+e.get_distinct_id(),$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:(c=p[0])===null||c===void 0?void 0:c.value,$sentry_exception_type:(u=p[0])===null||u===void 0?void 0:u.type,$sentry_tags:a.tags};return r&&i&&(m.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+i+"&query="+a.event_id),e.capture("$exception",m),a})}}),zy=function(t){Promise&&Promise.resolve||j.warn("This browser does not have Promise support, and can not use the segment integration");var e=function(r,i){r.event.userId||r.event.anonymousId===t.get_distinct_id()||t.reset(),r.event.userId&&r.event.userId!==t.get_distinct_id()&&(t.register({distinct_id:r.event.userId}),t.reloadFeatureFlags());var n=t._calculate_event_properties(i,r.event.properties);return r.event.properties=Object.assign({},n,r.event.properties),r};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:function(r){return e(r,r.event.event)},page:function(r){return e(r,"$pageview")},identify:function(r){return e(r,"$identify")},screen:function(r){return e(r,"$screen")}}},jy=function(){function t(){var e=this;Oe(this,t),Y(this,"_hasSeenPageView",!1),Y(this,"_updateScrollData",function(){var r,i,n,s;e._pageViewData||(e._pageViewData=e._createPageViewData());var a=e._pageViewData,o=e._scrollY(),l=e._scrollHeight(),h=e._contentY(),c=e._contentHeight();a.lastScrollY=o,a.maxScrollY=Math.max(o,(r=a.maxScrollY)!==null&&r!==void 0?r:0),a.maxScrollHeight=Math.max(l,(i=a.maxScrollHeight)!==null&&i!==void 0?i:0),a.lastContentY=h,a.maxContentY=Math.max(h,(n=a.maxContentY)!==null&&n!==void 0?n:0),a.maxContentHeight=Math.max(c,(s=a.maxContentHeight)!==null&&s!==void 0?s:0)})}return Re(t,[{key:"_createPageViewData",value:function(){var e;return{pathname:(e=O?.location.pathname)!==null&&e!==void 0?e:""}}},{key:"doPageView",value:function(){var e,r;return this._hasSeenPageView?(r=this._pageViewData,this._pageViewData=this._createPageViewData()):(this._hasSeenPageView=!0,r=void 0,this._pageViewData||(this._pageViewData=this._createPageViewData())),setTimeout(this._updateScrollData,0),ne({$prev_pageview_pathname:(e=r)===null||e===void 0?void 0:e.pathname},this._calculatePrevPageScrollProperties(r))}},{key:"doPageLeave",value:function(){var e=this._pageViewData;return ne({$prev_pageview_pathname:e?.pathname},this._calculatePrevPageScrollProperties(e))}},{key:"_calculatePrevPageScrollProperties",value:function(e){if(!e||e.maxScrollHeight==null||e.lastScrollY==null||e.maxScrollY==null||e.maxContentHeight==null||e.lastContentY==null||e.maxContentY==null)return{};var r=e.maxScrollHeight,i=e.lastScrollY,n=e.maxScrollY,s=e.maxContentHeight,a=e.lastContentY,o=e.maxContentY;return r=Math.ceil(r),i=Math.ceil(i),n=Math.ceil(n),s=Math.ceil(s),a=Math.ceil(a),o=Math.ceil(o),{$prev_pageview_last_scroll:i,$prev_pageview_last_scroll_percentage:r<=1?1:$a(i/r,0,1),$prev_pageview_max_scroll:n,$prev_pageview_max_scroll_percentage:r<=1?1:$a(n/r,0,1),$prev_pageview_last_content:a,$prev_pageview_last_content_percentage:s<=1?1:$a(a/s,0,1),$prev_pageview_max_content:o,$prev_pageview_max_content_percentage:s<=1?1:$a(o/s,0,1)}}},{key:"startMeasuringScrollPosition",value:function(){O?.addEventListener("scroll",this._updateScrollData),O?.addEventListener("scrollend",this._updateScrollData),O?.addEventListener("resize",this._updateScrollData)}},{key:"stopMeasuringScrollPosition",value:function(){O?.removeEventListener("scroll",this._updateScrollData),O?.removeEventListener("scrollend",this._updateScrollData),O?.removeEventListener("resize",this._updateScrollData)}},{key:"_scrollHeight",value:function(){return O?Math.max(0,O.document.documentElement.scrollHeight-O.document.documentElement.clientHeight):0}},{key:"_scrollY",value:function(){return O&&(O.scrollY||O.pageYOffset||O.document.documentElement.scrollTop)||0}},{key:"_contentHeight",value:function(){return O?.document.documentElement.scrollHeight||0}},{key:"_contentY",value:function(){var e=O?.document.documentElement.clientHeight||0;return this._scrollY()+e}}]),t}();function $a(t,e,r){return Math.max(e,Math.min(t,r))}var Zn,gh,Je,Gy={icontains:function(t){return!!O&&O.location.href.toLowerCase().indexOf(t.toLowerCase())>-1},regex:function(t){return!!O&&K0(O.location.href,t)},exact:function(t){return O?.location.href===t}},Hy=function(){function t(e){Oe(this,t),this.instance=e}return Re(t,[{key:"getSurveys",value:function(e){var r=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.instance.get_property(Kl);if(n&&!i)return e(n);this.instance._send_request("".concat(this.instance.config.api_host,"/api/surveys/?token=").concat(this.instance.config.token),{},{method:"GET"},function(s){var a,o=s.surveys||[];return(a=r.instance.persistence)===null||a===void 0||a.register(Y({},Kl,o)),e(o)})}},{key:"getActiveMatchingSurveys",value:function(e){var r=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(function(n){var s=n.filter(function(a){return!(!a.start_date||a.end_date)}).filter(function(a){var o,l,h,c;if(!a.conditions)return!0;var u=(o=a.conditions)===null||o===void 0||!o.url||Gy[(l=(h=a.conditions)===null||h===void 0?void 0:h.urlMatchType)!==null&&l!==void 0?l:"icontains"](a.conditions.url),f=(c=a.conditions)===null||c===void 0||!c.selector||K?.querySelector(a.conditions.selector);return u&&f}).filter(function(a){if(!a.linked_flag_key&&!a.targeting_flag_key)return!0;var o=!a.linked_flag_key||r.instance.featureFlags.isFeatureEnabled(a.linked_flag_key),l=!a.targeting_flag_key||r.instance.featureFlags.isFeatureEnabled(a.targeting_flag_key);return o&&l});return e(s)},i)}}]),t}(),qy=6e4,Uy=function(){function t(){var e=this;Oe(this,t),Y(this,"limits",{}),Y(this,"checkForLimiting",function(r){try{var i=r.responseText;if(!i||!i.length)return;(JSON.parse(i).quota_limited||[]).forEach(function(n){j.info("[RateLimiter] ".concat(n||"events"," is quota limited.")),e.limits[n]=new Date().getTime()+qy})}catch(n){return void j.error(n)}})}return Re(t,[{key:"isRateLimited",value:function(e){var r=this.limits[e||"events"]||!1;return r!==!1&&new Date().getTime()<r}}]),t}(),Wy=function(){return ne({initialPathName:O?.location.pathname||"",referringDomain:He.referringDomain()},He.campaignParams())},Zy=function(){function t(e,r,i){var n=this;Oe(this,t),Y(this,"_onSessionIdCallback",function(s){var a=n._getStoredProps();if(!a||a.sessionId!==s){var o={sessionId:s,props:n._sessionSourceParamGenerator()};n._persistence.register(Y({},th,o))}}),this._sessionIdManager=e,this._persistence=r,this._sessionSourceParamGenerator=i||Wy,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}return Re(t,[{key:"_getStoredProps",value:function(){return this._persistence.props[th]}},{key:"getSessionProps",value:function(){var e,r=(e=this._getStoredProps())===null||e===void 0?void 0:e.props;return r?{$client_session_initial_referring_host:r.referringDomain,$client_session_initial_pathname:r.initialPathName,$client_session_initial_utm_source:r.utm_source,$client_session_initial_utm_campaign:r.utm_campaign,$client_session_initial_utm_medium:r.utm_medium,$client_session_initial_utm_content:r.utm_content,$client_session_initial_utm_term:r.utm_term}:{}}}]),t}(),Yy=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"],Jy=function(t,e){if(!t)return!1;var r=t.toLowerCase();return Yy.concat(e||[]).some(function(i){var n=i.toLowerCase();return r.includes?r.includes(n):r.indexOf(n)!==-1})};(function(t){t[t.INIT_MODULE=0]="INIT_MODULE",t[t.INIT_SNIPPET=1]="INIT_SNIPPET"})(Zn||(Zn={}));var sh=function(){},Oa={},pt="posthog",za=O?.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,Gd=!za&&Ge?.indexOf("MSIE")===-1&&Ge?.indexOf("Mozilla")===-1,gd=function(){var t,e,r;return{api_host:"https://app.posthog.com",api_method:"POST",api_transport:"XHR",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:(e=K?.location,r=e?.hostname,!!St(r)&&r.split(".").slice(-2).join(".")!=="herokuapp.com"),persistence:"localStorage+cookie",persistence_name:"",cookie_name:"",loaded:sh,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:!0,debug:!1,verbose:!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_cookie:!1,enable_recording_console_log:void 0,secure_cookie:(O==null||(t=O.location)===null||t===void 0?void 0:t.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_blacklist:[],respect_dnt:!1,sanitize_properties:null,xhr_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,on_xhr_error:function(i){var n="Bad HTTP status: "+i.status+" "+i.statusText;j.error(n)},get_device_id:function(i){return i},_onCapture:sh,capture_performance:void 0,name:"posthog",callback_fn:"posthog._jsc",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800}},ah=function(t,e,r,i){var n,s=r!==pt&&Je?r?Je[r]:void 0:Je,a={initComplete:!1,syncCode:!1},o=function(l){return function(h){a[l]||(a[l]=!0,a.initComplete&&a.syncCode&&i?.(h))}};if(s&&gh===Zn.INIT_MODULE)n=s;else{if(s&&!We(s))return void j.error("You have already initialized "+r);n=new yh}return n._init(t,e,r,o("initComplete")),n.toolbar.maybeLoadToolbar(),n.sessionRecording=new uy(n),n.sessionRecording.startRecordingIfEnabled(),n.config.__preview_measure_pageview_stats&&n.pageViewManager.startMeasuringScrollPosition(),n.__autocapture=n.config.autocapture,Er._setIsAutocaptureEnabled(n),Er._isAutocaptureEnabled&&(n.__autocapture=n.config.autocapture,Er.enabledForProject(n.config.token,100,100)?Er.isBrowserSupported()?Er.init(n):(n.__autocapture=!1,j.info("Disabling Automatic Event Collection because this browser is not supported")):(n.__autocapture=!1,j.info("Not in active bucket: disabling Automatic Event Collection."))),oi.DEBUG=oi.DEBUG||n.config.debug,!ve(s)&&We(s)&&(n._execute_array.call(n.people,s.people),n._execute_array(s)),o("syncCode")(n),n},Xy=function(){function t(){Oe(this,t),Y(this,"__forceAllowLocalhost",!1)}return Re(t,[{key:"_forceAllowLocalhost",get:function(){return this.__forceAllowLocalhost},set:function(e){j.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}]),t}(),yh=function(){function t(){var e=this;Oe(this,t),Y(this,"webPerformance",new Xy),this.config=gd(),this.compression={},this.decideEndpointWasHit=!1,this.SentryIntegration=Ny,this.segmentIntegration=function(){return zy(e)},this.__captureHooks=[],this.__request_queue=[],this.__loaded=!1,this.__loaded_recorder_version=void 0,this.__autocapture=void 0,this._jsc=function(){},this.analyticsDefaultEndpoint="/e/",this.elementsChainAsString=!1,this.featureFlags=new N0(this),this.toolbar=new gy(this),this.pageViewManager=new jy,this.surveys=new Hy(this),this.rateLimiter=new Uy,this.people={set:function(r,i,n){var s=St(r)?Y({},r,i):r;e.setPersonProperties(s),n?.({})},set_once:function(r,i,n){var s=St(r)?Y({},r,i):r;e.setPersonProperties(void 0,s),n?.({})}}}return Re(t,[{key:"init",value:function(e,r,i){if(ve(i))j.critical("You must name your new library: init(token, config, name)");else{if(i!==pt){var n=ah(e,r,i,function(s){Je[i]=s,s._loaded()});return Je[i]=n,n}j.critical("You must initialize the main posthog object right after you include the PostHog js snippet")}}},{key:"_init",value:function(e){var r,i,n,s=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0,l=arguments.length>3?arguments[3]:void 0;this.__loaded=!0,this.config={},this._triggered_notifs=[];var h,c={segmentRegister:!1,syncCode:!1},u=function(S){return function(){c[S]||(c[S]=!0,c.segmentRegister&&c.syncCode&&l?.(s))}};if(this.set_config(Ye({},gd(),a,{name:o,token:e,callback_fn:(o===pt?o:pt+"."+o)+"._jsc"})),this._jsc=function(){},(O!=null&&(r=O.rrweb)!==null&&r!==void 0&&r.record||O!=null&&O.rrwebRecord)&&(this.__loaded_recorder_version=O==null||(h=O.rrweb)===null||h===void 0?void 0:h.version),this.persistence=new od(this.config),this._requestQueue=new xy(this._handle_queued_event.bind(this)),this._retryQueue=new Ly(this.config.on_xhr_error,this.rateLimiter),this.__captureHooks=[],this.__request_queue=[],this.sessionManager=new Vy(this.config,this.persistence),this.sessionPropsManager=new Zy(this.sessionManager,this.persistence),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new od(ne(ne({},this.config),{},{persistence:"sessionStorage"})),this._gdpr_init(),a.segment?(this.config.get_device_id=function(){return a.segment.user().anonymousId()},a.segment.user().id()&&(this.register({distinct_id:a.segment.user().id()}),this.persistence.set_user_state("identified")),a.segment.register(this.segmentIntegration()).then(u("segmentRegister"))):u("segmentRegister")(),((i=a.bootstrap)===null||i===void 0?void 0:i.distinctID)!==void 0){var f,p,m=this.config.get_device_id(ni()),g=(f=a.bootstrap)!==null&&f!==void 0&&f.isIdentifiedID?m:a.bootstrap.distinctID;this.persistence.set_user_state((p=a.bootstrap)!==null&&p!==void 0&&p.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:a.bootstrap.distinctID,$device_id:g})}if(this._hasBootstrappedFeatureFlags()){var d,y,v=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlags)||{}).filter(function(S){var T,x;return!((T=a.bootstrap)===null||T===void 0||(x=T.featureFlags)===null||x===void 0||!x[S])}).reduce(function(S,T){var x,w;return S[T]=((x=a.bootstrap)===null||x===void 0||(w=x.featureFlags)===null||w===void 0?void 0:w[T])||!1,S},{}),b=Object.keys(((y=a.bootstrap)===null||y===void 0?void 0:y.featureFlagPayloads)||{}).filter(function(S){return v[S]}).reduce(function(S,T){var x,w,M,k;return(x=a.bootstrap)!==null&&x!==void 0&&(w=x.featureFlagPayloads)!==null&&w!==void 0&&w[T]&&(S[T]=(M=a.bootstrap)===null||M===void 0||(k=M.featureFlagPayloads)===null||k===void 0?void 0:k[T]),S},{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:b})}if(!this.get_distinct_id()){var _=this.config.get_device_id(ni());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_user_state("anonymous")}O==null||(n=O.addEventListener)===null||n===void 0||n.call(O,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),u("syncCode")()}},{key:"_afterDecideResponse",value:function(e){var r;if(this.compression={},e.supportedCompression&&!this.config.disable_compression){var i,n={},s=ai(e.supportedCompression);try{for(s.s();!(i=s.n()).done;)n[i.value]=!0}catch(a){s.e(a)}finally{s.f()}this.compression=n}(r=e.analytics)!==null&&r!==void 0&&r.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),e.elementsChainAsString&&(this.elementsChainAsString=e.elementsChainAsString)}},{key:"_loaded",value:function(){var e=this.config.advanced_disable_decide;e||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(r){j.critical("`loaded` function failed",r)}this._start_queue_if_opted_in(),this.config.capture_pageview&&K&&this.capture("$pageview",{title:K.title},{send_instantly:!0}),e||(new py(this).call(),this.featureFlags.resetRequestQueue())}},{key:"_start_queue_if_opted_in",value:function(){var e;this.has_opted_out_capturing()||this.config.request_batching&&((e=this._requestQueue)===null||e===void 0||e.poll())}},{key:"_dom_loaded",value:function(){var e=this;this.has_opted_out_capturing()||Ji(this.__request_queue,function(r){e._send_request.apply(e,Ul(r))}),this.__request_queue=[],this._start_queue_if_opted_in()}},{key:"_prepare_callback",value:function(e,r){if(ve(e))return null;if(za)return function(a){e(a,r)};var i=this._jsc,n=""+Math.floor(1e8*Math.random()),s=this.config.callback_fn+"["+n+"]";return i[n]=function(a){delete i[n],e(a,r)},s}},{key:"_handle_unload",value:function(){var e,r;this.config.request_batching?(this.config.capture_pageview&&this.config.capture_pageleave&&this.capture("$pageleave"),(e=this._requestQueue)===null||e===void 0||e.unload(),(r=this._retryQueue)===null||r===void 0||r.unload()):this.config.capture_pageview&&this.config.capture_pageleave&&this.capture("$pageleave",null,{transport:"sendBeacon"})}},{key:"_handle_queued_event",value:function(e,r,i){var n=JSON.stringify(r);this.__compress_and_send_json_request(e,n,i||Oa,sh)}},{key:"__compress_and_send_json_request",value:function(e,r,i,n){var s=function(h,c,u){return h===ii.GZipJS?[$y(Oy(c),{mtime:0}),ne(ne({},u),{},{blob:!0,urlQueryArgs:{compression:ii.GZipJS}})]:[{data:hh(c)},u]}(this.compression[ii.GZipJS]?ii.GZipJS:ii.Base64,r,i),a=zt(s,2),o=a[0],l=a[1];this._send_request(e,o,l,n)}},{key:"_send_request",value:function(e,r,i,n){if(this.__loaded&&this._retryQueue&&!this.rateLimiter.isRateLimited(i._batchKey))if(Gd)this.__request_queue.push([e,r,i,n]);else{var s={method:this.config.api_method,transport:this.config.api_transport,verbose:this.config.verbose};i=Ye(s,i||{}),za||(i.method="GET");var a=O&&"sendBeacon"in O.navigator&&i.transport==="sendBeacon";if(e=zd(e,i.urlQueryArgs||{},{ip:this.config.ip}),a)try{O?.navigator.sendBeacon(e,mh(r,ne(ne({},i),{},{sendBeacon:!0})))}catch{}else if(za||!K)try{jd({url:e,data:r,headers:this.config.xhr_headers,options:i,callback:n,retriesPerformedSoFar:0,retryQueue:this._retryQueue,onXHRError:this.config.on_xhr_error,onResponse:this.rateLimiter.checkForLimiting})}catch(c){j.error(c)}else{var o,l=K.createElement("script");l.type="text/javascript",l.async=!0,l.defer=!0,l.src=e;var h=K.getElementsByTagName("script")[0];(o=h.parentNode)===null||o===void 0||o.insertBefore(l,h)}}}},{key:"_execute_array",value:function(e){var r,i=this,n=[],s=[],a=[];Ji(e,function(l){l&&(r=l[0],We(r)?a.push(l):jt(l)?l.call(i):We(l)&&r==="alias"?n.push(l):We(l)&&r.indexOf("capture")!==-1&&jt(i[r])?a.push(l):s.push(l))});var o=function(l,h){Ji(l,function(c){if(We(c[0])){var u=h;Ce(c,function(f){u=u[f[0]].apply(u,f.slice(1))})}else this[c[0]].apply(this,c.slice(1))},h)};o(n,this),o(s,this),o(a,this)}},{key:"_hasBootstrappedFeatureFlags",value:function(){var e,r;return((e=this.config.bootstrap)===null||e===void 0?void 0:e.featureFlags)&&Object.keys((r=this.config.bootstrap)===null||r===void 0?void 0:r.featureFlags).length>0||!1}},{key:"push",value:function(e){this._execute_array([e])}},{key:"capture",value:function(e,r){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Oa;if(!this.__loaded||!this.sessionPersistence||!this._requestQueue)return j.uninitializedWarning("posthog.capture");if(!function(c){var u=!1;try{var f=c.config.token,p=c.config.respect_dnt,m=c.config.opt_out_capturing_persistence_type,g=c.config.opt_out_capturing_cookie_prefix||void 0,d=c.config.window;f&&(u=ud(f,{respectDnt:p,persistenceType:m,persistencePrefix:g,window:d}))}catch(y){j.error("Unexpected error when checking capturing opt-out status: "+y)}return u}(this)){var n=(i=i||Oa).transport;if(n&&(i.transport=n),!ve(e)&&St(e)){if(!Ge||!Jy(Ge,this.config.custom_blocked_useragents)){this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info();var s={uuid:ni(),event:e,properties:this._calculate_event_properties(e,r||{})};e==="$identify"&&(s.$set=i.$set,s.$set_once=i.$set_once),(s=$0(s,i._noTruncate?null:this.config.properties_string_max_length)).timestamp=i.timestamp||new Date;var a=ne(ne({},s.properties.$set),s.$set);D0(a)||this.setPersonPropertiesForFlags(a),j.info("send",s);var o=JSON.stringify(s),l=this.config.api_host+(i.endpoint||this.analyticsDefaultEndpoint),h=i!==Oa;return!this.config.request_batching||h&&!i._batchKey||i.send_instantly?this.__compress_and_send_json_request(l,o,i):this._requestQueue.enqueue(l,s,i),this._invokeCaptureHooks(e,s),s}}else j.error("No event name provided to posthog.capture")}}},{key:"_addCaptureHook",value:function(e){this.__captureHooks.push(e)}},{key:"_invokeCaptureHooks",value:function(e,r){this.config._onCapture(e,r),Ce(this.__captureHooks,function(i){return i(e)})}},{key:"_calculate_event_properties",value:function(e,r){if(!this.persistence||!this.sessionPersistence)return r;var i=this.persistence.remove_event_timer(e),n=ne({},r);if(n.token=this.config.token,e==="$snapshot"){var s=ne(ne({},this.persistence.properties()),this.sessionPersistence.properties());return n.distinct_id=s.distinct_id,n}var a=He.properties();if(this.sessionManager){var o=this.sessionManager.checkAndGetSessionAndWindowId(),l=o.sessionId,h=o.windowId;n.$session_id=l,n.$window_id=h}if(this.sessionPropsManager&&this.config.__preview_send_client_session_params&&(e==="$pageview"||e==="$pageleave"||e==="$autocapture")){var c=this.sessionPropsManager.getSessionProps();n=Ye(n,c)}if(this.config.__preview_measure_pageview_stats){var u={};e==="$pageview"?u=this.pageViewManager.doPageView():e==="$pageleave"&&(u=this.pageViewManager.doPageLeave()),n=Ye(n,u)}if(e==="$pageview"&&K&&(n.title=K.title),e==="$performance_event"){var f=this.persistence.properties();return n.distinct_id=f.distinct_id,n.$current_url=a.$current_url,n}if(!ve(i)){var p=new Date().getTime()-i;n.$duration=parseFloat((p/1e3).toFixed(3))}n=Ye({},He.properties(),this.persistence.properties(),this.sessionPersistence.properties(),n);var m=this.config.property_blacklist;We(m)?Ce(m,function(d){delete n[d]}):j.error("Invalid value for property_blacklist config: "+m);var g=this.config.sanitize_properties;return g&&(n=g(n,e)),n}},{key:"register",value:function(e,r){var i;(i=this.persistence)===null||i===void 0||i.register(e,r)}},{key:"register_once",value:function(e,r,i){var n;(n=this.persistence)===null||n===void 0||n.register_once(e,r,i)}},{key:"register_for_session",value:function(e){var r;(r=this.sessionPersistence)===null||r===void 0||r.register(e)}},{key:"unregister",value:function(e){var r;(r=this.persistence)===null||r===void 0||r.unregister(e)}},{key:"unregister_for_session",value:function(e){var r;(r=this.sessionPersistence)===null||r===void 0||r.unregister(e)}},{key:"_register_single",value:function(e,r){this.register(Y({},e,r))}},{key:"getFeatureFlag",value:function(e,r){return this.featureFlags.getFeatureFlag(e,r)}},{key:"getFeatureFlagPayload",value:function(e){var r=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(r)}catch{return r}}},{key:"isFeatureEnabled",value:function(e,r){return this.featureFlags.isFeatureEnabled(e,r)}},{key:"reloadFeatureFlags",value:function(){this.featureFlags.reloadFeatureFlags()}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,r)}},{key:"getEarlyAccessFeatures",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(e,r)}},{key:"onFeatureFlags",value:function(e){return this.featureFlags.onFeatureFlags(e)}},{key:"onSessionId",value:function(e){var r,i;return(r=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(e))!==null&&r!==void 0?r:function(){}}},{key:"getSurveys",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(e,r)}},{key:"getActiveMatchingSurveys",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(e,r)}},{key:"identify",value:function(e,r,i){if(!this.__loaded||!this.persistence)return j.uninitializedWarning("posthog.identify");if(e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))j.critical('The string "'.concat(e,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else{var n=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=n;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==n&&e!==this.get_property(Ba)&&(this.unregister(Ba),this.register({distinct_id:e}));var a=this.persistence.get_user_state()==="anonymous";e!==n&&a?(this.persistence.set_user_state("identified"),this.setPersonPropertiesForFlags(r||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:n},{$set:r||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(n)):(r||i)&&this.setPersonProperties(r,i),e!==n&&(this.reloadFeatureFlags(),this.unregister(Wa))}else j.error("Unique user id has not been set in posthog.identify")}},{key:"setPersonProperties",value:function(e,r){(e||r)&&(this.setPersonPropertiesForFlags(e||{}),this.capture("$set",{$set:e||{},$set_once:r||{}}))}},{key:"group",value:function(e,r,i){if(e&&r){var n=this.getGroups();n[e]!==r&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ne(ne({},n),{},Y({},e,r))}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:r,$group_set:i}),this.setGroupPropertiesForFlags(Y({},e,i))),n[e]===r||i||this.reloadFeatureFlags()}else j.error("posthog.group requires a group type and group key")}},{key:"resetGroups",value:function(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}},{key:"setPersonPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,r)}},{key:"resetPersonPropertiesForFlags",value:function(){this.featureFlags.resetPersonPropertiesForFlags()}},{key:"setGroupPropertiesForFlags",value:function(e){var r=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setGroupPropertiesForFlags(e,r)}},{key:"resetGroupPropertiesForFlags",value:function(e){this.featureFlags.resetGroupPropertiesForFlags(e)}},{key:"reset",value:function(e){var r,i,n,s;if(!this.__loaded)return j.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");(r=this.persistence)===null||r===void 0||r.clear(),(i=this.sessionPersistence)===null||i===void 0||i.clear(),(n=this.persistence)===null||n===void 0||n.set_user_state("anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId();var o=this.config.get_device_id(ni());this.register_once({distinct_id:o,$device_id:e?o:a},"")}},{key:"get_distinct_id",value:function(){return this.get_property("distinct_id")}},{key:"getGroups",value:function(){return this.get_property("$groups")||{}}},{key:"get_session_id",value:function(){var e,r;return(e=(r=this.sessionManager)===null||r===void 0?void 0:r.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}},{key:"get_session_replay_url",value:function(e){if(!this.sessionManager)return"";var r=this.config.ui_host||this.config.api_host,i=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=i.sessionId,s=i.sessionStartTimestamp,a=r+"/replay/"+n;if(e!=null&&e.withTimestamp&&s){var o,l=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!s)return a;var h=Math.max(Math.floor((new Date().getTime()-s)/1e3)-l,0);a+="?t=".concat(h)}return a}},{key:"alias",value:function(e,r){return e===this.get_property(Td)?(j.critical("Attempting to create alias for existing People user - aborting."),-2):(ve(r)&&(r=this.get_distinct_id()),e!==r?(this._register_single(Ba,e),this.capture("$create_alias",{alias:e,distinct_id:r})):(j.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1))}},{key:"set_config",value:function(e){var r,i,n=ne({},this.config);Pr(e)&&(Ye(this.config,e),this.config.persistence_name||(this.config.persistence_name=this.config.cookie_name),this.config.disable_persistence||(this.config.disable_persistence=this.config.disable_cookie),this.config.api_host=this.config.api_host.replace(/\/$/,""),(r=this.persistence)===null||r===void 0||r.update_config(this.config),(i=this.sessionPersistence)===null||i===void 0||i.update_config(this.config),Le.is_supported()&&Le.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(oi.DEBUG=!0),this.sessionRecording&&!ve(e.disable_session_recording)&&n.disable_session_recording!==e.disable_session_recording&&(e.disable_session_recording?this.sessionRecording.stopRecording():this.sessionRecording.startRecordingIfEnabled()))}},{key:"startSessionRecording",value:function(){this.set_config({disable_session_recording:!1})}},{key:"stopSessionRecording",value:function(){this.set_config({disable_session_recording:!0})}},{key:"sessionRecordingStarted",value:function(){var e;return!((e=this.sessionRecording)===null||e===void 0||!e.started)}},{key:"loadToolbar",value:function(e){return this.toolbar.loadToolbar(e)}},{key:"get_property",value:function(e){var r;return(r=this.persistence)===null||r===void 0?void 0:r.props[e]}},{key:"getSessionProperty",value:function(e){var r;return(r=this.sessionPersistence)===null||r===void 0?void 0:r.props[e]}},{key:"toString",value:function(){var e,r=(e=this.config.name)!==null&&e!==void 0?e:pt;return r!==pt&&(r=pt+"."+r),r}},{key:"_gdpr_init",value:function(){this.config.opt_out_capturing_persistence_type==="localStorage"&&Le.is_supported()&&(!this.has_opted_in_capturing()&&this.has_opted_in_capturing({persistence_type:"cookie"})&&this.opt_in_capturing({enable_persistence:!1}),!this.has_opted_out_capturing()&&this.has_opted_out_capturing({persistence_type:"cookie"})&&this.opt_out_capturing({clear_persistence:!1}),this.clear_opt_in_out_capturing({persistence_type:"cookie",enable_persistence:!1})),this.has_opted_out_capturing()?this._gdpr_update_persistence({clear_persistence:!0}):this.has_opted_in_capturing()||!this.config.opt_out_capturing_by_default&&!Jt.get("ph_optout")||(Jt.remove("ph_optout"),this.opt_out_capturing({clear_persistence:this.config.opt_out_persistence_by_default}))}},{key:"_gdpr_update_persistence",value:function(e){var r,i,n,s,a;if(e&&e.clear_persistence)n=!0;else{if(!e||!e.enable_persistence)return;n=!1}this.config.disable_persistence||((r=this.persistence)===null||r===void 0?void 0:r.disabled)===n||(s=this.persistence)===null||s===void 0||s.set_disabled(n),this.config.disable_persistence||((i=this.sessionPersistence)===null||i===void 0?void 0:i.disabled)===n||(a=this.sessionPersistence)===null||a===void 0||a.set_disabled(n)}},{key:"_gdpr_call_func",value:function(e,r){return r=Ye({capture:this.capture.bind(this),persistence_type:this.config.opt_out_capturing_persistence_type,cookie_prefix:this.config.opt_out_capturing_cookie_prefix,cookie_expiration:this.config.cookie_expiration,cross_subdomain_cookie:this.config.cross_subdomain_cookie,secure_cookie:this.config.secure_cookie},r||{}),Le.is_supported()||r.persistence_type!=="localStorage"||(r.persistence_type="cookie"),e(this.config.token,{capture:r.capture,captureEventName:r.capture_event_name,captureProperties:r.capture_properties,persistenceType:r.persistence_type,persistencePrefix:r.cookie_prefix,cookieExpiration:r.cookie_expiration,crossSubdomainCookie:r.cross_subdomain_cookie,secureCookie:r.secure_cookie})}},{key:"opt_in_capturing",value:function(e){e=Ye({enable_persistence:!0},e||{}),this._gdpr_call_func(vy,e),this._gdpr_update_persistence(e)}},{key:"opt_out_capturing",value:function(e){var r=Ye({clear_persistence:!0},e||{});this._gdpr_call_func(by,r),this._gdpr_update_persistence(r)}},{key:"has_opted_in_capturing",value:function(e){return this._gdpr_call_func(_y,e)}},{key:"has_opted_out_capturing",value:function(e){return this._gdpr_call_func(ud,e)}},{key:"clear_opt_in_out_capturing",value:function(e){var r=Ye({enable_persistence:!0},e??{});this._gdpr_call_func(wy,r),this._gdpr_update_persistence(r)}},{key:"debug",value:function(e){e===!1?(O?.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(O?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}}]),t}();(function(t,e){for(var r=0;r<e.length;r++)t.prototype[e[r]]=Ed(t.prototype[e[r]])})(yh,["identify"]);var yd,vd,Sr={},Ky=function(){Je.init=function(t,e,r){if(r)return Je[r]||(Je[r]=Sr[r]=ah(t||"",e||{},r,function(n){Je[r]=Sr[r]=n,n._loaded()})),Je[r];var i=Je;return Sr[pt]?i=Sr[pt]:t&&(i=ah(t,e||{},pt,function(n){Sr[pt]=n,n._loaded()}),Sr[pt]=i),Je=i,gh===Zn.INIT_SNIPPET&&(tt[pt]=Je),Ce(Sr,function(n,s){s!==pt&&(Je[s]=n)}),i}},Qy=function(){function t(){t.done||(t.done=!0,Gd=!1,Ce(Sr,function(e){e._dom_loaded()}))}K!=null&&K.addEventListener&&(K.readyState==="complete"?t():K.addEventListener("DOMContentLoaded",t,!1)),O&&qn(O,"load",t,!0)};(function(t){t.Popover="popover",t.API="api",t.Widget="widget"})(yd||(yd={})),function(t){t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link"}(vd||(vd={}));var Hd=(gh=Zn.INIT_MODULE,Je=new yh,Ky(),Je.init(),Qy(),Je);var qd=Hd.init("phc_OTZ3wJ6VemgVupCRKS5Sbqb9Ks0JYe0hMYZPtLwl0nu",{api_host:"https://pheu.molin.ai",ui_host:"https://eu.posthog.com",secure_cookie:document.location.protocol==="https:",persistence:"cookie",autocapture:!1,rageclick:!1,capture_pageview:!0,disable_session_recording:!0},"MolinShopAI");function dt(t,e){if(!qd)throw new Error("Failed to initialize PostHog");qd.capture(t,e)}var Ki,Ka,$t,Be,Qa,Ud,eo,Wd,to,Zd,ro,Yd,io,Jd,no,Xd,so,Kd,ao,Qd,Xa=class extends Fe(Pe){constructor(){super();W(this,Ki);W(this,Qa);W(this,eo);W(this,to);W(this,ro);W(this,io);W(this,no);W(this,so);W(this,ao);W(this,$t,new Ta(this,{url:(r,{resume:i}={})=>{let n=new URL(this.config.wsApiUrl);return n.searchParams.set("widgetId",this.widgetId),n.searchParams.set("resume",i?"1":""),n.searchParams.set("conversationId",r),n.searchParams.set("pageUrl",window.location.href),n},onReconnect:()=>{},onError:r=>{console.error("ws error",r),dt("ShopAssistant: error",{widgetId:this.widgetId,error:"websocket onError"})},onClose:()=>{},onNewMessage:r=>{r.role==="assistant"&&dt("ShopAssistant: user received bot message (streaming started)",{widgetId:this.widgetId,message:r})},onUpdateMessage:r=>{},onMessageDone:r=>{let i={...L(this,$t)?.messages.find(n=>n.id===r.message?.id)};Object.assign(i,r.message),i.role==="assistant"&&dt("ShopAssistant: user received bot message (streaming ended)",{widgetId:this.widgetId,text:i.content??"",message:i,usage_TOKENS_COMPLETION:r.message.usage.TOKENS_COMPLETION})},onMessageError:r=>{console.error("ws message error",r),r.message&&L(this,Be)&&alert(r.message),dt("ShopAssistant: error",{widgetId:this.widgetId,error:"websocket ERROR message type: "+r.message})},persistConversationState:(r,i)=>{let n={conversationId:r,messages:i};localStorage.setItem(L(this,Ki,Ka),JSON.stringify(n))},restoreConversationState:()=>{try{let r=JSON.parse(localStorage.getItem(L(this,Ki,Ka))||"{}");return!(typeof r.conversationId=="string"&&r.conversationId)||!(Array.isArray(r.messages)&&r.messages.every(i=>typeof i=="object"&&i))?void 0:{conversationId:r.conversationId,messages:r.messages}}catch(r){console.error(r)}},onReset:()=>{localStorage.removeItem(L(this,Ki,Ka))}}));W(this,Be,!1);this.widgetId="",this.config}render(){console.assert(this.widgetId,"widget id is required"),console.assert(this.config,"config is required");let r=Object.entries(this.config.bubble.position).filter(([a,o])=>o).map(([a,o])=>`${a}-[${o}]`).reduce((a,o)=>(a[o]=!0,a),{}),i={bottom:"72px"},n=Object.entries(this.config.bubble.position).filter(([a,o])=>o).map(([a,o])=>`sm:${a}-[calc(${[i[a],o].filter(l=>!!l).join("+")})]`).reduce((a,o)=>(a[o]=!0,a),{}),s=n;return ye`
|
|
421
421
|
<mw-bubble class="${Bp(r)} fixed z-[99999999]" @click=${ue(this,ro,Yd)} ?dialog-shown="${L(this,Be)}" bubble-image-url="${this.config.bubble?.imageUrl||""}"></mw-bubble>
|
|
422
422
|
|
|
423
423
|
${this.config?.popup?.mobileEnabled||this.config?.popup?.desktopEnabled?ye`
|