@molin.ai/shop-ai 0.4.41 → 0.4.42

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.
@@ -1011,7 +1011,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1011
1011
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var n,a=!0,h=!1;return{s:function(){i=i.call(t)},n:function(){var o=i.next();return a=o.done,o},e:function(o){h=!0,n=o},f:function(){try{a||i.return==null||i.return()}finally{if(h)throw n}}}}var mh={DEBUG:!1,LIB_VERSION:"1.100.0"},rE=Array.isArray,Ob=Object.prototype,Bb=Ob.hasOwnProperty,Dp=Ob.toString,Hr=rE||function(t){return Dp.call(t)==="[object Array]"},ib=function(t){return Dp.call(t)==="[object Uint8Array]"},ea=function(t){return typeof t=="function"},xo=function(t){return t===Object(t)&&!Hr(t)},sE=function(t){if(xo(t)){for(var e in t)if(Bb.call(t,e))return!1;return!0}return!1},Ai=function(t){return t===void 0},yn=function(t){return Dp.call(t)=="[object String]"},Rn=function(t){return t===null},$a=function(t){return Dp.call(t)=="[object Number]"},Im=function(t){return Dp.call(t)==="[object Boolean]"},zb=Array.prototype,rb=zb.forEach,sb=zb.indexOf,ne=typeof window<"u"?window:void 0,nb=ne?.navigator,Ue=ne?.document,Tr=nb?.userAgent,Ts=ne??{},ab="[PostHog.js]",De={_log:function(t){if(ne&&(mh.DEBUG||Ts.POSTHOG_DEBUG)&&!Ai(ne.console)&&ne.console){for(var e=("__rrweb_original__"in ne.console[t])?ne.console[t].__rrweb_original__:ne.console[t],i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];e.apply(void 0,[ab].concat(r))}},info:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];De._log.apply(De,["log"].concat(e))},warn:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];De._log.apply(De,["warn"].concat(e))},error:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];De._log.apply(De,["error"].concat(e))},critical:function(){for(var t,e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];(t=console).error.apply(t,[ab].concat(i))},uninitializedWarning:function(t){De.error("You must initialize PostHog before calling ".concat(t))}},Wm={},Gf=function(t){return t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function pl(t,e,i){if(Hr(t)){if(rb&&t.forEach===rb)t.forEach(e,i);else if("length"in t&&t.length===+t.length){for(var r=0,s=t.length;r<s;r++)if(r in t&&e.call(i,t[r],r)===Wm)return}}}function er(t,e,i){if(!Rn(t)&&!Ai(t)){if(Hr(t))return pl(t,e,i);for(var r in t)if(Bb.call(t,r)&&e.call(i,t[r],r)===Wm)return}}var ms=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];return pl(i,function(s){for(var n in s)s[n]!==void 0&&(t[n]=s[n])}),t};function $i(t,e){return t.indexOf(e)!==-1}function Lf(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Nb=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},hb=function(t){try{return t()}catch{return}},Gb=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];return t.apply(this,i)}catch(s){De.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),De.critical(s)}}},Fm=function(t){var e={};return er(t,function(i,r){yn(i)&&i.length>0&&(e[r]=i)}),e},nE=["$performance_raw"];function aE(t,e){return i=t,r=function(n,a){return a&&nE.indexOf(a)>-1?n:yn(n)&&!Rn(e)?n.slice(0,e):n},s=new Set,function n(a,h){return a!==Object(a)?r?r(a,h):a:s.has(a)?void 0:(s.add(a),Hr(a)?(o=[],pl(a,function(f){o.push(n(f))})):(o={},er(a,function(f,g){s.has(f)||(o[g]=n(f,g))})),o);var o}(i);var i,r,s}function Um(t){var e,i,r,s,n,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,o=0,f="",g=[];if(!t)return t;t=oE(t);do e=(n=t.charCodeAt(h++)<<16|t.charCodeAt(h++)<<8|t.charCodeAt(h++))>>18&63,i=n>>12&63,r=n>>6&63,s=63&n,g[o++]=a.charAt(e)+a.charAt(i)+a.charAt(r)+a.charAt(s);while(h<t.length);switch(f=g.join(""),t.length%3){case 1:f=f.slice(0,-2)+"==";break;case 2:f=f.slice(0,-1)+"="}return f}var oE=function(t){var e,i,r,s,n="";for(e=i=0,r=(t=(t+"").replace(/\r\n/g,`
1012
1012
  `).replace(/\r/g,`
1013
1013
  `)).length,s=0;s<r;s++){var a=t.charCodeAt(s),h=null;a<128?i++:h=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),Rn(h)||(i>e&&(n+=t.substring(e,i)),n+=h,e=i=s+1)}return i>e&&(n+=t.substring(e,t.length)),n},Ap=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,i,r,s,n){if(e)if(e.addEventListener&&!s)e.addEventListener(i,r,!!n);else{var a="on"+i,h=e[a];e[a]=function(o,f,g){return function(c){if(c=c||t(ne?.event)){var l,b=!0;ea(g)&&(l=g(c));var y=f.call(o,c);return l!==!1&&y!==!1||(b=!1),b}}}(e,r,h)}else De.error("No valid element provided to register_event")}}();function Ep(t,e){var i=function(){if(!Ue)return e("document not found");var r=Ue.createElement("script");r.type="text/javascript",r.src=t,r.onload=function(a){return e(void 0,a)},r.onerror=function(a){return e(a)};var s,n=Ue.querySelectorAll("body > script");n.length>0?(s=n[0].parentNode)===null||s===void 0||s.insertBefore(r,n[0]):Ue.body.appendChild(r)};Ue!=null&&Ue.body?i():Ue?.addEventListener("DOMContentLoaded",i)}function Ym(t){return t?Gf(t).split(/\s+/):[]}function $f(t){var e="";switch(Em(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 Ym(e)}function jf(t){var e="";return Rf(t)&&!jb(t)&&t.childNodes&&t.childNodes.length&&er(t.childNodes,function(i){$b(i)&&i.textContent&&(e+=Gf(i.textContent).split(/(\s+)/).filter(ol).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255))}),Gf(e)}function lb(t){return!!t&&t.nodeType===1}function dh(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function $b(t){return!!t&&t.nodeType===3}function pb(t){return!!t&&t.nodeType===11}var wm=["a","button","form","input","select","textarea","label"];function Rf(t){for(var e=t;e.parentNode&&!dh(e,"body");e=e.parentNode){var i=$f(e);if($i(i,"ph-sensitive")||$i(i,"ph-no-capture"))return!1}if($i($f(t),"ph-include"))return!0;var r=t.type||"";if(yn(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!(yn(s)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,"")))}function jb(t){return!!(dh(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||dh(t,"select")||dh(t,"textarea")||t.getAttribute("contenteditable")==="true")}function ol(t){return!(Rn(t)||Ai(t)||yn(t)&&(t=Gf(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 cb(t){var e=jf(t);return ol(e="".concat(e," ").concat(qb(t)).trim())?e:""}function qb(t){var e="";return t&&t.childNodes&&t.childNodes.length&&er(t.childNodes,function(i){var r;if(i&&((r=i.tagName)===null||r===void 0?void 0:r.toLowerCase())==="span")try{var s=jf(i);e="".concat(e," ").concat(s).trim(),i.childNodes&&i.childNodes.length&&(e="".concat(e," ").concat(qb(i)).trim())}catch(n){De.error(n)}}),e}function hE(t){return function(e){var i=e.map(function(r){var s,n,a="";if(r.tag_name&&(a+=r.tag_name),r.attr_class){r.attr_class.sort();var h,o=So(r.attr_class);try{for(o.s();!(h=o.n()).done;){var f=h.value;a+=".".concat(f.replace(/"/g,""))}}catch(l){o.e(l)}finally{o.f()}}var g=ri(ri(ri(ri({},r.text?{text:r.text}:{}),{},{"nth-child":(s=r.nth_child)!==null&&s!==void 0?s:0,"nth-of-type":(n=r.nth_of_type)!==null&&n!==void 0?n:0},r.href?{href:r.href}:{}),r.attr_id?{attr_id:r.attr_id}:{}),r.attributes),c={};return Lf(g).sort(function(l,b){var y=ta(l,1)[0],m=ta(b,1)[0];return y.localeCompare(m)}).forEach(function(l){var b=ta(l,2),y=b[0],m=b[1];return c[fb(y.toString())]=fb(m.toString())}),a+=":",a+=Lf(g).map(function(l){var b=ta(l,2),y=b[0],m=b[1];return"".concat(y,'="').concat(m,'"')}).join("")});return i.join(";")}(function(e){return e.map(function(i){var r,s,n={text:(r=i.$el_text)===null||r===void 0?void 0:r.slice(0,400),tag_name:i.tag_name,href:(s=i.attr__href)===null||s===void 0?void 0:s.slice(0,2048),attr_class:lE(i),attr_id:i.attr__id,nth_child:i.nth_child,nth_of_type:i.nth_of_type,attributes:{}};return Lf(i).filter(function(a){return ta(a,1)[0].indexOf("attr__")===0}).forEach(function(a){var h=ta(a,2),o=h[0],f=h[1];return n.attributes[o]=f}),n})}(t))}function fb(t){return t.replace(/"|\\"/g,'\\"')}function lE(t){var e=t.attr__class;return e?Hr(e)?e:Ym(e):void 0}var pE=function(){function t(e){Mr(this,t),this.clicks=[],this.enabled=e}return Dr(t,[{key:"isRageClick",value:function(e,i,r){if(!this.enabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(i-s.y)<30&&r-s.timestamp<1e3){if(this.clicks.push({x:e,y:i,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:e,y:i,timestamp:r}];return!1}}]),t}(),Hb="$people_distinct_id",Vf="__alias",kp="__timers",ub="$autocapture_disabled_server_side",Lm="$session_recording_enabled_server_side",db="$console_log_recording_enabled_server_side",mb="$session_recording_recorder_version_server_side",gb="$session_recording_network_payload_capture",qf="$sesid",Of="$session_is_sampled",hl="$enabled_feature_flags",Rm="$early_access_features",ll="$stored_person_properties",bo="$stored_group_properties",Vm="$surveys",Hf="$flag_call_reported",Om="$user_state",Bm="$posthog_quota_limited",zm="$client_session_props",cE=[Hb,Vf,"__cmpns",kp,Lm,qf,hl,Om,Bm,Rm,bo,ll,Vm,Hf,zm];function Pm(t,e){return e.length>t?e.slice(0,t)+"...":e}var _o={_initializedTokens:[],_isDisabledServerSide:null,_isAutocaptureEnabled:!1,_setIsAutocaptureEnabled:function(t){var e,i=Rn(this._isDisabledServerSide)?!((e=t.persistence)===null||e===void 0||!e.props[ub]):this._isDisabledServerSide,r=!!t.config.autocapture;this._isAutocaptureEnabled=r&&!i},_previousElementSibling:function(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!lb(e));return e},_getAugmentPropertiesFromElement:function(t){if(!Rf(t))return{};var e={};return er(t.attributes,function(i){if(i.name.indexOf("data-ph-capture-attribute")===0){var r=i.name.replace("data-ph-capture-attribute-",""),s=i.value;r&&s&&ol(s)&&(e[r]=s)}}),e},_getPropertiesFromElement:function(t,e,i){var r,s=t.tagName.toLowerCase(),n={tag_name:s};wm.indexOf(s)>-1&&!i&&(s.toLowerCase()==="a"||s.toLowerCase()==="button"?n.$el_text=Pm(1024,cb(t)):n.$el_text=Pm(1024,jf(t)));var a=$f(t);a.length>0&&(n.classes=a.filter(function(c){return c!==""}));var h=(r=this.config)===null||r===void 0?void 0:r.element_attribute_ignorelist;er(t.attributes,function(c){var l;if((!jb(t)||["name","id","class"].indexOf(c.name)!==-1)&&(h==null||!h.includes(c.name))&&!e&&ol(c.value)&&(l=c.name,!yn(l)||l.substring(0,10)!=="_ngcontent"&&l.substring(0,7)!=="_nghost")){var b=c.value;c.name==="class"&&(b=Ym(b).join(" ")),n["attr__"+c.name]=Pm(1024,b)}});for(var o=1,f=1,g=t;g=this._previousElementSibling(g);)o++,g.tagName===t.tagName&&f++;return n.nth_child=o,n.nth_of_type=f,n},_getDefaultProperties:function(t){return{$event_type:t,$ce_version:1}},_extractCustomPropertyValue:function(t){var e=[];return er(Ue?.querySelectorAll(t.css_selector),function(i){var r;["input","select"].indexOf(i.tagName.toLowerCase())>-1?r=i.value:i.textContent&&(r=i.textContent),ol(r)&&e.push(r)}),e.join(", ")},_getCustomProperties:function(t){var e=this,i={};return er(this._customProperties,function(r){er(r.event_selectors,function(s){er(Ue?.querySelectorAll(s),function(n){$i(t,n)&&Rf(n)&&(i[r.name]=e._extractCustomPropertyValue(r))})})}),i},_getEventTarget:function(t){return Ai(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 i,r=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"$autocapture",n=this._getEventTarget(t);if($b(n)&&(n=n.parentNode||null),s==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&(i=this.rageclicks)!==null&&i!==void 0&&i.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this._captureEvent(t,e,"$rageclick"),n&&function(m,C){var d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!ne||!m||dh(m,"html")||!lb(m))return!1;if(d!=null&&d.url_allowlist){var u=ne.location.href,v=d.url_allowlist;if(v&&!v.some(function(it){return u.match(it)}))return!1}if(d!=null&&d.dom_event_allowlist){var S=d.dom_event_allowlist;if(S&&!S.some(function(it){return C.type===it}))return!1}if(d!=null&&d.element_allowlist){var E=d.element_allowlist;if(E&&!E.some(function(it){return m.tagName.toLowerCase()===it}))return!1}if(d!=null&&d.css_selector_allowlist){var I=d.css_selector_allowlist;if(I&&!I.some(function(it){return m.matches(it)}))return!1}for(var B=!1,z=[m],tt=!0,lt=m;lt.parentNode&&!dh(lt,"body");)if(pb(lt.parentNode))z.push(lt.parentNode.host),lt=lt.parentNode.host;else{if(!(tt=lt.parentNode||!1))break;if(wm.indexOf(tt.tagName.toLowerCase())>-1)B=!0;else{var dt=ne.getComputedStyle(tt);dt&&dt.getPropertyValue("cursor")==="pointer"&&(B=!0)}z.push(tt),lt=tt}var ut=ne.getComputedStyle(m);if(ut&&ut.getPropertyValue("cursor")==="pointer"&&C.type==="click")return!0;var St=m.tagName.toLowerCase();switch(St){case"html":return!1;case"form":return C.type==="submit";case"input":case"select":case"textarea":return C.type==="change"||C.type==="click";default:return B?C.type==="click":C.type==="click"&&(wm.indexOf(St)>-1||m.getAttribute("contenteditable")==="true")}}(n,t,this.config)){for(var a,h,o=[n],f=n;f.parentNode&&!dh(f,"body");)pb(f.parentNode)?(o.push(f.parentNode.host),f=f.parentNode.host):(o.push(f.parentNode),f=f.parentNode);var g,c=[],l={},b=!1;if(er(o,function(m){var C=Rf(m);m.tagName.toLowerCase()==="a"&&(g=m.getAttribute("href"),g=C&&ol(g)&&g),$i($f(m),"ph-no-capture")&&(b=!0),c.push(r._getPropertiesFromElement(m,e.config.mask_all_element_attributes,e.config.mask_all_text));var d=r._getAugmentPropertiesFromElement(m);ms(l,d)}),e.config.mask_all_text||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?c[0].$el_text=cb(n):c[0].$el_text=jf(n)),g&&(c[0].attr__href=g),b)return!1;var y=ms(this._getDefaultProperties(t.type),e.elementsChainAsString?{$elements_chain:hE(c)}:{$elements:c},(a=c[0])!==null&&a!==void 0&&a.$el_text?{$el_text:(h=c[0])===null||h===void 0?void 0:h.$el_text}:{},this._getCustomProperties(o),l);return e.capture(s,y),!0}},_navigate:function(t){ne&&(ne.location.href=t)},_addDomEventHandlers:function(t){var e=this;if(ne&&Ue){var i=function(r){r=r||ne?.event,e._captureEvent(r,t)};Ap(Ue,"submit",i,!1,!0),Ap(Ue,"change",i,!1,!0),Ap(Ue,"click",i,!1,!0)}},_customProperties:[],rageclicks:null,config:void 0,init:function(t){var e;Im(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(i){return new RegExp(i)})),this.rageclicks=new pE(t.config.rageclick)},afterDecideResponse:function(t,e){var i=e.config.token;this._initializedTokens.indexOf(i)>-1?De.info('autocapture already initialized for token "'+i+'"'):(e.persistence&&e.persistence.register(Ne({},ub,!!t.autocapture_opt_out)),this._isDisabledServerSide=!!t.autocapture_opt_out,this._setIsAutocaptureEnabled(e),this._initializedTokens.push(i),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,i){if(!t)return!0;e=Ai(e)?10:e,i=Ai(i)?10:i;for(var r=0,s=0;s<t.length;s++)r+=t.charCodeAt(s);return r%e<i},isBrowserSupported:function(){return ea(Ue?.querySelectorAll)}};(function(t){for(var e in t)ea(t[e])&&(t[e]=t[e].bind(t))})(_o),function(t){for(var e in t)ea(t[e])&&(t[e]=Gb(t[e]))}(_o);var km="$active_feature_flags",Tf="$override_feature_flags",yb="$feature_flag_payloads",vb=function(t){var e,i={},r=So(Lf(t||{}));try{for(r.s();!(e=r.n()).done;){var s=ta(e.value,2),n=s[0],a=s[1];a&&(i[n]=a)}}catch(h){r.e(h)}finally{r.f()}return i},fE=function(){function t(e){Mr(this,t),this.instance=e,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return Dr(t,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var e=this.instance.get_property(hl),i=this.instance.get_property(Tf);if(!i)return e||{};for(var r=ms({},e),s=Object.keys(i),n=0;n<s.length;n++)i[s[n]]===!1?delete r[s[n]]:r[s[n]]=i[s[n]];return this._override_warning||(De.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:i,finalFlags:r}),this._override_warning=!0),r}},{key:"getFlagPayloads",value:function(){return this.instance.get_property(yb)||{}}},{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 i=this.instance.config.token,r=this.instance.get_property(ll),s=this.instance.get_property(bo),n=Um(JSON.stringify({token:i,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:r,group_properties:s,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0}));this.instance._send_request(this.instance.config.api_host+"/decide/?v=3",{data:n},{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 i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0){var r,s=this.getFlagVariants()[e],n="".concat(s),a=this.instance.get_property(Hf)||{};return(i.send_event||!("send_event"in i))&&(!(e in a)||!a[e].includes(n))&&(Hr(a[e])?a[e].push(n):a[e]=[n],(r=this.instance.persistence)===null||r===void 0||r.register(Ne({},Hf,a)),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:s})),s}De.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 i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,i);De.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(i){return i!==e})}},{key:"receivedFeatureFlags",value:function(e){if(this.instance.persistence){this.instance.decideEndpointWasHit=!0;var i=this.getFlagVariants(),r=this.getFlagPayloads();(function(s,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},o=s.featureFlags,f=s.featureFlagPayloads;if(o)if(Hr(o)){var g,c={};if(o)for(var l=0;l<o.length;l++)c[o[l]]=!0;n&&n.register((Ne(g={},km,o),Ne(g,hl,c),g))}else{var b,y=o,m=f;s.errorsWhileComputingFlags&&(y=ri(ri({},a),y),m=ri(ri({},h),m)),n&&n.register((Ne(b={},km,Object.keys(vb(y))),Ne(b,hl,y||{}),Ne(b,yb,m||{}),b))}})(e,this.instance.persistence,i,r),this._fireFeatureFlagsCallbacks()}}},{key:"override",value:function(e){if(!this.instance.__loaded||!this.instance.persistence)return De.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=!1,e===!1)this.instance.persistence.unregister(Tf);else if(Hr(e)){for(var i={},r=0;r<e.length;r++)i[e[r]]=!0;this.instance.persistence.register(Ne({},Tf,i))}else this.instance.persistence.register(Ne({},Tf,e))}},{key:"onFeatureFlags",value:function(e){var i=this;if(this.addFeatureFlagsHandler(e),this.instance.decideEndpointWasHit){var r=this._prepareFeatureFlagsForCallbacks(),s=r.flags,n=r.flagVariants;e(s,n)}return function(){return i.removeFeatureFlagsHandler(e)}}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,i){var r,s,n=Ne({},"$feature_enrollment/".concat(e),i);this.instance.capture("$feature_enrollment_update",{$feature_flag:e,$feature_enrollment:i,$set:n}),this.setPersonPropertiesForFlags(n,!1);var a=ri(ri({},this.getFlagVariants()),{},Ne({},e,i));(r=this.instance.persistence)===null||r===void 0||r.register((Ne(s={},km,Object.keys(vb(a))),Ne(s,hl,a),s)),this._fireFeatureFlagsCallbacks()}},{key:"getEarlyAccessFeatures",value:function(e){var i=this,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],s=this.instance.get_property(Rm);if(s&&!r)return e(s);this.instance._send_request("".concat(this.instance.config.api_host,"/api/early_access_features/?token=").concat(this.instance.config.token),{},{method:"GET"},function(n){var a,h=n.earlyAccessFeatures;return(a=i.instance.persistence)===null||a===void 0||a.register(Ne({},Rm,h)),e(h)})}},{key:"_prepareFeatureFlagsForCallbacks",value:function(){var e=this.getFlags(),i=this.getFlagVariants();return{flags:e.filter(function(r){return i[r]}),flagVariants:Object.keys(i).filter(function(r){return i[r]}).reduce(function(r,s){return r[s]=i[s],r},{})}}},{key:"_fireFeatureFlagsCallbacks",value:function(){var e=this._prepareFeatureFlagsForCallbacks(),i=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach(function(s){return s(i,r)})}},{key:"setPersonPropertiesForFlags",value:function(e){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(ll)||{};this.instance.register(Ne({},ll,ri(ri({},r),e))),i&&this.instance.reloadFeatureFlags()}},{key:"resetPersonPropertiesForFlags",value:function(){this.instance.unregister(ll)}},{key:"setGroupPropertiesForFlags",value:function(e){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],r=this.instance.get_property(bo)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(function(s){r[s]=ri(ri({},r[s]),e[s]),delete e[s]}),this.instance.register(Ne({},bo,ri(ri({},r),e))),i&&this.instance.reloadFeatureFlags()}},{key:"resetGroupPropertiesForFlags",value:function(e){if(e){var i=this.instance.get_property(bo)||{};this.instance.register(Ne({},bo,ri(ri({},i),{},Ne({},e,{}))))}else this.instance.unregister(bo)}}]),t}();Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return $a(t)&&isFinite(t)&&Math.floor(t)===t});var bb="0123456789abcdef",uE=function(){function t(e){if(Mr(this,t),this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}return Dr(t,[{key:"toString",value:function(){for(var e="",i=0;i<this.bytes.length;i++)e=e+bb.charAt(this.bytes[i]>>>4)+bb.charAt(15&this.bytes[i]),i!==3&&i!==5&&i!==7&&i!==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 i=0;i<16;i++){var r=this.bytes[i]-e.bytes[i];if(r!==0)return Math.sign(r)}return 0}}],[{key:"fromFieldsV7",value:function(e,i,r,s){if(!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||!Number.isInteger(s)||e<0||i<0||r<0||s<0||e>0xffffffffffff||i>4095||r>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|i>>>8,n[7]=i,n[8]=128|r>>>24,n[9]=r>>>16,n[10]=r>>>8,n[11]=r,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new t(n)}}]),t}(),dE=function(){function t(){Mr(this,t),Ne(this,"timestamp",0),Ne(this,"counter",0),Ne(this,"random",new mE)}return Dr(t,[{key:"generate",value:function(){var e=this.generateOrAbort();if(Ai(e)){this.timestamp=0;var i=this.generateOrAbort();if(Ai(i))throw new Error("Could not generate UUID after timestamp reset");return i}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 uE.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}(),Wb=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};ne&&!Ai(ne.crypto)&&crypto.getRandomValues&&(Wb=function(t){return crypto.getRandomValues(t)});var _b,mE=function(){function t(){Mr(this,t),Ne(this,"buffer",new Uint32Array(8)),Ne(this,"cursor",1/0)}return Dr(t,[{key:"nextUint32",value:function(){return this.cursor>=this.buffer.length&&(Wb(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}]),t}(),uh=function(){return gE().toString()},gE=function(){return(_b||(_b=new dE)).generate()},yE="Thu, 01 Jan 1970 00:00:00 GMT",Sp="",vE=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,bE=function(t){var e=t.match(vE);return e?e[0]:""};function _E(t,e){if(e){var i=function(s){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ue;if(Sp)return Sp;if(!n||["localhost","127.0.0.1"].includes(s))return"";for(var a=s.split("."),h=Math.min(a.length,8),o="dmn_chk_"+uh(),f=new RegExp("(^|;)\\s*"+o+"=1");!Sp&&h--;){var g=a.slice(h).join("."),c=o+"=1;domain=."+g;n.cookie=c,f.test(n.cookie)&&(n.cookie=c+";expires="+yE,Sp=g)}return Sp}(t);if(!i){var r=bE(t);r!==i&&De.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var ba={is_supported:function(){return!!Ue},error:function(t){De.error("cookieStore error: "+t)},get:function(t){if(Ue){try{for(var e=t+"=",i=Ue.cookie.split(";").filter(function(n){return n.length}),r=0;r<i.length;r++){for(var s=i[r];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}},parse:function(t){var e;try{e=JSON.parse(ba.get(t))||{}}catch{}return e},set:function(t,e,i,r,s){if(Ue)try{var n="",a="",h=_E(Ue.location.hostname,r);if(i){var o=new Date;o.setTime(o.getTime()+24*i*60*60*1e3),n="; expires="+o.toUTCString()}s&&(a="; secure");var f=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+h+a;return f.length>3686.4&&De.warn("cookieStore warning: large cookie, len="+f.length),Ue.cookie=f,f}catch{return}},remove:function(t,e){try{ba.set(t,"",-1,e)}catch{return}}},Cm=null,Lr={is_supported:function(){if(!Rn(Cm))return Cm;var t=!0;if(Ai(ne))t=!1;else try{var e="__mplssupport__";Lr.set(e,"xyz"),Lr.get(e)!=='"xyz"'&&(t=!1),Lr.remove(e)}catch{t=!1}return t||De.error("localStorage unsupported; falling back to cookie store"),Cm=t,t},error:function(t){De.error("localStorage error: "+t)},get:function(t){try{return ne?.localStorage.getItem(t)}catch(e){Lr.error(e)}return null},parse:function(t){try{return JSON.parse(Lr.get(t))||{}}catch{}return null},set:function(t,e){try{ne?.localStorage.setItem(t,JSON.stringify(e))}catch(i){Lr.error(i)}},remove:function(t){try{ne?.localStorage.removeItem(t)}catch(e){Lr.error(e)}}},xE=["distinct_id",qf,Of],Cp=ri(ri({},Lr),{},{parse:function(t){try{var e={};try{e=ba.parse(t)||{}}catch{}var i=ms(e,JSON.parse(Lr.get(t)||"{}"));return Lr.set(t,i),i}catch{}return null},set:function(t,e,i,r,s){try{Lr.set(t,e);var n={};xE.forEach(function(a){e[a]&&(n[a]=e[a])}),Object.keys(n).length&&ba.set(t,n,i,r,s)}catch(a){Lr.error(a)}},remove:function(t,e){try{ne?.localStorage.removeItem(t),ba.remove(t,e)}catch(i){Lr.error(i)}}}),Mf={},SE={is_supported:function(){return!0},error:function(t){De.error("memoryStorage error: "+t)},get:function(t){return Mf[t]||null},parse:function(t){return Mf[t]||null},set:function(t,e){Mf[t]=e},remove:function(t){delete Mf[t]}},ch=null,ys={is_supported:function(){if(!Rn(ch))return ch;if(ch=!0,Ai(ne))ch=!1;else try{var t="__support__";ys.set(t,"xyz"),ys.get(t)!=='"xyz"'&&(ch=!1),ys.remove(t)}catch{ch=!1}return ch},error:function(t){De.error("sessionStorage error: ",t)},get:function(t){try{return ne?.sessionStorage.getItem(t)}catch(e){ys.error(e)}return null},parse:function(t){try{return JSON.parse(ys.get(t))||null}catch{}return null},set:function(t,e){try{ne?.sessionStorage.setItem(t,JSON.stringify(e))}catch(i){ys.error(i)}},remove:function(t){try{ne?.sessionStorage.removeItem(t)}catch(e){ys.error(e)}}},wE=["localhost","127.0.0.1"],Ub=function(t){var e=Ue?.createElement("a");return Ai(e)?null:(e.href=t,e)},PE=function(t,e){return!!function(i){try{new RegExp(i)}catch{return!1}return!0}(e)&&new RegExp(e).test(t)},xb=function(t,e){for(var i,r=((t.split("#")[0]||"").split("?")[1]||"").split("&"),s=0;s<r.length;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!Hr(i)||i.length<2)return"";var a=i[1];try{a=decodeURIComponent(a)}catch{De.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Wf=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},qr={campaignParams:function(t){var e=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gad_source","gbraid","wbraid","fbclid","msclkid"].concat(t||[]),i={};return er(e,function(r){var s=Ue?xb(Ue.URL,r):"";s.length&&(i[r]=s)}),i},searchEngine:function(){var t=Ue?.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=qr.searchEngine(),e=t!="yahoo"?"q":"p",i={};if(!Rn(t)){i.$search_engine=t;var r=Ue?xb(Ue.referrer,e):"";r.length&&(i.ph_keyword=r)}return i},browser:function(t,e,i){return e=e||"",i||$i(t," OPR/")?$i(t,"Mini")?"Opera Mini":"Opera":/(BlackBerry|PlayBook|BB10)/i.test(t)?"BlackBerry":$i(t,"IEMobile")||$i(t,"WPDesktop")?"Internet Explorer Mobile":$i(t,"SamsungBrowser/")?"Samsung Internet":$i(t,"Edge")||$i(t,"Edg/")?"Microsoft Edge":$i(t,"FBIOS")?"Facebook Mobile":$i(t,"Chrome")?"Chrome":$i(t,"CriOS")?"Chrome iOS":$i(t,"UCWEB")||$i(t,"UCBrowser")?"UC Browser":$i(t,"FxiOS")?"Firefox iOS":$i(e,"Apple")||function(r){return $i(r,"Safari")&&!$i(r,"Chrome")&&!$i(r,"Android")}(t)?$i(t,"Mobile")?"Mobile Safari":"Safari":$i(t,"Android")?"Android Mobile":$i(t,"Konqueror")||$i(t,"konqueror")?"Konqueror":$i(t,"Firefox")?"Firefox":$i(t,"MSIE")||$i(t,"Trident/")?"Internet Explorer":$i(t,"Gecko")?"Mozilla":""},browserVersion:function(t,e,i){var r={"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+)?)/]}[qr.browser(t,e,i)];if(Ai(r))return null;for(var s=0;s<r.length;s++){var n=r[s],a=t.match(n);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 i=/OS (\d+)_(\d+)_?(\d+)?/i.exec(t);return i&&i[1]?{os_name:"iOS",os_version:[i[1],i[2],i[3]||"0"].join(".")}:{os_name:"iOS",os_version:""}}if(/Android/.test(t)){var r=/Android (\d+)\.(\d+)\.?(\d+)?/i.exec(t);return r&&r[1]?{os_name:"Android",os_version:[r[1],r[2],r[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 s=/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i.exec(t);return s&&s[1]?{os_name:"Mac OS X",os_version:[s[1],s[2],s[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 Ue?.referrer||"$direct"},referringDomain:function(){var t;return Ue!=null&&Ue.referrer&&((t=Ub(Ue.referrer))===null||t===void 0?void 0:t.host)||"$direct"},properties:function(){if(!Tr)return{};var t=qr.os(Tr),e=t.os_name,i=t.os_version;return ms(Fm({$os:e,$os_version:i,$browser:qr.browser(Tr,navigator.vendor,Ts.opera),$device:qr.device(Tr),$device_type:qr.deviceType(Tr)}),{$current_url:ne?.location.href,$host:ne?.location.host,$pathname:ne?.location.pathname,$raw_user_agent:Tr.length>1e3?Tr.substring(0,997)+"...":Tr,$browser_version:qr.browserVersion(Tr,navigator.vendor,Ts.opera),$browser_language:qr.browserLanguage(),$screen_height:ne?.screen.height,$screen_width:ne?.screen.width,$viewport_height:ne?.innerHeight,$viewport_width:ne?.innerWidth,$lib:"web",$lib_version:mh.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Nb()/1e3})},people_properties:function(){if(!Tr)return{};var t=qr.os(Tr),e=t.os_name,i=t.os_version;return ms(Fm({$os:e,$os_version:i,$browser:qr.browser(Tr,navigator.vendor,Ts.opera)}),{$browser_version:qr.browserVersion(Tr,navigator.vendor,Ts.opera)})}},kE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Sb=function(){function t(e){Mr(this,t);var i="";e.token&&(i=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_"+i+"_posthog",kE.indexOf(e.persistence.toLowerCase())===-1&&(De.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var r=e.persistence.toLowerCase();r==="localstorage"&&Lr.is_supported()?this.storage=Lr:r==="localstorage+cookie"&&Cp.is_supported()?this.storage=Cp:r==="sessionstorage"&&ys.is_supported()?this.storage=ys:r==="memory"?this.storage=SE:r==="cookie"?this.storage=ba:Cp.is_supported()?this.storage=Cp:this.storage=ba,this.load(),this.update_config(e),this.save()}return Dr(t,[{key:"properties",value:function(){var e={};return er(this.props,function(i,r){if(r===hl&&xo(i))for(var s=Object.keys(i),n=0;n<s.length;n++)e["$feature/".concat(s[n])]=i[s[n]];else h=r,o=!1,(Rn(a=cE)?o:sb&&a.indexOf===sb?a.indexOf(h)!=-1:(er(a,function(f){if(o||(o=f===h))return Wm}),o))||(e[r]=i);var a,h,o}),e}},{key:"load",value:function(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=ms({},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,i,r){var s=this;if(xo(e)){Ai(i)&&(i="None"),this.expire_days=Ai(r)?this.default_expiry:r;var n=!1;if(er(e,function(a,h){s.props.hasOwnProperty(h)&&s.props[h]!==i||(s.props[h]=a,n=!0)}),n)return this.save(),!0}return!1}},{key:"register",value:function(e,i){var r=this;if(xo(e)){this.expire_days=Ai(i)?this.default_expiry:i;var s=!1;if(er(e,function(n,a){e.hasOwnProperty(a)&&r.props[a]!==n&&(r.props[a]=n,s=!0)}),s)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(qr.campaignParams(this.custom_campaign_params)),this.campaign_params_saved=!0)}},{key:"update_search_keyword",value:function(){this.register(qr.searchInfo())}},{key:"update_referrer_info",value:function(){this.register({$referrer:this.props.$referrer||qr.referrer(),$referring_domain:this.props.$referring_domain||qr.referringDomain()})}},{key:"get_referrer_info",value:function(){return Fm({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}},{key:"safe_merge",value:function(e){return er(this.props,function(i,r){r in e||(e[r]=i)}),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,i){var r=this.props[kp]||{};r[e]=i,this.props[kp]=r,this.save()}},{key:"remove_event_timer",value:function(e){var i=(this.props[kp]||{})[e];return Ai(i)||(delete this.props[kp][e],this.save()),i}},{key:"get_user_state",value:function(){return this.props[Om]||"anonymous"}},{key:"set_user_state",value:function(e){this.props[Om]=e,this.save()}},{key:"get_quota_limits",value:function(){return this.props[Bm]||{}}},{key:"set_quota_limits",value:function(e){this.props[Bm]=e,this.save()}}]),t}(),wb=2,CE=4,Yb=3,AE=6,EE=0,TE="rrweb/console@1",ME=Dr(function t(e){var i,r,s=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Mr(this,t),Ne(this,"bucketSize",100),Ne(this,"refillRate",10),Ne(this,"mutationBuckets",{}),Ne(this,"loggedTracker",{}),Ne(this,"refillBuckets",function(){Object.keys(s.mutationBuckets).forEach(function(a){s.mutationBuckets[a]=s.mutationBuckets[a]+s.refillRate,s.mutationBuckets[a]>=s.bucketSize&&delete s.mutationBuckets[a]})}),Ne(this,"getNodeOrRelevantParent",function(a){var h=s.rrweb.mirror.getNode(a);if(h?.nodeName!=="svg"&&h instanceof Element){var o=h.closest("svg");if(o)return[s.rrweb.mirror.getId(o),o]}return[a,h]}),Ne(this,"numberOfChanges",function(a){var h,o,f,g,c,l,b,y;return((h=(o=a.removes)===null||o===void 0?void 0:o.length)!==null&&h!==void 0?h:0)+((f=(g=a.attributes)===null||g===void 0?void 0:g.length)!==null&&f!==void 0?f:0)+((c=(l=a.texts)===null||l===void 0?void 0:l.length)!==null&&c!==void 0?c:0)+((b=(y=a.adds)===null||y===void 0?void 0:y.length)!==null&&b!==void 0?b:0)}),Ne(this,"throttleMutations",function(a){if(a.type!==Yb||a.data.source!==EE)return a;var h=a.data,o=s.numberOfChanges(h);h.attributes&&(h.attributes=h.attributes.filter(function(g){var c,l,b,y=ta(s.getNodeOrRelevantParent(g.id),2),m=y[0],C=y[1];return s.mutationBuckets[m]===0?!1:(s.mutationBuckets[m]=(c=s.mutationBuckets[m])!==null&&c!==void 0?c:s.bucketSize,s.mutationBuckets[m]=Math.max(s.mutationBuckets[m]-1,0),s.mutationBuckets[m]===0&&(s.loggedTracker[m]||(s.loggedTracker[m]=!0,(l=(b=s.options).onBlockedNode)===null||l===void 0||l.call(b,m,C))),g)}));var f=s.numberOfChanges(h);return f!==0||o===f?a:void 0}),this.rrweb=e,this.options=n,this.refillRate=(i=this.options.refillRate)!==null&&i!==void 0?i:this.refillRate,this.bucketSize=(r=this.options.bucketSize)!==null&&r!==void 0?r:this.bucketSize,setInterval(function(){s.refillBuckets()},1e3)}),Zb=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}(Zb||{}),DE={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},IE=["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"],FE=["/s/","/e/","/i/vo/e/"];function Pb(t,e,i,r){var s=e?.["content-length"];return s&&parseInt(s)>i?"".concat(r," body too large to record"):t}var va,LE=function(t,e){var i,r,s,n=t.session_recording,a=n.recordHeaders!==!1&&e.recordHeaders,h=n.recordBody!==!1&&e.recordBody,o=n.recordPerformance!==!1&&e.recordPerformance,f=(i=n,s=Math.min(1e6,(r=i.payloadSizeLimitBytes)!==null&&r!==void 0?r:1e6),function(l){return l!=null&&l.requestBody&&(l.requestBody=Pb(l.requestBody,l.requestHeaders,s,"Request")),l!=null&&l.responseBody&&(l.responseBody=Pb(l.responseBody,l.responseHeaders,s,"Response")),l}),g=function(l){return f(function(m){var C=Ub(m.name);if(!(C&&C.pathname&&FE.includes(C.pathname)))return m}((b=l,Object.keys((y=b.requestHeaders)!==null&&y!==void 0?y:{}).forEach(function(m){var C;IE.includes(m.toLowerCase())&&((C=b.requestHeaders)===null||C===void 0||delete C[m])}),b)));var b,y},c=ea(t.session_recording.maskNetworkRequestFn);return c&&ea(t.session_recording.maskCapturedNetworkRequestFn)&&De.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),c&&(t.session_recording.maskCapturedNetworkRequestFn=function(l){var b=t.session_recording.maskNetworkRequestFn({url:l.name});return ri(ri({},l),{},{name:b?.url})}),n.maskRequestFn=ea(t.session_recording.maskCapturedNetworkRequestFn)?function(l){var b,y,m,C=g(l);return C&&(b=(y=(m=t.session_recording).maskCapturedNetworkRequestFn)===null||y===void 0?void 0:y.call(m,C))!==null&&b!==void 0?b:void 0}:void 0,n.maskRequestFn||(n.maskRequestFn=g),ri(ri(ri({},DE),n),{},{recordHeaders:a,recordBody:h,recordPerformance:o,recordInitialRequests:o})},RE="/s/",kb=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"})(va||(va={}));var VE=[va.MouseMove,va.MouseInteraction,va.Scroll,va.ViewportResize,va.Input,va.TouchMove,va.MediaInteraction,va.Drag],OE=function(){function t(e){var i=this;if(Mr(this,t),Ne(this,"isIdle",!1),Ne(this,"_linkedFlagSeen",!1),Ne(this,"_lastActivityTimestamp",Date.now()),Ne(this,"windowId",null),Ne(this,"sessionId",null),Ne(this,"_linkedFlag",null),Ne(this,"_sampleRate",null),Ne(this,"_minimumDuration",null),Ne(this,"_forceAllowLocalhostNetworkCapture",!1),this.instance=e,this._captureStarted=!1,this._endpoint=RE,this.stopRrweb=void 0,this.receivedDecide=!1,ne?.addEventListener("beforeunload",function(){i._flushBuffer()}),!this.instance.sessionManager)throw De.error("Session recording started without valid sessionManager"),new Error("Session recording started without valid sessionManager. This is a bug.");this.buffer=this.clearBuffer()}return Dr(t,[{key:"started",get:function(){return this._captureStarted}},{key:"sessionManager",get:function(){if(!this.instance.sessionManager)throw De.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 $a(this._sampleRate)?this.instance.get_property(Of):null}},{key:"sessionDuration",get:function(){var e,i,r=(e=this.buffer)===null||e===void 0?void 0:e.data[((i=this.buffer)===null||i===void 0?void 0:i.data.length)-1],s=this.sessionManager.checkAndGetSessionAndWindowId(!0).sessionStartTimestamp;return r?r.timestamp-s:null}},{key:"isRecordingEnabled",get:function(){var e=!!this.instance.get_property(Lm),i=!this.instance.config.disable_session_recording;return ne&&e&&i}},{key:"isConsoleLogCaptureEnabled",get:function(){var e=!!this.instance.get_property(db),i=this.instance.config.enable_recording_console_log;return i??e}},{key:"recordingVersion",get:function(){var e,i=this.instance.get_property(mb);return((e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recorderVersion)||i||"v1"}},{key:"networkPayloadCapture",get:function(){var e,i,r=this.instance.get_property(gb),s={recordHeaders:(e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recordHeaders,recordBody:(i=this.instance.config.session_recording)===null||i===void 0?void 0:i.recordBody},n=s?.recordHeaders||r?.recordHeaders,a=s?.recordBody||r?.recordBody,h=this.instance.config.capture_performance||r?.capturePerformance;return n||a||h?{recordHeaders:n,recordBody:a,recordPerformance:h}:void 0}},{key:"status",get:function(){return this.receivedDecide?this.isRecordingEnabled?yn(this._linkedFlag)&&!this._linkedFlagSeen?"buffering":Im(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 i,r=this.sessionId!==e;if($a(this._sampleRate)){var s,n=this.isSampled;r||!Im(n)?s=Math.random()<this._sampleRate:s=n,s||De.warn("[SessionSampling] Sample rate (".concat(this._sampleRate,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),(i=this.instance.persistence)===null||i===void 0||i.register(Ne({},Of,s))}else{var a;(a=this.instance.persistence)===null||a===void 0||a.register(Ne({},Of,null))}}},{key:"afterDecideResponse",value:function(e){var i,r,s,n,a,h,o,f,g=this;this.instance.persistence&&this.instance.persistence.register((Ne(f={},Lm,!!e.sessionRecording),Ne(f,db,(a=e.sessionRecording)===null||a===void 0?void 0:a.consoleLogRecordingEnabled),Ne(f,mb,(h=e.sessionRecording)===null||h===void 0?void 0:h.recorderVersion),Ne(f,gb,ri({capturePerformance:e.capturePerformance},(o=e.sessionRecording)===null||o===void 0?void 0:o.networkPayloadCapture)),f));var c=(i=e.sessionRecording)===null||i===void 0?void 0:i.sampleRate;this._sampleRate=Ai(c)||Rn(c)?null:parseFloat(c);var l,b=(r=e.sessionRecording)===null||r===void 0?void 0:r.minimumDurationMilliseconds;if(this._minimumDuration=Ai(b)?null:b,this._linkedFlag=((s=e.sessionRecording)===null||s===void 0?void 0:s.linkedFlag)||null,(n=e.sessionRecording)!==null&&n!==void 0&&n.endpoint&&(this._endpoint=(l=e.sessionRecording)===null||l===void 0?void 0:l.endpoint),$a(this._sampleRate)&&this.sessionManager.onSessionId(function(m){g.makeSamplingDecision(m)}),yn(this._linkedFlag)){var y=this._linkedFlag;this.instance.onFeatureFlags(function(m){g._linkedFlagSeen=m.includes(y)})}this.receivedDecide=!0,this.startRecordingIfEnabled()}},{key:"log",value:function(e){var i,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(i=this.instance.sessionRecording)===null||i===void 0||i.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:r,trace:[],payload:[JSON.stringify(e)]}},timestamp:Nb()})}},{key:"startCaptureAndTrySendingQueuedSnapshots",value:function(){this._startCapture()}},{key:"_startCapture",value:function(){var e=this;if(!Ai(Object.assign)&&!this._captureStarted&&!this.instance.config.disable_session_recording){this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId();var i=this.recordingVersion==="v2"?"recorder-v2.js":"recorder.js";this.instance.__loaded_recorder_version!==this.recordingVersion?Ep(this.instance.config.api_host+"/static/".concat(i,"?v=").concat(mh.LIB_VERSION),function(r){if(r)return De.error("Could not load ".concat(i),r);e._onScriptLoaded()}):this._onScriptLoaded()}}},{key:"_isInteractiveEvent",value:function(e){var i;return e.type===Yb&&VE.indexOf((i=e.data)===null||i===void 0?void 0:i.source)!==-1}},{key:"_updateWindowAndSessionIds",value:function(e){var i=this._isInteractiveEvent(e);i||this.isIdle||e.timestamp-this._lastActivityTimestamp>kb&&(this.isIdle=!0,this._tryAddCustomEvent("sessionIdle",{reason:"user inactivity",timeSinceLastActive:e.timestamp-this._lastActivityTimestamp,threshold:kb}));var r=!1;if(i&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),r=!0)),!this.isIdle){var s=this.sessionManager.checkAndGetSessionAndWindowId(!i,e.timestamp),n=s.windowId,a=s.sessionId,h=this.sessionId!==a,o=this.windowId!==n;this.windowId=n,this.sessionId=a,(r||[wb,CE].indexOf(e.type)===-1&&(o||h))&&this._tryTakeFullSnapshot()}}},{key:"_tryRRwebMethod",value:function(e){if(!this._captureStarted)return!1;try{return e(),!0}catch(i){return De.error("[Session-Recording] using rrweb when not started.",i),!1}}},{key:"_tryAddCustomEvent",value:function(e,i){var r=this;return this._tryRRwebMethod(function(){var s;return(s=r.rrwebRecord)===null||s===void 0?void 0:s.addCustomEvent(e,i)})}},{key:"_tryTakeFullSnapshot",value:function(){var e=this;return this._tryRRwebMethod(function(){var i;return(i=e.rrwebRecord)===null||i===void 0?void 0:i.takeFullSnapshot()})}},{key:"_onScriptLoaded",value:function(){var e,i=this,r={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=ne.rrweb?ne.rrweb.record:ne.rrwebRecord;for(var s=this.instance.config.session_recording,n=0,a=Object.entries(s||{});n<a.length;n++){var h=ta(a[n],2),o=h[0],f=h[1];o in r&&(r[o]=f)}if(this.rrwebRecord){this.mutationRateLimiter=(e=this.mutationRateLimiter)!==null&&e!==void 0?e:new ME(this.rrwebRecord,{onBlockedNode:function(c,l){var b="Too many mutations on node '".concat(c,"'. Rate limiting. This could be due to SVG animations or something similar");De.info(b,{node:l}),i.log("[PostHog Recorder] "+b,"warn")}});var g=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(ri({emit:function(c){i.onRRwebEmit(c)},plugins:g},r)),this.instance._addCaptureHook(function(c){try{if(c==="$pageview"){var l=ne?i._maskUrl(ne.location.href):"";if(!l)return;i._tryAddCustomEvent("$pageview",{href:l})}}catch(b){De.error("Could not add $pageview to rrweb session",b)}}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:r,activePlugins:g.map(function(c){return c?.name})})}else De.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}},{key:"_gatherRRWebPlugins",value:function(){var e=[];return Ts.rrwebConsoleRecord&&this.isConsoleLogCaptureEnabled&&e.push(Ts.rrwebConsoleRecord.getRecordConsolePlugin()),this.networkPayloadCapture&&ea(Ts.getRecordNetworkPlugin)&&(!wE.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?e.push(Ts.getRecordNetworkPlugin(LE(this.instance.config,this.networkPayloadCapture))):De.info("[SessionReplay-NetworkCapture] not started because we are on localhost.")),e}},{key:"onRRwebEmit",value:function(e){if(e&&xo(e)){if(e.type===Zb.Meta){var i=this._maskUrl(e.data.href);if(!i)return;e.data.href=i}var r=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(r){var s=function(h){var o=h;if(o&&xo(o)&&o.type===AE&&xo(o.data)&&o.data.plugin===TE){o.data.payload.payload.length>10&&(o.data.payload.payload=o.data.payload.payload.slice(0,10),o.data.payload.payload.push("...[truncated]"));for(var f=[],g=0;g<o.data.payload.payload.length;g++)o.data.payload.payload[g]&&o.data.payload.payload[g].length>2e3?f.push(o.data.payload.payload[g].slice(0,2e3)+"...[truncated]"):f.push(o.data.payload.payload[g]);return o.data.payload.payload=f,h}return h}(r),n=JSON.stringify(s).length;if(this._updateWindowAndSessionIds(s),!this.isIdle){var a={$snapshot_bytes:n,$snapshot_data:s,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(a):this.clearBuffer()}}}}},{key:"_maskUrl",value:function(e){var i=this.instance.config.session_recording;if(i.maskNetworkRequestFn){var r,s={url:e};return(r=s=i.maskNetworkRequestFn(s))===null||r===void 0?void 0:r.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 i=this._minimumDuration,r=this.sessionDuration,s=$a(r)&&r>=0,n=$a(i)&&s&&r<i;return this.status==="buffering"||n?(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 i,r=this,s=2+(((i=this.buffer)===null||i===void 0?void 0:i.data.length)||0);(!this.buffer||this.buffer.size+e.$snapshot_bytes+s>943718.4||this.buffer.sessionId&&this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),Rn(this.buffer.sessionId)&&!Rn(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(){r._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===wb}})}}]),t}(),BE=function(){function t(e){Mr(this,t),this.instance=e,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}return Dr(t,[{key:"call",value:function(){var e=this,i=Um(JSON.stringify({token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(ll),group_properties:this.instance.get_property(bo),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:i,verbose:!0},{method:"POST"},function(r){return e.parseDecideResponse(r)})}},{key:"parseDecideResponse",value:function(e){var i,r=this;if(this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer(),e?.status!==0){if(!Ue||!Ue.body)return De.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){r.parseDecideResponse(e)},500);this.instance.toolbar.afterDecideResponse(e),(i=this.instance.sessionRecording)===null||i===void 0||i.afterDecideResponse(e),_o.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 s=ne?.extendPostHogWithSurveys;e.surveys&&!s&&Ep(this.instance.config.api_host+"/static/surveys.js",function(g){if(g)return De.error("Could not load surveys script",g);ne.extendPostHogWithSurveys(r.instance)});var n=ne?.extendPostHogWithExceptionAutoCapture;if(e.autocaptureExceptions&&e.autocaptureExceptions&&Ai(n)&&Ep(this.instance.config.api_host+"/static/exception-autocapture.js",function(g){if(g)return De.error("Could not load exception autocapture script",g);ne.extendPostHogWithExceptionAutocapture(r.instance,e)}),e.siteApps)if(this.instance.config.opt_in_site_apps){var a,h=this.instance.config.api_host,o=So(e.siteApps);try{var f=function(){var g=a.value,c=g.id,l=g.url,b=[h,h[h.length-1]==="/"&&l[0]==="/"?l.substring(1):l].join("");Ts["__$$ph_site_app_".concat(c)]=r.instance,Ep(b,function(y){y&&De.error("Error while initializing PostHog app with config id ".concat(c),y)})};for(o.s();!(a=o.n()).done;)f()}catch(g){o.e(g)}finally{o.f()}}else e.siteApps.length>0&&De.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}else De.error("Failed to fetch feature flags from PostHog.")}}]),t}(),zE=["https://app.posthog.com","https://eu.posthog.com"],NE=["source"],GE=ne!=null&&ne.location?Wf(ne.location.hash,"__posthog")||Wf(location.hash,"state"):null,$E=function(){function t(e){Mr(this,t),this.instance=e}return Dr(t,[{key:"afterDecideResponse",value:function(e){var i=e.toolbarParams||e.editorParams||(e.toolbarVersion?{toolbarVersion:e.toolbarVersion}:{});e.isAuthenticated&&i.toolbarVersion&&i.toolbarVersion.indexOf("toolbar")===0&&this.loadToolbar(ri({},i))}},{key:"maybeLoadToolbar",value:function(){var e,i,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!ne||!Ue)return!1;r=(e=r)!==null&&e!==void 0?e:ne.location,n=(i=n)!==null&&i!==void 0?i:ne.history;try{if(!s){try{ne.localStorage.setItem("test","test"),ne.localStorage.removeItem("test")}catch{return!1}s=ne?.localStorage}var a,h=GE||Wf(r.hash,"__posthog")||Wf(r.hash,"state"),o=h?hb(function(){return JSON.parse(atob(decodeURIComponent(h)))})||hb(function(){return JSON.parse(decodeURIComponent(h))}):null;return o&&o.action==="ph_authorize"?((a=o).source="url",a&&Object.keys(a).length>0&&(o.desiredHash?r.hash=o.desiredHash:n?n.replaceState("",Ue.title,r.pathname+r.search):r.hash="")):((a=JSON.parse(s.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 i=this;if(!ne||Ts._postHogToolbarLoaded)return!1;Ts._postHogToolbarLoaded=!0;var r=this.instance.config.api_host,s=3e5,n=Math.floor(Date.now()/s)*s,a="".concat(r).concat(r.endsWith("/")?"":"/","static/toolbar.js?t=").concat(n),h=!zE.includes(this.instance.config.api_host)&&this.instance.config.advanced_disable_toolbar_metrics,o=ri(ri({token:this.instance.config.token},e),{},{apiURL:r},h?{instrument:!1}:{});o.source;var f=eE(o,NE);return ne.localStorage.setItem("_postHogToolbarParams",JSON.stringify(f)),Ep(a,function(g){g?De.error("Failed to load toolbar",g):(Ts.ph_load_toolbar||Ts.ph_load_editor)(o,i.instance)}),Ap(ne,"turbolinks:load",function(){Ts._postHogToolbarLoaded=!1,i.loadToolbar(o)}),!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,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(e,i,r)}}]),t}(),jE="__ph_opt_in_out_";function qE(t,e){Jb(!0,t,e)}function HE(t,e){Jb(!1,t,e)}function WE(t,e){return Xb(t,e)==="1"}function Cb(t,e){return!!function(i){if(i&&i.respectDnt){var r=i&&i.window||ne,s=r?.navigator,n=!1;return er([s?.doNotTrack,s.msDoNotTrack,r.doNotTrack],function(a){$i([!0,1,"1","yes"],a)&&(n=!0)}),n}return!1}(e)||Xb(t,e)==="0"}function UE(t,e){Zm(e=e||{}).remove(Xm(t,e),!!e.crossSubdomainCookie)}function Zm(t){return(t=t||{}).persistenceType==="localStorage"?Lr:t.persistenceType==="localStorage+cookie"?Cp:ba}function Xm(t,e){return((e=e||{}).persistencePrefix||jE)+t}function Xb(t,e){return Zm(e).get(Xm(t,e))}function Jb(t,e,i){yn(e)&&e.length?(Zm(i=i||{}).set(Xm(e,i),t?1:0,$a(i.cookieExpiration)?i.cookieExpiration:null,i.crossSubdomainCookie,i.secureCookie),i.capture&&t&&i.capture(i.captureEventName||"$opt_in",i.captureProperties||{},{send_instantly:!0})):De.error("gdpr."+(t?"optIn":"optOut")+" called with an invalid token")}var Kb=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:3e3;Mr(this,t),this.isPolling=!0,this._event_queue=[],this._empty_queue_count=0,this._poller=void 0,this._pollInterval=e}return Dr(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}(),YE=function(t){Rb(i,Kb);var e=Vb(i);function i(r){var s,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3e3;return Mr(this,i),(s=e.call(this,n)).handlePollRequest=r,s}return Dr(i,[{key:"enqueue",value:function(r,s,n){this._event_queue.push({url:r,data:s,options:n}),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var r=this;clearTimeout(this._poller),this._poller=setTimeout(function(){if(r._event_queue.length>0){var s=r.formatQueue(),n=function(h){var o=s[h],f=o.url,g=o.data,c=o.options;er(g,function(l,b){g[b].offset=Math.abs(g[b].timestamp-r.getTime()),delete g[b].timestamp}),r.handlePollRequest(f,g,c)};for(var a in s)n(a);r._event_queue.length=0,r._empty_queue_count=0}else r._empty_queue_count++;r._empty_queue_count>4&&(r.isPolling=!1,r._empty_queue_count=0),r.isPolling&&r.poll()},this._pollInterval)}},{key:"unload",value:function(){var r=this;clearTimeout(this._poller);var s=this._event_queue.length>0?this.formatQueue():{};this._event_queue.length=0;var n=Object.values(s);[].concat(Mm(n.filter(function(a){return a.url.indexOf("/e")===0})),Mm(n.filter(function(a){return a.url.indexOf("/e")!==0}))).map(function(a){var h=a.url,o=a.data,f=a.options;r.handlePollRequest(h,o,ri(ri({},f),{},{transport:"sendBeacon"}))})}},{key:"formatQueue",value:function(){var r={};return er(this._event_queue,function(s){var n=s.url,a=s.data,h=s.options,o=(h?h._batchKey:null)||n;Ai(r[o])&&(r[o]={data:[],url:n,options:h}),h&&r[o].options&&r[o].options._metrics&&!r[o].options._metrics.rrweb_full_snapshot&&(r[o].options._metrics.rrweb_full_snapshot=h._metrics.rrweb_full_snapshot),r[o].data.push(a)}),r}}]),i}(),vn=Uint8Array,Bs=Uint16Array,cl=Uint32Array,Jm=new vn([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]),Km=new vn([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]),Ab=new vn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qb=function(t,e){for(var i=new Bs(31),r=0;r<31;++r)i[r]=e+=1<<t[r-1];var s=new cl(i[30]);for(r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return[i,s]},t_=Qb(Jm,2),ZE=t_[0],Nm=t_[1];ZE[28]=258,Nm[258]=28;for(Gm=Qb(Km,0)[1],Uf=new Bs(32768),nr=0;nr<32768;++nr)yo=(43690&nr)>>>1|(21845&nr)<<1,yo=(61680&(yo=(52428&yo)>>>2|(13107&yo)<<2))>>>4|(3855&yo)<<4,Uf[nr]=((65280&yo)>>>8|(255&yo)<<8)>>>1;var yo,Gm,Uf,nr,Tp=function(t,e,i){for(var r=t.length,s=0,n=new Bs(e);s<r;++s)++n[t[s]-1];var a,h=new Bs(e);for(s=0;s<e;++s)h[s]=h[s-1]+n[s-1]<<1;if(i){a=new Bs(1<<e);var o=15-e;for(s=0;s<r;++s)if(t[s])for(var f=s<<4|t[s],g=e-t[s],c=h[t[s]-1]++<<g,l=c|(1<<g)-1;c<=l;++c)a[Uf[c]>>>o]=f}else for(a=new Bs(r),s=0;s<r;++s)a[s]=Uf[h[t[s]-1]++]>>>15-t[s];return a},gh=new vn(288);for(nr=0;nr<144;++nr)gh[nr]=8;for(nr=144;nr<256;++nr)gh[nr]=9;for(nr=256;nr<280;++nr)gh[nr]=7;for(nr=280;nr<288;++nr)gh[nr]=8;var Yf=new vn(32);for(nr=0;nr<32;++nr)Yf[nr]=5;var fh,XE=Tp(gh,9,0),JE=Tp(Yf,5,0),e_=function(t){return(t/8>>0)+(7&t&&1)},i_=function(t,e,i){(e==null||e<0)&&(e=0),(i==null||i>t.length)&&(i=t.length);var r=new(t instanceof Bs?Bs:t instanceof cl?cl:vn)(i-e);return r.set(t.subarray(e,i)),r},Ga=function(t,e,i){i<<=7&e;var r=e/8>>0;t[r]|=i,t[r+1]|=i>>>8},wp=function(t,e,i){i<<=7&e;var r=e/8>>0;t[r]|=i,t[r+1]|=i>>>8,t[r+2]|=i>>>16},Am=function(t,e){for(var i=[],r=0;r<t.length;++r)t[r]&&i.push({s:r,f:t[r]});var s=i.length,n=i.slice();if(!s)return[new vn(0),0];if(s==1){var a=new vn(i[0].s+1);return a[i[0].s]=1,[a,1]}i.sort(function(E,I){return E.f-I.f}),i.push({s:-1,f:25001});var h=i[0],o=i[1],f=0,g=1,c=2;for(i[0]={s:-1,f:h.f+o.f,l:h,r:o};g!=s-1;)h=i[i[f].f<i[c].f?f++:c++],o=i[f!=g&&i[f].f<i[c].f?f++:c++],i[g++]={s:-1,f:h.f+o.f,l:h,r:o};var l=n[0].s;for(r=1;r<s;++r)n[r].s>l&&(l=n[r].s);var b=new Bs(l+1),y=KE(i[g-1],b,0);if(y>e){r=0;var m=0,C=y-e,d=1<<C;for(n.sort(function(E,I){return b[I.s]-b[E.s]||E.f-I.f});r<s;++r){var u=n[r].s;if(!(b[u]>e))break;m+=d-(1<<y-b[u]),b[u]=e}for(m>>>=C;m>0;){var v=n[r].s;b[v]<e?m-=1<<e-b[v]++-1:++r}for(;r>=0&&m;--r){var S=n[r].s;b[S]==e&&(--b[S],++m)}y=e}return[new vn(b),y]},KE=function t(e,i,r){return e.s==-1?Math.max(t(e.l,i,r+1),t(e.r,i,r+1)):i[e.s]=r},Eb=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Bs(++e),r=0,s=t[0],n=1,a=function(o){i[r++]=o},h=1;h<=e;++h)if(t[h]==s&&h!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(s),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(s);n=1,s=t[h]}return[i.subarray(0,r),e]},Pp=function(t,e){for(var i=0,r=0;r<e.length;++r)i+=t[r]*e[r];return i},Bf=function(t,e,i){var r=i.length,s=e_(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;n<r;++n)t[s+n+4]=i[n];return 8*(s+4+r)},Tb=function(t,e,i,r,s,n,a,h,o,f,g){Ga(e,g++,i),++s[256];for(var c=Am(s,15),l=c[0],b=c[1],y=Am(n,15),m=y[0],C=y[1],d=Eb(l),u=d[0],v=d[1],S=Eb(m),E=S[0],I=S[1],B=new Bs(19),z=0;z<u.length;++z)B[31&u[z]]++;for(z=0;z<E.length;++z)B[31&E[z]]++;for(var tt=Am(B,7),lt=tt[0],dt=tt[1],ut=19;ut>4&&!lt[Ab[ut-1]];--ut);var St,it,vt,D,O=f+5<<3,w=Pp(s,gh)+Pp(n,Yf)+a,L=Pp(s,l)+Pp(n,m)+a+14+3*ut+Pp(B,lt)+(2*B[16]+3*B[17]+7*B[18]);if(O<=w&&O<=L)return Bf(e,g,t.subarray(o,o+f));if(Ga(e,g,1+(L<w)),g+=2,L<w){St=Tp(l,b,0),it=l,vt=Tp(m,C,0),D=m;var J=Tp(lt,dt,0);for(Ga(e,g,v-257),Ga(e,g+5,I-1),Ga(e,g+10,ut-4),g+=14,z=0;z<ut;++z)Ga(e,g+3*z,lt[Ab[z]]);g+=3*ut;for(var U=[u,E],Gt=0;Gt<2;++Gt){var Dt=U[Gt];for(z=0;z<Dt.length;++z){var Ht=31&Dt[z];Ga(e,g,J[Ht]),g+=lt[Ht],Ht>15&&(Ga(e,g,Dt[z]>>>5&127),g+=Dt[z]>>>12)}}}else St=XE,it=gh,vt=JE,D=Yf;for(z=0;z<h;++z)if(r[z]>255){Ht=r[z]>>>18&31,wp(e,g,St[Ht+257]),g+=it[Ht+257],Ht>7&&(Ga(e,g,r[z]>>>23&31),g+=Jm[Ht]);var Ot=31&r[z];wp(e,g,vt[Ot]),g+=D[Ot],Ot>3&&(wp(e,g,r[z]>>>5&8191),g+=Km[Ot])}else wp(e,g,St[r[z]]),g+=it[r[z]];return wp(e,g,St[256]),g+it[256]},QE=new cl([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),t2=new vn(0),e2=function(){for(var t=new cl(256),e=0;e<256;++e){for(var i=e,r=9;--r;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),i2=function(){var t=4294967295;return{p:function(e){for(var i=t,r=0;r<e.length;++r)i=e2[255&i^e[r]]^i>>>8;t=i},d:function(){return 4294967295^t}}},r2=function(t,e,i,r,s){return function(n,a,h,o,f,g){var c=n.length,l=new vn(o+c+5*(1+Math.floor(c/7e3))+f),b=l.subarray(o,l.length-f),y=0;if(!a||c<8)for(var m=0;m<=c;m+=65535){var C=m+65535;C<c?y=Bf(b,y,n.subarray(m,C)):(b[m]=g,y=Bf(b,y,n.subarray(m,c)))}else{for(var d=QE[a-1],u=d>>>13,v=8191&d,S=(1<<h)-1,E=new Bs(32768),I=new Bs(S+1),B=Math.ceil(h/3),z=2*B,tt=function(Ye){return(n[Ye]^n[Ye+1]<<B^n[Ye+2]<<z)&S},lt=new cl(25e3),dt=new Bs(288),ut=new Bs(32),St=0,it=0,vt=(m=0,0),D=0,O=0;m<c;++m){var w=tt(m),L=32767&m,J=I[w];if(E[L]=J,I[w]=L,D<=m){var U=c-m;if((St>7e3||vt>24576)&&U>423){y=Tb(n,b,0,lt,dt,ut,it,vt,O,m-O,y),vt=St=it=0,O=m;for(var Gt=0;Gt<286;++Gt)dt[Gt]=0;for(Gt=0;Gt<30;++Gt)ut[Gt]=0}var Dt=2,Ht=0,Ot=v,ee=L-J&32767;if(U>2&&w==tt(m-ee))for(var ae=Math.min(u,U)-1,ce=Math.min(32767,m),ve=Math.min(258,U);ee<=ce&&--Ot&&L!=J;){if(n[m+Dt]==n[m+Dt-ee]){for(var ue=0;ue<ve&&n[m+ue]==n[m+ue-ee];++ue);if(ue>Dt){if(Dt=ue,Ht=ee,ue>ae)break;var Zt=Math.min(ee,ue-2),de=0;for(Gt=0;Gt<Zt;++Gt){var Wt=m-ee+Gt+32768&32767,Nt=Wt-E[Wt]+32768&32767;Nt>de&&(de=Nt,J=Wt)}}}ee+=(L=J)-(J=E[L])+32768&32767}if(Ht){lt[vt++]=268435456|Nm[Dt]<<18|Gm[Ht];var Ge=31&Nm[Dt],si=31&Gm[Ht];it+=Jm[Ge]+Km[si],++dt[257+Ge],++ut[si],D=m+Dt,++St}else lt[vt++]=n[m],++dt[n[m]]}}y=Tb(n,b,g,lt,dt,ut,it,vt,O,m-O,y),g||(y=Bf(b,y,t2))}return i_(l,0,o+e_(y)+f)}(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,i,r,!s)},$m=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8},s2=function(t,e){var i=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&&$m(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;r<=i.length;++r)t[r+10]=i.charCodeAt(r)}},n2=function(t){return 10+(t.filename&&t.filename.length+1||0)};function a2(t,e){e===void 0&&(e={});var i=i2(),r=t.length;i.p(t);var s=r2(t,e,n2(e),8),n=s.length;return s2(s,e),$m(s,n-8,i.d()),$m(s,n-4,r),s}function o2(t,e){var i=t.length;if(!e&&typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var r=new vn(t.length+(t.length>>>1)),s=0,n=function(f){r[s++]=f},a=0;a<i;++a){if(s+5>r.length){var h=new vn(s+8+(i-a<<1));h.set(r),r=h}var o=t.charCodeAt(a);o<128||e?n(o):o<2048?(n(192|o>>>6),n(128|63&o)):o>55295&&o<57344?(n(240|(o=65536+(1047552&o)|1023&t.charCodeAt(++a))>>>18),n(128|o>>>12&63),n(128|o>>>6&63),n(128|63&o)):(n(224|o>>>12),n(128|o>>>6&63),n(128|63&o))}return i_(r,0,s)}(function(t){t.GZipJS="gzip-js",t.Base64="base64"})(fh||(fh={}));var r_=function(t,e,i){var r=e||{};r.ip=i.ip?1:0,r._=new Date().getTime().toString(),r.ver=mh.LIB_VERSION;var s=t.split("?");if(s.length>1){var n,a=So(s[1].split("&"));try{for(a.s();!(n=a.n()).done;){var h=n.value.split("=")[0];Ai(r[h])||delete r[h]}}catch(f){a.e(f)}finally{a.f()}}var o=t.indexOf("?")>-1?"&":"?";return t+o+function(f){var g,c,l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",b=[];return er(f,function(y,m){Ai(y)||Ai(m)||m==="undefined"||(g=encodeURIComponent(y.toString()),c=encodeURIComponent(m),b[b.length]=c+"="+g)}),b.join(l)}(r)},Qm=function t(e,i){if(i.blob&&e.buffer)return new Blob([ib(e)?e:e.buffer],{type:"text/plain"});if(i.sendBeacon||i.blob){var r=t(e,{method:"POST"});return new Blob([r],{type:"application/x-www-form-urlencoded"})}return i.method!=="POST"?null:(s=Hr(e)||ib(e)?"data="+encodeURIComponent(e):"data="+encodeURIComponent(e.data),"compression"in e&&e.compression&&(s+="&compression="+e.compression),s);var s},s_=function(t){var e=t.url,i=t.data,r=t.headers,s=t.options,n=t.callback,a=t.retriesPerformedSoFar,h=t.retryQueue,o=t.onXHRError,f=t.timeout,g=f===void 0?6e4:f,c=t.onResponse;$a(a)&&a>0&&(e=r_(e,{retry_count:a},{}));var l=new XMLHttpRequest;l.open(s.method||"GET",e,!0);var b=Qm(i,s);er(r,function(y,m){l.setRequestHeader(m,y)}),s.method!=="POST"||s.blob||l.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),l.timeout=g,l.withCredentials=!0,l.onreadystatechange=function(){if(l.readyState===4)if(c?.(l),l.status===200){if(n){var y;try{y=JSON.parse(l.responseText)}catch(m){return void De.error(m)}n(y)}}else ea(o)&&o(l),(l.status<400||l.status>500)&&h.enqueue({url:e,data:i,options:s,headers:r,retriesPerformedSoFar:(a||0)+1,callback:n}),n?.({status:0})},l.send(b)},h2=18e5,l2=function(t){Rb(i,Kb);var e=Vb(i);function i(r,s){var n;return Mr(this,i),(n=e.call(this)).isPolling=!1,n.queue=[],n.areWeOnline=!0,n.onXHRError=r,n.rateLimiter=s,!Ai(ne)&&"onLine"in ne.navigator&&(n.areWeOnline=ne.navigator.onLine,ne.addEventListener("online",function(){n._handleWeAreNowOnline()}),ne.addEventListener("offline",function(){n.areWeOnline=!1})),n}return Dr(i,[{key:"enqueue",value:function(r){var s=r.retriesPerformedSoFar||0;if(!(s>=10)){var n=function(o){var f=3e3*Math.pow(2,o),g=f/2,c=Math.min(h2,f),l=(Math.random()-.5)*(c-g);return Math.ceil(c+l)}(s),a=new Date(Date.now()+n);this.queue.push({retryAt:a,requestData:r});var h="Enqueued failed request for retry in ".concat(n);navigator.onLine||(h+=" (Browser is offline)"),De.warn(h),this.isPolling||(this.isPolling=!0,this.poll())}}},{key:"poll",value:function(){var r=this;this._poller&&clearTimeout(this._poller),this._poller=setTimeout(function(){r.areWeOnline&&r.queue.length>0&&r.flush(),r.poll()},this._pollInterval)}},{key:"flush",value:function(){var r=new Date(Date.now()),s=this.queue.filter(function(o){return o.retryAt<r});if(s.length>0){this.queue=this.queue.filter(function(o){return o.retryAt>=r});var n,a=So(s);try{for(a.s();!(n=a.n()).done;){var h=n.value.requestData;this._executeXhrRequest(h)}}catch(o){a.e(o)}finally{a.f()}}}},{key:"unload",value:function(){this._poller&&(clearTimeout(this._poller),this._poller=void 0);var r,s=So(this.queue);try{for(s.s();!(r=s.n()).done;){var n=r.value.requestData,a=n.url,h=n.data,o=n.options;if(this.rateLimiter.isRateLimited(o._batchKey))De.warn("[RetryQueue] is quota limited. Dropping request.");else try{ne?.navigator.sendBeacon(a,Qm(h,ri(ri({},o),{},{sendBeacon:!0})))}catch(f){De.error(f)}}}catch(f){s.e(f)}finally{s.f()}this.queue=[]}},{key:"_executeXhrRequest",value:function(r){var s=r.url,n=r.data,a=r.options,h=r.headers,o=r.callback,f=r.retriesPerformedSoFar;this.rateLimiter.isRateLimited(a._batchKey)||s_({url:s,data:n||{},options:a||{},headers:h||{},retriesPerformedSoFar:f||0,callback:o,retryQueue:this,onXHRError:this.onXHRError,onResponse:this.rateLimiter.checkForLimiting})}},{key:"_handleWeAreNowOnline",value:function(){this.areWeOnline=!0,this.flush()}}]),i}(),Df=1800,Mb=60,p2=864e5,c2=function(){function t(e,i,r,s){Mr(this,t),Ne(this,"_sessionIdChangedHandlers",[]),this.config=e,this.persistence=i,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=r||uh,this._windowIdGenerator=s||uh;var n=e.persistence_name||e.token,a=e.session_idle_timeout_seconds||Df;if($a(a)?a>Df?De.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):a<Mb&&De.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(De.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),a=Df),this._sessionTimeoutMs=1e3*Math.min(Math.max(a,Mb),Df),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){var h=ys.parse(this._window_id_storage_key),o=ys.parse(this._primary_window_exists_storage_key);h&&!o?this._windowId=h:ys.remove(this._window_id_storage_key),ys.set(this._primary_window_exists_storage_key,!0)}this._listenToReloadWindow()}return Dr(t,[{key:"onSessionId",value:function(e){var i=this;return Ai(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),function(){i._sessionIdChangedHandlers=i._sessionIdChangedHandlers.filter(function(r){return r!==e})}}},{key:"_canUseSessionStorage",value:function(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&ys.is_supported()}},{key:"_setWindowId",value:function(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&ys.set(this._window_id_storage_key,e))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:this._canUseSessionStorage()?ys.parse(this._window_id_storage_key):null}},{key:"_setSessionId",value:function(e,i,r){e===this._sessionId&&i===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=i,this._sessionId=e,this.persistence.register(Ne({},qf,[i,e,r])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[qf];return Hr(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;ne?.addEventListener("beforeunload",function(){e._canUseSessionStorage()&&ys.remove(e._primary_window_exists_storage_key)})}},{key:"checkAndGetSessionAndWindowId",value:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],i=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||new Date().getTime(),r=ta(this._getSessionId(),3),s=r[0],n=r[1],a=r[2],h=this._getWindowId(),o=a&&a>0&&Math.abs(i-a)>p2,f=!1,g=!n,c=!e&&Math.abs(i-s)>this._sessionTimeoutMs;g||c||o?(n=this._sessionIdGenerator(),h=this._windowIdGenerator(),a=i,f=!0):h||(h=this._windowIdGenerator(),f=!0);var l=s===0||!e||o?i:s,b=a===0?new Date().getTime():a;return this._setWindowId(h),this._setSessionId(n,l,b),f&&this._sessionIdChangedHandlers.forEach(function(y){return y(n,h)}),{sessionId:n,windowId:h,sessionStartTimestamp:b}}}]),t}(),f2=Dr(function t(e,i,r,s){Mr(this,t),this.name="posthog-js",this.setupOnce=function(n){n(function(a){var h,o,f,g,c;if(a.level!=="error"||!e.__loaded)return a;a.tags||(a.tags={});var l=e.config.ui_host||e.config.api_host;a.tags["PostHog Person URL"]=l+"/person/"+e.get_distinct_id(),e.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var b=((h=a.exception)===null||h===void 0?void 0:h.values)||[],y={$exception_message:(o=b[0])===null||o===void 0?void 0:o.value,$exception_type:(f=b[0])===null||f===void 0?void 0:f.type,$exception_personURL:l+"/person/"+e.get_distinct_id(),$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:(g=b[0])===null||g===void 0?void 0:g.value,$sentry_exception_type:(c=b[0])===null||c===void 0?void 0:c.type,$sentry_tags:a.tags};return i&&r&&(y.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+a.event_id),e.capture("$exception",y),a})}}),u2=function(t){Promise&&Promise.resolve||De.warn("This browser does not have Promise support, and can not use the segment integration");var e=function(i,r){i.event.userId||i.event.anonymousId===t.get_distinct_id()||t.reset(),i.event.userId&&i.event.userId!==t.get_distinct_id()&&(t.register({distinct_id:i.event.userId}),t.reloadFeatureFlags());var s=t._calculate_event_properties(r,i.event.properties);return i.event.properties=Object.assign({},s,i.event.properties),i};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:function(i){return e(i,i.event.event)},page:function(i){return e(i,"$pageview")},identify:function(i){return e(i,"$identify")},screen:function(i){return e(i,"$screen")}}},d2=function(){function t(e){var i=this;Mr(this,t),Ne(this,"_hasSeenPageView",!1),Ne(this,"_updateScrollData",function(){var r,s,n,a;i._pageViewData||(i._pageViewData=i._createPageViewData());var h=i._pageViewData,o=i._scrollY(),f=i._scrollHeight(),g=i._contentY(),c=i._contentHeight();h.lastScrollY=o,h.maxScrollY=Math.max(o,(r=h.maxScrollY)!==null&&r!==void 0?r:0),h.maxScrollHeight=Math.max(f,(s=h.maxScrollHeight)!==null&&s!==void 0?s:0),h.lastContentY=g,h.maxContentY=Math.max(g,(n=h.maxContentY)!==null&&n!==void 0?n:0),h.maxContentHeight=Math.max(c,(a=h.maxContentHeight)!==null&&a!==void 0?a:0)}),this._instance=e}return Dr(t,[{key:"_createPageViewData",value:function(){var e;return{pathname:(e=ne?.location.pathname)!==null&&e!==void 0?e:""}}},{key:"doPageView",value:function(){var e,i;return this._hasSeenPageView?(i=this._pageViewData,this._pageViewData=this._createPageViewData()):(this._hasSeenPageView=!0,i=void 0,this._pageViewData||(this._pageViewData=this._createPageViewData())),setTimeout(this._updateScrollData,0),ri({$prev_pageview_pathname:(e=i)===null||e===void 0?void 0:e.pathname},this._calculatePrevPageScrollProperties(i))}},{key:"doPageLeave",value:function(){var e=this._pageViewData;return ri({$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 i=e.maxScrollHeight,r=e.lastScrollY,s=e.maxScrollY,n=e.maxContentHeight,a=e.lastContentY,h=e.maxContentY;return i=Math.ceil(i),r=Math.ceil(r),s=Math.ceil(s),n=Math.ceil(n),a=Math.ceil(a),h=Math.ceil(h),{$prev_pageview_last_scroll:r,$prev_pageview_last_scroll_percentage:i<=1?1:If(r/i,0,1),$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:i<=1?1:If(s/i,0,1),$prev_pageview_last_content:a,$prev_pageview_last_content_percentage:n<=1?1:If(a/n,0,1),$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:n<=1?1:If(h/n,0,1)}}},{key:"startMeasuringScrollPosition",value:function(){ne?.addEventListener("scroll",this._updateScrollData,!0),ne?.addEventListener("scrollend",this._updateScrollData,!0),ne?.addEventListener("resize",this._updateScrollData)}},{key:"stopMeasuringScrollPosition",value:function(){ne?.removeEventListener("scroll",this._updateScrollData),ne?.removeEventListener("scrollend",this._updateScrollData),ne?.removeEventListener("resize",this._updateScrollData)}},{key:"_scrollElement",value:function(){if(!this._instance.config.scroll_root_selector)return ne?.document.documentElement;var e,i=So(Hr(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector]);try{for(i.s();!(e=i.n()).done;){var r=e.value,s=ne?.document.querySelector(r);if(s)return s}}catch(n){i.e(n)}finally{i.f()}}},{key:"_scrollHeight",value:function(){var e=this._scrollElement();return e?Math.max(0,e.scrollHeight-e.clientHeight):0}},{key:"_scrollY",value:function(){if(this._instance.config.scroll_root_selector){var e=this._scrollElement();return e&&e.scrollTop||0}return ne&&(ne.scrollY||ne.pageYOffset||ne.document.documentElement.scrollTop)||0}},{key:"_contentHeight",value:function(){var e=this._scrollElement();return e?.scrollHeight||0}},{key:"_contentY",value:function(){var e=this._scrollElement(),i=e?.clientHeight||0;return this._scrollY()+i}}]),t}();function If(t,e,i){return Math.max(e,Math.min(t,i))}var Mp,t0,gs,m2={icontains:function(t){return!!ne&&ne.location.href.toLowerCase().indexOf(t.toLowerCase())>-1},regex:function(t){return!!ne&&PE(ne.location.href,t)},exact:function(t){return ne?.location.href===t}},g2=function(){function t(e){Mr(this,t),this.instance=e}return Dr(t,[{key:"getSurveys",value:function(e){var i=this,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1],s=this.instance.get_property(Vm);if(s&&!r)return e(s);this.instance._send_request("".concat(this.instance.config.api_host,"/api/surveys/?token=").concat(this.instance.config.token),{},{method:"GET"},function(n){var a,h=n.surveys||[];return(a=i.instance.persistence)===null||a===void 0||a.register(Ne({},Vm,h)),e(h)})}},{key:"getActiveMatchingSurveys",value:function(e){var i=this,r=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(function(s){var n=s.filter(function(a){return!(!a.start_date||a.end_date)}).filter(function(a){var h,o,f,g;if(!a.conditions)return!0;var c=(h=a.conditions)===null||h===void 0||!h.url||m2[(o=(f=a.conditions)===null||f===void 0?void 0:f.urlMatchType)!==null&&o!==void 0?o:"icontains"](a.conditions.url),l=(g=a.conditions)===null||g===void 0||!g.selector||Ue?.querySelector(a.conditions.selector);return c&&l}).filter(function(a){if(!a.linked_flag_key&&!a.targeting_flag_key)return!0;var h=!a.linked_flag_key||i.instance.featureFlags.isFeatureEnabled(a.linked_flag_key),o=!a.targeting_flag_key||i.instance.featureFlags.isFeatureEnabled(a.targeting_flag_key);return h&&o});return e(n)},r)}}]),t}(),y2=6e4,v2=function(){function t(){var e=this;Mr(this,t),Ne(this,"limits",{}),Ne(this,"checkForLimiting",function(i){try{var r=i.responseText;if(!r||!r.length)return;(JSON.parse(r).quota_limited||[]).forEach(function(s){De.info("[RateLimiter] ".concat(s||"events"," is quota limited.")),e.limits[s]=new Date().getTime()+y2})}catch(s){return void De.error(s)}})}return Dr(t,[{key:"isRateLimited",value:function(e){var i=this.limits[e||"events"]||!1;return i!==!1&&new Date().getTime()<i}}]),t}(),b2=function(){return ri({initialPathName:ne?.location.pathname||"",referringDomain:qr.referringDomain()},qr.campaignParams())},_2=function(){function t(e,i,r){var s=this;Mr(this,t),Ne(this,"_onSessionIdCallback",function(n){var a=s._getStoredProps();if(!a||a.sessionId!==n){var h={sessionId:n,props:s._sessionSourceParamGenerator()};s._persistence.register(Ne({},zm,h))}}),this._sessionIdManager=e,this._persistence=i,this._sessionSourceParamGenerator=r||b2,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}return Dr(t,[{key:"_getStoredProps",value:function(){return this._persistence.props[zm]}},{key:"getSessionProps",value:function(){var e,i=(e=this._getStoredProps())===null||e===void 0?void 0:e.props;return i?{$client_session_initial_referring_host:i.referringDomain,$client_session_initial_pathname:i.initialPathName,$client_session_initial_utm_source:i.utm_source,$client_session_initial_utm_campaign:i.utm_campaign,$client_session_initial_utm_medium:i.utm_medium,$client_session_initial_utm_content:i.utm_content,$client_session_initial_utm_term:i.utm_term}:{}}}]),t}(),x2=["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"],Db=function(t,e){if(!t)return!1;var i=t.toLowerCase();return x2.concat(e||[]).some(function(r){var s=r.toLowerCase();return i.includes?i.includes(s):i.indexOf(s)!==-1})};(function(t){t[t.INIT_MODULE=0]="INIT_MODULE",t[t.INIT_SNIPPET=1]="INIT_SNIPPET"})(Mp||(Mp={}));var jm=function(){},Ff={},Ks="posthog",zf=ne?.XMLHttpRequest&&"withCredentials"in new XMLHttpRequest,n_=!zf&&Tr?.indexOf("MSIE")===-1&&Tr?.indexOf("Mozilla")===-1,Ib=function(){var t,e,i;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=Ue?.location,i=e?.hostname,!!yn(i)&&i.split(".").slice(-2).join(".")!=="herokuapp.com"),persistence:"localStorage+cookie",persistence_name:"",cookie_name:"",loaded:jm,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:(ne==null||(t=ne.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_useragent_filter:!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(r){var s="Bad HTTP status: "+r.status+" "+r.statusText;De.error(s)},get_device_id:function(r){return r},_onCapture:jm,capture_performance:void 0,name:"posthog",callback_fn:"posthog._jsc",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800}},qm=function(t,e,i,r){var s,n=i!==Ks&&gs?i?gs[i]:void 0:gs,a={initComplete:!1,syncCode:!1},h=function(o){return function(f){a[o]||(a[o]=!0,a.initComplete&&a.syncCode&&r?.(f))}};if(n&&t0===Mp.INIT_MODULE)s=n;else{if(n&&!Hr(n))return void De.error("You have already initialized "+i);s=new e0}return s._init(t,e,i,h("initComplete")),s.toolbar.maybeLoadToolbar(),s.sessionRecording=new OE(s),s.sessionRecording.startRecordingIfEnabled(),s.config.disable_scroll_properties||s.pageViewManager.startMeasuringScrollPosition(),s.__autocapture=s.config.autocapture,_o._setIsAutocaptureEnabled(s),_o._isAutocaptureEnabled&&(s.__autocapture=s.config.autocapture,_o.enabledForProject(s.config.token,100,100)?_o.isBrowserSupported()?_o.init(s):(s.__autocapture=!1,De.info("Disabling Automatic Event Collection because this browser is not supported")):(s.__autocapture=!1,De.info("Not in active bucket: disabling Automatic Event Collection."))),mh.DEBUG=mh.DEBUG||s.config.debug,!Ai(n)&&Hr(n)&&(s._execute_array.call(s.people,n.people),s._execute_array(n)),h("syncCode")(s),s},S2=function(){function t(){Mr(this,t),Ne(this,"__forceAllowLocalhost",!1)}return Dr(t,[{key:"_forceAllowLocalhost",get:function(){return this.__forceAllowLocalhost},set:function(e){De.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}]),t}(),e0=function(){function t(){var e=this;Mr(this,t),Ne(this,"webPerformance",new S2),this.config=Ib(),this.compression={},this.decideEndpointWasHit=!1,this.SentryIntegration=f2,this.segmentIntegration=function(){return u2(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 fE(this),this.toolbar=new $E(this),this.pageViewManager=new d2(this),this.surveys=new g2(this),this.rateLimiter=new v2,this.people={set:function(i,r,s){var n=yn(i)?Ne({},i,r):i;e.setPersonProperties(n),s?.({})},set_once:function(i,r,s){var n=yn(i)?Ne({},i,r):i;e.setPersonProperties(void 0,n),s?.({})}}}return Dr(t,[{key:"init",value:function(e,i,r){if(Ai(r))De.critical("You must name your new library: init(token, config, name)");else{if(r!==Ks){var s=qm(e,i,r,function(n){gs[r]=n,n._loaded()});return gs[r]=s,s}De.critical("You must initialize the main posthog object right after you include the PostHog js snippet")}}},{key:"_init",value:function(e){var i,r,s,n=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},h=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0;this.__loaded=!0,this.config={},this._triggered_notifs=[];var f,g={segmentRegister:!1,syncCode:!1},c=function(E){return function(){g[E]||(g[E]=!0,g.segmentRegister&&g.syncCode&&o?.(n))}};if(this.set_config(ms({},Ib(),a,{name:h,token:e,callback_fn:(h===Ks?h:Ks+"."+h)+"._jsc"})),this._jsc=function(){},(ne!=null&&(i=ne.rrweb)!==null&&i!==void 0&&i.record||ne!=null&&ne.rrwebRecord)&&(this.__loaded_recorder_version=ne==null||(f=ne.rrweb)===null||f===void 0?void 0:f.version),this.persistence=new Sb(this.config),this._requestQueue=new YE(this._handle_queued_event.bind(this)),this._retryQueue=new l2(this.config.on_xhr_error,this.rateLimiter),this.__captureHooks=[],this.__request_queue=[],this.sessionManager=new c2(this.config,this.persistence),this.sessionPropsManager=new _2(this.sessionManager,this.persistence),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new Sb(ri(ri({},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(c("segmentRegister"))):c("segmentRegister")(),((r=a.bootstrap)===null||r===void 0?void 0:r.distinctID)!==void 0){var l,b,y=this.config.get_device_id(uh()),m=(l=a.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?y:a.bootstrap.distinctID;this.persistence.set_user_state((b=a.bootstrap)!==null&&b!==void 0&&b.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:a.bootstrap.distinctID,$device_id:m})}if(this._hasBootstrappedFeatureFlags()){var C,d,u=Object.keys(((C=a.bootstrap)===null||C===void 0?void 0:C.featureFlags)||{}).filter(function(E){var I,B;return!((I=a.bootstrap)===null||I===void 0||(B=I.featureFlags)===null||B===void 0||!B[E])}).reduce(function(E,I){var B,z;return E[I]=((B=a.bootstrap)===null||B===void 0||(z=B.featureFlags)===null||z===void 0?void 0:z[I])||!1,E},{}),v=Object.keys(((d=a.bootstrap)===null||d===void 0?void 0:d.featureFlagPayloads)||{}).filter(function(E){return u[E]}).reduce(function(E,I){var B,z,tt,lt;return(B=a.bootstrap)!==null&&B!==void 0&&(z=B.featureFlagPayloads)!==null&&z!==void 0&&z[I]&&(E[I]=(tt=a.bootstrap)===null||tt===void 0||(lt=tt.featureFlagPayloads)===null||lt===void 0?void 0:lt[I]),E},{});this.featureFlags.receivedFeatureFlags({featureFlags:u,featureFlagPayloads:v})}if(!this.get_distinct_id()){var S=this.config.get_device_id(uh());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_user_state("anonymous")}ne==null||(s=ne.addEventListener)===null||s===void 0||s.call(ne,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),c("syncCode")()}},{key:"_afterDecideResponse",value:function(e){var i;if(this.compression={},e.supportedCompression&&!this.config.disable_compression){var r,s={},n=So(e.supportedCompression);try{for(n.s();!(r=n.n()).done;)s[r.value]=!0}catch(a){n.e(a)}finally{n.f()}this.compression=s}(i=e.analytics)!==null&&i!==void 0&&i.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(i){De.critical("`loaded` function failed",i)}this._start_queue_if_opted_in(),this.config.capture_pageview&&Ue&&this.capture("$pageview",{title:Ue.title},{send_instantly:!0}),e||(new BE(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()||pl(this.__request_queue,function(i){e._send_request.apply(e,Mm(i))}),this.__request_queue=[],this._start_queue_if_opted_in()}},{key:"_prepare_callback",value:function(e,i){if(Ai(e))return null;if(zf)return function(a){e(a,i)};var r=this._jsc,s=""+Math.floor(1e8*Math.random()),n=this.config.callback_fn+"["+s+"]";return r[s]=function(a){delete r[s],e(a,i)},n}},{key:"_handle_unload",value:function(){var e,i;this.config.request_batching?(this.config.capture_pageview&&this.config.capture_pageleave&&this.capture("$pageleave"),(e=this._requestQueue)===null||e===void 0||e.unload(),(i=this._retryQueue)===null||i===void 0||i.unload()):this.config.capture_pageview&&this.config.capture_pageleave&&this.capture("$pageleave",null,{transport:"sendBeacon"})}},{key:"_handle_queued_event",value:function(e,i,r){var s=JSON.stringify(i);this.__compress_and_send_json_request(e,s,r||Ff,jm)}},{key:"__compress_and_send_json_request",value:function(e,i,r,s){var n=function(f,g,c){return f===fh.GZipJS?[a2(o2(g),{mtime:0}),ri(ri({},c),{},{blob:!0,urlQueryArgs:{compression:fh.GZipJS}})]:[{data:Um(g)},c]}(this.compression[fh.GZipJS]?fh.GZipJS:fh.Base64,i,r),a=ta(n,2),h=a[0],o=a[1];this._send_request(e,h,o,s)}},{key:"_send_request",value:function(e,i,r,s){if(this.__loaded&&this._retryQueue&&!this.rateLimiter.isRateLimited(r._batchKey))if(n_)this.__request_queue.push([e,i,r,s]);else{var n={method:this.config.api_method,transport:this.config.api_transport,verbose:this.config.verbose};r=ms(n,r||{}),zf||(r.method="GET");var a=ne&&"sendBeacon"in ne.navigator&&r.transport==="sendBeacon";if(e=r_(e,r.urlQueryArgs||{},{ip:this.config.ip}),a)try{ne?.navigator.sendBeacon(e,Qm(i,ri(ri({},r),{},{sendBeacon:!0})))}catch{}else if(zf||!Ue)try{s_({url:e,data:i,headers:this.config.xhr_headers,options:r,callback:s,retriesPerformedSoFar:0,retryQueue:this._retryQueue,onXHRError:this.config.on_xhr_error,onResponse:this.rateLimiter.checkForLimiting})}catch(g){De.error(g)}else{var h,o=Ue.createElement("script");o.type="text/javascript",o.async=!0,o.defer=!0,o.src=e;var f=Ue.getElementsByTagName("script")[0];(h=f.parentNode)===null||h===void 0||h.insertBefore(o,f)}}}},{key:"_execute_array",value:function(e){var i,r=this,s=[],n=[],a=[];pl(e,function(o){o&&(i=o[0],Hr(i)?a.push(o):ea(o)?o.call(r):Hr(o)&&i==="alias"?s.push(o):Hr(o)&&i.indexOf("capture")!==-1&&ea(r[i])?a.push(o):n.push(o))});var h=function(o,f){pl(o,function(g){if(Hr(g[0])){var c=f;er(g,function(l){c=c[l[0]].apply(c,l.slice(1))})}else this[g[0]].apply(this,g.slice(1))},f)};h(s,this),h(n,this),h(a,this)}},{key:"_hasBootstrappedFeatureFlags",value:function(){var e,i;return((e=this.config.bootstrap)===null||e===void 0?void 0:e.featureFlags)&&Object.keys((i=this.config.bootstrap)===null||i===void 0?void 0:i.featureFlags).length>0||!1}},{key:"push",value:function(e){this._execute_array([e])}},{key:"capture",value:function(e,i){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ff;if(!this.__loaded||!this.sessionPersistence||!this._requestQueue)return De.uninitializedWarning("posthog.capture");if(!function(g){var c=!1;try{var l=g.config.token,b=g.config.respect_dnt,y=g.config.opt_out_capturing_persistence_type,m=g.config.opt_out_capturing_cookie_prefix||void 0,C=g.config.window;l&&(c=Cb(l,{respectDnt:b,persistenceType:y,persistencePrefix:m,window:C}))}catch(d){De.error("Unexpected error when checking capturing opt-out status: "+d)}return c}(this)){var s=(r=r||Ff).transport;if(s&&(r.transport=s),!Ai(e)&&yn(e)){if(!Tr||this.config.opt_out_useragent_filter||!Db(Tr,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 n={uuid:uh(),event:e,properties:this._calculate_event_properties(e,i||{})};e==="$identify"&&(n.$set=r.$set,n.$set_once=r.$set_once),(n=aE(n,r._noTruncate?null:this.config.properties_string_max_length)).timestamp=r.timestamp||new Date;var a=ri(ri({},n.properties.$set),n.$set);sE(a)||this.setPersonPropertiesForFlags(a),De.info("send",n);var h=JSON.stringify(n),o=this.config.api_host+(r.endpoint||this.analyticsDefaultEndpoint),f=r!==Ff;return!this.config.request_batching||f&&!r._batchKey||r.send_instantly?this.__compress_and_send_json_request(o,h,r):this._requestQueue.enqueue(o,n,r),this._invokeCaptureHooks(e,n),n}}else De.error("No event name provided to posthog.capture")}}},{key:"_addCaptureHook",value:function(e){this.__captureHooks.push(e)}},{key:"_invokeCaptureHooks",value:function(e,i){this.config._onCapture(e,i),er(this.__captureHooks,function(r){return r(e)})}},{key:"_calculate_event_properties",value:function(e,i){if(!this.persistence||!this.sessionPersistence)return i;var r=this.persistence.remove_event_timer(e),s=ri({},i);if(s.token=this.config.token,e==="$snapshot"){var n=ri(ri({},this.persistence.properties()),this.sessionPersistence.properties());return s.distinct_id=n.distinct_id,s}var a=qr.properties();if(this.sessionManager){var h=this.sessionManager.checkAndGetSessionAndWindowId(),o=h.sessionId,f=h.windowId;s.$session_id=o,s.$window_id=f}if(this.sessionPropsManager&&this.config.__preview_send_client_session_params&&(e==="$pageview"||e==="$pageleave"||e==="$autocapture")){var g=this.sessionPropsManager.getSessionProps();s=ms(s,g)}if(!this.config.disable_scroll_properties){var c={};e==="$pageview"?c=this.pageViewManager.doPageView():e==="$pageleave"&&(c=this.pageViewManager.doPageLeave()),s=ms(s,c)}if(e==="$pageview"&&Ue&&(s.title=Ue.title),e==="$performance_event"){var l=this.persistence.properties();return s.distinct_id=l.distinct_id,s.$current_url=a.$current_url,s}if(!Ai(r)){var b=new Date().getTime()-r;s.$duration=parseFloat((b/1e3).toFixed(3))}Tr&&this.config.opt_out_useragent_filter&&(s.$browser_type=Db(Tr,this.config.custom_blocked_useragents)?"bot":"browser"),s=ms({},qr.properties(),this.persistence.properties(),this.sessionPersistence.properties(),s);var y=this.config.property_blacklist;Hr(y)?er(y,function(C){delete s[C]}):De.error("Invalid value for property_blacklist config: "+y);var m=this.config.sanitize_properties;return m&&(s=m(s,e)),s}},{key:"register",value:function(e,i){var r;(r=this.persistence)===null||r===void 0||r.register(e,i)}},{key:"register_once",value:function(e,i,r){var s;(s=this.persistence)===null||s===void 0||s.register_once(e,i,r)}},{key:"register_for_session",value:function(e){var i;(i=this.sessionPersistence)===null||i===void 0||i.register(e)}},{key:"unregister",value:function(e){var i;(i=this.persistence)===null||i===void 0||i.unregister(e)}},{key:"unregister_for_session",value:function(e){var i;(i=this.sessionPersistence)===null||i===void 0||i.unregister(e)}},{key:"_register_single",value:function(e,i){this.register(Ne({},e,i))}},{key:"getFeatureFlag",value:function(e,i){return this.featureFlags.getFeatureFlag(e,i)}},{key:"getFeatureFlagPayload",value:function(e){var i=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(i)}catch{return i}}},{key:"isFeatureEnabled",value:function(e,i){return this.featureFlags.isFeatureEnabled(e,i)}},{key:"reloadFeatureFlags",value:function(){this.featureFlags.reloadFeatureFlags()}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,i)}},{key:"getEarlyAccessFeatures",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(e,i)}},{key:"onFeatureFlags",value:function(e){return this.featureFlags.onFeatureFlags(e)}},{key:"onSessionId",value:function(e){var i,r;return(i=(r=this.sessionManager)===null||r===void 0?void 0:r.onSessionId(e))!==null&&i!==void 0?i:function(){}}},{key:"getSurveys",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(e,i)}},{key:"getActiveMatchingSurveys",value:function(e){var i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(e,i)}},{key:"identify",value:function(e,i,r){if(!this.__loaded||!this.persistence)return De.uninitializedWarning("posthog.identify");if(e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))De.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 s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==s&&e!==this.get_property(Vf)&&(this.unregister(Vf),this.register({distinct_id:e}));var a=this.persistence.get_user_state()==="anonymous";e!==s&&a?(this.persistence.set_user_state("identified"),this.setPersonPropertiesForFlags(i||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:i||{},$set_once:r||{}}),this.featureFlags.setAnonymousDistinctId(s)):(i||r)&&this.setPersonProperties(i,r),e!==s&&(this.reloadFeatureFlags(),this.unregister(Hf))}else De.error("Unique user id has not been set in posthog.identify")}},{key:"setPersonProperties",value:function(e,i){(e||i)&&(this.setPersonPropertiesForFlags(e||{}),this.capture("$set",{$set:e||{},$set_once:i||{}}))}},{key:"group",value:function(e,i,r){if(e&&i){var s=this.getGroups();s[e]!==i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:ri(ri({},s),{},Ne({},e,i))}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:i,$group_set:r}),this.setGroupPropertiesForFlags(Ne({},e,r))),s[e]===i||r||this.reloadFeatureFlags()}else De.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 i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,i)}},{key:"resetPersonPropertiesForFlags",value:function(){this.featureFlags.resetPersonPropertiesForFlags()}},{key:"setGroupPropertiesForFlags",value:function(e){var i=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this.featureFlags.setGroupPropertiesForFlags(e,i)}},{key:"resetGroupPropertiesForFlags",value:function(e){this.featureFlags.resetGroupPropertiesForFlags(e)}},{key:"reset",value:function(e){var i,r,s,n;if(!this.__loaded)return De.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");(i=this.persistence)===null||i===void 0||i.clear(),(r=this.sessionPersistence)===null||r===void 0||r.clear(),(s=this.persistence)===null||s===void 0||s.set_user_state("anonymous"),(n=this.sessionManager)===null||n===void 0||n.resetSessionId();var h=this.config.get_device_id(uh());this.register_once({distinct_id:h,$device_id:e?h: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,i;return(e=(i=this.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}},{key:"get_session_replay_url",value:function(e){if(!this.sessionManager)return"";var i=this.config.ui_host||this.config.api_host,r=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=r.sessionId,n=r.sessionStartTimestamp,a=i+"/replay/"+s;if(e!=null&&e.withTimestamp&&n){var h,o=(h=e.timestampLookBack)!==null&&h!==void 0?h:10;if(!n)return a;var f=Math.max(Math.floor((new Date().getTime()-n)/1e3)-o,0);a+="?t=".concat(f)}return a}},{key:"alias",value:function(e,i){return e===this.get_property(Hb)?(De.critical("Attempting to create alias for existing People user - aborting."),-2):(Ai(i)&&(i=this.get_distinct_id()),e!==i?(this._register_single(Vf,e),this.capture("$create_alias",{alias:e,distinct_id:i})):(De.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1))}},{key:"set_config",value:function(e){var i,r,s=ri({},this.config);xo(e)&&(ms(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(/\/$/,""),this.config.api_host==="https://us.posthog.com"&&(this.config.api_host="https://app.posthog.com"),(i=this.persistence)===null||i===void 0||i.update_config(this.config),(r=this.sessionPersistence)===null||r===void 0||r.update_config(this.config),Lr.is_supported()&&Lr.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(mh.DEBUG=!0),this.sessionRecording&&!Ai(e.disable_session_recording)&&s.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 i;return(i=this.persistence)===null||i===void 0?void 0:i.props[e]}},{key:"getSessionProperty",value:function(e){var i;return(i=this.sessionPersistence)===null||i===void 0?void 0:i.props[e]}},{key:"toString",value:function(){var e,i=(e=this.config.name)!==null&&e!==void 0?e:Ks;return i!==Ks&&(i=Ks+"."+i),i}},{key:"_gdpr_init",value:function(){this.config.opt_out_capturing_persistence_type==="localStorage"&&Lr.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&&!ba.get("ph_optout")||(ba.remove("ph_optout"),this.opt_out_capturing({clear_persistence:this.config.opt_out_persistence_by_default}))}},{key:"_gdpr_update_persistence",value:function(e){var i,r,s,n,a;if(e&&e.clear_persistence)s=!0;else{if(!e||!e.enable_persistence)return;s=!1}this.config.disable_persistence||((i=this.persistence)===null||i===void 0?void 0:i.disabled)===s||(n=this.persistence)===null||n===void 0||n.set_disabled(s),this.config.disable_persistence||((r=this.sessionPersistence)===null||r===void 0?void 0:r.disabled)===s||(a=this.sessionPersistence)===null||a===void 0||a.set_disabled(s)}},{key:"_gdpr_call_func",value:function(e,i){return i=ms({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},i||{}),Lr.is_supported()||i.persistence_type!=="localStorage"||(i.persistence_type="cookie"),e(this.config.token,{capture:i.capture,captureEventName:i.capture_event_name,captureProperties:i.capture_properties,persistenceType:i.persistence_type,persistencePrefix:i.cookie_prefix,cookieExpiration:i.cookie_expiration,crossSubdomainCookie:i.cross_subdomain_cookie,secureCookie:i.secure_cookie})}},{key:"opt_in_capturing",value:function(e){e=ms({enable_persistence:!0},e||{}),this._gdpr_call_func(qE,e),this._gdpr_update_persistence(e)}},{key:"opt_out_capturing",value:function(e){var i=ms({clear_persistence:!0},e||{});this._gdpr_call_func(HE,i),this._gdpr_update_persistence(i)}},{key:"has_opted_in_capturing",value:function(e){return this._gdpr_call_func(WE,e)}},{key:"has_opted_out_capturing",value:function(e){return this._gdpr_call_func(Cb,e)}},{key:"clear_opt_in_out_capturing",value:function(e){var i=ms({enable_persistence:!0},e??{});this._gdpr_call_func(UE,i),this._gdpr_update_persistence(i)}},{key:"debug",value:function(e){e===!1?(ne?.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(ne?.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 i=0;i<e.length;i++)t.prototype[e[i]]=Gb(t.prototype[e[i]])})(e0,["identify"]);var Fb,Lb,vo={},w2=function(){gs.init=function(t,e,i){if(i)return gs[i]||(gs[i]=vo[i]=qm(t||"",e||{},i,function(s){gs[i]=vo[i]=s,s._loaded()})),gs[i];var r=gs;return vo[Ks]?r=vo[Ks]:t&&(r=qm(t,e||{},Ks,function(s){vo[Ks]=s,s._loaded()}),vo[Ks]=r),gs=r,t0===Mp.INIT_SNIPPET&&(Ts[Ks]=gs),er(vo,function(s,n){n!==Ks&&(gs[n]=s)}),r}},P2=function(){function t(){t.done||(t.done=!0,n_=!1,er(vo,function(e){e._dom_loaded()}))}Ue!=null&&Ue.addEventListener&&(Ue.readyState==="complete"?t():Ue.addEventListener("DOMContentLoaded",t,!1)),ne&&Ap(ne,"load",t,!0)};(function(t){t.Popover="popover",t.API="api",t.Widget="widget"})(Fb||(Fb={})),function(t){t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link"}(Lb||(Lb={}));var a_=(t0=Mp.INIT_MODULE,gs=new e0,w2(),gs.init(),P2(),gs);var o_=a_.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 Qs(t,e){if(!o_)throw new Error("Failed to initialize PostHog");o_.capture(t,e)}var yh,Ip,Jf,h_,Wr,yr,ia,Kf,l_,Qf,p_,tu,c_,eu,f_,iu,u_,ru,d_,su,m_,nu,g_,au,y_,fl,Xf,Zf=class extends br(zi){constructor(){super();Le(this,yh);Le(this,Jf);Le(this,Kf);Le(this,Qf);Le(this,tu);Le(this,eu);Le(this,iu);Le(this,ru);Le(this,su);Le(this,nu);Le(this,au);Le(this,fl);Le(this,Wr,new kf(this,{url:(i,{resume:r}={})=>{let s=new URL(this.config.wsApiUrl);return s.searchParams.set("widgetId",this.widgetId),s.searchParams.set("resume",r?"1":""),s.searchParams.set("conversationId",i),s.searchParams.set("pageUrl",window.location.href),s},onReconnect:()=>{},onError:i=>{console.error("ws error",i),Qs("ShopAssistant: error",{widgetId:this.widgetId,error:"websocket onError"})},onClose:()=>{},onNewMessage:i=>{i.role==="assistant"&&Qs("ShopAssistant: user received bot message (streaming started)",{widgetId:this.widgetId,message:i})},onUpdateMessage:i=>{},onMessageDone:i=>{let r={...fe(this,Wr)?.messages.find(s=>s.id===i.message?.id)};Object.assign(r,i.message),r.role==="assistant"&&Qs("ShopAssistant: user received bot message (streaming ended)",{widgetId:this.widgetId,text:r.content??"",message:r,usage_TOKENS_COMPLETION:i.message.usage.TOKENS_COMPLETION})},onMessageError:i=>{console.error("ws message error",i),i.message&&fe(this,yr)&&alert(i.message),Qs("ShopAssistant: error",{widgetId:this.widgetId,error:"websocket ERROR message type: "+i.message})},persistConversationState:(i,r)=>{let s={conversationId:i,messages:r};localStorage.setItem(fe(this,yh,Ip),JSON.stringify(s))},restoreConversationState:()=>{try{let i=JSON.parse(localStorage.getItem(fe(this,yh,Ip))||"{}"),r=u0.parse(i);return{conversationId:r.conversationId||Sm(),messages:r.messages||[]}}catch(i){console.error(i)}},onReset:()=>{localStorage.removeItem(fe(this,yh,Ip))},onConnect:i=>{localStorage.setItem(fe(this,yh,Ip),JSON.stringify({conversationId:i}))}}));Le(this,yr,!1);Le(this,ia,void 0);this.widgetId="",this.config}render(){console.assert(this.widgetId,"widget id is required"),console.assert(this.config,"config is required");let i=Object.entries(this.config.bubble.position).filter(([o,f])=>f).map(([o,f])=>`${o}-[${f}]`).reduce((o,f)=>(o[f]=!0,o),{}),r=Object.entries(this.config.bubble.position).filter(([o,f])=>f).map(([o,f])=>`${o}-[${f}]`).reduce((o,f)=>(o[f]=!0,o),{}),s={bottom:"72px"},n=Object.entries(this.config.bubble.position).filter(([o,f])=>f).map(([o,f])=>`sm:${o}-[calc(${[s[o],f].filter(g=>!!g).join("+")})]`).reduce((o,f)=>(o[f]=!0,o),{}),a=n;if(this.config.hidden&&!fe(this,Jf,h_))return Ki;let h=X1(fe(this,Wr).messages,o=>new Date(new Date(o.timestamp).setSeconds(0,0)).getTime().toString());return di`
1014
- ${this.config.kioskMode?Ki:di`<mw-bubble class="${W1(i)} fixed z-[2147483647]" @click=${ii(this,eu,f_)} ?dialog-shown="${fe(this,yr)}" bubble-image-url="${this.config.bubble?.imageUrl||""}"></mw-bubble>
1014
+ ${this.config.kioskMode?Ki:di`
1015
+ <mw-bubble class="${W1(i)} fixed z-[2147483647]" @click=${ii(this,eu,f_)} ?dialog-shown="${fe(this,yr)}" bubble-image-url="${this.config.bubble?.imageUrl||""}"></mw-bubble>
1015
1016
 
1016
1017
  ${this.config?.popup?.mobileEnabled||this.config?.popup?.desktopEnabled?di`
1017
1018
  <!-- -->
@@ -1020,7 +1021,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1020
1021
  ${this.config?.tryItOut?.mobileEnabled||this.config?.tryItOut?.desktopEnabled?di`
1021
1022
  <!-- -->
1022
1023
  <mw-try-it-out class="${this.config?.tryItOut?.mobileEnabled?"visible":"invisible"} ${this.config?.tryItOut?.desktopEnabled?"sm:visible":"sm:invisible"}" .position="${r}" popup-text="${xf(this.config.tryItOut?.text)}"></mw-try-it-out>
1023
- `:""} `}
1024
+ `:""}
1025
+ `}
1024
1026
 
1025
1027
  <div id="dialog" class="${fe(this,yr)?"visible opacity-100 translate-y-0":"invisible opacity-0 translate-y-3"} ${Object.keys(n).join(" ")} fixed bottom-0 left-0 right-0 top-0 z-[2147483647] overflow-hidden bg-white font-sans text-[16px] leading-normal text-gray-800 subpixel-antialiased shadow-2xl transition-all sm:left-auto sm:top-auto sm:h-4/5 sm:max-h-[800px] sm:w-5/6 sm:max-w-[400px] sm:rounded-2xl 2xl:max-w-[420px]">
1026
1028
  <div class="mx-auto flex h-full w-full max-w-4xl flex-col">
@@ -1079,7 +1081,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1079
1081
  </div>
1080
1082
  </div>
1081
1083
  </div>
1082
- `}updated(i){i.has("config")&&this.config.kioskMode&&(ci(this,yr,this.config.kioskMode),this.requestUpdate())}firstUpdated(){if(!window.matchMedia("(min-width: 640px)").matches){let i=()=>{window.scrollTo(0,0);let s=window.innerHeight,n=this.shadowRoot?.querySelector("#dialog");if(!n||!window.visualViewport)return;let a=s-window.visualViewport?.height;n.style.bottom=a>150?`${a}px`:"0px"},r=window.visualViewport;r&&(r.addEventListener("resize",i),document.addEventListener("touchend",i))}}disconnectedCallback(){fe(this,ia)&&clearTimeout(fe(this,ia))}openChat(){fe(this,yr)||(ci(this,yr,!0),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}closeChat(){fe(this,yr)&&(ci(this,yr,!1),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}async injectConfig(i){i.kioskMode=this.config.kioskMode,this.config=i,this.requestUpdate()}};yh=new WeakSet,Ip=function(){if(!this.widgetId)throw new Error("widgetId is required");return`_molin_${this.widgetId}`},Jf=new WeakSet,h_=function(){return window.location.hostname==="molin.ai"},Wr=new WeakMap,yr=new WeakMap,ia=new WeakMap,Kf=new WeakSet,l_=function(i){let r=i.target;r&&r instanceof HTMLAnchorElement&&r.tagName==="A"&&Qs("ShopAssistant: user clicked link",{widgetId:this.widgetId,url:r.href})},Qf=new WeakSet,p_=function(){ci(this,yr,!0),ii(this,fl,Xf).call(this,fe(this,yr)),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"popup-click",state:fe(this,yr)?"open":"close"})},tu=new WeakSet,c_=function(i){let r=i.detail.example;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),Qs("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!0})},eu=new WeakSet,f_=function(){ci(this,yr,!fe(this,yr)),ii(this,fl,Xf).call(this,fe(this,yr)),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"bubble-toggle",state:fe(this,yr)?"open":"close"})},iu=new WeakSet,u_=function(i){ci(this,yr,!1),ii(this,fl,Xf).call(this,fe(this,yr)),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"top-right-close-button",state:fe(this,yr)?"open":"close"})},ru=new WeakSet,d_=function(i){fe(this,Wr)?.reset()},su=new WeakSet,m_=function(i){let r=i.detail.value;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),Qs("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!1})},nu=new WeakSet,g_=function(i){fe(this,Wr)?.sendUserCancel(),Qs("ShopAssistant: user canceled streaming",{widgetId:this.widgetId})},au=new WeakSet,y_=function(){fe(this,ia)?(clearTimeout(fe(this,ia)),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3))):(fe(this,Wr)?.sendUserTypingStart(),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3)))},fl=new WeakSet,Xf=function(i=!0){window.matchMedia("(min-width: 640px)").matches||(document.body.style.overflow=i?"hidden":"")},le(Zf,"properties",{widgetId:{type:String,attribute:"widget"},config:{type:Object,attribute:!1}});customElements.define("molin-shop-ai",Zf);
1084
+ `}updated(i){i.has("config")&&this.config.kioskMode&&(ci(this,yr,this.config.kioskMode),this.requestUpdate())}firstUpdated(){}disconnectedCallback(){fe(this,ia)&&clearTimeout(fe(this,ia))}openChat(){fe(this,yr)||(ci(this,yr,!0),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}closeChat(){fe(this,yr)&&(ci(this,yr,!1),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"programmatic-method",state:fe(this,yr)?"open":"close"}))}async injectConfig(i){i.kioskMode=this.config.kioskMode,this.config=i,this.requestUpdate()}};yh=new WeakSet,Ip=function(){if(!this.widgetId)throw new Error("widgetId is required");return`_molin_${this.widgetId}`},Jf=new WeakSet,h_=function(){return window.location.hostname==="molin.ai"},Wr=new WeakMap,yr=new WeakMap,ia=new WeakMap,Kf=new WeakSet,l_=function(i){let r=i.target;r&&r instanceof HTMLAnchorElement&&r.tagName==="A"&&Qs("ShopAssistant: user clicked link",{widgetId:this.widgetId,url:r.href})},Qf=new WeakSet,p_=function(){ci(this,yr,!0),ii(this,fl,Xf).call(this,fe(this,yr)),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"popup-click",state:fe(this,yr)?"open":"close"})},tu=new WeakSet,c_=function(i){let r=i.detail.example;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),Qs("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!0})},eu=new WeakSet,f_=function(){ci(this,yr,!fe(this,yr)),ii(this,fl,Xf).call(this,fe(this,yr)),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"bubble-toggle",state:fe(this,yr)?"open":"close"})},iu=new WeakSet,u_=function(i){ci(this,yr,!1),ii(this,fl,Xf).call(this,fe(this,yr)),this.requestUpdate(),Qs("ShopAssistant: user toggled window",{widgetId:this.widgetId,source:"top-right-close-button",state:fe(this,yr)?"open":"close"})},ru=new WeakSet,d_=function(i){fe(this,Wr)?.reset()},su=new WeakSet,m_=function(i){let r=i.detail.value;fe(this,Wr)?.sendUserInput(r,{expectStreaming:!this.config.liveChatEnabled}),Qs("ShopAssistant: user sent input",{widgetId:this.widgetId,text:r,example:!1})},nu=new WeakSet,g_=function(i){fe(this,Wr)?.sendUserCancel(),Qs("ShopAssistant: user canceled streaming",{widgetId:this.widgetId})},au=new WeakSet,y_=function(){fe(this,ia)?(clearTimeout(fe(this,ia)),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3))):(fe(this,Wr)?.sendUserTypingStart(),ci(this,ia,setTimeout(()=>{fe(this,Wr)?.sendUserTypingStop(),ci(this,ia,void 0)},2e3)))},fl=new WeakSet,Xf=function(i=!0){window.matchMedia("(min-width: 640px)").matches||(document.body.style.overflow=i?"hidden":"")},le(Zf,"properties",{widgetId:{type:String,attribute:"widget"},config:{type:Object,attribute:!1}});customElements.define("molin-shop-ai",Zf);
1083
1085
  /*! Bundled license information:
1084
1086
 
1085
1087
  @dotlottie/player-component/dist/dist-TF5BXIJN-GNSUL5QU.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molin.ai/shop-ai",
3
- "version": "0.4.41",
3
+ "version": "0.4.42",
4
4
  "description": "Molin Shop AI",
5
5
  "keywords": [
6
6
  "molin",