@cartbot/vehicle-search-beta 3.0.13 → 3.0.14
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.
|
@@ -58,4 +58,4 @@ Hint: It might not be working because maybe you're not up to date with the Meili
|
|
|
58
58
|
${i.stack}.`,Promise.reject(i)}}function yy(t){return Buffer.from(JSON.stringify(t)).toString("base64")}async function L2(t,e,n){const{createHmac:r}=await Promise.resolve().then(()=>UT);return r("sha256",t).update(`${e}.${n}`).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function D2(){return yy({alg:"HS256",typ:"JWT"}).replace(/=/g,"")}function N2(t){const{searchRules:e,uid:n,apiKey:r,expiresAt:i}=t;if(i)if(i instanceof Date){if(i.getTime()<Date.now())throw new ct("Meilisearch: The expiresAt field must be a date in the future.")}else throw new ct("Meilisearch: The expiredAt field must be an instance of Date.");if(e&&!(typeof e=="object"||Array.isArray(e)))throw new ct("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!r||typeof r!="string")throw new ct("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!n||typeof n!="string")throw new ct("Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.");if(!P2(n))throw new ct("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}function j2(t){const{searchRules:e,uid:n,expiresAt:r}=t,i={searchRules:e,apiKeyUid:n,exp:r?Math.floor(r.getTime()/1e3):void 0};return yy(i).replace(/=/g,"")}class z2{constructor(e){re(this,"config");this.config=e}async generateTenantToken(e,n,r){const i=(r==null?void 0:r.apiKey)||this.config.apiKey||"",s=e||"",o=r==null?void 0:r.expiresAt;N2({apiKey:i,uid:s,expiresAt:o,searchRules:n});const a=D2(),l=j2({searchRules:n,uid:s,expiresAt:o}),u=await L2(i,a,l);return`${a}.${l}.${u}`}}class H2 extends F2{constructor(n){super(n);re(this,"tokens");this.tokens=new z2(n)}async generateTenantToken(n,r,i){return typeof window>"u"?await this.tokens.generateTenantToken(n,r,i):await super.generateTenantToken(n,r,i)}}function U2(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var _y=U2,B2=typeof En=="object"&&En&&En.Object===Object&&En,q2=B2,V2=q2,W2=typeof self=="object"&&self&&self.Object===Object&&self,G2=V2||W2||Function("return this")(),wy=G2,K2=wy,Y2=function(){return K2.Date.now()},Q2=Y2,X2=/\s/;function Z2(t){for(var e=t.length;e--&&X2.test(t.charAt(e)););return e}var J2=Z2,eC=J2,tC=/^\s+/;function nC(t){return t&&t.slice(0,eC(t)+1).replace(tC,"")}var rC=nC,iC=wy,sC=iC.Symbol,by=sC,xy=by,ky=Object.prototype,oC=ky.hasOwnProperty,aC=ky.toString,Ao=xy?xy.toStringTag:void 0;function lC(t){var e=oC.call(t,Ao),n=t[Ao];try{t[Ao]=void 0;var r=!0}catch{}var i=aC.call(t);return r&&(e?t[Ao]=n:delete t[Ao]),i}var uC=lC,cC=Object.prototype,dC=cC.toString;function fC(t){return dC.call(t)}var hC=fC,Sy=by,pC=uC,gC=hC,vC="[object Null]",mC="[object Undefined]",Ey=Sy?Sy.toStringTag:void 0;function yC(t){return t==null?t===void 0?mC:vC:Ey&&Ey in Object(t)?pC(t):gC(t)}var _C=yC;function wC(t){return t!=null&&typeof t=="object"}var bC=wC,xC=_C,kC=bC,SC="[object Symbol]";function EC(t){return typeof t=="symbol"||kC(t)&&xC(t)==SC}var $C=EC,CC=rC,$y=_y,RC=$C,Cy=NaN,TC=/^[-+]0x[0-9a-f]+$/i,PC=/^0b[01]+$/i,MC=/^0o[0-7]+$/i,OC=parseInt;function AC(t){if(typeof t=="number")return t;if(RC(t))return Cy;if($y(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=$y(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=CC(t);var n=PC.test(t);return n||MC.test(t)?OC(t.slice(2),n?2:8):TC.test(t)?Cy:+t}var IC=AC,FC=_y,Pf=Q2,Ry=IC,LC="Expected a function",DC=Math.max,NC=Math.min;function jC(t,e,n){var r,i,s,o,a,l,u=0,c=!1,f=!1,d=!0;if(typeof t!="function")throw new TypeError(LC);e=Ry(e)||0,FC(n)&&(c=!!n.leading,f="maxWait"in n,s=f?DC(Ry(n.maxWait)||0,e):s,d="trailing"in n?!!n.trailing:d);function h(k){var $=r,C=i;return r=i=void 0,u=k,o=t.apply(C,$),o}function p(k){return u=k,a=setTimeout(m,e),c?h(k):o}function g(k){var $=k-l,C=k-u,H=e-$;return f?NC(H,s-C):H}function w(k){var $=k-l,C=k-u;return l===void 0||$>=e||$<0||f&&C>=s}function m(){var k=Pf();if(w(k))return v(k);a=setTimeout(m,g(k))}function v(k){return a=void 0,d&&r?h(k):(r=i=void 0,o)}function y(){a!==void 0&&clearTimeout(a),u=0,r=l=i=a=void 0}function b(){return a===void 0?o:v(Pf())}function x(){var k=Pf(),$=w(k);if(r=arguments,i=this,l=k,$){if(a===void 0)return p(l);if(f)return clearTimeout(a),a=setTimeout(m,e),h(l)}return a===void 0&&(a=setTimeout(m,e)),o}return x.cancel=y,x.flush=b,x}var zC=jC;const HC=Ss(zC);function Bl(t){"@babel/helpers - typeof";return Bl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bl(t)}var UC=/^\s+/,BC=/\s+$/;function Y(t,e){if(t=t||"",e=e||{},t instanceof Y)return t;if(!(this instanceof Y))return new Y(t,e);var n=qC(t);this._originalInput=t,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||n.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}Y.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),n,r,i,s,o,a;return n=e.r/255,r=e.g/255,i=e.b/255,n<=.03928?s=n/12.92:s=Math.pow((n+.055)/1.055,2.4),r<=.03928?o=r/12.92:o=Math.pow((r+.055)/1.055,2.4),i<=.03928?a=i/12.92:a=Math.pow((i+.055)/1.055,2.4),.2126*s+.7152*o+.0722*a},setAlpha:function(e){return this._a=Iy(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=Py(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=Py(this._r,this._g,this._b),n=Math.round(e.h*360),r=Math.round(e.s*100),i=Math.round(e.v*100);return this._a==1?"hsv("+n+", "+r+"%, "+i+"%)":"hsva("+n+", "+r+"%, "+i+"%, "+this._roundA+")"},toHsl:function(){var e=Ty(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Ty(this._r,this._g,this._b),n=Math.round(e.h*360),r=Math.round(e.s*100),i=Math.round(e.l*100);return this._a==1?"hsl("+n+", "+r+"%, "+i+"%)":"hsla("+n+", "+r+"%, "+i+"%, "+this._roundA+")"},toHex:function(e){return My(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return KC(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Me(this._r,255)*100)+"%",g:Math.round(Me(this._g,255)*100)+"%",b:Math.round(Me(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Me(this._r,255)*100)+"%, "+Math.round(Me(this._g,255)*100)+"%, "+Math.round(Me(this._b,255)*100)+"%)":"rgba("+Math.round(Me(this._r,255)*100)+"%, "+Math.round(Me(this._g,255)*100)+"%, "+Math.round(Me(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:o3[My(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var n="#"+Oy(this._r,this._g,this._b,this._a),r=n,i=this._gradientType?"GradientType = 1, ":"";if(e){var s=Y(e);r="#"+Oy(s._r,s._g,s._b,s._a)}return"progid:DXImageTransform.Microsoft.gradient("+i+"startColorstr="+n+",endColorstr="+r+")"},toString:function(e){var n=!!e;e=e||this._format;var r=!1,i=this._a<1&&this._a>=0,s=!n&&i&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return s?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return Y(this.toString())},_applyModification:function(e,n){var r=e.apply(null,[this].concat([].slice.call(n)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(ZC,arguments)},brighten:function(){return this._applyModification(JC,arguments)},darken:function(){return this._applyModification(e3,arguments)},desaturate:function(){return this._applyModification(YC,arguments)},saturate:function(){return this._applyModification(QC,arguments)},greyscale:function(){return this._applyModification(XC,arguments)},spin:function(){return this._applyModification(t3,arguments)},_applyCombination:function(e,n){return e.apply(null,[this].concat([].slice.call(n)))},analogous:function(){return this._applyCombination(i3,arguments)},complement:function(){return this._applyCombination(n3,arguments)},monochromatic:function(){return this._applyCombination(s3,arguments)},splitcomplement:function(){return this._applyCombination(r3,arguments)},triad:function(){return this._applyCombination(Ay,[3])},tetrad:function(){return this._applyCombination(Ay,[4])}},Y.fromRatio=function(t,e){if(Bl(t)=="object"){var n={};for(var r in t)t.hasOwnProperty(r)&&(r==="a"?n[r]=t[r]:n[r]=Io(t[r]));t=n}return Y(t,e)};function qC(t){var e={r:0,g:0,b:0},n=1,r=null,i=null,s=null,o=!1,a=!1;return typeof t=="string"&&(t=c3(t)),Bl(t)=="object"&&(er(t.r)&&er(t.g)&&er(t.b)?(e=VC(t.r,t.g,t.b),o=!0,a=String(t.r).substr(-1)==="%"?"prgb":"rgb"):er(t.h)&&er(t.s)&&er(t.v)?(r=Io(t.s),i=Io(t.v),e=GC(t.h,r,i),o=!0,a="hsv"):er(t.h)&&er(t.s)&&er(t.l)&&(r=Io(t.s),s=Io(t.l),e=WC(t.h,r,s),o=!0,a="hsl"),t.hasOwnProperty("a")&&(n=t.a)),n=Iy(n),{ok:o,format:t.format||a,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:n}}function VC(t,e,n){return{r:Me(t,255)*255,g:Me(e,255)*255,b:Me(n,255)*255}}function Ty(t,e,n){t=Me(t,255),e=Me(e,255),n=Me(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),s,o,a=(r+i)/2;if(r==i)s=o=0;else{var l=r-i;switch(o=a>.5?l/(2-r-i):l/(r+i),r){case t:s=(e-n)/l+(e<n?6:0);break;case e:s=(n-t)/l+2;break;case n:s=(t-e)/l+4;break}s/=6}return{h:s,s:o,l:a}}function WC(t,e,n){var r,i,s;t=Me(t,360),e=Me(e,100),n=Me(n,100);function o(u,c,f){return f<0&&(f+=1),f>1&&(f-=1),f<1/6?u+(c-u)*6*f:f<1/2?c:f<2/3?u+(c-u)*(2/3-f)*6:u}if(e===0)r=i=s=n;else{var a=n<.5?n*(1+e):n+e-n*e,l=2*n-a;r=o(l,a,t+1/3),i=o(l,a,t),s=o(l,a,t-1/3)}return{r:r*255,g:i*255,b:s*255}}function Py(t,e,n){t=Me(t,255),e=Me(e,255),n=Me(n,255);var r=Math.max(t,e,n),i=Math.min(t,e,n),s,o,a=r,l=r-i;if(o=r===0?0:l/r,r==i)s=0;else{switch(r){case t:s=(e-n)/l+(e<n?6:0);break;case e:s=(n-t)/l+2;break;case n:s=(t-e)/l+4;break}s/=6}return{h:s,s:o,v:a}}function GC(t,e,n){t=Me(t,360)*6,e=Me(e,100),n=Me(n,100);var r=Math.floor(t),i=t-r,s=n*(1-e),o=n*(1-i*e),a=n*(1-(1-i)*e),l=r%6,u=[n,o,s,s,a,n][l],c=[a,n,n,o,s,s][l],f=[s,s,a,n,n,o][l];return{r:u*255,g:c*255,b:f*255}}function My(t,e,n,r){var i=[yn(Math.round(t).toString(16)),yn(Math.round(e).toString(16)),yn(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function KC(t,e,n,r,i){var s=[yn(Math.round(t).toString(16)),yn(Math.round(e).toString(16)),yn(Math.round(n).toString(16)),yn(Fy(r))];return i&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)&&s[3].charAt(0)==s[3].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0)+s[3].charAt(0):s.join("")}function Oy(t,e,n,r){var i=[yn(Fy(r)),yn(Math.round(t).toString(16)),yn(Math.round(e).toString(16)),yn(Math.round(n).toString(16))];return i.join("")}Y.equals=function(t,e){return!t||!e?!1:Y(t).toRgbString()==Y(e).toRgbString()},Y.random=function(){return Y.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function YC(t,e){e=e===0?0:e||10;var n=Y(t).toHsl();return n.s-=e/100,n.s=ql(n.s),Y(n)}function QC(t,e){e=e===0?0:e||10;var n=Y(t).toHsl();return n.s+=e/100,n.s=ql(n.s),Y(n)}function XC(t){return Y(t).desaturate(100)}function ZC(t,e){e=e===0?0:e||10;var n=Y(t).toHsl();return n.l+=e/100,n.l=ql(n.l),Y(n)}function JC(t,e){e=e===0?0:e||10;var n=Y(t).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(255*-(e/100)))),n.g=Math.max(0,Math.min(255,n.g-Math.round(255*-(e/100)))),n.b=Math.max(0,Math.min(255,n.b-Math.round(255*-(e/100)))),Y(n)}function e3(t,e){e=e===0?0:e||10;var n=Y(t).toHsl();return n.l-=e/100,n.l=ql(n.l),Y(n)}function t3(t,e){var n=Y(t).toHsl(),r=(n.h+e)%360;return n.h=r<0?360+r:r,Y(n)}function n3(t){var e=Y(t).toHsl();return e.h=(e.h+180)%360,Y(e)}function Ay(t,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var n=Y(t).toHsl(),r=[Y(t)],i=360/e,s=1;s<e;s++)r.push(Y({h:(n.h+s*i)%360,s:n.s,l:n.l}));return r}function r3(t){var e=Y(t).toHsl(),n=e.h;return[Y(t),Y({h:(n+72)%360,s:e.s,l:e.l}),Y({h:(n+216)%360,s:e.s,l:e.l})]}function i3(t,e,n){e=e||6,n=n||30;var r=Y(t).toHsl(),i=360/n,s=[Y(t)];for(r.h=(r.h-(i*e>>1)+720)%360;--e;)r.h=(r.h+i)%360,s.push(Y(r));return s}function s3(t,e){e=e||6;for(var n=Y(t).toHsv(),r=n.h,i=n.s,s=n.v,o=[],a=1/e;e--;)o.push(Y({h:r,s:i,v:s})),s=(s+a)%1;return o}Y.mix=function(t,e,n){n=n===0?0:n||50;var r=Y(t).toRgb(),i=Y(e).toRgb(),s=n/100,o={r:(i.r-r.r)*s+r.r,g:(i.g-r.g)*s+r.g,b:(i.b-r.b)*s+r.b,a:(i.a-r.a)*s+r.a};return Y(o)},Y.readability=function(t,e){var n=Y(t),r=Y(e);return(Math.max(n.getLuminance(),r.getLuminance())+.05)/(Math.min(n.getLuminance(),r.getLuminance())+.05)},Y.isReadable=function(t,e,n){var r=Y.readability(t,e),i,s;switch(s=!1,i=d3(n),i.level+i.size){case"AAsmall":case"AAAlarge":s=r>=4.5;break;case"AAlarge":s=r>=3;break;case"AAAsmall":s=r>=7;break}return s},Y.mostReadable=function(t,e,n){var r=null,i=0,s,o,a,l;n=n||{},o=n.includeFallbackColors,a=n.level,l=n.size;for(var u=0;u<e.length;u++)s=Y.readability(t,e[u]),s>i&&(i=s,r=Y(e[u]));return Y.isReadable(t,r,{level:a,size:l})||!o?r:(n.includeFallbackColors=!1,Y.mostReadable(t,["#fff","#000"],n))};var Mf=Y.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},o3=Y.hexNames=a3(Mf);function a3(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[t[n]]=n);return e}function Iy(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function Me(t,e){l3(t)&&(t="100%");var n=u3(t);return t=Math.min(e,Math.max(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),Math.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function ql(t){return Math.min(1,Math.max(0,t))}function qt(t){return parseInt(t,16)}function l3(t){return typeof t=="string"&&t.indexOf(".")!=-1&&parseFloat(t)===1}function u3(t){return typeof t=="string"&&t.indexOf("%")!=-1}function yn(t){return t.length==1?"0"+t:""+t}function Io(t){return t<=1&&(t=t*100+"%"),t}function Fy(t){return Math.round(parseFloat(t)*255).toString(16)}function Ly(t){return qt(t)/255}var _n=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",n="(?:"+e+")|(?:"+t+")",r="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?",i="[\\s|\\(]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")[,|\\s]+("+n+")\\s*\\)?";return{CSS_UNIT:new RegExp(n),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+i),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+i),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+i),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function er(t){return!!_n.CSS_UNIT.exec(t)}function c3(t){t=t.replace(UC,"").replace(BC,"").toLowerCase();var e=!1;if(Mf[t])t=Mf[t],e=!0;else if(t=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var n;return(n=_n.rgb.exec(t))?{r:n[1],g:n[2],b:n[3]}:(n=_n.rgba.exec(t))?{r:n[1],g:n[2],b:n[3],a:n[4]}:(n=_n.hsl.exec(t))?{h:n[1],s:n[2],l:n[3]}:(n=_n.hsla.exec(t))?{h:n[1],s:n[2],l:n[3],a:n[4]}:(n=_n.hsv.exec(t))?{h:n[1],s:n[2],v:n[3]}:(n=_n.hsva.exec(t))?{h:n[1],s:n[2],v:n[3],a:n[4]}:(n=_n.hex8.exec(t))?{r:qt(n[1]),g:qt(n[2]),b:qt(n[3]),a:Ly(n[4]),format:e?"name":"hex8"}:(n=_n.hex6.exec(t))?{r:qt(n[1]),g:qt(n[2]),b:qt(n[3]),format:e?"name":"hex"}:(n=_n.hex4.exec(t))?{r:qt(n[1]+""+n[1]),g:qt(n[2]+""+n[2]),b:qt(n[3]+""+n[3]),a:Ly(n[4]+""+n[4]),format:e?"name":"hex8"}:(n=_n.hex3.exec(t))?{r:qt(n[1]+""+n[1]),g:qt(n[2]+""+n[2]),b:qt(n[3]+""+n[3]),format:e?"name":"hex"}:!1}function d3(t){var e,n;return t=t||{level:"AA",size:"small"},e=(t.level||"AA").toUpperCase(),n=(t.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),n!=="small"&&n!=="large"&&(n="small"),{level:e,size:n}}var E=typeof window<"u"?window:void 0,Tt=typeof globalThis<"u"?globalThis:E,Dy=Array.prototype,Ny=Dy.forEach,jy=Dy.indexOf,Vt=Tt==null?void 0:Tt.navigator,W=Tt==null?void 0:Tt.document,Pt=Tt==null?void 0:Tt.location,Of=Tt==null?void 0:Tt.fetch,Af=Tt!=null&&Tt.XMLHttpRequest&&"withCredentials"in new Tt.XMLHttpRequest?Tt.XMLHttpRequest:void 0,zy=Tt==null?void 0:Tt.AbortController,Mt=Vt==null?void 0:Vt.userAgent,X=E??{},tr={DEBUG:!1,LIB_VERSION:"1.270.1"};function Hy(t,e,n,r,i,s,o){try{var a=t[s](o),l=a.value}catch(u){return void n(u)}a.done?e(l):Promise.resolve(l).then(r,i)}function Uy(t){return function(){var e=this,n=arguments;return new Promise(function(r,i){var s=t.apply(e,n);function o(l){Hy(s,r,i,o,a,"next",l)}function a(l){Hy(s,r,i,o,a,"throw",l)}o(void 0)})}}function z(){return z=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},z.apply(null,arguments)}function By(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var f3=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function oe(t,e){return t.indexOf(e)!==-1}var Vl=function(t){return t.trim()},If=function(t){return t.replace(/^\$/,"")},h3=Array.isArray,qy=Object.prototype,Vy=qy.hasOwnProperty,Wl=qy.toString,$e=h3||function(t){return Wl.call(t)==="[object Array]"},tn=t=>typeof t=="function",Ne=t=>t===Object(t)&&!$e(t),us=t=>{if(Ne(t)){for(var e in t)if(Vy.call(t,e))return!1;return!0}return!1},L=t=>t===void 0,je=t=>Wl.call(t)=="[object String]",Ff=t=>je(t)&&t.trim().length===0,nr=t=>t===null,fe=t=>L(t)||nr(t),dt=t=>Wl.call(t)=="[object Number]",wn=t=>Wl.call(t)==="[object Boolean]",p3=t=>t instanceof FormData,g3=t=>oe(f3,t);function Lf(t){return t===null||typeof t!="object"}function Gl(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"}function Wy(t){return!L(Event)&&function(e,n){try{return e instanceof n}catch{return!1}}(t,Event)}var v3=[!0,"true",1,"1","yes"],Df=t=>oe(v3,t),m3=[!1,"false",0,"0","no"];function Wt(t,e,n,r,i){return e>n&&(r.warn("min cannot be greater than max."),e=n),dt(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),Wt(i||n,e,n,r))}class Gy{constructor(e){this.t=e,this.i={},this.o=()=>{Object.keys(this.i).forEach(n=>{var r=this.h(n)+this.m;r>=this.S?delete this.i[n]:this.k(n,r)})},this.h=n=>this.i[String(n)],this.k=(n,r)=>{this.i[String(n)]=r},this.consumeRateLimit=n=>{var r,i,s=(r=this.h(n))!==null&&r!==void 0?r:this.S;if((s=Math.max(s-1,0))===0)return!0;this.k(n,s);var o=s===0;return o&&((i=this.$)==null||i.call(this,n)),o},this.$=this.t.$,this.S=Wt(this.t.bucketSize,0,100,this.t.R),this.m=Wt(this.t.refillRate,0,this.S,this.t.R),this.I=Wt(this.t.refillInterval,0,864e5,this.t.R),this.P=setInterval(()=>{this.o()},this.I)}stop(){this.P&&(clearInterval(this.P),this.P=void 0)}}var Kl,Ky,Nf,y3=t=>t instanceof Error;function _3(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return Nf&&n.length===Ky||(Ky=n.length,Nf=n.reduce((r,i)=>{Kl||(Kl={});var s=Kl[i];if(s)r[s[0]]=s[1];else for(var o=t(i),a=o.length-1;a>=0;a--){var l=o[a],u=l==null?void 0:l.filename,c=e[i];if(u&&c){r[u]=c,Kl[i]=[u,c];break}}return r},{})),Nf}}var cs="?";function jf(t,e,n,r){var i={platform:"web:javascript",filename:t,function:e==="<anonymous>"?cs:e,in_app:!0};return L(n)||(i.lineno=n),L(r)||(i.colno=r),i}var Yy=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:cs,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},w3=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,b3=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,x3=/\((\S*)(?::(\d+))(?::(\d+))\)/,k3=t=>{var e=w3.exec(t);if(e){var[,n,r,i]=e;return jf(n,cs,+r,+i)}var s=b3.exec(t);if(s){if(s[2]&&s[2].indexOf("eval")===0){var o=x3.exec(s[2]);o&&(s[2]=o[1],s[3]=o[2],s[4]=o[3])}var[a,l]=Yy(s[1]||cs,s[2]);return jf(l,a,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},S3=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,E3=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,$3=t=>{var e=S3.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){var n=E3.exec(e[3]);n&&(e[1]=e[1]||"eval",e[3]=n[1],e[4]=n[2],e[5]="")}var r=e[3],i=e[1]||cs;return[i,r]=Yy(i,r),jf(r,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}},Qy=/\(error: (.*)\)/,Xy=50;function C3(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return function(r,i){i===void 0&&(i=0);for(var s=[],o=r.split(`
|
|
59
59
|
`),a=i;a<o.length;a++){var l=o[a];if(!(l.length>1024)){var u=Qy.test(l)?l.replace(Qy,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of e){var f=c(u);if(f){s.push(f);break}}if(s.length>=Xy)break}}}return function(d){if(!d.length)return[];var h=Array.from(d);return h.reverse(),h.slice(0,Xy).map(p=>{return z({},p,{filename:p.filename||(g=h,g[g.length-1]||{}).filename,function:p.function||cs});var g})}(s)}}class R3{constructor(e,n,r){e===void 0&&(e=[]),n===void 0&&(n=[]),r===void 0&&(r=[]),this.coercers=e,this.modifiers=r,this.stackParser=C3(...n)}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,n,0).apply(e),s=this.buildParsingContext(),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var n=this;return Uy(function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&$e(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e})()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),n.chunkIdMap)),z({},e,{cause:r,stack:i})}applyChunkIds(e,n){return e.map(r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return Uy(function*(){var r=e;for(var i of n.modifiers)r=yield i(r);return r})()}convertToExceptionList(e,n){var r,i,s,o={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(s=e.synthetic)!==null&&s!==void 0&&s}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,z({},n,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:_3(this.stackParser)}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var i=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,n,o);return this.applyCoercers(s,a)}};return z({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}}class T3{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var r=je(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return Gl(e,"DOMException")}isDOMError(e){return Gl(e,"DOMError")}}class P3{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var r=e.message;return r.error&&typeof r.error.message=="string"?String(r.error.message):String(r)}getStack(e){return e.stacktrace||e.stack||void 0}}class M3{constructor(){}match(e){return Gl(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var r,i=n.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}var O3=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class A3{match(e){return typeof e=="string"}coerce(e,n){var r,[i,s]=this.getInfos(e);return{type:i??"Error",value:s??e,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var n="Error",r=e,i=e.match(O3);return i&&(n=i[1],r=i[2]),[n,r]}}var I3=["fatal","error","warning","log","info","debug"];function Zy(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(!(i.length>e))return r===n.length||i.length<=e?i:i.slice(0,e)+"..."}return""}class F3{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var r,i=this.getErrorPropertyFromObject(e);return i?n.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=n.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Wy(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+Zy(e)}isSeverityLevel(e){return je(e)&&!Ff(e)&&I3.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=e[n];if(y3(r))return r}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}}class L3{match(e){return Wy(e)}coerce(e,n){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Zy(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class D3{match(e){return Lf(e)}coerce(e,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class N3{match(e){return Gl(e,"PromiseRejectionEvent")}coerce(e,n){var r,i=this.getUnhandledRejectionReason(e);return Lf(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(i)}getUnhandledRejectionReason(e){if(Lf(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}}var Jy=t=>{var e={T:function(n){if(E&&(tr.DEBUG||X.POSTHOG_DEBUG)&&!L(E.console)&&E.console){for(var r=("__rrweb_original__"in E.console[n])?E.console[n].__rrweb_original__:E.console[n],i=arguments.length,s=new Array(i>1?i-1:0),o=1;o<i;o++)s[o-1]=arguments[o];r(t,...s)}},info:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.T("log",...r)},warn:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.T("warn",...r)},error:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.T("error",...r)},critical:function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];console.error(t,...r)},uninitializedWarning:n=>{e.error("You must initialize PostHog before calling "+n)},createLogger:n=>Jy(t+" "+n)};return e},V=Jy("[PostHog.js]"),Ge=V.createLogger,j3=Ge("[ExternalScriptsLoader]"),e_=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return j3.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=W==null?void 0:W.querySelectorAll("script");if(r){for(var i,s=function(){if(r[o].src===e){var l=r[o];return l.__posthog_loading_callback_fired?{v:n()}:(l.addEventListener("load",u=>{l.__posthog_loading_callback_fired=!0,n(void 0,u)}),l.onerror=u=>n(u),{v:void 0})}},o=0;o<r.length;o++)if(i=s())return i.v}var a=()=>{if(!W)return n("document not found");var l=W.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=f=>{l.__posthog_loading_callback_fired=!0,n(void 0,f)},l.onerror=f=>n(f),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return n("prepare_external_dependency_script returned null");var u,c=W.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[0]):W.body.appendChild(l)};W!=null&&W.body?a():W==null||W.addEventListener("DOMContentLoaded",a)};X.__PosthogExtensions__=X.__PosthogExtensions__||{},X.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{var r="/static/"+e+".js?v="+t.version;if(e==="remote-config"&&(r="/array/"+t.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var s=t.requestRouter.endpointFor("assets",r);e_(t,s,n)},X.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);e_(t,r,n)};var Yl={};function Or(t,e,n){if($e(t)){if(Ny&&t.forEach===Ny)t.forEach(e,n);else if("length"in t&&t.length===+t.length){for(var r=0,i=t.length;r<i;r++)if(r in t&&e.call(n,t[r],r)===Yl)return}}}function be(t,e,n){if(!fe(t)){if($e(t))return Or(t,e,n);if(p3(t)){for(var r of t.entries())if(e.call(n,r[1],r[0])===Yl)return}else for(var i in t)if(Vy.call(t,i)&&e.call(n,t[i],i)===Yl)return}}var He=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Or(n,function(i){for(var s in i)i[s]!==void 0&&(t[s]=i[s])}),t},Ql=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Or(n,function(i){Or(i,function(s){t.push(s)})}),t};function Xl(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var t_=function(t){try{return t()}catch{return}},z3=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(this,n)}catch(i){V.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),V.critical(i)}}},zf=function(t){var e={};return be(t,function(n,r){(je(n)&&n.length>0||dt(n))&&(e[r]=n)}),e};function H3(t,e){return n=t,r=s=>je(s)&&!nr(e)?s.slice(0,e):s,i=new Set,function s(o,a){return o!==Object(o)?r?r(o,a):o:i.has(o)?void 0:(i.add(o),$e(o)?(l=[],Or(o,u=>{l.push(s(u))})):(l={},be(o,(u,c)=>{i.has(u)||(l[c]=s(u,c))})),l);var l}(n);var n,r,i}var U3=["herokuapp.com","vercel.app","netlify.app"];function B3(t){var e=t==null?void 0:t.hostname;if(!je(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of U3)if(n===r)return!1;return!0}function n_(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return t[n]}function Le(t,e,n,r){var{capture:i=!1,passive:s=!0}=r??{};t==null||t.addEventListener(e,n,{capture:i,passive:s})}var r_="$people_distinct_id",Fo="__alias",Lo="__timers",i_="$autocapture_disabled_server_side",Hf="$heatmaps_enabled_server_side",s_="$exception_capture_enabled_server_side",Uf="$error_tracking_suppression_rules",o_="$error_tracking_capture_extension_exceptions",a_="$web_vitals_enabled_server_side",l_="$dead_clicks_enabled_server_side",u_="$web_vitals_allowed_metrics",Bf="$session_recording_remote_config",qf="$session_recording_enabled_server_side",c_="$console_log_recording_enabled_server_side",d_="$session_recording_network_payload_capture",f_="$session_recording_masking",h_="$session_recording_canvas_recording",p_="$replay_sample_rate",g_="$replay_minimum_duration",v_="$replay_script_config",Zl="$sesid",ds="$session_is_sampled",Vf="$session_recording_url_trigger_activated_session",Wf="$session_recording_event_trigger_activated_session",fs="$enabled_feature_flags",Do="$early_access_features",Gf="$feature_flag_details",No="$stored_person_properties",hi="$stored_group_properties",Kf="$surveys",Jl="$surveys_activated",eu="$flag_call_reported",rr="$user_state",Yf="$client_session_props",Qf="$capture_rate_limit",Xf="$initial_campaign_params",Zf="$initial_referrer_info",tu="$initial_person_info",nu="$epp",m_="__POSTHOG_TOOLBAR__",jo="$posthog_cookieless",q3=[r_,Fo,"__cmpns",Lo,qf,Hf,Zl,fs,Uf,rr,Do,Gf,hi,No,Kf,eu,Yf,Qf,Xf,Zf,nu,tu];function y_(t){return t instanceof Element&&(t.id===m_||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function ru(t){return!!t&&t.nodeType===1}function Ar(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function __(t){return!!t&&t.nodeType===3}function w_(t){return!!t&&t.nodeType===11}function Jf(t){return t?Vl(t).split(/\s+/):[]}function b_(t){var e=E==null?void 0:E.location.href;return!!(e&&t&&t.some(n=>e.match(n)))}function iu(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Jf(e)}function x_(t){return fe(t)?null:Vl(t).split(/(\s+)/).filter(e=>hs(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function su(t){var e="";return nh(t)&&!R_(t)&&t.childNodes&&t.childNodes.length&&be(t.childNodes,function(n){var r;__(n)&&n.textContent&&(e+=(r=x_(n.textContent))!==null&&r!==void 0?r:"")}),Vl(e)}function k_(t){return L(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var eh=["a","button","form","input","select","textarea","label"];function S_(t,e){if(L(e))return!0;var n,r=function(s){if(e.some(o=>s.matches(o)))return{v:!0}};for(var i of t)if(n=r(i))return n.v;return!1}function E_(t){var e=t.parentNode;return!(!e||!ru(e))&&e}var $_=[".ph-no-rageclick",".ph-no-capture"],th=t=>!t||Ar(t,"html")||!ru(t),C_=(t,e)=>{if(!E||th(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[t],i=t;i.parentNode&&!Ar(i,"body");)if(w_(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=E_(i);if(!s)break;if(e||eh.indexOf(s.tagName.toLowerCase())>-1)n=!0;else{var o=E.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(n=!0)}r.push(s),i=s}return{parentIsUsefulElement:n,targetElementList:r}};function V3(t,e,n,r,i){var s,o,a,l;if(n===void 0&&(n=void 0),!E||th(t)||(s=n)!=null&&s.url_allowlist&&!b_(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&b_(n.url_ignorelist))return!1;if((a=n)!=null&&a.dom_event_allowlist){var u=n.dom_event_allowlist;if(u&&!u.some(p=>e.type===p))return!1}var{parentIsUsefulElement:c,targetElementList:f}=C_(t,r);if(!function(p,g){var w=g==null?void 0:g.element_allowlist;if(L(w))return!0;var m,v=function(b){if(w.some(x=>b.tagName.toLowerCase()===x))return{v:!0}};for(var y of p)if(m=v(y))return m.v;return!1}(f,n)||!S_(f,(l=n)==null?void 0:l.css_selector_allowlist))return!1;var d=E.getComputedStyle(t);if(d&&d.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var h=t.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(i||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(e.type)>=0;default:return c?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(eh.indexOf(h)>-1||t.getAttribute("contenteditable")==="true")}}function nh(t){for(var e=t;e.parentNode&&!Ar(e,"body");e=e.parentNode){var n=iu(e);if(oe(n,"ph-sensitive")||oe(n,"ph-no-capture"))return!1}if(oe(iu(t),"ph-include"))return!0;var r=t.type||"";if(je(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!(je(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function R_(t){return!!(Ar(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ar(t,"select")||Ar(t,"textarea")||t.getAttribute("contenteditable")==="true")}var 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})",W3=new RegExp("^(?:"+T_+")$"),G3=new RegExp(T_),P_="\\d{3}-?\\d{2}-?\\d{4}",K3=new RegExp("^("+P_+")$"),Y3=new RegExp("("+P_+")");function hs(t,e){return e===void 0&&(e=!0),!(fe(t)||je(t)&&(t=Vl(t),(e?W3:G3).test((t||"").replace(/[- ]/g,""))||(e?K3:Y3).test(t)))}function M_(t){var e=su(t);return hs(e=(e+" "+O_(t)).trim())?e:""}function O_(t){var e="";return t&&t.childNodes&&t.childNodes.length&&be(t.childNodes,function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=su(n);e=(e+" "+i).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+O_(n)).trim())}catch(s){V.error("[AutoCapture]",s)}}),e}function Q3(t){return function(e){var n=e.map(r=>{var i,s,o="";if(r.tag_name&&(o+=r.tag_name),r.attr_class)for(var a of(r.attr_class.sort(),r.attr_class))o+="."+a.replace(/"/g,"");var l=z({},r.text?{text:r.text}:{},{"nth-child":(i=r.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),u={};return Xl(l).sort((c,f)=>{var[d]=c,[h]=f;return d.localeCompare(h)}).forEach(c=>{var[f,d]=c;return u[A_(f.toString())]=A_(d.toString())}),o+=":",o+=Xl(u).map(c=>{var[f,d]=c;return f+'="'+d+'"'}).join("")});return n.join(";")}(function(e){return e.map(n=>{var r,i,s={text:(r=n.$el_text)==null?void 0:r.slice(0,400),tag_name:n.tag_name,href:(i=n.attr__href)==null?void 0:i.slice(0,2048),attr_class:X3(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return Xl(n).filter(o=>{var[a]=o;return a.indexOf("attr__")===0}).forEach(o=>{var[a,l]=o;return s.attributes[a]=l}),s})}(t))}function A_(t){return t.replace(/"|\\"/g,'\\"')}function X3(t){var e=t.attr__class;return e?$e(e)?e:Jf(e):void 0}class I_{constructor(){this.clicks=[]}isRageClick(e,n,r){var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<30&&r-i.timestamp<1e3){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===3)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}}var rh="$copy_autocapture",ir=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),Z3=["localhost","127.0.0.1"],ps=t=>{var e=W==null?void 0:W.createElement("a");return L(e)?null:(e.href=t,e)},J3=function(t,e){var n,r;e===void 0&&(e="&");var i=[];return be(t,function(s,o){L(s)||L(o)||o==="undefined"||(n=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),i[i.length]=r+"="+n)}),i.join(e)},ou=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===e){n=s;break}}if(!$e(n)||n.length<2)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{V.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},ih=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),c=[],f=0;f<u.length;f++){var d=u[f].split("=");$e(d)&&(e.includes(d[0])?c.push(d[0]+"="+n):c.push(u[f]))}var h=l;return a!=null&&(h+="?"+c.join("&")),s!=null&&(h+="#"+s),h},au=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},F_=Ge("[AutoCapture]");function sh(t,e){return e.length>t?e.slice(0,t)+"...":e}function eR(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!ru(e));return e}function tR(t,e,n,r){var i=t.tagName.toLowerCase(),s={tag_name:i};eh.indexOf(i)>-1&&!n&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=sh(1024,M_(t)):s.$el_text=sh(1024,su(t)));var o=iu(t);o.length>0&&(s.classes=o.filter(function(c){return c!==""})),be(t.attributes,function(c){var f;if((!R_(t)||["name","id","class","aria-label"].indexOf(c.name)!==-1)&&(r==null||!r.includes(c.name))&&!e&&hs(c.value)&&(f=c.name,!je(f)||f.substring(0,10)!=="_ngcontent"&&f.substring(0,7)!=="_nghost")){var d=c.value;c.name==="class"&&(d=Jf(d).join(" ")),s["attr__"+c.name]=sh(1024,d)}});for(var a=1,l=1,u=t;u=eR(u);)a++,u.tagName===t.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function nR(t,e){for(var n,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,u=[t],c=t;c.parentNode&&!Ar(c,"body");)w_(c.parentNode)?(u.push(c.parentNode.host),c=c.parentNode.host):(u.push(c.parentNode),c=c.parentNode);var f,d=[],h={},p=!1,g=!1;if(be(u,b=>{var x=nh(b);b.tagName.toLowerCase()==="a"&&(p=b.getAttribute("href"),p=x&&p&&hs(p)&&p),oe(iu(b),"ph-no-capture")&&(g=!0),d.push(tR(b,s,o,a));var k=function($){if(!nh($))return{};var C={};return be($.attributes,function(H){if(H.name&&H.name.indexOf("data-ph-capture-attribute")===0){var M=H.name.replace("data-ph-capture-attribute-",""),U=H.value;M&&U&&hs(U)&&(C[M]=U)}}),C}(b);He(h,k)}),g)return{props:{},explicitNoCapture:g};if(o||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?d[0].$el_text=M_(t):d[0].$el_text=su(t)),p){var w,m;d[0].attr__href=p;var v=(w=ps(p))==null?void 0:w.host,y=E==null||(m=E.location)==null?void 0:m.host;v&&y&&v!==y&&(f=p)}return{props:He({$event_type:i.type,$ce_version:1},l?{}:{$elements:d},{$elements_chain:Q3(d)},(n=d[0])!=null&&n.$el_text?{$el_text:(r=d[0])==null?void 0:r.$el_text}:{},f&&i.type==="click"?{$external_click_url:f}:{},h)}}class rR{constructor(e){this.C=!1,this.M=null,this.rageclicks=new I_,this.O=!1,this.instance=e,this.F=null}get A(){var e,n,r=Ne(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(e=r.url_allowlist)==null?void 0:e.map(i=>new RegExp(i)),r.url_ignorelist=(n=r.url_ignorelist)==null?void 0:n.map(i=>new RegExp(i)),r}D(){if(this.isBrowserSupported()){if(E&&W){var e=r=>{r=r||(E==null?void 0:E.event);try{this.j(r)}catch(i){F_.error("Failed to capture event",i)}};if(Le(W,"submit",e,{capture:!0}),Le(W,"change",e,{capture:!0}),Le(W,"click",e,{capture:!0}),this.A.capture_copied_text){var n=r=>{r=r||(E==null?void 0:E.event),this.j(r,rh)};Le(W,"copy",n,{capture:!0}),Le(W,"cut",n,{capture:!0})}}}else F_.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.C&&(this.D(),this.C=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.O=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[i_]:!!e.autocapture_opt_out}),this.M=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.F=e}getElementSelectors(e){var n,r=[];return(n=this.F)==null||n.forEach(i=>{var s=W==null?void 0:W.querySelectorAll(i);s==null||s.forEach(o=>{e===o&&r.push(i)})}),r}get isEnabled(){var e,n,r=(e=this.instance.persistence)==null?void 0:e.props[i_],i=this.M;if(nr(i)&&!wn(r)&&!this.instance.L())return!1;var s=(n=this.M)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!s}j(e,n){if(n===void 0&&(n="$autocapture"),this.isEnabled){var r,i=k_(e);__(i)&&(i=i.parentNode||null),n==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&function(d,h){if(!E||th(d))return!1;var p,g;if((p=wn(h)?!!h&&$_:(g=h==null?void 0:h.css_selector_ignorelist)!==null&&g!==void 0?g:$_)===!1)return!1;var{targetElementList:w}=C_(d,!1);return!S_(w,p)}(i,this.instance.config.rageclick)&&this.j(e,"$rageclick");var s=n===rh;if(i&&V3(i,e,this.A,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=nR(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.A.element_attribute_ignorelist,elementsChainAsString:this.O});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(o.$element_selectors=l),n===rh){var u,c=x_(E==null||(u=E.getSelection())==null?void 0:u.toString()),f=e.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=f}return this.instance.capture(n,o),!0}}}isBrowserSupported(){return tn(W==null?void 0:W.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return dt(t)&&isFinite(t)&&Math.floor(t)===t});var L_="0123456789abcdef";class lu{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||n<0||r<0||i<0||e>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|n>>>8,s[7]=n,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new lu(s)}toString(){for(var e="",n=0;n<this.bytes.length;n++)e=e+L_.charAt(this.bytes[n]>>>4)+L_.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new lu(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;n<16;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class iR{constructor(){this.N=0,this.U=0,this.B=new sR}generate(){var e=this.generateOrAbort();if(L(e)){this.N=0;var n=this.generateOrAbort();if(L(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.N)this.N=e,this.q();else{if(!(e+1e4>this.N))return;this.U++,this.U>4398046511103&&(this.N++,this.q())}return lu.fromFieldsV7(this.N,Math.trunc(this.U/Math.pow(2,30)),this.U&Math.pow(2,30)-1,this.B.nextUint32())}q(){this.U=1024*this.B.nextUint32()+(1023&this.B.nextUint32())}}var D_,N_=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};E&&!L(E.crypto)&&crypto.getRandomValues&&(N_=t=>crypto.getRandomValues(t));class sR{constructor(){this.H=new Uint32Array(8),this.W=1/0}nextUint32(){return this.W>=this.H.length&&(N_(this.H),this.W=0),this.H[this.W++]}}var Ir=()=>oR().toString(),oR=()=>(D_||(D_=new iR)).generate(),zo="",aR=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function lR(t,e){if(e){var n=function(i,s){if(s===void 0&&(s=W),zo)return zo;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+Ir();!zo&&a--;){var u=o.slice(a).join("."),c=l+"=1;domain=."+u+";path=/";s.cookie=c+";max-age=3",s.cookie.includes(l)&&(s.cookie=c+";max-age=0",zo=u)}return zo}(t);if(!n){var r=(i=>{var s=i.match(aR);return s?s[0]:""})(t);r!==n&&V.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var Dn={G:()=>!!W,V:function(t){V.error("cookieStore error: "+t)},J:function(t){if(W){try{for(var e=t+"=",n=W.cookie.split(";").filter(s=>s.length),r=0;r<n.length;r++){for(var i=n[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.length))}}catch{}return null}},K:function(t){var e;try{e=JSON.parse(Dn.J(t))||{}}catch{}return e},Y:function(t,e,n,r,i){if(W)try{var s="",o="",a=lR(W.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),s="; expires="+l.toUTCString()}i&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&V.warn("cookieStore warning: large cookie, len="+u.length),W.cookie=u,u}catch{return}},X:function(t,e){if(W!=null&&W.cookie)try{Dn.Y(t,"",-1,e)}catch{return}}},oh=null,Ke={G:function(){if(!nr(oh))return oh;var t=!0;if(L(E))t=!1;else try{var e="__mplssupport__";Ke.Y(e,"xyz"),Ke.J(e)!=='"xyz"'&&(t=!1),Ke.X(e)}catch{t=!1}return t||V.error("localStorage unsupported; falling back to cookie store"),oh=t,t},V:function(t){V.error("localStorage error: "+t)},J:function(t){try{return E==null?void 0:E.localStorage.getItem(t)}catch(e){Ke.V(e)}return null},K:function(t){try{return JSON.parse(Ke.J(t))||{}}catch{}return null},Y:function(t,e){try{E==null||E.localStorage.setItem(t,JSON.stringify(e))}catch(n){Ke.V(n)}},X:function(t){try{E==null||E.localStorage.removeItem(t)}catch(e){Ke.V(e)}}},uR=["distinct_id",Zl,ds,nu,tu],uu=z({},Ke,{K:function(t){try{var e={};try{e=Dn.K(t)||{}}catch{}var n=He(e,JSON.parse(Ke.J(t)||"{}"));return Ke.Y(t,n),n}catch{}return null},Y:function(t,e,n,r,i,s){try{Ke.Y(t,e,void 0,void 0,s);var o={};uR.forEach(a=>{e[a]&&(o[a]=e[a])}),Object.keys(o).length&&Dn.Y(t,o,n,r,i,s)}catch(a){Ke.V(a)}},X:function(t,e){try{E==null||E.localStorage.removeItem(t),Dn.X(t,e)}catch(n){Ke.V(n)}}}),cu={},cR={G:function(){return!0},V:function(t){V.error("memoryStorage error: "+t)},J:function(t){return cu[t]||null},K:function(t){return cu[t]||null},Y:function(t,e){cu[t]=e},X:function(t){delete cu[t]}},pi=null,it={G:function(){if(!nr(pi))return pi;if(pi=!0,L(E))pi=!1;else try{var t="__support__";it.Y(t,"xyz"),it.J(t)!=='"xyz"'&&(pi=!1),it.X(t)}catch{pi=!1}return pi},V:function(t){V.error("sessionStorage error: ",t)},J:function(t){try{return E==null?void 0:E.sessionStorage.getItem(t)}catch(e){it.V(e)}return null},K:function(t){try{return JSON.parse(it.J(t))||null}catch{}return null},Y:function(t,e){try{E==null||E.sessionStorage.setItem(t,JSON.stringify(e))}catch(n){it.V(n)}},X:function(t){try{E==null||E.sessionStorage.removeItem(t)}catch(e){it.V(e)}}},sr=function(t){return t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED",t}({});class dR{constructor(e){this._instance=e}get A(){return this._instance.config}get consent(){return this.Z()?sr.DENIED:this.tt}isOptedOut(){return this.A.cookieless_mode==="always"||this.consent===sr.DENIED||this.consent===sr.PENDING&&(this.A.opt_out_capturing_by_default||this.A.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===sr.DENIED}optInOut(e){this.it.Y(this.et,e?1:0,this.A.cookie_expiration,this.A.cross_subdomain_cookie,this.A.secure_cookie)}reset(){this.it.X(this.et,this.A.cross_subdomain_cookie)}get et(){var{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:r}=this._instance.config;return r||(n?n+e:"__ph_opt_in_out_"+e)}get tt(){var e=this.it.J(this.et);return Df(e)?sr.GRANTED:oe(m3,e)?sr.DENIED:sr.PENDING}get it(){if(!this.rt){var e=this.A.opt_out_capturing_persistence_type;this.rt=e==="localStorage"?Ke:Dn;var n=e==="localStorage"?Dn:Ke;n.J(this.et)&&(this.rt.J(this.et)||this.optInOut(Df(n.J(this.et))),n.X(this.et,this.A.cross_subdomain_cookie))}return this.rt}Z(){return!!this.A.respect_dnt&&!!n_([Vt==null?void 0:Vt.doNotTrack,Vt==null?void 0:Vt.msDoNotTrack,X.doNotTrack],e=>Df(e))}}var du=Ge("[Dead Clicks]"),fR=()=>!0,hR=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(l_)),r=t.instance.config.capture_dead_clicks;return wn(r)?r:n};class j_{get lazyLoadedDeadClicksAutocapture(){return this.st}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[l_]:e==null?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.nt(()=>{this.ot()})}nt(e){var n,r;(n=X.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture&&e(),(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?du.error("failed to load script",i):e()})}ot(){var e;if(W){if(!this.st&&(e=X.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=Ne(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.st=X.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.st.start(W),du.info("starting...")}}else du.error("`document` not found. Cannot start.")}stop(){this.st&&(this.st.stop(),this.st=void 0,du.info("stopping..."))}}var Ho=Ge("[ExceptionAutocapture]");class pR{constructor(e){var n,r,i;this.lt=()=>{var s;if(E&&this.isEnabled&&(s=X.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=X.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=X.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=X.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ut&&this.A.capture_unhandled_errors&&(this.ut=o(this.captureException.bind(this))),!this.ht&&this.A.capture_unhandled_rejections&&(this.ht=a(this.captureException.bind(this))),!this.dt&&this.A.capture_console_errors&&(this.dt=l(this.captureException.bind(this)))}catch(u){Ho.error("failed to start",u),this.vt()}}},this._instance=e,this.ct=!((n=this._instance.persistence)==null||!n.props[s_]),this.A=this.ft(),this.gt=new Gy({refillRate:(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,R:Ho}),this.startIfEnabled()}ft(){var e=this._instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Ne(e)?n=z({},n,e):(L(e)?this.ct:e)&&(n=z({},n,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.A.capture_console_errors||this.A.capture_unhandled_errors||this.A.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Ho.info("enabled"),this.nt(this.lt))}nt(e){var n,r;(n=X.__PosthogExtensions__)!=null&&n.errorWrappingFunctions&&e(),(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return Ho.error("failed to load script",i);e()})}vt(){var e,n,r;(e=this.ut)==null||e.call(this),this.ut=void 0,(n=this.ht)==null||n.call(this),this.ht=void 0,(r=this.dt)==null||r.call(this),this.dt=void 0}onRemoteConfig(e){var n=e.autocaptureExceptions;this.ct=!!n||!1,this.A=this.ft(),this._instance.persistence&&this._instance.persistence.register({[s_]:this.ct}),this.startIfEnabled()}captureException(e){var n,r,i=(n=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&n!==void 0?n:"Exception";this.gt.consumeRateLimit(i)?Ho.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}}function z_(t,e,n){try{if(!(e in t))return()=>{};var r=t[e],i=n(r);return tn(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=i,()=>{t[e]=r}}catch{return()=>{}}}class gR{constructor(e){var n;this._instance=e,this._t=(E==null||(n=E.location)==null?void 0:n.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(V.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.yt&&this.yt(),this.yt=void 0,V.info("History API monitoring stopped")}monitorHistoryChanges(){var e,n;if(E&&E.history){var r=this;(e=E.history.pushState)!=null&&e.__posthog_wrapped__||z_(E.history,"pushState",i=>function(s,o,a){i.call(this,s,o,a),r.bt("pushState")}),(n=E.history.replaceState)!=null&&n.__posthog_wrapped__||z_(E.history,"replaceState",i=>function(s,o,a){i.call(this,s,o,a),r.bt("replaceState")}),this.wt()}}bt(e){try{var n,r=E==null||(n=E.location)==null?void 0:n.pathname;if(!r)return;r!==this._t&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._t=r}catch(i){V.error("Error capturing "+e+" pageview",i)}}wt(){if(!this.yt){var e=()=>{this.bt("popstate")};Le(E,"popstate",e),this.yt=()=>{E&&E.removeEventListener("popstate",e)}}}}function fu(t){var e,n;return((e=JSON.stringify(t,(n=[],function(r,i){if(Ne(i)){for(;n.length>0&&n[n.length-1]!==this;)n.pop();return n.includes(i)?"[Circular]":(n.push(i),i)}return i})))==null?void 0:e.length)||0}function ah(t,e){if(e===void 0&&(e=66060288e-1),t.size>=e&&t.data.length>1){var n=Math.floor(t.data.length/2),r=t.data.slice(0,n),i=t.data.slice(n);return[ah({size:fu(r),data:r,sessionId:t.sessionId,windowId:t.windowId}),ah({size:fu(i),data:i,sessionId:t.sessionId,windowId:t.windowId})].flatMap(s=>s)}return[t]}var Nn=(t=>(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))(Nn||{}),bn=(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",t[t.CustomElement=16]="CustomElement",t))(bn||{}),lh="[SessionRecording]",uh="redacted",hu={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:t=>t,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com","bam.nr-data.net"]},vR=["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"],mR=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],yR=["/s/","/e/","/i/"];function H_(t,e,n,r){if(fe(t))return t;var i=(e==null?void 0:e["content-length"])||function(s){return new Blob([s]).size}(t);return je(i)&&(i=parseInt(i)),i>n?lh+" "+r+" body too large to record ("+i+" bytes)":t}function U_(t,e){if(fe(t))return t;var n=t;return hs(n,!1)||(n=lh+" "+e+" body "+uh),be(mR,r=>{var i,s;(i=n)!=null&&i.length&&((s=n)==null?void 0:s.indexOf(r))!==-1&&(n=lh+" "+e+" body "+uh+" as might contain: "+r)}),n}var _R=(t,e)=>{var n,r,i,s={payloadSizeLimitBytes:hu.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...hu.performanceEntryTypeToObserve],payloadHostDenyList:[...e.payloadHostDenyList||[],...hu.payloadHostDenyList]},o=t.session_recording.recordHeaders!==!1&&e.recordHeaders,a=t.session_recording.recordBody!==!1&&e.recordBody,l=t.capture_performance!==!1&&e.recordPerformance,u=(n=s,i=Math.min(1e6,(r=n.payloadSizeLimitBytes)!==null&&r!==void 0?r:1e6),d=>(d!=null&&d.requestBody&&(d.requestBody=H_(d.requestBody,d.requestHeaders,i,"Request")),d!=null&&d.responseBody&&(d.responseBody=H_(d.responseBody,d.responseHeaders,i,"Response")),d)),c=d=>{return u(((g,w)=>{var m,v=ps(g.name),y=w.indexOf("http")===0?(m=ps(w))==null?void 0:m.pathname:w;y==="/"&&(y="");var b=v==null?void 0:v.pathname.replace(y||"","");if(!(v&&b&&yR.some(x=>b.indexOf(x)===0)))return g})((p=(h=d).requestHeaders,fe(p)||be(Object.keys(p??{}),g=>{vR.includes(g.toLowerCase())&&(p[g]=uh)}),h),t.api_host));var h,p},f=tn(t.session_recording.maskNetworkRequestFn);return f&&tn(t.session_recording.maskCapturedNetworkRequestFn)&&V.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),f&&(t.session_recording.maskCapturedNetworkRequestFn=d=>{var h=t.session_recording.maskNetworkRequestFn({url:d.name});return z({},d,{name:h==null?void 0:h.url})}),s.maskRequestFn=tn(t.session_recording.maskCapturedNetworkRequestFn)?d=>{var h,p=c(d);return p&&(h=t.session_recording.maskCapturedNetworkRequestFn==null?void 0:t.session_recording.maskCapturedNetworkRequestFn(p))!==null&&h!==void 0?h:void 0}:d=>function(h){if(!L(h))return h.requestBody=U_(h.requestBody,"Request"),h.responseBody=U_(h.responseBody,"Response"),h}(c(d)),z({},hu,s,{recordHeaders:o,recordBody:a,recordPerformance:l,recordInitialRequests:l})};class wR{constructor(e,n){var r,i;n===void 0&&(n={}),this.St={},this.kt=s=>{if(!this.St[s]){var o,a;this.St[s]=!0;var l=this.$t(s);(o=(a=this.t).onBlockedNode)==null||o.call(a,s,l)}},this.xt=s=>{var o=this.$t(s);if((o==null?void 0:o.nodeName)!=="svg"&&o instanceof Element){var a=o.closest("svg");if(a)return[this._rrweb.mirror.getId(a),a]}return[s,o]},this.$t=s=>this._rrweb.mirror.getNode(s),this.Et=s=>{var o,a,l,u,c,f,d,h;return((o=(a=s.removes)==null?void 0:a.length)!==null&&o!==void 0?o:0)+((l=(u=s.attributes)==null?void 0:u.length)!==null&&l!==void 0?l:0)+((c=(f=s.texts)==null?void 0:f.length)!==null&&c!==void 0?c:0)+((d=(h=s.adds)==null?void 0:h.length)!==null&&d!==void 0?d:0)},this.throttleMutations=s=>{if(s.type!==3||s.data.source!==0)return s;var o=s.data,a=this.Et(o);o.attributes&&(o.attributes=o.attributes.filter(u=>{var[c]=this.xt(u.id);return!this.gt.consumeRateLimit(c)&&u}));var l=this.Et(o);return l!==0||a===l?s:void 0},this._rrweb=e,this.t=n,this.gt=new Gy({bucketSize:(r=this.t.bucketSize)!==null&&r!==void 0?r:100,refillRate:(i=this.t.refillRate)!==null&&i!==void 0?i:10,refillInterval:1e3,$:this.kt,R:V})}}var nn=Uint8Array,Ot=Uint16Array,gs=Uint32Array,ch=new nn([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]),dh=new nn([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]),B_=new nn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),q_=function(t,e){for(var n=new Ot(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new gs(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},V_=q_(ch,2),bR=V_[0],fh=V_[1];bR[28]=258,fh[258]=28;for(var W_=q_(dh,0)[1],G_=new Ot(32768),Te=0;Te<32768;++Te){var gi=(43690&Te)>>>1|(21845&Te)<<1;gi=(61680&(gi=(52428&gi)>>>2|(13107&gi)<<2))>>>4|(3855&gi)<<4,G_[Te]=((65280&gi)>>>8|(255&gi)<<8)>>>1}var Uo=function(t,e,n){for(var r=t.length,i=0,s=new Ot(e);i<r;++i)++s[t[i]-1];var o,a=new Ot(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;for(o=new Ot(r),i=0;i<r;++i)o[i]=G_[a[t[i]-1]++]>>>15-t[i];return o},vi=new nn(288);for(Te=0;Te<144;++Te)vi[Te]=8;for(Te=144;Te<256;++Te)vi[Te]=9;for(Te=256;Te<280;++Te)vi[Te]=7;for(Te=280;Te<288;++Te)vi[Te]=8;var pu=new nn(32);for(Te=0;Te<32;++Te)pu[Te]=5;var xR=Uo(vi,9),kR=Uo(pu,5),K_=function(t){return(t/8>>0)+(7&t&&1)},Y_=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof Ot?Ot:t instanceof gs?gs:nn)(n-e);return r.set(t.subarray(e,n)),r},or=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8},Bo=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8,t[r+2]|=n>>>16},hh=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var i=n.length,s=n.slice();if(!i)return[new nn(0),0];if(i==1){var o=new nn(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort(function(x,k){return x.f-k.f}),n.push({s:-1,f:25001});var a=n[0],l=n[1],u=0,c=1,f=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=n[n[u].f<n[f].f?u++:f++],l=n[u!=c&&n[u].f<n[f].f?u++:f++],n[c++]={s:-1,f:a.f+l.f,l:a,r:l};var d=s[0].s;for(r=1;r<i;++r)s[r].s>d&&(d=s[r].s);var h=new Ot(d+1),p=ph(n[c-1],h,0);if(p>e){r=0;var g=0,w=p-e,m=1<<w;for(s.sort(function(x,k){return h[k.s]-h[x.s]||x.f-k.f});r<i;++r){var v=s[r].s;if(!(h[v]>e))break;g+=m-(1<<p-h[v]),h[v]=e}for(g>>>=w;g>0;){var y=s[r].s;h[y]<e?g-=1<<e-h[y]++-1:++r}for(;r>=0&&g;--r){var b=s[r].s;h[b]==e&&(--h[b],++g)}p=e}return[new nn(h),p]},ph=function(t,e,n){return t.s==-1?Math.max(ph(t.l,e,n+1),ph(t.r,e,n+1)):e[t.s]=n},Q_=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Ot(++e),r=0,i=t[0],s=1,o=function(l){n[r++]=l},a=1;a<=e;++a)if(t[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=t[a]}return[n.subarray(0,r),e]},qo=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},gh=function(t,e,n){var r=n.length,i=K_(e+2);t[i]=255&r,t[i+1]=r>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var s=0;s<r;++s)t[i+s+4]=n[s];return 8*(i+4+r)},X_=function(t,e,n,r,i,s,o,a,l,u,c){or(e,c++,n),++i[256];for(var f=hh(i,15),d=f[0],h=f[1],p=hh(s,15),g=p[0],w=p[1],m=Q_(d),v=m[0],y=m[1],b=Q_(g),x=b[0],k=b[1],$=new Ot(19),C=0;C<v.length;++C)$[31&v[C]]++;for(C=0;C<x.length;++C)$[31&x[C]]++;for(var H=hh($,7),M=H[0],U=H[1],q=19;q>4&&!M[B_[q-1]];--q);var B,K,N,Z,ae=u+5<<3,R=qo(i,vi)+qo(s,pu)+o,A=qo(i,d)+qo(s,g)+o+14+3*q+qo($,M)+(2*$[16]+3*$[17]+7*$[18]);if(ae<=R&&ae<=A)return gh(e,c,t.subarray(l,l+u));if(or(e,c,1+(A<R)),c+=2,A<R){B=Uo(d,h),K=d,N=Uo(g,w),Z=g;var j=Uo(M,U);for(or(e,c,y-257),or(e,c+5,k-1),or(e,c+10,q-4),c+=14,C=0;C<q;++C)or(e,c+3*C,M[B_[C]]);c+=3*q;for(var ne=[v,x],I=0;I<2;++I){var se=ne[I];for(C=0;C<se.length;++C){var ee=31&se[C];or(e,c,j[ee]),c+=M[ee],ee>15&&(or(e,c,se[C]>>>5&127),c+=se[C]>>>12)}}}else B=xR,K=vi,N=kR,Z=pu;for(C=0;C<a;++C)if(r[C]>255){ee=r[C]>>>18&31,Bo(e,c,B[ee+257]),c+=K[ee+257],ee>7&&(or(e,c,r[C]>>>23&31),c+=ch[ee]);var ge=31&r[C];Bo(e,c,N[ge]),c+=Z[ge],ge>3&&(Bo(e,c,r[C]>>>5&8191),c+=dh[ge])}else Bo(e,c,B[r[C]]),c+=K[r[C]];return Bo(e,c,B[256]),c+K[256]},SR=new gs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ER=function(){for(var t=new gs(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t}(),$R=function(){var t=4294967295;return{p:function(e){for(var n=t,r=0;r<e.length;++r)n=ER[255&n^e[r]]^n>>>8;t=n},d:function(){return 4294967295^t}}},CR=function(t,e,n,r,i){return function(s,o,a,l,u,c){var f=s.length,d=new nn(l+f+5*(1+Math.floor(f/7e3))+u),h=d.subarray(l,d.length-u),p=0;if(!o||f<8)for(var g=0;g<=f;g+=65535){var w=g+65535;w<f?p=gh(h,p,s.subarray(g,w)):(h[g]=c,p=gh(h,p,s.subarray(g,f)))}else{for(var m=SR[o-1],v=m>>>13,y=8191&m,b=(1<<a)-1,x=new Ot(32768),k=new Ot(b+1),$=Math.ceil(a/3),C=2*$,H=function(ia){return(s[ia]^s[ia+1]<<$^s[ia+2]<<C)&b},M=new gs(25e3),U=new Ot(288),q=new Ot(32),B=0,K=0,N=(g=0,0),Z=0,ae=0;g<f;++g){var R=H(g),A=32767&g,j=k[R];if(x[A]=j,k[R]=A,Z<=g){var ne=f-g;if((B>7e3||N>24576)&&ne>423){p=X_(s,h,0,M,U,q,K,N,ae,g-ae,p),N=B=K=0,ae=g;for(var I=0;I<286;++I)U[I]=0;for(I=0;I<30;++I)q[I]=0}var se=2,ee=0,ge=y,ie=A-j&32767;if(ne>2&&R==H(g-ie))for(var Se=Math.min(v,ne)-1,ye=Math.min(32767,g),At=Math.min(258,ne);ie<=ye&&--ge&&A!=j;){if(s[g+se]==s[g+se-ie]){for(var sn=0;sn<At&&s[g+sn]==s[g+sn-ie];++sn);if(sn>se){if(se=sn,ee=ie,sn>Se)break;var Oe=Math.min(ie,sn-2),$u=0;for(I=0;I<Oe;++I){var kn=g-ie+I+32768&32767,xs=kn-x[kn]+32768&32767;xs>$u&&($u=xs,j=kn)}}}ie+=(A=j)-(j=x[A])+32768&32767}if(ee){M[N++]=268435456|fh[se]<<18|W_[ee];var S=31&fh[se],It=31&W_[ee];K+=ch[S]+dh[It],++U[257+S],++q[It],Z=g+se,++B}else M[N++]=s[g],++U[s[g]]}}p=X_(s,h,c,M,U,q,K,N,ae,g-ae,p)}return Y_(d,0,l+K_(p)+u)}(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,n,r,!0)},vh=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8},RR=function(t,e){var n=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&&vh(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),n){t[3]=8;for(var r=0;r<=n.length;++r)t[r+10]=n.charCodeAt(r)}},TR=function(t){return 10+(t.filename&&t.filename.length+1||0)};function Z_(t,e){e===void 0&&(e={});var n=$R(),r=t.length;n.p(t);var i=CR(t,e,TR(e),8),s=i.length;return RR(i,e),vh(i,s-8,n.d()),vh(i,s-4,r),i}function J_(t,e){var n=t.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(t);for(var r=new nn(t.length+(t.length>>>1)),i=0,s=function(u){r[i++]=u},o=0;o<n;++o){if(i+5>r.length){var a=new nn(i+8+(n-o<<1));a.set(r),r=a}var l=t.charCodeAt(o);l<128||e?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&t.charCodeAt(++o))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return Y_(r,0,i)}function PR(t,e){return function(n){for(var r=0,i=0;i<n.length;i++)r=(r<<5)-r+n.charCodeAt(i),r|=0;return Math.abs(r)}(t)%100<Wt(100*e,0,100,V)}var Fr="disabled",mh="sampled",gu="active",mi="buffering",yh="paused",_h="trigger",jn=_h+"_activated",ft=_h+"_pending",zn=_h+"_"+Fr;function ew(t,e){return e.some(n=>n.matching==="regex"&&new RegExp(n.url).test(t))}class tw{constructor(e){this.Rt=e}triggerStatus(e){var n=this.Rt.map(r=>r.triggerStatus(e));return n.includes(jn)?jn:n.includes(ft)?ft:zn}stop(){this.Rt.forEach(e=>e.stop())}}class nw{constructor(e){this.Rt=e}triggerStatus(e){var n=new Set;for(var r of this.Rt)n.add(r.triggerStatus(e));switch(n.delete(zn),n.size){case 0:return zn;case 1:return Array.from(n)[0];default:return ft}}stop(){this.Rt.forEach(e=>e.stop())}}class MR{triggerStatus(){return ft}stop(){}}var vu=t=>"sessionRecording"in t;class OR{constructor(e){this.It=[],this.Pt=[],this.urlBlocked=!1,this._instance=e}onConfig(e){var n,r;this.It=(vu(e)?(n=e.sessionRecording)==null?void 0:n.urlTriggers:e==null?void 0:e.urlTriggers)||[],this.Pt=(vu(e)?(r=e.sessionRecording)==null?void 0:r.urlBlocklist:e==null?void 0:e.urlBlocklist)||[]}onRemoteConfig(e){this.onConfig(e)}Tt(e){var n;return this.It.length===0?zn:((n=this._instance)==null?void 0:n.get_property(Vf))===e?jn:ft}triggerStatus(e){var n=this.Tt(e),r=n===jn?jn:n===ft?ft:zn;return this._instance.register_for_session({$sdk_debug_replay_url_trigger_status:r}),r}checkUrlTriggerConditions(e,n,r){if(E!==void 0&&E.location.href){var i=E.location.href,s=this.urlBlocked,o=ew(i,this.Pt);s&&o||(o&&!s?e():!o&&s&&n(),ew(i,this.It)&&r("url"))}}stop(){}}class AR{constructor(e){this.linkedFlag=null,this.linkedFlagSeen=!1,this.Ct=()=>{},this._instance=e}triggerStatus(){var e=ft;return fe(this.linkedFlag)&&(e=zn),this.linkedFlagSeen&&(e=jn),this._instance.register_for_session({$sdk_debug_replay_linked_flag_trigger_status:e}),e}onConfig(e,n){var r;if(this.linkedFlag=(vu(e)?(r=e.sessionRecording)==null?void 0:r.linkedFlag:e==null?void 0:e.linkedFlag)||null,!fe(this.linkedFlag)&&!this.linkedFlagSeen){var i=je(this.linkedFlag)?this.linkedFlag:this.linkedFlag.flag,s=je(this.linkedFlag)?null:this.linkedFlag.variant;this.Ct=this._instance.onFeatureFlags((o,a)=>{var l=!1;if(Ne(a)&&i in a){var u=a[i];l=wn(u)?u===!0:s?u===s:!!u}this.linkedFlagSeen=l,l&&n(i,s)})}}onRemoteConfig(e,n){this.onConfig(e,n)}stop(){this.Ct()}}class IR{constructor(e){this.Mt=[],this._instance=e}onConfig(e){var n;this.Mt=(vu(e)?(n=e.sessionRecording)==null?void 0:n.eventTriggers:e==null?void 0:e.eventTriggers)||[]}onRemoteConfig(e){this.onConfig(e)}Ot(e){var n;return this.Mt.length===0?zn:((n=this._instance)==null?void 0:n.get_property(Wf))===e?jn:ft}triggerStatus(e){var n=this.Ot(e),r=n===jn?jn:n===ft?ft:zn;return this._instance.register_for_session({$sdk_debug_replay_event_trigger_status:r}),r}stop(){}}function FR(t){return t.isRecordingEnabled?mi:Fr}function LR(t){if(!t.receivedFlags)return mi;if(!t.isRecordingEnabled)return Fr;if(t.urlTriggerMatching.urlBlocked)return yh;var e=t.isSampled===!0,n=new tw([t.eventTriggerMatching,t.urlTriggerMatching,t.linkedFlagMatching]).triggerStatus(t.sessionId);return e?mh:n===jn?gu:n===ft?mi:t.isSampled===!1?Fr:gu}function DR(t){if(!t.receivedFlags)return mi;if(!t.isRecordingEnabled)return Fr;if(t.urlTriggerMatching.urlBlocked)return yh;var e=new nw([t.eventTriggerMatching,t.urlTriggerMatching,t.linkedFlagMatching]).triggerStatus(t.sessionId),n=e!==zn,r=wn(t.isSampled);return n&&e===ft?mi:n&&e===zn||r&&!t.isSampled?Fr:t.isSampled===!0?mh:gu}var Vo="[SessionRecording]",et=Ge(Vo);function mu(){var t;return X==null||(t=X.__PosthogExtensions__)==null||(t=t.rrweb)==null?void 0:t.record}var NR=3e5,jR=[bn.MouseMove,bn.MouseInteraction,bn.Scroll,bn.ViewportResize,bn.Input,bn.TouchMove,bn.MediaInteraction,bn.Drag],rw=t=>({rrwebMethod:t,enqueuedAt:Date.now(),attempt:1});function yi(t){return function(e,n){for(var r="",i=0;i<e.length;){var s=e[i++];r+=String.fromCharCode(s)}return r}(Z_(J_(JSON.stringify(t))))}function iw(t){return t.type===Nn.Custom&&t.data.tag==="sessionIdle"}class sw{get sessionId(){return this.Ft}get At(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this.Dt}get jt(){if(!this._instance.sessionManager)throw new Error(Vo+" must be started with a valid sessionManager.");return this._instance.sessionManager}get Lt(){var e,n;return this.Nt.triggerStatus(this.sessionId)===ft?6e4:(e=(n=this._instance.config.session_recording)==null?void 0:n.full_snapshot_interval_millis)!==null&&e!==void 0?e:NR}get Ut(){var e=this._instance.get_property(ds);return wn(e)?e:null}get zt(){var e,n,r=(e=this.H)==null?void 0:e.data[((n=this.H)==null?void 0:n.data.length)-1],{sessionStartTimestamp:i}=this.jt.checkAndGetSessionAndWindowId(!0);return r?r.timestamp-i:null}get Bt(){var e=!!this._instance.get_property(qf),n=!this._instance.config.disable_session_recording;return E&&e&&n}get qt(){var e=!!this._instance.get_property(c_),n=this._instance.config.enable_recording_console_log;return n??e}get Ht(){var e,n,r,i,s,o,a=this._instance.config.session_recording.captureCanvas,l=this._instance.get_property(h_),u=(e=(n=a==null?void 0:a.recordCanvas)!==null&&n!==void 0?n:l==null?void 0:l.enabled)!==null&&e!==void 0&&e,c=(r=(i=a==null?void 0:a.canvasFps)!==null&&i!==void 0?i:l==null?void 0:l.fps)!==null&&r!==void 0?r:4,f=(s=(o=a==null?void 0:a.canvasQuality)!==null&&o!==void 0?o:l==null?void 0:l.quality)!==null&&s!==void 0?s:.4;if(typeof f=="string"){var d=parseFloat(f);f=isNaN(d)?.4:d}return{enabled:u,fps:Wt(c,0,12,et.createLogger("canvas recording fps"),4),quality:Wt(f,0,1,et.createLogger("canvas recording quality"),.4)}}get Wt(){var e,n,r=this._instance.get_property(d_),i={recordHeaders:(e=this._instance.config.session_recording)==null?void 0:e.recordHeaders,recordBody:(n=this._instance.config.session_recording)==null?void 0:n.recordBody},s=(i==null?void 0:i.recordHeaders)||(r==null?void 0:r.recordHeaders),o=(i==null?void 0:i.recordBody)||(r==null?void 0:r.recordBody),a=Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.network_timing:this._instance.config.capture_performance,l=!!(wn(a)?a:r!=null&&r.capturePerformance);return s||o||l?{recordHeaders:s,recordBody:o,recordPerformance:l}:void 0}get Gt(){var e,n,r,i,s,o,a=this._instance.get_property(f_),l={maskAllInputs:(e=this._instance.config.session_recording)==null?void 0:e.maskAllInputs,maskTextSelector:(n=this._instance.config.session_recording)==null?void 0:n.maskTextSelector,blockSelector:(r=this._instance.config.session_recording)==null?void 0:r.blockSelector},u=(i=l==null?void 0:l.maskAllInputs)!==null&&i!==void 0?i:a==null?void 0:a.maskAllInputs,c=(s=l==null?void 0:l.maskTextSelector)!==null&&s!==void 0?s:a==null?void 0:a.maskTextSelector,f=(o=l==null?void 0:l.blockSelector)!==null&&o!==void 0?o:a==null?void 0:a.blockSelector;return L(u)&&L(c)&&L(f)?void 0:{maskAllInputs:u==null||u,maskTextSelector:c,blockSelector:f}}get Vt(){var e=this._instance.get_property(p_);return dt(e)?e:null}get Jt(){var e=this._instance.get_property(g_);return dt(e)?e:null}get status(){return this.Kt?this.Yt({receivedFlags:this.Kt,isRecordingEnabled:this.Bt,isSampled:this.Ut,urlTriggerMatching:this.Xt,eventTriggerMatching:this.Qt,linkedFlagMatching:this.Zt,sessionId:this.sessionId}):mi}constructor(e){if(this.Yt=FR,this.Kt=!1,this.ti=[],this.ii="unknown",this.ei=Date.now(),this.Nt=new MR,this.ri=void 0,this.si=void 0,this.ni=void 0,this.oi=void 0,this.ai=void 0,this._forceAllowLocalhostNetworkCapture=!1,this.li=()=>{this.ui()},this.hi=()=>{this.tryAddCustomEvent("browser offline",{})},this.di=()=>{this.tryAddCustomEvent("browser online",{})},this.vi=()=>{if(W!=null&&W.visibilityState){var i="window "+W.visibilityState;this.tryAddCustomEvent(i,{})}},this._instance=e,this.Dt=!1,this.ci="/s/",this.fi=void 0,this.Kt=!1,!this._instance.sessionManager)throw et.error("started without valid sessionManager"),new Error(Vo+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Vo+' cannot be used with cookieless_mode="always"');this.Zt=new AR(this._instance),this.Xt=new OR(this._instance),this.Qt=new IR(this._instance);var{sessionId:n,windowId:r}=this.jt.checkAndGetSessionAndWindowId();this.Ft=n,this.pi=r,this.H=this.gi(),this.At>=this.jt.sessionTimeoutMs&&et.warn("session_idle_threshold_ms ("+this.At+") is greater than the session timeout ("+this.jt.sessionTimeoutMs+"). Session will never be detected as idle")}startIfEnabledOrStop(e){this.Bt?(this.mi(e),Le(E,"beforeunload",this.li),Le(E,"offline",this.hi),Le(E,"online",this.di),Le(E,"visibilitychange",this.vi),this.yi(),this.bi(),fe(this.ri)&&(this.ri=this._instance.on("eventCaptured",n=>{try{if(n.event==="$pageview"){var r=n!=null&&n.properties.$current_url?this.wi(n==null?void 0:n.properties.$current_url):"";if(!r)return;this.tryAddCustomEvent("$pageview",{href:r})}}catch(i){et.error("Could not add $pageview to rrweb session",i)}})),this.si||(this.si=this.jt.onSessionId((n,r,i)=>{var s,o;i&&(this.tryAddCustomEvent("$session_id_change",{sessionId:n,windowId:r,changeReason:i}),(s=this._instance)==null||(s=s.persistence)==null||s.unregister(Wf),(o=this._instance)==null||(o=o.persistence)==null||o.unregister(Vf))}))):this.stopRecording()}stopRecording(){var e,n,r,i;this.Dt&&this.fi&&(this.fi(),this.fi=void 0,this.Dt=!1,E==null||E.removeEventListener("beforeunload",this.li),E==null||E.removeEventListener("offline",this.hi),E==null||E.removeEventListener("online",this.di),E==null||E.removeEventListener("visibilitychange",this.vi),this.gi(),clearInterval(this.Si),(e=this.ri)==null||e.call(this),this.ri=void 0,(n=this.ai)==null||n.call(this),this.ai=void 0,(r=this.si)==null||r.call(this),this.si=void 0,(i=this.oi)==null||i.call(this),this.oi=void 0,this.Qt.stop(),this.Xt.stop(),this.Zt.stop(),et.info("stopped"))}ki(){var e;(e=this._instance.persistence)==null||e.unregister(ds)}$i(e){var n,r=this.Ft!==e,i=this.Vt;if(dt(i)){var s=this.Ut,o=r||!wn(s),a=o?PR(e,i):s;o&&(a?this.xi(mh):et.warn("Sample rate ("+i+") has determined that this sessionId ("+e+") will not be sent to the server."),this.tryAddCustomEvent("samplingDecisionMade",{sampleRate:i,isSampled:a})),(n=this._instance.persistence)==null||n.register({[ds]:a})}else this.ki()}onRemoteConfig(e){var n,r,i,s;this.tryAddCustomEvent("$remote_config_received",e),this.Ei(e),(n=e.sessionRecording)!=null&&n.endpoint&&(this.ci=(s=e.sessionRecording)==null?void 0:s.endpoint),this.yi(),((r=e.sessionRecording)==null?void 0:r.triggerMatchType)==="any"?(this.Yt=LR,this.Nt=new tw([this.Qt,this.Xt])):(this.Yt=DR,this.Nt=new nw([this.Qt,this.Xt])),this._instance.register_for_session({$sdk_debug_replay_remote_trigger_matching_config:(i=e.sessionRecording)==null?void 0:i.triggerMatchType}),this.Xt.onConfig(e),this.Qt.onConfig(e),this.Zt.onConfig(e,(o,a)=>{this.xi("linked_flag_matched",{flag:o,variant:a})}),this.Kt=!0,this.startIfEnabledOrStop()}yi(){dt(this.Vt)&&fe(this.oi)&&(this.oi=this.jt.onSessionId(e=>{this.$i(e)}))}Ei(e){if(this._instance.persistence){var n,r=this._instance.persistence,i=()=>{var s,o,a,l,u,c,f,d,h,p=(s=e.sessionRecording)==null?void 0:s.sampleRate,g=fe(p)?null:parseFloat(p);fe(g)&&this.ki();var w=(o=e.sessionRecording)==null?void 0:o.minimumDurationMilliseconds;r.register({[qf]:!!e.sessionRecording,[c_]:(a=e.sessionRecording)==null?void 0:a.consoleLogRecordingEnabled,[d_]:z({capturePerformance:e.capturePerformance},(l=e.sessionRecording)==null?void 0:l.networkPayloadCapture),[f_]:(u=e.sessionRecording)==null?void 0:u.masking,[h_]:{enabled:(c=e.sessionRecording)==null?void 0:c.recordCanvas,fps:(f=e.sessionRecording)==null?void 0:f.canvasFps,quality:(d=e.sessionRecording)==null?void 0:d.canvasQuality},[p_]:g,[g_]:L(w)?null:w,[v_]:(h=e.sessionRecording)==null?void 0:h.scriptConfig})};i(),(n=this.ni)==null||n.call(this),this.ni=this.jt.onSessionId(i)}}log(e,n){var r;n===void 0&&(n="log"),(r=this._instance.sessionRecording)==null||r.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:n,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}mi(e){if(!L(Object.assign)&&!L(Array.from)&&!(this.Dt||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())){var n;this.Dt=!0,this.jt.checkAndGetSessionAndWindowId(),mu()?this.Ri():(n=X.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.Ii,r=>{if(r)return et.error("could not load recorder",r);this.Ri()}),et.info("starting"),this.status===gu&&this.xi(e||"recording_initialized")}}get Ii(){var e;return((e=this._instance)==null||(e=e.persistence)==null||(e=e.get_property(v_))==null?void 0:e.script)||"recorder"}Pi(e){var n;return e.type===3&&jR.indexOf((n=e.data)==null?void 0:n.source)!==-1}Ti(e){var n=this.Pi(e);n||this.ii||e.timestamp-this.ei>this.At&&(this.ii=!0,clearInterval(this.Si),this.tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this.ei,threshold:this.At,bufferLength:this.H.data.length,bufferSize:this.H.size}),this.ui());var r=!1;if(n&&(this.ei=e.timestamp,this.ii)){var i=this.ii==="unknown";this.ii=!1,i||(this.tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),r=!0)}if(!this.ii){var{windowId:s,sessionId:o}=this.jt.checkAndGetSessionAndWindowId(!n,e.timestamp),a=this.Ft!==o,l=this.pi!==s;this.pi=s,this.Ft=o,a||l?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):r&&this.Ci()}}Mi(e){try{return e.rrwebMethod(),!0}catch(n){return this.ti.length<10?this.ti.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):et.warn("could not emit queued rrweb event.",n,e),!1}}tryAddCustomEvent(e,n){return this.Mi(rw(()=>mu().addCustomEvent(e,n)))}Oi(){return this.Mi(rw(()=>mu().takeFullSnapshot()))}Ri(){var e,n,r,i,s={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},o=this._instance.config.session_recording;for(var[a,l]of Object.entries(o||{}))a in s&&(a==="maskInputOptions"?s.maskInputOptions=z({password:!0},l):s[a]=l);this.Ht&&this.Ht.enabled&&(s.recordCanvas=!0,s.sampling={canvas:this.Ht.fps},s.dataURLOptions={type:"image/webp",quality:this.Ht.quality}),this.Gt&&(s.maskAllInputs=(n=this.Gt.maskAllInputs)===null||n===void 0||n,s.maskTextSelector=(r=this.Gt.maskTextSelector)!==null&&r!==void 0?r:void 0,s.blockSelector=(i=this.Gt.blockSelector)!==null&&i!==void 0?i:void 0);var u=mu();if(u){this.Fi=(e=this.Fi)!==null&&e!==void 0?e:new wR(u,{refillRate:this._instance.config.session_recording.__mutationThrottlerRefillRate,bucketSize:this._instance.config.session_recording.__mutationThrottlerBucketSize,onBlockedNode:(f,d)=>{var h="Too many mutations on node '"+f+"'. Rate limiting. This could be due to SVG animations or something similar";et.info(h,{node:d}),this.log(Vo+" "+h,"warn")}});var c=this.Ai();this.fi=u(z({emit:f=>{this.onRRwebEmit(f)},plugins:c},s)),this.ei=Date.now(),this.ii=wn(this.ii)?this.ii:"unknown",this.tryAddCustomEvent("$session_options",{sessionRecordingOptions:s,activePlugins:c.map(f=>f==null?void 0:f.name)}),this.tryAddCustomEvent("$posthog_config",{config:this._instance.config})}else et.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}Ci(){if(this.Si&&clearInterval(this.Si),this.ii!==!0){var e=this.Lt;e&&(this.Si=setInterval(()=>{this.Oi()},e))}}Ai(){var e,n,r=[],i=(e=X.__PosthogExtensions__)==null||(e=e.rrwebPlugins)==null?void 0:e.getRecordConsolePlugin;i&&this.qt&&r.push(i());var s=(n=X.__PosthogExtensions__)==null||(n=n.rrwebPlugins)==null?void 0:n.getRecordNetworkPlugin;return this.Wt&&tn(s)&&(!Z3.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?r.push(s(_R(this._instance.config,this.Wt))):et.info("NetworkCapture not started because we are on localhost.")),r}onRRwebEmit(e){var n;if(this.Di(),e&&Ne(e)){if(e.type===Nn.Meta){var r=this.wi(e.data.href);if(this.ji=r,!r)return;e.data.href=r}else this.Li();if(this.Xt.checkUrlTriggerConditions(()=>this.Ni(),()=>this.Ui(),d=>this.zi(d)),!this.Xt.urlBlocked||(i=e).type===Nn.Custom&&i.data.tag==="recording paused"){var i;e.type===Nn.FullSnapshot&&this.Ci(),e.type===Nn.FullSnapshot&&this.Kt&&this.Nt.triggerStatus(this.sessionId)===ft&&this.Bi();var s=this.Fi?this.Fi.throttleMutations(e):e;if(s){var o=function(d){var h=d;if(h&&Ne(h)&&h.type===6&&Ne(h.data)&&h.data.plugin==="rrweb/console@1"){h.data.payload.payload.length>10&&(h.data.payload.payload=h.data.payload.payload.slice(0,10),h.data.payload.payload.push("...[truncated]"));for(var p=[],g=0;g<h.data.payload.payload.length;g++)h.data.payload.payload[g]&&h.data.payload.payload[g].length>2e3?p.push(h.data.payload.payload[g].slice(0,2e3)+"...[truncated]"):p.push(h.data.payload.payload[g]);return h.data.payload.payload=p,d}return d}(s);if(this.Ti(o),this.ii!==!0||iw(o)){if(iw(o)){var a=o.data.payload;if(a){var l=a.lastActivityTimestamp,u=a.threshold;o.timestamp=l+u}}var c=(n=this._instance.config.session_recording.compress_events)===null||n===void 0||n?function(d){try{if(d.type===Nn.FullSnapshot)return z({},d,{data:yi(d.data),cv:"2024-10"});if(d.type===Nn.IncrementalSnapshot&&d.data.source===bn.Mutation)return z({},d,{cv:"2024-10",data:z({},d.data,{texts:yi(d.data.texts),attributes:yi(d.data.attributes),removes:yi(d.data.removes),adds:yi(d.data.adds)})});if(d.type===Nn.IncrementalSnapshot&&d.data.source===bn.StyleSheetRule)return z({},d,{cv:"2024-10",data:z({},d.data,{adds:d.data.adds?yi(d.data.adds):void 0,removes:d.data.removes?yi(d.data.removes):void 0})})}catch(h){et.error("could not compress event - will use uncompressed event",h)}return d}(o):o,f={$snapshot_bytes:fu(c),$snapshot_data:c,$session_id:this.Ft,$window_id:this.pi};this.status!==Fr?this.qi(f):this.gi()}}}}}Li(){if(!this._instance.config.capture_pageview&&E){var e=this.wi(E.location.href);this.ji!==e&&(this.tryAddCustomEvent("$url_changed",{href:e}),this.ji=e)}}Di(){if(this.ti.length){var e=[...this.ti];this.ti=[],e.forEach(n=>{Date.now()-n.enqueuedAt<=2e3&&this.Mi(n)})}}wi(e){var n=this._instance.config.session_recording;if(n.maskNetworkRequestFn){var r,i={url:e};return(r=i=n.maskNetworkRequestFn(i))==null?void 0:r.url}return e}Bi(){if(!this.H||this.H.data.length===0)return this.gi();for(var e=-1,n=this.H.data.length-1;n>=0;n--)if(this.H.data[n].type===Nn.Meta){e=n;break}return e>=0?(this.H.data=this.H.data.slice(e),this.H.size=this.H.data.reduce((r,i)=>r+fu(i),0),this.H):this.gi()}gi(){return this.H={size:0,data:[],sessionId:this.Ft,windowId:this.pi},this.H}ui(){this.Hi&&(clearTimeout(this.Hi),this.Hi=void 0);var e=this.Jt,n=this.zt,r=dt(n)&&n>=0,i=dt(e)&&r&&n<e;return this.status===mi||this.status===yh||this.status===Fr||i?(this.Hi=setTimeout(()=>{this.ui()},2e3),this.H):(this.H.data.length>0&&ah(this.H).forEach(s=>{this.Wi({$snapshot_bytes:s.size,$snapshot_data:s.data,$session_id:s.sessionId,$window_id:s.windowId,$lib:"web",$lib_version:tr.LIB_VERSION})}),this.gi())}qi(e){var n,r=2+(((n=this.H)==null?void 0:n.data.length)||0);!this.ii&&(this.H.size+e.$snapshot_bytes+r>943718.4||this.H.sessionId!==this.Ft)&&(this.H=this.ui()),this.H.size+=e.$snapshot_bytes,this.H.data.push(e.$snapshot_data),this.Hi||this.ii||(this.Hi=setTimeout(()=>{this.ui()},2e3))}Wi(e){this._instance.capture("$snapshot",e,{_url:this._instance.requestRouter.endpointFor("api",this.ci),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}zi(e){var n;this.Nt.triggerStatus(this.sessionId)===ft&&((n=this._instance)==null||(n=n.persistence)==null||n.register({[e==="url"?Vf:Wf]:this.Ft}),this.ui(),this.xi(e+"_trigger_matched"))}Ni(){this.Xt.urlBlocked||(this.Xt.urlBlocked=!0,clearInterval(this.Si),et.info("recording paused due to URL blocker"),this.tryAddCustomEvent("recording paused",{reason:"url blocker"}))}Ui(){this.Xt.urlBlocked&&(this.Xt.urlBlocked=!1,this.Oi(),this.Ci(),this.tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),et.info("recording resumed"))}bi(){this.Qt.Mt.length!==0&&fe(this.ai)&&(this.ai=this._instance.on("eventCaptured",e=>{try{this.Qt.Mt.includes(e.event)&&this.zi("event")}catch(n){et.error("Could not activate event trigger",n)}}))}overrideLinkedFlag(){this.Zt.linkedFlagSeen=!0,this.Oi(),this.xi("linked_flag_overridden")}overrideSampling(){var e;(e=this._instance.persistence)==null||e.register({[ds]:!0}),this.Oi(),this.xi("sampling_overridden")}overrideTrigger(e){this.zi(e)}xi(e,n){this._instance.register_for_session({$session_recording_start_reason:e}),et.info(e.replace("_"," "),n),oe(["recording_initialized","session_id_changed"],e)||this.tryAddCustomEvent(e,n)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this.jt.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this.H.data.length,$sdk_debug_replay_internal_buffer_size:this.H.size,$sdk_debug_current_session_duration:this.zt,$sdk_debug_session_start:e}}}var wh=Ge("[SegmentIntegration]");function zR(t,e){var n=t.config.segment;if(!n)return e();(function(r,i){var s=r.config.segment;if(!s)return i();var o=l=>{var u=()=>l.anonymousId()||Ir();r.config.get_device_id=u,l.id()&&(r.register({distinct_id:l.id(),$device_id:u()}),r.persistence.set_property(rr,"identified")),i()},a=s.user();"then"in a&&tn(a.then)?a.then(l=>o(l)):o(a)})(t,()=>{n.register((r=>{Promise&&Promise.resolve||wh.warn("This browser does not have Promise support, and can not use the segment integration");var i=(s,o)=>{if(!o)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(wh.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(wh.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var a=r.calculateEventProperties(o,s.event.properties);return s.event.properties=Object.assign({},a,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>i(s,s.event.event),page:s=>i(s,"$pageview"),identify:s=>i(s,"$identify"),screen:s=>i(s,"$screen")}})(t)).then(()=>{e()})})}var ow="posthog-js";function aw(t,e){var{organization:n,projectId:r,prefix:i,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,c,f,d;if(!(s==="*"||s.includes(a.level))||!t.__loaded)return a;a.tags||(a.tags={});var h=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=h,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var p=((l=a.exception)==null?void 0:l.values)||[],g=p.map(m=>z({},m,{stacktrace:m.stacktrace?z({},m.stacktrace,{type:"raw",frames:(m.stacktrace.frames||[]).map(v=>z({},v,{platform:"web:javascript"}))}):void 0})),w={$exception_message:((u=p[0])==null?void 0:u.value)||a.message,$exception_type:(c=p[0])==null?void 0:c.type,$exception_personURL:h,$exception_level:a.level,$exception_list:g,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((f=p[0])==null?void 0:f.value)||a.message,$sentry_exception_type:(d=p[0])==null?void 0:d.type,$sentry_tags:a.tags};return n&&r&&(w.$sentry_url=(i||"https://sentry.io/organizations/")+n+"/issues/?project="+r+"&query="+a.event_id),o&&t.exceptions.sendExceptionEvent(w),a}}class HR{constructor(e,n,r,i,s,o){this.name=ow,this.setupOnce=function(a){a(aw(e,{organization:n,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}}var UR=E!=null&&E.location?au(E.location.hash,"__posthog")||au(location.hash,"state"):null,lw="_postHogToolbarParams",uw=Ge("[Toolbar]"),Lr=function(t){return t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t}(Lr||{});class BR{constructor(e){this.instance=e}Gi(e){X.ph_toolbar_state=e}Vi(){var e;return(e=X.ph_toolbar_state)!==null&&e!==void 0?e:Lr.UNINITIALIZED}maybeLoadToolbar(e,n,r){if(e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),!E||!W)return!1;e=e??E.location,r=r??E.history;try{if(!n){try{E.localStorage.setItem("test","test"),E.localStorage.removeItem("test")}catch{return!1}n=E==null?void 0:E.localStorage}var i,s=UR||au(e.hash,"__posthog")||au(e.hash,"state"),o=s?t_(()=>JSON.parse(atob(decodeURIComponent(s))))||t_(()=>JSON.parse(decodeURIComponent(s))):null;return o&&o.action==="ph_authorize"?((i=o).source="url",i&&Object.keys(i).length>0&&(o.desiredHash?e.hash=o.desiredHash:r?r.replaceState(r.state,"",e.pathname+e.search):e.hash="")):((i=JSON.parse(n.getItem(lw)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}Ji(e){var n=X.ph_load_toolbar||X.ph_load_editor;!fe(n)&&tn(n)?n(e,this.instance):uw.warn("No toolbar load function found")}loadToolbar(e){var n=!(W==null||!W.getElementById(m_));if(!E||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=z({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(E.localStorage.setItem(lw,JSON.stringify(z({},i,{source:void 0}))),this.Vi()===Lr.LOADED)this.Ji(i);else if(this.Vi()===Lr.UNINITIALIZED){var s;this.Gi(Lr.LOADING),(s=X.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",o=>{if(o)return uw.error("[Toolbar] Failed to load",o),void this.Gi(Lr.UNINITIALIZED);this.Gi(Lr.LOADED),this.Ji(i)}),Le(E,"turbolinks:load",()=>{this.Gi(Lr.UNINITIALIZED),this.loadToolbar(i)})}return!0}Ki(e){return this.loadToolbar(e)}maybeLoadEditor(e,n,r){return e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,n,r)}}var qR=Ge("[TracingHeaders]");class VR{constructor(e){this.Yi=void 0,this.Xi=void 0,this.lt=()=>{var n,r;L(this.Yi)&&((n=X.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),L(this.Xi)&&((r=X.__PosthogExtensions__)==null||(r=r.tracingHeadersPatchFns)==null||r._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}nt(e){var n,r;(n=X.__PosthogExtensions__)!=null&&n.tracingHeadersPatchFns&&e(),(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return qR.error("failed to load script",i);e()})}startIfEnabledOrStop(){var e,n;this._instance.config.__add_tracing_headers?this.nt(this.lt):((e=this.Yi)==null||e.call(this),(n=this.Xi)==null||n.call(this),this.Yi=void 0,this.Xi=void 0)}}var Dr=Ge("[Web Vitals]"),cw=9e5;class WR{constructor(e){var n;this.Qi=!1,this.C=!1,this.H={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Zi=()=>{clearTimeout(this.te),this.H.metrics.length!==0&&(this._instance.capture("$web_vitals",this.H.metrics.reduce((r,i)=>z({},r,{["$web_vitals_"+i.name+"_event"]:z({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{})),this.H={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ie=r=>{var i,s=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(L(s))Dr.error("Could not read session ID. Dropping metrics!");else{this.H=this.H||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.ee();L(o)||(fe(r==null?void 0:r.name)||fe(r==null?void 0:r.value)?Dr.error("Invalid metric received",r):this.re&&r.value>=this.re?Dr.error("Ignoring metric with value >= "+this.re,r):(this.H.url!==o&&(this.Zi(),this.te=setTimeout(this.Zi,this.flushToCaptureTimeoutMs)),L(this.H.url)&&(this.H.url=o),this.H.firstMetricTimestamp=L(this.H.firstMetricTimestamp)?Date.now():this.H.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.H.metrics.push(z({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.H.metrics.length===this.allowedMetrics.length&&this.Zi()))}},this.lt=()=>{var r,i,s,o,a=X.__PosthogExtensions__;L(a)||L(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&i&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.ie.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.ie.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.ie.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.ie.bind(this)),this.C=!0):Dr.error("web vitals callbacks not loaded - not starting")},this._instance=e,this.Qi=!((n=this._instance.persistence)==null||!n.props[a_]),this.startIfEnabled()}get allowedMetrics(){var e,n,r=Ne(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return L(r)?((n=this._instance.persistence)==null?void 0:n.props[u_])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get re(){var e=Ne(this._instance.config.capture_performance)&&dt(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:cw;return 0<e&&e<=6e4?cw:e}get isEnabled(){var e=Pt==null?void 0:Pt.protocol;if(e!=="http:"&&e!=="https:")return Dr.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:wn(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return wn(n)?n:this.Qi}startIfEnabled(){this.isEnabled&&!this.C&&(Dr.info("enabled, starting..."),this.nt(this.lt))}onRemoteConfig(e){var n=Ne(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Ne(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[a_]:n}),this._instance.persistence.register({[u_]:r})),this.Qi=n,this.startIfEnabled()}nt(e){var n,r;(n=X.__PosthogExtensions__)!=null&&n.postHogWebVitalsCallbacks&&e(),(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"web-vitals",i=>{i?Dr.error("failed to load script",i):e()})}ee(){var e=E?E.location.href:void 0;return e||Dr.error("Could not determine current URL"),e}}var GR=Ge("[Heatmaps]");function dw(t){return Ne(t)&&"clientX"in t&&"clientY"in t&&dt(t.clientX)&&dt(t.clientY)}class KR{constructor(e){var n;this.rageclicks=new I_,this.Qi=!1,this.C=!1,this.se=null,this.instance=e,this.Qi=!((n=this.instance.persistence)==null||!n.props[Hf])}get flushIntervalMilliseconds(){var e=5e3;return Ne(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return L(this.instance.config.capture_heatmaps)?L(this.instance.config.enable_heatmaps)?this.Qi:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.C)return;GR.info("starting..."),this.ne(),this.se=setInterval(this.oe.bind(this),this.flushIntervalMilliseconds)}else{var e,n;clearInterval((e=this.se)!==null&&e!==void 0?e:void 0),(n=this.ae)==null||n.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Hf]:n}),this.Qi=n,this.startIfEnabled()}getAndClearBuffer(){var e=this.H;return this.H=void 0,e}le(e){this.ue(e.originalEvent,"deadclick")}ne(){E&&W&&(Le(E,"beforeunload",this.oe.bind(this)),Le(W,"click",e=>this.ue(e||(E==null?void 0:E.event)),{capture:!0}),Le(W,"mousemove",e=>this.he(e||(E==null?void 0:E.event)),{capture:!0}),this.ae=new j_(this.instance,fR,this.le.bind(this)),this.ae.startIfEnabled(),this.C=!0)}de(e,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=function(a,l,u){for(var c=a;c&&ru(c)&&!Ar(c,"body");){if(c===u)return!1;if(oe(l,E==null?void 0:E.getComputedStyle(c).position))return!0;c=E_(c)}return!1}(k_(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:n}}ue(e,n){var r;if(n===void 0&&(n="click"),!y_(e.target)&&dw(e)){var i=this.de(e,n);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.ve(z({},i,{type:"rageclick"})),this.ve(i)}}he(e){!y_(e.target)&&dw(e)&&(clearTimeout(this.ce),this.ce=setTimeout(()=>{this.ve(this.de(e,"mousemove"))},500))}ve(e){if(E){var n=E.location.href;this.H=this.H||{},this.H[n]||(this.H[n]=[]),this.H[n].push(e)}}oe(){this.H&&!us(this.H)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class YR{constructor(e){this._instance=e}doPageView(e,n){var r,i=this.fe(e,n);return this.pe={pathname:(r=E==null?void 0:E.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.fe(e,(n=this.pe)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.pe)==null?void 0:e.pageViewId}}fe(e,n){var r=this.pe;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:c,maxContentY:f}=s;if(!(L(o)||L(a)||L(l)||L(u)||L(c)||L(f))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),f=Math.ceil(f);var d=o<=1?1:Wt(a/o,0,1,V),h=o<=1?1:Wt(l/o,0,1,V),p=u<=1?1:Wt(c/u,0,1,V),g=u<=1?1:Wt(f/u,0,1,V);i=He(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:f,$prev_pageview_max_content_percentage:g})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}}var QR=function(t){var e,n,r,i,s="";for(e=n=0,r=(t=(t+"").replace(/\r\n/g,`
|
|
60
60
|
`).replace(/\r/g,`
|
|
61
|
-
`)).length,i=0;i<r;i++){var o=t.charCodeAt(i),a=null;o<128?n++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),nr(a)||(n>e&&(s+=t.substring(e,n)),s+=a,e=n=i+1)}return n>e&&(s+=t.substring(e,t.length)),s},XR=!!Af||!!Of,fw="text/plain",yu=(t,e)=>{var[n,r]=t.split("?"),i=z({},e);r==null||r.split("&").forEach(o=>{var[a]=o.split("=");delete i[a]});var s=J3(i);return n+"?"+(s=s?(r?r+"&":"")+s:r)},Wo=(t,e)=>JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r,e),bh=t=>{var{data:e,compression:n}=t;if(e){if(n===ir.GZipJS){var r=Z_(J_(Wo(e)),{mtime:0}),i=new Blob([r],{type:fw});return{contentType:fw,body:i,estimatedSize:i.size}}if(n===ir.Base64){var s=function(l){var u,c,f,d,h,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=0,w=0,m="",v=[];if(!l)return l;l=QR(l);do u=(h=l.charCodeAt(g++)<<16|l.charCodeAt(g++)<<8|l.charCodeAt(g++))>>18&63,c=h>>12&63,f=h>>6&63,d=63&h,v[w++]=p.charAt(u)+p.charAt(c)+p.charAt(f)+p.charAt(d);while(g<l.length);switch(m=v.join(""),l.length%3){case 1:m=m.slice(0,-2)+"==";break;case 2:m=m.slice(0,-1)+"="}return m}(Wo(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Wo(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Wo(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},_u=[];Of&&_u.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:i,estimatedSize:s}=(e=bh(t))!==null&&e!==void 0?e:{},o=new Headers;be(t.headers,function(c,f){o.append(f,c)}),r&&o.append("Content-Type",r);var a=t.url,l=null;if(zy){var u=new zy;l={signal:u.signal,timeout:setTimeout(()=>u.abort(),t.timeout)}}Of(a,z({method:(t==null?void 0:t.method)||"GET",headers:o,keepalive:t.method==="POST"&&(s||0)<52428.8,body:i,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then(c=>c.text().then(f=>{var d={statusCode:c.status,text:f};if(c.status===200)try{d.json=JSON.parse(f)}catch(h){V.error(h)}t.callback==null||t.callback(d)})).catch(c=>{V.error(c),t.callback==null||t.callback({statusCode:0,text:c})}).finally(()=>l?clearTimeout(l.timeout):null)}}),Af&&_u.push({transport:"XHR",method:t=>{var e,n=new Af;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:i}=(e=bh(t))!==null&&e!==void 0?e:{};be(t.headers,function(s,o){n.setRequestHeader(o,s)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var s={statusCode:n.status,text:n.responseText};if(n.status===200)try{s.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(s)}},n.send(i)}}),Vt!=null&&Vt.sendBeacon&&_u.push({transport:"sendBeacon",method:t=>{var e=yu(t.url,{beacon:"1"});try{var n,{contentType:r,body:i}=(n=bh(t))!==null&&n!==void 0?n:{},s=typeof i=="string"?new Blob([i],{type:r}):i;Vt.sendBeacon(e,s)}catch{}}});var vs=function(t,e){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function hw(t,e,n){return Wo({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var pw={exact:(t,e)=>e.some(n=>t.some(r=>n===r)),is_not:(t,e)=>e.every(n=>t.every(r=>n!==r)),regex:(t,e)=>e.some(n=>t.some(r=>vs(n,r))),not_regex:(t,e)=>e.every(n=>t.every(r=>!vs(n,r))),icontains:(t,e)=>e.map(wu).some(n=>t.map(wu).some(r=>n.includes(r))),not_icontains:(t,e)=>e.map(wu).every(n=>t.map(wu).every(r=>!n.includes(r)))},wu=t=>t.toLowerCase(),gw=Ge("[Error tracking]");class ZR{constructor(e){var n,r;this.ge=[],this._e=new R3([new T3,new N3,new M3,new P3,new L3,new F3,new A3,new D3],[k3,$3]),this._instance=e,this.ge=(n=(r=this._instance.persistence)==null?void 0:r.get_property(Uf))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,i,s=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.ge=s,this._instance.persistence&&this._instance.persistence.register({[Uf]:this.ge,[o_]:o})}get me(){var e,n=!!this._instance.get_property(o_),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??n)!==null&&e!==void 0&&e}buildProperties(e,n){return this._e.buildFromUnknown(e,{syntheticException:n==null?void 0:n.syntheticException,mechanism:{handled:n==null?void 0:n.handled}})}sendExceptionEvent(e){if(this.ye(e))gw.info("Skipping exception capture because a suppression rule matched");else{if(this.me||!this.be(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});gw.info("Skipping exception capture because it was thrown by an extension")}}ye(e){var n=e.$exception_list;if(!n||!$e(n)||n.length===0)return!1;var r=n.reduce((i,s)=>{var{type:o,value:a}=s;return je(o)&&o.length>0&&i.$exception_types.push(o),je(a)&&a.length>0&&i.$exception_values.push(a),i},{$exception_types:[],$exception_values:[]});return this.ge.some(i=>{var s=i.values.map(o=>{var a,l=pw[o.operator],u=$e(o.value)?o.value:[o.value],c=(a=r[o.key])!==null&&a!==void 0?a:[];return u.length>0&&l(u,c)});return i.type==="OR"?s.some(Boolean):s.every(Boolean)})}be(e){var n=e.$exception_list;return!(!n||!$e(n))&&n.flatMap(r=>{var i,s;return(i=(s=r.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]}).some(r=>r.filename&&r.filename.startsWith("chrome-extension://"))}}var rn="Mobile",bu="iOS",Hn="Android",Go="Tablet",vw=Hn+" "+Go,mw="iPad",yw="Apple",_w=yw+" Watch",Ko="Safari",ms="BlackBerry",ww="Samsung",bw=ww+"Browser",xw=ww+" Internet",_i="Chrome",JR=_i+" OS",kw=_i+" "+bu,xh="Internet Explorer",Sw=xh+" "+rn,kh="Opera",eT=kh+" Mini",Sh="Edge",Ew="Microsoft "+Sh,ys="Firefox",$w=ys+" "+bu,Yo="Nintendo",Qo="PlayStation",_s="Xbox",Cw=Hn+" "+rn,Rw=rn+" "+Ko,Xo="Windows",Eh=Xo+" Phone",Tw="Nokia",$h="Ouya",Pw="Generic",tT=Pw+" "+rn.toLowerCase(),Mw=Pw+" "+Go.toLowerCase(),Ch="Konqueror",xt="(\\d+(\\.\\d+)?)",Rh=new RegExp("Version/"+xt),nT=new RegExp(_s,"i"),rT=new RegExp(Qo+" \\w+","i"),iT=new RegExp(Yo+" \\w+","i"),Th=new RegExp(ms+"|PlayBook|BB10","i"),sT={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},oT=(t,e)=>e&&oe(e,yw)||function(n){return oe(n,Ko)&&!oe(n,_i)&&!oe(n,Hn)}(t),Ow=function(t,e){return e=e||"",oe(t," OPR/")&&oe(t,"Mini")?eT:oe(t," OPR/")?kh:Th.test(t)?ms:oe(t,"IE"+rn)||oe(t,"WPDesktop")?Sw:oe(t,bw)?xw:oe(t,Sh)||oe(t,"Edg/")?Ew:oe(t,"FBIOS")?"Facebook "+rn:oe(t,"UCWEB")||oe(t,"UCBrowser")?"UC Browser":oe(t,"CriOS")?kw:oe(t,"CrMo")||oe(t,_i)?_i:oe(t,Hn)&&oe(t,Ko)?Cw:oe(t,"FxiOS")?$w:oe(t.toLowerCase(),Ch.toLowerCase())?Ch:oT(t,e)?oe(t,rn)?Rw:Ko:oe(t,ys)?ys:oe(t,"MSIE")||oe(t,"Trident/")?xh:oe(t,"Gecko")?ys:""},aT={[Sw]:[new RegExp("rv:"+xt)],[Ew]:[new RegExp(Sh+"?\\/"+xt)],[_i]:[new RegExp("("+_i+"|CrMo)\\/"+xt)],[kw]:[new RegExp("CriOS\\/"+xt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+xt)],[Ko]:[Rh],[Rw]:[Rh],[kh]:[new RegExp("(Opera|OPR)\\/"+xt)],[ys]:[new RegExp(ys+"\\/"+xt)],[$w]:[new RegExp("FxiOS\\/"+xt)],[Ch]:[new RegExp("Konqueror[:/]?"+xt,"i")],[ms]:[new RegExp(ms+" "+xt),Rh],[Cw]:[new RegExp("android\\s"+xt,"i")],[xw]:[new RegExp(bw+"\\/"+xt)],[xh]:[new RegExp("(rv:|MSIE )"+xt)],Mozilla:[new RegExp("rv:"+xt)]},lT=function(t,e){var n=Ow(t,e),r=aT[n];if(L(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=t.match(s);if(o)return parseFloat(o[o.length-2])}return null},Aw=[[new RegExp(_s+"; "+_s+" (.*?)[);]","i"),t=>[_s,t&&t[1]||""]],[new RegExp(Yo,"i"),[Yo,""]],[new RegExp(Qo,"i"),[Qo,""]],[Th,[ms,""]],[new RegExp(Xo,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Eh,""];if(new RegExp(rn).test(e)&&!/IEMobile\b/.test(e))return[Xo+" "+rn,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],i=sT[r]||"";return/arm/i.test(e)&&(i="RT"),[Xo,i]}return[Xo,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[bu,e.join(".")]}return[bu,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=L(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Hn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Hn+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[Hn,e.join(".")]}return[Hn,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[JR,""]],[/Linux|debian/i,["Linux",""]]],Iw=function(t){return iT.test(t)?Yo:rT.test(t)?Qo:nT.test(t)?_s:new RegExp($h,"i").test(t)?$h:new RegExp("("+Eh+"|WPDesktop)","i").test(t)?Eh:/iPad/.test(t)?mw:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?_w:Th.test(t)?ms:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Tw,"i").test(t)?Tw:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(rn).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Hn:vw:Hn:new RegExp("(pda|"+rn+")","i").test(t)?tT:new RegExp(Go,"i").test(t)&&!new RegExp(Go+" pc","i").test(t)?Mw:""},xu="https?://(.*)",ku=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],uT=Ql(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],ku),Ph="<masked>",cT=["li_fat_id"];function Fw(t,e,n){if(!W)return{};var r,i=e?Ql([],ku,n||[]):[],s=Lw(ih(W.URL,i,Ph),t),o=(r={},be(cT,function(a){var l=Dn.J(a);r[a]=l||null}),r);return He(o,s)}function Lw(t,e){var n=uT.concat(e||[]),r={};return be(n,function(i){var s=ou(t,i);r[i]=s||null}),r}function Dw(t){var e=function(s){return s?s.search(xu+"google.([^/?]*)")===0?"google":s.search(xu+"bing.com")===0?"bing":s.search(xu+"yahoo.com")===0?"yahoo":s.search(xu+"duckduckgo.com")===0?"duckduckgo":null:null}(t),n=e!="yahoo"?"q":"p",r={};if(!nr(e)){r.$search_engine=e;var i=W?ou(W.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function Nw(){return navigator.language||navigator.userLanguage}function jw(){return(W==null?void 0:W.referrer)||"$direct"}function zw(t,e){var n=t?Ql([],ku,e||[]):[],r=Pt==null?void 0:Pt.href.substring(0,1e3);return{r:jw().substring(0,1e3),u:r?ih(r,n,Ph):void 0}}function Hw(t){var e,{r:n,u:r}=t,i={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(e=ps(n))==null?void 0:e.host};if(r){i.$current_url=r;var s=ps(r);i.$host=s==null?void 0:s.host,i.$pathname=s==null?void 0:s.pathname;var o=Lw(r);He(i,o)}if(n){var a=Dw(n);He(i,a)}return i}function Uw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function dT(){try{return new Date().getTimezoneOffset()}catch{return}}function fT(t,e){if(!Mt)return{};var n,r,i,s=t?Ql([],ku,e||[]):[],[o,a]=function(l){for(var u=0;u<Aw.length;u++){var[c,f]=Aw[u],d=c.exec(l),h=d&&(tn(f)?f(d,l):f);if(h)return h}return["",""]}(Mt);return He(zf({$os:o,$os_version:a,$browser:Ow(Mt,navigator.vendor),$device:Iw(Mt),$device_type:(r=Mt,i=Iw(r),i===mw||i===vw||i==="Kobo"||i==="Kindle Fire"||i===Mw?Go:i===Yo||i===_s||i===Qo||i===$h?"Console":i===_w?"Wearable":i?rn:"Desktop"),$timezone:Uw(),$timezone_offset:dT()}),{$current_url:ih(Pt==null?void 0:Pt.href,s,Ph),$host:Pt==null?void 0:Pt.host,$pathname:Pt==null?void 0:Pt.pathname,$raw_user_agent:Mt.length>1e3?Mt.substring(0,997)+"...":Mt,$browser_version:lT(Mt,navigator.vendor),$browser_language:Nw(),$browser_language_prefix:(n=Nw(),typeof n=="string"?n.split("-")[0]:void 0),$screen_height:E==null?void 0:E.screen.height,$screen_width:E==null?void 0:E.screen.width,$viewport_height:E==null?void 0:E.innerHeight,$viewport_width:E==null?void 0:E.innerWidth,$lib:"web",$lib_version:tr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var xn=Ge("[FeatureFlags]"),Mh="$active_feature_flags",ws="$override_feature_flags",Bw="$feature_flag_payloads",Zo="$override_feature_flag_payloads",qw="$feature_flag_request_id",Vw=t=>{var e={};for(var[n,r]of Xl(t||{}))r&&(e[n]=r);return e},hT=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map(n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]})),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(n=>e[n].enabled).filter(n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload}).map(n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]}))):xn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},pT=function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t}({});class gT{constructor(e){this.we=!1,this.Se=!1,this.ke=!1,this.$e=!1,this.xe=!1,this.Ee=!1,this.Re=!1,this._instance=e,this.featureFlagEventHandlers=[]}Ie(){var e=this._instance.config.evaluation_environments;return e!=null&&e.length?e.filter(n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||xn.error("Invalid evaluation environment found:",n,"Expected non-empty string"),r}):[]}Pe(){return this.Ie().length>0}flags(){if(this._instance.config.__preview_remote_config)this.Ee=!0;else{var e=!this.Te&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.Ce({disableFlags:e})}}get hasLoadedFlags(){return this.Se}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Gf),n=this._instance.get_property(ws),r=this._instance.get_property(Zo);if(!r&&!n)return e||{};var i=He({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var o of s){var a,l,u=i[o],c=n==null?void 0:n[o],f=L(c)?(a=u==null?void 0:u.enabled)!==null&&a!==void 0&&a:!!c,d=L(c)?u.variant:typeof c=="string"?c:void 0,h=r==null?void 0:r[o],p=z({},u,{enabled:f,variant:f?d??(u==null?void 0:u.variant):void 0});f!==(u==null?void 0:u.enabled)&&(p.original_enabled=u==null?void 0:u.enabled),d!==(u==null?void 0:u.variant)&&(p.original_variant=u==null?void 0:u.variant),h&&(p.metadata=z({},u==null?void 0:u.metadata,{payload:h,original_payload:u==null||(l=u.metadata)==null?void 0:l.payload})),i[o]=p}return this.we||(xn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.we=!0),i}getFlagVariants(){var e=this._instance.get_property(fs),n=this._instance.get_property(ws);if(!n)return e||{};for(var r=He({},e),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.we||(xn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.we=!0),r}getFlagPayloads(){var e=this._instance.get_property(Bw),n=this._instance.get_property(Zo);if(!n)return e||{};for(var r=He({},e||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.we||(xn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.we=!0),r}reloadFeatureFlags(){this.$e||this._instance.config.advanced_disable_feature_flags||this.Te||(this.Te=setTimeout(()=>{this.Ce()},5))}Me(){clearTimeout(this.Te),this.Te=void 0}ensureFlagsLoaded(){this.Se||this.ke||this.Te||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.$e=e}Ce(e){var n;if(this.Me(),!this._instance.L())if(this.ke)this.xe=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:z({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(No)||{}),group_properties:this._instance.get_property(hi)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Pe()&&(r.evaluation_environments=this.Ie());var i=this._instance.config.__preview_remote_config,s=i?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("api",s+o);i&&(r.timezone=Uw()),this.ke=!0,this._instance.Oe({method:"POST",url:a,data:r,compression:this._instance.config.disable_compression?void 0:ir.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var u,c,f=!0;if(l.statusCode===200&&(this.xe||(this.$anon_distinct_id=void 0),f=!1),this.ke=!1,this.Ee||(this.Ee=!0,this._instance.Fe((c=l.json)!==null&&c!==void 0?c:{})),!r.disable_flags||this.xe)if(this.Re=!f,l.json&&(u=l.json.quotaLimited)!=null&&u.includes(pT.FeatureFlags))xn.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var d;r.disable_flags||this.receivedFeatureFlags((d=l.json)!==null&&d!==void 0?d:{},f),this.xe&&(this.xe=!1,this.Ce())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.Se||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],i=""+r,s=this._instance.get_property(qw)||void 0,o=this._instance.get_property(eu)||{};if((n.send_event||!("send_event"in n))&&(!(e in o)||!o[e].includes(i))){var a,l,u,c,f,d,h,p,g;$e(o[e])?o[e].push(i):o[e]=[i],(a=this._instance.persistence)==null||a.register({[eu]:o});var w=this.getFeatureFlagDetails(e),m={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:((l=this._instance.config.bootstrap)==null||(l=l.featureFlags)==null?void 0:l[e])||null,$feature_flag_bootstrapped_payload:((u=this._instance.config.bootstrap)==null||(u=u.featureFlagPayloads)==null?void 0:u[e])||null,$used_bootstrap_value:!this.Re};L(w==null||(c=w.metadata)==null?void 0:c.version)||(m.$feature_flag_version=w.metadata.version);var v,y=(f=w==null||(d=w.reason)==null?void 0:d.description)!==null&&f!==void 0?f:w==null||(h=w.reason)==null?void 0:h.code;y&&(m.$feature_flag_reason=y),w!=null&&(p=w.metadata)!=null&&p.id&&(m.$feature_flag_id=w.metadata.id),L(w==null?void 0:w.original_variant)&&L(w==null?void 0:w.original_enabled)||(m.$feature_flag_original_response=L(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(g=w.metadata)!=null&&g.original_payload&&(m.$feature_flag_original_payload=w==null||(v=w.metadata)==null?void 0:v.original_payload),this._instance.capture("$feature_flag_called",m)}return r}xn.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.Pe()&&(i.evaluation_environments=this.Ie()),this._instance.Oe({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:ir.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;n((a==null?void 0:a[e])||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.Se||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,n);return L(r)?void 0:!!r}xn.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==e)}receivedFeatureFlags(e,n){if(this._instance.persistence){this.Se=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,u,c){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var f=hT(o),d=f.flags,h=f.featureFlags,p=f.featureFlagPayloads;if(h){var g=o.requestId;if($e(h)){xn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var w={};if(h)for(var m=0;m<h.length;m++)w[h[m]]=!0;a&&a.register({[Mh]:h,[fs]:w})}else{var v=h,y=p,b=d;o.errorsWhileComputingFlags&&(v=z({},l,v),y=z({},u,y),b=z({},c,b)),a&&a.register(z({[Mh]:Object.keys(Vw(v)),[fs]:v||{},[Bw]:y||{},[Gf]:b||{}},g?{[qw]:g}:{}))}}})(e,this._instance.persistence,r,i,s),this.Ae(n)}}override(e,n){n===void 0&&(n=!1),xn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return xn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ws),this._instance.persistence.unregister(Zo),void this.Ae();if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.we=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(ws);else if(r.flags)if($e(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[ws]:i})}else this._instance.persistence.register({[ws]:r.flags})}return"payloads"in r&&(r.payloads===!1?this._instance.persistence.unregister(Zo):r.payloads&&this._instance.persistence.register({[Zo]:r.payloads})),void this.Ae()}this.Ae()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Se){var{flags:n,flagVariants:r}=this.De();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var i,s=(this._instance.get_property(Do)||[]).find(u=>u.flagKey===e),o={["$feature_enrollment/"+e]:n},a={$feature_flag:e,$feature_enrollment:n,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=z({},this.getFlagVariants(),{[e]:n});(i=this._instance.persistence)==null||i.register({[Mh]:Object.keys(Vw(l)),[fs]:l}),this.Ae()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var i=this._instance.get_property(Do),s=r?"&"+r.map(o=>"stage="+o).join("&"):"";if(i&&!n)return e(i);this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var u=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Do),(l=this._instance.persistence)==null||l.register({[Do]:u}),e(u)}}})}De(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,i)=>(r[i]=n[i],r),{})}}Ae(e){var{flags:n,flagVariants:r}=this.De();this.featureFlagEventHandlers.forEach(i=>i(n,r,{errorsLoading:e}))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(No)||{};this._instance.register({[No]:z({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(No)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(hi)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=z({},r[i],e[i]),delete e[i]}),this._instance.register({[hi]:z({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(hi)||{};this._instance.register({[hi]:z({},n,{[e]:{}})})}else this._instance.unregister(hi)}reset(){this.Se=!1,this.ke=!1,this.$e=!1,this.xe=!1,this.Ee=!1,this.Re=!1,this.$anon_distinct_id=void 0,this.Me(),this.we=!1}}var vT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Oh{constructor(e,n){this.A=e,this.props={},this.je=!1,this.Le=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.it=this.Ne(e),this.load(),e.debug&&V.info("Persistence loaded",e.persistence,z({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.Ue}Ne(e){vT.indexOf(e.persistence.toLowerCase())===-1&&(V.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&Ke.G()?Ke:n==="localstorage+cookie"&&uu.G()?uu:n==="sessionstorage"&&it.G()?it:n==="memory"?cR:n==="cookie"?Dn:uu.G()?uu:Dn}properties(){var e={};return be(this.props,function(n,r){if(r===fs&&Ne(n))for(var i=Object.keys(n),s=0;s<i.length;s++)e["$feature/"+i[s]]=n[i[s]];else a=r,l=!1,(nr(o=q3)?l:jy&&o.indexOf===jy?o.indexOf(a)!=-1:(be(o,function(u){if(l||(l=u===a))return Yl}),l))||(e[r]=n);var o,a,l}),e}load(){if(!this.Ue){var e=this.it.K(this.Le);e&&(this.props=He({},e))}}save(){this.Ue||this.it.Y(this.Le,this.props,this.ze,this.Be,this.qe,this.A.debug)}remove(){this.it.X(this.Le,!1),this.it.X(this.Le,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Ne(e)){L(n)&&(n="None"),this.ze=L(r)?this.He:r;var i=!1;if(be(e,(s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=s,i=!0)}),i)return this.save(),!0}return!1}register(e,n){if(Ne(e)){this.ze=L(n)?this.He:n;var r=!1;if(be(e,(i,s)=>{e.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)}),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.je){var e=Fw(this.A.custom_campaign_params,this.A.mask_personal_data_properties,this.A.custom_personal_data_properties);us(zf(e))||this.register(e),this.je=!0}}update_search_keyword(){var e;this.register((e=W==null?void 0:W.referrer)?Dw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:jw(),$referring_domain:W!=null&&W.referrer&&((e=ps(W.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Xf]||this.props[Zf]||this.register_once({[tu]:zw(this.A.mask_personal_data_properties,this.A.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};be([Zf,Xf],o=>{var a=this.props[o];a&&be(a,function(l,u){e["$initial_"+If(u)]=l})});var n,r,i=this.props[tu];if(i){var s=(n=Hw(i),r={},be(n,function(o,a){r["$initial_"+If(a)]=o}),r);He(e,s)}return e}safe_merge(e){return be(this.props,function(n,r){r in e||(e[r]=n)}),e}update_config(e,n,r){if(this.He=this.ze=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence){var i=this.Ne(e),s=this.props;this.clear(),this.it=i,this.props=s,this.save()}}set_disabled(e){this.Ue=e,this.Ue?this.remove():this.save()}set_cross_subdomain(e){e!==this.Be&&(this.Be=e,this.remove(),this.save())}set_secure(e){e!==this.qe&&(this.qe=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Lo]||{};r[e]=n,this.props[Lo]=r,this.save()}remove_event_timer(e){var n=(this.props[Lo]||{})[e];return L(n)||(delete this.props[Lo][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({}),function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t}({});var Ah=function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t}({});(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({}),function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t}({}),function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t}({});var Su=function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t}({}),Ww=function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t}({}),Gw=function(t){return t.Popover="popover",t.Inline="inline",t}({});class Ih{constructor(){this.We={},this.We={}}on(e,n){return this.We[e]||(this.We[e]=[]),this.We[e].push(n),()=>{this.We[e]=this.We[e].filter(r=>r!==n)}}emit(e,n){for(var r of this.We[e]||[])r(n);for(var i of this.We["*"]||[])i(e,n)}}class wi{constructor(e){this.Ge=new Ih,this.Ve=(n,r)=>this.Je(n,r)&&this.Ke(n,r)&&this.Ye(n,r),this.Je=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.Xe=new Set,this.Qe=new Set}init(){var e;if(!L((e=this._instance)==null?void 0:e.Ze)){var n;(n=this._instance)==null||n.Ze((r,i)=>{this.on(r,i)})}}register(e){var n,r;if(!L((n=this._instance)==null?void 0:n.Ze)&&(e.forEach(o=>{var a,l;(a=this.Qe)==null||a.add(o),(l=o.steps)==null||l.forEach(u=>{var c;(c=this.Xe)==null||c.add((u==null?void 0:u.event)||"")})}),(r=this._instance)!=null&&r.autocapture)){var i,s=new Set;e.forEach(o=>{var a;(a=o.steps)==null||a.forEach(l=>{l!=null&&l.selector&&s.add(l==null?void 0:l.selector)})}),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,n){var r;n!=null&&e.length!=0&&(this.Xe.has(e)||this.Xe.has(n==null?void 0:n.event))&&this.Qe&&((r=this.Qe)==null?void 0:r.size)>0&&this.Qe.forEach(i=>{this.tr(n,i)&&this.Ge.emit("actionCaptured",i.name)})}ir(e){this.onAction("actionCaptured",n=>e(n))}tr(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Ve(e,r))return!0;return!1}onAction(e,n){return this.Ge.on(e,n)}Ke(e,n){if(n!=null&&n.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!wi.er(i,n==null?void 0:n.url,(n==null?void 0:n.url_matching)||"contains"))return!1}return!0}static er(e,n,r){switch(r){case"regex":return!!E&&vs(e,n);case"exact":return n===e;case"contains":var i=wi.rr(n).replace(/_/g,".").replace(/%/g,".*");return vs(e,i);default:return!1}}static rr(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Ye(e,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.sr(e).some(s=>!(n!=null&&n.href&&!wi.er(s.href||"",n==null?void 0:n.href,(n==null?void 0:n.href_matching)||"exact"))&&(n==null||!n.tag_name||s.tag_name===(n==null?void 0:n.tag_name))&&!(n!=null&&n.text&&!wi.er(s.text||"",n==null?void 0:n.text,(n==null?void 0:n.text_matching)||"exact")&&!wi.er(s.$el_text||"",n==null?void 0:n.text,(n==null?void 0:n.text_matching)||"exact"))))return!1;if(n!=null&&n.selector){var r,i=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(!i||!i.includes(n==null?void 0:n.selector))return!1}return!0}sr(e){return(e==null?void 0:e.properties.$elements)==null?[]:e==null?void 0:e.properties.$elements}}var xe=Ge("[Surveys]"),Fh="seenSurvey_",mT=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},Kw=t=>{var e=""+Fh+t.id;return t.current_iteration&&t.current_iteration>0&&(e=""+Fh+t.id+"_"+t.current_iteration),e},yT=[Ah.Popover,Ah.Widget,Ah.API],_T={ignoreConditions:!1,ignoreDelay:!1,displayType:Gw.Popover};class wT{constructor(e){this._instance=e,this.nr=new Map,this.ar=new Map}register(e){var n;L((n=this._instance)==null?void 0:n.Ze)||(this.lr(e),this.ur(e))}ur(e){var n=e.filter(r=>{var i,s;return((i=r.conditions)==null?void 0:i.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0});n.length!==0&&(this.hr==null&&(this.hr=new wi(this._instance),this.hr.init(),this.hr.ir(r=>{this.onAction(r)})),n.forEach(r=>{var i,s,o,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.hr)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(u=>{if(u&&u.name){var c=this.ar.get(u.name);c&&c.push(r.id),this.ar.set(u.name,c||[r.id])}}))}))}lr(e){var n;e.filter(r=>{var i,s;return((i=r.conditions)==null?void 0:i.events)&&((s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null?void 0:s.length)>0}).length!==0&&((n=this._instance)==null||n.Ze((r,i)=>{this.onEvent(r,i)}),e.forEach(r=>{var i;(i=r.conditions)==null||(i=i.events)==null||(i=i.values)==null||i.forEach(s=>{if(s&&s.name){var o=this.nr.get(s.name);o&&o.push(r.id),this.nr.set(s.name,o||[r.id])}})}))}onEvent(e,n){var r,i,s=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[Jl])||[];if(Su.SHOWN===e&&n&&s.length>0){var o;xe.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:n,existingActivatedSurveys:s});var a=n==null||(o=n.properties)==null?void 0:o.$survey_id;if(a){var l=s.indexOf(a);l>=0&&(s.splice(l,1),this.dr(s))}}else if(this.nr.has(e)){xe.info("survey event name matched",{event:e,eventPayload:n,surveys:this.nr.get(e)});var u=[];(i=this._instance)==null||i.getSurveys(f=>{u=f.filter(d=>{var h;return(h=this.nr.get(e))==null?void 0:h.includes(d.id)})});var c=u.filter(f=>{var d,h=(d=f.conditions)==null||(d=d.events)==null||(d=d.values)==null?void 0:d.find(p=>p.name===e);return!!h&&(!h.propertyFilters||Object.entries(h.propertyFilters).every(p=>{var g,[w,m]=p,v=n==null||(g=n.properties)==null?void 0:g[w];if(L(v)||nr(v))return!1;var y=[String(v)],b=pw[m.operator];return b?b(m.values,y):(xe.warn("Unknown property comparison operator: "+m.operator),!1)}))});this.dr(s.concat(c.map(f=>f.id)||[]))}}onAction(e){var n,r=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[Jl])||[];this.ar.has(e)&&this.dr(r.concat(this.ar.get(e)||[]))}dr(e){var n;xe.info("updating activated surveys",{activatedSurveys:e}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[Jl]:[...new Set(e)]})}getSurveys(){var e,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[Jl];return n||[]}getEventToSurveys(){return this.nr}vr(){return this.hr}}class bT{constructor(e){this.cr=void 0,this._surveyManager=null,this.pr=!1,this.gr=!1,this._r=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var n=e.surveys;if(fe(n))return xe.warn("Flags not loaded yet. Not loading surveys.");var r=$e(n);this.cr=r?n.length>0:n,xe.info("flags response received, isSurveysEnabled: "+this.cr),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(Fh)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this._surveyManager)if(this.gr)xe.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)xe.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())xe.info("Not loading surveys in cookieless mode without consent.");else{var e=X==null?void 0:X.__PosthogExtensions__;if(e){if(!L(this.cr)||this._instance.config.advanced_enable_surveys){var n=this.cr||this._instance.config.advanced_enable_surveys;this.gr=!0;try{var r=e.generateSurveys;if(r)return void this.mr(r,n);var i=e.loadExternalDependency;if(!i)return void this.yr("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",s=>{s||!e.generateSurveys?this.yr("Could not load surveys script",s):this.mr(e.generateSurveys,n)})}catch(s){throw this.yr("Error initializing surveys",s),s}finally{this.gr=!1}}}else xe.error("PostHog Extensions not found.")}}mr(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new wT(this._instance),xe.info("Surveys loaded successfully"),this.br({isLoaded:!0})}yr(e,n){xe.error(e,n),this.br({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._r.push(e),this._surveyManager&&this.br({isLoaded:!0}),()=>{this._r=this._r.filter(n=>n!==e)}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return xe.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(Kf);if(r&&!n)return e(r,{isLoaded:!0});if(this.pr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.pr=!0,this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var s;this.pr=!1;var o=i.statusCode;if(o!==200||!i.json){var a="Surveys API could not be loaded, status: "+o;return xe.error(a),e([],{isLoaded:!1,error:a})}var l,u=i.json.surveys||[],c=u.filter(f=>function(d){return!(!d.start_date||d.end_date)}(f)&&(function(d){var h;return!((h=d.conditions)==null||(h=h.events)==null||(h=h.values)==null||!h.length)}(f)||function(d){var h;return!((h=d.conditions)==null||(h=h.actions)==null||(h=h.values)==null||!h.length)}(f)));return c.length>0&&((l=this._surveyEventReceiver)==null||l.register(c)),(s=this._instance.persistence)==null||s.register({[Kf]:u}),e(u,{isLoaded:!0})}})}catch(i){throw this.pr=!1,i}}br(e){for(var n of this._r)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){xe.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!fe(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);xe.warn("init was not called")}wr(e){var n=null;return this.getSurveys(r=>{var i;n=(i=r.find(s=>s.id===e))!==null&&i!==void 0?i:null}),n}Sr(e){if(fe(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this.wr(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(fe(this._surveyManager))return xe.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this.Sr(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return fe(this._surveyManager)?(xe.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(r=>{this.getSurveys(i=>{var s,o=(s=i.find(l=>l.id===e))!==null&&s!==void 0?s:null;if(o){var a=this.Sr(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(e,n){var r;if(fe(this._surveyManager))xe.warn("init was not called");else{var i=typeof e=="string"?this.wr(e):e;if(i!=null&&i.id)if(yT.includes(i.type)){var s=W==null?void 0:W.querySelector(n);if(s)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(xe.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var o,a;xe.info("Rendering survey "+i.id+" with delay of "+((o=i.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(i,s),xe.info("Survey "+i.id+" rendered")},1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,s);xe.warn("Survey element not found")}else xe.warn("Surveys of type "+i.type+" cannot be rendered in the app");else xe.warn("Survey not found")}}displaySurvey(e,n){var r;if(fe(this._surveyManager))xe.warn("init was not called");else{var i=this.wr(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(s=z({},i,{appearance:z({},i.appearance,{surveyPopupDelaySeconds:0})})),n.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void xe.warn("Survey is not eligible to be displayed: ",o.disabledReason)}n.displayType!==Gw.Inline?this._surveyManager.handlePopoverSurvey(s):this.renderSurvey(s,n.selector)}else xe.warn("Survey not found")}}}var Yw=Ge("[RateLimiter]");class xT{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(o=>{Yw.info((o||"events")+" is quota limited."),this.serverLimits[o]=new Date().getTime()+6e4})}catch(o){return void Yw.warn('could not rate limit - continuing. Error: "'+(o==null?void 0:o.message)+'"',{text:s})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,i;e===void 0&&(e=!1);var s=new Date().getTime(),o=(n=(r=this.instance.persistence)==null?void 0:r.get_property(Qf))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:s};o.tokens+=(s-o.last)/1e3*this.captureEventsPerSecond,o.last=s,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var a=o.tokens<1;return a||e||(o.tokens=Math.max(0,o.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,(i=this.instance.persistence)==null||i.set_property(Qf,o),{isRateLimited:a,remainingTokens:o.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var bi=Ge("[RemoteConfig]");class kT{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=X._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}kr(e){var n,r;(n=X.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(bi.error("PostHog Extensions not found. Cannot load remote config."),e())}$r(e){this._instance.Oe({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return bi.info("Using preloaded remote config",this.remoteConfig),void this.Fe(this.remoteConfig);if(this._instance.L())return void bi.warn("Remote config is disabled. Falling back to local config.");this.kr(e=>{if(!e)return bi.info("No config found after loading remote JS config. Falling back to JSON."),void this.$r(n=>{this.Fe(n)});this.Fe(e)})}catch(e){bi.error("Error loading remote config",e)}}Fe(e){e?this._instance.config.__preview_remote_config?(this._instance.Fe(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):bi.info("__preview_remote_config is disabled. Logging config instead",e):bi.error("Failed to fetch remote config from PostHog.")}}var Lh=3e3;class ST{constructor(e,n){this.Er=!0,this.Rr=[],this.Ir=Wt((n==null?void 0:n.flush_interval_ms)||Lh,250,5e3,V.createLogger("flush interval"),Lh),this.Pr=e}enqueue(e){this.Rr.push(e),this.Tr||this.Cr()}unload(){this.Mr();var e=this.Rr.length>0?this.Or():{},n=Object.values(e);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Pr(z({},r,{transport:"sendBeacon"}))})}enable(){this.Er=!1,this.Cr()}Cr(){var e=this;this.Er||(this.Tr=setTimeout(()=>{if(this.Mr(),this.Rr.length>0){var n=this.Or(),r=function(){var s=n[i],o=new Date().getTime();s.data&&$e(s.data)&&be(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),e.Pr(s)};for(var i in n)r()}},this.Ir))}Mr(){clearTimeout(this.Tr),this.Tr=void 0}Or(){var e={};return be(this.Rr,n=>{var r,i=n,s=(i?i.batchKey:null)||i.url;L(e[s])&&(e[s]=z({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)}),this.Rr=[],e}}var ET=["retriesPerformedSoFar"];class $T{constructor(e){this.Fr=!1,this.Ar=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.Dr=!0,!L(E)&&"onLine"in E.navigator&&(this.Dr=E.navigator.onLine,Le(E,"online",()=>{this.Dr=!0,this.oe()}),Le(E,"offline",()=>{this.Dr=!1}))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=By(e,ET);dt(n)&&n>0&&(r.url=yu(r.url,{retry_count:n})),this._instance.Oe(z({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(n??0)<10?this.jr(z({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(i)}}))}jr(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)}(n),i=Date.now()+r;this.Rr.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),V.warn(s),this.Fr||(this.Fr=!0,this.Lr())}Lr(){this.Nr&&clearTimeout(this.Nr),this.Nr=setTimeout(()=>{this.Dr&&this.Rr.length>0&&this.oe(),this.Lr()},this.Ar)}oe(){var e=Date.now(),n=[],r=this.Rr.filter(s=>s.retryAt<e||(n.push(s),!1));if(this.Rr=n,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.Nr&&(clearTimeout(this.Nr),this.Nr=void 0),this.Rr))try{this._instance.Oe(z({},e,{transport:"sendBeacon"}))}catch(n){V.error(n)}this.Rr=[]}}class CT{constructor(e){this.Ur=()=>{var n,r,i,s;this.zr||(this.zr={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+((o==null?void 0:o.clientHeight)||0),c=(o==null?void 0:o.scrollHeight)||0;this.zr.lastScrollY=Math.ceil(a),this.zr.maxScrollY=Math.max(a,(n=this.zr.maxScrollY)!==null&&n!==void 0?n:0),this.zr.maxScrollHeight=Math.max(l,(r=this.zr.maxScrollHeight)!==null&&r!==void 0?r:0),this.zr.lastContentY=u,this.zr.maxContentY=Math.max(u,(i=this.zr.maxContentY)!==null&&i!==void 0?i:0),this.zr.maxContentHeight=Math.max(c,(s=this.zr.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.zr}resetContext(){var e=this.zr;return setTimeout(this.Ur,0),e}startMeasuringScrollPosition(){Le(E,"scroll",this.Ur,{capture:!0}),Le(E,"scrollend",this.Ur,{capture:!0}),Le(E,"resize",this.Ur)}scrollElement(){if(!this._instance.config.scroll_root_selector)return E==null?void 0:E.document.documentElement;var e=$e(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=E==null?void 0:E.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return E&&(E.scrollY||E.pageYOffset||E.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return E&&(E.scrollX||E.pageXOffset||E.document.documentElement.scrollLeft)||0}}var RT=t=>zw(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties);class Qw{constructor(e,n,r,i){this.Br=s=>{var o=this.qr();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Hr(this._instance)};this.Wr.register({[Yf]:a})}},this._instance=e,this.Gr=n,this.Wr=r,this.Hr=i||RT,this.Gr.onSessionId(this.Br)}qr(){return this.Wr.props[Yf]}getSetOnceProps(){var e,n=(e=this.qr())==null?void 0:e.props;return n?"r"in n?Hw(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return be(zf(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+If(r)]=n}),e}}var Dh=Ge("[SessionId]");class Xw{on(e,n){return this.Vr.on(e,n)}constructor(e,n,r){var i;if(this.Jr=[],this.Vr=new Ih,this.Kr=(c,f)=>Math.abs(c-f)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.A=e.config,this.Wr=e.persistence,this.pi=void 0,this.Ft=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Yr=n||Ir,this.Xr=r||Ir;var s=this.A.persistence_name||this.A.token,o=this.A.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Wt(o,60,36e3,Dh.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Qr(),this.Zr="ph_"+s+"_window_id",this.ts="ph_"+s+"_primary_window_exists",this.es()){var a=it.K(this.Zr),l=it.K(this.ts);a&&!l?this.pi=a:it.X(this.Zr),it.Y(this.ts,!0)}if((i=this.A.bootstrap)!=null&&i.sessionID)try{var u=(c=>{var f=c.replace(/-/g,"");if(f.length!==32)throw new Error("Not a valid UUID");if(f[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(f.substring(0,12),16)})(this.A.bootstrap.sessionID);this.rs(this.A.bootstrap.sessionID,new Date().getTime(),u)}catch(c){Dh.error("Invalid sessionID in bootstrap",c)}this.ss()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this.Jr)&&(this.Jr=[]),this.Jr.push(e),this.Ft&&e(this.Ft,this.pi),()=>{this.Jr=this.Jr.filter(n=>n!==e)}}es(){return this.A.persistence!=="memory"&&!this.Wr.Ue&&it.G()}ns(e){e!==this.pi&&(this.pi=e,this.es()&&it.Y(this.Zr,e))}os(){return this.pi?this.pi:this.es()?it.K(this.Zr):null}rs(e,n,r){e===this.Ft&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ft=e,this.Wr.register({[Zl]:[n,e,r]}))}ls(){if(this.Ft&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ft,this._sessionStartTimestamp];var e=this.Wr.props[Zl];return $e(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.rs(null,null,null)}ss(){Le(E,"beforeunload",()=>{this.es()&&it.X(this.ts)},{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.A.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[i,s,o]=this.ls(),a=this.os(),l=dt(o)&&o>0&&Math.abs(r-o)>864e5,u=!1,c=!s,f=!e&&this.Kr(r,i);c||f||l?(s=this.Yr(),a=this.Xr(),Dh.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:f,sessionPastMaximumLength:l}}),o=r,u=!0):a||(a=this.Xr(),u=!0);var d=i===0||!e||l?r:i,h=o===0?new Date().getTime():o;return this.ns(a),this.rs(s,d,h),e||this.Qr(),u&&this.Jr.forEach(p=>p(s,a,u?{noSessionId:c,activityTimeout:f,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:a,sessionStartTimestamp:h,changeReason:u?{noSessionId:c,activityTimeout:f,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}Qr(){clearTimeout(this.us),this.us=setTimeout(()=>{var[e]=this.ls();if(this.Kr(new Date().getTime(),e)){var n=this.Ft;this.resetSessionId(),this.Vr.emit("forcedIdleReset",{idleSessionId:n})}},1.1*this.sessionTimeoutMs)}}var TT=["$set_once","$set"],Nr=Ge("[SiteApps]");class PT{constructor(e){this._instance=e,this.hs=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ds(e,n){if(n){var r=this.globalsForEvent(n);this.hs.push(r),this.hs.length>1e3&&(this.hs=this.hs.slice(10))}}get siteAppLoaders(){var e;return(e=X._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ze(this.ds.bind(this));this.vs=()=>{e(),this.hs=[],this.vs=void 0}}}globalsForEvent(e){var n,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var u={},c=this._instance.get_property("$groups")||[],f=this._instance.get_property("$stored_group_properties")||{};for(var[d,h]of Object.entries(f))u[d]={id:c[d],type:d,properties:h};var{$set_once:p,$set:g}=e;return{event:z({},By(e,TT),{properties:z({},e.properties,g?{$set:z({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},g)}:{},p?{$set_once:z({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},p)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var a;!n.errored&&this.hs.length&&(Nr.info("Processing "+this.hs.length+" events for site app with id "+e.id),this.hs.forEach(l=>n.processEvent==null?void 0:n.processEvent(l)),n.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((a=this.vs)==null||a.call(this))},i=!1,s=a=>{n.errored=!a,n.loaded=!0,Nr.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(n.processEvent=o),i=!0}catch(a){Nr.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&n.loaded)try{r()}catch(a){Nr.error("Error while processing buffered events PostHog app with config id "+e.id,a),n.errored=!0}}cs(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}fs(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(i){Nr.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var n,r,i,s=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this.cs(),void this._instance.on("eventCaptured",u=>this.fs(u))):void Nr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.vs)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(u){var c;X["__$$ph_site_app_"+u]=s._instance,(c=X.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(s._instance,l,f=>{if(f)return Nr.error("Error while initializing PostHog app with config id "+u,f)})};for(var{id:a,url:l}of e.siteApps)o(a)}else Nr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var MT=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Zw=function(t,e){if(!t)return!1;var n=t.toLowerCase();return MT.concat(e||[]).some(r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1})},Jw=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&Zw(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>Zw(i==null?void 0:i.brand,e)))return!0}catch{}return!!t.webdriver},Jo=function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t}({}),e1="i.posthog.com";class OT{constructor(e){this.ps={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+e1,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.ps[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.ps[this.apiHost]=Jo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.ps[this.apiHost]=Jo.EU:this.ps[this.apiHost]=Jo.CUSTOM),this.ps[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(this.region===Jo.CUSTOM)return this.apiHost+n;var r=e1+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var AT={icontains:(t,e)=>!!E&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!E&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!E&&vs(e.href,t),not_regex:(t,e)=>!!E&&!vs(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class ht{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(i=>{ht.gs("retrieved web experiments from the server"),n._s=new Map,i.forEach(s=>{if(s.feature_flag_key){var o;n._s&&(ht.gs("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=n._s)==null||o.set(s.feature_flag_key,s));var a=n._instance.getFeatureFlag(s.feature_flag_key);je(a)&&s.variants[a]&&n.ys(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var u=s.variants[l];ht.bs(u)&&n.ys(s.name,l,u.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(e){if(this._is_bot())ht.gs("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(fe(this._s))return this._s=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ht.gs("applying feature flags",e),e.forEach(n=>{var r;if(this._s&&(r=this._s)!=null&&r.has(n)){var i,s=this._instance.getFeatureFlag(n),o=(i=this._s)==null?void 0:i.get(n);s&&o!=null&&o.variants[s]&&this.ys(o.name,s,o.variants[s].transforms)}})}}previewWebExperiment(){var e=ht.getWindowLocation();if(e!=null&&e.search){var n=ou(e==null?void 0:e.search,"__experiment_id"),r=ou(e==null?void 0:e.search,"__experiment_variant");n&&r&&(ht.gs("previewing web experiments "+n+" && "+r),this.getWebExperiments(i=>{this.ws(parseInt(n),r,i)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}ws(e,n,r){var i=r.filter(s=>s.id===e);i&&i.length>0&&(ht.gs("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.ys(i[0].name,n,i[0].variants[n].transforms))}static bs(e){return!fe(e.conditions)&&ht.Ss(e)&&ht.ks(e)}static Ss(e){var n;if(fe(e.conditions)||fe((n=e.conditions)==null?void 0:n.url))return!0;var r,i,s,o=ht.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||AT[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return E==null?void 0:E.location}static ks(e){var n;if(fe(e.conditions)||fe((n=e.conditions)==null?void 0:n.utm))return!0;var r=Fw();if(r.utm_source){var i,s,o,a,l,u,c,f,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,h=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==r.utm_medium,g=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((f=e.conditions)==null||(f=f.utm)==null?void 0:f.utm_term)==r.utm_term;return d&&p&&g&&h}return!1}static gs(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];V.info("[WebExperiments] "+e,r)}ys(e,n,r){this._is_bot()?ht.gs("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach(i=>{if(i.selector){var s;ht.gs("applying transform of variant "+n+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o==null||o.forEach(a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):ht.gs("Control variants leave the page unmodified.")}_is_bot(){return Vt&&this._instance?Jw(Vt,this._instance.config.custom_blocked_useragents):void 0}}var IT=Ge("[PostHog ExternalIntegrations]"),FT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class LT{constructor(e){this._instance=e}nt(e,n){var r;(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,i=>{if(i)return IT.error("failed to load script",i);n()})}startIfEnabledOrStop(){var e=this,n=function(o){var a,l,u;!i||(a=X.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.nt(FT[o],()=>{var c;(c=X.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)}),!i&&(l=X.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=X.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;n(r)}}}var Nh="[SessionRecording]",ea=Ge(Nh);class DT{get started(){var e;return!((e=this.$s)==null||!e.isStarted)}get status(){var e;return((e=this.$s)==null?void 0:e.status)||"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.ni=void 0,this._instance=e,!this._instance.sessionManager)throw ea.error("started without valid sessionManager"),new Error(Nh+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Nh+' cannot be used with cookieless_mode="always"')}get Bt(){var e,n=!((e=this._instance.get_property(Bf))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return E&&n&&r&&!i}startIfEnabledOrStop(e){var n;if(!this.Bt||(n=this.$s)==null||!n.isStarted){var r=!L(Object.assign)&&!L(Array.from);this.Bt&&r?(this.xs(e),ea.info("starting")):this.stopRecording()}}xs(e){var n,r,i;this.Bt&&(X!=null&&(n=X.__PosthogExtensions__)!=null&&(n=n.rrweb)!=null&&n.record&&(r=X.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Ri(e):(i=X.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Ii,s=>{if(s)return ea.error("could not load recorder",s);this.Ri(e)}))}stopRecording(){var e;(e=this.$s)==null||e.stop()}ki(){var e;(e=this._instance.persistence)==null||e.unregister(ds)}Ei(e){if(this._instance.persistence){var n,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording,a=o==null?void 0:o.sampleRate,l=fe(a)?null:parseFloat(a);fe(l)&&this.ki();var u=o==null?void 0:o.minimumDurationMilliseconds;i.register({[Bf]:z({enabled:!!o},o,{networkPayloadCapture:z({capturePerformance:e.capturePerformance},o==null?void 0:o.networkPayloadCapture),canvasRecording:{enabled:o==null?void 0:o.recordCanvas,fps:o==null?void 0:o.canvasFps,quality:o==null?void 0:o.canvasQuality},sampleRate:l,minimumDurationMilliseconds:L(u)?null:u,endpoint:o==null?void 0:o.endpoint,triggerMatchType:o==null?void 0:o.triggerMatchType,masking:o==null?void 0:o.masking,urlTriggers:o==null?void 0:o.urlTriggers})})};s(),(n=this.ni)==null||n.call(this),this.ni=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?(this.Ei(e),this.startIfEnabledOrStop()):ea.info("skipping remote config with no sessionRecording",e)}log(e,n){var r;n===void 0&&(n="log"),(r=this.$s)!=null&&r.log?this.$s.log(e,n):ea.warn("log called before recorder was ready")}get Ii(){var e,n,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Bf);return(r==null||(n=r.scriptConfig)==null?void 0:n.script)||"lazy-recorder"}Ri(e){var n,r;if((n=X.__PosthogExtensions__)==null||!n.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.$s||(this.$s=(r=X.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.$s._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.$s.start(e)}onRRwebEmit(e){var n;(n=this.$s)==null||n.onRRwebEmit==null||n.onRRwebEmit(e)}overrideLinkedFlag(){var e;(e=this.$s)==null||e.overrideLinkedFlag()}overrideSampling(){var e;(e=this.$s)==null||e.overrideSampling()}overrideTrigger(e){var n;(n=this.$s)==null||n.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.$s)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,n){var r;return!((r=this.$s)==null||!r.tryAddCustomEvent(e,n))}}var ta={},jh=()=>{},bs="posthog",t1=!XR&&(Mt==null?void 0:Mt.indexOf("MSIE"))===-1&&(Mt==null?void 0:Mt.indexOf("Mozilla"))===-1,n1=t=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:B3(W==null?void 0:W.location),persistence:"localStorage+cookie",persistence_name:"",loaded:jh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:t!=="2025-05-24"||"history_change",capture_pageleave:"if_capture_pageview",defaults:t??"unset",debug:Pt&&je(Pt==null?void 0:Pt.search)&&Pt.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(E==null||(e=E.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;V.error(r)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Lh},error_tracking:{},_onCapture:jh,__preview_eager_load_replay:!0}},r1=t=>{var e={};L(t.process_person)||(e.person_profiles=t.process_person),L(t.xhr_headers)||(e.request_headers=t.xhr_headers),L(t.cookie_name)||(e.persistence_name=t.cookie_name),L(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),L(t.store_google)||(e.save_campaign_params=t.store_google),L(t.verbose)||(e.debug=t.verbose);var n=He({},e,t);return $e(t.property_blacklist)&&(L(t.property_denylist)?n.property_denylist=t.property_blacklist:$e(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:V.error("Invalid value for property_denylist config: "+t.property_denylist)),n};class NT{constructor(){this.__forceAllowLocalhost=!1}get Es(){return this.__forceAllowLocalhost}set Es(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Eu{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new NT,this.Rs=!1,this.version=tr.LIB_VERSION,this.Is=new Ih,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=n1(),this.SentryIntegration=HR,this.sentryIntegration=e=>function(n,r){var i=aw(n,r);return{name:ow,processEvent:s=>i(s)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ps=!1,this.Ts=null,this.Cs=null,this.Ms=null,this.featureFlags=new gT(this),this.toolbar=new BR(this),this.scrollManager=new CT(this),this.pageViewManager=new YR(this),this.surveys=new bT(this),this.experiments=new ht(this),this.exceptions=new ZR(this),this.rateLimiter=new xT(this),this.requestRouter=new OT(this),this.consent=new dR(this),this.externalIntegrations=new LT(this),this.people={set:(e,n,r)=>{var i=je(e)?{[e]:n}:e;this.setPersonProperties(i),r==null||r({})},set_once:(e,n,r)=>{var i=je(e)?{[e]:n}:e;this.setPersonProperties(void 0,i),r==null||r({})}},this.on("eventCaptured",e=>V.info('send "'+(e==null?void 0:e.event)+'"',e))}init(e,n,r){if(r&&r!==bs){var i,s=(i=ta[r])!==null&&i!==void 0?i:new Eu;return s._init(e,n,r),ta[r]=s,ta[bs][r]=s,s}return this._init(e,n,r)}_init(e,n,r){var i,s;if(n===void 0&&(n={}),L(e)||Ff(e))return V.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return V.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.Os=n,this.Fs=[],n.person_profiles&&(this.Cs=n.person_profiles),this.set_config(He({},n1(n.defaults),r1(n),{name:r,token:e})),this.config.on_xhr_error&&V.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:ir.GZipJS;var o=this.As();this.persistence=new Oh(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Oh(z({},this.config,{persistence:"sessionStorage"}),o);var a=z({},this.persistence.props),l=z({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ds=new ST(y=>this.js(y),this.config.request_queue_config),this.Ls=new $T(this),this.__request_queue=[];var u=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(u||(this.sessionManager=new Xw(this),this.sessionPropsManager=new Qw(this,this.sessionManager,this.persistence)),new VR(this).startIfEnabledOrStop(),this.siteApps=new PT(this),(i=this.siteApps)==null||i.init(),u||(this.config.__preview_eager_load_replay?this.sessionRecording=new sw(this):this.sessionRecording=new DT(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new rR(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new KR(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new WR(this),this.exceptionObserver=new pR(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new j_(this,hR),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new gR(this),this.historyAutocapture.startIfEnabled(),tr.DEBUG=tr.DEBUG||this.config.debug,tr.DEBUG&&V.info("Starting in debug mode",{this:this,config:n,thisC:z({},this.config),p:a,s:l}),((s=n.bootstrap)==null?void 0:s.distinctID)!==void 0){var c,f,d=this.config.get_device_id(Ir()),h=(c=n.bootstrap)!=null&&c.isIdentifiedID?d:n.bootstrap.distinctID;this.persistence.set_property(rr,(f=n.bootstrap)!=null&&f.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:h})}if(this.Ns()){var p,g,w=Object.keys(((p=n.bootstrap)==null?void 0:p.featureFlags)||{}).filter(y=>{var b;return!((b=n.bootstrap)==null||(b=b.featureFlags)==null||!b[y])}).reduce((y,b)=>{var x;return y[b]=((x=n.bootstrap)==null||(x=x.featureFlags)==null?void 0:x[b])||!1,y},{}),m=Object.keys(((g=n.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter(y=>w[y]).reduce((y,b)=>{var x,k;return(x=n.bootstrap)!=null&&(x=x.featureFlagPayloads)!=null&&x[b]&&(y[b]=(k=n.bootstrap)==null||(k=k.featureFlagPayloads)==null?void 0:k[b]),y},{});this.featureFlags.receivedFeatureFlags({featureFlags:w,featureFlagPayloads:m})}if(u)this.register_once({distinct_id:jo,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(Ir());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(rr,"anonymous")}return Le(E,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?zR(this,()=>this.Us()):this.Us(),tn(this.config._onCapture)&&this.config._onCapture!==jh&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",y=>this.config._onCapture(y.event,y))),this.config.ip&&V.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Fe(e){var n,r,i,s,o,a,l,u;if(!W||!W.body)return V.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Fe(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=oe(e.supportedCompression,ir.GZipJS)?ir.GZipJS:oe(e.supportedCompression,ir.Base64)?ir.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Cs?this.Cs:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),(a=this.webVitalsAutocapture)==null||a.onRemoteConfig(e),(l=this.exceptionObserver)==null||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}Us(){try{this.config.loaded(this)}catch(e){V.critical("`loaded` function failed",e)}this.zs(),this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.Bs()},1),new kT(this).load(),this.featureFlags.flags()}zs(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ds)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Or(this.__request_queue,e=>this.js(e)),this.__request_queue=[],this.zs()}_handle_unload(){var e,n;this.config.request_batching?(this.qs()&&this.capture("$pageleave"),(e=this.Ds)==null||e.unload(),(n=this.Ls)==null||n.unload()):this.qs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Oe(e){this.__loaded&&(t1?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=yu(e.url,{ip:this.config.ip?1:0}),e.headers=z({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,i,s,o=z({},n);o.timeout=o.timeout||6e4,o.url=yu(o.url,{_:new Date().getTime().toString(),ver:tr.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=_u.filter(c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport)),u=(i=(s=n_(l,c=>c.transport===a))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!u)throw new Error("No available transport method");u(o)})(z({},e,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,n)),e.callback==null||e.callback(n)}}))))}js(e){this.Ls?this.Ls.retriableRequest(e):this.Oe(e)}_execute_array(e){var n,r=[],i=[],s=[];Or(e,a=>{a&&(n=a[0],$e(n)?s.push(a):tn(a)?a.call(this):$e(a)&&n==="alias"?r.push(a):$e(a)&&n.indexOf("capture")!==-1&&tn(this[n])?s.push(a):i.push(a))});var o=function(a,l){Or(a,function(u){if($e(u[0])){var c=l;be(u,function(f){c=c[f[0]].apply(c,f.slice(1))})}else this[u[0]].apply(this,u.slice(1))},l)};o(r,this),o(i,this),o(s,this)}Ns(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ds){if(this.is_capturing())if(!L(e)&&je(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var s=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){n!=null&&n.$current_url&&!je(n==null?void 0:n.$current_url)&&(V.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(r==null?void 0:r.timestamp)||o,l=Ir(),u={uuid:l,event:e,properties:this.calculateEventProperties(e,n||{},a,l)};s&&(u.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),r!=null&&r.$set&&(u.$set=r==null?void 0:r.$set);var c,f=this.Hs(r==null?void 0:r.$set_once);if(f&&(u.$set_once=f),(u=H3(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,L(r==null?void 0:r.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=o),e===Su.DISMISSED||e===Su.SENT){var d=n==null?void 0:n[Ww.SURVEY_ID],h=n==null?void 0:n[Ww.SURVEY_ITERATION];c={id:d,current_iteration:h},localStorage.getItem(Kw(c))||localStorage.setItem(Kw(c),"true"),u.$set=z({},u.$set,{[mT({id:d,current_iteration:h},e===Su.SENT?"responded":"dismissed")]:!0})}var p=z({},u.properties.$set,u.$set);if(us(p)||this.setPersonPropertiesForFlags(p),!fe(this.config.before_send)){var g=this.Ws(u);if(!g)return;u=g}this.Is.emit("eventCaptured",u);var w={method:"POST",url:(i=r==null?void 0:r._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r==null?void 0:r._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.js(w):this.Ds.enqueue(w),u}V.critical("This capture call is ignored due to client rate limiting.")}}else V.error("No event name provided to posthog.capture")}else V.uninitializedWarning("posthog.capture")}Ze(e){return this.on("eventCaptured",n=>e(n.event,n))}calculateEventProperties(e,n,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=s?void 0:this.persistence.remove_event_timer(e),a=z({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=z({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!je(a.distinct_id)&&!dt(a.distinct_id)||Ff(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=fT(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:f,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=f,a.$window_id=d}this.sessionPropsManager&&He(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&He(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.Ls)==null?void 0:h.length}catch(m){a.$sdk_debug_error_capturing_properties=String(m)}if(this.requestRouter.region===Jo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=He(a,u),e==="$pageview"&&W&&(a.title=W.title),!L(o)){var p=r.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Mt&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=He({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),$e(this.config.property_denylist)?be(this.config.property_denylist,function(m){delete a[m]}):V.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var g=this.config.sanitize_properties;g&&(V.error("sanitize_properties is deprecated. Use before_send instead"),a=g(a,e));var w=this.Gs();return a.$process_person_profile=w,w&&!s&&this.Vs("_calculate_event_properties"),a}Hs(e){var n;if(!this.persistence||!this.Gs()||this.Rs)return e;var r=this.persistence.get_initial_props(),i=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),s=He({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(V.error("sanitize_properties is deprecated. Use before_send instead"),s=o(s,"$set_once")),this.Rs=!0,us(s)?void 0:s}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var i;(i=this.persistence)==null||i.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Js(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.Is.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}displaySurvey(e,n){n===void 0&&(n=_T),this.surveys.displaySurvey(e,n)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return V.uninitializedWarning("posthog.identify");if(dt(e)&&(e=e.toString(),V.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))V.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==jo){if(this.Vs("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==i&&e!==this.get_property(Fo)&&(this.unregister(Fo),this.register({distinct_id:e}));var o=(this.persistence.get_property(rr)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(rr,"identified"),this.setPersonPropertiesForFlags(z({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:r||{}}),this.Ms=hw(e,n,r),this.featureFlags.setAnonymousDistinctId(i)):(n||r)&&this.setPersonProperties(n,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(eu))}}else V.critical('The string "'+jo+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else V.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.Vs("posthog.setPersonProperties")){var r=hw(this.get_distinct_id(),e,n);this.Ms!==r?(this.setPersonPropertiesForFlags(z({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Ms=r):V.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){if(this.Vs("posthog.group")){var i=this.getGroups();i[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:z({},i,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===n||r||this.reloadFeatureFlags()}}else V.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.Vs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,i,s;if(V.info("reset"),!this.__loaded)return V.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(rr,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Ms=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:jo,$device_id:null},"");else{var a=this.config.get_device_id(Ir());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(e,n){return e===this.get_property(r_)?(V.critical("Attempting to create alias for existing People user - aborting."),-2):this.Vs("posthog.alias")?(L(n)&&(n=this.get_distinct_id()),e!==n?(this.Js(Fo,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(V.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=z({},this.config);if(Ne(e)){var r,i,s,o,a;He(this.config,r1(e));var l=this.As();(r=this.persistence)==null||r.update_config(this.config,n,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Oh(z({},this.config,{persistence:"sessionStorage"}),l),Ke.G()&&Ke.J("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(tr.DEBUG=!0,V.info("set_config",{config:e,oldConfig:n,newConfig:z({},this.config)})),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),this.surveys.loadIfEnabled(),this.Ks(),(a=this.externalIntegrations)==null||a.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,s,o,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(z({},i,n))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:bs;return n!==bs&&(n=bs+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(rr))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(rr))==="identified"}Gs(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&us(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Fo])&&((n=this.persistence)==null||(n=n.props)==null||!n[nu]))}qs(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Gs()||this.Vs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Vs(e){return this.config.person_profiles==="never"?(V.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Js(nu,!0),!0)}As(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}Ks(){var e,n,r,i,s=this.As();return((e=this.persistence)==null?void 0:e.Ue)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((n=this.sessionPersistence)==null?void 0:n.Ue)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){if(this.config.cookieless_mode!=="always"){var n;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new Xw(this),this.persistence&&(this.sessionPropsManager=new Qw(this,this.sessionManager,this.persistence)),this.sessionRecording=new sw(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.Ks(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(L(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((n=e==null?void 0:e.captureEventName)!==null&&n!==void 0?n:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bs()}else V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Ks(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:jo,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,this.Bs())):V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===sr.GRANTED?"granted":e===sr.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Ks()}_is_bot(){return Vt?Jw(Vt,this.config.custom_blocked_useragents):void 0}Bs(){W&&(W.visibilityState==="visible"?this.Ps||(this.Ps=!0,this.capture("$pageview",{title:W.title},{send_instantly:!0}),this.Ts&&(W.removeEventListener("visibilitychange",this.Ts),this.Ts=null)):this.Ts||(this.Ts=this.Bs.bind(this),Le(W,"visibilitychange",this.Ts)))}debug(e){e===!1?(E==null||E.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(E==null||E.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}))}L(){var e,n,r,i,s,o,a,l=this.Os||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(V.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,s=V,o=(n="advanced_disable_flags")in(e=l)&&!L(e[n]),a=r in e&&!L(e[r]),o?e[n]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):i)}Ws(e){if(fe(this.config.before_send))return e;var n=$e(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),fe(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return g3(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!us(r.properties)||V.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.pe)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}}(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=z3(t.prototype[e[n]])})(Eu,["identify"]);var i1,zh=(i1=ta[bs]=new Eu,function(){function t(){t.done||(t.done=!0,t1=!1,be(ta,function(e){e._dom_loaded()}))}W!=null&&W.addEventListener?W.readyState==="complete"?t():Le(W,"DOMContentLoaded",t,{capture:!1}):E&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),i1);console.info("Vehicle Search powered by Partbot https://use.partbot.io");function na(t=[],e=[]){const n=[];return t.forEach(r=>{const[i,...s]=r.split(":"),o=s.join(":");if(o.includes(" > ")){const a=o.split(" > "),l=a[a.length-1].trim();if(i!=="make"&&a.length>=2){const u=a[0].trim();n.push(`make = "${u}"`)}n.push(`${i} = "${l}"`)}else n.push(`${i} = "${o}"`)}),e.forEach(r=>{n.push(r)}),n.length>0?n.join(" AND "):null}function Hh({apiKey:t,makes:e="",models:n="",callbackUrl:r="",layout:i="row",fields:s,fieldPrefix:o="",showBranding:a=!0,showLabels:l=!1,mobileFullWidthButton:u=!0,mobileDrawer:c=!0,modifyQueryString:f=!0,onChange:d,buttonLabel:h="Search",showButton:p=!0,onSubmit:g,store:w,useStoreVehicles:m=!0,fieldOrder:v="MMY",enableFeatureFlags:y=!1,yearOptional:b=!1,mobileButtonLabel:x="Select Vehicle"}){const k=_.useRef(null),$=_.useRef(null),C=_.useRef(null),H=_.useRef(null),M=_.useRef(null),U=_.useRef(null),q=_.useRef(null),B=_.useRef(null),K=_.useRef(!1),N=v==="YMM",[Z,ae]=_.useState([]),[R,A]=_.useState([]),[j,ne]=_.useState([]),[I,se]=_.useState([]),[ee,ge]=_.useState([]),[ie,Se]=_.useState([]),[ye,At]=_.useState([]),[sn,Oe]=_.useState([]),$u=_.useRef([]),[kn,xs]=_.useState([]),[S,It]=_.useState({make:null,model:null,year:null,body:null,series:null,variant:null,engine:null,engine_capacity:null}),[ia,Uh]=_.useState(!1),o1=_.useRef(["body","series","variant","engine","engine_capacity"]),Cu=_.useRef(s&&s.length&&o1.current?s.split(",").filter(T=>{var F;return(F=o1.current)==null?void 0:F.includes(T)}):null),[Sn,BT]=_.useState(!1);_.useEffect(()=>{const T=navigator.userAgent;BT(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(T)),zh.__loaded||zh.init("phc_mLZkVvweXDfwCPYS7kSCxoAxgQUkw8fgyDiplKnleGw",{api_host:"https://app.posthog.com",autocapture:!1,capture_pageview:!1,capture_pageleave:!1,disable_session_recording:!1})},[]);const[xi,qT]=_.useState({}),[uP,VT]=_.useState(""),a1=_.useCallback(async()=>{if(!t)return;const F=`${y?"https://api.cartbot.io":"https://api.partbot.io"}/v1/vehicles/auth`;try{const Q=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,referrerPolicy:"no-referrer"},body:JSON.stringify((()=>{const ve={use_store_vehicles:m};return w&&(ve.store=w),ve})())});if(!Q.ok)throw new Error(`Error: ${Q.status} ${Q.statusText}`);const{merchant:D,vehicle_makes:te,vehicle_models:J,meilisearch_search_key:pe,meilisearch_index_name:ke,algolia_search_key:qe,algolia_index_name:ks,store_index_name:ki,store_popular_makes:_e,store_popular_models:Ye}=await Q.json();$.current=D,C.current=(te||[]).map(ve=>({...ve,refinement:ve.value})),H.current=Array.isArray(J)?J.map(ve=>ve&&ve.value?String(ve.value).trim():"").filter(Boolean):[],M.current=Array.isArray(_e)?_e.map(ve=>String(ve).trim().toUpperCase()):null,console.log("[VehicleSearch] PostHog popular makes:",M.current),U.current=Ye||null,console.log("[VehicleSearch] PostHog popular models:",U.current),qT({searchKey:"f0be4e6a192a51ad360e4f5886be389d34334bb930bb32e5cd6d32ceddba17ff",indexName:"otto_v1_vehicles_production",storeIndexName:ki||"shopify_partbot-app-test_development"})}catch(Q){console.error("[VehicleSearch] Auth failed:",Q),VT(Q)}},[t,w,m,y]);_.useEffect(()=>{a1()},[a1]),_.useEffect(()=>{if(xi.searchKey){try{q.current=new H2({host:"https://search.partbot.io",apiKey:xi.searchKey}),B.current=q.current.index(xi.indexName)}catch(T){console.error("[VehicleSearch] Failed to initialize Meilisearch:",T)}return()=>{q.current=null}}},[xi.searchKey,t]);const[on,WT]=_.useState(!1),l1=_.useCallback(()=>{function T(J){if(!J)return"rgba(0,0,0,1)";var pe=F(),ke=window.getComputedStyle(J).backgroundColor;return ke!==pe?ke:J.parentElement?T(J.parentElement):"rgba(255,255,255,1)"}function F(){var J=document.createElement("div");document.head.appendChild(J);var pe=window.getComputedStyle(J).backgroundColor;return document.head.removeChild(J),pe}const Q=document.querySelector("vehicle-search");let D;Q?D=T(Q):D=T(k.current);const te=Y(D).isDark();WT(te)},[]);_.useEffect(()=>{async function T(){if(!S.make||!B.current)return;let F=[],Q=[];S.make&&F.push(`make:${S.make.refinement}`),S.model&&F.push(`model:${S.make.refinement} > ${S.model.refinement}`),S.year&&(Q=[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]),S.body&&F.push(`body:${S.make.refinement} > ${S.model.refinement} > ${S.body.refinement}`),S.series&&F.push(`series:${S.series.refinement}`),S.engine&&F.push(`engine:${S.engine.refinement}`),S.engine_capacity&&F.push(`engine_capacity:${S.engine_capacity.refinement}`);let te=(await B.current.search("",{filter:na(F,Q),attributesToRetrieve:["otto_id"],limit:500})).hits.map(ke=>ke.otto_id);xs(te);let pe={...Object.fromEntries(Object.entries(S||{}).map(([ke,qe])=>[ke,qe&&qe.value||null]).filter(([ke,qe])=>qe!==null)),merchant:$.current};zh.capture("vehicle select",pe)}T()},[S,B,b]);const Bh=T=>o?`${o}${T}`:T,GT=T=>o?T.replace(new RegExp(`^${o}`),""):T,KT=_.useCallback(()=>{const T=new URL(window.location.href).searchParams,F=["make","model","year","body","series","engine","engine_capacity"].map(Bh),Q=Object.fromEntries([...T.entries()].filter(([D])=>F.includes(D)).map(([D,te])=>[GT(D),{value:te,refinement:te}]));It(Q)},[]),pt=_.useCallback(({query:T,value:F,remove:Q})=>{if(f&&"URLSearchParams"in window){let D=new URLSearchParams(window.location.search);T=Bh(T),T&&F&&D.set(T,F),T&&!F&&D.delete(T),Q&&Q.forEach(J=>{J=Bh(J),D.delete(J)});const te=window.location.pathname+"?"+D.toString();window.history.pushState(null,"",te)}},[]),YT=_.useCallback(()=>{var Q;const T={vehicle_ids:kn,vehicle:(Q=S==null?void 0:S.make)!=null&&Q.value?S:{}};g&&g(T);const F=new CustomEvent("vehicle-search-submit",{detail:T});document.dispatchEvent(F),setTimeout(()=>{Uh(!1)},900)},[kn,g]),u1=_.useCallback(()=>{var Q,D,te,J,pe,ke,qe,ks,ki;const T={vehicle_ids:kn,vehicle:(Q=S==null?void 0:S.make)!=null&&Q.value?S:{}};d&&d(T);const F=new CustomEvent("vehicle-search-change",{detail:T});if(K.current===!0&&!localStorage.getItem("partbot_plate_details")){const _e=JSON.stringify({description:`${((D=S.make)==null?void 0:D.value)||""} ${((te=S.model)==null?void 0:te.value)||""} ${((J=S.year)==null?void 0:J.value)||""} ${((pe=S.body)==null?void 0:pe.value)||""} ${((ke=S.series)==null?void 0:ke.value)||""} ${((qe=S.variant)==null?void 0:qe.value)||""} ${((ks=S.engine)==null?void 0:ks.value)||""} ${((ki=S.engine_capacity)==null?void 0:ki.value)||""}`.trim(),vehicle_ids:kn,vehicle:S?Object.entries(S).reduce((Ye,[ve,jr])=>(Ye[ve]=jr!=null&&jr.value?jr.value:{},Ye),{}):{}});localStorage.setItem("partbot_selected_vehicle",_e),Vx.set("partbot_selected_vehicle",_e,{secure:!0})}document.dispatchEvent(F),$u.current=kn,setTimeout(()=>{Uh(!1)},900)},[kn,d]),Ru=_.useMemo(()=>HC(u1,100),[u1]);_.useEffect(()=>{Ru()},[kn,Ru]),_.useEffect(()=>()=>{Ru.cancel()},[Ru]),_.useEffect(()=>{xi.searchKey&&(N||tP(),KT())},[xi.searchKey,N]),_.useEffect(()=>{N&&B.current&&j.length===0&&!S.year&&(console.log("[VehicleSearch] YMM mode: Loading year range from dataset..."),B.current.search("",{attributesToRetrieve:["year_from","year_to"],limit:1e4}).then(({hits:T})=>{console.log("[VehicleSearch] YMM mode: Fetched",T.length,"hits for year range");const F=T.map(pe=>pe.year_from).filter(Boolean),Q=T.map(pe=>pe.year_to).filter(Boolean),D=Math.min(...F),te=Math.max(...Q);console.log("[VehicleSearch] YMM mode: Year range:",D,"-",te);const J=Array.from({length:te-D+1},(pe,ke)=>({value:D+ke,refinement:D+ke})).reverse();console.log("[VehicleSearch] YMM mode: Setting",J.length,"years"),ne(J)}).catch(T=>{console.error("[VehicleSearch] Error loading year range:",T)}))},[N,xi.searchKey,j.length,S.year]),_.useEffect(()=>{typeof document>"u"||l1()},[l1]);const c1=_.useCallback(T=>{K.current=!0,A([]),!N&&!b&&ne([]),se([]),ge([]),Se([]),Oe([]),At([]),It(F=>({make:T,year:N||b?F.year:null})),pt({query:"make",value:(T==null?void 0:T.value)??"",remove:N?["model","body","series","engine","variant","engine_capacity"]:b?["model","body","series","engine","variant","engine_capacity"]:["model","year","body","series","engine","variant","engine_capacity"]}),T||xs([])},[pt,N,b]),d1=_.useCallback(T=>{K.current=!0,It(F=>({...F,model:T!==""?T:null,year:N||b?F.year:null,body:null,series:null,variant:null,engine:null,engine_capacity:null})),!N&&!b&&ne([]),se([]),ge([]),Se([]),Oe([]),At([]),pt({query:"model",value:(T==null?void 0:T.value)??"",remove:N?["body","series","engine","variant","engine_capacity"]:b?["body","series","engine","variant","engine_capacity"]:["year","body","series","engine","variant","engine_capacity"]})},[pt,N,b]),f1=_.useCallback(T=>{K.current=!0,N?(ae([]),A([]),It({year:T!==""?T:null}),(!T||T==="")&&ne([])):It(b?F=>({...F,year:T!==""?T:null}):F=>({...F,year:T!==""?T:null,body:null,series:null,variant:null,engine:null,engine_capacity:null})),b||(se([]),ge([]),Se([]),Oe([]),At([])),pt({query:"year",value:(T==null?void 0:T.value)??"",remove:N?["make","model","body","series","variant","engine","engine_capacity"]:b?[]:["body","series","variant","engine","engine_capacity"]}),!b&&(!T||T==="")&&xs([])},[pt,N,b]),QT=_.useCallback(T=>{K.current=!0,It(F=>({...F,body:T!==""?T:null})),pt({query:"body",value:(T==null?void 0:T.value)??""})},[pt]),XT=_.useCallback(T=>{K.current=!0,It(F=>({...F,series:T!==""?T:null})),pt({query:"series",value:(T==null?void 0:T.value)??""})},[pt]),ZT=_.useCallback(T=>{K.current=!0,It(F=>({...F,variant:T!==""?T:null})),pt({query:"variant",value:(T==null?void 0:T.value)??""})},[pt]),JT=_.useCallback(T=>{K.current=!0,It(F=>({...F,engine:T!==""?T:null})),pt({query:"engine",value:(T==null?void 0:T.value)??""})},[pt]),eP=_.useCallback(T=>{K.current=!0,It(F=>({...F,engine_capacity:T!==""?T:null})),pt({query:"engine_capacity",value:(T==null?void 0:T.value)??""})},[pt]);_.useEffect(()=>{N&&S.year&&B.current&&(async()=>{try{const F=await B.current.search("",{filter:`year_from <= ${S.year.value} AND year_to >= ${S.year.value}`,attributesToRetrieve:["make","make_popularity"],limit:1e4}),Q=new Map;F.hits.forEach(J=>{J.make&&!Q.has(J.make)&&Q.set(J.make,{value:J.make.toUpperCase(),refinement:J.make.toUpperCase(),popularity:J.make_popularity||0})});let D=Array.from(Q.values());const te=new Set(M.current||[]);te.size>0?D.sort((J,pe)=>{const ke=te.has(J.value),qe=te.has(pe.value);return ke&&!qe?-1:!ke&&qe?1:ke&&qe?M.current.indexOf(J.value)-M.current.indexOf(pe.value):J.value.localeCompare(pe.value)}):D.sort((J,pe)=>pe.popularity===J.popularity?J.value.localeCompare(pe.value):pe.popularity-J.popularity),ae(D)}catch(F){console.error("[VehicleSearch] Error loading makes for year:",F)}})()},[N,S.year]);const tP=_.useCallback(()=>{(async()=>{let F=[];if(C.current&&C.current.length)F=C.current;else if(B.current)try{const Q=await B.current.search("",{attributesToRetrieve:["make","make_popularity"],limit:1e3}),D=new Map;Q.hits.forEach(te=>{te.make&&!D.has(te.make)&&D.set(te.make,{value:te.make.toUpperCase(),refinement:te.make.toUpperCase(),popularity:te.make_popularity||0})}),F=Array.from(D.values())}catch(Q){console.error("[VehicleSearch] Error loading makes:",Q)}if(e&&F.length){const Q=e.trim().split(",").map(D=>D.trim().toUpperCase());F=F.filter(D=>Q.includes(D.value))}if(M.current&&M.current.length>0){const Q=new Set(M.current);F.sort((D,te)=>{const J=Q.has(D.value),pe=Q.has(te.value);return J&&!pe?-1:!J&&pe?1:J&&pe?M.current.indexOf(D.value)-M.current.indexOf(te.value):D.value.localeCompare(te.value)})}else F.sort((Q,D)=>Q.popularity===D.popularity?Q.value.localeCompare(D.value):D.popularity-Q.popularity);ae(F)})()},[e]);_.useEffect(()=>{if(B.current&&S.make&&S.make.refinement&&t){let T=[`make:${S.make.refinement}`],F=[];N&&S.year&&(F=[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]);const Q=na(T,F);console.log("[VehicleSearch] Fetching models with filter:",Q),B.current.search("",{filter:Q,attributesToRetrieve:["model","model_popularity","otto_id"],limit:1e3}).then(({hits:D})=>{var ks,ki;console.log("[VehicleSearch] Models search returned hits:",D.length);const te=Array.isArray(H.current)?H.current:typeof H.current=="string"&&H.current.length?H.current.split(",").map(_e=>_e.trim()).filter(Boolean):[];let J=te;if(n){const _e=n.trim().split(",").map(ve=>ve.trim()).filter(Boolean),Ye=new Set(_e.map(ve=>ve.toLowerCase()));J=te.length?te.filter(ve=>Ye.has(String(ve).toLowerCase())):_e,D=D.filter(ve=>Ye.has(ve.model.match(/[^>]*$/)[0].trim().toLowerCase()))}if(J&&J.length>0){const _e=new Set(J.map(ve=>String(ve).toLowerCase()));D.some(ve=>_e.has(ve.model.match(/[^>]*$/)[0].trim().toLowerCase()))&&(D=D.filter(ve=>_e.has(ve.model.match(/[^>]*$/)[0].trim().toLowerCase())))}let pe=new Set;D=D.filter(_e=>_e.model&&_e.model!==""&&!pe.has(_e.model)&&_e.model.match(/[^>]*$/)[0].trim()!==""?(pe.add(_e.model),!0):!1),D=D.map(_e=>({value:_e.model.match(/[^>]*$/)[0].trim(),refinement:_e.model.match(/[^>]*$/)[0].trim(),popularity:_e.model_popularity}));const ke=(ks=S.make)==null?void 0:ks.refinement,qe=(ki=U.current)==null?void 0:ki[ke];if(qe&&Array.isArray(qe)&&qe.length>0){const _e=new Set(qe.map(Ye=>String(Ye).trim().toUpperCase()));D.sort((Ye,ve)=>{const jr=_e.has(Ye.value),Vh=_e.has(ve.value);if(jr&&!Vh)return-1;if(!jr&&Vh)return 1;if(jr&&Vh){const h1=qe.map(rP=>String(rP).trim().toUpperCase());return h1.indexOf(Ye.value)-h1.indexOf(ve.value)}return Ye.value.localeCompare(ve.value)})}else D.sort((_e,Ye)=>_e.popularity===Ye.popularity?_e.value.localeCompare(Ye.value):Ye.popularity-_e.popularity);A(D)}).catch(D=>{console.error("[VehicleSearch] Error loading models:",D),A([])})}else A([])},[S.make,n,t,N,S.year]),_.useEffect(()=>{if(B.current&&S.make&&S.model){console.log("[VehicleSearch] Fetching year range for:",S.make.refinement,">",S.model.refinement);let T=[`model:${S.make.refinement} > ${S.model.refinement}`];b&&(S.body&&T.push(`body:${S.make.refinement} > ${S.model.refinement} > ${S.body.refinement}`),S.series&&T.push(`series:${S.series.refinement}`),S.engine&&T.push(`engine:${S.engine.refinement}`),S.engine_capacity&&T.push(`engine_capacity:${S.engine_capacity.refinement}`)),B.current.search("",{filter:na(T,[]),attributesToRetrieve:["year_from","year_to","otto_id"],limit:200}).then(({hits:F})=>{console.log("[VehicleSearch] Year search returned hits:",F.length);const Q=F.map(ke=>ke.year_from),D=Math.min(...Q),te=F.map(ke=>ke.year_to),J=Math.max(...te);let pe=Array.apply(null,{length:J+1-D}).map(function(ke,qe){return qe+D});pe=pe.reverse().map(ke=>({value:ke,refinement:ke})),ne(pe)}).catch(F=>{console.error("[VehicleSearch] Error fetching years:",F)})}},[S.model,S.make,N,b,S.body,S.series,S.engine,S.engine_capacity]),_.useEffect(()=>{const T=b?S.make&&S.model:S.year&&S.make&&S.model;if(B.current&&T){const F=S.year?[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]:[];B.current.search("",{filter:na([`model:${S.make.refinement} > ${S.model.refinement}`],F),attributesToRetrieve:["body","otto_id"],limit:1e3}).then(({hits:Q})=>{Q=[...new Map(Q.map(D=>[D.body,D])).values()].map(D=>({value:D.body.match(/[^>]*$/)[0].trim(),refinement:D.body.match(/[^>]*$/)[0].trim()})).filter(D=>D.value),se(Q)})}},[S.year,S.make,S.model,b]);const sa=_.useCallback(({hits:T,attribute:F,stateCallback:Q})=>{let D=[...new Map(T.map(te=>[te[F],te])).values()].map(te=>({value:te[F].match(/[^|]*$/)[0].trim(),refinement:te[F].match(/[^|]*$/)[0].trim()})).filter(te=>te.refinement);Q(D)},[]),nP=_.useCallback(()=>{const T=Cu.current?Cu.current.length+3:3,F=p?T+1:T;return`vs:lg:grid-cols-${F>8?8:F}`},[p]);_.useEffect(()=>{const T=b?S.make&&S.model:S.make&&S.model&&S.year;if(B.current&&T){let F=[`make:${S.make.refinement}`,`model:${S.make.refinement} > ${S.model.refinement}`,S.body?`body:${S.make.refinement} > ${S.model.refinement} > ${S.body.refinement}`:"",S.series?`series:${S.series.refinement}`:"",S.variant?`variant:${S.variant.refinement}`:"",S.engine?`engine:${S.engine.refinement}`:"",S.engine_capacity?`engine_capacity:${S.engine_capacity.refinement}`:""].filter(D=>D);const Q=S.year?[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]:[];B.current.search("",{filter:na(F,Q),attributesToRetrieve:["series","engine_capacity","engine","cylinders","variant","otto_id"],limit:1e3}).then(({hits:D})=>{sa({hits:D,attribute:"series",stateCallback:ge}),sa({hits:D,attribute:"variant",stateCallback:Se}),sa({hits:D,attribute:"engine",stateCallback:At}),sa({hits:D,attribute:"engine_capacity",stateCallback:Oe})})}},[S.body,S.series,S.variant,S.engine,S.engine_capacity,sa,S.make,S.model,S.year,b]);const[Tu,qh]=_.useState(!1);return _.useEffect(()=>{if(c)return Tu?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}},[Tu,c]),O.jsxs(O.Fragment,{children:[c&&O.jsx("button",{onClick:()=>qh(!0),type:"button",className:Rr("vehicle-search-btn vs:md:hidden!",u?"vs:w-full! vs:flex! vs:shrink-0!":"vs:w-auto! vs:inline-flex! vs:shrink!"),children:O.jsx("span",{children:x})}),c&&O.jsx("div",{onClick:()=>qh(!1),className:Rr("vs:z-10 vs:fixed vs:inset-0 vs:bg-stone-900 vs:transition-all vs:duration-300",Tu?"vs:opacity-75":"vs:pointer-events-none vs:opacity-0")}),O.jsxs("div",{className:Rr("partbot-mmyvs-container",c&&Tu&&"active","w-full"),children:[c&&O.jsxs("div",{className:"vs:flex vs:justify-between vs:items-center vs:pb-4 vs:font-bold vs:text-white vs:md:hidden",children:[O.jsx("span",{children:"Select Vehicle"}),O.jsxs("button",{onClick:()=>qh(!1),type:"button",className:"vs:appearance-none vs:bg-transparent vs:border-none vs:ring-none vs:outline-none vs:hover:border-none vs:hover:ring-none vs:hover:outline-none",children:[O.jsx("span",{className:"vs:sr-only",children:"Close vehicle selection"}),O.jsx("span",{className:"vs:h-5 vs:w-5 vs:text-white",children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 256 256",className:"vs:h-5 vs:w-5",children:O.jsx("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"})})})]})]}),O.jsxs("div",{ref:k,className:Rr("vs:grid vs:gap-3",i==="row"?`${nP()} vs:grid-cols-1 vs:md:grid-cols-3`:"vs:grid-cols-1 vs:md:max-w-[400px] vs:md:gap-5","vs:w-full vs:transition vs:lg:mx-auto"),children:[N?O.jsxs(O.Fragment,{children:[O.jsx(mn,{label:"Year",items:j,refine:f1,selected:S.year,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:j.length===0}),O.jsx(mn,{label:"Make",items:Z,refine:c1,selected:S.make,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.year&&Z.length===0}),O.jsx(mn,{label:"Model",items:R,refine:d1,selected:S.model,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.make&&R.length===0})]}):O.jsxs(O.Fragment,{children:[O.jsx(mn,{label:"Make",items:Z,refine:c1,selected:S.make,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:Z.length===0}),O.jsx(mn,{label:"Model",items:R,refine:d1,selected:S.model,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.make&&R.length===0}),O.jsx(mn,{label:"Year",items:j,refine:f1,selected:S.year,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.model&&j.length===0})]}),Cu.current&&Cu.current.map(T=>{let F=null;switch(T){case"body":F=O.jsx(mn,{label:"Body",items:I,refine:QT,selected:S.body,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"body");break;case"series":F=O.jsx(mn,{label:"Series",items:ee,refine:XT,selected:S.series,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"series");break;case"variant":F=O.jsx(mn,{label:"Variant",items:ie,refine:ZT,selected:S.variant,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"variant");break;case"engine_capacity":F=O.jsx(mn,{label:"Engine Capacity",items:sn,refine:eP,selected:S.engine_capacity,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"engine_capacity");break;case"engine":F=O.jsx(mn,{label:"Engine",items:ye,refine:JT,selected:S.engine,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"engine");break}return F}),p&&O.jsx("div",{className:"vs:flex vs:h-full vs:flex-col vs:justify-end vs:md:col-span-3 vs:lg:col-span-1",children:O.jsxs("button",{className:"vehicle-search-btn",onClick:()=>{Uh(!0),r&&!g?window.location.href=r+window.location.search:YT()},children:[O.jsx("span",{children:h}),ia&&O.jsx(Rf,{className:"vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin"})]})})]}),a&&O.jsx("div",{className:Rr("vs:flex vs:w-full vs:justify-center vs:items-center",i==="row"?"vs:md:items-end vs:md:justify-end":"vs:md:justify-center","vs:mt-4 vs:md:mt-3 vs:md:pr-1.5"),children:O.jsxs("a",{href:`https://use.partbot.io/?ref=${typeof window<"u"?window.location.href.split("/")[2]:"unknown"}&utm_source=vehicle-select&utm_medium=referral&utm_campaign=powered-by`,target:"_blank",rel:"noreferrer",className:`${on?"vs:text-white":"vs:text-black"} vs:flex vs:items-center vs:space-x-1.5 vs:px-1.5 vs:text-center vs:leading-normal vs:text-[10px] vs:opacity-75 vs:transition vs:hover:opacity-100 vs:font-sans vs:no-underline vs:m-0 pb-1.5`,children:[O.jsx("span",{children:"Powered by"}),O.jsx(Wx,{className:"vs:inline-flex vs:h-[13px]"})]})})]})]})}let s1=!1,ra=!1;function jT(t){var c,f;const e=t.shadowRoot;if(!e){console.error("[ShadowDOMPatch] No shadow root found");return}const n=e.children[1];if(!n){console.error("[ShadowDOMPatch] No mount point found in shadow root");return}if(new MutationObserver(d=>{d.forEach(h=>{h.addedNodes.forEach(p=>{p.nodeType===1&&p.id==="headlessui-portal-root"&&(n.appendChild(p),ra=!0)})}),d.forEach(h=>{h.removedNodes.forEach(p=>{p.nodeType===1&&p.id==="headlessui-portal-root"&&(n.querySelector("#headlessui-portal-root")||(ra=!1))})})}).observe(document.body,{childList:!0}),new MutationObserver(d=>{d.forEach(h=>{h.removedNodes.forEach(p=>{p.nodeType===1&&p.id==="headlessui-portal-root"&&(ra=!1)})})}).observe(n,{childList:!0,subtree:!0}),s1)return;const s=(c=Object.getOwnPropertyDescriptor(Document.prototype,"activeElement"))==null?void 0:c.get;Object.defineProperty(Document.prototype,"activeElement",{get:function(){const d=s==null?void 0:s.call(this);return d===t?e.activeElement:d}});const o=(f=Object.getOwnPropertyDescriptor(Event.prototype,"target"))==null?void 0:f.get;Object.defineProperty(Event.prototype,"target",{get:function(){const d=o==null?void 0:o.call(this);return d===t?this.composedPath()[0]:d}});const a=d=>{try{return document.body&&d===document.body.style}catch{return!1}},l=CSSStyleDeclaration.prototype.setProperty;CSSStyleDeclaration.prototype.setProperty=function(d,h,p){if(!(a(this)&&d==="overflow"&&h==="hidden"&&ra))return l.call(this,d,h,p)};const u=Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype,"overflow");u&&Object.defineProperty(CSSStyleDeclaration.prototype,"overflow",{get:function(){return u.get.call(this)},set:function(d){if(!(a(this)&&d==="hidden"&&ra))return u.set.call(this,d)}}),s1=!0}const zT="/css/vehicle-search.css";class HT extends HTMLElement{connectedCallback(){if(!document.getElementById("vehicle-search-inter-font")){const U=document.createElement("link");U.id="vehicle-search-inter-font",U.rel="stylesheet",U.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap",document.head.appendChild(U)}let e=document.createElement("style");e.textContent=Bx;const n=document.createElement("div"),r=this.attachShadow({mode:"open"}),i=(U,q,B)=>{let K;if(this.hasAttribute(q)){const N=this.getAttribute(q);if(/^#[0-9A-F]{6}$/i.test(N)){const Z=parseInt(N.slice(1,3),16),ae=parseInt(N.slice(3,5),16),R=parseInt(N.slice(5,7),16);K=`${Z} ${ae} ${R}`}}return K=K||B,`:host { --${U}: ${K}; } .partbot-mmyvs-container { --${U}: ${K}; }`};let s=i("partbot-theme","data-button-color","0 0 0"),o=i("partbot-button-color","data-button-color","0 0 0"),a=i("partbot-button-hover-color","data-button-hover-color","0 0 0"),l=i("partbot-button-label-color","data-button-label-color","255 255 255"),u=i("partbot-button-hover-label-color","data-button-hover-label-color","255 255 255"),c=i("partbot-mobile-background-color","data-mobile-background-color","0 0 0"),f=`:host { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius")||"0.375rem"}; } .partbot-mmyvs-container { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius")||"0.375rem"}; }`,d=`:host { --partbot-font-size: ${this.getAttribute("data-font-size")||"0.875rem"}; } .partbot-mmyvs-container { --partbot-font-size: ${this.getAttribute("data-font-size")||"0.875rem"}; }`,h=`:host { --partbot-font-family: ${(this.getAttribute("data-font-family")||this.getAttribute("data-font"))&&(this.getAttribute("data-font-family")||this.getAttribute("data-font")).trim()!==""?this.getAttribute("data-font-family")||this.getAttribute("data-font"):'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}; } .partbot-mmyvs-container { --partbot-font-family: ${(this.getAttribute("data-font-family")||this.getAttribute("data-font"))&&(this.getAttribute("data-font-family")||this.getAttribute("data-font")).trim()!==""?this.getAttribute("data-font-family")||this.getAttribute("data-font"):'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}; }`,p=`:host { --partbot-padding: ${this.getAttribute("data-padding")||"0.5rem"}; } .partbot-mmyvs-container { --partbot-padding: ${this.getAttribute("data-padding")||"0.5rem"}; }`;const g=this.getAttribute("data-input-shadow"),w=g==="none"?"none":g||"0 1px 2px 0 rgb(0 0 0 / 0.05)";let m=`:host { --partbot-input-shadow: ${w}; } .partbot-mmyvs-container { --partbot-input-shadow: ${w}; }`;const v=this.getAttribute("data-input-border-color");let y="229 231 235";if(v)if(/^#[0-9A-F]{6}$/i.test(v)){const U=parseInt(v.slice(1,3),16),q=parseInt(v.slice(3,5),16),B=parseInt(v.slice(5,7),16);y=`${U} ${q} ${B}`}else/^\d+\s+\d+\s+\d+$/.test(v)&&(y=v);let b=`:host { --partbot-input-border-color: ${y}; } .partbot-mmyvs-container { --partbot-input-border-color: ${y}; }`;const x=this.getAttribute("data-input-border-width")||"1px";let k=`:host { --partbot-input-border-width: ${x}; } .partbot-mmyvs-container { --partbot-input-border-width: ${x}; }`;e.textContent+=s,e.textContent+=o,e.textContent+=a,e.textContent+=l,e.textContent+=u,e.textContent+=c,e.textContent+=f,e.textContent+=d,e.textContent+=h,e.textContent+=p,e.textContent+=m,e.textContent+=b,e.textContent+=k,r.appendChild(e),r.appendChild(n);const $=this.getAttribute("data-api-key");if(!$){console.warn("Missing attributes: "+($?"":"data-api-key "));return}const C=this.attributes,H={};for(let U=0;U<C.length;U++){const{name:q,value:B}=C[U];if(q.startsWith("data-")){const K=q.slice(5).replace(/-([a-z])/g,N=>N[1].toUpperCase());H[K]=B==="true"?!0:B==="false"?!1:B}}jT(this);const M=O.jsx(Hh,{...H});Ux.render(M,n)}}customElements.define("vehicle-search",HT);const UT=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));kt.VehicleSearch=Hh,kt.default=Hh,kt.vehicleSearchCssUrl=zT,Object.defineProperties(kt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
61
|
+
`)).length,i=0;i<r;i++){var o=t.charCodeAt(i),a=null;o<128?n++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),nr(a)||(n>e&&(s+=t.substring(e,n)),s+=a,e=n=i+1)}return n>e&&(s+=t.substring(e,t.length)),s},XR=!!Af||!!Of,fw="text/plain",yu=(t,e)=>{var[n,r]=t.split("?"),i=z({},e);r==null||r.split("&").forEach(o=>{var[a]=o.split("=");delete i[a]});var s=J3(i);return n+"?"+(s=s?(r?r+"&":"")+s:r)},Wo=(t,e)=>JSON.stringify(t,(n,r)=>typeof r=="bigint"?r.toString():r,e),bh=t=>{var{data:e,compression:n}=t;if(e){if(n===ir.GZipJS){var r=Z_(J_(Wo(e)),{mtime:0}),i=new Blob([r],{type:fw});return{contentType:fw,body:i,estimatedSize:i.size}}if(n===ir.Base64){var s=function(l){var u,c,f,d,h,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g=0,w=0,m="",v=[];if(!l)return l;l=QR(l);do u=(h=l.charCodeAt(g++)<<16|l.charCodeAt(g++)<<8|l.charCodeAt(g++))>>18&63,c=h>>12&63,f=h>>6&63,d=63&h,v[w++]=p.charAt(u)+p.charAt(c)+p.charAt(f)+p.charAt(d);while(g<l.length);switch(m=v.join(""),l.length%3){case 1:m=m.slice(0,-2)+"==";break;case 2:m=m.slice(0,-1)+"="}return m}(Wo(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Wo(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Wo(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},_u=[];Of&&_u.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:i,estimatedSize:s}=(e=bh(t))!==null&&e!==void 0?e:{},o=new Headers;be(t.headers,function(c,f){o.append(f,c)}),r&&o.append("Content-Type",r);var a=t.url,l=null;if(zy){var u=new zy;l={signal:u.signal,timeout:setTimeout(()=>u.abort(),t.timeout)}}Of(a,z({method:(t==null?void 0:t.method)||"GET",headers:o,keepalive:t.method==="POST"&&(s||0)<52428.8,body:i,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then(c=>c.text().then(f=>{var d={statusCode:c.status,text:f};if(c.status===200)try{d.json=JSON.parse(f)}catch(h){V.error(h)}t.callback==null||t.callback(d)})).catch(c=>{V.error(c),t.callback==null||t.callback({statusCode:0,text:c})}).finally(()=>l?clearTimeout(l.timeout):null)}}),Af&&_u.push({transport:"XHR",method:t=>{var e,n=new Af;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:i}=(e=bh(t))!==null&&e!==void 0?e:{};be(t.headers,function(s,o){n.setRequestHeader(o,s)}),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var s={statusCode:n.status,text:n.responseText};if(n.status===200)try{s.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(s)}},n.send(i)}}),Vt!=null&&Vt.sendBeacon&&_u.push({transport:"sendBeacon",method:t=>{var e=yu(t.url,{beacon:"1"});try{var n,{contentType:r,body:i}=(n=bh(t))!==null&&n!==void 0?n:{},s=typeof i=="string"?new Blob([i],{type:r}):i;Vt.sendBeacon(e,s)}catch{}}});var vs=function(t,e){if(!function(n){try{new RegExp(n)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function hw(t,e,n){return Wo({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var pw={exact:(t,e)=>e.some(n=>t.some(r=>n===r)),is_not:(t,e)=>e.every(n=>t.every(r=>n!==r)),regex:(t,e)=>e.some(n=>t.some(r=>vs(n,r))),not_regex:(t,e)=>e.every(n=>t.every(r=>!vs(n,r))),icontains:(t,e)=>e.map(wu).some(n=>t.map(wu).some(r=>n.includes(r))),not_icontains:(t,e)=>e.map(wu).every(n=>t.map(wu).every(r=>!n.includes(r)))},wu=t=>t.toLowerCase(),gw=Ge("[Error tracking]");class ZR{constructor(e){var n,r;this.ge=[],this._e=new R3([new T3,new N3,new M3,new P3,new L3,new F3,new A3,new D3],[k3,$3]),this._instance=e,this.ge=(n=(r=this._instance.persistence)==null?void 0:r.get_property(Uf))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,i,s=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.ge=s,this._instance.persistence&&this._instance.persistence.register({[Uf]:this.ge,[o_]:o})}get me(){var e,n=!!this._instance.get_property(o_),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??n)!==null&&e!==void 0&&e}buildProperties(e,n){return this._e.buildFromUnknown(e,{syntheticException:n==null?void 0:n.syntheticException,mechanism:{handled:n==null?void 0:n.handled}})}sendExceptionEvent(e){if(this.ye(e))gw.info("Skipping exception capture because a suppression rule matched");else{if(this.me||!this.be(e))return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"});gw.info("Skipping exception capture because it was thrown by an extension")}}ye(e){var n=e.$exception_list;if(!n||!$e(n)||n.length===0)return!1;var r=n.reduce((i,s)=>{var{type:o,value:a}=s;return je(o)&&o.length>0&&i.$exception_types.push(o),je(a)&&a.length>0&&i.$exception_values.push(a),i},{$exception_types:[],$exception_values:[]});return this.ge.some(i=>{var s=i.values.map(o=>{var a,l=pw[o.operator],u=$e(o.value)?o.value:[o.value],c=(a=r[o.key])!==null&&a!==void 0?a:[];return u.length>0&&l(u,c)});return i.type==="OR"?s.some(Boolean):s.every(Boolean)})}be(e){var n=e.$exception_list;return!(!n||!$e(n))&&n.flatMap(r=>{var i,s;return(i=(s=r.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]}).some(r=>r.filename&&r.filename.startsWith("chrome-extension://"))}}var rn="Mobile",bu="iOS",Hn="Android",Go="Tablet",vw=Hn+" "+Go,mw="iPad",yw="Apple",_w=yw+" Watch",Ko="Safari",ms="BlackBerry",ww="Samsung",bw=ww+"Browser",xw=ww+" Internet",_i="Chrome",JR=_i+" OS",kw=_i+" "+bu,xh="Internet Explorer",Sw=xh+" "+rn,kh="Opera",eT=kh+" Mini",Sh="Edge",Ew="Microsoft "+Sh,ys="Firefox",$w=ys+" "+bu,Yo="Nintendo",Qo="PlayStation",_s="Xbox",Cw=Hn+" "+rn,Rw=rn+" "+Ko,Xo="Windows",Eh=Xo+" Phone",Tw="Nokia",$h="Ouya",Pw="Generic",tT=Pw+" "+rn.toLowerCase(),Mw=Pw+" "+Go.toLowerCase(),Ch="Konqueror",xt="(\\d+(\\.\\d+)?)",Rh=new RegExp("Version/"+xt),nT=new RegExp(_s,"i"),rT=new RegExp(Qo+" \\w+","i"),iT=new RegExp(Yo+" \\w+","i"),Th=new RegExp(ms+"|PlayBook|BB10","i"),sT={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},oT=(t,e)=>e&&oe(e,yw)||function(n){return oe(n,Ko)&&!oe(n,_i)&&!oe(n,Hn)}(t),Ow=function(t,e){return e=e||"",oe(t," OPR/")&&oe(t,"Mini")?eT:oe(t," OPR/")?kh:Th.test(t)?ms:oe(t,"IE"+rn)||oe(t,"WPDesktop")?Sw:oe(t,bw)?xw:oe(t,Sh)||oe(t,"Edg/")?Ew:oe(t,"FBIOS")?"Facebook "+rn:oe(t,"UCWEB")||oe(t,"UCBrowser")?"UC Browser":oe(t,"CriOS")?kw:oe(t,"CrMo")||oe(t,_i)?_i:oe(t,Hn)&&oe(t,Ko)?Cw:oe(t,"FxiOS")?$w:oe(t.toLowerCase(),Ch.toLowerCase())?Ch:oT(t,e)?oe(t,rn)?Rw:Ko:oe(t,ys)?ys:oe(t,"MSIE")||oe(t,"Trident/")?xh:oe(t,"Gecko")?ys:""},aT={[Sw]:[new RegExp("rv:"+xt)],[Ew]:[new RegExp(Sh+"?\\/"+xt)],[_i]:[new RegExp("("+_i+"|CrMo)\\/"+xt)],[kw]:[new RegExp("CriOS\\/"+xt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+xt)],[Ko]:[Rh],[Rw]:[Rh],[kh]:[new RegExp("(Opera|OPR)\\/"+xt)],[ys]:[new RegExp(ys+"\\/"+xt)],[$w]:[new RegExp("FxiOS\\/"+xt)],[Ch]:[new RegExp("Konqueror[:/]?"+xt,"i")],[ms]:[new RegExp(ms+" "+xt),Rh],[Cw]:[new RegExp("android\\s"+xt,"i")],[xw]:[new RegExp(bw+"\\/"+xt)],[xh]:[new RegExp("(rv:|MSIE )"+xt)],Mozilla:[new RegExp("rv:"+xt)]},lT=function(t,e){var n=Ow(t,e),r=aT[n];if(L(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=t.match(s);if(o)return parseFloat(o[o.length-2])}return null},Aw=[[new RegExp(_s+"; "+_s+" (.*?)[);]","i"),t=>[_s,t&&t[1]||""]],[new RegExp(Yo,"i"),[Yo,""]],[new RegExp(Qo,"i"),[Qo,""]],[Th,[ms,""]],[new RegExp(Xo,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Eh,""];if(new RegExp(rn).test(e)&&!/IEMobile\b/.test(e))return[Xo+" "+rn,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],i=sT[r]||"";return/arm/i.test(e)&&(i="RT"),[Xo,i]}return[Xo,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[bu,e.join(".")]}return[bu,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=L(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Hn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Hn+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[Hn,e.join(".")]}return[Hn,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[JR,""]],[/Linux|debian/i,["Linux",""]]],Iw=function(t){return iT.test(t)?Yo:rT.test(t)?Qo:nT.test(t)?_s:new RegExp($h,"i").test(t)?$h:new RegExp("("+Eh+"|WPDesktop)","i").test(t)?Eh:/iPad/.test(t)?mw:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?_w:Th.test(t)?ms:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Tw,"i").test(t)?Tw:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(rn).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Hn:vw:Hn:new RegExp("(pda|"+rn+")","i").test(t)?tT:new RegExp(Go,"i").test(t)&&!new RegExp(Go+" pc","i").test(t)?Mw:""},xu="https?://(.*)",ku=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],uT=Ql(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],ku),Ph="<masked>",cT=["li_fat_id"];function Fw(t,e,n){if(!W)return{};var r,i=e?Ql([],ku,n||[]):[],s=Lw(ih(W.URL,i,Ph),t),o=(r={},be(cT,function(a){var l=Dn.J(a);r[a]=l||null}),r);return He(o,s)}function Lw(t,e){var n=uT.concat(e||[]),r={};return be(n,function(i){var s=ou(t,i);r[i]=s||null}),r}function Dw(t){var e=function(s){return s?s.search(xu+"google.([^/?]*)")===0?"google":s.search(xu+"bing.com")===0?"bing":s.search(xu+"yahoo.com")===0?"yahoo":s.search(xu+"duckduckgo.com")===0?"duckduckgo":null:null}(t),n=e!="yahoo"?"q":"p",r={};if(!nr(e)){r.$search_engine=e;var i=W?ou(W.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function Nw(){return navigator.language||navigator.userLanguage}function jw(){return(W==null?void 0:W.referrer)||"$direct"}function zw(t,e){var n=t?Ql([],ku,e||[]):[],r=Pt==null?void 0:Pt.href.substring(0,1e3);return{r:jw().substring(0,1e3),u:r?ih(r,n,Ph):void 0}}function Hw(t){var e,{r:n,u:r}=t,i={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(e=ps(n))==null?void 0:e.host};if(r){i.$current_url=r;var s=ps(r);i.$host=s==null?void 0:s.host,i.$pathname=s==null?void 0:s.pathname;var o=Lw(r);He(i,o)}if(n){var a=Dw(n);He(i,a)}return i}function Uw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function dT(){try{return new Date().getTimezoneOffset()}catch{return}}function fT(t,e){if(!Mt)return{};var n,r,i,s=t?Ql([],ku,e||[]):[],[o,a]=function(l){for(var u=0;u<Aw.length;u++){var[c,f]=Aw[u],d=c.exec(l),h=d&&(tn(f)?f(d,l):f);if(h)return h}return["",""]}(Mt);return He(zf({$os:o,$os_version:a,$browser:Ow(Mt,navigator.vendor),$device:Iw(Mt),$device_type:(r=Mt,i=Iw(r),i===mw||i===vw||i==="Kobo"||i==="Kindle Fire"||i===Mw?Go:i===Yo||i===_s||i===Qo||i===$h?"Console":i===_w?"Wearable":i?rn:"Desktop"),$timezone:Uw(),$timezone_offset:dT()}),{$current_url:ih(Pt==null?void 0:Pt.href,s,Ph),$host:Pt==null?void 0:Pt.host,$pathname:Pt==null?void 0:Pt.pathname,$raw_user_agent:Mt.length>1e3?Mt.substring(0,997)+"...":Mt,$browser_version:lT(Mt,navigator.vendor),$browser_language:Nw(),$browser_language_prefix:(n=Nw(),typeof n=="string"?n.split("-")[0]:void 0),$screen_height:E==null?void 0:E.screen.height,$screen_width:E==null?void 0:E.screen.width,$viewport_height:E==null?void 0:E.innerHeight,$viewport_width:E==null?void 0:E.innerWidth,$lib:"web",$lib_version:tr.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var xn=Ge("[FeatureFlags]"),Mh="$active_feature_flags",ws="$override_feature_flags",Bw="$feature_flag_payloads",Zo="$override_feature_flag_payloads",qw="$feature_flag_request_id",Vw=t=>{var e={};for(var[n,r]of Xl(t||{}))r&&(e[n]=r);return e},hT=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map(n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]})),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(n=>e[n].enabled).filter(n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload}).map(n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]}))):xn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},pT=function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t}({});class gT{constructor(e){this.we=!1,this.Se=!1,this.ke=!1,this.$e=!1,this.xe=!1,this.Ee=!1,this.Re=!1,this._instance=e,this.featureFlagEventHandlers=[]}Ie(){var e=this._instance.config.evaluation_environments;return e!=null&&e.length?e.filter(n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||xn.error("Invalid evaluation environment found:",n,"Expected non-empty string"),r}):[]}Pe(){return this.Ie().length>0}flags(){if(this._instance.config.__preview_remote_config)this.Ee=!0;else{var e=!this.Te&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.Ce({disableFlags:e})}}get hasLoadedFlags(){return this.Se}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Gf),n=this._instance.get_property(ws),r=this._instance.get_property(Zo);if(!r&&!n)return e||{};var i=He({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var o of s){var a,l,u=i[o],c=n==null?void 0:n[o],f=L(c)?(a=u==null?void 0:u.enabled)!==null&&a!==void 0&&a:!!c,d=L(c)?u.variant:typeof c=="string"?c:void 0,h=r==null?void 0:r[o],p=z({},u,{enabled:f,variant:f?d??(u==null?void 0:u.variant):void 0});f!==(u==null?void 0:u.enabled)&&(p.original_enabled=u==null?void 0:u.enabled),d!==(u==null?void 0:u.variant)&&(p.original_variant=u==null?void 0:u.variant),h&&(p.metadata=z({},u==null?void 0:u.metadata,{payload:h,original_payload:u==null||(l=u.metadata)==null?void 0:l.payload})),i[o]=p}return this.we||(xn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.we=!0),i}getFlagVariants(){var e=this._instance.get_property(fs),n=this._instance.get_property(ws);if(!n)return e||{};for(var r=He({},e),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.we||(xn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.we=!0),r}getFlagPayloads(){var e=this._instance.get_property(Bw),n=this._instance.get_property(Zo);if(!n)return e||{};for(var r=He({},e||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.we||(xn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.we=!0),r}reloadFeatureFlags(){this.$e||this._instance.config.advanced_disable_feature_flags||this.Te||(this.Te=setTimeout(()=>{this.Ce()},5))}Me(){clearTimeout(this.Te),this.Te=void 0}ensureFlagsLoaded(){this.Se||this.ke||this.Te||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.$e=e}Ce(e){var n;if(this.Me(),!this._instance.L())if(this.ke)this.xe=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:z({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(No)||{}),group_properties:this._instance.get_property(hi)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Pe()&&(r.evaluation_environments=this.Ie());var i=this._instance.config.__preview_remote_config,s=i?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("api",s+o);i&&(r.timezone=Uw()),this.ke=!0,this._instance.Oe({method:"POST",url:a,data:r,compression:this._instance.config.disable_compression?void 0:ir.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var u,c,f=!0;if(l.statusCode===200&&(this.xe||(this.$anon_distinct_id=void 0),f=!1),this.ke=!1,this.Ee||(this.Ee=!0,this._instance.Fe((c=l.json)!==null&&c!==void 0?c:{})),!r.disable_flags||this.xe)if(this.Re=!f,l.json&&(u=l.json.quotaLimited)!=null&&u.includes(pT.FeatureFlags))xn.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var d;r.disable_flags||this.receivedFeatureFlags((d=l.json)!==null&&d!==void 0?d:{},f),this.xe&&(this.xe=!1,this.Ce())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.Se||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],i=""+r,s=this._instance.get_property(qw)||void 0,o=this._instance.get_property(eu)||{};if((n.send_event||!("send_event"in n))&&(!(e in o)||!o[e].includes(i))){var a,l,u,c,f,d,h,p,g;$e(o[e])?o[e].push(i):o[e]=[i],(a=this._instance.persistence)==null||a.register({[eu]:o});var w=this.getFeatureFlagDetails(e),m={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:s,$feature_flag_bootstrapped_response:((l=this._instance.config.bootstrap)==null||(l=l.featureFlags)==null?void 0:l[e])||null,$feature_flag_bootstrapped_payload:((u=this._instance.config.bootstrap)==null||(u=u.featureFlagPayloads)==null?void 0:u[e])||null,$used_bootstrap_value:!this.Re};L(w==null||(c=w.metadata)==null?void 0:c.version)||(m.$feature_flag_version=w.metadata.version);var v,y=(f=w==null||(d=w.reason)==null?void 0:d.description)!==null&&f!==void 0?f:w==null||(h=w.reason)==null?void 0:h.code;y&&(m.$feature_flag_reason=y),w!=null&&(p=w.metadata)!=null&&p.id&&(m.$feature_flag_id=w.metadata.id),L(w==null?void 0:w.original_variant)&&L(w==null?void 0:w.original_enabled)||(m.$feature_flag_original_response=L(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(g=w.metadata)!=null&&g.original_payload&&(m.$feature_flag_original_payload=w==null||(v=w.metadata)==null?void 0:v.original_payload),this._instance.capture("$feature_flag_called",m)}return r}xn.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.Pe()&&(i.evaluation_environments=this.Ie()),this._instance.Oe({method:"POST",url:this._instance.requestRouter.endpointFor("api","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:ir.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;n((a==null?void 0:a[e])||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.Se||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,n);return L(r)?void 0:!!r}xn.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(n=>n!==e)}receivedFeatureFlags(e,n){if(this._instance.persistence){this.Se=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,u,c){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var f=hT(o),d=f.flags,h=f.featureFlags,p=f.featureFlagPayloads;if(h){var g=o.requestId;if($e(h)){xn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var w={};if(h)for(var m=0;m<h.length;m++)w[h[m]]=!0;a&&a.register({[Mh]:h,[fs]:w})}else{var v=h,y=p,b=d;o.errorsWhileComputingFlags&&(v=z({},l,v),y=z({},u,y),b=z({},c,b)),a&&a.register(z({[Mh]:Object.keys(Vw(v)),[fs]:v||{},[Bw]:y||{},[Gf]:b||{}},g?{[qw]:g}:{}))}}})(e,this._instance.persistence,r,i,s),this.Ae(n)}}override(e,n){n===void 0&&(n=!1),xn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return xn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ws),this._instance.persistence.unregister(Zo),void this.Ae();if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.we=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(ws);else if(r.flags)if($e(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[ws]:i})}else this._instance.persistence.register({[ws]:r.flags})}return"payloads"in r&&(r.payloads===!1?this._instance.persistence.unregister(Zo):r.payloads&&this._instance.persistence.register({[Zo]:r.payloads})),void this.Ae()}this.Ae()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Se){var{flags:n,flagVariants:r}=this.De();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var i,s=(this._instance.get_property(Do)||[]).find(u=>u.flagKey===e),o={["$feature_enrollment/"+e]:n},a={$feature_flag:e,$feature_enrollment:n,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=z({},this.getFlagVariants(),{[e]:n});(i=this._instance.persistence)==null||i.register({[Mh]:Object.keys(Vw(l)),[fs]:l}),this.Ae()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var i=this._instance.get_property(Do),s=r?"&"+r.map(o=>"stage="+o).join("&"):"";if(i&&!n)return e(i);this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var u=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Do),(l=this._instance.persistence)==null||l.register({[Do]:u}),e(u)}}})}De(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter(r=>n[r]),flagVariants:Object.keys(n).filter(r=>n[r]).reduce((r,i)=>(r[i]=n[i],r),{})}}Ae(e){var{flags:n,flagVariants:r}=this.De();this.featureFlagEventHandlers.forEach(i=>i(n,r,{errorsLoading:e}))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(No)||{};this._instance.register({[No]:z({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(No)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(hi)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=z({},r[i],e[i]),delete e[i]}),this._instance.register({[hi]:z({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(hi)||{};this._instance.register({[hi]:z({},n,{[e]:{}})})}else this._instance.unregister(hi)}reset(){this.Se=!1,this.ke=!1,this.$e=!1,this.xe=!1,this.Ee=!1,this.Re=!1,this.$anon_distinct_id=void 0,this.Me(),this.we=!1}}var vT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Oh{constructor(e,n){this.A=e,this.props={},this.je=!1,this.Le=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.it=this.Ne(e),this.load(),e.debug&&V.info("Persistence loaded",e.persistence,z({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.Ue}Ne(e){vT.indexOf(e.persistence.toLowerCase())===-1&&(V.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&Ke.G()?Ke:n==="localstorage+cookie"&&uu.G()?uu:n==="sessionstorage"&&it.G()?it:n==="memory"?cR:n==="cookie"?Dn:uu.G()?uu:Dn}properties(){var e={};return be(this.props,function(n,r){if(r===fs&&Ne(n))for(var i=Object.keys(n),s=0;s<i.length;s++)e["$feature/"+i[s]]=n[i[s]];else a=r,l=!1,(nr(o=q3)?l:jy&&o.indexOf===jy?o.indexOf(a)!=-1:(be(o,function(u){if(l||(l=u===a))return Yl}),l))||(e[r]=n);var o,a,l}),e}load(){if(!this.Ue){var e=this.it.K(this.Le);e&&(this.props=He({},e))}}save(){this.Ue||this.it.Y(this.Le,this.props,this.ze,this.Be,this.qe,this.A.debug)}remove(){this.it.X(this.Le,!1),this.it.X(this.Le,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Ne(e)){L(n)&&(n="None"),this.ze=L(r)?this.He:r;var i=!1;if(be(e,(s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=s,i=!0)}),i)return this.save(),!0}return!1}register(e,n){if(Ne(e)){this.ze=L(n)?this.He:n;var r=!1;if(be(e,(i,s)=>{e.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)}),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.je){var e=Fw(this.A.custom_campaign_params,this.A.mask_personal_data_properties,this.A.custom_personal_data_properties);us(zf(e))||this.register(e),this.je=!0}}update_search_keyword(){var e;this.register((e=W==null?void 0:W.referrer)?Dw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:jw(),$referring_domain:W!=null&&W.referrer&&((e=ps(W.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Xf]||this.props[Zf]||this.register_once({[tu]:zw(this.A.mask_personal_data_properties,this.A.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};be([Zf,Xf],o=>{var a=this.props[o];a&&be(a,function(l,u){e["$initial_"+If(u)]=l})});var n,r,i=this.props[tu];if(i){var s=(n=Hw(i),r={},be(n,function(o,a){r["$initial_"+If(a)]=o}),r);He(e,s)}return e}safe_merge(e){return be(this.props,function(n,r){r in e||(e[r]=n)}),e}update_config(e,n,r){if(this.He=this.ze=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence){var i=this.Ne(e),s=this.props;this.clear(),this.it=i,this.props=s,this.save()}}set_disabled(e){this.Ue=e,this.Ue?this.remove():this.save()}set_cross_subdomain(e){e!==this.Be&&(this.Be=e,this.remove(),this.save())}set_secure(e){e!==this.qe&&(this.qe=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Lo]||{};r[e]=n,this.props[Lo]=r,this.save()}remove_event_timer(e){var n=(this.props[Lo]||{})[e];return L(n)||(delete this.props[Lo][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({}),function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t}({});var Ah=function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t}({});(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({}),function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t}({}),function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t}({});var Su=function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t}({}),Ww=function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t}({}),Gw=function(t){return t.Popover="popover",t.Inline="inline",t}({});class Ih{constructor(){this.We={},this.We={}}on(e,n){return this.We[e]||(this.We[e]=[]),this.We[e].push(n),()=>{this.We[e]=this.We[e].filter(r=>r!==n)}}emit(e,n){for(var r of this.We[e]||[])r(n);for(var i of this.We["*"]||[])i(e,n)}}class wi{constructor(e){this.Ge=new Ih,this.Ve=(n,r)=>this.Je(n,r)&&this.Ke(n,r)&&this.Ye(n,r),this.Je=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.Xe=new Set,this.Qe=new Set}init(){var e;if(!L((e=this._instance)==null?void 0:e.Ze)){var n;(n=this._instance)==null||n.Ze((r,i)=>{this.on(r,i)})}}register(e){var n,r;if(!L((n=this._instance)==null?void 0:n.Ze)&&(e.forEach(o=>{var a,l;(a=this.Qe)==null||a.add(o),(l=o.steps)==null||l.forEach(u=>{var c;(c=this.Xe)==null||c.add((u==null?void 0:u.event)||"")})}),(r=this._instance)!=null&&r.autocapture)){var i,s=new Set;e.forEach(o=>{var a;(a=o.steps)==null||a.forEach(l=>{l!=null&&l.selector&&s.add(l==null?void 0:l.selector)})}),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,n){var r;n!=null&&e.length!=0&&(this.Xe.has(e)||this.Xe.has(n==null?void 0:n.event))&&this.Qe&&((r=this.Qe)==null?void 0:r.size)>0&&this.Qe.forEach(i=>{this.tr(n,i)&&this.Ge.emit("actionCaptured",i.name)})}ir(e){this.onAction("actionCaptured",n=>e(n))}tr(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Ve(e,r))return!0;return!1}onAction(e,n){return this.Ge.on(e,n)}Ke(e,n){if(n!=null&&n.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!wi.er(i,n==null?void 0:n.url,(n==null?void 0:n.url_matching)||"contains"))return!1}return!0}static er(e,n,r){switch(r){case"regex":return!!E&&vs(e,n);case"exact":return n===e;case"contains":var i=wi.rr(n).replace(/_/g,".").replace(/%/g,".*");return vs(e,i);default:return!1}}static rr(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}Ye(e,n){if((n!=null&&n.href||n!=null&&n.tag_name||n!=null&&n.text)&&!this.sr(e).some(s=>!(n!=null&&n.href&&!wi.er(s.href||"",n==null?void 0:n.href,(n==null?void 0:n.href_matching)||"exact"))&&(n==null||!n.tag_name||s.tag_name===(n==null?void 0:n.tag_name))&&!(n!=null&&n.text&&!wi.er(s.text||"",n==null?void 0:n.text,(n==null?void 0:n.text_matching)||"exact")&&!wi.er(s.$el_text||"",n==null?void 0:n.text,(n==null?void 0:n.text_matching)||"exact"))))return!1;if(n!=null&&n.selector){var r,i=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(!i||!i.includes(n==null?void 0:n.selector))return!1}return!0}sr(e){return(e==null?void 0:e.properties.$elements)==null?[]:e==null?void 0:e.properties.$elements}}var xe=Ge("[Surveys]"),Fh="seenSurvey_",mT=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},Kw=t=>{var e=""+Fh+t.id;return t.current_iteration&&t.current_iteration>0&&(e=""+Fh+t.id+"_"+t.current_iteration),e},yT=[Ah.Popover,Ah.Widget,Ah.API],_T={ignoreConditions:!1,ignoreDelay:!1,displayType:Gw.Popover};class wT{constructor(e){this._instance=e,this.nr=new Map,this.ar=new Map}register(e){var n;L((n=this._instance)==null?void 0:n.Ze)||(this.lr(e),this.ur(e))}ur(e){var n=e.filter(r=>{var i,s;return((i=r.conditions)==null?void 0:i.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0});n.length!==0&&(this.hr==null&&(this.hr=new wi(this._instance),this.hr.init(),this.hr.ir(r=>{this.onAction(r)})),n.forEach(r=>{var i,s,o,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.hr)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(u=>{if(u&&u.name){var c=this.ar.get(u.name);c&&c.push(r.id),this.ar.set(u.name,c||[r.id])}}))}))}lr(e){var n;e.filter(r=>{var i,s;return((i=r.conditions)==null?void 0:i.events)&&((s=r.conditions)==null||(s=s.events)==null||(s=s.values)==null?void 0:s.length)>0}).length!==0&&((n=this._instance)==null||n.Ze((r,i)=>{this.onEvent(r,i)}),e.forEach(r=>{var i;(i=r.conditions)==null||(i=i.events)==null||(i=i.values)==null||i.forEach(s=>{if(s&&s.name){var o=this.nr.get(s.name);o&&o.push(r.id),this.nr.set(s.name,o||[r.id])}})}))}onEvent(e,n){var r,i,s=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[Jl])||[];if(Su.SHOWN===e&&n&&s.length>0){var o;xe.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:n,existingActivatedSurveys:s});var a=n==null||(o=n.properties)==null?void 0:o.$survey_id;if(a){var l=s.indexOf(a);l>=0&&(s.splice(l,1),this.dr(s))}}else if(this.nr.has(e)){xe.info("survey event name matched",{event:e,eventPayload:n,surveys:this.nr.get(e)});var u=[];(i=this._instance)==null||i.getSurveys(f=>{u=f.filter(d=>{var h;return(h=this.nr.get(e))==null?void 0:h.includes(d.id)})});var c=u.filter(f=>{var d,h=(d=f.conditions)==null||(d=d.events)==null||(d=d.values)==null?void 0:d.find(p=>p.name===e);return!!h&&(!h.propertyFilters||Object.entries(h.propertyFilters).every(p=>{var g,[w,m]=p,v=n==null||(g=n.properties)==null?void 0:g[w];if(L(v)||nr(v))return!1;var y=[String(v)],b=pw[m.operator];return b?b(m.values,y):(xe.warn("Unknown property comparison operator: "+m.operator),!1)}))});this.dr(s.concat(c.map(f=>f.id)||[]))}}onAction(e){var n,r=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[Jl])||[];this.ar.has(e)&&this.dr(r.concat(this.ar.get(e)||[]))}dr(e){var n;xe.info("updating activated surveys",{activatedSurveys:e}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[Jl]:[...new Set(e)]})}getSurveys(){var e,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[Jl];return n||[]}getEventToSurveys(){return this.nr}vr(){return this.hr}}class bT{constructor(e){this.cr=void 0,this._surveyManager=null,this.pr=!1,this.gr=!1,this._r=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var n=e.surveys;if(fe(n))return xe.warn("Flags not loaded yet. Not loading surveys.");var r=$e(n);this.cr=r?n.length>0:n,xe.info("flags response received, isSurveysEnabled: "+this.cr),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(Fh)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this._surveyManager)if(this.gr)xe.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)xe.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())xe.info("Not loading surveys in cookieless mode without consent.");else{var e=X==null?void 0:X.__PosthogExtensions__;if(e){if(!L(this.cr)||this._instance.config.advanced_enable_surveys){var n=this.cr||this._instance.config.advanced_enable_surveys;this.gr=!0;try{var r=e.generateSurveys;if(r)return void this.mr(r,n);var i=e.loadExternalDependency;if(!i)return void this.yr("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",s=>{s||!e.generateSurveys?this.yr("Could not load surveys script",s):this.mr(e.generateSurveys,n)})}catch(s){throw this.yr("Error initializing surveys",s),s}finally{this.gr=!1}}}else xe.error("PostHog Extensions not found.")}}mr(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new wT(this._instance),xe.info("Surveys loaded successfully"),this.br({isLoaded:!0})}yr(e,n){xe.error(e,n),this.br({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._r.push(e),this._surveyManager&&this.br({isLoaded:!0}),()=>{this._r=this._r.filter(n=>n!==e)}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return xe.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(Kf);if(r&&!n)return e(r,{isLoaded:!0});if(this.pr)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.pr=!0,this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var s;this.pr=!1;var o=i.statusCode;if(o!==200||!i.json){var a="Surveys API could not be loaded, status: "+o;return xe.error(a),e([],{isLoaded:!1,error:a})}var l,u=i.json.surveys||[],c=u.filter(f=>function(d){return!(!d.start_date||d.end_date)}(f)&&(function(d){var h;return!((h=d.conditions)==null||(h=h.events)==null||(h=h.values)==null||!h.length)}(f)||function(d){var h;return!((h=d.conditions)==null||(h=h.actions)==null||(h=h.values)==null||!h.length)}(f)));return c.length>0&&((l=this._surveyEventReceiver)==null||l.register(c)),(s=this._instance.persistence)==null||s.register({[Kf]:u}),e(u,{isLoaded:!0})}})}catch(i){throw this.pr=!1,i}}br(e){for(var n of this._r)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){xe.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!fe(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);xe.warn("init was not called")}wr(e){var n=null;return this.getSurveys(r=>{var i;n=(i=r.find(s=>s.id===e))!==null&&i!==void 0?i:null}),n}Sr(e){if(fe(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this.wr(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(fe(this._surveyManager))return xe.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this.Sr(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return fe(this._surveyManager)?(xe.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise(r=>{this.getSurveys(i=>{var s,o=(s=i.find(l=>l.id===e))!==null&&s!==void 0?s:null;if(o){var a=this.Sr(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})},n)})}renderSurvey(e,n){var r;if(fe(this._surveyManager))xe.warn("init was not called");else{var i=typeof e=="string"?this.wr(e):e;if(i!=null&&i.id)if(yT.includes(i.type)){var s=W==null?void 0:W.querySelector(n);if(s)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(xe.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var o,a;xe.info("Rendering survey "+i.id+" with delay of "+((o=i.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(i,s),xe.info("Survey "+i.id+" rendered")},1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,s);xe.warn("Survey element not found")}else xe.warn("Surveys of type "+i.type+" cannot be rendered in the app");else xe.warn("Survey not found")}}displaySurvey(e,n){var r;if(fe(this._surveyManager))xe.warn("init was not called");else{var i=this.wr(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(s=z({},i,{appearance:z({},i.appearance,{surveyPopupDelaySeconds:0})})),n.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void xe.warn("Survey is not eligible to be displayed: ",o.disabledReason)}n.displayType!==Gw.Inline?this._surveyManager.handlePopoverSurvey(s):this.renderSurvey(s,n.selector)}else xe.warn("Survey not found")}}}var Yw=Ge("[RateLimiter]");class xT{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(o=>{Yw.info((o||"events")+" is quota limited."),this.serverLimits[o]=new Date().getTime()+6e4})}catch(o){return void Yw.warn('could not rate limit - continuing. Error: "'+(o==null?void 0:o.message)+'"',{text:s})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,i;e===void 0&&(e=!1);var s=new Date().getTime(),o=(n=(r=this.instance.persistence)==null?void 0:r.get_property(Qf))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:s};o.tokens+=(s-o.last)/1e3*this.captureEventsPerSecond,o.last=s,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var a=o.tokens<1;return a||e||(o.tokens=Math.max(0,o.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,(i=this.instance.persistence)==null||i.set_property(Qf,o),{isRateLimited:a,remainingTokens:o.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var bi=Ge("[RemoteConfig]");class kT{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=X._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}kr(e){var n,r;(n=X.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(bi.error("PostHog Extensions not found. Cannot load remote config."),e())}$r(e){this._instance.Oe({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return bi.info("Using preloaded remote config",this.remoteConfig),void this.Fe(this.remoteConfig);if(this._instance.L())return void bi.warn("Remote config is disabled. Falling back to local config.");this.kr(e=>{if(!e)return bi.info("No config found after loading remote JS config. Falling back to JSON."),void this.$r(n=>{this.Fe(n)});this.Fe(e)})}catch(e){bi.error("Error loading remote config",e)}}Fe(e){e?this._instance.config.__preview_remote_config?(this._instance.Fe(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):bi.info("__preview_remote_config is disabled. Logging config instead",e):bi.error("Failed to fetch remote config from PostHog.")}}var Lh=3e3;class ST{constructor(e,n){this.Er=!0,this.Rr=[],this.Ir=Wt((n==null?void 0:n.flush_interval_ms)||Lh,250,5e3,V.createLogger("flush interval"),Lh),this.Pr=e}enqueue(e){this.Rr.push(e),this.Tr||this.Cr()}unload(){this.Mr();var e=this.Rr.length>0?this.Or():{},n=Object.values(e);[...n.filter(r=>r.url.indexOf("/e")===0),...n.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Pr(z({},r,{transport:"sendBeacon"}))})}enable(){this.Er=!1,this.Cr()}Cr(){var e=this;this.Er||(this.Tr=setTimeout(()=>{if(this.Mr(),this.Rr.length>0){var n=this.Or(),r=function(){var s=n[i],o=new Date().getTime();s.data&&$e(s.data)&&be(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),e.Pr(s)};for(var i in n)r()}},this.Ir))}Mr(){clearTimeout(this.Tr),this.Tr=void 0}Or(){var e={};return be(this.Rr,n=>{var r,i=n,s=(i?i.batchKey:null)||i.url;L(e[s])&&(e[s]=z({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)}),this.Rr=[],e}}var ET=["retriesPerformedSoFar"];class $T{constructor(e){this.Fr=!1,this.Ar=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.Dr=!0,!L(E)&&"onLine"in E.navigator&&(this.Dr=E.navigator.onLine,Le(E,"online",()=>{this.Dr=!0,this.oe()}),Le(E,"offline",()=>{this.Dr=!1}))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=By(e,ET);dt(n)&&n>0&&(r.url=yu(r.url,{retry_count:n})),this._instance.Oe(z({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(n??0)<10?this.jr(z({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(i)}}))}jr(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)}(n),i=Date.now()+r;this.Rr.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),V.warn(s),this.Fr||(this.Fr=!0,this.Lr())}Lr(){this.Nr&&clearTimeout(this.Nr),this.Nr=setTimeout(()=>{this.Dr&&this.Rr.length>0&&this.oe(),this.Lr()},this.Ar)}oe(){var e=Date.now(),n=[],r=this.Rr.filter(s=>s.retryAt<e||(n.push(s),!1));if(this.Rr=n,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.Nr&&(clearTimeout(this.Nr),this.Nr=void 0),this.Rr))try{this._instance.Oe(z({},e,{transport:"sendBeacon"}))}catch(n){V.error(n)}this.Rr=[]}}class CT{constructor(e){this.Ur=()=>{var n,r,i,s;this.zr||(this.zr={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+((o==null?void 0:o.clientHeight)||0),c=(o==null?void 0:o.scrollHeight)||0;this.zr.lastScrollY=Math.ceil(a),this.zr.maxScrollY=Math.max(a,(n=this.zr.maxScrollY)!==null&&n!==void 0?n:0),this.zr.maxScrollHeight=Math.max(l,(r=this.zr.maxScrollHeight)!==null&&r!==void 0?r:0),this.zr.lastContentY=u,this.zr.maxContentY=Math.max(u,(i=this.zr.maxContentY)!==null&&i!==void 0?i:0),this.zr.maxContentHeight=Math.max(c,(s=this.zr.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.zr}resetContext(){var e=this.zr;return setTimeout(this.Ur,0),e}startMeasuringScrollPosition(){Le(E,"scroll",this.Ur,{capture:!0}),Le(E,"scrollend",this.Ur,{capture:!0}),Le(E,"resize",this.Ur)}scrollElement(){if(!this._instance.config.scroll_root_selector)return E==null?void 0:E.document.documentElement;var e=$e(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=E==null?void 0:E.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return E&&(E.scrollY||E.pageYOffset||E.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return E&&(E.scrollX||E.pageXOffset||E.document.documentElement.scrollLeft)||0}}var RT=t=>zw(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties);class Qw{constructor(e,n,r,i){this.Br=s=>{var o=this.qr();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Hr(this._instance)};this.Wr.register({[Yf]:a})}},this._instance=e,this.Gr=n,this.Wr=r,this.Hr=i||RT,this.Gr.onSessionId(this.Br)}qr(){return this.Wr.props[Yf]}getSetOnceProps(){var e,n=(e=this.qr())==null?void 0:e.props;return n?"r"in n?Hw(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return be(zf(this.getSetOnceProps()),(n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+If(r)]=n}),e}}var Dh=Ge("[SessionId]");class Xw{on(e,n){return this.Vr.on(e,n)}constructor(e,n,r){var i;if(this.Jr=[],this.Vr=new Ih,this.Kr=(c,f)=>Math.abs(c-f)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.A=e.config,this.Wr=e.persistence,this.pi=void 0,this.Ft=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Yr=n||Ir,this.Xr=r||Ir;var s=this.A.persistence_name||this.A.token,o=this.A.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Wt(o,60,36e3,Dh.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Qr(),this.Zr="ph_"+s+"_window_id",this.ts="ph_"+s+"_primary_window_exists",this.es()){var a=it.K(this.Zr),l=it.K(this.ts);a&&!l?this.pi=a:it.X(this.Zr),it.Y(this.ts,!0)}if((i=this.A.bootstrap)!=null&&i.sessionID)try{var u=(c=>{var f=c.replace(/-/g,"");if(f.length!==32)throw new Error("Not a valid UUID");if(f[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(f.substring(0,12),16)})(this.A.bootstrap.sessionID);this.rs(this.A.bootstrap.sessionID,new Date().getTime(),u)}catch(c){Dh.error("Invalid sessionID in bootstrap",c)}this.ss()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this.Jr)&&(this.Jr=[]),this.Jr.push(e),this.Ft&&e(this.Ft,this.pi),()=>{this.Jr=this.Jr.filter(n=>n!==e)}}es(){return this.A.persistence!=="memory"&&!this.Wr.Ue&&it.G()}ns(e){e!==this.pi&&(this.pi=e,this.es()&&it.Y(this.Zr,e))}os(){return this.pi?this.pi:this.es()?it.K(this.Zr):null}rs(e,n,r){e===this.Ft&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ft=e,this.Wr.register({[Zl]:[n,e,r]}))}ls(){if(this.Ft&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this.Ft,this._sessionStartTimestamp];var e=this.Wr.props[Zl];return $e(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.rs(null,null,null)}ss(){Le(E,"beforeunload",()=>{this.es()&&it.X(this.ts)},{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.A.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[i,s,o]=this.ls(),a=this.os(),l=dt(o)&&o>0&&Math.abs(r-o)>864e5,u=!1,c=!s,f=!e&&this.Kr(r,i);c||f||l?(s=this.Yr(),a=this.Xr(),Dh.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:f,sessionPastMaximumLength:l}}),o=r,u=!0):a||(a=this.Xr(),u=!0);var d=i===0||!e||l?r:i,h=o===0?new Date().getTime():o;return this.ns(a),this.rs(s,d,h),e||this.Qr(),u&&this.Jr.forEach(p=>p(s,a,u?{noSessionId:c,activityTimeout:f,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:a,sessionStartTimestamp:h,changeReason:u?{noSessionId:c,activityTimeout:f,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}Qr(){clearTimeout(this.us),this.us=setTimeout(()=>{var[e]=this.ls();if(this.Kr(new Date().getTime(),e)){var n=this.Ft;this.resetSessionId(),this.Vr.emit("forcedIdleReset",{idleSessionId:n})}},1.1*this.sessionTimeoutMs)}}var TT=["$set_once","$set"],Nr=Ge("[SiteApps]");class PT{constructor(e){this._instance=e,this.hs=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ds(e,n){if(n){var r=this.globalsForEvent(n);this.hs.push(r),this.hs.length>1e3&&(this.hs=this.hs.slice(10))}}get siteAppLoaders(){var e;return(e=X._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ze(this.ds.bind(this));this.vs=()=>{e(),this.hs=[],this.vs=void 0}}}globalsForEvent(e){var n,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var u={},c=this._instance.get_property("$groups")||[],f=this._instance.get_property("$stored_group_properties")||{};for(var[d,h]of Object.entries(f))u[d]={id:c[d],type:d,properties:h};var{$set_once:p,$set:g}=e;return{event:z({},By(e,TT),{properties:z({},e.properties,g?{$set:z({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},g)}:{},p?{$set_once:z({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},p)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var a;!n.errored&&this.hs.length&&(Nr.info("Processing "+this.hs.length+" events for site app with id "+e.id),this.hs.forEach(l=>n.processEvent==null?void 0:n.processEvent(l)),n.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((a=this.vs)==null||a.call(this))},i=!1,s=a=>{n.errored=!a,n.loaded=!0,Nr.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(n.processEvent=o),i=!0}catch(a){Nr.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&n.loaded)try{r()}catch(a){Nr.error("Error while processing buffered events PostHog app with config id "+e.id,a),n.errored=!0}}cs(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}fs(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(i){Nr.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var n,r,i,s=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this.cs(),void this._instance.on("eventCaptured",u=>this.fs(u))):void Nr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.vs)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(u){var c;X["__$$ph_site_app_"+u]=s._instance,(c=X.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(s._instance,l,f=>{if(f)return Nr.error("Error while initializing PostHog app with config id "+u,f)})};for(var{id:a,url:l}of e.siteApps)o(a)}else Nr.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var MT=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Zw=function(t,e){if(!t)return!1;var n=t.toLowerCase();return MT.concat(e||[]).some(r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1})},Jw=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&Zw(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>Zw(i==null?void 0:i.brand,e)))return!0}catch{}return!!t.webdriver},Jo=function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t}({}),e1="i.posthog.com";class OT{constructor(e){this.ps={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+e1,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.ps[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.ps[this.apiHost]=Jo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.ps[this.apiHost]=Jo.EU:this.ps[this.apiHost]=Jo.CUSTOM),this.ps[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(this.region===Jo.CUSTOM)return this.apiHost+n;var r=e1+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var AT={icontains:(t,e)=>!!E&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!E&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!E&&vs(e.href,t),not_regex:(t,e)=>!!E&&!vs(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class ht{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments(i=>{ht.gs("retrieved web experiments from the server"),n._s=new Map,i.forEach(s=>{if(s.feature_flag_key){var o;n._s&&(ht.gs("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=n._s)==null||o.set(s.feature_flag_key,s));var a=n._instance.getFeatureFlag(s.feature_flag_key);je(a)&&s.variants[a]&&n.ys(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var u=s.variants[l];ht.bs(u)&&n.ys(s.name,l,u.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(e){if(this._is_bot())ht.gs("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(fe(this._s))return this._s=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ht.gs("applying feature flags",e),e.forEach(n=>{var r;if(this._s&&(r=this._s)!=null&&r.has(n)){var i,s=this._instance.getFeatureFlag(n),o=(i=this._s)==null?void 0:i.get(n);s&&o!=null&&o.variants[s]&&this.ys(o.name,s,o.variants[s].transforms)}})}}previewWebExperiment(){var e=ht.getWindowLocation();if(e!=null&&e.search){var n=ou(e==null?void 0:e.search,"__experiment_id"),r=ou(e==null?void 0:e.search,"__experiment_variant");n&&r&&(ht.gs("previewing web experiments "+n+" && "+r),this.getWebExperiments(i=>{this.ws(parseInt(n),r,i)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance.Oe({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}ws(e,n,r){var i=r.filter(s=>s.id===e);i&&i.length>0&&(ht.gs("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.ys(i[0].name,n,i[0].variants[n].transforms))}static bs(e){return!fe(e.conditions)&&ht.Ss(e)&&ht.ks(e)}static Ss(e){var n;if(fe(e.conditions)||fe((n=e.conditions)==null?void 0:n.url))return!0;var r,i,s,o=ht.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||AT[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return E==null?void 0:E.location}static ks(e){var n;if(fe(e.conditions)||fe((n=e.conditions)==null?void 0:n.utm))return!0;var r=Fw();if(r.utm_source){var i,s,o,a,l,u,c,f,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,h=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==r.utm_medium,g=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((f=e.conditions)==null||(f=f.utm)==null?void 0:f.utm_term)==r.utm_term;return d&&p&&g&&h}return!1}static gs(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];V.info("[WebExperiments] "+e,r)}ys(e,n,r){this._is_bot()?ht.gs("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach(i=>{if(i.selector){var s;ht.gs("applying transform of variant "+n+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o==null||o.forEach(a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):ht.gs("Control variants leave the page unmodified.")}_is_bot(){return Vt&&this._instance?Jw(Vt,this._instance.config.custom_blocked_useragents):void 0}}var IT=Ge("[PostHog ExternalIntegrations]"),FT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class LT{constructor(e){this._instance=e}nt(e,n){var r;(r=X.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,i=>{if(i)return IT.error("failed to load script",i);n()})}startIfEnabledOrStop(){var e=this,n=function(o){var a,l,u;!i||(a=X.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.nt(FT[o],()=>{var c;(c=X.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)}),!i&&(l=X.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=X.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;n(r)}}}var Nh="[SessionRecording]",ea=Ge(Nh);class DT{get started(){var e;return!((e=this.$s)==null||!e.isStarted)}get status(){var e;return((e=this.$s)==null?void 0:e.status)||"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.ni=void 0,this._instance=e,!this._instance.sessionManager)throw ea.error("started without valid sessionManager"),new Error(Nh+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Nh+' cannot be used with cookieless_mode="always"')}get Bt(){var e,n=!((e=this._instance.get_property(Bf))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return E&&n&&r&&!i}startIfEnabledOrStop(e){var n;if(!this.Bt||(n=this.$s)==null||!n.isStarted){var r=!L(Object.assign)&&!L(Array.from);this.Bt&&r?(this.xs(e),ea.info("starting")):this.stopRecording()}}xs(e){var n,r,i;this.Bt&&(X!=null&&(n=X.__PosthogExtensions__)!=null&&(n=n.rrweb)!=null&&n.record&&(r=X.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Ri(e):(i=X.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Ii,s=>{if(s)return ea.error("could not load recorder",s);this.Ri(e)}))}stopRecording(){var e;(e=this.$s)==null||e.stop()}ki(){var e;(e=this._instance.persistence)==null||e.unregister(ds)}Ei(e){if(this._instance.persistence){var n,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording,a=o==null?void 0:o.sampleRate,l=fe(a)?null:parseFloat(a);fe(l)&&this.ki();var u=o==null?void 0:o.minimumDurationMilliseconds;i.register({[Bf]:z({enabled:!!o},o,{networkPayloadCapture:z({capturePerformance:e.capturePerformance},o==null?void 0:o.networkPayloadCapture),canvasRecording:{enabled:o==null?void 0:o.recordCanvas,fps:o==null?void 0:o.canvasFps,quality:o==null?void 0:o.canvasQuality},sampleRate:l,minimumDurationMilliseconds:L(u)?null:u,endpoint:o==null?void 0:o.endpoint,triggerMatchType:o==null?void 0:o.triggerMatchType,masking:o==null?void 0:o.masking,urlTriggers:o==null?void 0:o.urlTriggers})})};s(),(n=this.ni)==null||n.call(this),this.ni=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?(this.Ei(e),this.startIfEnabledOrStop()):ea.info("skipping remote config with no sessionRecording",e)}log(e,n){var r;n===void 0&&(n="log"),(r=this.$s)!=null&&r.log?this.$s.log(e,n):ea.warn("log called before recorder was ready")}get Ii(){var e,n,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Bf);return(r==null||(n=r.scriptConfig)==null?void 0:n.script)||"lazy-recorder"}Ri(e){var n,r;if((n=X.__PosthogExtensions__)==null||!n.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.$s||(this.$s=(r=X.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.$s._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.$s.start(e)}onRRwebEmit(e){var n;(n=this.$s)==null||n.onRRwebEmit==null||n.onRRwebEmit(e)}overrideLinkedFlag(){var e;(e=this.$s)==null||e.overrideLinkedFlag()}overrideSampling(){var e;(e=this.$s)==null||e.overrideSampling()}overrideTrigger(e){var n;(n=this.$s)==null||n.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.$s)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,n){var r;return!((r=this.$s)==null||!r.tryAddCustomEvent(e,n))}}var ta={},jh=()=>{},bs="posthog",t1=!XR&&(Mt==null?void 0:Mt.indexOf("MSIE"))===-1&&(Mt==null?void 0:Mt.indexOf("Mozilla"))===-1,n1=t=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:B3(W==null?void 0:W.location),persistence:"localStorage+cookie",persistence_name:"",loaded:jh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:t!=="2025-05-24"||"history_change",capture_pageleave:"if_capture_pageview",defaults:t??"unset",debug:Pt&&je(Pt==null?void 0:Pt.search)&&Pt.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(E==null||(e=E.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;V.error(r)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Lh},error_tracking:{},_onCapture:jh,__preview_eager_load_replay:!0}},r1=t=>{var e={};L(t.process_person)||(e.person_profiles=t.process_person),L(t.xhr_headers)||(e.request_headers=t.xhr_headers),L(t.cookie_name)||(e.persistence_name=t.cookie_name),L(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),L(t.store_google)||(e.save_campaign_params=t.store_google),L(t.verbose)||(e.debug=t.verbose);var n=He({},e,t);return $e(t.property_blacklist)&&(L(t.property_denylist)?n.property_denylist=t.property_blacklist:$e(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:V.error("Invalid value for property_denylist config: "+t.property_denylist)),n};class NT{constructor(){this.__forceAllowLocalhost=!1}get Es(){return this.__forceAllowLocalhost}set Es(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Eu{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new NT,this.Rs=!1,this.version=tr.LIB_VERSION,this.Is=new Ih,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=n1(),this.SentryIntegration=HR,this.sentryIntegration=e=>function(n,r){var i=aw(n,r);return{name:ow,processEvent:s=>i(s)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ps=!1,this.Ts=null,this.Cs=null,this.Ms=null,this.featureFlags=new gT(this),this.toolbar=new BR(this),this.scrollManager=new CT(this),this.pageViewManager=new YR(this),this.surveys=new bT(this),this.experiments=new ht(this),this.exceptions=new ZR(this),this.rateLimiter=new xT(this),this.requestRouter=new OT(this),this.consent=new dR(this),this.externalIntegrations=new LT(this),this.people={set:(e,n,r)=>{var i=je(e)?{[e]:n}:e;this.setPersonProperties(i),r==null||r({})},set_once:(e,n,r)=>{var i=je(e)?{[e]:n}:e;this.setPersonProperties(void 0,i),r==null||r({})}},this.on("eventCaptured",e=>V.info('send "'+(e==null?void 0:e.event)+'"',e))}init(e,n,r){if(r&&r!==bs){var i,s=(i=ta[r])!==null&&i!==void 0?i:new Eu;return s._init(e,n,r),ta[r]=s,ta[bs][r]=s,s}return this._init(e,n,r)}_init(e,n,r){var i,s;if(n===void 0&&(n={}),L(e)||Ff(e))return V.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return V.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this.Os=n,this.Fs=[],n.person_profiles&&(this.Cs=n.person_profiles),this.set_config(He({},n1(n.defaults),r1(n),{name:r,token:e})),this.config.on_xhr_error&&V.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:ir.GZipJS;var o=this.As();this.persistence=new Oh(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Oh(z({},this.config,{persistence:"sessionStorage"}),o);var a=z({},this.persistence.props),l=z({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ds=new ST(y=>this.js(y),this.config.request_queue_config),this.Ls=new $T(this),this.__request_queue=[];var u=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(u||(this.sessionManager=new Xw(this),this.sessionPropsManager=new Qw(this,this.sessionManager,this.persistence)),new VR(this).startIfEnabledOrStop(),this.siteApps=new PT(this),(i=this.siteApps)==null||i.init(),u||(this.config.__preview_eager_load_replay?this.sessionRecording=new sw(this):this.sessionRecording=new DT(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new rR(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new KR(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new WR(this),this.exceptionObserver=new pR(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new j_(this,hR),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new gR(this),this.historyAutocapture.startIfEnabled(),tr.DEBUG=tr.DEBUG||this.config.debug,tr.DEBUG&&V.info("Starting in debug mode",{this:this,config:n,thisC:z({},this.config),p:a,s:l}),((s=n.bootstrap)==null?void 0:s.distinctID)!==void 0){var c,f,d=this.config.get_device_id(Ir()),h=(c=n.bootstrap)!=null&&c.isIdentifiedID?d:n.bootstrap.distinctID;this.persistence.set_property(rr,(f=n.bootstrap)!=null&&f.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:h})}if(this.Ns()){var p,g,w=Object.keys(((p=n.bootstrap)==null?void 0:p.featureFlags)||{}).filter(y=>{var b;return!((b=n.bootstrap)==null||(b=b.featureFlags)==null||!b[y])}).reduce((y,b)=>{var x;return y[b]=((x=n.bootstrap)==null||(x=x.featureFlags)==null?void 0:x[b])||!1,y},{}),m=Object.keys(((g=n.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter(y=>w[y]).reduce((y,b)=>{var x,k;return(x=n.bootstrap)!=null&&(x=x.featureFlagPayloads)!=null&&x[b]&&(y[b]=(k=n.bootstrap)==null||(k=k.featureFlagPayloads)==null?void 0:k[b]),y},{});this.featureFlags.receivedFeatureFlags({featureFlags:w,featureFlagPayloads:m})}if(u)this.register_once({distinct_id:jo,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(Ir());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(rr,"anonymous")}return Le(E,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?zR(this,()=>this.Us()):this.Us(),tn(this.config._onCapture)&&this.config._onCapture!==jh&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",y=>this.config._onCapture(y.event,y))),this.config.ip&&V.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Fe(e){var n,r,i,s,o,a,l,u;if(!W||!W.body)return V.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Fe(e)},500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=oe(e.supportedCompression,ir.GZipJS)?ir.GZipJS:oe(e.supportedCompression,ir.Base64)?ir.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Cs?this.Cs:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),(a=this.webVitalsAutocapture)==null||a.onRemoteConfig(e),(l=this.exceptionObserver)==null||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}Us(){try{this.config.loaded(this)}catch(e){V.critical("`loaded` function failed",e)}this.zs(),this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.Bs()},1),new kT(this).load(),this.featureFlags.flags()}zs(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ds)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Or(this.__request_queue,e=>this.js(e)),this.__request_queue=[],this.zs()}_handle_unload(){var e,n;this.config.request_batching?(this.qs()&&this.capture("$pageleave"),(e=this.Ds)==null||e.unload(),(n=this.Ls)==null||n.unload()):this.qs()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}Oe(e){this.__loaded&&(t1?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=yu(e.url,{ip:this.config.ip?1:0}),e.headers=z({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,i,s,o=z({},n);o.timeout=o.timeout||6e4,o.url=yu(o.url,{_:new Date().getTime().toString(),ver:tr.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=_u.filter(c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport)),u=(i=(s=n_(l,c=>c.transport===a))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!u)throw new Error("No available transport method");u(o)})(z({},e,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,n)),e.callback==null||e.callback(n)}}))))}js(e){this.Ls?this.Ls.retriableRequest(e):this.Oe(e)}_execute_array(e){var n,r=[],i=[],s=[];Or(e,a=>{a&&(n=a[0],$e(n)?s.push(a):tn(a)?a.call(this):$e(a)&&n==="alias"?r.push(a):$e(a)&&n.indexOf("capture")!==-1&&tn(this[n])?s.push(a):i.push(a))});var o=function(a,l){Or(a,function(u){if($e(u[0])){var c=l;be(u,function(f){c=c[f[0]].apply(c,f.slice(1))})}else this[u[0]].apply(this,u.slice(1))},l)};o(r,this),o(i,this),o(s,this)}Ns(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ds){if(this.is_capturing())if(!L(e)&&je(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var s=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){n!=null&&n.$current_url&&!je(n==null?void 0:n.$current_url)&&(V.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(r==null?void 0:r.timestamp)||o,l=Ir(),u={uuid:l,event:e,properties:this.calculateEventProperties(e,n||{},a,l)};s&&(u.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),r!=null&&r.$set&&(u.$set=r==null?void 0:r.$set);var c,f=this.Hs(r==null?void 0:r.$set_once);if(f&&(u.$set_once=f),(u=H3(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,L(r==null?void 0:r.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=o),e===Su.DISMISSED||e===Su.SENT){var d=n==null?void 0:n[Ww.SURVEY_ID],h=n==null?void 0:n[Ww.SURVEY_ITERATION];c={id:d,current_iteration:h},localStorage.getItem(Kw(c))||localStorage.setItem(Kw(c),"true"),u.$set=z({},u.$set,{[mT({id:d,current_iteration:h},e===Su.SENT?"responded":"dismissed")]:!0})}var p=z({},u.properties.$set,u.$set);if(us(p)||this.setPersonPropertiesForFlags(p),!fe(this.config.before_send)){var g=this.Ws(u);if(!g)return;u=g}this.Is.emit("eventCaptured",u);var w={method:"POST",url:(i=r==null?void 0:r._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r==null?void 0:r._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.js(w):this.Ds.enqueue(w),u}V.critical("This capture call is ignored due to client rate limiting.")}}else V.error("No event name provided to posthog.capture")}else V.uninitializedWarning("posthog.capture")}Ze(e){return this.on("eventCaptured",n=>e(n.event,n))}calculateEventProperties(e,n,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=s?void 0:this.persistence.remove_event_timer(e),a=z({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=z({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!je(a.distinct_id)&&!dt(a.distinct_id)||Ff(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=fT(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:f,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=f,a.$window_id=d}this.sessionPropsManager&&He(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&He(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.Ls)==null?void 0:h.length}catch(m){a.$sdk_debug_error_capturing_properties=String(m)}if(this.requestRouter.region===Jo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=He(a,u),e==="$pageview"&&W&&(a.title=W.title),!L(o)){var p=r.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Mt&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=He({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),$e(this.config.property_denylist)?be(this.config.property_denylist,function(m){delete a[m]}):V.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var g=this.config.sanitize_properties;g&&(V.error("sanitize_properties is deprecated. Use before_send instead"),a=g(a,e));var w=this.Gs();return a.$process_person_profile=w,w&&!s&&this.Vs("_calculate_event_properties"),a}Hs(e){var n;if(!this.persistence||!this.Gs()||this.Rs)return e;var r=this.persistence.get_initial_props(),i=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),s=He({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(V.error("sanitize_properties is deprecated. Use before_send instead"),s=o(s,"$set_once")),this.Rs=!0,us(s)?void 0:s}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var i;(i=this.persistence)==null||i.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Js(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.Is.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}displaySurvey(e,n){n===void 0&&(n=_T),this.surveys.displaySurvey(e,n)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return V.uninitializedWarning("posthog.identify");if(dt(e)&&(e=e.toString(),V.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))V.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==jo){if(this.Vs("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==i&&e!==this.get_property(Fo)&&(this.unregister(Fo),this.register({distinct_id:e}));var o=(this.persistence.get_property(rr)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(rr,"identified"),this.setPersonPropertiesForFlags(z({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:r||{}}),this.Ms=hw(e,n,r),this.featureFlags.setAnonymousDistinctId(i)):(n||r)&&this.setPersonProperties(n,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(eu))}}else V.critical('The string "'+jo+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else V.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.Vs("posthog.setPersonProperties")){var r=hw(this.get_distinct_id(),e,n);this.Ms!==r?(this.setPersonPropertiesForFlags(z({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Ms=r):V.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){if(this.Vs("posthog.group")){var i=this.getGroups();i[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:z({},i,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===n||r||this.reloadFeatureFlags()}}else V.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.Vs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,i,s;if(V.info("reset"),!this.__loaded)return V.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(rr,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Ms=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:jo,$device_id:null},"");else{var a=this.config.get_device_id(Ir());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(e,n){return e===this.get_property(r_)?(V.critical("Attempting to create alias for existing People user - aborting."),-2):this.Vs("posthog.alias")?(L(n)&&(n=this.get_distinct_id()),e!==n?(this.Js(Fo,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(V.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=z({},this.config);if(Ne(e)){var r,i,s,o,a;He(this.config,r1(e));var l=this.As();(r=this.persistence)==null||r.update_config(this.config,n,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Oh(z({},this.config,{persistence:"sessionStorage"}),l),Ke.G()&&Ke.J("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(tr.DEBUG=!0,V.info("set_config",{config:e,oldConfig:n,newConfig:z({},this.config)})),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),this.surveys.loadIfEnabled(),this.Ks(),(a=this.externalIntegrations)==null||a.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,s,o,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(z({},i,n))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:bs;return n!==bs&&(n=bs+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(rr))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(rr))==="identified"}Gs(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&us(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Fo])&&((n=this.persistence)==null||(n=n.props)==null||!n[nu]))}qs(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Gs()||this.Vs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Vs(e){return this.config.person_profiles==="never"?(V.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Js(nu,!0),!0)}As(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}Ks(){var e,n,r,i,s=this.As();return((e=this.persistence)==null?void 0:e.Ue)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((n=this.sessionPersistence)==null?void 0:n.Ue)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){if(this.config.cookieless_mode!=="always"){var n;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),this.sessionManager=new Xw(this),this.persistence&&(this.sessionPropsManager=new Qw(this,this.sessionManager,this.persistence)),this.sessionRecording=new sw(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.Ks(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(L(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((n=e==null?void 0:e.captureEventName)!==null&&n!==void 0?n:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Bs()}else V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Ks(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:jo,$device_id:null}),this.sessionManager=void 0,this.sessionPropsManager=void 0,(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,this.Bs())):V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===sr.GRANTED?"granted":e===sr.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Ks()}_is_bot(){return Vt?Jw(Vt,this.config.custom_blocked_useragents):void 0}Bs(){W&&(W.visibilityState==="visible"?this.Ps||(this.Ps=!0,this.capture("$pageview",{title:W.title},{send_instantly:!0}),this.Ts&&(W.removeEventListener("visibilitychange",this.Ts),this.Ts=null)):this.Ts||(this.Ts=this.Bs.bind(this),Le(W,"visibilitychange",this.Ts)))}debug(e){e===!1?(E==null||E.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(E==null||E.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}))}L(){var e,n,r,i,s,o,a,l=this.Os||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(V.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,s=V,o=(n="advanced_disable_flags")in(e=l)&&!L(e[n]),a=r in e&&!L(e[r]),o?e[n]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):i)}Ws(e){if(fe(this.config.before_send))return e;var n=$e(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),fe(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return g3(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!us(r.properties)||V.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.pe)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}}(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=z3(t.prototype[e[n]])})(Eu,["identify"]);var i1,zh=(i1=ta[bs]=new Eu,function(){function t(){t.done||(t.done=!0,t1=!1,be(ta,function(e){e._dom_loaded()}))}W!=null&&W.addEventListener?W.readyState==="complete"?t():Le(W,"DOMContentLoaded",t,{capture:!1}):E&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),i1);console.info("Vehicle Search powered by Partbot https://use.partbot.io");function na(t=[],e=[]){const n=[];return t.forEach(r=>{const[i,...s]=r.split(":"),o=s.join(":");if(o.includes(" > ")){const a=o.split(" > "),l=a[a.length-1].trim();if(i!=="make"&&a.length>=2){const u=a[0].trim();n.push(`make = "${u}"`)}n.push(`${i} = "${l}"`)}else n.push(`${i} = "${o}"`)}),e.forEach(r=>{n.push(r)}),n.length>0?n.join(" AND "):null}function Hh({apiKey:t,makes:e="",models:n="",callbackUrl:r="",layout:i="row",fields:s,fieldPrefix:o="",showBranding:a=!0,showLabels:l=!1,mobileFullWidthButton:u=!0,mobileDrawer:c=!0,modifyQueryString:f=!0,onChange:d,buttonLabel:h="Search",showButton:p=!0,onSubmit:g,store:w,useStoreVehicles:m=!0,fieldOrder:v="MMY",enableFeatureFlags:y=!1,yearOptional:b=!1,mobileButtonLabel:x="Select Vehicle"}){const k=_.useRef(null),$=_.useRef(null),C=_.useRef(null),H=_.useRef(null),M=_.useRef(null),U=_.useRef(null),q=_.useRef(null),B=_.useRef(null),K=_.useRef(!1),N=v==="YMM",[Z,ae]=_.useState([]),[R,A]=_.useState([]),[j,ne]=_.useState([]),[I,se]=_.useState([]),[ee,ge]=_.useState([]),[ie,Se]=_.useState([]),[ye,At]=_.useState([]),[sn,Oe]=_.useState([]),$u=_.useRef([]),[kn,xs]=_.useState([]),[S,It]=_.useState({make:null,model:null,year:null,body:null,series:null,variant:null,engine:null,engine_capacity:null}),[ia,Uh]=_.useState(!1),o1=_.useRef(["body","series","variant","engine","engine_capacity"]),Cu=_.useRef(s&&s.length&&o1.current?s.split(",").filter(T=>{var F;return(F=o1.current)==null?void 0:F.includes(T)}):null),[Sn,BT]=_.useState(!1);_.useEffect(()=>{const T=navigator.userAgent;BT(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(T)),zh.__loaded||zh.init("phc_mLZkVvweXDfwCPYS7kSCxoAxgQUkw8fgyDiplKnleGw",{api_host:"https://app.posthog.com",autocapture:!1,capture_pageview:!1,capture_pageleave:!1,disable_session_recording:!1})},[]);const[xi,qT]=_.useState({}),[uP,VT]=_.useState(""),a1=_.useCallback(async()=>{if(!t)return;const F=`${y?"https://api.cartbot.io":"https://api.partbot.io"}/v1/vehicles/auth`;try{const Q=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,referrerPolicy:"no-referrer"},body:JSON.stringify((()=>{const ve={use_store_vehicles:m};return w&&(ve.store=w),ve})())});if(!Q.ok)throw new Error(`Error: ${Q.status} ${Q.statusText}`);const{merchant:D,vehicle_makes:te,vehicle_models:J,meilisearch_search_key:pe,meilisearch_index_name:ke,algolia_search_key:qe,algolia_index_name:ks,store_index_name:ki,store_popular_makes:_e,store_popular_models:Ye}=await Q.json();$.current=D,C.current=(te||[]).map(ve=>({...ve,refinement:ve.value})),H.current=m&&Array.isArray(J)?J.map(ve=>ve&&ve.value?String(ve.value).trim():"").filter(Boolean):[],M.current=Array.isArray(_e)?_e.map(ve=>String(ve).trim().toUpperCase()):null,console.log("[VehicleSearch] PostHog popular makes:",M.current),U.current=Ye||null,console.log("[VehicleSearch] PostHog popular models:",U.current),qT({searchKey:"f0be4e6a192a51ad360e4f5886be389d34334bb930bb32e5cd6d32ceddba17ff",indexName:"otto_v1_vehicles_production",storeIndexName:ki||"shopify_partbot-app-test_development"})}catch(Q){console.error("[VehicleSearch] Auth failed:",Q),VT(Q)}},[t,w,m,y]);_.useEffect(()=>{a1()},[a1]),_.useEffect(()=>{if(xi.searchKey){try{q.current=new H2({host:"https://search.partbot.io",apiKey:xi.searchKey}),B.current=q.current.index(xi.indexName)}catch(T){console.error("[VehicleSearch] Failed to initialize Meilisearch:",T)}return()=>{q.current=null}}},[xi.searchKey,t]);const[on,WT]=_.useState(!1),l1=_.useCallback(()=>{function T(J){if(!J)return"rgba(0,0,0,1)";var pe=F(),ke=window.getComputedStyle(J).backgroundColor;return ke!==pe?ke:J.parentElement?T(J.parentElement):"rgba(255,255,255,1)"}function F(){var J=document.createElement("div");document.head.appendChild(J);var pe=window.getComputedStyle(J).backgroundColor;return document.head.removeChild(J),pe}const Q=document.querySelector("vehicle-search");let D;Q?D=T(Q):D=T(k.current);const te=Y(D).isDark();WT(te)},[]);_.useEffect(()=>{async function T(){if(!S.make||!B.current)return;let F=[],Q=[];S.make&&F.push(`make:${S.make.refinement}`),S.model&&F.push(`model:${S.make.refinement} > ${S.model.refinement}`),S.year&&(Q=[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]),S.body&&F.push(`body:${S.make.refinement} > ${S.model.refinement} > ${S.body.refinement}`),S.series&&F.push(`series:${S.series.refinement}`),S.engine&&F.push(`engine:${S.engine.refinement}`),S.engine_capacity&&F.push(`engine_capacity:${S.engine_capacity.refinement}`);let te=(await B.current.search("",{filter:na(F,Q),attributesToRetrieve:["otto_id"],limit:500})).hits.map(ke=>ke.otto_id);xs(te);let pe={...Object.fromEntries(Object.entries(S||{}).map(([ke,qe])=>[ke,qe&&qe.value||null]).filter(([ke,qe])=>qe!==null)),merchant:$.current};zh.capture("vehicle select",pe)}T()},[S,B,b]);const Bh=T=>o?`${o}${T}`:T,GT=T=>o?T.replace(new RegExp(`^${o}`),""):T,KT=_.useCallback(()=>{const T=new URL(window.location.href).searchParams,F=["make","model","year","body","series","engine","engine_capacity"].map(Bh),Q=Object.fromEntries([...T.entries()].filter(([D])=>F.includes(D)).map(([D,te])=>[GT(D),{value:te,refinement:te}]));It(Q)},[]),pt=_.useCallback(({query:T,value:F,remove:Q})=>{if(f&&"URLSearchParams"in window){let D=new URLSearchParams(window.location.search);T=Bh(T),T&&F&&D.set(T,F),T&&!F&&D.delete(T),Q&&Q.forEach(J=>{J=Bh(J),D.delete(J)});const te=window.location.pathname+"?"+D.toString();window.history.pushState(null,"",te)}},[]),YT=_.useCallback(()=>{var Q;const T={vehicle_ids:kn,vehicle:(Q=S==null?void 0:S.make)!=null&&Q.value?S:{}};g&&g(T);const F=new CustomEvent("vehicle-search-submit",{detail:T});document.dispatchEvent(F),setTimeout(()=>{Uh(!1)},900)},[kn,g]),u1=_.useCallback(()=>{var Q,D,te,J,pe,ke,qe,ks,ki;const T={vehicle_ids:kn,vehicle:(Q=S==null?void 0:S.make)!=null&&Q.value?S:{}};d&&d(T);const F=new CustomEvent("vehicle-search-change",{detail:T});if(K.current===!0&&!localStorage.getItem("partbot_plate_details")){const _e=JSON.stringify({description:`${((D=S.make)==null?void 0:D.value)||""} ${((te=S.model)==null?void 0:te.value)||""} ${((J=S.year)==null?void 0:J.value)||""} ${((pe=S.body)==null?void 0:pe.value)||""} ${((ke=S.series)==null?void 0:ke.value)||""} ${((qe=S.variant)==null?void 0:qe.value)||""} ${((ks=S.engine)==null?void 0:ks.value)||""} ${((ki=S.engine_capacity)==null?void 0:ki.value)||""}`.trim(),vehicle_ids:kn,vehicle:S?Object.entries(S).reduce((Ye,[ve,jr])=>(Ye[ve]=jr!=null&&jr.value?jr.value:{},Ye),{}):{}});localStorage.setItem("partbot_selected_vehicle",_e),Vx.set("partbot_selected_vehicle",_e,{secure:!0})}document.dispatchEvent(F),$u.current=kn,setTimeout(()=>{Uh(!1)},900)},[kn,d]),Ru=_.useMemo(()=>HC(u1,100),[u1]);_.useEffect(()=>{Ru()},[kn,Ru]),_.useEffect(()=>()=>{Ru.cancel()},[Ru]),_.useEffect(()=>{xi.searchKey&&(N||tP(),KT())},[xi.searchKey,N]),_.useEffect(()=>{N&&B.current&&j.length===0&&!S.year&&(console.log("[VehicleSearch] YMM mode: Loading year range from dataset..."),B.current.search("",{attributesToRetrieve:["year_from","year_to"],limit:1e4}).then(({hits:T})=>{console.log("[VehicleSearch] YMM mode: Fetched",T.length,"hits for year range");const F=T.map(pe=>pe.year_from).filter(Boolean),Q=T.map(pe=>pe.year_to).filter(Boolean),D=Math.min(...F),te=Math.max(...Q);console.log("[VehicleSearch] YMM mode: Year range:",D,"-",te);const J=Array.from({length:te-D+1},(pe,ke)=>({value:D+ke,refinement:D+ke})).reverse();console.log("[VehicleSearch] YMM mode: Setting",J.length,"years"),ne(J)}).catch(T=>{console.error("[VehicleSearch] Error loading year range:",T)}))},[N,xi.searchKey,j.length,S.year]),_.useEffect(()=>{typeof document>"u"||l1()},[l1]);const c1=_.useCallback(T=>{K.current=!0,A([]),!N&&!b&&ne([]),se([]),ge([]),Se([]),Oe([]),At([]),It(F=>({make:T,year:N||b?F.year:null})),pt({query:"make",value:(T==null?void 0:T.value)??"",remove:N?["model","body","series","engine","variant","engine_capacity"]:b?["model","body","series","engine","variant","engine_capacity"]:["model","year","body","series","engine","variant","engine_capacity"]}),T||xs([])},[pt,N,b]),d1=_.useCallback(T=>{K.current=!0,It(F=>({...F,model:T!==""?T:null,year:N||b?F.year:null,body:null,series:null,variant:null,engine:null,engine_capacity:null})),!N&&!b&&ne([]),se([]),ge([]),Se([]),Oe([]),At([]),pt({query:"model",value:(T==null?void 0:T.value)??"",remove:N?["body","series","engine","variant","engine_capacity"]:b?["body","series","engine","variant","engine_capacity"]:["year","body","series","engine","variant","engine_capacity"]})},[pt,N,b]),f1=_.useCallback(T=>{K.current=!0,N?(ae([]),A([]),It({year:T!==""?T:null}),(!T||T==="")&&ne([])):It(b?F=>({...F,year:T!==""?T:null}):F=>({...F,year:T!==""?T:null,body:null,series:null,variant:null,engine:null,engine_capacity:null})),b||(se([]),ge([]),Se([]),Oe([]),At([])),pt({query:"year",value:(T==null?void 0:T.value)??"",remove:N?["make","model","body","series","variant","engine","engine_capacity"]:b?[]:["body","series","variant","engine","engine_capacity"]}),!b&&(!T||T==="")&&xs([])},[pt,N,b]),QT=_.useCallback(T=>{K.current=!0,It(F=>({...F,body:T!==""?T:null})),pt({query:"body",value:(T==null?void 0:T.value)??""})},[pt]),XT=_.useCallback(T=>{K.current=!0,It(F=>({...F,series:T!==""?T:null})),pt({query:"series",value:(T==null?void 0:T.value)??""})},[pt]),ZT=_.useCallback(T=>{K.current=!0,It(F=>({...F,variant:T!==""?T:null})),pt({query:"variant",value:(T==null?void 0:T.value)??""})},[pt]),JT=_.useCallback(T=>{K.current=!0,It(F=>({...F,engine:T!==""?T:null})),pt({query:"engine",value:(T==null?void 0:T.value)??""})},[pt]),eP=_.useCallback(T=>{K.current=!0,It(F=>({...F,engine_capacity:T!==""?T:null})),pt({query:"engine_capacity",value:(T==null?void 0:T.value)??""})},[pt]);_.useEffect(()=>{N&&S.year&&B.current&&(async()=>{try{const F=await B.current.search("",{filter:`year_from <= ${S.year.value} AND year_to >= ${S.year.value}`,attributesToRetrieve:["make","make_popularity"],limit:1e4}),Q=new Map;F.hits.forEach(J=>{J.make&&!Q.has(J.make)&&Q.set(J.make,{value:J.make.toUpperCase(),refinement:J.make.toUpperCase(),popularity:J.make_popularity||0})});let D=Array.from(Q.values());const te=new Set(M.current||[]);te.size>0?D.sort((J,pe)=>{const ke=te.has(J.value),qe=te.has(pe.value);return ke&&!qe?-1:!ke&&qe?1:ke&&qe?M.current.indexOf(J.value)-M.current.indexOf(pe.value):J.value.localeCompare(pe.value)}):D.sort((J,pe)=>pe.popularity===J.popularity?J.value.localeCompare(pe.value):pe.popularity-J.popularity),ae(D)}catch(F){console.error("[VehicleSearch] Error loading makes for year:",F)}})()},[N,S.year]);const tP=_.useCallback(()=>{(async()=>{let F=[];if(C.current&&C.current.length)F=C.current;else if(B.current)try{const Q=await B.current.search("",{attributesToRetrieve:["make","make_popularity"],limit:1e3}),D=new Map;Q.hits.forEach(te=>{te.make&&!D.has(te.make)&&D.set(te.make,{value:te.make.toUpperCase(),refinement:te.make.toUpperCase(),popularity:te.make_popularity||0})}),F=Array.from(D.values())}catch(Q){console.error("[VehicleSearch] Error loading makes:",Q)}if(e&&F.length){const Q=e.trim().split(",").map(D=>D.trim().toUpperCase());F=F.filter(D=>Q.includes(D.value))}if(M.current&&M.current.length>0){const Q=new Set(M.current);F.sort((D,te)=>{const J=Q.has(D.value),pe=Q.has(te.value);return J&&!pe?-1:!J&&pe?1:J&&pe?M.current.indexOf(D.value)-M.current.indexOf(te.value):D.value.localeCompare(te.value)})}else F.sort((Q,D)=>Q.popularity===D.popularity?Q.value.localeCompare(D.value):D.popularity-Q.popularity);ae(F)})()},[e]);_.useEffect(()=>{if(B.current&&S.make&&S.make.refinement&&t){let T=[`make:${S.make.refinement}`],F=[];N&&S.year&&(F=[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]);const Q=na(T,F);console.log("[VehicleSearch] Fetching models with filter:",Q),B.current.search("",{filter:Q,attributesToRetrieve:["model","model_popularity","otto_id"],limit:1e3}).then(({hits:D})=>{var ks,ki;console.log("[VehicleSearch] Models search returned hits:",D.length);const te=Array.isArray(H.current)?H.current:typeof H.current=="string"&&H.current.length?H.current.split(",").map(_e=>_e.trim()).filter(Boolean):[];let J=te;if(n){const _e=n.trim().split(",").map(ve=>ve.trim()).filter(Boolean),Ye=new Set(_e.map(ve=>ve.toLowerCase()));J=te.length?te.filter(ve=>Ye.has(String(ve).toLowerCase())):_e,D=D.filter(ve=>Ye.has(ve.model.match(/[^>]*$/)[0].trim().toLowerCase()))}if(J&&J.length>0){const _e=new Set(J.map(ve=>String(ve).toLowerCase()));D.some(ve=>_e.has(ve.model.match(/[^>]*$/)[0].trim().toLowerCase()))&&(D=D.filter(ve=>_e.has(ve.model.match(/[^>]*$/)[0].trim().toLowerCase())))}let pe=new Set;D=D.filter(_e=>_e.model&&_e.model!==""&&!pe.has(_e.model)&&_e.model.match(/[^>]*$/)[0].trim()!==""?(pe.add(_e.model),!0):!1),D=D.map(_e=>({value:_e.model.match(/[^>]*$/)[0].trim(),refinement:_e.model.match(/[^>]*$/)[0].trim(),popularity:_e.model_popularity}));const ke=(ks=S.make)==null?void 0:ks.refinement,qe=(ki=U.current)==null?void 0:ki[ke];if(qe&&Array.isArray(qe)&&qe.length>0){const _e=new Set(qe.map(Ye=>String(Ye).trim().toUpperCase()));D.sort((Ye,ve)=>{const jr=_e.has(Ye.value),Vh=_e.has(ve.value);if(jr&&!Vh)return-1;if(!jr&&Vh)return 1;if(jr&&Vh){const h1=qe.map(rP=>String(rP).trim().toUpperCase());return h1.indexOf(Ye.value)-h1.indexOf(ve.value)}return Ye.value.localeCompare(ve.value)})}else D.sort((_e,Ye)=>_e.popularity===Ye.popularity?_e.value.localeCompare(Ye.value):Ye.popularity-_e.popularity);A(D)}).catch(D=>{console.error("[VehicleSearch] Error loading models:",D),A([])})}else A([])},[S.make,n,t,N,S.year]),_.useEffect(()=>{if(B.current&&S.make&&S.model){console.log("[VehicleSearch] Fetching year range for:",S.make.refinement,">",S.model.refinement);let T=[`model:${S.make.refinement} > ${S.model.refinement}`];b&&(S.body&&T.push(`body:${S.make.refinement} > ${S.model.refinement} > ${S.body.refinement}`),S.series&&T.push(`series:${S.series.refinement}`),S.engine&&T.push(`engine:${S.engine.refinement}`),S.engine_capacity&&T.push(`engine_capacity:${S.engine_capacity.refinement}`)),B.current.search("",{filter:na(T,[]),attributesToRetrieve:["year_from","year_to","otto_id"],limit:200}).then(({hits:F})=>{console.log("[VehicleSearch] Year search returned hits:",F.length);const Q=F.map(ke=>ke.year_from),D=Math.min(...Q),te=F.map(ke=>ke.year_to),J=Math.max(...te);let pe=Array.apply(null,{length:J+1-D}).map(function(ke,qe){return qe+D});pe=pe.reverse().map(ke=>({value:ke,refinement:ke})),ne(pe)}).catch(F=>{console.error("[VehicleSearch] Error fetching years:",F)})}},[S.model,S.make,N,b,S.body,S.series,S.engine,S.engine_capacity]),_.useEffect(()=>{const T=b?S.make&&S.model:S.year&&S.make&&S.model;if(B.current&&T){const F=S.year?[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]:[];B.current.search("",{filter:na([`model:${S.make.refinement} > ${S.model.refinement}`],F),attributesToRetrieve:["body","otto_id"],limit:1e3}).then(({hits:Q})=>{Q=[...new Map(Q.map(D=>[D.body,D])).values()].map(D=>({value:D.body.match(/[^>]*$/)[0].trim(),refinement:D.body.match(/[^>]*$/)[0].trim()})).filter(D=>D.value),se(Q)})}},[S.year,S.make,S.model,b]);const sa=_.useCallback(({hits:T,attribute:F,stateCallback:Q})=>{let D=[...new Map(T.map(te=>[te[F],te])).values()].map(te=>({value:te[F].match(/[^|]*$/)[0].trim(),refinement:te[F].match(/[^|]*$/)[0].trim()})).filter(te=>te.refinement);Q(D)},[]),nP=_.useCallback(()=>{const T=Cu.current?Cu.current.length+3:3,F=p?T+1:T;return`vs:lg:grid-cols-${F>8?8:F}`},[p]);_.useEffect(()=>{const T=b?S.make&&S.model:S.make&&S.model&&S.year;if(B.current&&T){let F=[`make:${S.make.refinement}`,`model:${S.make.refinement} > ${S.model.refinement}`,S.body?`body:${S.make.refinement} > ${S.model.refinement} > ${S.body.refinement}`:"",S.series?`series:${S.series.refinement}`:"",S.variant?`variant:${S.variant.refinement}`:"",S.engine?`engine:${S.engine.refinement}`:"",S.engine_capacity?`engine_capacity:${S.engine_capacity.refinement}`:""].filter(D=>D);const Q=S.year?[`year_from <= ${S.year.value}`,`year_to >= ${S.year.value}`]:[];B.current.search("",{filter:na(F,Q),attributesToRetrieve:["series","engine_capacity","engine","cylinders","variant","otto_id"],limit:1e3}).then(({hits:D})=>{sa({hits:D,attribute:"series",stateCallback:ge}),sa({hits:D,attribute:"variant",stateCallback:Se}),sa({hits:D,attribute:"engine",stateCallback:At}),sa({hits:D,attribute:"engine_capacity",stateCallback:Oe})})}},[S.body,S.series,S.variant,S.engine,S.engine_capacity,sa,S.make,S.model,S.year,b]);const[Tu,qh]=_.useState(!1);return _.useEffect(()=>{if(c)return Tu?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}},[Tu,c]),O.jsxs(O.Fragment,{children:[c&&O.jsx("button",{onClick:()=>qh(!0),type:"button",className:Rr("vehicle-search-btn vs:md:hidden!",u?"vs:w-full! vs:flex! vs:shrink-0!":"vs:w-auto! vs:inline-flex! vs:shrink!"),children:O.jsx("span",{children:x})}),c&&O.jsx("div",{onClick:()=>qh(!1),className:Rr("vs:z-10 vs:fixed vs:inset-0 vs:bg-stone-900 vs:transition-all vs:duration-300",Tu?"vs:opacity-75":"vs:pointer-events-none vs:opacity-0")}),O.jsxs("div",{className:Rr("partbot-mmyvs-container",c&&Tu&&"active","w-full"),children:[c&&O.jsxs("div",{className:"vs:flex vs:justify-between vs:items-center vs:pb-4 vs:font-bold vs:text-white vs:md:hidden",children:[O.jsx("span",{children:"Select Vehicle"}),O.jsxs("button",{onClick:()=>qh(!1),type:"button",className:"vs:appearance-none vs:bg-transparent vs:border-none vs:ring-none vs:outline-none vs:hover:border-none vs:hover:ring-none vs:hover:outline-none",children:[O.jsx("span",{className:"vs:sr-only",children:"Close vehicle selection"}),O.jsx("span",{className:"vs:h-5 vs:w-5 vs:text-white",children:O.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 256 256",className:"vs:h-5 vs:w-5",children:O.jsx("path",{d:"M208.49,191.51a12,12,0,0,1-17,17L128,145,64.49,208.49a12,12,0,0,1-17-17L111,128,47.51,64.49a12,12,0,0,1,17-17L128,111l63.51-63.52a12,12,0,0,1,17,17L145,128Z"})})})]})]}),O.jsxs("div",{ref:k,className:Rr("vs:grid vs:gap-3",i==="row"?`${nP()} vs:grid-cols-1 vs:md:grid-cols-3`:"vs:grid-cols-1 vs:md:max-w-[400px] vs:md:gap-5","vs:w-full vs:transition vs:lg:mx-auto"),children:[N?O.jsxs(O.Fragment,{children:[O.jsx(mn,{label:"Year",items:j,refine:f1,selected:S.year,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:j.length===0}),O.jsx(mn,{label:"Make",items:Z,refine:c1,selected:S.make,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.year&&Z.length===0}),O.jsx(mn,{label:"Model",items:R,refine:d1,selected:S.model,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.make&&R.length===0})]}):O.jsxs(O.Fragment,{children:[O.jsx(mn,{label:"Make",items:Z,refine:c1,selected:S.make,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:Z.length===0}),O.jsx(mn,{label:"Model",items:R,refine:d1,selected:S.model,showPopular:!0,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.make&&R.length===0}),O.jsx(mn,{label:"Year",items:j,refine:f1,selected:S.year,bgDark:on,showLabel:l,isMobile:Sn,sortOptions:!1,loading:S.model&&j.length===0})]}),Cu.current&&Cu.current.map(T=>{let F=null;switch(T){case"body":F=O.jsx(mn,{label:"Body",items:I,refine:QT,selected:S.body,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"body");break;case"series":F=O.jsx(mn,{label:"Series",items:ee,refine:XT,selected:S.series,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"series");break;case"variant":F=O.jsx(mn,{label:"Variant",items:ie,refine:ZT,selected:S.variant,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"variant");break;case"engine_capacity":F=O.jsx(mn,{label:"Engine Capacity",items:sn,refine:eP,selected:S.engine_capacity,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"engine_capacity");break;case"engine":F=O.jsx(mn,{label:"Engine",items:ye,refine:JT,selected:S.engine,bgDark:on,showLabel:l,isMobile:Sn,loading:!1,shouldBeActive:!!(S.make&&S.model&&S.year)},"engine");break}return F}),p&&O.jsx("div",{className:"vs:flex vs:h-full vs:flex-col vs:justify-end vs:md:col-span-3 vs:lg:col-span-1",children:O.jsxs("button",{className:"vehicle-search-btn",onClick:()=>{Uh(!0),r&&!g?window.location.href=r+window.location.search:YT()},children:[O.jsx("span",{children:h}),ia&&O.jsx(Rf,{className:"vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin"})]})})]}),a&&O.jsx("div",{className:Rr("vs:flex vs:w-full vs:justify-center vs:items-center",i==="row"?"vs:md:items-end vs:md:justify-end":"vs:md:justify-center","vs:mt-4 vs:md:mt-3 vs:md:pr-1.5"),children:O.jsxs("a",{href:`https://use.partbot.io/?ref=${typeof window<"u"?window.location.href.split("/")[2]:"unknown"}&utm_source=vehicle-select&utm_medium=referral&utm_campaign=powered-by`,target:"_blank",rel:"noreferrer",className:`${on?"vs:text-white":"vs:text-black"} vs:flex vs:items-center vs:space-x-1.5 vs:px-1.5 vs:text-center vs:leading-normal vs:text-[10px] vs:opacity-75 vs:transition vs:hover:opacity-100 vs:font-sans vs:no-underline vs:m-0 pb-1.5`,children:[O.jsx("span",{children:"Powered by"}),O.jsx(Wx,{className:"vs:inline-flex vs:h-[13px]"})]})})]})]})}let s1=!1,ra=!1;function jT(t){var c,f;const e=t.shadowRoot;if(!e){console.error("[ShadowDOMPatch] No shadow root found");return}const n=e.children[1];if(!n){console.error("[ShadowDOMPatch] No mount point found in shadow root");return}if(new MutationObserver(d=>{d.forEach(h=>{h.addedNodes.forEach(p=>{p.nodeType===1&&p.id==="headlessui-portal-root"&&(n.appendChild(p),ra=!0)})}),d.forEach(h=>{h.removedNodes.forEach(p=>{p.nodeType===1&&p.id==="headlessui-portal-root"&&(n.querySelector("#headlessui-portal-root")||(ra=!1))})})}).observe(document.body,{childList:!0}),new MutationObserver(d=>{d.forEach(h=>{h.removedNodes.forEach(p=>{p.nodeType===1&&p.id==="headlessui-portal-root"&&(ra=!1)})})}).observe(n,{childList:!0,subtree:!0}),s1)return;const s=(c=Object.getOwnPropertyDescriptor(Document.prototype,"activeElement"))==null?void 0:c.get;Object.defineProperty(Document.prototype,"activeElement",{get:function(){const d=s==null?void 0:s.call(this);return d===t?e.activeElement:d}});const o=(f=Object.getOwnPropertyDescriptor(Event.prototype,"target"))==null?void 0:f.get;Object.defineProperty(Event.prototype,"target",{get:function(){const d=o==null?void 0:o.call(this);return d===t?this.composedPath()[0]:d}});const a=d=>{try{return document.body&&d===document.body.style}catch{return!1}},l=CSSStyleDeclaration.prototype.setProperty;CSSStyleDeclaration.prototype.setProperty=function(d,h,p){if(!(a(this)&&d==="overflow"&&h==="hidden"&&ra))return l.call(this,d,h,p)};const u=Object.getOwnPropertyDescriptor(CSSStyleDeclaration.prototype,"overflow");u&&Object.defineProperty(CSSStyleDeclaration.prototype,"overflow",{get:function(){return u.get.call(this)},set:function(d){if(!(a(this)&&d==="hidden"&&ra))return u.set.call(this,d)}}),s1=!0}const zT="/css/vehicle-search.css";class HT extends HTMLElement{connectedCallback(){if(!document.getElementById("vehicle-search-inter-font")){const U=document.createElement("link");U.id="vehicle-search-inter-font",U.rel="stylesheet",U.href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap",document.head.appendChild(U)}let e=document.createElement("style");e.textContent=Bx;const n=document.createElement("div"),r=this.attachShadow({mode:"open"}),i=(U,q,B)=>{let K;if(this.hasAttribute(q)){const N=this.getAttribute(q);if(/^#[0-9A-F]{6}$/i.test(N)){const Z=parseInt(N.slice(1,3),16),ae=parseInt(N.slice(3,5),16),R=parseInt(N.slice(5,7),16);K=`${Z} ${ae} ${R}`}}return K=K||B,`:host { --${U}: ${K}; } .partbot-mmyvs-container { --${U}: ${K}; }`};let s=i("partbot-theme","data-button-color","0 0 0"),o=i("partbot-button-color","data-button-color","0 0 0"),a=i("partbot-button-hover-color","data-button-hover-color","0 0 0"),l=i("partbot-button-label-color","data-button-label-color","255 255 255"),u=i("partbot-button-hover-label-color","data-button-hover-label-color","255 255 255"),c=i("partbot-mobile-background-color","data-mobile-background-color","0 0 0"),f=`:host { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius")||"0.375rem"}; } .partbot-mmyvs-container { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius")||"0.375rem"}; }`,d=`:host { --partbot-font-size: ${this.getAttribute("data-font-size")||"0.875rem"}; } .partbot-mmyvs-container { --partbot-font-size: ${this.getAttribute("data-font-size")||"0.875rem"}; }`,h=`:host { --partbot-font-family: ${(this.getAttribute("data-font-family")||this.getAttribute("data-font"))&&(this.getAttribute("data-font-family")||this.getAttribute("data-font")).trim()!==""?this.getAttribute("data-font-family")||this.getAttribute("data-font"):'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}; } .partbot-mmyvs-container { --partbot-font-family: ${(this.getAttribute("data-font-family")||this.getAttribute("data-font"))&&(this.getAttribute("data-font-family")||this.getAttribute("data-font")).trim()!==""?this.getAttribute("data-font-family")||this.getAttribute("data-font"):'"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}; }`,p=`:host { --partbot-padding: ${this.getAttribute("data-padding")||"0.5rem"}; } .partbot-mmyvs-container { --partbot-padding: ${this.getAttribute("data-padding")||"0.5rem"}; }`;const g=this.getAttribute("data-input-shadow"),w=g==="none"?"none":g||"0 1px 2px 0 rgb(0 0 0 / 0.05)";let m=`:host { --partbot-input-shadow: ${w}; } .partbot-mmyvs-container { --partbot-input-shadow: ${w}; }`;const v=this.getAttribute("data-input-border-color");let y="229 231 235";if(v)if(/^#[0-9A-F]{6}$/i.test(v)){const U=parseInt(v.slice(1,3),16),q=parseInt(v.slice(3,5),16),B=parseInt(v.slice(5,7),16);y=`${U} ${q} ${B}`}else/^\d+\s+\d+\s+\d+$/.test(v)&&(y=v);let b=`:host { --partbot-input-border-color: ${y}; } .partbot-mmyvs-container { --partbot-input-border-color: ${y}; }`;const x=this.getAttribute("data-input-border-width")||"1px";let k=`:host { --partbot-input-border-width: ${x}; } .partbot-mmyvs-container { --partbot-input-border-width: ${x}; }`;e.textContent+=s,e.textContent+=o,e.textContent+=a,e.textContent+=l,e.textContent+=u,e.textContent+=c,e.textContent+=f,e.textContent+=d,e.textContent+=h,e.textContent+=p,e.textContent+=m,e.textContent+=b,e.textContent+=k,r.appendChild(e),r.appendChild(n);const $=this.getAttribute("data-api-key");if(!$){console.warn("Missing attributes: "+($?"":"data-api-key "));return}const C=this.attributes,H={};for(let U=0;U<C.length;U++){const{name:q,value:B}=C[U];if(q.startsWith("data-")){const K=q.slice(5).replace(/-([a-z])/g,N=>N[1].toUpperCase());H[K]=B==="true"?!0:B==="false"?!1:B}}jT(this);const M=O.jsx(Hh,{...H});Ux.render(M,n)}}customElements.define("vehicle-search",HT);const UT=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));kt.VehicleSearch=Hh,kt.default=Hh,kt.vehicleSearchCssUrl=zT,Object.defineProperties(kt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|