@payment-kit-js/vanilla 0.5.7 → 0.5.9

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.
@@ -1,14 +1,14 @@
1
1
  /**
2
- * PaymentKit.js v0.5.7
2
+ * PaymentKit.js v0.5.9
3
3
  * https://paymentkit.com
4
4
  *
5
5
  * @license MIT
6
6
  */
7
7
 
8
- "use strict";var PaymentKit=(()=>{var cr=Object.defineProperty;var sl=Object.getOwnPropertyDescriptor;var ol=Object.getOwnPropertyNames;var al=Object.prototype.hasOwnProperty;var hs=n=>{throw TypeError(n)};var ll=(n,e,t)=>e in n?cr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ul=(n,e)=>{for(var t in e)cr(n,t,{get:e[t],enumerable:!0})},cl=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ol(e))!al.call(n,i)&&i!==t&&cr(n,i,{get:()=>e[i],enumerable:!(r=sl(e,i))||r.enumerable});return n};var pl=n=>cl(cr({},"__esModule",{value:!0}),n);var R=(n,e,t)=>ll(n,typeof e!="symbol"?e+"":e,t),fs=(n,e,t)=>e.has(n)||hs("Cannot "+t);var M=(n,e,t)=>(fs(n,e,"read from private field"),t?t.call(n):e.get(n)),Z=(n,e,t)=>e.has(n)?hs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),_e=(n,e,t,r)=>(fs(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);var cp={};ul(cp,{PaymentMethods:()=>up,default:()=>lp});var gs="0.5.7";var It=class{constructor(){R(this,"events",[]);R(this,"distinctId",null)}identify(e){this.distinctId=e}capture(e,t){this.events.push({event:e,distinct_id:this.distinctId,properties:t,timestamp:Date.now()})}isInitialized(){return!0}getEvents(){return[...this.events]}getEventsByName(e){return this.events.filter(t=>t.event===e)}clear(){this.events=[]}};var g=typeof window<"u"?window:void 0,W=typeof globalThis<"u"?globalThis:g;typeof self>"u"&&(W.self=W),typeof File>"u"&&(W.File=function(){});var po=Array.prototype,vs=po.forEach,ys=po.indexOf,le=W?.navigator,_=W?.document,B=W?.location,kn=W?.fetch,wn=W!=null&&W.XMLHttpRequest&&"withCredentials"in new W.XMLHttpRequest?W.XMLHttpRequest:void 0,ms=W?.AbortController,se=le?.userAgent,I=g??{},Se={DEBUG:!1,LIB_VERSION:"1.341.0"};function _s(n,e,t,r,i,s,o){try{var a=n[s](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(r,i)}function pt(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(l){_s(s,r,i,o,a,"next",l)}function a(l){_s(s,r,i,o,a,"throw",l)}o(void 0)})}}function E(){return E=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},E.apply(null,arguments)}function ho(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var hl=["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"],bs=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return hl.concat(e).some(r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1})},fl=["$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 A(n,e){return n.indexOf(e)!==-1}var Gr=function(n){return n.trim()},En=function(n){return n.replace(/^\$/,"")},gl=Array.isArray,fo=Object.prototype,go=fo.hasOwnProperty,Lr=fo.toString,$=gl||function(n){return Lr.call(n)==="[object Array]"},Le=n=>typeof n=="function",z=n=>n===Object(n)&&!$(n),dt=n=>{if(z(n)){for(var e in n)if(go.call(n,e))return!1;return!0}return!1},b=n=>n===void 0,H=n=>Lr.call(n)=="[object String]",xn=n=>H(n)&&n.trim().length===0,ye=n=>n===null,T=n=>b(n)||ye(n),Te=n=>Lr.call(n)=="[object Number]"&&n==n,ut=n=>Te(n)&&n>0,Ae=n=>Lr.call(n)==="[object Boolean]",vl=n=>n instanceof FormData,yl=n=>A(fl,n);function Pn(n){return n===null||typeof n!="object"}function mr(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function vo(n){return!b(Event)&&function(e,t){try{return e instanceof t}catch{return!1}}(n,Event)}var ml=[!0,"true",1,"1","yes"],nn=n=>A(ml,n),_l=[!1,"false",0,"0","no"];function ke(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),Te(n)?n>t?(r.warn(" cannot be greater than max: "+t+". Using max value instead."),t):n<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):n:(r.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+i),ke(i||t,e,t,r))}var Sn=class{constructor(e){this.t={},this.i=e.i,this.o=ke(e.bucketSize,0,100,e.h),this.m=ke(e.refillRate,0,this.o,e.h),this.$=ke(e.refillInterval,0,864e5,e.h)}S(e,t){var r=t-e.lastAccess,i=Math.floor(r/this.$);if(i>0){var s=i*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+i*this.$}}consumeRateLimit(e){var t,r=Date.now(),i=String(e),s=this.t[i];return s?this.S(s,r):(s={tokens:this.o,lastAccess:r},this.t[i]=s),s.tokens===0||(s.tokens--,s.tokens===0&&((t=this.i)==null||t.call(this,e)),s.tokens===0)}stop(){this.t={}}},fe="Mobile",_r="iOS",Re="Android",Xt="Tablet",yo=Re+" "+Xt,mo="iPad",_o="Apple",bo=_o+" Watch",Yt="Safari",vt="BlackBerry",ko="Samsung",wo=ko+"Browser",Eo=ko+" Internet",Ye="Chrome",bl=Ye+" OS",xo=Ye+" "+_r,Oi="Internet Explorer",Po=Oi+" "+fe,$i="Opera",kl=$i+" Mini",Di="Edge",So="Microsoft "+Di,ft="Firefox",Co=ft+" "+_r,Jt="Nintendo",Zt="PlayStation",gt="Xbox",Io=Re+" "+fe,Mo=fe+" "+Yt,qt="Windows",Cn=qt+" Phone",ks="Nokia",In="Ouya",Ro="Generic",wl=Ro+" "+fe.toLowerCase(),Ao=Ro+" "+Xt.toLowerCase(),Mn="Konqueror",te="(\\d+(\\.\\d+)?)",sn=new RegExp("Version/"+te),El=new RegExp(gt,"i"),xl=new RegExp(Zt+" \\w+","i"),Pl=new RegExp(Jt+" \\w+","i"),Ni=new RegExp(vt+"|PlayBook|BB10","i"),Sl={"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"},pr,ws,on,Cl=(n,e)=>e&&A(e,_o)||function(t){return A(t,Yt)&&!A(t,Ye)&&!A(t,Re)}(n),To=function(n,e){return e=e||"",A(n," OPR/")&&A(n,"Mini")?kl:A(n," OPR/")?$i:Ni.test(n)?vt:A(n,"IE"+fe)||A(n,"WPDesktop")?Po:A(n,wo)?Eo:A(n,Di)||A(n,"Edg/")?So:A(n,"FBIOS")?"Facebook "+fe:A(n,"UCWEB")||A(n,"UCBrowser")?"UC Browser":A(n,"CriOS")?xo:A(n,"CrMo")||A(n,Ye)?Ye:A(n,Re)&&A(n,Yt)?Io:A(n,"FxiOS")?Co:A(n.toLowerCase(),Mn.toLowerCase())?Mn:Cl(n,e)?A(n,fe)?Mo:Yt:A(n,ft)?ft:A(n,"MSIE")||A(n,"Trident/")?Oi:A(n,"Gecko")?ft:""},Il={[Po]:[new RegExp("rv:"+te)],[So]:[new RegExp(Di+"?\\/"+te)],[Ye]:[new RegExp("("+Ye+"|CrMo)\\/"+te)],[xo]:[new RegExp("CriOS\\/"+te)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+te)],[Yt]:[sn],[Mo]:[sn],[$i]:[new RegExp("(Opera|OPR)\\/"+te)],[ft]:[new RegExp(ft+"\\/"+te)],[Co]:[new RegExp("FxiOS\\/"+te)],[Mn]:[new RegExp("Konqueror[:/]?"+te,"i")],[vt]:[new RegExp(vt+" "+te),sn],[Io]:[new RegExp("android\\s"+te,"i")],[Eo]:[new RegExp(wo+"\\/"+te)],[Oi]:[new RegExp("(rv:|MSIE )"+te)],Mozilla:[new RegExp("rv:"+te)]},Ml=function(n,e){var t=To(n,e),r=Il[t];if(b(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=n.match(s);if(o)return parseFloat(o[o.length-2])}return null},Es=[[new RegExp(gt+"; "+gt+" (.*?)[);]","i"),n=>[gt,n&&n[1]||""]],[new RegExp(Jt,"i"),[Jt,""]],[new RegExp(Zt,"i"),[Zt,""]],[Ni,[vt,""]],[new RegExp(qt,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Cn,""];if(new RegExp(fe).test(e)&&!/IEMobile\b/.test(e))return[qt+" "+fe,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=Sl[r]||"";return/arm/i.test(e)&&(i="RT"),[qt,i]}return[qt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[_r,e.join(".")]}return[_r,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=b(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+Re+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Re+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Re,e.join(".")]}return[Re,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,n=>{var e=["Mac OS X",""];if(n&&n[1]){var t=[n[1],n[2],n[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[bl,""]],[/Linux|debian/i,["Linux",""]]],xs=function(n){return Pl.test(n)?Jt:xl.test(n)?Zt:El.test(n)?gt:new RegExp(In,"i").test(n)?In:new RegExp("("+Cn+"|WPDesktop)","i").test(n)?Cn:/iPad/.test(n)?mo:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?bo:Ni.test(n)?vt:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(ks,"i").test(n)?ks:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(n)||/(kf[a-z]+)( bui|\)).+silk\//i.test(n)?"Kindle Fire":/(Android|ZTE)/i.test(n)?new RegExp(fe).test(n)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(n)||/pixel[\daxl ]{1,6}/i.test(n)&&!/pixel c/i.test(n)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(n)||/lmy47v/i.test(n)&&!/QTAQZ3/i.test(n)?Re:yo:new RegExp("(pda|"+fe+")","i").test(n)?wl:new RegExp(Xt,"i").test(n)&&!new RegExp(Xt+" pc","i").test(n)?Ao:""},Rl=n=>n instanceof Error;function Al(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return on&&t.length===ws||(ws=t.length,on=t.reduce((r,i)=>{pr||(pr={});var s=pr[i];if(s)r[s[0]]=s[1];else for(var o=n(i),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[i];if(c&&u){r[c]=u,pr[i]=[c,u];break}}return r},{})),on}}var Rn=class{constructor(e,t,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=t,this.modifiers=r}buildFromUnknown(e,t){t===void 0&&(t={});var r=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,t,0).apply(e),s=this.buildParsingContext(),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var t=this;return pt(function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&$(r.stacktrace.frames)&&(r.stacktrace.frames=yield t.applyModifiers(r.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),E({},e,{cause:r,stack:i})}applyChunkIds(e,t){return e.map(r=>(r.filename&&t&&(r.chunk_id=t[r.filename]),r))}applyCoercers(e,t){for(var r of this.coercers)if(r.match(e))return r.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return pt(function*(){var r=e;for(var i of t.modifiers)r=yield i(r);return r})()}convertToExceptionList(e,t){var r,i,s,o={type:e.type,value:e.value,mechanism:{type:(r=t.type)!==null&&r!==void 0?r:"generic",handled:(i=t.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,E({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:Al(this.stackParser)}}buildCoercingContext(e,t,r){r===void 0&&(r=0);var i=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(s,a)}};return E({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},yt="?";function An(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?yt:t,in_app:!0};return b(r)||(s.lineno=r),b(i)||(s.colno=i),s}var Fo=(n,e)=>{var t=n.indexOf("safari-extension")!==-1,r=n.indexOf("safari-web-extension")!==-1;return t||r?[n.indexOf("@")!==-1?n.split("@")[0]:yt,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},Tl=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Fl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ol=/\((\S*)(?::(\d+))(?::(\d+))\)/,$l=(n,e)=>{var t=Tl.exec(n);if(t){var[,r,i,s]=t;return An(e,r,yt,+i,+s)}var o=Fl.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Ol.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=Fo(o[1]||yt,o[2]);return An(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Dl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Nl=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ql=(n,e)=>{var t=Dl.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=Nl.exec(t[3]);r&&(t[1]=t[1]||"eval",t[3]=r[1],t[4]=r[2],t[5]="")}var i=t[3],s=t[1]||yt;return[s,i]=Fo(s,i),An(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},Ps=/\(error: (.*)\)/,Ss=50;function jl(){return function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return function(i,s){s===void 0&&(s=0);for(var o=[],a=i.split(`
9
- `),l=s;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=Ps.test(c)?c.replace(Ps,"$1"):c;if(!u.match(/\S*Error: /)){for(var p of t){var h=p(u,n);if(h){o.push(h);break}}if(o.length>=Ss)break}}}return function(d){if(!d.length)return[];var f=Array.from(d);return f.reverse(),f.slice(0,Ss).map(v=>{return E({},v,{filename:v.filename||(y=f,y[y.length-1]||{}).filename,function:v.function||yt});var y})}(o)}}("web:javascript",$l,ql)}var Tn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=H(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return mr(e,"DOMException")}isDOMError(e){return mr(e,"DOMError")}},Fn=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){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}},On=class{constructor(){}match(e){return mr(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var r,i=t.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Gl=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,$n=class{match(e){return typeof e=="string"}coerce(e,t){var r,[i,s]=this.getInfos(e);return{type:i??"Error",value:s??e,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var t="Error",r=e,i=e.match(Gl);return i&&(t=i[1],r=i[2]),[t,r]}},Ll=["fatal","error","warning","log","info","debug"];function Oo(n,e){e===void 0&&(e=40);var t=Object.keys(n);if(t.sort(),!t.length)return"[object has no keys]";for(var r=t.length;r>0;r--){var i=t.slice(0,r).join(", ");if(!(i.length>e))return r===t.length||i.length<=e?i:i.slice(0,e)+"..."}return""}var Dn=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var r,i=this.getErrorPropertyFromObject(e);return i?t.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return vo(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}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: "+Oo(e)}isSeverityLevel(e){return H(e)&&!xn(e)&&Ll.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(Rl(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Nn=class{match(e){return vo(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Oo(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},qn=class{match(e){return Pn(e)}coerce(e,t){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},jn=class{match(e){return mr(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return Pn(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}:t.apply(i)}getUnhandledRejectionReason(e){if(Pn(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}},$o=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(g&&(Se.DEBUG||I.POSTHOG_DEBUG||t)&&!b(g.console)&&g.console){for(var s=("__rrweb_original__"in g.console[i])?g.console[i].__rrweb_original__:g.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];s(n,...a)}},info:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("log",...s)},warn:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("warn",...s)},error:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("error",...s)},critical:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];console.error(n,...s)},uninitializedWarning:i=>{r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>$o(n+" "+i,s)};return r},k=$o("[PostHog.js]"),G=k.createLogger,Vl=G("[ExternalScriptsLoader]"),Cs=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return Vl.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=_?.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:t()}:(l.addEventListener("load",c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)}),l.onerror=c=>t(c),{v:void 0})}},o=0;o<r.length;o++)if(i=s())return i.v}var a=()=>{if(!_)return t("document not found");var l=_.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=p=>{l.__posthog_loading_callback_fired=!0,t(void 0,p)},l.onerror=p=>t(p),n.config.prepare_external_dependency_script&&(l=n.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(n.config.external_scripts_inject_target==="head")_.head.appendChild(l);else{var c,u=_.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):_.body.appendChild(l)}};_!=null&&_.body?a():_?.addEventListener("DOMContentLoaded",a)};I.__PosthogExtensions__=I.__PosthogExtensions__||{},I.__PosthogExtensions__.loadExternalDependency=(n,e,t)=>{var r="/static/"+e+".js?v="+n.version;if(e==="remote-config"&&(r="/array/"+n.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var s=n.requestRouter.endpointFor("assets",r);Cs(n,s,t)},I.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);Cs(n,r,t)};var br={};function Ve(n,e,t){if($(n)){if(vs&&n.forEach===vs)n.forEach(e,t);else if("length"in n&&n.length===+n.length){for(var r=0,i=n.length;r<i;r++)if(r in n&&e.call(t,n[r],r)===br)return}}}function N(n,e,t){if(!T(n)){if($(n))return Ve(n,e,t);if(vl(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===br)return}else for(var i in n)if(go.call(n,i)&&e.call(t,n[i],i)===br)return}}var L=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Ve(t,function(i){for(var s in i)i[s]!==void 0&&(n[s]=i[s])}),n},_t=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Ve(t,function(i){Ve(i,function(s){n.push(s)})}),n};function vr(n){for(var e=Object.keys(n),t=e.length,r=new Array(t);t--;)r[t]=[e[t],n[e[t]]];return r}var Is=function(n){try{return n()}catch{return}},Ul=function(n){return function(){try{for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.apply(this,t)}catch(i){k.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),k.critical(i)}}},qi=function(n){var e={};return N(n,function(t,r){(H(t)&&t.length>0||Te(t))&&(e[r]=t)}),e};function zl(n,e){return t=n,r=s=>H(s)&&!ye(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),$(o)?(l=[],Ve(o,c=>{l.push(s(c))})):(l={},N(o,(c,u)=>{i.has(c)||(l[u]=s(c,u))})),l);var l}(t);var t,r,i}var Hl=["herokuapp.com","vercel.app","netlify.app"];function Kl(n){var e=n?.hostname;if(!H(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of Hl)if(t===r)return!1;return!0}function Do(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function U(n,e,t,r){var{capture:i=!1,passive:s=!0}=r??{};n?.addEventListener(e,t,{capture:i,passive:s})}var No="$people_distinct_id",jt="__alias",Gt="__timers",Ms="$autocapture_disabled_server_side",Gn="$heatmaps_enabled_server_side",Rs="$exception_capture_enabled_server_side",Ln="$error_tracking_suppression_rules",As="$error_tracking_capture_extension_exceptions",Ts="$web_vitals_enabled_server_side",qo="$dead_clicks_enabled_server_side",Fs="$product_tours_enabled_server_side",Os="$web_vitals_allowed_metrics",an="$session_recording_remote_config",kr="$sesid",jo="$session_is_sampled",ht="$enabled_feature_flags",Lt="$early_access_features",Vn="$feature_flag_details",Vt="$stored_person_properties",Xe="$stored_group_properties",Un="$surveys",wr="$flag_call_reported",Ce="$user_state",zn="$client_session_props",Hn="$capture_rate_limit",Kn="$initial_campaign_params",Bn="$initial_referrer_info",Er="$initial_person_info",xr="$epp",Go="__POSTHOG_TOOLBAR__",Mt="$posthog_cookieless",Bl=[No,jt,"__cmpns",Gt,"$session_recording_enabled_server_side",Gn,kr,ht,Ln,Ce,Lt,Vn,Xe,Vt,Un,wr,zn,Hn,Kn,Bn,xr,Er,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function $s(n){return n instanceof Element&&(n.id===Go||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function Vr(n){return!!n&&n.nodeType===1}function Ue(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function Lo(n){return!!n&&n.nodeType===3}function Vo(n){return!!n&&n.nodeType===11}function ji(n){return n?Gr(n).split(/\s+/):[]}function Ds(n){var e=g?.location.href;return!!(e&&n&&n.some(t=>e.match(t)))}function Pr(n){var e="";switch(typeof n.className){case"string":e=n.className;break;case"object":e=(n.className&&"baseVal"in n.className?n.className.baseVal:null)||n.getAttribute("class")||"";break;default:e=""}return ji(e)}function Uo(n){return T(n)?null:Gr(n).split(/(\s+)/).filter(e=>Qt(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function tr(n){var e="";return Wn(n)&&!Wo(n)&&n.childNodes&&n.childNodes.length&&N(n.childNodes,function(t){var r;Lo(t)&&t.textContent&&(e+=(r=Uo(t.textContent))!==null&&r!==void 0?r:"")}),Gr(e)}function zo(n){return b(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var Gi=["a","button","form","input","select","textarea","label"];function Ho(n,e){if(b(e))return!0;var t,r=function(s){if(e.some(o=>s.matches(o)))return{v:!0}};for(var i of n)if(t=r(i))return t.v;return!1}function Ko(n){var e=n.parentNode;return!(!e||!Vr(e))&&e}var Wl=["next","previous","prev",">","<"],Ns=10,qs=[".ph-no-rageclick",".ph-no-capture"];function Xl(n,e){if(!g||Li(n))return!1;var t,r,i;if(Ae(e)?(t=!!e&&qs,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:qs,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=Bo(n,!1);return!function(o,a){if(o===!1||b(o))return!1;var l;if(o===!0)l=Wl;else{if(!$(o))return!1;if(o.length>Ns)return k.error("[PostHog] content_ignorelist array cannot exceed "+Ns+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map(c=>c.toLowerCase())}return a.some(c=>{var{safeText:u,ariaLabel:p}=c;return l.some(h=>u.includes(h)||p.includes(h))})}(r,s.map(o=>{var a;return{safeText:tr(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}}))&&!Ho(s,t)}var Li=n=>!n||Ue(n,"html")||!Vr(n),Bo=(n,e)=>{if(!g||Li(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!Ue(i,"body");)if(Vo(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=Ko(i);if(!s)break;if(e||Gi.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=g.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),i=s}return{parentIsUsefulElement:t,targetElementList:r}};function Yl(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!g||Li(n)||(s=t)!=null&&s.url_allowlist&&!Ds(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Ds(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some(f=>e.type===f))return!1}var{parentIsUsefulElement:u,targetElementList:p}=Bo(n,r);if(!function(f,v){var y=v?.element_allowlist;if(b(y))return!0;var S,w=function(m){if(y.some(P=>m.tagName.toLowerCase()===P))return{v:!0}};for(var x of f)if(S=w(x))return S.v;return!1}(p,t)||!Ho(p,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var h=g.getComputedStyle(n);if(h&&h.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var d=n.tagName.toLowerCase();switch(d){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 u?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Gi.indexOf(d)>-1||n.getAttribute("contenteditable")==="true")}}function Wn(n){for(var e=n;e.parentNode&&!Ue(e,"body");e=e.parentNode){var t=Pr(e);if(A(t,"ph-sensitive")||A(t,"ph-no-capture"))return!1}if(A(Pr(n),"ph-include"))return!0;var r=n.type||"";if(H(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=n.name||n.id||"";return!(H(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 Wo(n){return!!(Ue(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Ue(n,"select")||Ue(n,"textarea")||n.getAttribute("contenteditable")==="true")}var Xo="(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})",Jl=new RegExp("^(?:"+Xo+")$"),Zl=new RegExp(Xo),Yo="\\d{3}-?\\d{2}-?\\d{4}",Ql=new RegExp("^("+Yo+")$"),eu=new RegExp("("+Yo+")");function Qt(n,e){return e===void 0&&(e=!0),!(T(n)||H(n)&&(n=Gr(n),(e?Jl:Zl).test((n||"").replace(/[- ]/g,""))||(e?Ql:eu).test(n)))}function Jo(n){var e=tr(n);return Qt(e=(e+" "+Zo(n)).trim())?e:""}function Zo(n){var e="";return n&&n.childNodes&&n.childNodes.length&&N(n.childNodes,function(t){var r;if(t&&((r=t.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=tr(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Zo(t)).trim())}catch(s){k.error("[AutoCapture]",s)}}),e}function tu(n){return function(e){var t=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=E({},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),c={};return vr(l).sort((u,p)=>{var[h]=u,[d]=p;return h.localeCompare(d)}).forEach(u=>{var[p,h]=u;return c[js(p.toString())]=js(h.toString())}),o+=":",o+=vr(c).map(u=>{var[p,h]=u;return p+'="'+h+'"'}).join("")});return t.join(";")}(function(e){return e.map(t=>{var r,i,s={text:(r=t.$el_text)==null?void 0:r.slice(0,400),tag_name:t.tag_name,href:(i=t.attr__href)==null?void 0:i.slice(0,2048),attr_class:ru(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return vr(t).filter(o=>{var[a]=o;return a.indexOf("attr__")===0}).forEach(o=>{var[a,l]=o;return s.attributes[a]=l}),s})}(n))}function js(n){return n.replace(/"|\\"/g,'\\"')}function ru(n){var e=n.attr__class;return e?$(e)?e:ji(e):void 0}var Sr=class{constructor(e){this.disabled=e===!1;var t=z(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&r-i.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}},Cr=n=>{var e=_?.createElement("a");return b(e)?null:(e.href=n,e)},nu=function(n,e){var t,r;e===void 0&&(e="&");var i=[];return N(n,function(s,o){b(s)||b(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),i[i.length]=r+"="+t)}),i.join(e)},Ir=function(n,e){for(var t,r=((n.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===e){t=s;break}}if(!$(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{k.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},rr=function(n,e,t){if(!n||!e||!e.length)return n;for(var r=n.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],p=0;p<c.length;p++){var h=c[p].split("=");$(h)&&(e.includes(h[0])?u.push(h[0]+"="+t):u.push(c[p]))}var d=l;return a!=null&&(d+="?"+u.join("&")),s!=null&&(d+="#"+s),d},Mr=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},ln="$copy_autocapture",Gs=G("[AutoCapture]");function un(n,e){return e.length>n?e.slice(0,n)+"...":e}function iu(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!Vr(e));return e}function su(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};Gi.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=un(1024,Jo(n)):s.$el_text=un(1024,tr(n)));var o=Pr(n);o.length>0&&(s.classes=o.filter(function(u){return u!==""})),N(n.attributes,function(u){var p;if((!Wo(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Qt(u.value)&&(p=u.name,!H(p)||p.substring(0,10)!=="_ngcontent"&&p.substring(0,7)!=="_nghost")){var h=u.value;u.name==="class"&&(h=ji(h).join(" ")),s["attr__"+u.name]=un(1024,h)}});for(var a=1,l=1,c=n;c=iu(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function ou(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!Ue(u,"body");)Vo(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var p,h=[],d={},f=!1,v=!1;if(N(c,m=>{var P=Wn(m);m.tagName.toLowerCase()==="a"&&(f=m.getAttribute("href"),f=P&&f&&Qt(f)&&f),A(Pr(m),"ph-no-capture")&&(v=!0),h.push(su(m,s,o,a));var F=function(O){if(!Wn(O))return{};var C={};return N(O.attributes,function(V){if(V.name&&V.name.indexOf("data-ph-capture-attribute")===0){var X=V.name.replace("data-ph-capture-attribute-",""),ne=V.value;X&&ne&&Qt(ne)&&(C[X]=ne)}}),C}(m);L(d,F)}),v)return{props:{},explicitNoCapture:v};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?h[0].$el_text=Jo(n):h[0].$el_text=tr(n)),f){var y,S;h[0].attr__href=f;var w=(y=Cr(f))==null?void 0:y.host,x=g==null||(S=g.location)==null?void 0:S.host;w&&x&&w!==x&&(p=f)}return{props:L({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:tu(h)},(t=h[0])!=null&&t.$el_text?{$el_text:(r=h[0])==null?void 0:r.$el_text}:{},p&&i.type==="click"?{$external_click_url:p}:{},d)}}var Xn=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Sr(e.config.rageclick),this.C=null}get R(){var e,t,r=z(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=(t=r.url_ignorelist)==null?void 0:t.map(i=>new RegExp(i)),r}F(){if(this.isBrowserSupported()){if(g&&_){var e=r=>{r=r||g?.event;try{this.O(r)}catch(i){Gs.error("Failed to capture event",i)}};if(U(_,"submit",e,{capture:!0}),U(_,"change",e,{capture:!0}),U(_,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||g?.event,this.O(r,ln)};U(_,"copy",t,{capture:!0}),U(_,"cut",t,{capture:!0})}}}else Gs.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ms]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,r=[];return(t=this.C)==null||t.forEach(i=>{var s=_?.querySelectorAll(i);s?.forEach(o=>{e===o&&r.push(i)})}),r}get isEnabled(){var e,t,r=(e=this.instance.persistence)==null?void 0:e.props[Ms],i=this.T;if(ye(i)&&!Ae(r)&&!this.instance.M())return!1;var s=(t=this.T)!==null&&t!==void 0?t:!!r;return!!this.instance.config.autocapture&&!s}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var r,i=zo(e);Lo(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&Xl(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===ln;if(i&&Yl(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=ou(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(o.$element_selectors=l),t===ln){var c,u=Uo(g==null||(c=g.getSelection())==null?void 0:c.toString()),p=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=p}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return Le(_?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return Te(n)&&isFinite(n)&&Math.floor(n)===n});var Ls="0123456789abcdef",Yn=class n{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||t<0||r<0||i<0||e>0xffffffffffff||t>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|t>>>8,s[7]=t,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 n(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ls.charAt(this.bytes[t]>>>4)+Ls.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new n(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(r!==0)return Math.sign(r)}return 0}},Jn=class{constructor(){this.A=0,this.j=0,this.D=new Zn}generate(){var e=this.generateOrAbort();if(b(e)){this.A=0;var t=this.generateOrAbort();if(b(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return Yn.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}},Vs,Qo=n=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<n.length;e++)n[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return n};g&&!b(g.crypto)&&crypto.getRandomValues&&(Qo=n=>crypto.getRandomValues(n));var Zn=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(Qo(this.N),this.U=0),this.N[this.U++]}},Ge=()=>au().toString(),au=()=>(Vs||(Vs=new Jn)).generate(),Rt="",lu=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function uu(n,e){if(e){var t=function(i,s){if(s===void 0&&(s=_),Rt)return Rt;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+Ge();!Rt&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";s.cookie=u+";max-age=3",s.cookie.includes(l)&&(s.cookie=u+";max-age=0",Rt=c)}return Rt}(n);if(!t){var r=(i=>{var s=i.match(lu);return s?s[0]:""})(n);r!==t&&k.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var be={H:()=>!!_,B:function(n){k.error("cookieStore error: "+n)},q:function(n){if(_){try{for(var e=n+"=",t=_.cookie.split(";").filter(s=>s.length),r=0;r<t.length;r++){for(var i=t[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}},W:function(n){var e;try{e=JSON.parse(be.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(_)try{var s="",o="",a=uu(_.location.hostname,r);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),s="; expires="+l.toUTCString()}i&&(o="; secure");var c=n+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&k.warn("cookieStore warning: large cookie, len="+c.length),_.cookie=c,c}catch{return}},V:function(n,e){if(_!=null&&_.cookie)try{be.G(n,"",-1,e)}catch{return}}},cn=null,j={H:function(){if(!ye(cn))return cn;var n=!0;if(b(g))n=!1;else try{var e="__mplssupport__";j.G(e,"xyz"),j.q(e)!=='"xyz"'&&(n=!1),j.V(e)}catch{n=!1}return n||k.error("localStorage unsupported; falling back to cookie store"),cn=n,n},B:function(n){k.error("localStorage error: "+n)},q:function(n){try{return g?.localStorage.getItem(n)}catch(e){j.B(e)}return null},W:function(n){try{return JSON.parse(j.q(n))||{}}catch{}return null},G:function(n,e){try{g?.localStorage.setItem(n,JSON.stringify(e))}catch(t){j.B(t)}},V:function(n){try{g?.localStorage.removeItem(n)}catch(e){j.B(e)}}},cu=["$device_id","distinct_id",kr,jo,xr,Er],dr={},pu={H:function(){return!0},B:function(n){k.error("memoryStorage error: "+n)},q:function(n){return dr[n]||null},W:function(n){return dr[n]||null},G:function(n,e){dr[n]=e},V:function(n){delete dr[n]}},Be=null,K={H:function(){if(!ye(Be))return Be;if(Be=!0,b(g))Be=!1;else try{var n="__support__";K.G(n,"xyz"),K.q(n)!=='"xyz"'&&(Be=!1),K.V(n)}catch{Be=!1}return Be},B:function(n){k.error("sessionStorage error: ",n)},q:function(n){try{return g?.sessionStorage.getItem(n)}catch(e){K.B(e)}return null},W:function(n){try{return JSON.parse(K.q(n))||null}catch{}return null},G:function(n,e){try{g?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){K.B(t)}},V:function(n){try{g?.sessionStorage.removeItem(n)}catch(e){K.B(e)}}},Ie=function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n}({}),Qn=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Ie.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===Ie.DENIED||this.consent===Ie.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ie.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:r}=this._instance.config;return r||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return nn(e)?Ie.GRANTED:A(_l,e)?Ie.DENIED:Ie.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?j:be;var t=e==="localStorage"?be:j;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(nn(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Do([le?.doNotTrack,le?.msDoNotTrack,I.doNotTrack],e=>nn(e))}},hr=G("[Dead Clicks]"),du=()=>!0,hu=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(qo)),r=n.instance.config.capture_dead_clicks;return Ae(r)?r:!!z(r)||t},Rr=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,r){this.instance=e,this.isEnabled=t,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[qo]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?hr.error("failed to load script",i):e()})}et(){var e;if(_){if(!this.tt&&(e=I.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=z(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=I.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(_),hr.info("starting...")}}else hr.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,hr.info("stopping..."))}},At=G("[ExceptionAutocapture]"),ei=class{constructor(e){var t,r,i;this.rt=()=>{var s;if(g&&this.isEnabled&&(s=I.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=I.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=I.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=I.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){At.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[Rs]),this.dt=new Sn({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,h:At}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return z(e)?t=E({},t,e):(b(e)?this.ht:e)&&(t=E({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(At.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return At.error("failed to load script",i);e()})}ut(){var e,t,r;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Rs]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,r,i=(t=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(i)?At.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function Us(n,e,t){try{if(!(e in n))return()=>{};var r=n[e],i=t(r);return Le(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=i,()=>{n[e]=r}}catch{return()=>{}}}var ti=class{constructor(e){var t;this._instance=e,this.ct=(g==null||(t=g.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(k.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,k.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(g&&g.history){var r=this;(e=g.history.pushState)!=null&&e.__posthog_wrapped__||Us(g.history,"pushState",i=>function(s,o,a){i.call(this,s,o,a),r._t("pushState")}),(t=g.history.replaceState)!=null&&t.__posthog_wrapped__||Us(g.history,"replaceState",i=>function(s,o,a){i.call(this,s,o,a),r._t("replaceState")}),this.bt()}}_t(e){try{var t,r=g==null||(t=g.location)==null?void 0:t.pathname;if(!r)return;r!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=r}catch(i){k.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};U(g,"popstate",e),this.ft=()=>{g&&g.removeEventListener("popstate",e)}}}},pn=G("[SegmentIntegration]");function fu(n,e){var t=n.config.segment;if(!t)return e();(function(r,i){var s=r.config.segment;if(!s)return i();var o=l=>{var c=()=>l.anonymousId()||Ge();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(Ce,"identified")),i()},a=s.user();"then"in a&&Le(a.then)?a.then(o):o(a)})(n,()=>{t.register((r=>{Promise&&Promise.resolve||pn.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()||(pn.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(pn.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")}})(n)).then(()=>{e()})})}var ea="posthog-js";function ta(n,e){var{organization:t,projectId:r,prefix:i,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,p,h;if(!(s==="*"||s.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var d=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=d,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var f=((l=a.exception)==null?void 0:l.values)||[],v=f.map(S=>E({},S,{stacktrace:S.stacktrace?E({},S.stacktrace,{type:"raw",frames:(S.stacktrace.frames||[]).map(w=>E({},w,{platform:"web:javascript"}))}):void 0})),y={$exception_message:((c=f[0])==null?void 0:c.value)||a.message,$exception_type:(u=f[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((p=f[0])==null?void 0:p.value)||a.message,$sentry_exception_type:(h=f[0])==null?void 0:h.type,$sentry_tags:a.tags};return t&&r&&(y.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),o&&n.exceptions.sendExceptionEvent(y),a}}var ri=class{constructor(e,t,r,i,s,o){this.name=ea,this.setupOnce=function(a){a(ta(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},gu=g!=null&&g.location?Mr(g.location.hash,"__posthog")||Mr(location.hash,"state"):null,zs="_postHogToolbarParams",Hs=G("[Toolbar]"),je=function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n}(je||{}),ni=class{constructor(e){this.instance=e}yt(e){I.ph_toolbar_state=e}wt(){var e;return(e=I.ph_toolbar_state)!==null&&e!==void 0?e:je.UNINITIALIZED}maybeLoadToolbar(e,t,r){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),!g||!_)return!1;e=e??g.location,r=r??g.history;try{if(!t){try{g.localStorage.setItem("test","test"),g.localStorage.removeItem("test")}catch{return!1}t=g?.localStorage}var i,s=gu||Mr(e.hash,"__posthog")||Mr(e.hash,"state"),o=s?Is(()=>JSON.parse(atob(decodeURIComponent(s))))||Is(()=>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(t.getItem(zs)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=I.ph_load_toolbar||I.ph_load_editor;!T(t)&&Le(t)?t(e,this.instance):Hs.warn("No toolbar load function found")}loadToolbar(e){var t=!(_==null||!_.getElementById(Go));if(!g||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=E({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(g.localStorage.setItem(zs,JSON.stringify(E({},i,{source:void 0}))),this.wt()===je.LOADED)this.xt(i);else if(this.wt()===je.UNINITIALIZED){var s;this.yt(je.LOADING),(s=I.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",o=>{if(o)return Hs.error("[Toolbar] Failed to load",o),void this.yt(je.UNINITIALIZED);this.yt(je.LOADED),this.xt(i)}),U(g,"turbolinks:load",()=>{this.yt(je.UNINITIALIZED),this.loadToolbar(i)})}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,r){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,t,r)}},vu=G("[TracingHeaders]"),ii=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;b(this.$t)&&((t=I.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),b(this.St)&&((r=I.__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}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return vu.error("failed to load script",i);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}},fr="https?://(.*)",bt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],yu=_t(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],bt),nr="<masked>",mu=["li_fat_id"];function ra(n,e,t){if(!_)return{};var r,i=e?_t([],bt,t||[]):[],s=na(rr(_.URL,i,nr),n),o=(r={},N(mu,function(a){var l=be.q(a);r[a]=l||null}),r);return L(o,s)}function na(n,e){var t=yu.concat(e||[]),r={};return N(t,function(i){var s=Ir(n,i);r[i]=s||null}),r}function ia(n){var e=function(s){return s?s.search(fr+"google.([^/?]*)")===0?"google":s.search(fr+"bing.com")===0?"bing":s.search(fr+"yahoo.com")===0?"yahoo":s.search(fr+"duckduckgo.com")===0?"duckduckgo":null:null}(n),t=e!="yahoo"?"q":"p",r={};if(!ye(e)){r.$search_engine=e;var i=_?Ir(_.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function Ks(){return navigator.language||navigator.userLanguage}function sa(){return _?.referrer||"$direct"}function oa(n,e){var t=n?_t([],bt,e||[]):[],r=B?.href.substring(0,1e3);return{r:sa().substring(0,1e3),u:r?rr(r,t,nr):void 0}}function aa(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Cr(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=Cr(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=na(r);L(i,o)}if(t){var a=ia(t);L(i,a)}return i}function la(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function _u(){try{return new Date().getTimezoneOffset()}catch{return}}function bu(n,e){if(!se)return{};var t,r,i,s=n?_t([],bt,e||[]):[],[o,a]=function(l){for(var c=0;c<Es.length;c++){var[u,p]=Es[c],h=u.exec(l),d=h&&(Le(p)?p(h,l):p);if(d)return d}return["",""]}(se);return L(qi({$os:o,$os_version:a,$browser:To(se,navigator.vendor),$device:xs(se),$device_type:(r=se,i=xs(r),i===mo||i===yo||i==="Kobo"||i==="Kindle Fire"||i===Ao?Xt:i===Jt||i===gt||i===Zt||i===In?"Console":i===bo?"Wearable":i?fe:"Desktop"),$timezone:la(),$timezone_offset:_u()}),{$current_url:rr(B?.href,s,nr),$host:B?.host,$pathname:B?.pathname,$raw_user_agent:se.length>1e3?se.substring(0,997)+"...":se,$browser_version:Ml(se,navigator.vendor),$browser_language:Ks(),$browser_language_prefix:(t=Ks(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:g?.screen.height,$screen_width:g?.screen.width,$viewport_height:g?.innerHeight,$viewport_width:g?.innerWidth,$lib:"web",$lib_version:Se.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var De=G("[Web Vitals]"),Bs=9e5,si=class{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce((r,i)=>E({},r,{["$web_vitals_"+i.name+"_event"]:E({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=r=>{var i,s=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(b(s))De.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();b(o)||(T(r?.name)||T(r?.value)?De.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?De.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),b(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=b(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(E({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var r,i,s,o,a=I.__PosthogExtensions__;b(a)||b(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&i&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.It.bind(this)),this.P=!0):De.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[Ts]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=z(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return T(r)?((t=this._instance.persistence)==null?void 0:t.props[Os])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(z(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=z(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=z(this._instance.config.capture_performance)&&Te(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Bs;return 0<e&&e<=6e4?Bs:e}get isEnabled(){var e=B?.protocol;if(e!=="http:"&&e!=="https:")return De.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=z(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:Ae(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Ae(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(De.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=z(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=z(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ts]:t}),this._instance.persistence.register({[Os]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=I.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,s=>{s?De.error("failed to load script",s):e()})}}Ct(){var e=g?g.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,i=t?_t([],bt,r||[]):[];return rr(e,i,nr)}De.error("Could not determine current URL")}},ku=G("[Heatmaps]");function Ws(n){return z(n)&&"clientX"in n&&"clientY"in n&&Te(n.clientX)&&Te(n.clientY)}var oi=class{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[Gn]),this.rageclicks=new Sr(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return z(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 T(this.instance.config.capture_heatmaps)?T(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;ku.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Gn]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=function(e){return e?.visibilityState==="visible"}(_)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){g&&_&&(this.Nt=this.Lt.bind(this),U(g,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||g?.event),U(_,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||g?.event),U(_,"mousemove",this.zt,{capture:!0}),this.Bt=new Rr(this.instance,du,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),U(_,"visibilitychange",this.qt),this.P=!0)}At(){var e;g&&_&&(this.Nt&&g.removeEventListener("beforeunload",this.Nt),this.Ut&&_.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&_.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&_.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=function(a,l,c){for(var u=a;u&&Vr(u)&&!Ue(u,"body");){if(u===c)return!1;if(A(l,g?.getComputedStyle(u).position))return!0;u=Ko(u)}return!1}(zo(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:t}}Dt(e,t){var r;if(t===void 0&&(t="click"),!$s(e.target)&&Ws(e)){var i=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(E({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!$s(e.target)&&Ws(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(g){var t=g.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?_t([],bt,i||[]):[],o=rr(t,s,nr);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!dt(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Ar=class{constructor(e){this.Jt=(t,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(k.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var r,i=this.Qt(e,t);return this.Kt={pathname:(r=g?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var r=this.Kt;if(!r)return{$pageview_id:t};var i={$pageview_id:t,$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:c,lastContentY:u,maxContentY:p}=s;if(!(b(o)||b(a)||b(l)||b(c)||b(u)||b(p))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),p=Math.ceil(p);var h=o<=1?1:ke(a/o,0,1,k),d=o<=1?1:ke(l/o,0,1,k),f=c<=1?1:ke(u/c,0,1,k),v=c<=1?1:ke(p/c,0,1,k);i=L(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:f,$prev_pageview_max_content:p,$prev_pageview_max_content_percentage:v})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}};var Me=function(n){return n.GZipJS="gzip-js",n.Base64="base64",n}({}),ge=Uint8Array,re=Uint16Array,mt=Uint32Array,Vi=new ge([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]),Ui=new ge([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]),Xs=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ua=function(n,e){for(var t=new re(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new mt(t[30]);for(r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return[t,i]},ca=ua(Vi,2),wu=ca[0],ai=ca[1];wu[28]=258,ai[258]=28;for(li=ua(Ui,0)[1],Tr=new re(32768),q=0;q<32768;++q)Ne=(43690&q)>>>1|(21845&q)<<1,Ne=(61680&(Ne=(52428&Ne)>>>2|(13107&Ne)<<2))>>>4|(3855&Ne)<<4,Tr[q]=((65280&Ne)>>>8|(255&Ne)<<8)>>>1;var Ne,li,Tr,q,Kt=function(n,e,t){for(var r=n.length,i=0,s=new re(e);i<r;++i)++s[n[i]-1];var o,a=new re(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new re(1<<e);var l=15-e;for(i=0;i<r;++i)if(n[i])for(var c=i<<4|n[i],u=e-n[i],p=a[n[i]-1]++<<u,h=p|(1<<u)-1;p<=h;++p)o[Tr[p]>>>l]=c}else for(o=new re(r),i=0;i<r;++i)o[i]=Tr[a[n[i]-1]++]>>>15-n[i];return o},Je=new ge(288);for(q=0;q<144;++q)Je[q]=8;for(q=144;q<256;++q)Je[q]=9;for(q=256;q<280;++q)Je[q]=7;for(q=280;q<288;++q)Je[q]=8;var Fr=new ge(32);for(q=0;q<32;++q)Fr[q]=5;var Eu=Kt(Je,9,0),xu=Kt(Fr,5,0),pa=function(n){return(n/8>>0)+(7&n&&1)},da=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof re?re:n instanceof mt?mt:ge)(t-e);return r.set(n.subarray(e,t)),r},xe=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},Tt=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8,n[r+2]|=t>>>16},dn=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var i=t.length,s=t.slice();if(!i)return[new ge(0),0];if(i==1){var o=new ge(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort(function(P,F){return P.f-F.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,p=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=t[t[c].f<t[p].f?c++:p++],l=t[c!=u&&t[c].f<t[p].f?c++:p++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(r=1;r<i;++r)s[r].s>h&&(h=s[r].s);var d=new re(h+1),f=ui(t[u-1],d,0);if(f>e){r=0;var v=0,y=f-e,S=1<<y;for(s.sort(function(P,F){return d[F.s]-d[P.s]||P.f-F.f});r<i;++r){var w=s[r].s;if(!(d[w]>e))break;v+=S-(1<<f-d[w]),d[w]=e}for(v>>>=y;v>0;){var x=s[r].s;d[x]<e?v-=1<<e-d[x]++-1:++r}for(;r>=0&&v;--r){var m=s[r].s;d[m]==e&&(--d[m],++v)}f=e}return[new ge(d),f]},ui=function(n,e,t){return n.s==-1?Math.max(ui(n.l,e,t+1),ui(n.r,e,t+1)):e[n.s]=t},Ys=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new re(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[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=n[a]}return[t.subarray(0,r),e]},Ft=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},ci=function(n,e,t){var r=t.length,i=pa(e+2);n[i]=255&r,n[i+1]=r>>>8,n[i+2]=255^n[i],n[i+3]=255^n[i+1];for(var s=0;s<r;++s)n[i+s+4]=t[s];return 8*(i+4+r)},Js=function(n,e,t,r,i,s,o,a,l,c,u){xe(e,u++,t),++i[256];for(var p=dn(i,15),h=p[0],d=p[1],f=dn(s,15),v=f[0],y=f[1],S=Ys(h),w=S[0],x=S[1],m=Ys(v),P=m[0],F=m[1],O=new re(19),C=0;C<w.length;++C)O[31&w[C]]++;for(C=0;C<P.length;++C)O[31&P[C]]++;for(var V=dn(O,7),X=V[0],ne=V[1],Q=19;Q>4&&!X[Xs[Q-1]];--Q);var Y,ie,J,de,ve=c+5<<3,Ee=Ft(i,Je)+Ft(s,Fr)+o,me=Ft(i,h)+Ft(s,v)+o+14+3*Q+Ft(O,X)+(2*O[16]+3*O[17]+7*O[18]);if(ve<=Ee&&ve<=me)return ci(e,u,n.subarray(l,l+c));if(xe(e,u,1+(me<Ee)),u+=2,me<Ee){Y=Kt(h,d,0),ie=h,J=Kt(v,y,0),de=v;var Fe=Kt(X,ne,0);for(xe(e,u,x-257),xe(e,u+5,F-1),xe(e,u+10,Q-4),u+=14,C=0;C<Q;++C)xe(e,u+3*C,X[Xs[C]]);u+=3*Q;for(var st=[w,P],ee=0;ee<2;++ee){var he=st[ee];for(C=0;C<he.length;++C){var oe=31&he[C];xe(e,u,Fe[oe]),u+=X[oe],oe>15&&(xe(e,u,he[C]>>>5&127),u+=he[C]>>>12)}}}else Y=Eu,ie=Je,J=xu,de=Fr;for(C=0;C<a;++C)if(r[C]>255){oe=r[C]>>>18&31,Tt(e,u,Y[oe+257]),u+=ie[oe+257],oe>7&&(xe(e,u,r[C]>>>23&31),u+=Vi[oe]);var ot=31&r[C];Tt(e,u,J[ot]),u+=de[ot],ot>3&&(Tt(e,u,r[C]>>>5&8191),u+=Ui[ot])}else Tt(e,u,Y[r[C]]),u+=ie[r[C]];return Tt(e,u,Y[256]),u+ie[256]},Pu=new mt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Su=function(){for(var n=new mt(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n}(),Cu=function(n,e,t,r,i){return function(s,o,a,l,c,u){var p=s.length,h=new ge(l+p+5*(1+Math.floor(p/7e3))+c),d=h.subarray(l,h.length-c),f=0;if(!o||p<8)for(var v=0;v<=p;v+=65535){var y=v+65535;y<p?f=ci(d,f,s.subarray(v,y)):(d[v]=u,f=ci(d,f,s.subarray(v,p)))}else{for(var S=Pu[o-1],w=S>>>13,x=8191&S,m=(1<<a)-1,P=new re(32768),F=new re(m+1),O=Math.ceil(a/3),C=2*O,V=function(rn){return(s[rn]^s[rn+1]<<O^s[rn+2]<<C)&m},X=new mt(25e3),ne=new re(288),Q=new re(32),Y=0,ie=0,J=(v=0,0),de=0,ve=0;v<p;++v){var Ee=V(v),me=32767&v,Fe=F[Ee];if(P[me]=Fe,F[Ee]=me,de<=v){var st=p-v;if((Y>7e3||J>24576)&&st>423){f=Js(s,d,0,X,ne,Q,ie,J,ve,v-ve,f),J=Y=ie=0,ve=v;for(var ee=0;ee<286;++ee)ne[ee]=0;for(ee=0;ee<30;++ee)Q[ee]=0}var he=2,oe=0,ot=x,Oe=me-Fe&32767;if(st>2&&Ee==V(v-Oe))for(var tl=Math.min(w,st)-1,rl=Math.min(32767,v),nl=Math.min(258,st);Oe<=rl&&--ot&&me!=Fe;){if(s[v+he]==s[v+he-Oe]){for(var $e=0;$e<nl&&s[v+$e]==s[v+$e-Oe];++$e);if($e>he){if(he=$e,oe=Oe,$e>tl)break;var il=Math.min(Oe,$e-2),us=0;for(ee=0;ee<il;++ee){var tn=v-Oe+ee+32768&32767,cs=tn-P[tn]+32768&32767;cs>us&&(us=cs,Fe=tn)}}}Oe+=(me=Fe)-(Fe=P[me])+32768&32767}if(oe){X[J++]=268435456|ai[he]<<18|li[oe];var ps=31&ai[he],ds=31&li[oe];ie+=Vi[ps]+Ui[ds],++ne[257+ps],++Q[ds],de=v+he,++Y}else X[J++]=s[v],++ne[s[v]]}}f=Js(s,d,u,X,ne,Q,ie,J,ve,v-ve,f)}return da(h,0,l+pa(f)+c)}(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,r,!0)},hn=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function Iu(n,e){e===void 0&&(e={});var t=function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=Su[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}}(),r=n.length;t.p(n);var i,s=Cu(n,e,10+((i=e).filename&&i.filename.length+1||0),8),o=s.length;return function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&hn(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}}(s,e),hn(s,o-8,t.d()),hn(s,o-4,r),s}var Mu=function(n){var e,t,r,i,s="";for(e=t=0,r=(n=(n+"").replace(/\r\n/g,`
8
+ "use strict";var PaymentKit=(()=>{var pn=Object.defineProperty;var sl=Object.getOwnPropertyDescriptor;var ol=Object.getOwnPropertyNames;var al=Object.prototype.hasOwnProperty;var hs=n=>{throw TypeError(n)};var ll=(n,e,t)=>e in n?pn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ul=(n,e)=>{for(var t in e)pn(n,t,{get:e[t],enumerable:!0})},cl=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of ol(e))!al.call(n,i)&&i!==t&&pn(n,i,{get:()=>e[i],enumerable:!(r=sl(e,i))||r.enumerable});return n};var pl=n=>cl(pn({},"__esModule",{value:!0}),n);var R=(n,e,t)=>ll(n,typeof e!="symbol"?e+"":e,t),fs=(n,e,t)=>e.has(n)||hs("Cannot "+t);var M=(n,e,t)=>(fs(n,e,"read from private field"),t?t.call(n):e.get(n)),Z=(n,e,t)=>e.has(n)?hs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),_e=(n,e,t,r)=>(fs(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);var cp={};ul(cp,{PaymentMethods:()=>up,default:()=>lp});var gs="0.5.9";var It=class{constructor(){R(this,"events",[]);R(this,"distinctId",null)}identify(e){this.distinctId=e}capture(e,t){this.events.push({event:e,distinct_id:this.distinctId,properties:t,timestamp:Date.now()})}isInitialized(){return!0}getEvents(){return[...this.events]}getEventsByName(e){return this.events.filter(t=>t.event===e)}clear(){this.events=[]}};var v=typeof window<"u"?window:void 0,W=typeof globalThis<"u"?globalThis:v;typeof self>"u"&&(W.self=W),typeof File>"u"&&(W.File=function(){});var po=Array.prototype,vs=po.forEach,ys=po.indexOf,le=W?.navigator,k=W?.document,B=W?.location,kr=W?.fetch,wr=W!=null&&W.XMLHttpRequest&&"withCredentials"in new W.XMLHttpRequest?W.XMLHttpRequest:void 0,ms=W?.AbortController,se=le?.userAgent,I=v??{},Se={DEBUG:!1,LIB_VERSION:"1.341.0"};function _s(n,e,t,r,i,s,o){try{var a=n[s](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(r,i)}function pt(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(l){_s(s,r,i,o,a,"next",l)}function a(l){_s(s,r,i,o,a,"throw",l)}o(void 0)})}}function E(){return E=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},E.apply(null,arguments)}function ho(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var hl=["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"],bs=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return hl.concat(e).some(r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1})},fl=["$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 A(n,e){return n.indexOf(e)!==-1}var Ln=function(n){return n.trim()},xr=function(n){return n.replace(/^\$/,"")},gl=Array.isArray,fo=Object.prototype,go=fo.hasOwnProperty,Vn=fo.toString,$=gl||function(n){return Vn.call(n)==="[object Array]"},Le=n=>typeof n=="function",z=n=>n===Object(n)&&!$(n),dt=n=>{if(z(n)){for(var e in n)if(go.call(n,e))return!1;return!0}return!1},w=n=>n===void 0,H=n=>Vn.call(n)=="[object String]",Er=n=>H(n)&&n.trim().length===0,ye=n=>n===null,T=n=>w(n)||ye(n),Te=n=>Vn.call(n)=="[object Number]"&&n==n,ut=n=>Te(n)&&n>0,Ae=n=>Vn.call(n)==="[object Boolean]",vl=n=>n instanceof FormData,yl=n=>A(fl,n);function Pr(n){return n===null||typeof n!="object"}function _n(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function vo(n){return!w(Event)&&function(e,t){try{return e instanceof t}catch{return!1}}(n,Event)}var ml=[!0,"true",1,"1","yes"],ir=n=>A(ml,n),_l=[!1,"false",0,"0","no"];function ke(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),Te(n)?n>t?(r.warn(" cannot be greater than max: "+t+". Using max value instead."),t):n<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):n:(r.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+i),ke(i||t,e,t,r))}var Sr=class{constructor(e){this.t={},this.i=e.i,this.o=ke(e.bucketSize,0,100,e.h),this.m=ke(e.refillRate,0,this.o,e.h),this.$=ke(e.refillInterval,0,864e5,e.h)}S(e,t){var r=t-e.lastAccess,i=Math.floor(r/this.$);if(i>0){var s=i*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+i*this.$}}consumeRateLimit(e){var t,r=Date.now(),i=String(e),s=this.t[i];return s?this.S(s,r):(s={tokens:this.o,lastAccess:r},this.t[i]=s),s.tokens===0||(s.tokens--,s.tokens===0&&((t=this.i)==null||t.call(this,e)),s.tokens===0)}stop(){this.t={}}},fe="Mobile",bn="iOS",Re="Android",Xt="Tablet",yo=Re+" "+Xt,mo="iPad",_o="Apple",bo=_o+" Watch",Yt="Safari",vt="BlackBerry",ko="Samsung",wo=ko+"Browser",xo=ko+" Internet",Ye="Chrome",bl=Ye+" OS",Eo=Ye+" "+bn,Oi="Internet Explorer",Po=Oi+" "+fe,$i="Opera",kl=$i+" Mini",Di="Edge",So="Microsoft "+Di,ft="Firefox",Co=ft+" "+bn,Jt="Nintendo",Zt="PlayStation",gt="Xbox",Io=Re+" "+fe,Mo=fe+" "+Yt,qt="Windows",Cr=qt+" Phone",ks="Nokia",Ir="Ouya",Ro="Generic",wl=Ro+" "+fe.toLowerCase(),Ao=Ro+" "+Xt.toLowerCase(),Mr="Konqueror",te="(\\d+(\\.\\d+)?)",sr=new RegExp("Version/"+te),xl=new RegExp(gt,"i"),El=new RegExp(Zt+" \\w+","i"),Pl=new RegExp(Jt+" \\w+","i"),Ni=new RegExp(vt+"|PlayBook|BB10","i"),Sl={"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"},dn,ws,or,Cl=(n,e)=>e&&A(e,_o)||function(t){return A(t,Yt)&&!A(t,Ye)&&!A(t,Re)}(n),To=function(n,e){return e=e||"",A(n," OPR/")&&A(n,"Mini")?kl:A(n," OPR/")?$i:Ni.test(n)?vt:A(n,"IE"+fe)||A(n,"WPDesktop")?Po:A(n,wo)?xo:A(n,Di)||A(n,"Edg/")?So:A(n,"FBIOS")?"Facebook "+fe:A(n,"UCWEB")||A(n,"UCBrowser")?"UC Browser":A(n,"CriOS")?Eo:A(n,"CrMo")||A(n,Ye)?Ye:A(n,Re)&&A(n,Yt)?Io:A(n,"FxiOS")?Co:A(n.toLowerCase(),Mr.toLowerCase())?Mr:Cl(n,e)?A(n,fe)?Mo:Yt:A(n,ft)?ft:A(n,"MSIE")||A(n,"Trident/")?Oi:A(n,"Gecko")?ft:""},Il={[Po]:[new RegExp("rv:"+te)],[So]:[new RegExp(Di+"?\\/"+te)],[Ye]:[new RegExp("("+Ye+"|CrMo)\\/"+te)],[Eo]:[new RegExp("CriOS\\/"+te)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+te)],[Yt]:[sr],[Mo]:[sr],[$i]:[new RegExp("(Opera|OPR)\\/"+te)],[ft]:[new RegExp(ft+"\\/"+te)],[Co]:[new RegExp("FxiOS\\/"+te)],[Mr]:[new RegExp("Konqueror[:/]?"+te,"i")],[vt]:[new RegExp(vt+" "+te),sr],[Io]:[new RegExp("android\\s"+te,"i")],[xo]:[new RegExp(wo+"\\/"+te)],[Oi]:[new RegExp("(rv:|MSIE )"+te)],Mozilla:[new RegExp("rv:"+te)]},Ml=function(n,e){var t=To(n,e),r=Il[t];if(w(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=n.match(s);if(o)return parseFloat(o[o.length-2])}return null},xs=[[new RegExp(gt+"; "+gt+" (.*?)[);]","i"),n=>[gt,n&&n[1]||""]],[new RegExp(Jt,"i"),[Jt,""]],[new RegExp(Zt,"i"),[Zt,""]],[Ni,[vt,""]],[new RegExp(qt,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Cr,""];if(new RegExp(fe).test(e)&&!/IEMobile\b/.test(e))return[qt+" "+fe,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=Sl[r]||"";return/arm/i.test(e)&&(i="RT"),[qt,i]}return[qt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[bn,e.join(".")]}return[bn,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=w(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+Re+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Re+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Re,e.join(".")]}return[Re,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,n=>{var e=["Mac OS X",""];if(n&&n[1]){var t=[n[1],n[2],n[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[bl,""]],[/Linux|debian/i,["Linux",""]]],Es=function(n){return Pl.test(n)?Jt:El.test(n)?Zt:xl.test(n)?gt:new RegExp(Ir,"i").test(n)?Ir:new RegExp("("+Cr+"|WPDesktop)","i").test(n)?Cr:/iPad/.test(n)?mo:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?bo:Ni.test(n)?vt:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(ks,"i").test(n)?ks:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(n)||/(kf[a-z]+)( bui|\)).+silk\//i.test(n)?"Kindle Fire":/(Android|ZTE)/i.test(n)?new RegExp(fe).test(n)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(n)||/pixel[\daxl ]{1,6}/i.test(n)&&!/pixel c/i.test(n)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(n)||/lmy47v/i.test(n)&&!/QTAQZ3/i.test(n)?Re:yo:new RegExp("(pda|"+fe+")","i").test(n)?wl:new RegExp(Xt,"i").test(n)&&!new RegExp(Xt+" pc","i").test(n)?Ao:""},Rl=n=>n instanceof Error;function Al(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return or&&t.length===ws||(ws=t.length,or=t.reduce((r,i)=>{dn||(dn={});var s=dn[i];if(s)r[s[0]]=s[1];else for(var o=n(i),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[i];if(c&&u){r[c]=u,dn[i]=[c,u];break}}return r},{})),or}}var Rr=class{constructor(e,t,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=t,this.modifiers=r}buildFromUnknown(e,t){t===void 0&&(t={});var r=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,t,0).apply(e),s=this.buildParsingContext(),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var t=this;return pt(function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&$(r.stacktrace.frames)&&(r.stacktrace.frames=yield t.applyModifiers(r.stacktrace.frames));return e})()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),E({},e,{cause:r,stack:i})}applyChunkIds(e,t){return e.map(r=>(r.filename&&t&&(r.chunk_id=t[r.filename]),r))}applyCoercers(e,t){for(var r of this.coercers)if(r.match(e))return r.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return pt(function*(){var r=e;for(var i of t.modifiers)r=yield i(r);return r})()}convertToExceptionList(e,t){var r,i,s,o={type:e.type,value:e.value,mechanism:{type:(r=t.type)!==null&&r!==void 0?r:"generic",handled:(i=t.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,E({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:Al(this.stackParser)}}buildCoercingContext(e,t,r){r===void 0&&(r=0);var i=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(s,a)}};return E({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},yt="?";function Ar(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?yt:t,in_app:!0};return w(r)||(s.lineno=r),w(i)||(s.colno=i),s}var Fo=(n,e)=>{var t=n.indexOf("safari-extension")!==-1,r=n.indexOf("safari-web-extension")!==-1;return t||r?[n.indexOf("@")!==-1?n.split("@")[0]:yt,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},Tl=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Fl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ol=/\((\S*)(?::(\d+))(?::(\d+))\)/,$l=(n,e)=>{var t=Tl.exec(n);if(t){var[,r,i,s]=t;return Ar(e,r,yt,+i,+s)}var o=Fl.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Ol.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=Fo(o[1]||yt,o[2]);return Ar(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Dl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Nl=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ql=(n,e)=>{var t=Dl.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=Nl.exec(t[3]);r&&(t[1]=t[1]||"eval",t[3]=r[1],t[4]=r[2],t[5]="")}var i=t[3],s=t[1]||yt;return[s,i]=Fo(s,i),Ar(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},Ps=/\(error: (.*)\)/,Ss=50;function jl(){return function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return function(i,s){s===void 0&&(s=0);for(var o=[],a=i.split(`
9
+ `),l=s;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=Ps.test(c)?c.replace(Ps,"$1"):c;if(!u.match(/\S*Error: /)){for(var p of t){var h=p(u,n);if(h){o.push(h);break}}if(o.length>=Ss)break}}}return function(d){if(!d.length)return[];var g=Array.from(d);return g.reverse(),g.slice(0,Ss).map(f=>{return E({},f,{filename:f.filename||(y=g,y[y.length-1]||{}).filename,function:f.function||yt});var y})}(o)}}("web:javascript",$l,ql)}var Tr=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=H(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return _n(e,"DOMException")}isDOMError(e){return _n(e,"DOMError")}},Fr=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){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}},Or=class{constructor(){}match(e){return _n(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var r,i=t.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Gl=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,$r=class{match(e){return typeof e=="string"}coerce(e,t){var r,[i,s]=this.getInfos(e);return{type:i??"Error",value:s??e,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var t="Error",r=e,i=e.match(Gl);return i&&(t=i[1],r=i[2]),[t,r]}},Ll=["fatal","error","warning","log","info","debug"];function Oo(n,e){e===void 0&&(e=40);var t=Object.keys(n);if(t.sort(),!t.length)return"[object has no keys]";for(var r=t.length;r>0;r--){var i=t.slice(0,r).join(", ");if(!(i.length>e))return r===t.length||i.length<=e?i:i.slice(0,e)+"..."}return""}var Dr=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var r,i=this.getErrorPropertyFromObject(e);return i?t.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return vo(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}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: "+Oo(e)}isSeverityLevel(e){return H(e)&&!Er(e)&&Ll.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(Rl(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Nr=class{match(e){return vo(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Oo(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},qr=class{match(e){return Pr(e)}coerce(e,t){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},jr=class{match(e){return _n(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return Pr(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}:t.apply(i)}getUnhandledRejectionReason(e){if(Pr(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}},$o=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(v&&(Se.DEBUG||I.POSTHOG_DEBUG||t)&&!w(v.console)&&v.console){for(var s=("__rrweb_original__"in v.console[i])?v.console[i].__rrweb_original__:v.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];s(n,...a)}},info:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("log",...s)},warn:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("warn",...s)},error:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("error",...s)},critical:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];console.error(n,...s)},uninitializedWarning:i=>{r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>$o(n+" "+i,s)};return r},x=$o("[PostHog.js]"),G=x.createLogger,Vl=G("[ExternalScriptsLoader]"),Cs=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return Vl.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=k?.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:t()}:(l.addEventListener("load",c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)}),l.onerror=c=>t(c),{v:void 0})}},o=0;o<r.length;o++)if(i=s())return i.v}var a=()=>{if(!k)return t("document not found");var l=k.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=p=>{l.__posthog_loading_callback_fired=!0,t(void 0,p)},l.onerror=p=>t(p),n.config.prepare_external_dependency_script&&(l=n.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(n.config.external_scripts_inject_target==="head")k.head.appendChild(l);else{var c,u=k.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):k.body.appendChild(l)}};k!=null&&k.body?a():k?.addEventListener("DOMContentLoaded",a)};I.__PosthogExtensions__=I.__PosthogExtensions__||{},I.__PosthogExtensions__.loadExternalDependency=(n,e,t)=>{var r="/static/"+e+".js?v="+n.version;if(e==="remote-config"&&(r="/array/"+n.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var s=n.requestRouter.endpointFor("assets",r);Cs(n,s,t)},I.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);Cs(n,r,t)};var kn={};function Ve(n,e,t){if($(n)){if(vs&&n.forEach===vs)n.forEach(e,t);else if("length"in n&&n.length===+n.length){for(var r=0,i=n.length;r<i;r++)if(r in n&&e.call(t,n[r],r)===kn)return}}}function N(n,e,t){if(!T(n)){if($(n))return Ve(n,e,t);if(vl(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===kn)return}else for(var i in n)if(go.call(n,i)&&e.call(t,n[i],i)===kn)return}}var L=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Ve(t,function(i){for(var s in i)i[s]!==void 0&&(n[s]=i[s])}),n},_t=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Ve(t,function(i){Ve(i,function(s){n.push(s)})}),n};function yn(n){for(var e=Object.keys(n),t=e.length,r=new Array(t);t--;)r[t]=[e[t],n[e[t]]];return r}var Is=function(n){try{return n()}catch{return}},Ul=function(n){return function(){try{for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.apply(this,t)}catch(i){x.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),x.critical(i)}}},qi=function(n){var e={};return N(n,function(t,r){(H(t)&&t.length>0||Te(t))&&(e[r]=t)}),e};function zl(n,e){return t=n,r=s=>H(s)&&!ye(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),$(o)?(l=[],Ve(o,c=>{l.push(s(c))})):(l={},N(o,(c,u)=>{i.has(c)||(l[u]=s(c,u))})),l);var l}(t);var t,r,i}var Hl=["herokuapp.com","vercel.app","netlify.app"];function Kl(n){var e=n?.hostname;if(!H(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of Hl)if(t===r)return!1;return!0}function Do(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function U(n,e,t,r){var{capture:i=!1,passive:s=!0}=r??{};n?.addEventListener(e,t,{capture:i,passive:s})}var No="$people_distinct_id",jt="__alias",Gt="__timers",Ms="$autocapture_disabled_server_side",Gr="$heatmaps_enabled_server_side",Rs="$exception_capture_enabled_server_side",Lr="$error_tracking_suppression_rules",As="$error_tracking_capture_extension_exceptions",Ts="$web_vitals_enabled_server_side",qo="$dead_clicks_enabled_server_side",Fs="$product_tours_enabled_server_side",Os="$web_vitals_allowed_metrics",ar="$session_recording_remote_config",wn="$sesid",jo="$session_is_sampled",ht="$enabled_feature_flags",Lt="$early_access_features",Vr="$feature_flag_details",Vt="$stored_person_properties",Xe="$stored_group_properties",Ur="$surveys",xn="$flag_call_reported",Ce="$user_state",zr="$client_session_props",Hr="$capture_rate_limit",Kr="$initial_campaign_params",Br="$initial_referrer_info",En="$initial_person_info",Pn="$epp",Go="__POSTHOG_TOOLBAR__",Mt="$posthog_cookieless",Bl=[No,jt,"__cmpns",Gt,"$session_recording_enabled_server_side",Gr,wn,ht,Lr,Ce,Lt,Vr,Xe,Vt,Ur,xn,zr,Hr,Kr,Br,Pn,En,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function $s(n){return n instanceof Element&&(n.id===Go||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function Un(n){return!!n&&n.nodeType===1}function Ue(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function Lo(n){return!!n&&n.nodeType===3}function Vo(n){return!!n&&n.nodeType===11}function ji(n){return n?Ln(n).split(/\s+/):[]}function Ds(n){var e=v?.location.href;return!!(e&&n&&n.some(t=>e.match(t)))}function Sn(n){var e="";switch(typeof n.className){case"string":e=n.className;break;case"object":e=(n.className&&"baseVal"in n.className?n.className.baseVal:null)||n.getAttribute("class")||"";break;default:e=""}return ji(e)}function Uo(n){return T(n)?null:Ln(n).split(/(\s+)/).filter(e=>Qt(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function tn(n){var e="";return Wr(n)&&!Wo(n)&&n.childNodes&&n.childNodes.length&&N(n.childNodes,function(t){var r;Lo(t)&&t.textContent&&(e+=(r=Uo(t.textContent))!==null&&r!==void 0?r:"")}),Ln(e)}function zo(n){return w(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var Gi=["a","button","form","input","select","textarea","label"];function Ho(n,e){if(w(e))return!0;var t,r=function(s){if(e.some(o=>s.matches(o)))return{v:!0}};for(var i of n)if(t=r(i))return t.v;return!1}function Ko(n){var e=n.parentNode;return!(!e||!Un(e))&&e}var Wl=["next","previous","prev",">","<"],Ns=10,qs=[".ph-no-rageclick",".ph-no-capture"];function Xl(n,e){if(!v||Li(n))return!1;var t,r,i;if(Ae(e)?(t=!!e&&qs,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:qs,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=Bo(n,!1);return!function(o,a){if(o===!1||w(o))return!1;var l;if(o===!0)l=Wl;else{if(!$(o))return!1;if(o.length>Ns)return x.error("[PostHog] content_ignorelist array cannot exceed "+Ns+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map(c=>c.toLowerCase())}return a.some(c=>{var{safeText:u,ariaLabel:p}=c;return l.some(h=>u.includes(h)||p.includes(h))})}(r,s.map(o=>{var a;return{safeText:tn(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}}))&&!Ho(s,t)}var Li=n=>!n||Ue(n,"html")||!Un(n),Bo=(n,e)=>{if(!v||Li(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!Ue(i,"body");)if(Vo(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=Ko(i);if(!s)break;if(e||Gi.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=v.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),i=s}return{parentIsUsefulElement:t,targetElementList:r}};function Yl(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!v||Li(n)||(s=t)!=null&&s.url_allowlist&&!Ds(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Ds(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some(g=>e.type===g))return!1}var{parentIsUsefulElement:u,targetElementList:p}=Bo(n,r);if(!function(g,f){var y=f?.element_allowlist;if(w(y))return!0;var P,b=function(m){if(y.some(S=>m.tagName.toLowerCase()===S))return{v:!0}};for(var _ of g)if(P=b(_))return P.v;return!1}(p,t)||!Ho(p,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var h=v.getComputedStyle(n);if(h&&h.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var d=n.tagName.toLowerCase();switch(d){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 u?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Gi.indexOf(d)>-1||n.getAttribute("contenteditable")==="true")}}function Wr(n){for(var e=n;e.parentNode&&!Ue(e,"body");e=e.parentNode){var t=Sn(e);if(A(t,"ph-sensitive")||A(t,"ph-no-capture"))return!1}if(A(Sn(n),"ph-include"))return!0;var r=n.type||"";if(H(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=n.name||n.id||"";return!(H(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 Wo(n){return!!(Ue(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Ue(n,"select")||Ue(n,"textarea")||n.getAttribute("contenteditable")==="true")}var Xo="(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})",Jl=new RegExp("^(?:"+Xo+")$"),Zl=new RegExp(Xo),Yo="\\d{3}-?\\d{2}-?\\d{4}",Ql=new RegExp("^("+Yo+")$"),eu=new RegExp("("+Yo+")");function Qt(n,e){return e===void 0&&(e=!0),!(T(n)||H(n)&&(n=Ln(n),(e?Jl:Zl).test((n||"").replace(/[- ]/g,""))||(e?Ql:eu).test(n)))}function Jo(n){var e=tn(n);return Qt(e=(e+" "+Zo(n)).trim())?e:""}function Zo(n){var e="";return n&&n.childNodes&&n.childNodes.length&&N(n.childNodes,function(t){var r;if(t&&((r=t.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=tn(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Zo(t)).trim())}catch(s){x.error("[AutoCapture]",s)}}),e}function tu(n){return function(e){var t=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=E({},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),c={};return yn(l).sort((u,p)=>{var[h]=u,[d]=p;return h.localeCompare(d)}).forEach(u=>{var[p,h]=u;return c[js(p.toString())]=js(h.toString())}),o+=":",o+=yn(c).map(u=>{var[p,h]=u;return p+'="'+h+'"'}).join("")});return t.join(";")}(function(e){return e.map(t=>{var r,i,s={text:(r=t.$el_text)==null?void 0:r.slice(0,400),tag_name:t.tag_name,href:(i=t.attr__href)==null?void 0:i.slice(0,2048),attr_class:nu(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return yn(t).filter(o=>{var[a]=o;return a.indexOf("attr__")===0}).forEach(o=>{var[a,l]=o;return s.attributes[a]=l}),s})}(n))}function js(n){return n.replace(/"|\\"/g,'\\"')}function nu(n){var e=n.attr__class;return e?$(e)?e:ji(e):void 0}var Cn=class{constructor(e){this.disabled=e===!1;var t=z(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&r-i.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}},In=n=>{var e=k?.createElement("a");return w(e)?null:(e.href=n,e)},ru=function(n,e){var t,r;e===void 0&&(e="&");var i=[];return N(n,function(s,o){w(s)||w(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),i[i.length]=r+"="+t)}),i.join(e)},Mn=function(n,e){for(var t,r=((n.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===e){t=s;break}}if(!$(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{x.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},nn=function(n,e,t){if(!n||!e||!e.length)return n;for(var r=n.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],p=0;p<c.length;p++){var h=c[p].split("=");$(h)&&(e.includes(h[0])?u.push(h[0]+"="+t):u.push(c[p]))}var d=l;return a!=null&&(d+="?"+u.join("&")),s!=null&&(d+="#"+s),d},Rn=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},lr="$copy_autocapture",Gs=G("[AutoCapture]");function ur(n,e){return e.length>n?e.slice(0,n)+"...":e}function iu(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!Un(e));return e}function su(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};Gi.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=ur(1024,Jo(n)):s.$el_text=ur(1024,tn(n)));var o=Sn(n);o.length>0&&(s.classes=o.filter(function(u){return u!==""})),N(n.attributes,function(u){var p;if((!Wo(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Qt(u.value)&&(p=u.name,!H(p)||p.substring(0,10)!=="_ngcontent"&&p.substring(0,7)!=="_nghost")){var h=u.value;u.name==="class"&&(h=ji(h).join(" ")),s["attr__"+u.name]=ur(1024,h)}});for(var a=1,l=1,c=n;c=iu(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function ou(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!Ue(u,"body");)Vo(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var p,h=[],d={},g=!1,f=!1;if(N(c,m=>{var S=Wr(m);m.tagName.toLowerCase()==="a"&&(g=m.getAttribute("href"),g=S&&g&&Qt(g)&&g),A(Sn(m),"ph-no-capture")&&(f=!0),h.push(su(m,s,o,a));var F=function(O){if(!Wr(O))return{};var C={};return N(O.attributes,function(V){if(V.name&&V.name.indexOf("data-ph-capture-attribute")===0){var X=V.name.replace("data-ph-capture-attribute-",""),re=V.value;X&&re&&Qt(re)&&(C[X]=re)}}),C}(m);L(d,F)}),f)return{props:{},explicitNoCapture:f};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?h[0].$el_text=Jo(n):h[0].$el_text=tn(n)),g){var y,P;h[0].attr__href=g;var b=(y=In(g))==null?void 0:y.host,_=v==null||(P=v.location)==null?void 0:P.host;b&&_&&b!==_&&(p=g)}return{props:L({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:tu(h)},(t=h[0])!=null&&t.$el_text?{$el_text:(r=h[0])==null?void 0:r.$el_text}:{},p&&i.type==="click"?{$external_click_url:p}:{},d)}}var Xr=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Cn(e.config.rageclick),this.C=null}get R(){var e,t,r=z(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=(t=r.url_ignorelist)==null?void 0:t.map(i=>new RegExp(i)),r}F(){if(this.isBrowserSupported()){if(v&&k){var e=r=>{r=r||v?.event;try{this.O(r)}catch(i){Gs.error("Failed to capture event",i)}};if(U(k,"submit",e,{capture:!0}),U(k,"change",e,{capture:!0}),U(k,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||v?.event,this.O(r,lr)};U(k,"copy",t,{capture:!0}),U(k,"cut",t,{capture:!0})}}}else Gs.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ms]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,r=[];return(t=this.C)==null||t.forEach(i=>{var s=k?.querySelectorAll(i);s?.forEach(o=>{e===o&&r.push(i)})}),r}get isEnabled(){var e,t,r=(e=this.instance.persistence)==null?void 0:e.props[Ms],i=this.T;if(ye(i)&&!Ae(r)&&!this.instance.M())return!1;var s=(t=this.T)!==null&&t!==void 0?t:!!r;return!!this.instance.config.autocapture&&!s}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var r,i=zo(e);Lo(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&Xl(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===lr;if(i&&Yl(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=ou(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(o.$element_selectors=l),t===lr){var c,u=Uo(v==null||(c=v.getSelection())==null?void 0:c.toString()),p=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=p}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return Le(k?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return Te(n)&&isFinite(n)&&Math.floor(n)===n});var Ls="0123456789abcdef",Yr=class n{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||t<0||r<0||i<0||e>0xffffffffffff||t>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|t>>>8,s[7]=t,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 n(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ls.charAt(this.bytes[t]>>>4)+Ls.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new n(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(r!==0)return Math.sign(r)}return 0}},Jr=class{constructor(){this.A=0,this.j=0,this.D=new Zr}generate(){var e=this.generateOrAbort();if(w(e)){this.A=0;var t=this.generateOrAbort();if(w(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return Yr.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}},Vs,Qo=n=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<n.length;e++)n[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return n};v&&!w(v.crypto)&&crypto.getRandomValues&&(Qo=n=>crypto.getRandomValues(n));var Zr=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(Qo(this.N),this.U=0),this.N[this.U++]}},Ge=()=>au().toString(),au=()=>(Vs||(Vs=new Jr)).generate(),Rt="",lu=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function uu(n,e){if(e){var t=function(i,s){if(s===void 0&&(s=k),Rt)return Rt;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+Ge();!Rt&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";s.cookie=u+";max-age=3",s.cookie.includes(l)&&(s.cookie=u+";max-age=0",Rt=c)}return Rt}(n);if(!t){var r=(i=>{var s=i.match(lu);return s?s[0]:""})(n);r!==t&&x.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var be={H:()=>!!k,B:function(n){x.error("cookieStore error: "+n)},q:function(n){if(k){try{for(var e=n+"=",t=k.cookie.split(";").filter(s=>s.length),r=0;r<t.length;r++){for(var i=t[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}},W:function(n){var e;try{e=JSON.parse(be.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(k)try{var s="",o="",a=uu(k.location.hostname,r);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),s="; expires="+l.toUTCString()}i&&(o="; secure");var c=n+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&x.warn("cookieStore warning: large cookie, len="+c.length),k.cookie=c,c}catch{return}},V:function(n,e){if(k!=null&&k.cookie)try{be.G(n,"",-1,e)}catch{return}}},cr=null,j={H:function(){if(!ye(cr))return cr;var n=!0;if(w(v))n=!1;else try{var e="__mplssupport__";j.G(e,"xyz"),j.q(e)!=='"xyz"'&&(n=!1),j.V(e)}catch{n=!1}return n||x.error("localStorage unsupported; falling back to cookie store"),cr=n,n},B:function(n){x.error("localStorage error: "+n)},q:function(n){try{return v?.localStorage.getItem(n)}catch(e){j.B(e)}return null},W:function(n){try{return JSON.parse(j.q(n))||{}}catch{}return null},G:function(n,e){try{v?.localStorage.setItem(n,JSON.stringify(e))}catch(t){j.B(t)}},V:function(n){try{v?.localStorage.removeItem(n)}catch(e){j.B(e)}}},cu=["$device_id","distinct_id",wn,jo,Pn,En],hn={},pu={H:function(){return!0},B:function(n){x.error("memoryStorage error: "+n)},q:function(n){return hn[n]||null},W:function(n){return hn[n]||null},G:function(n,e){hn[n]=e},V:function(n){delete hn[n]}},Be=null,K={H:function(){if(!ye(Be))return Be;if(Be=!0,w(v))Be=!1;else try{var n="__support__";K.G(n,"xyz"),K.q(n)!=='"xyz"'&&(Be=!1),K.V(n)}catch{Be=!1}return Be},B:function(n){x.error("sessionStorage error: ",n)},q:function(n){try{return v?.sessionStorage.getItem(n)}catch(e){K.B(e)}return null},W:function(n){try{return JSON.parse(K.q(n))||null}catch{}return null},G:function(n,e){try{v?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){K.B(t)}},V:function(n){try{v?.sessionStorage.removeItem(n)}catch(e){K.B(e)}}},Ie=function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n}({}),Qr=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Ie.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===Ie.DENIED||this.consent===Ie.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ie.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:r}=this._instance.config;return r||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return ir(e)?Ie.GRANTED:A(_l,e)?Ie.DENIED:Ie.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?j:be;var t=e==="localStorage"?be:j;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(ir(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Do([le?.doNotTrack,le?.msDoNotTrack,I.doNotTrack],e=>ir(e))}},fn=G("[Dead Clicks]"),du=()=>!0,hu=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(qo)),r=n.instance.config.capture_dead_clicks;return Ae(r)?r:!!z(r)||t},An=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,r){this.instance=e,this.isEnabled=t,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[qo]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?fn.error("failed to load script",i):e()})}et(){var e;if(k){if(!this.tt&&(e=I.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=z(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=I.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(k),fn.info("starting...")}}else fn.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,fn.info("stopping..."))}},At=G("[ExceptionAutocapture]"),ei=class{constructor(e){var t,r,i;this.rt=()=>{var s;if(v&&this.isEnabled&&(s=I.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=I.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=I.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=I.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){At.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[Rs]),this.dt=new Sr({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,h:At}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return z(e)?t=E({},t,e):(w(e)?this.ht:e)&&(t=E({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(At.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return At.error("failed to load script",i);e()})}ut(){var e,t,r;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Rs]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,r,i=(t=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(i)?At.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function Us(n,e,t){try{if(!(e in n))return()=>{};var r=n[e],i=t(r);return Le(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=i,()=>{n[e]=r}}catch{return()=>{}}}var ti=class{constructor(e){var t;this._instance=e,this.ct=(v==null||(t=v.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(x.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,x.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(v&&v.history){var r=this;(e=v.history.pushState)!=null&&e.__posthog_wrapped__||Us(v.history,"pushState",i=>function(s,o,a){i.call(this,s,o,a),r._t("pushState")}),(t=v.history.replaceState)!=null&&t.__posthog_wrapped__||Us(v.history,"replaceState",i=>function(s,o,a){i.call(this,s,o,a),r._t("replaceState")}),this.bt()}}_t(e){try{var t,r=v==null||(t=v.location)==null?void 0:t.pathname;if(!r)return;r!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=r}catch(i){x.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};U(v,"popstate",e),this.ft=()=>{v&&v.removeEventListener("popstate",e)}}}},pr=G("[SegmentIntegration]");function fu(n,e){var t=n.config.segment;if(!t)return e();(function(r,i){var s=r.config.segment;if(!s)return i();var o=l=>{var c=()=>l.anonymousId()||Ge();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(Ce,"identified")),i()},a=s.user();"then"in a&&Le(a.then)?a.then(o):o(a)})(n,()=>{t.register((r=>{Promise&&Promise.resolve||pr.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()||(pr.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(pr.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")}})(n)).then(()=>{e()})})}var ea="posthog-js";function ta(n,e){var{organization:t,projectId:r,prefix:i,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,p,h;if(!(s==="*"||s.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var d=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=d,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var g=((l=a.exception)==null?void 0:l.values)||[],f=g.map(P=>E({},P,{stacktrace:P.stacktrace?E({},P.stacktrace,{type:"raw",frames:(P.stacktrace.frames||[]).map(b=>E({},b,{platform:"web:javascript"}))}):void 0})),y={$exception_message:((c=g[0])==null?void 0:c.value)||a.message,$exception_type:(u=g[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:f,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((p=g[0])==null?void 0:p.value)||a.message,$sentry_exception_type:(h=g[0])==null?void 0:h.type,$sentry_tags:a.tags};return t&&r&&(y.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),o&&n.exceptions.sendExceptionEvent(y),a}}var ni=class{constructor(e,t,r,i,s,o){this.name=ea,this.setupOnce=function(a){a(ta(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},gu=v!=null&&v.location?Rn(v.location.hash,"__posthog")||Rn(location.hash,"state"):null,zs="_postHogToolbarParams",Hs=G("[Toolbar]"),je=function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n}(je||{}),ri=class{constructor(e){this.instance=e}yt(e){I.ph_toolbar_state=e}wt(){var e;return(e=I.ph_toolbar_state)!==null&&e!==void 0?e:je.UNINITIALIZED}maybeLoadToolbar(e,t,r){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),!v||!k)return!1;e=e??v.location,r=r??v.history;try{if(!t){try{v.localStorage.setItem("test","test"),v.localStorage.removeItem("test")}catch{return!1}t=v?.localStorage}var i,s=gu||Rn(e.hash,"__posthog")||Rn(e.hash,"state"),o=s?Is(()=>JSON.parse(atob(decodeURIComponent(s))))||Is(()=>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(t.getItem(zs)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=I.ph_load_toolbar||I.ph_load_editor;!T(t)&&Le(t)?t(e,this.instance):Hs.warn("No toolbar load function found")}loadToolbar(e){var t=!(k==null||!k.getElementById(Go));if(!v||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=E({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(v.localStorage.setItem(zs,JSON.stringify(E({},i,{source:void 0}))),this.wt()===je.LOADED)this.xt(i);else if(this.wt()===je.UNINITIALIZED){var s;this.yt(je.LOADING),(s=I.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",o=>{if(o)return Hs.error("[Toolbar] Failed to load",o),void this.yt(je.UNINITIALIZED);this.yt(je.LOADED),this.xt(i)}),U(v,"turbolinks:load",()=>{this.yt(je.UNINITIALIZED),this.loadToolbar(i)})}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,r){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,t,r)}},vu=G("[TracingHeaders]"),ii=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;w(this.$t)&&((t=I.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),w(this.St)&&((r=I.__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}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return vu.error("failed to load script",i);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}},gn="https?://(.*)",bt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],yu=_t(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],bt),rn="<masked>",mu=["li_fat_id"];function na(n,e,t){if(!k)return{};var r,i=e?_t([],bt,t||[]):[],s=ra(nn(k.URL,i,rn),n),o=(r={},N(mu,function(a){var l=be.q(a);r[a]=l||null}),r);return L(o,s)}function ra(n,e){var t=yu.concat(e||[]),r={};return N(t,function(i){var s=Mn(n,i);r[i]=s||null}),r}function ia(n){var e=function(s){return s?s.search(gn+"google.([^/?]*)")===0?"google":s.search(gn+"bing.com")===0?"bing":s.search(gn+"yahoo.com")===0?"yahoo":s.search(gn+"duckduckgo.com")===0?"duckduckgo":null:null}(n),t=e!="yahoo"?"q":"p",r={};if(!ye(e)){r.$search_engine=e;var i=k?Mn(k.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function Ks(){return navigator.language||navigator.userLanguage}function sa(){return k?.referrer||"$direct"}function oa(n,e){var t=n?_t([],bt,e||[]):[],r=B?.href.substring(0,1e3);return{r:sa().substring(0,1e3),u:r?nn(r,t,rn):void 0}}function aa(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=In(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=In(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=ra(r);L(i,o)}if(t){var a=ia(t);L(i,a)}return i}function la(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function _u(){try{return new Date().getTimezoneOffset()}catch{return}}function bu(n,e){if(!se)return{};var t,r,i,s=n?_t([],bt,e||[]):[],[o,a]=function(l){for(var c=0;c<xs.length;c++){var[u,p]=xs[c],h=u.exec(l),d=h&&(Le(p)?p(h,l):p);if(d)return d}return["",""]}(se);return L(qi({$os:o,$os_version:a,$browser:To(se,navigator.vendor),$device:Es(se),$device_type:(r=se,i=Es(r),i===mo||i===yo||i==="Kobo"||i==="Kindle Fire"||i===Ao?Xt:i===Jt||i===gt||i===Zt||i===Ir?"Console":i===bo?"Wearable":i?fe:"Desktop"),$timezone:la(),$timezone_offset:_u()}),{$current_url:nn(B?.href,s,rn),$host:B?.host,$pathname:B?.pathname,$raw_user_agent:se.length>1e3?se.substring(0,997)+"...":se,$browser_version:Ml(se,navigator.vendor),$browser_language:Ks(),$browser_language_prefix:(t=Ks(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:v?.screen.height,$screen_width:v?.screen.width,$viewport_height:v?.innerHeight,$viewport_width:v?.innerWidth,$lib:"web",$lib_version:Se.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var De=G("[Web Vitals]"),Bs=9e5,si=class{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce((r,i)=>E({},r,{["$web_vitals_"+i.name+"_event"]:E({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=r=>{var i,s=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(w(s))De.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();w(o)||(T(r?.name)||T(r?.value)?De.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?De.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),w(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=w(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(E({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var r,i,s,o,a=I.__PosthogExtensions__;w(a)||w(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&i&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.It.bind(this)),this.P=!0):De.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[Ts]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=z(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return T(r)?((t=this._instance.persistence)==null?void 0:t.props[Os])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(z(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=z(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=z(this._instance.config.capture_performance)&&Te(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Bs;return 0<e&&e<=6e4?Bs:e}get isEnabled(){var e=B?.protocol;if(e!=="http:"&&e!=="https:")return De.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=z(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:Ae(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Ae(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(De.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=z(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=z(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ts]:t}),this._instance.persistence.register({[Os]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=I.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,s=>{s?De.error("failed to load script",s):e()})}}Ct(){var e=v?v.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,i=t?_t([],bt,r||[]):[];return nn(e,i,rn)}De.error("Could not determine current URL")}},ku=G("[Heatmaps]");function Ws(n){return z(n)&&"clientX"in n&&"clientY"in n&&Te(n.clientX)&&Te(n.clientY)}var oi=class{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[Gr]),this.rageclicks=new Cn(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return z(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 T(this.instance.config.capture_heatmaps)?T(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;ku.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Gr]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=function(e){return e?.visibilityState==="visible"}(k)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){v&&k&&(this.Nt=this.Lt.bind(this),U(v,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||v?.event),U(k,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||v?.event),U(k,"mousemove",this.zt,{capture:!0}),this.Bt=new An(this.instance,du,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),U(k,"visibilitychange",this.qt),this.P=!0)}At(){var e;v&&k&&(this.Nt&&v.removeEventListener("beforeunload",this.Nt),this.Ut&&k.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&k.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&k.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=function(a,l,c){for(var u=a;u&&Un(u)&&!Ue(u,"body");){if(u===c)return!1;if(A(l,v?.getComputedStyle(u).position))return!0;u=Ko(u)}return!1}(zo(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:t}}Dt(e,t){var r;if(t===void 0&&(t="click"),!$s(e.target)&&Ws(e)){var i=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(E({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!$s(e.target)&&Ws(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(v){var t=v.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?_t([],bt,i||[]):[],o=nn(t,s,rn);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!dt(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Tn=class{constructor(e){this.Jt=(t,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(x.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var r,i=this.Qt(e,t);return this.Kt={pathname:(r=v?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var r=this.Kt;if(!r)return{$pageview_id:t};var i={$pageview_id:t,$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:c,lastContentY:u,maxContentY:p}=s;if(!(w(o)||w(a)||w(l)||w(c)||w(u)||w(p))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),p=Math.ceil(p);var h=o<=1?1:ke(a/o,0,1,x),d=o<=1?1:ke(l/o,0,1,x),g=c<=1?1:ke(u/c,0,1,x),f=c<=1?1:ke(p/c,0,1,x);i=L(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:p,$prev_pageview_max_content_percentage:f})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}};var Me=function(n){return n.GZipJS="gzip-js",n.Base64="base64",n}({}),ge=Uint8Array,ne=Uint16Array,mt=Uint32Array,Vi=new ge([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]),Ui=new ge([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]),Xs=new ge([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ua=function(n,e){for(var t=new ne(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new mt(t[30]);for(r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return[t,i]},ca=ua(Vi,2),wu=ca[0],ai=ca[1];wu[28]=258,ai[258]=28;for(li=ua(Ui,0)[1],Fn=new ne(32768),q=0;q<32768;++q)Ne=(43690&q)>>>1|(21845&q)<<1,Ne=(61680&(Ne=(52428&Ne)>>>2|(13107&Ne)<<2))>>>4|(3855&Ne)<<4,Fn[q]=((65280&Ne)>>>8|(255&Ne)<<8)>>>1;var Ne,li,Fn,q,Kt=function(n,e,t){for(var r=n.length,i=0,s=new ne(e);i<r;++i)++s[n[i]-1];var o,a=new ne(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new ne(1<<e);var l=15-e;for(i=0;i<r;++i)if(n[i])for(var c=i<<4|n[i],u=e-n[i],p=a[n[i]-1]++<<u,h=p|(1<<u)-1;p<=h;++p)o[Fn[p]>>>l]=c}else for(o=new ne(r),i=0;i<r;++i)o[i]=Fn[a[n[i]-1]++]>>>15-n[i];return o},Je=new ge(288);for(q=0;q<144;++q)Je[q]=8;for(q=144;q<256;++q)Je[q]=9;for(q=256;q<280;++q)Je[q]=7;for(q=280;q<288;++q)Je[q]=8;var On=new ge(32);for(q=0;q<32;++q)On[q]=5;var xu=Kt(Je,9,0),Eu=Kt(On,5,0),pa=function(n){return(n/8>>0)+(7&n&&1)},da=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof ne?ne:n instanceof mt?mt:ge)(t-e);return r.set(n.subarray(e,t)),r},Ee=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},Tt=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8,n[r+2]|=t>>>16},dr=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var i=t.length,s=t.slice();if(!i)return[new ge(0),0];if(i==1){var o=new ge(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort(function(S,F){return S.f-F.f}),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,p=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=t[t[c].f<t[p].f?c++:p++],l=t[c!=u&&t[c].f<t[p].f?c++:p++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(r=1;r<i;++r)s[r].s>h&&(h=s[r].s);var d=new ne(h+1),g=ui(t[u-1],d,0);if(g>e){r=0;var f=0,y=g-e,P=1<<y;for(s.sort(function(S,F){return d[F.s]-d[S.s]||S.f-F.f});r<i;++r){var b=s[r].s;if(!(d[b]>e))break;f+=P-(1<<g-d[b]),d[b]=e}for(f>>>=y;f>0;){var _=s[r].s;d[_]<e?f-=1<<e-d[_]++-1:++r}for(;r>=0&&f;--r){var m=s[r].s;d[m]==e&&(--d[m],++f)}g=e}return[new ge(d),g]},ui=function(n,e,t){return n.s==-1?Math.max(ui(n.l,e,t+1),ui(n.r,e,t+1)):e[n.s]=t},Ys=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new ne(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[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=n[a]}return[t.subarray(0,r),e]},Ft=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},ci=function(n,e,t){var r=t.length,i=pa(e+2);n[i]=255&r,n[i+1]=r>>>8,n[i+2]=255^n[i],n[i+3]=255^n[i+1];for(var s=0;s<r;++s)n[i+s+4]=t[s];return 8*(i+4+r)},Js=function(n,e,t,r,i,s,o,a,l,c,u){Ee(e,u++,t),++i[256];for(var p=dr(i,15),h=p[0],d=p[1],g=dr(s,15),f=g[0],y=g[1],P=Ys(h),b=P[0],_=P[1],m=Ys(f),S=m[0],F=m[1],O=new ne(19),C=0;C<b.length;++C)O[31&b[C]]++;for(C=0;C<S.length;++C)O[31&S[C]]++;for(var V=dr(O,7),X=V[0],re=V[1],Q=19;Q>4&&!X[Xs[Q-1]];--Q);var Y,ie,J,de,ve=c+5<<3,xe=Ft(i,Je)+Ft(s,On)+o,me=Ft(i,h)+Ft(s,f)+o+14+3*Q+Ft(O,X)+(2*O[16]+3*O[17]+7*O[18]);if(ve<=xe&&ve<=me)return ci(e,u,n.subarray(l,l+c));if(Ee(e,u,1+(me<xe)),u+=2,me<xe){Y=Kt(h,d,0),ie=h,J=Kt(f,y,0),de=f;var Fe=Kt(X,re,0);for(Ee(e,u,_-257),Ee(e,u+5,F-1),Ee(e,u+10,Q-4),u+=14,C=0;C<Q;++C)Ee(e,u+3*C,X[Xs[C]]);u+=3*Q;for(var st=[b,S],ee=0;ee<2;++ee){var he=st[ee];for(C=0;C<he.length;++C){var oe=31&he[C];Ee(e,u,Fe[oe]),u+=X[oe],oe>15&&(Ee(e,u,he[C]>>>5&127),u+=he[C]>>>12)}}}else Y=xu,ie=Je,J=Eu,de=On;for(C=0;C<a;++C)if(r[C]>255){oe=r[C]>>>18&31,Tt(e,u,Y[oe+257]),u+=ie[oe+257],oe>7&&(Ee(e,u,r[C]>>>23&31),u+=Vi[oe]);var ot=31&r[C];Tt(e,u,J[ot]),u+=de[ot],ot>3&&(Tt(e,u,r[C]>>>5&8191),u+=Ui[ot])}else Tt(e,u,Y[r[C]]),u+=ie[r[C]];return Tt(e,u,Y[256]),u+ie[256]},Pu=new mt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Su=function(){for(var n=new mt(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n}(),Cu=function(n,e,t,r,i){return function(s,o,a,l,c,u){var p=s.length,h=new ge(l+p+5*(1+Math.floor(p/7e3))+c),d=h.subarray(l,h.length-c),g=0;if(!o||p<8)for(var f=0;f<=p;f+=65535){var y=f+65535;y<p?g=ci(d,g,s.subarray(f,y)):(d[f]=u,g=ci(d,g,s.subarray(f,p)))}else{for(var P=Pu[o-1],b=P>>>13,_=8191&P,m=(1<<a)-1,S=new ne(32768),F=new ne(m+1),O=Math.ceil(a/3),C=2*O,V=function(rr){return(s[rr]^s[rr+1]<<O^s[rr+2]<<C)&m},X=new mt(25e3),re=new ne(288),Q=new ne(32),Y=0,ie=0,J=(f=0,0),de=0,ve=0;f<p;++f){var xe=V(f),me=32767&f,Fe=F[xe];if(S[me]=Fe,F[xe]=me,de<=f){var st=p-f;if((Y>7e3||J>24576)&&st>423){g=Js(s,d,0,X,re,Q,ie,J,ve,f-ve,g),J=Y=ie=0,ve=f;for(var ee=0;ee<286;++ee)re[ee]=0;for(ee=0;ee<30;++ee)Q[ee]=0}var he=2,oe=0,ot=_,Oe=me-Fe&32767;if(st>2&&xe==V(f-Oe))for(var tl=Math.min(b,st)-1,nl=Math.min(32767,f),rl=Math.min(258,st);Oe<=nl&&--ot&&me!=Fe;){if(s[f+he]==s[f+he-Oe]){for(var $e=0;$e<rl&&s[f+$e]==s[f+$e-Oe];++$e);if($e>he){if(he=$e,oe=Oe,$e>tl)break;var il=Math.min(Oe,$e-2),us=0;for(ee=0;ee<il;++ee){var nr=f-Oe+ee+32768&32767,cs=nr-S[nr]+32768&32767;cs>us&&(us=cs,Fe=nr)}}}Oe+=(me=Fe)-(Fe=S[me])+32768&32767}if(oe){X[J++]=268435456|ai[he]<<18|li[oe];var ps=31&ai[he],ds=31&li[oe];ie+=Vi[ps]+Ui[ds],++re[257+ps],++Q[ds],de=f+he,++Y}else X[J++]=s[f],++re[s[f]]}}g=Js(s,d,u,X,re,Q,ie,J,ve,f-ve,g)}return da(h,0,l+pa(g)+c)}(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,r,!0)},hr=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function Iu(n,e){e===void 0&&(e={});var t=function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=Su[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}}(),r=n.length;t.p(n);var i,s=Cu(n,e,10+((i=e).filename&&i.filename.length+1||0),8),o=s.length;return function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&hr(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}}(s,e),hr(s,o-8,t.d()),hr(s,o-4,r),s}var Mu=function(n){var e,t,r,i,s="";for(e=t=0,r=(n=(n+"").replace(/\r\n/g,`
10
10
  `).replace(/\r/g,`
11
- `)).length,i=0;i<r;i++){var o=n.charCodeAt(i),a=null;o<128?t++: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),ye(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},Ru=!!wn||!!kn,Zs="text/plain",Or=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=E({},e),a=(r=s?.split("&").map(c=>{var u,[p,h]=c.split("="),d=t&&(u=o[p])!==null&&u!==void 0?u:h;return delete o[p],p+"="+d}))!==null&&r!==void 0?r:[],l=nu(o);return l&&a.push(l),i+"?"+a.join("&")},Ut=(n,e)=>JSON.stringify(n,(t,r)=>typeof r=="bigint"?r.toString():r,e),fn=n=>{var{data:e,compression:t}=n;if(e){if(t===Me.GZipJS){var r=Iu(function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new ge(l.length+(l.length>>>1)),h=0,d=function(S){p[h++]=S},f=0;f<u;++f){if(h+5>p.length){var v=new ge(h+8+(u-f<<1));v.set(p),p=v}var y=l.charCodeAt(f);y<128||c?d(y):y<2048?(d(192|y>>>6),d(128|63&y)):y>55295&&y<57344?(d(240|(y=65536+(1047552&y)|1023&l.charCodeAt(++f))>>>18),d(128|y>>>12&63),d(128|y>>>6&63),d(128|63&y)):(d(224|y>>>12),d(128|y>>>6&63),d(128|63&y))}return da(p,0,h)}(Ut(e)),{mtime:0}),i=new Blob([r],{type:Zs});return{contentType:Zs,body:i,estimatedSize:i.size}}if(t===Me.Base64){var s=function(l){var c,u,p,h,d,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,y=0,S="",w=[];if(!l)return l;l=Mu(l);do c=(d=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=d>>12&63,p=d>>6&63,h=63&d,w[y++]=f.charAt(c)+f.charAt(u)+f.charAt(p)+f.charAt(h);while(v<l.length);switch(S=w.join(""),l.length%3){case 1:S=S.slice(0,-2)+"==";break;case 2:S=S.slice(0,-1)+"="}return S}(Ut(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Ut(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Ut(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},yr=[];kn&&yr.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=fn(n))!==null&&e!==void 0?e:{},o=new Headers;N(n.headers,function(u,p){o.append(p,u)}),r&&o.append("Content-Type",r);var a=n.url,l=null;if(ms){var c=new ms;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),n.timeout)}}kn(a,E({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(s||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then(u=>u.text().then(p=>{var h={statusCode:u.status,text:p};if(u.status===200)try{h.json=JSON.parse(p)}catch(d){k.error(d)}n.callback==null||n.callback(h)})).catch(u=>{k.error(u),n.callback==null||n.callback({statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),wn&&yr.push({transport:"XHR",method:n=>{var e,t=new wn;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=fn(n))!==null&&e!==void 0?e:{};N(n.headers,function(s,o){t.setRequestHeader(o,s)}),r&&t.setRequestHeader("Content-Type",r),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(s)}},t.send(i)}}),le!=null&&le.sendBeacon&&yr.push({transport:"sendBeacon",method:n=>{var e=Or(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=fn(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;le.sendBeacon(e,s)}catch{}}});var $r=function(n,e){if(!function(t){try{new RegExp(t)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};function Qs(n,e,t){return Ut({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var ha={exact:(n,e)=>e.some(t=>n.some(r=>t===r)),is_not:(n,e)=>e.every(t=>n.every(r=>t!==r)),regex:(n,e)=>e.some(t=>n.some(r=>$r(t,r))),not_regex:(n,e)=>e.every(t=>n.every(r=>!$r(t,r))),icontains:(n,e)=>e.map(gr).some(t=>n.map(gr).some(r=>t.includes(r))),not_icontains:(n,e)=>e.map(gr).every(t=>n.map(gr).every(r=>!t.includes(r))),gt:(n,e)=>e.some(t=>{var r=parseFloat(t);return!isNaN(r)&&n.some(i=>r>parseFloat(i))}),lt:(n,e)=>e.some(t=>{var r=parseFloat(t);return!isNaN(r)&&n.some(i=>r<parseFloat(i))})},gr=n=>n.toLowerCase();function fa(n,e){return!n||Object.entries(n).every(t=>{var[r,i]=t,s=e?.[r];if(b(s)||ye(s))return!1;var o=[String(s)],a=ha[i.operator];return!!a&&a(i.values,o)})}var gn=G("[Error tracking]"),pi=class{constructor(e){var t,r;this.Zt=[],this.ti=new Rn([new Tn,new jn,new On,new Fn,new Nn,new Dn,new $n,new qn],jl()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Ln))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,i,s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[Ln]:this.Zt,[As]:o})}get ii(){var e,t=!!this._instance.get_property(As),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void gn.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void gn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void gn.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce((r,i)=>{var{type:s,value:o}=i;return H(s)&&s.length>0&&r.$exception_types.push(s),H(o)&&o.length>0&&r.$exception_values.push(o),r},{$exception_types:[],$exception_values:[]});return this.Zt.some(r=>{var i=r.values.map(s=>{var o,a=ha[s.operator],l=$(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)});return r.type==="OR"?i.some(Boolean):i.every(Boolean)})}si(e){return e.flatMap(t=>{var r,i;return(r=(i=t.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]}).some(t=>t.filename&&t.filename.startsWith("chrome-extension://"))}ni(e){if(e.length>0){var t,r,i,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(i=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ei(e){return!T(e)&&$(e)}},ae=G("[FeatureFlags]"),Ot=G("[FeatureFlags]",{debugEnabled:!0}),vn="$active_feature_flags",at="$override_feature_flags",eo="$feature_flag_payloads",$t="$override_feature_flag_payloads",to="$feature_flag_request_id",ro="$feature_flag_evaluated_at",no=n=>{var e={};for(var[t,r]of vr(n||{}))r&&(e[t]=r);return e},Au=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map(t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]})),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload}).map(t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]}))):ae.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},Tu=function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n}({}),di=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(ae.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter(r=>{var i=r&&typeof r=="string"&&r.trim().length>0;return i||ae.error("Invalid evaluation context found:",r,"Expected non-empty string"),i}):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Vn),t=this._instance.get_property(at),r=this._instance.get_property($t);if(!r&&!t)return e||{};var i=L({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=i[o],u=t?.[o],p=b(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,h=b(u)?c.variant:typeof u=="string"?u:void 0,d=r?.[o],f=E({},c,{enabled:p,variant:p?h??c?.variant:void 0});p!==c?.enabled&&(f.original_enabled=c?.enabled),h!==c?.variant&&(f.original_variant=c?.variant),d&&(f.metadata=E({},c?.metadata,{payload:d,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=f}return this.oi||(ae.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(ht),t=this._instance.get_property(at);if(!t)return e||{};for(var r=L({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ae.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(eo),t=this._instance.get_property($t);if(!t)return e||{};for(var r=L({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ae.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.oi=!0),r}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this.gi=setTimeout(()=>{this.mi()},5))}bi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.bi(),!this._instance.M())if(this.li)this.hi=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:E({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(Vt)||{}),group_properties:this._instance.get_property(Xe)};ye(i)||b(i)||(s.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(s.timezone=la()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Me.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var p,h,d=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),d=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((h=u.json)!==null&&h!==void 0?h:{})),!s.disable_flags||this.hi)if(this.vi=!d,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(Tu.FeatureFlags))ae.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 f;s.disable_flags||this.receivedFeatureFlags((f=u.json)!==null&&f!==void 0?f:{},d),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlagResult(e,t);return(r=i?.variant)!==null&&r!==void 0?r:i?.enabled}ae.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(to)||void 0,c=this._instance.get_property(ro)||void 0,u=this._instance.get_property(wr)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,h,d,f,v,y,S,w,x;$(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[wr]:u});var m=this.getFeatureFlagDetails(e),P={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((h=this._instance.config.bootstrap)==null||(h=h.featureFlags)==null?void 0:h[e])||null,$feature_flag_bootstrapped_payload:((d=this._instance.config.bootstrap)==null||(d=d.featureFlagPayloads)==null?void 0:d[e])||null,$used_bootstrap_value:!this.vi};b(m==null||(f=m.metadata)==null?void 0:f.version)||(P.$feature_flag_version=m.metadata.version);var F,O=(v=m==null||(y=m.reason)==null?void 0:y.description)!==null&&v!==void 0?v:m==null||(S=m.reason)==null?void 0:S.code;O&&(P.$feature_flag_reason=O),m!=null&&(w=m.metadata)!=null&&w.id&&(P.$feature_flag_id=m.metadata.id),b(m?.original_variant)&&b(m?.original_enabled)||(P.$feature_flag_original_response=b(m.original_variant)?m.original_enabled:m.original_variant),m!=null&&(x=m.metadata)!=null&&x.original_payload&&(P.$feature_flag_original_payload=m==null||(F=m.metadata)==null?void 0:F.original_payload),this._instance.capture("$feature_flag_called",P)}if(i){var C=o;if(!b(o))try{C=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:C}}}else ae.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(i.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:Me.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return b(r)?void 0:!!r}ae.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(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var p=Au(o),h=p.flags,d=p.featureFlags,f=p.featureFlagPayloads;if(d){var v=o.requestId,y=o.evaluatedAt;if($(d)){ae.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var S={};if(d)for(var w=0;w<d.length;w++)S[d[w]]=!0;a&&a.register({[vn]:d,[ht]:S})}else{var x=d,m=f,P=h;if(o.errorsWhileComputingFlags)if(h){var F=new Set(Object.keys(h).filter(O=>{var C;return!((C=h[O])!=null&&C.failed)}));x=E({},l,Object.fromEntries(Object.entries(x).filter(O=>{var[C]=O;return F.has(C)}))),m=E({},c,Object.fromEntries(Object.entries(m||{}).filter(O=>{var[C]=O;return F.has(C)}))),P=E({},u,Object.fromEntries(Object.entries(P||{}).filter(O=>{var[C]=O;return F.has(C)})))}else x=E({},l,x),m=E({},c,m),P=E({},u,P);a&&a.register(E({[vn]:Object.keys(no(x)),[ht]:x||{},[eo]:m||{},[Vn]:P||{}},v?{[to]:v}:{},y?{[ro]:y}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),ae.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ae.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(at),this._instance.persistence.unregister($t),this.wi(),Ot.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.oi=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(at),Ot.info("Flag overrides cleared");else if(r.flags){if($(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[at]:i})}else this._instance.persistence.register({[at]:r.flags});Ot.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister($t),Ot.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[$t]:r.payloads}),Ot.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var i,s=(this._instance.get_property(Lt)||[]).find(c=>c.flagKey===e),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$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=E({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[vn]:Object.keys(no(l)),[ht]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(Lt),s=r?"&"+r.map(o=>"stage="+o).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({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 c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Lt),(l=this._instance.persistence)==null||l.register({[Lt]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(r=>t[r]),flagVariants:Object.keys(t).filter(r=>t[r]).reduce((r,i)=>(r[i]=t[i],r),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach(i=>i(t,r,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Vt)||{};this._instance.register({[Vt]:E({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Vt)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Xe)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=E({},r[i],e[i]),delete e[i]}),this._instance.register({[Xe]:E({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Xe)||{};this._instance.register({[Xe]:E({},t,{[e]:{}})})}else this._instance.unregister(Xe)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.bi(),this.oi=!1}},Fu=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Bt=class{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(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.Y=this.Si(e),this.load(),e.debug&&k.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){Fu.indexOf(e.persistence.toLowerCase())===-1&&(k.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(i){i===void 0&&(i=[]);var s=[...cu,...i];return E({},j,{W:function(o){try{var a={};try{a=be.W(o)||{}}catch{}var l=L(a,JSON.parse(j.q(o)||"{}"));return j.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{j.G(o,a,void 0,void 0,p);var h={};s.forEach(d=>{a[d]&&(h[d]=a[d])}),Object.keys(h).length&&be.G(o,h,l,c,u,p)}catch(d){j.B(d)}},V:function(o,a){try{g?.localStorage.removeItem(o),be.V(o,a)}catch(l){j.B(l)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&j.H()?j:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&K.H()?K:r==="memory"?pu:r==="cookie"?be:t.H()?t:be}properties(){var e={};return N(this.props,function(t,r){if(r===ht&&z(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else a=r,l=!1,(ye(o=Bl)?l:ys&&o.indexOf===ys?o.indexOf(a)!=-1:(N(o,function(c){if(l||(l=c===a))return br}),l))||(e[r]=t);var o,a,l}),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=L({},e))}}save(){this.ki||this.Y.G(this.$i,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.$i,!1),this.Y.V(this.$i,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(z(e)){b(t)&&(t="None"),this.Pi=b(r)?this.Ci:r;var i=!1;if(N(e,(s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(z(e)){this.Pi=b(t)?this.Ci:t;var r=!1;if(N(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.Ei){var e=ra(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);dt(qi(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=_?.referrer)?ia(e):{})}update_referrer_info(){var e;this.register_once({$referrer:sa(),$referring_domain:_!=null&&_.referrer&&((e=Cr(_.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Kn]||this.props[Bn]||this.register_once({[Er]:oa(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};N([Bn,Kn],o=>{var a=this.props[o];a&&N(a,function(l,c){e["$initial_"+En(c)]=l})});var t,r,i=this.props[Er];if(i){var s=(t=aa(i),r={},N(t,function(o,a){r["$initial_"+En(a)]=o}),r);L(e,s)}return e}safe_merge(e){return N(this.props,function(t,r){r in e||(e[r]=t)}),e}update_config(e,t,r){if(this.Ci=this.Pi=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!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every((u,p)=>u===c[p])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var i=this.Si(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[Gt]||{};r[e]=t,this.props[Gt]=r,this.save()}remove_event_timer(e){var t=(this.props[Gt]||{})[e];return b(t)||(delete this.props[Gt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},io=G("[Product Tours]"),yn="ph_product_tours",hi=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Fs]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Fs)||this.it(()=>this.Oi())}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",i=>{i?io.error("Could not load product tours script",i):e()})}Oi(){var e;!this.Ri&&(e=I.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=I.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!$(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[yn];if($(i)&&!t)return this.Fi=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return io.error(a),void e([],{isLoaded:!1,error:a})}var l=$(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[yn]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){T(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it(()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(yn)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},Dt=function(n){return n.Activation="events",n.Cancellation="cancelEvents",n}({}),gp=function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n}({}),vp=function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n}({}),yp=function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n}({}),mn=function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n}({}),mp=function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n}({}),_p=function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n}({}),bp=function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n}({}),zt=function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n}({}),_n=function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n}({}),fi=function(n){return n.Popover="popover",n.Inline="inline",n}({}),D=G("[Surveys]"),ga="seenSurvey_",Ou=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},so=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(ga,n),$u=[mn.Popover,mn.Widget,mn.API],Du={ignoreConditions:!1,ignoreDelay:!1,displayType:fi.Popover},er=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter(r=>r!==t)}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var i of this.Mi["*"]||[])i(e,t)}};function lt(n,e,t){if(T(n))return!1;switch(t){case"exact":return n===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var gi=class{constructor(e){this.Ai=new er,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!b((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook((r,i)=>{this.on(r,i)})}}register(e){var t,r;if(!b((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach(o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach(c=>{var u;(u=this.zi)==null||u.add(c?.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?.selector)})}),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach(i=>{this.Bi(t,i)&&this.Ai.emit("actionCaptured",i.name)})}qi(e){this.onAction("actionCaptured",t=>e(t))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!lt(i,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var i=this.Ji(e);if(i.length>0)return i.some(a=>lt(a.href,t.href,t.href_matching||"exact"));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&lt((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var i=this.Ji(e);if(i.length>0)return i.some(c=>lt(c.text,t.text,t.text_matching||"exact")||lt(c.$el_text,t.text,t.text_matching||"exact"));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=function(c){for(var u,p=[],h=/(?::|")text="(.*?)"/g;!T(u=h.exec(c));)p.includes(u[1])||p.push(u[1]);return p}(l),o=t.text,a=t.text_matching||"exact",s.some(c=>lt(c,o,a)))}Vi(e,t){var r,i;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||fa(t.properties.reduce((r,i)=>{var s=$(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r},{}),e?.properties)}},vi=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&fa(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach(i=>{var s;(s=i.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach(o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}})}),r}te(e,t,r){var i=(r===Dt.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie(o=>{s=o.filter(a=>i?.includes(a.id))}),s.filter(o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find(c=>c.name===e);return this.Qi(l,t)})}register(e){var t;b((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=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});t.length!==0&&(this.se==null&&(this.se=new gi(this._instance),this.se.init(),this.se.qi(r=>{this.onAction(r)})),t.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.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}}))}))}ee(e){var t,r=e.filter(s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0}),i=e.filter(s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0});(r.length!==0||i.length!==0)&&((t=this._instance)==null||t._addCaptureHook((s,o)=>{this.onEvent(s,o)}),this.Ki=this.Zi(e,Dt.Activation),this.Yi=this.Zi(e,Dt.Cancellation))}onEvent(e,t){var r,i=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var p=a.indexOf(u);p>=0&&(a.splice(p,1),this.le(a))}}else{if(this.Yi.has(e)){var h=this.te(e,t,Dt.Cancellation);h.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:h.map(f=>f.id)}),h.forEach(f=>{var v=a.indexOf(f.id);v>=0&&a.splice(v,1),this.ue(f.id)}),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var d=this.te(e,t,Dt.Activation);this.le(a.concat(d.map(f=>f.id)||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter(o=>!this.he(o));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},yi=class extends vi{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return zt.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return D}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},mi=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(T(t))return D.warn("Flags not loaded yet. Not loading surveys.");var r=$(t);this.ve=r?t.length>0:t,D.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(ga)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)D.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)D.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())D.info("Not loading surveys in cookieless mode without consent.");else{var e=I?.__PosthogExtensions__;if(e){if(!b(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this.ge(r,t);var i=e.loadExternalDependency;if(!i)return void this._e("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",s=>{s||!e.generateSurveys?this._e("Could not load surveys script",s):this.ge(e.generateSurveys,t)})}catch(s){throw this._e("Error initializing surveys",s),s}finally{this.ce=!1}}}else D.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new yi(this._instance),D.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){D.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter(t=>t!==e)}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return D.info("Disabled. Not loading surveys."),e([]);var r,i=this._instance.get_property(Un);if(i&&!t)return e(i,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then(s=>{var{surveys:o,context:a}=s;return e(o,a)}):(typeof Promise<"u"&&(this.pe=new Promise(s=>{r=s})),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;D.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,p=s.json.surveys||[],h=p.filter(f=>function(v){return!(!v.start_date||v.end_date)}(f)&&(function(v){var y;return!((y=v.conditions)==null||(y=y.events)==null||(y=y.values)==null||!y.length)}(f)||function(v){var y;return!((y=v.conditions)==null||(y=y.actions)==null||(y=y.values)==null||!y.length)}(f)));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(o=this._instance.persistence)==null||o.register({[Un]:p});var d={isLoaded:!0};e(p,d),r?.({surveys:p,context:d})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){D.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!T(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);D.warn("init was not called")}be(e){var t=null;return this.getSurveys(r=>{var i;t=(i=r.find(s=>s.id===e))!==null&&i!==void 0?i:null}),t}ye(e){if(T(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(T(this._surveyManager))return D.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return T(this._surveyManager)?(D.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.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,r){var i;if(T(this._surveyManager))D.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if($u.includes(s.type)){var o=_?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(D.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var a,l;D.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),D.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);D.warn("Survey element not found")}else D.warn("Surveys of type "+s.type+" cannot be rendered in the app");else D.warn("Survey not found")}}displaySurvey(e,t){var r;if(T(this._surveyManager))D.warn("init was not called");else{var i=this.be(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=E({},i,{appearance:E({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==fi.Popover&&t.initialResponses&&D.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void D.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==fi.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else D.warn("Survey not found")}}cancelPendingSurvey(e){T(this._surveyManager)?D.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},Pe=G("[Conversations]"),_i=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.Ee=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;T(t)||(Ae(t)?this.we=t:(this.we=t.enabled,this.Ee=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.Ee=null}loadIfEnabled(){if(!this._conversationsManager&&!this.xe&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=I?.__PosthogExtensions__;if(e&&!b(this.we)&&this.we)if(this.Ee&&this.Ee.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.$e(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",i=>{i||!e.initConversations?this.Se("Could not load conversations script",i):this.$e(e.initConversations),this.xe=!1})}catch(i){this.Se("Error initializing conversations",i),this.xe=!1}}else Pe.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),Pe.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else Pe.error("Cannot complete initialization: remote config is null")}Se(e,t){Pe.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():Pe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!ye(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var i=this;return pt(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(Pe.warn("Conversations not available yet."),null)})()}getMessages(e,t){var r=this;return pt(function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(Pe.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Pe.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Pe.warn("Conversations not available yet."),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},bi=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!T(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=G("[logs]"),t=I?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Pe=!0)}):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},oo=G("[RateLimiter]"),ki=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach(i=>{oo.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void oo.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,i;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(Hn))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(Hn,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},We=G("[RemoteConfig]"),wi=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=I._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(We.error("PostHog Extensions not found. Cannot load remote config."),e())}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return We.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void We.warn("Remote config is disabled. Falling back to local config.");this.Te(e=>{if(!e)return We.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie(t=>{this.yi(t)});this.yi(e)})}catch(e){We.error("Error loading remote config",e)}}yi(e){e?this._instance.config.__preview_remote_config?(this._instance.yi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):We.info("__preview_remote_config is disabled. Logging config instead",e):We.error("Failed to fetch remote config from PostHog.")}},Ei=3e3,xi=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=ke(t?.flush_interval_ms||Ei,250,5e3,k.createLogger("flush interval"),Ei),this.Oe=e}enqueue(e){this.Re.push(e),this.Me||this.Ae()}unload(){this.je();var e=this.Re.length>0?this.De():{},t=Object.values(e);[...t.filter(r=>r.url.indexOf("/e")===0),...t.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Oe(E({},r,{transport:"sendBeacon"}))})}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Me=setTimeout(()=>{if(this.je(),this.Re.length>0){var t=this.De(),r=function(){var s=t[i],o=new Date().getTime();s.data&&$(s.data)&&N(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),e.Oe(s)};for(var i in t)r()}},this.Fe))}je(){clearTimeout(this.Me),this.Me=void 0}De(){var e={};return N(this.Re,t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;b(e[s])&&(e[s]=E({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)}),this.Re=[],e}},Nu=["retriesPerformedSoFar"],Pi=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!b(g)&&"onLine"in g.navigator&&(this.Ue=g.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},U(g,"online",this.ze),U(g,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=ho(e,Nu);ut(t)&&(r.url=Or(r.url,{retry_count:t})),this._instance._send_request(E({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(E({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(i)}}))}Be(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)}(t),i=Date.now()+r;this.Re.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),k.warn(s),this.Le||(this.Le=!0,this.qe())}qe(){if(this.We&&clearTimeout(this.We),this.Re.length===0)return this.Le=!1,void(this.We=void 0);this.We=setTimeout(()=>{this.Ue&&this.Re.length>0&&this.Lt(),this.qe()},this.Ne)}Lt(){var e=Date.now(),t=[],r=this.Re.filter(s=>s.retryAt<e||(t.push(s),!1));if(this.Re=t,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.We&&(clearTimeout(this.We),this.We=void 0),this.Le=!1,b(g)||(this.ze&&(g.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(g.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(E({},e,{transport:"sendBeacon"}))}catch(t){k.error(t)}this.Re=[]}},Si=class{constructor(e){this.Ge=()=>{var t,r,i,s;this.Ve||(this.Ve={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ve.lastScrollY=Math.ceil(a),this.Ve.maxScrollY=Math.max(a,(t=this.Ve.maxScrollY)!==null&&t!==void 0?t:0),this.Ve.maxScrollHeight=Math.max(l,(r=this.Ve.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ve.lastContentY=c,this.Ve.maxContentY=Math.max(c,(i=this.Ve.maxContentY)!==null&&i!==void 0?i:0),this.Ve.maxContentHeight=Math.max(u,(s=this.Ve.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ve}resetContext(){var e=this.Ve;return setTimeout(this.Ge,0),e}startMeasuringScrollPosition(){U(g,"scroll",this.Ge,{capture:!0}),U(g,"scrollend",this.Ge,{capture:!0}),U(g,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return g?.document.documentElement;var e=$(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=g?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return g&&(g.scrollY||g.pageYOffset||g.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return g&&(g.scrollX||g.pageXOffset||g.document.documentElement.scrollLeft)||0}},qu=n=>oa(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Dr=class{constructor(e,t,r,i){this.Je=s=>{var o=this.Ke();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ye(this._instance)};this.Xe.register({[zn]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||qu,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[zn]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?aa(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return N(qi(this.getSetOnceProps()),(t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+En(r)]=t}),e}},bn=G("[SessionId]"),Nr=class{on(e,t){return this.Ze.on(e,t)}constructor(e,t,r){var i;if(this.tr=[],this.ir=void 0,this.Ze=new er,this.er=(u,p)=>!(!ut(u)||!ut(p))&&Math.abs(u-p)>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.R=e.config,this.Xe=e.persistence,this.rr=void 0,this.sr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.nr=t||Ge,this.ar=r||Ge;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ke(o,60,36e3,bn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+s+"_window_id",this.hr="ph_"+s+"_primary_window_exists",this.dr()){var a=K.W(this.ur),l=K.W(this.hr);a&&!l?this.rr=a:K.V(this.ur),K.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var p=u.replace(/-/g,"");if(p.length!==32)throw new Error("Not a valid UUID");if(p[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(p.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){bn.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return b(this.tr)&&(this.tr=[]),this.tr.push(e),this.sr&&e(this.sr,this.rr),()=>{this.tr=this.tr.filter(t=>t!==e)}}dr(){return this.R.persistence!=="memory"&&!this.Xe.ki&&K.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&K.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?K.W(this.ur):null}vr(e,t,r){e===this.sr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.sr=e,this.Xe.register({[kr]:[t,e,r]}))}_r(){var e=this.Xe.props[kr];return $(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vr(null,null,null)}destroy(){clearTimeout(this.mr),this.mr=void 0,this.ir&&g&&(g.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&K.V(this.hr)},U(g,"beforeunload",this.ir,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[i,s,o]=this._r(),a=this.gr(),l=ut(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,p=!u&&!e&&this.er(r,i);u||p||l?(s=this.nr(),a=this.ar(),bn.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var h=ut(i)&&e&&!l?i:r,d=ut(o)?o:new Date().getTime();return this.pr(a),this.vr(s,h,d),e||this.lr(),c&&this.tr.forEach(f=>f(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:a,sessionStartTimestamp:d,changeReason:c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}lr(){clearTimeout(this.mr),this.mr=setTimeout(()=>{var[e]=this._r();if(this.er(new Date().getTime(),e)){var t=this.sr;this.resetSessionId(),this.Ze.emit("forcedIdleReset",{idleSessionId:t})}},1.1*this.sessionTimeoutMs)}},ju=["$set_once","$set"],qe=G("[SiteApps]"),Ci=class{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yr(e,t){if(t){var r=this.globalsForEvent(t);this.br.push(r),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=I._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yr.bind(this));this.wr=()=>{e(),this.br=[],this.wr=void 0}}}globalsForEvent(e){var t,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],p=this._instance.get_property("$stored_group_properties")||{};for(var[h,d]of Object.entries(p))c[h]={id:u[h],type:h,properties:d};var{$set_once:f,$set:v}=e;return{event:E({},ho(e,ju),{properties:E({},e.properties,v?{$set:E({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},f?{$set_once:E({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},f)}:{}),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:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.br.length&&(qe.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach(l=>t.processEvent==null?void 0:t.processEvent(l)),t.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((a=this.wr)==null||a.call(this))},i=!1,s=a=>{t.errored=!a,t.loaded=!0,qe.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&&(t.processEvent=o),i=!0}catch(a){qe.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){qe.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}Er(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}$r(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(i){qe.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var t,r,i,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Er(),void this._instance.on("eventCaptured",c=>this.$r(c))):void qe.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.wr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(c){var u;I["__$$ph_site_app_"+c]=s._instance,(u=I.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,p=>{if(p)return qe.error("Error while initializing PostHog app with config id "+c,p)})};for(var{id:a,url:l}of e.siteApps)o(a)}else qe.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},va=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&bs(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>bs(i?.brand,e)))return!0}catch{}return!!n.webdriver},Ht=function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n}({}),ao="i.posthog.com",Ii=class{constructor(e){this.Sr={},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 flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Sr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Ht.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Ht.EU:this.Sr[this.apiHost]=Ht.CUSTOM),this.Sr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===Ht.CUSTOM)return this.apiHost+t;var r=ao+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},Gu={icontains:(n,e)=>!!g&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!g&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!g&&$r(e.href,n),not_regex:(n,e)=>!!g&&!$r(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Mi=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments(i=>{n.kr("retrieved web experiments from the server"),t.Pr=new Map,i.forEach(s=>{if(s.feature_flag_key){var o;t.Pr&&(n.kr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Pr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);H(a)&&s.variants[a]&&t.Tr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];n.Ir(c)&&t.Tr(s.name,l,c.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(e){if(this._is_bot())n.kr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(T(this.Pr))return this.Pr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.kr("applying feature flags",e),e.forEach(t=>{var r;if(this.Pr&&(r=this.Pr)!=null&&r.has(t)){var i,s=this._instance.getFeatureFlag(t),o=(i=this.Pr)==null?void 0:i.get(t);s&&o!=null&&o.variants[s]&&this.Tr(o.name,s,o.variants[s].transforms)}})}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=Ir(e?.search,"__experiment_id"),r=Ir(e?.search,"__experiment_variant");t&&r&&(n.kr("previewing web experiments "+t+" && "+r),this.getWebExperiments(i=>{this.Cr(parseInt(t),r,i)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance._send_request({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)}})}Cr(e,t,r){var i=r.filter(s=>s.id===e);i&&i.length>0&&(n.kr("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.Tr(i[0].name,t,i[0].variants[t].transforms))}static Ir(e){return!T(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(T(e.conditions)||T((t=e.conditions)==null?void 0:t.url))return!0;var r,i,s,o=n.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||Gu[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return g?.location}static Fr(e){var t;if(T(e.conditions)||T((t=e.conditions)==null?void 0:t.utm))return!0;var r=ra();if(r.utm_source){var i,s,o,a,l,c,u,p,h=(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,d=(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,f=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return h&&f&&v&&d}return!1}static kr(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];k.info("[WebExperiments] "+e,r)}Tr(e,t,r){this._is_bot()?n.kr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach(i=>{if(i.selector){var s;n.kr("applying transform of variant "+t+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o?.forEach(a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):n.kr("Control variants leave the page unmodified.")}_is_bot(){return le&&this._instance?va(le,this._instance.config.custom_blocked_useragents):void 0}},Lu=G("[PostHog ExternalIntegrations]"),Vu={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ri=class{constructor(e){this._instance=e}it(e,t){var r;(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,i=>{if(i)return Lu.error("failed to load script",i);t()})}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=I.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(Vu[o],()=>{var u;(u=I.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)}),!i&&(l=I.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=I.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}},Ai="[SessionRecording]",Nt=G(Ai),qr=class{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Mr&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Mr=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw Nt.error("started without valid sessionManager"),new Error(Ai+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ai+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(an))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return g&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!b(Object.assign)&&!b(Array.from);this.Ar&&r?(this.Dr(e),Nt.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(I!=null&&(t=I.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=I.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=I.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,s=>{if(s)return Nt.error("could not load recorder",s);this.Lr(e)}))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(jo)}zr(e){if(this._instance.persistence){var t,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=T(a)?null:parseFloat(a);T(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[an]:E({enabled:!!o},o,{networkPayloadCapture:E({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:b(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.jr)==null||t.call(this),this.jr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Mr=!0,this.startIfEnabledOrStop()):this.Mr=!0:Nt.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Or)!=null&&r.log?this.Or.log(e,t):Nt.warn("log called before recorder was ready")}get Nr(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(an);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=I.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=I.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Or||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Or)==null||!r.tryAddCustomEvent(e,t))}},Wt={},Ti=()=>{},ct="posthog",ya=!Ru&&se?.indexOf("MSIE")===-1&&se?.indexOf("Mozilla")===-1,lo=n=>{var e;return E({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Kl(_?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ti,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:B&&H(B?.search)&&B.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_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(g==null||(e=g.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,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:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;k.error(r)},get_device_id:t=>t,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:Ei},error_tracking:{},_onCapture:Ti,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},uo=n=>{var e={};b(n.process_person)||(e.person_profiles=n.process_person),b(n.xhr_headers)||(e.request_headers=n.xhr_headers),b(n.cookie_name)||(e.persistence_name=n.cookie_name),b(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),b(n.store_google)||(e.save_campaign_params=n.store_google),b(n.verbose)||(e.debug=n.verbose);var t=L({},e,n);return $(n.property_blacklist)&&(b(n.property_denylist)?t.property_denylist=n.property_blacklist:$(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:k.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Fi=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){k.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},jr=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Fi,this.Br=!1,this.version=Se.LIB_VERSION,this.qr=new er,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=lo(),this.SentryIntegration=ri,this.sentryIntegration=e=>function(t,r){var i=ta(t,r);return{name:ea,processEvent:s=>i(s)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new di(this),this.toolbar=new ni(this),this.scrollManager=new Si(this),this.pageViewManager=new Ar(this),this.surveys=new mi(this),this.conversations=new _i(this),this.logs=new bi(this),this.experiments=new Mi(this),this.exceptions=new pi(this),this.rateLimiter=new ki(this),this.requestRouter=new Ii(this),this.consent=new Qn(this),this.externalIntegrations=new Ri(this),this.people={set:(e,t,r)=>{var i=H(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=H(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",e=>k.info('send "'+e?.event+'"',e))}init(e,t,r){if(r&&r!==ct){var i,s=(i=Wt[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Wt[r]=s,Wt[ct][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),b(e)||xn(e))return k.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 console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(L({},lo(t.defaults),uo(t),{name:r,token:e})),this.config.on_xhr_error&&k.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Me.GZipJS;var s=this.Qr();this.persistence=new Bt(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Bt(E({},this.config,{persistence:"sessionStorage"}),s);var o=E({},this.persistence.props),a=E({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new xi(w=>this.ts(w),this.config.request_queue_config),this.es=new Pi(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new Nr(this),this.sessionPropsManager=new Dr(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(k.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(k.info("Initializing extensions synchronously"),this.rs(l)),Se.DEBUG=Se.DEBUG||this.config.debug,Se.DEBUG&&k.info("Starting in debug mode",{this:this,config:t,thisC:E({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,p=this.config.get_device_id(Ge()),h=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(Ce,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this.ss()){var d,f,v=Object.keys(((d=t.bootstrap)==null?void 0:d.featureFlags)||{}).filter(w=>{var x;return!((x=t.bootstrap)==null||(x=x.featureFlags)==null||!x[w])}).reduce((w,x)=>{var m;return w[x]=((m=t.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[x])||!1,w},{}),y=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlagPayloads)||{}).filter(w=>v[w]).reduce((w,x)=>{var m,P;return(m=t.bootstrap)!=null&&(m=m.featureFlagPayloads)!=null&&m[x]&&(w[x]=(P=t.bootstrap)==null||(P=P.featureFlagPayloads)==null?void 0:P[x]),w},{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:y})}if(l)this.register_once({distinct_id:Mt,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(Ge());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(Ce,"anonymous")}return U(g,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?fu(this,()=>this.ns()):this.ns(),Le(this.config._onCapture)&&this.config._onCapture!==Ti&&(k.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",w=>this.config._onCapture(w.event,w))),this.config.ip&&k.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}rs(e){var t=performance.now();this.historyAutocapture=new ti(this),this.historyAutocapture.startIfEnabled();var r=[];r.push(()=>{new ii(this).startIfEnabledOrStop()}),r.push(()=>{var i;this.siteApps=new Ci(this),(i=this.siteApps)==null||i.init()}),e||r.push(()=>{this.sessionRecording=new qr(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.push(()=>{this.autocapture=new Xn(this),this.autocapture.startIfEnabled()}),r.push(()=>{this.surveys.loadIfEnabled()}),r.push(()=>{this.logs.loadIfEnabled()}),r.push(()=>{this.conversations.loadIfEnabled()}),r.push(()=>{this.productTours=new hi(this),this.productTours.loadIfEnabled()}),r.push(()=>{this.heatmaps=new oi(this),this.heatmaps.startIfEnabled()}),r.push(()=>{this.webVitalsAutocapture=new si(this)}),r.push(()=>{this.exceptionObserver=new ei(this),this.exceptionObserver.startIfEnabledOrStop()}),r.push(()=>{this.deadClicksAutocapture=new Rr(this,hu),this.deadClicksAutocapture.startIfEnabled()}),r.push(()=>{if(this.os){var i=this.os;this.os=void 0,this.yi(i)}}),this.ls(r,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.ls(e,t)},0);var r=e.shift();if(r)try{r()}catch(s){k.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&k.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!_||!_.body)return k.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.yi(e)},500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=A(e.supportedCompression,Me.GZipJS)?Me.GZipJS:A(e.supportedCompression,Me.Base64)?Me.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"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),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(r){k.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&B!=null&&B.hostname){var e=B.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()},1),new wi(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Ve(this.__request_queue,e=>this.ts(e)),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(ya?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Or(e.url,{ip:this.config.ip?1:0}),e.headers=E({},this.config.request_headers,e.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,(t=>{var r,i,s,o=E({},t);o.timeout=o.timeout||6e4,o.url=Or(o.url,{_:new Date().getTime().toString(),ver:Se.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=yr.filter(u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport)),c=(i=(s=Do(l,u=>u.transport===a))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(E({},e,{callback:t=>{var r,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,r=[],i=[],s=[];Ve(e,a=>{a&&(t=a[0],$(t)?s.push(a):Le(a)?a.call(this):$(a)&&t==="alias"?r.push(a):$(a)&&t.indexOf("capture")!==-1&&Le(this[t])?s.push(a):i.push(a))});var o=function(a,l){Ve(a,function(c){if($(c[0])){var u=l;N(c,function(p){u=u[p[0]].apply(u,p.slice(1))})}else this[c[0]].apply(this,c.slice(1))},l)};o(r,this),o(i,this),o(s,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!b(e)&&H(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!H(t?.$current_url)&&(k.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$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 a=new Date,l=r?.timestamp||a,c=Ge(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var p,h=e!=="$groupidentify",d=this.vs(r?.$set_once,h);if(d&&(u.$set_once=d),(u=zl(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,b(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===zt.DISMISSED||e===zt.SENT){var f=t?.[_n.SURVEY_ID],v=t?.[_n.SURVEY_ITERATION];p={id:f,current_iteration:v},localStorage.getItem(so(p))||localStorage.setItem(so(p),"true"),u.$set=E({},u.$set,{[Ou({id:f,current_iteration:v},e===zt.SENT?"responded":"dismissed")]:!0})}else e===zt.SHOWN&&(u.$set=E({},u.$set,{[_n.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var y=E({},u.properties.$set,u.$set);if(dt(y)||this.setPersonPropertiesForFlags(y),!T(this.config.before_send)){var S=this.cs(u);if(!S)return;u=S}this.qr.emit("eventCaptured",u);var w={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ts(w):this.Zr.enqueue(w),u}k.critical("This capture call is ignored due to client rate limiting.")}}else k.error("No event name provided to posthog.capture")}else k.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=E({},t);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=E({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!H(a.distinct_id)&&!Te(a.distinct_id)||xn(a.distinct_id))&&k.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=bu(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=h}this.sessionPropsManager&&L(a,this.sessionPropsManager.getSessionProps());try{var d;this.sessionRecording&&L(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(d=this.es)==null?void 0:d.length}catch(S){a.$sdk_debug_error_capturing_properties=String(S)}if(this.requestRouter.region===Ht.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=L(a,c),e==="$pageview"&&_&&(a.title=_.title),!b(o)){var f=r.getTime()-o;a.$duration=parseFloat((f/1e3).toFixed(3))}se&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=L({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),$(this.config.property_denylist)?N(this.config.property_denylist,function(S){delete a[S]}):k.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(k.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var y=this.fs();return a.$process_person_profile=y,y&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.Br)return e;var i=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=L({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(k.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),dt(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var i;(i=this.persistence)==null||i.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var i=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=E({},i,e),a=E({},s,t),l={};for(var[c,u]of Object.entries(o)){var p=typeof u=="string";l[c]={key:c,enabled:!!p||!!u,variant:p?u:void 0,reason:void 0,metadata:b(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.qr.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=Du),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return k.uninitializedWarning("posthog.identify");if(Te(e)&&(e=e.toString(),k.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()))k.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!==Mt){if(this.ps("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(jt)&&(this.unregister(jt),this.register({distinct_id:e}));var o=(this.persistence.get_property(Ce)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(Ce,"identified"),this.setPersonPropertiesForFlags(E({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=Qs(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(wr))}}else k.critical('The string "'+Mt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else k.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=Qs(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(E({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):k.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:E({},i,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===t||r||this.reloadFeatureFlags()}else k.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,i,s;if(k.info("reset"),!this.__loaded)return k.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(Ce,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Mt,$device_id:null},"");else{var a=this.config.get_device_id(Ge());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,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);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,t){return e===this.get_property(No)?(k.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(b(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(jt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(k.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=E({},this.config);if(z(e)){var r,i,s,o,a,l,c;L(this.config,uo(e));var u=this.Qr();(r=this.persistence)==null||r.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Bt(E({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);Ae(p)&&(this.config.debug=p),Ae(this.config.debug)&&(this.config.debug?(Se.DEBUG=!0,j.H()&&j.G("ph_debug","true"),k.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(Se.DEBUG=!1,j.H()&&j.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(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,t){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(E({},i,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:ct;return t!==ct&&(t=ct+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Ce))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(Ce))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&dt(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[jt])&&((t=this.persistence)==null||(t=t.props)==null||!t[xr]))}ds(){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.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(k.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(xr,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,r,i,s=this.Qr();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,i,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Nr(this),this.pageViewManager=new Ar(this),this.persistence&&(this.sessionPropsManager=new Dr(this,this.sessionManager,this.persistence)),this.sessionRecording=new qr(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(b(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else k.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Mt,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.hs())):k.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===Ie.GRANTED?"granted":e===Ie.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._s()}_is_bot(){return le?va(le,this.config.custom_blocked_useragents):void 0}hs(){_&&(_.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:_.title},{send_instantly:!0}),this.Gr&&(_.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),U(_,"visibilitychange",this.Gr)))}debug(e){e===!1?(g?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(g?.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)`."),this.set_config({debug:!0}))}M(){var e,t,r,i,s,o,a,l=this.Yr||{};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?(k.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=k,o=(t="advanced_disable_flags")in(e=l)&&!T(e[t]),a=r in e&&!T(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):i)}cs(e){if(T(this.config.before_send))return e;var t=$(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),T(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return yl(e.event)?k.warn(s+". This can cause unexpected behavior."):k.info(s),null}r.properties&&!dt(r.properties)||k.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Kr(e){var t=Ae(e)&&!e,r=j.H()&&j.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=Ul(n.prototype[e[t]])})(jr,["identify"]);var co;var Ur=(co=Wt[ct]=new jr,function(){function n(){n.done||(n.done=!0,ya=!1,N(Wt,function(e){e._dom_loaded()}))}_!=null&&_.addEventListener?_.readyState==="complete"?n():U(_,"DOMContentLoaded",n,{capture:!1}):g&&k.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),co);var Uu="phc_u9YDYUeUxo3CYn16XGrrwpVb8ycXgcjz5DarvIKRAAG",ir=class n{constructor(e){R(this,"initialized",!1);this.initPostHog(e)}static getInstance(e){if(typeof window>"u")throw new Error("[PaymentKit Analytics] PostHog requires a browser environment");let t=window.__paymentKitPostHog__;if(t){if(t.apiBaseUrl!==e)throw new Error(`[PaymentKit Analytics] PostHog already initialized with apiBaseUrl "${t.apiBaseUrl}", cannot re-initialize with different apiBaseUrl "${e}"`);return t.instance}let r=new n(e);return window.__paymentKitPostHog__={instance:r,apiBaseUrl:e},r}initPostHog(e){try{Ur.init(Uu,{api_host:`${e}/ingest`,ui_host:"https://us.posthog.com",persistence:"memory",disable_session_recording:!0,autocapture:!1,capture_pageview:!1,request_batching:!1,opt_out_useragent_filter:!0,loaded:()=>{this.initialized=!0}})}catch(t){console.warn("[PaymentKit Analytics] Failed to initialize PostHog:",t)}}identify(e){try{Ur.identify(e)}catch(t){console.warn("[PaymentKit Analytics] Failed to identify:",t)}}capture(e,t){try{Ur.capture(e,t)}catch(r){console.warn("[PaymentKit Analytics] Failed to capture event:",r)}}isInitialized(){return this.initialized}};var zi=class{constructor(){R(this,"adapters",[]);R(this,"testMock",null)}init(e,t){try{this.addAdapter(ir.getInstance(e)),t&&this.enableTestMode()}catch(r){console.warn("[PaymentKit Analytics] Init failed:",r)}}enableTestMode(){this.testMock||(this.testMock=new It,this.addAdapter(this.testMock),typeof window<"u"&&(window.__paymentKitAnalytics__=this.testMock))}getTestMock(){return this.testMock}addAdapter(e){this.adapters.includes(e)||this.adapters.push(e)}clearAdapters(){this.adapters=[],this.testMock=null,typeof window<"u"&&delete window.__paymentKitAnalytics__}identify(e){for(let t of this.adapters)try{t.identify(e)}catch{}}capture(e,t){for(let r of this.adapters)try{r.capture(e,t)}catch{}}isInitialized(){return this.adapters.some(e=>e.isInitialized())}},we=new zi;var sr=class sr{constructor(e,t){R(this,"startTime");R(this,"checkoutSessionId");R(this,"requestId");R(this,"inputReadyTracked",!1);this.startTime=performance.now(),this.checkoutSessionId=e,this.requestId=t}trackPageReady(){sr.pageReadyTracked||(sr.pageReadyTracked=!0,we.capture("checkout_page_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackInputReady(){this.inputReadyTracked||(this.inputReadyTracked=!0,we.capture("checkout_input_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackSubmit(){we.capture("checkout_submit",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()})}trackSuccess(e){we.capture("checkout_success",{checkout_session_id:this.checkoutSessionId,checkout_attempt_id:e,request_id:this.requestId,total_elapsed_ms:this.getElapsedMs()})}trackFail(e,t,r){we.capture("checkout_fail",{checkout_session_id:this.checkoutSessionId,checkout_attempt_id:e,request_id:this.requestId,error_code:t,error_message:r,total_elapsed_ms:this.getElapsedMs()})}getElapsedMs(){return Math.round(performance.now()-this.startTime)}};R(sr,"pageReadyTracked",!1);var or=sr;var zu=class extends Error{constructor(e,t){super(t);R(this,"code");this.name="PenpalError",this.code=e}},pe=zu,Hu=n=>({name:n.name,message:n.message,stack:n.stack,penpalCode:n instanceof pe?n.code:void 0}),Ku=({name:n,message:e,stack:t,penpalCode:r})=>{let i=r?new pe(r,e):new Error(e);return i.name=n,i.stack=t,i},Bu=Symbol("Reply"),Bi,wa,Wu=(wa=class{constructor(n,e){R(this,"value");R(this,"transferables");Z(this,Bi,Bu);this.value=n,this.transferables=e?.transferables}},Bi=new WeakMap,wa),Xu=Wu,ce="penpal",Br=n=>typeof n=="object"&&n!==null,Pa=n=>typeof n=="function",Yu=n=>Br(n)&&n.namespace===ce,zr=n=>n.type==="SYN",Xi=n=>n.type==="ACK1",Hi=n=>n.type==="ACK2",Sa=n=>n.type==="CALL",Ca=n=>n.type==="REPLY",Ju=n=>n.type==="DESTROY",Ia=(n,e=[])=>{let t=[];for(let r of Object.keys(n)){let i=n[r];Pa(i)?t.push([...e,r]):Br(i)&&t.push(...Ia(i,[...e,r]))}return t},Zu=(n,e)=>{let t=n.reduce((r,i)=>Br(r)?r[i]:void 0,e);return Pa(t)?t:void 0},Ke=n=>n.join("."),ma=(n,e,t)=>({namespace:ce,channel:n,type:"REPLY",callId:e,isError:!0,...t instanceof Error?{value:Hu(t),isSerializedErrorInstance:!0}:{value:t}}),Qu=(n,e,t,r)=>{let i=!1,s=async o=>{if(i||!Sa(o))return;r?.(`Received ${Ke(o.methodPath)}() call`,o);let{methodPath:a,args:l,id:c}=o,u,p;try{let h=Zu(a,e);if(!h)throw new pe("METHOD_NOT_FOUND",`Method \`${Ke(a)}\` is not found.`);let d=await h(...l);d instanceof Xu&&(p=d.transferables,d=await d.value),u={namespace:ce,channel:t,type:"REPLY",callId:c,value:d}}catch(h){u=ma(t,c,h)}if(!i)try{r?.(`Sending ${Ke(a)}() reply`,u),n.sendMessage(u,p)}catch(h){throw h.name==="DataCloneError"&&(u=ma(t,c,h),r?.(`Sending ${Ke(a)}() reply`,u),n.sendMessage(u)),h}};return n.addMessageHandler(s),()=>{i=!0,n.removeMessageHandler(s)}},ec=Qu,Ma=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),tc=Symbol("CallOptions"),Wi,Ea,rc=(Ea=class{constructor(n){R(this,"transferables");R(this,"timeout");Z(this,Wi,tc);this.transferables=n?.transferables,this.timeout=n?.timeout}},Wi=new WeakMap,Ea),nc=rc,ic=new Set(["apply","call","bind"]),Ra=(n,e,t=[])=>new Proxy(t.length?()=>{}:Object.create(null),{get(r,i){if(i!=="then")return t.length&&ic.has(i)?Reflect.get(r,i):Ra(n,e,[...t,i])},apply(r,i,s){return n(t,s)}}),_a=n=>new pe("CONNECTION_DESTROYED",`Method call ${Ke(n)}() failed due to destroyed connection`),sc=(n,e,t)=>{let r=!1,i=new Map,s=l=>{if(!Ca(l))return;let{callId:c,value:u,isError:p,isSerializedErrorInstance:h}=l,d=i.get(c);d&&(i.delete(c),t?.(`Received ${Ke(d.methodPath)}() call`,l),p?d.reject(h?Ku(u):u):d.resolve(u))};return n.addMessageHandler(s),{remoteProxy:Ra((l,c)=>{if(r)throw _a(l);let u=Ma(),p=c[c.length-1],h=p instanceof nc,{timeout:d,transferables:f}=h?p:{},v=h?c.slice(0,-1):c;return new Promise((y,S)=>{let w=d!==void 0?window.setTimeout(()=>{i.delete(u),S(new pe("METHOD_CALL_TIMEOUT",`Method call ${Ke(l)}() timed out after ${d}ms`))},d):void 0;i.set(u,{methodPath:l,resolve:y,reject:S,timeoutId:w});try{let x={namespace:ce,channel:e,type:"CALL",id:u,methodPath:l,args:v};t?.(`Sending ${Ke(l)}() call`,x),n.sendMessage(x,f)}catch(x){S(new pe("TRANSMISSION_FAILED",x.message))}})},t),destroy:()=>{r=!0,n.removeMessageHandler(s);for(let{methodPath:l,reject:c,timeoutId:u}of i.values())clearTimeout(u),c(_a(l));i.clear()}}},oc=sc,ac=()=>{let n,e;return{promise:new Promise((r,i)=>{n=r,e=i}),resolve:n,reject:e}},lc=ac,uc=class extends Error{constructor(n){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${n}`)}},Hr=uc,Ki="deprecated-penpal",cc=n=>Br(n)&&"penpal"in n,pc=n=>n.split("."),ba=n=>n.join("."),Aa=n=>new Hr(`Unexpected message to translate: ${JSON.stringify(n)}`),dc=n=>{if(n.penpal==="syn")return{namespace:ce,channel:void 0,type:"SYN",participantId:Ki};if(n.penpal==="ack")return{namespace:ce,channel:void 0,type:"ACK2"};if(n.penpal==="call")return{namespace:ce,channel:void 0,type:"CALL",id:n.id,methodPath:pc(n.methodName),args:n.args};if(n.penpal==="reply")return n.resolution==="fulfilled"?{namespace:ce,channel:void 0,type:"REPLY",callId:n.id,value:n.returnValue}:{namespace:ce,channel:void 0,type:"REPLY",callId:n.id,isError:!0,...n.returnValueIsError?{value:n.returnValue,isSerializedErrorInstance:!0}:{value:n.returnValue}};throw Aa(n)},hc=n=>{if(Xi(n))return{penpal:"synAck",methodNames:n.methodPaths.map(ba)};if(Sa(n))return{penpal:"call",id:n.id,methodName:ba(n.methodPath),args:n.args};if(Ca(n))return n.isError?{penpal:"reply",id:n.callId,resolution:"rejected",...n.isSerializedErrorInstance?{returnValue:n.value,returnValueIsError:!0}:{returnValue:n.value}}:{penpal:"reply",id:n.callId,resolution:"fulfilled",returnValue:n.value};throw Aa(n)},fc=({messenger:n,methods:e,timeout:t,channel:r,log:i})=>{let s=Ma(),o,a=[],l=!1,c=Ia(e),{promise:u,resolve:p,reject:h}=lc(),d=t!==void 0?setTimeout(()=>{h(new pe("CONNECTION_TIMEOUT",`Connection timed out after ${t}ms`))},t):void 0,f=()=>{for(let P of a)P()},v=()=>{if(l)return;a.push(ec(n,e,r,i));let{remoteProxy:P,destroy:F}=oc(n,r,i);a.push(F),clearTimeout(d),l=!0,p({remoteProxy:P,destroy:f})},y=()=>{let P={namespace:ce,type:"SYN",channel:r,participantId:s};i?.("Sending handshake SYN",P);try{n.sendMessage(P)}catch(F){h(new pe("TRANSMISSION_FAILED",F.message))}},S=P=>{if(i?.("Received handshake SYN",P),P.participantId===o&&o!==Ki||(o=P.participantId,y(),!(s>o||o===Ki)))return;let O={namespace:ce,channel:r,type:"ACK1",methodPaths:c};i?.("Sending handshake ACK1",O);try{n.sendMessage(O)}catch(C){h(new pe("TRANSMISSION_FAILED",C.message));return}},w=P=>{i?.("Received handshake ACK1",P);let F={namespace:ce,channel:r,type:"ACK2"};i?.("Sending handshake ACK2",F);try{n.sendMessage(F)}catch(O){h(new pe("TRANSMISSION_FAILED",O.message));return}v()},x=P=>{i?.("Received handshake ACK2",P),v()},m=P=>{zr(P)&&S(P),Xi(P)&&w(P),Hi(P)&&x(P)};return n.addMessageHandler(m),a.push(()=>n.removeMessageHandler(m)),y(),u},gc=fc,vc=n=>{let e=!1,t;return(...r)=>(e||(e=!0,t=n(...r)),t)},yc=vc,ka=new WeakSet,mc=({messenger:n,methods:e={},timeout:t,channel:r,log:i})=>{if(!n)throw new pe("INVALID_ARGUMENT","messenger must be defined");if(ka.has(n))throw new pe("INVALID_ARGUMENT","A messenger can only be used for a single connection");ka.add(n);let s=[n.destroy],o=yc(c=>{if(c){let u={namespace:ce,channel:r,type:"DESTROY"};try{n.sendMessage(u)}catch{}}for(let u of s)u();i?.("Connection destroyed")}),a=c=>Yu(c)&&c.channel===r;return{promise:(async()=>{try{n.initialize({log:i,validateReceivedMessage:a}),n.addMessageHandler(p=>{Ju(p)&&o(!1)});let{remoteProxy:c,destroy:u}=await gc({messenger:n,methods:e,timeout:t,channel:r,log:i});return s.push(u),c}catch(c){throw o(!0),c}})(),destroy:()=>{o(!0)}}},Ta=mc,ze,Ze,kt,wt,Qe,He,ue,et,Kr,Et,ar,lr,xt,xa,_c=(xa=class{constructor({remoteWindow:n,allowedOrigins:e}){Z(this,ze);Z(this,Ze);Z(this,kt);Z(this,wt);Z(this,Qe);Z(this,He,new Set);Z(this,ue);Z(this,et,!1);R(this,"initialize",({log:n,validateReceivedMessage:e})=>{_e(this,kt,n),_e(this,wt,e),window.addEventListener("message",M(this,lr))});R(this,"sendMessage",(n,e)=>{if(zr(n)){let t=M(this,Et).call(this,n);M(this,ze).postMessage(n,{targetOrigin:t,transfer:e});return}if(Xi(n)||M(this,et)){let t=M(this,et)?hc(n):n,r=M(this,Et).call(this,n);M(this,ze).postMessage(t,{targetOrigin:r,transfer:e});return}if(Hi(n)){let{port1:t,port2:r}=new MessageChannel;_e(this,ue,t),t.addEventListener("message",M(this,xt)),t.start();let i=[r,...e||[]],s=M(this,Et).call(this,n);M(this,ze).postMessage(n,{targetOrigin:s,transfer:i});return}if(M(this,ue)){M(this,ue).postMessage(n,{transfer:e});return}throw new Hr("Port is undefined")});R(this,"addMessageHandler",n=>{M(this,He).add(n)});R(this,"removeMessageHandler",n=>{M(this,He).delete(n)});R(this,"destroy",()=>{window.removeEventListener("message",M(this,lr)),M(this,ar).call(this),M(this,He).clear()});Z(this,Kr,n=>M(this,Ze).some(e=>e instanceof RegExp?e.test(n):e===n||e==="*"));Z(this,Et,n=>{if(zr(n))return"*";if(!M(this,Qe))throw new Hr("Concrete remote origin not set");return M(this,Qe)==="null"&&M(this,Ze).includes("*")?"*":M(this,Qe)});Z(this,ar,()=>{M(this,ue)?.removeEventListener("message",M(this,xt)),M(this,ue)?.close(),_e(this,ue,void 0)});Z(this,lr,({source:n,origin:e,ports:t,data:r})=>{var i,s,o;if(n===M(this,ze)&&(cc(r)&&((i=M(this,kt))==null||i.call(this,"Please upgrade the child window to the latest version of Penpal."),_e(this,et,!0),r=dc(r)),!!((s=M(this,wt))!=null&&s.call(this,r)))){if(!M(this,Kr).call(this,e)){(o=M(this,kt))==null||o.call(this,`Received a message from origin \`${e}\` which did not match allowed origins \`[${M(this,Ze).join(", ")}]\``);return}if(zr(r)&&(M(this,ar).call(this),_e(this,Qe,e)),Hi(r)&&!M(this,et)){if(_e(this,ue,t[0]),!M(this,ue))throw new Hr("No port received on ACK2");M(this,ue).addEventListener("message",M(this,xt)),M(this,ue).start()}for(let a of M(this,He))a(r)}});Z(this,xt,({data:n})=>{var e;if((e=M(this,wt))!=null&&e.call(this,n))for(let t of M(this,He))t(n)});if(!n)throw new pe("INVALID_ARGUMENT","remoteWindow must be defined");_e(this,ze,n),_e(this,Ze,e?.length?e:[window.origin])}},ze=new WeakMap,Ze=new WeakMap,kt=new WeakMap,wt=new WeakMap,Qe=new WeakMap,He=new WeakMap,ue=new WeakMap,et=new WeakMap,Kr=new WeakMap,Et=new WeakMap,ar=new WeakMap,lr=new WeakMap,xt=new WeakMap,xa),Fa=_c;var Wr=({window:n,methods:e})=>{let t=new Fa({remoteWindow:n,allowedOrigins:["*"]});return Ta({methods:e,messenger:t})};var Oa=(n,e)=>Wr({window:n.contentWindow,methods:e});var Yr=class Yr{constructor(e,t){R(this,"penpalConn");R(this,"_methods");this.penpalConn=e,this._methods=t}get publicEndpoints(){let e={get:(t,r)=>async(...i)=>await this._methods.queryPublicEndpoint(r,i[0],i[1])};return new Proxy({},e)}destroy(){this.penpalConn.destroy()}};R(Yr,"createFromPenpalConnection",async e=>{let t=await e.promise;return new Yr(e,t)});var Xr=Yr;var $a={local:{baseUrl:"http://localhost:9101",apiBaseUrl:"http://localhost:9000"},sandbox:{baseUrl:"https://staging.paymentkit.com/customer",apiBaseUrl:"https://staging.paymentkit.com"},production:{baseUrl:"https://paymentkit.com/customer",apiBaseUrl:"https://paymentkit.com"}};function bc(){if(typeof window<"u"){let e=new URLSearchParams(window.location.search).get("api_base_url");if(e)return{baseUrl:window.location.origin,apiBaseUrl:e};let t=window.location.hostname;if(t.includes("loclx.io")){let r=t.replace(/cportal|playground/,"api");return{baseUrl:`https://${t}`,apiBaseUrl:`https://${r}`}}}return $a.local}function Da(n){if(n==="tunnel")return bc();let t=$a[n];if(!t)throw new Error(`Invalid environment: ${n}. Must be one of: local, tunnel, sandbox, production`);return t}var Na="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var qa=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=Na[t[n]&63];return e};var kc={local:"dev",tunnel:"dev",sandbox:"stg",production:"prod"},Yi="__paymentKitRequestId__";function ja(n){let e=kc[n]||"dev",t=qa(12);return`pk_${e}_${t}`}function tt(n){if(typeof window<"u"&&window[Yi])return window[Yi];let e=ja(n);return typeof window<"u"&&(window[Yi]=e),e}function Ji(n){return{headers:{"x-request-id":n}}}var Zi;function Ga(n){return{lang:n?.lang??Zi?.lang,message:n?.message,abortEarly:n?.abortEarly??Zi?.abortEarly,abortPipeEarly:n?.abortPipeEarly??Zi?.abortPipeEarly}}var wc;function Ec(n){return wc?.get(n)}var xc;function Pc(n){return xc?.get(n)}var Sc;function Cc(n,e){return Sc?.get(n)?.get(e)}function Ic(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}function rt(n,e,t,r,i){let s=i&&"input"in i?i.input:t.value,o=i?.expected??n.expects??null,a=i?.received??Ic(s),l={kind:n.kind,type:n.type,input:s,expected:o,received:a,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:n.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=n.kind==="schema",u=i?.message??n.message??Cc(n.reference,l.lang)??(c?Pc(l.lang):null)??r.message??Ec(l.lang);u!==void 0&&(l.message=typeof u=="function"?u(l):u),c&&(t.typed=!1),t.issues?t.issues.push(l):t.issues=[l]}function Qi(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},Ga())}}}function La(n){if(n.path){let e="";for(let t of n.path)if(typeof t.key=="string"||typeof t.key=="number")e?e+=`.${t.key}`:e+=t.key;else return null;return e}return null}var Mc=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function es(n){return{kind:"validation",type:"email",reference:es,expects:null,async:!1,requirement:Mc,message:n,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&rt(this,"email",e,t),e}}}function ts(n,e){return{kind:"validation",type:"max_length",reference:ts,async:!1,expects:`<=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length>this.requirement&&rt(this,"length",t,r,{received:`${t.value.length}`}),t}}}function rs(n,e){return{kind:"validation",type:"min_length",reference:rs,async:!1,expects:`>=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&rt(this,"length",t,r,{received:`${t.value.length}`}),t}}}function Pt(n){return{kind:"validation",type:"non_empty",reference:Pt,async:!1,expects:"!0",message:n,"~run"(e,t){return e.typed&&e.value.length===0&&rt(this,"length",e,t,{received:"0"}),e}}}function Rc(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}function Ac(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}function ns(n,e){return{kind:"schema",type:"object",reference:ns,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return Qi(this)},"~run"(t,r){let i=t.value;if(i&&typeof i=="object"){t.typed=!0,t.value={};for(let s in this.entries){let o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=s in i?i[s]:Ac(o),l=o["~run"]({value:a},r);if(l.issues){let c={type:"object",origin:"value",input:i,key:s,value:a};for(let u of l.issues)u.path?u.path.unshift(c):u.path=[c],t.issues?.push(u);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value[s]=l.value}else if(o.fallback!==void 0)t.value[s]=Rc(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(rt(this,"key",t,r,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),r.abortEarly))break}}else rt(this,"type",t,r);return t}}}function nt(n){return{kind:"schema",type:"string",reference:nt,expects:"string",async:!1,message:n,get"~standard"(){return Qi(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:rt(this,"type",e,t),e}}}function St(...n){return{...n[0],pipe:n,get"~standard"(){return Qi(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}function Va(n,e,t){let r=n["~run"]({value:e},Ga(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var is=async(n,e={})=>{let t=ns({customer_name:St(nt("required"),Pt("required"),rs(4,"invalid"),ts(40,"invalid")),customer_email:St(nt("required"),Pt("required"),es("invalid")),customer_country:St(nt("required"),Pt("required")),customer_zip_code:e.optionalZipCode?St(nt("required")):St(nt("required"),Pt("required"))}),r=Va(t,n);return r.issues?{isSuccess:!1,errors:r.issues.reduce((s,o)=>{let a=La(o);return s[a]=o.kind==="schema"?"required":o.message,s},{})}:{isSuccess:!0}};var Ua=n=>{let e=document.querySelector(n);if(!e)throw new Error(`Cannot find element with selector: ${n}`);return e},Ct=n=>n,Jr=(n,e,t)=>{let r=document.createElement("iframe"),s=new URLSearchParams(t).toString();return r.src=`${e}/embeds/v1/${n}${s?`?${s}`:""}`,Object.assign(r.style,{width:"100%",height:"100%",border:"none"}),r};function it(){return{ipAddress:void 0,browserInfo:{userAgent:navigator.userAgent,language:navigator.language,screenHeight:window.screen.height,screenWidth:window.screen.width,colorDepth:window.screen.colorDepth,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},processorFraudInfo:void 0}}var Fc=(n,e,t)=>{let r=Jr("tunnel-x",n,{checkout_token:t,api_base_url:e});document.body.appendChild(r);let i=Oa(r,{});return{unmount:()=>{i.destroy(),document.body.removeChild(r)},connection:i}},Oc=({environment:n,secureToken:e,paymentMethods:t,cardTokenizationMode:r,vgsVaultId:i,vgsEnvironment:s,__enableAnalyticsTestMode:o})=>{let{baseUrl:a,apiBaseUrl:l}=Da(n);console.log(`[PaymentKit] v${gs} initialized (env: ${n})`);let c=tt(n);console.log(`[PaymentKit] checkout_request_id: ${c}`),we.init(l,o),we.identify(e);let u=new or(e,c);u.trackPageReady();let{connection:p,unmount:h}=Fc(a,l,e),d={baseUrl:a,apiBaseUrl:l,secureToken:e,environment:n,tunnelXConnection:p,timingTracker:u,checkoutRequestId:c,cardTokenizationMode:r,vgsVaultId:i,vgsEnvironment:s,_sessionConfigReady:void 0};if(r===void 0){let w=`${l}/api/checkout-sessions/token/${e}`;console.log(`[PaymentKit] cardTokenizationMode not provided \u2014 auto-detecting from session API: ${w}`),d._sessionConfigReady=fetch(w).then(x=>x.ok?x.json():(console.warn(`[PaymentKit] Session config fetch failed with status ${x.status}`),null)).then(x=>{if(x&&typeof x=="object"&&typeof x.card_tokenization_mode=="string"){d.cardTokenizationMode=x.card_tokenization_mode||"direct",console.log(`[PaymentKit] Session config detected \u2014 cardTokenizationMode: ${d.cardTokenizationMode}`);let m=x.vgs_vault_id,P=x.vgs_environment;m&&/^tnt[a-z0-9]+$/.test(m)&&(P==="sandbox"||P==="live")?(d.vgsVaultId=m,d.vgsEnvironment=P,console.log(`[PaymentKit] VGS config valid \u2014 vaultId: ${m}, environment: ${P}`)):d.cardTokenizationMode==="vgs"&&(console.warn(`[PaymentKit] Invalid VGS config from session API (vaultId: ${m}, env: ${P}), falling back to direct mode`),d.cardTokenizationMode="direct")}else console.log("[PaymentKit] Session response missing card_tokenization_mode \u2014 defaulting to direct mode"),d.cardTokenizationMode="direct"}).catch(x=>{console.error("[PaymentKit] Session config fetch error \u2014 falling back to direct mode:",x),d.cardTokenizationMode="direct"})}else console.log(`[PaymentKit] cardTokenizationMode explicitly set: ${r}`);let f=t.map(w=>w(d)),v=f.reduce((w,{name:x,externalFuncs:m})=>(w[x]=m,w),{});return{submit:({paymentMethod:w,fields:x,options:m,onSuccess:P,onError:F})=>{let O=f.find(({name:C})=>C===w);if(!O){F({root:"payment_method_not_found"});return}O.internalFuncs.submitPayment(x,m).then(({data:C,errors:V})=>{V?F(V):P(C)}).catch(C=>{console.error("PaymentKit:submit:catch",C),C?.response?.data?F(C.response.data):C?.message?F({root:C.message}):F({root:"unknown_error"})})},cleanup:()=>{for(let w of f)w.internalFuncs.cleanup&&w.internalFuncs.cleanup();h()},...v}},za=Oc;var Ha=(n,e)=>Wr({window:n.contentWindow,methods:e});function ss(n){let{url:e,size:t,radius:r=6,onMessage:i}=n;return new Promise(s=>{let o=!1,a=document.createElement("div");a.id="pk-iframe-modal-overlay",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label","3D Secure Verification"),a.style.cssText=`
11
+ `)).length,i=0;i<r;i++){var o=n.charCodeAt(i),a=null;o<128?t++: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),ye(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},Ru=!!wr||!!kr,Zs="text/plain",$n=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=E({},e),a=(r=s?.split("&").map(c=>{var u,[p,h]=c.split("="),d=t&&(u=o[p])!==null&&u!==void 0?u:h;return delete o[p],p+"="+d}))!==null&&r!==void 0?r:[],l=ru(o);return l&&a.push(l),i+"?"+a.join("&")},Ut=(n,e)=>JSON.stringify(n,(t,r)=>typeof r=="bigint"?r.toString():r,e),fr=n=>{var{data:e,compression:t}=n;if(e){if(t===Me.GZipJS){var r=Iu(function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new ge(l.length+(l.length>>>1)),h=0,d=function(P){p[h++]=P},g=0;g<u;++g){if(h+5>p.length){var f=new ge(h+8+(u-g<<1));f.set(p),p=f}var y=l.charCodeAt(g);y<128||c?d(y):y<2048?(d(192|y>>>6),d(128|63&y)):y>55295&&y<57344?(d(240|(y=65536+(1047552&y)|1023&l.charCodeAt(++g))>>>18),d(128|y>>>12&63),d(128|y>>>6&63),d(128|63&y)):(d(224|y>>>12),d(128|y>>>6&63),d(128|63&y))}return da(p,0,h)}(Ut(e)),{mtime:0}),i=new Blob([r],{type:Zs});return{contentType:Zs,body:i,estimatedSize:i.size}}if(t===Me.Base64){var s=function(l){var c,u,p,h,d,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,y=0,P="",b=[];if(!l)return l;l=Mu(l);do c=(d=l.charCodeAt(f++)<<16|l.charCodeAt(f++)<<8|l.charCodeAt(f++))>>18&63,u=d>>12&63,p=d>>6&63,h=63&d,b[y++]=g.charAt(c)+g.charAt(u)+g.charAt(p)+g.charAt(h);while(f<l.length);switch(P=b.join(""),l.length%3){case 1:P=P.slice(0,-2)+"==";break;case 2:P=P.slice(0,-1)+"="}return P}(Ut(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Ut(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Ut(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},mn=[];kr&&mn.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=fr(n))!==null&&e!==void 0?e:{},o=new Headers;N(n.headers,function(u,p){o.append(p,u)}),r&&o.append("Content-Type",r);var a=n.url,l=null;if(ms){var c=new ms;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),n.timeout)}}kr(a,E({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(s||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then(u=>u.text().then(p=>{var h={statusCode:u.status,text:p};if(u.status===200)try{h.json=JSON.parse(p)}catch(d){x.error(d)}n.callback==null||n.callback(h)})).catch(u=>{x.error(u),n.callback==null||n.callback({statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),wr&&mn.push({transport:"XHR",method:n=>{var e,t=new wr;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=fr(n))!==null&&e!==void 0?e:{};N(n.headers,function(s,o){t.setRequestHeader(o,s)}),r&&t.setRequestHeader("Content-Type",r),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(s)}},t.send(i)}}),le!=null&&le.sendBeacon&&mn.push({transport:"sendBeacon",method:n=>{var e=$n(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=fr(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;le.sendBeacon(e,s)}catch{}}});var Dn=function(n,e){if(!function(t){try{new RegExp(t)}catch{return!1}return!0}(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};function Qs(n,e,t){return Ut({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var ha={exact:(n,e)=>e.some(t=>n.some(r=>t===r)),is_not:(n,e)=>e.every(t=>n.every(r=>t!==r)),regex:(n,e)=>e.some(t=>n.some(r=>Dn(t,r))),not_regex:(n,e)=>e.every(t=>n.every(r=>!Dn(t,r))),icontains:(n,e)=>e.map(vn).some(t=>n.map(vn).some(r=>t.includes(r))),not_icontains:(n,e)=>e.map(vn).every(t=>n.map(vn).every(r=>!t.includes(r))),gt:(n,e)=>e.some(t=>{var r=parseFloat(t);return!isNaN(r)&&n.some(i=>r>parseFloat(i))}),lt:(n,e)=>e.some(t=>{var r=parseFloat(t);return!isNaN(r)&&n.some(i=>r<parseFloat(i))})},vn=n=>n.toLowerCase();function fa(n,e){return!n||Object.entries(n).every(t=>{var[r,i]=t,s=e?.[r];if(w(s)||ye(s))return!1;var o=[String(s)],a=ha[i.operator];return!!a&&a(i.values,o)})}var gr=G("[Error tracking]"),pi=class{constructor(e){var t,r;this.Zt=[],this.ti=new Rr([new Tr,new jr,new Or,new Fr,new Nr,new Dr,new $r,new qr],jl()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Lr))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,i,s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[Lr]:this.Zt,[As]:o})}get ii(){var e,t=!!this._instance.get_property(As),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void gr.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void gr.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void gr.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce((r,i)=>{var{type:s,value:o}=i;return H(s)&&s.length>0&&r.$exception_types.push(s),H(o)&&o.length>0&&r.$exception_values.push(o),r},{$exception_types:[],$exception_values:[]});return this.Zt.some(r=>{var i=r.values.map(s=>{var o,a=ha[s.operator],l=$(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)});return r.type==="OR"?i.some(Boolean):i.every(Boolean)})}si(e){return e.flatMap(t=>{var r,i;return(r=(i=t.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]}).some(t=>t.filename&&t.filename.startsWith("chrome-extension://"))}ni(e){if(e.length>0){var t,r,i,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(i=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ei(e){return!T(e)&&$(e)}},ae=G("[FeatureFlags]"),Ot=G("[FeatureFlags]",{debugEnabled:!0}),vr="$active_feature_flags",at="$override_feature_flags",eo="$feature_flag_payloads",$t="$override_feature_flag_payloads",to="$feature_flag_request_id",no="$feature_flag_evaluated_at",ro=n=>{var e={};for(var[t,r]of yn(n||{}))r&&(e[t]=r);return e},Au=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map(t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]})),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter(t=>e[t].enabled).filter(t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload}).map(t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]}))):ae.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},Tu=function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n}({}),di=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(ae.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter(r=>{var i=r&&typeof r=="string"&&r.trim().length>0;return i||ae.error("Invalid evaluation context found:",r,"Expected non-empty string"),i}):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Vr),t=this._instance.get_property(at),r=this._instance.get_property($t);if(!r&&!t)return e||{};var i=L({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=i[o],u=t?.[o],p=w(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,h=w(u)?c.variant:typeof u=="string"?u:void 0,d=r?.[o],g=E({},c,{enabled:p,variant:p?h??c?.variant:void 0});p!==c?.enabled&&(g.original_enabled=c?.enabled),h!==c?.variant&&(g.original_variant=c?.variant),d&&(g.metadata=E({},c?.metadata,{payload:d,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=g}return this.oi||(ae.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(ht),t=this._instance.get_property(at);if(!t)return e||{};for(var r=L({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ae.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(eo),t=this._instance.get_property($t);if(!t)return e||{};for(var r=L({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ae.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.oi=!0),r}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this.gi=setTimeout(()=>{this.mi()},5))}bi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.bi(),!this._instance.M())if(this.li)this.hi=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:E({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(Vt)||{}),group_properties:this._instance.get_property(Xe)};ye(i)||w(i)||(s.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(s.timezone=la()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Me.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var p,h,d=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),d=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((h=u.json)!==null&&h!==void 0?h:{})),!s.disable_flags||this.hi)if(this.vi=!d,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(Tu.FeatureFlags))ae.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 g;s.disable_flags||this.receivedFeatureFlags((g=u.json)!==null&&g!==void 0?g:{},d),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlagResult(e,t);return(r=i?.variant)!==null&&r!==void 0?r:i?.enabled}ae.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(to)||void 0,c=this._instance.get_property(no)||void 0,u=this._instance.get_property(xn)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,h,d,g,f,y,P,b,_;$(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[xn]:u});var m=this.getFeatureFlagDetails(e),S={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((h=this._instance.config.bootstrap)==null||(h=h.featureFlags)==null?void 0:h[e])||null,$feature_flag_bootstrapped_payload:((d=this._instance.config.bootstrap)==null||(d=d.featureFlagPayloads)==null?void 0:d[e])||null,$used_bootstrap_value:!this.vi};w(m==null||(g=m.metadata)==null?void 0:g.version)||(S.$feature_flag_version=m.metadata.version);var F,O=(f=m==null||(y=m.reason)==null?void 0:y.description)!==null&&f!==void 0?f:m==null||(P=m.reason)==null?void 0:P.code;O&&(S.$feature_flag_reason=O),m!=null&&(b=m.metadata)!=null&&b.id&&(S.$feature_flag_id=m.metadata.id),w(m?.original_variant)&&w(m?.original_enabled)||(S.$feature_flag_original_response=w(m.original_variant)?m.original_enabled:m.original_variant),m!=null&&(_=m.metadata)!=null&&_.original_payload&&(S.$feature_flag_original_payload=m==null||(F=m.metadata)==null?void 0:F.original_payload),this._instance.capture("$feature_flag_called",S)}if(i){var C=o;if(!w(o))try{C=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:C}}}else ae.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(i.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:Me.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return w(r)?void 0:!!r}ae.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(t=>t!==e)}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var p=Au(o),h=p.flags,d=p.featureFlags,g=p.featureFlagPayloads;if(d){var f=o.requestId,y=o.evaluatedAt;if($(d)){ae.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var P={};if(d)for(var b=0;b<d.length;b++)P[d[b]]=!0;a&&a.register({[vr]:d,[ht]:P})}else{var _=d,m=g,S=h;if(o.errorsWhileComputingFlags)if(h){var F=new Set(Object.keys(h).filter(O=>{var C;return!((C=h[O])!=null&&C.failed)}));_=E({},l,Object.fromEntries(Object.entries(_).filter(O=>{var[C]=O;return F.has(C)}))),m=E({},c,Object.fromEntries(Object.entries(m||{}).filter(O=>{var[C]=O;return F.has(C)}))),S=E({},u,Object.fromEntries(Object.entries(S||{}).filter(O=>{var[C]=O;return F.has(C)})))}else _=E({},l,_),m=E({},c,m),S=E({},u,S);a&&a.register(E({[vr]:Object.keys(ro(_)),[ht]:_||{},[eo]:m||{},[Vr]:S||{}},f?{[to]:f}:{},y?{[no]:y}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),ae.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ae.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(at),this._instance.persistence.unregister($t),this.wi(),Ot.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.oi=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(at),Ot.info("Flag overrides cleared");else if(r.flags){if($(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[at]:i})}else this._instance.persistence.register({[at]:r.flags});Ot.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister($t),Ot.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[$t]:r.payloads}),Ot.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var i,s=(this._instance.get_property(Lt)||[]).find(c=>c.flagKey===e),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$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=E({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[vr]:Object.keys(ro(l)),[ht]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(Lt),s=r?"&"+r.map(o=>"stage="+o).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({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 c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Lt),(l=this._instance.persistence)==null||l.register({[Lt]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(r=>t[r]),flagVariants:Object.keys(t).filter(r=>t[r]).reduce((r,i)=>(r[i]=t[i],r),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach(i=>i(t,r,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Vt)||{};this._instance.register({[Vt]:E({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Vt)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Xe)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=E({},r[i],e[i]),delete e[i]}),this._instance.register({[Xe]:E({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Xe)||{};this._instance.register({[Xe]:E({},t,{[e]:{}})})}else this._instance.unregister(Xe)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.bi(),this.oi=!1}},Fu=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Bt=class{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(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.Y=this.Si(e),this.load(),e.debug&&x.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){Fu.indexOf(e.persistence.toLowerCase())===-1&&(x.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(i){i===void 0&&(i=[]);var s=[...cu,...i];return E({},j,{W:function(o){try{var a={};try{a=be.W(o)||{}}catch{}var l=L(a,JSON.parse(j.q(o)||"{}"));return j.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{j.G(o,a,void 0,void 0,p);var h={};s.forEach(d=>{a[d]&&(h[d]=a[d])}),Object.keys(h).length&&be.G(o,h,l,c,u,p)}catch(d){j.B(d)}},V:function(o,a){try{v?.localStorage.removeItem(o),be.V(o,a)}catch(l){j.B(l)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&j.H()?j:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&K.H()?K:r==="memory"?pu:r==="cookie"?be:t.H()?t:be}properties(){var e={};return N(this.props,function(t,r){if(r===ht&&z(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else a=r,l=!1,(ye(o=Bl)?l:ys&&o.indexOf===ys?o.indexOf(a)!=-1:(N(o,function(c){if(l||(l=c===a))return kn}),l))||(e[r]=t);var o,a,l}),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=L({},e))}}save(){this.ki||this.Y.G(this.$i,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.$i,!1),this.Y.V(this.$i,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(z(e)){w(t)&&(t="None"),this.Pi=w(r)?this.Ci:r;var i=!1;if(N(e,(s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,i=!0)}),i)return this.save(),!0}return!1}register(e,t){if(z(e)){this.Pi=w(t)?this.Ci:t;var r=!1;if(N(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.Ei){var e=na(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);dt(qi(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=k?.referrer)?ia(e):{})}update_referrer_info(){var e;this.register_once({$referrer:sa(),$referring_domain:k!=null&&k.referrer&&((e=In(k.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Kr]||this.props[Br]||this.register_once({[En]:oa(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};N([Br,Kr],o=>{var a=this.props[o];a&&N(a,function(l,c){e["$initial_"+xr(c)]=l})});var t,r,i=this.props[En];if(i){var s=(t=aa(i),r={},N(t,function(o,a){r["$initial_"+xr(a)]=o}),r);L(e,s)}return e}safe_merge(e){return N(this.props,function(t,r){r in e||(e[r]=t)}),e}update_config(e,t,r){if(this.Ci=this.Pi=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!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every((u,p)=>u===c[p])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var i=this.Si(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[Gt]||{};r[e]=t,this.props[Gt]=r,this.save()}remove_event_timer(e){var t=(this.props[Gt]||{})[e];return w(t)||(delete this.props[Gt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},io=G("[Product Tours]"),yr="ph_product_tours",hi=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Fs]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Fs)||this.it(()=>this.Oi())}it(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",i=>{i?io.error("Could not load product tours script",i):e()})}Oi(){var e;!this.Ri&&(e=I.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=I.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!$(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[yr];if($(i)&&!t)return this.Fi=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return io.error(a),void e([],{isLoaded:!1,error:a})}var l=$(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[yr]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){T(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it(()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)})}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(yr)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},Dt=function(n){return n.Activation="events",n.Cancellation="cancelEvents",n}({}),gp=function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n}({}),vp=function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n}({}),yp=function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n}({}),mr=function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n}({}),mp=function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n}({}),_p=function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n}({}),bp=function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n}({}),zt=function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n}({}),_r=function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n}({}),fi=function(n){return n.Popover="popover",n.Inline="inline",n}({}),D=G("[Surveys]"),ga="seenSurvey_",Ou=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},so=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(ga,n),$u=[mr.Popover,mr.Widget,mr.API],Du={ignoreConditions:!1,ignoreDelay:!1,displayType:fi.Popover},en=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter(r=>r!==t)}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var i of this.Mi["*"]||[])i(e,t)}};function lt(n,e,t){if(T(n))return!1;switch(t){case"exact":return n===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var gi=class{constructor(e){this.Ai=new en,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!w((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook((r,i)=>{this.on(r,i)})}}register(e){var t,r;if(!w((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach(o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach(c=>{var u;(u=this.zi)==null||u.add(c?.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?.selector)})}),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach(i=>{this.Bi(t,i)&&this.Ai.emit("actionCaptured",i.name)})}qi(e){this.onAction("actionCaptured",t=>e(t))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!lt(i,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var i=this.Ji(e);if(i.length>0)return i.some(a=>lt(a.href,t.href,t.href_matching||"exact"));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&lt((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var i=this.Ji(e);if(i.length>0)return i.some(c=>lt(c.text,t.text,t.text_matching||"exact")||lt(c.$el_text,t.text,t.text_matching||"exact"));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=function(c){for(var u,p=[],h=/(?::|")text="(.*?)"/g;!T(u=h.exec(c));)p.includes(u[1])||p.push(u[1]);return p}(l),o=t.text,a=t.text_matching||"exact",s.some(c=>lt(c,o,a)))}Vi(e,t){var r,i;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||fa(t.properties.reduce((r,i)=>{var s=$(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r},{}),e?.properties)}},vi=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&fa(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach(i=>{var s;(s=i.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach(o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}})}),r}te(e,t,r){var i=(r===Dt.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie(o=>{s=o.filter(a=>i?.includes(a.id))}),s.filter(o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find(c=>c.name===e);return this.Qi(l,t)})}register(e){var t;w((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=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});t.length!==0&&(this.se==null&&(this.se=new gi(this._instance),this.se.init(),this.se.qi(r=>{this.onAction(r)})),t.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.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach(c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}}))}))}ee(e){var t,r=e.filter(s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0}),i=e.filter(s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0});(r.length!==0||i.length!==0)&&((t=this._instance)==null||t._addCaptureHook((s,o)=>{this.onEvent(s,o)}),this.Ki=this.Zi(e,Dt.Activation),this.Yi=this.Zi(e,Dt.Cancellation))}onEvent(e,t){var r,i=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var p=a.indexOf(u);p>=0&&(a.splice(p,1),this.le(a))}}else{if(this.Yi.has(e)){var h=this.te(e,t,Dt.Cancellation);h.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:h.map(g=>g.id)}),h.forEach(g=>{var f=a.indexOf(g.id);f>=0&&a.splice(f,1),this.ue(g.id)}),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var d=this.te(e,t,Dt.Activation);this.le(a.concat(d.map(g=>g.id)||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter(o=>!this.he(o));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},yi=class extends vi{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return zt.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return D}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},mi=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(T(t))return D.warn("Flags not loaded yet. Not loading surveys.");var r=$(t);this.ve=r?t.length>0:t,D.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(ga)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)D.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)D.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())D.info("Not loading surveys in cookieless mode without consent.");else{var e=I?.__PosthogExtensions__;if(e){if(!w(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this.ge(r,t);var i=e.loadExternalDependency;if(!i)return void this._e("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",s=>{s||!e.generateSurveys?this._e("Could not load surveys script",s):this.ge(e.generateSurveys,t)})}catch(s){throw this._e("Error initializing surveys",s),s}finally{this.ce=!1}}}else D.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new yi(this._instance),D.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){D.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter(t=>t!==e)}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return D.info("Disabled. Not loading surveys."),e([]);var r,i=this._instance.get_property(Ur);if(i&&!t)return e(i,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then(s=>{var{surveys:o,context:a}=s;return e(o,a)}):(typeof Promise<"u"&&(this.pe=new Promise(s=>{r=s})),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;D.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,p=s.json.surveys||[],h=p.filter(g=>function(f){return!(!f.start_date||f.end_date)}(g)&&(function(f){var y;return!((y=f.conditions)==null||(y=y.events)==null||(y=y.values)==null||!y.length)}(g)||function(f){var y;return!((y=f.conditions)==null||(y=y.actions)==null||(y=y.values)==null||!y.length)}(g)));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(o=this._instance.persistence)==null||o.register({[Ur]:p});var d={isLoaded:!0};e(p,d),r?.({surveys:p,context:d})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){D.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!T(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);D.warn("init was not called")}be(e){var t=null;return this.getSurveys(r=>{var i;t=(i=r.find(s=>s.id===e))!==null&&i!==void 0?i:null}),t}ye(e){if(T(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(T(this._surveyManager))return D.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return T(this._surveyManager)?(D.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.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,r){var i;if(T(this._surveyManager))D.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if($u.includes(s.type)){var o=k?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(D.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var a,l;D.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),D.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);D.warn("Survey element not found")}else D.warn("Surveys of type "+s.type+" cannot be rendered in the app");else D.warn("Survey not found")}}displaySurvey(e,t){var r;if(T(this._surveyManager))D.warn("init was not called");else{var i=this.be(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=E({},i,{appearance:E({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==fi.Popover&&t.initialResponses&&D.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void D.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==fi.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else D.warn("Survey not found")}}cancelPendingSurvey(e){T(this._surveyManager)?D.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},Pe=G("[Conversations]"),_i=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.Ee=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;T(t)||(Ae(t)?this.we=t:(this.we=t.enabled,this.Ee=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.Ee=null}loadIfEnabled(){if(!this._conversationsManager&&!this.xe&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=I?.__PosthogExtensions__;if(e&&!w(this.we)&&this.we)if(this.Ee&&this.Ee.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.$e(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",i=>{i||!e.initConversations?this.Se("Could not load conversations script",i):this.$e(e.initConversations),this.xe=!1})}catch(i){this.Se("Error initializing conversations",i),this.xe=!1}}else Pe.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),Pe.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else Pe.error("Cannot complete initialization: remote config is null")}Se(e,t){Pe.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():Pe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!ye(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var i=this;return pt(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(Pe.warn("Conversations not available yet."),null)})()}getMessages(e,t){var r=this;return pt(function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(Pe.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Pe.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Pe.warn("Conversations not available yet."),null)})()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},bi=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!T(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=G("[logs]"),t=I?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Pe=!0)}):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},oo=G("[RateLimiter]"),ki=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach(i=>{oo.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void oo.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,i;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(Hr))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(Hr,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},We=G("[RemoteConfig]"),wi=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=I._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=I.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(We.error("PostHog Extensions not found. Cannot load remote config."),e())}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return We.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void We.warn("Remote config is disabled. Falling back to local config.");this.Te(e=>{if(!e)return We.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie(t=>{this.yi(t)});this.yi(e)})}catch(e){We.error("Error loading remote config",e)}}yi(e){e?this._instance.config.__preview_remote_config?(this._instance.yi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):We.info("__preview_remote_config is disabled. Logging config instead",e):We.error("Failed to fetch remote config from PostHog.")}},xi=3e3,Ei=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=ke(t?.flush_interval_ms||xi,250,5e3,x.createLogger("flush interval"),xi),this.Oe=e}enqueue(e){this.Re.push(e),this.Me||this.Ae()}unload(){this.je();var e=this.Re.length>0?this.De():{},t=Object.values(e);[...t.filter(r=>r.url.indexOf("/e")===0),...t.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Oe(E({},r,{transport:"sendBeacon"}))})}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Me=setTimeout(()=>{if(this.je(),this.Re.length>0){var t=this.De(),r=function(){var s=t[i],o=new Date().getTime();s.data&&$(s.data)&&N(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),e.Oe(s)};for(var i in t)r()}},this.Fe))}je(){clearTimeout(this.Me),this.Me=void 0}De(){var e={};return N(this.Re,t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;w(e[s])&&(e[s]=E({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)}),this.Re=[],e}},Nu=["retriesPerformedSoFar"],Pi=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!w(v)&&"onLine"in v.navigator&&(this.Ue=v.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},U(v,"online",this.ze),U(v,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=ho(e,Nu);ut(t)&&(r.url=$n(r.url,{retry_count:t})),this._instance._send_request(E({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(E({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(i)}}))}Be(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)}(t),i=Date.now()+r;this.Re.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),x.warn(s),this.Le||(this.Le=!0,this.qe())}qe(){if(this.We&&clearTimeout(this.We),this.Re.length===0)return this.Le=!1,void(this.We=void 0);this.We=setTimeout(()=>{this.Ue&&this.Re.length>0&&this.Lt(),this.qe()},this.Ne)}Lt(){var e=Date.now(),t=[],r=this.Re.filter(s=>s.retryAt<e||(t.push(s),!1));if(this.Re=t,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.We&&(clearTimeout(this.We),this.We=void 0),this.Le=!1,w(v)||(this.ze&&(v.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(v.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(E({},e,{transport:"sendBeacon"}))}catch(t){x.error(t)}this.Re=[]}},Si=class{constructor(e){this.Ge=()=>{var t,r,i,s;this.Ve||(this.Ve={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ve.lastScrollY=Math.ceil(a),this.Ve.maxScrollY=Math.max(a,(t=this.Ve.maxScrollY)!==null&&t!==void 0?t:0),this.Ve.maxScrollHeight=Math.max(l,(r=this.Ve.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ve.lastContentY=c,this.Ve.maxContentY=Math.max(c,(i=this.Ve.maxContentY)!==null&&i!==void 0?i:0),this.Ve.maxContentHeight=Math.max(u,(s=this.Ve.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ve}resetContext(){var e=this.Ve;return setTimeout(this.Ge,0),e}startMeasuringScrollPosition(){U(v,"scroll",this.Ge,{capture:!0}),U(v,"scrollend",this.Ge,{capture:!0}),U(v,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return v?.document.documentElement;var e=$(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=v?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return v&&(v.scrollY||v.pageYOffset||v.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return v&&(v.scrollX||v.pageXOffset||v.document.documentElement.scrollLeft)||0}},qu=n=>oa(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Nn=class{constructor(e,t,r,i){this.Je=s=>{var o=this.Ke();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ye(this._instance)};this.Xe.register({[zr]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||qu,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[zr]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?aa(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return N(qi(this.getSetOnceProps()),(t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+xr(r)]=t}),e}},br=G("[SessionId]"),qn=class{on(e,t){return this.Ze.on(e,t)}constructor(e,t,r){var i;if(this.tr=[],this.ir=void 0,this.Ze=new en,this.er=(u,p)=>!(!ut(u)||!ut(p))&&Math.abs(u-p)>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.R=e.config,this.Xe=e.persistence,this.rr=void 0,this.sr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.nr=t||Ge,this.ar=r||Ge;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ke(o,60,36e3,br.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+s+"_window_id",this.hr="ph_"+s+"_primary_window_exists",this.dr()){var a=K.W(this.ur),l=K.W(this.hr);a&&!l?this.rr=a:K.V(this.ur),K.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var p=u.replace(/-/g,"");if(p.length!==32)throw new Error("Not a valid UUID");if(p[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(p.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){br.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return w(this.tr)&&(this.tr=[]),this.tr.push(e),this.sr&&e(this.sr,this.rr),()=>{this.tr=this.tr.filter(t=>t!==e)}}dr(){return this.R.persistence!=="memory"&&!this.Xe.ki&&K.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&K.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?K.W(this.ur):null}vr(e,t,r){e===this.sr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.sr=e,this.Xe.register({[wn]:[t,e,r]}))}_r(){var e=this.Xe.props[wn];return $(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vr(null,null,null)}destroy(){clearTimeout(this.mr),this.mr=void 0,this.ir&&v&&(v.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&K.V(this.hr)},U(v,"beforeunload",this.ir,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[i,s,o]=this._r(),a=this.gr(),l=ut(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,p=!u&&!e&&this.er(r,i);u||p||l?(s=this.nr(),a=this.ar(),br.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var h=ut(i)&&e&&!l?i:r,d=ut(o)?o:new Date().getTime();return this.pr(a),this.vr(s,h,d),e||this.lr(),c&&this.tr.forEach(g=>g(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:a,sessionStartTimestamp:d,changeReason:c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}lr(){clearTimeout(this.mr),this.mr=setTimeout(()=>{var[e]=this._r();if(this.er(new Date().getTime(),e)){var t=this.sr;this.resetSessionId(),this.Ze.emit("forcedIdleReset",{idleSessionId:t})}},1.1*this.sessionTimeoutMs)}},ju=["$set_once","$set"],qe=G("[SiteApps]"),Ci=class{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yr(e,t){if(t){var r=this.globalsForEvent(t);this.br.push(r),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=I._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yr.bind(this));this.wr=()=>{e(),this.br=[],this.wr=void 0}}}globalsForEvent(e){var t,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],p=this._instance.get_property("$stored_group_properties")||{};for(var[h,d]of Object.entries(p))c[h]={id:u[h],type:h,properties:d};var{$set_once:g,$set:f}=e;return{event:E({},ho(e,ju),{properties:E({},e.properties,f?{$set:E({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},f)}:{},g?{$set_once:E({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},g)}:{}),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:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.br.length&&(qe.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach(l=>t.processEvent==null?void 0:t.processEvent(l)),t.processedBuffer=!0),Object.values(this.apps).every(l=>l.processedBuffer||l.errored)&&((a=this.wr)==null||a.call(this))},i=!1,s=a=>{t.errored=!a,t.loaded=!0,qe.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&&(t.processEvent=o),i=!0}catch(a){qe.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){qe.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}Er(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}$r(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(i){qe.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var t,r,i,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Er(),void this._instance.on("eventCaptured",c=>this.$r(c))):void qe.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.wr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(c){var u;I["__$$ph_site_app_"+c]=s._instance,(u=I.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,p=>{if(p)return qe.error("Error while initializing PostHog app with config id "+c,p)})};for(var{id:a,url:l}of e.siteApps)o(a)}else qe.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},va=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&bs(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>bs(i?.brand,e)))return!0}catch{}return!!n.webdriver},Ht=function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n}({}),ao="i.posthog.com",Ii=class{constructor(e){this.Sr={},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 flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Sr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Ht.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Ht.EU:this.Sr[this.apiHost]=Ht.CUSTOM),this.Sr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===Ht.CUSTOM)return this.apiHost+t;var r=ao+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},Gu={icontains:(n,e)=>!!v&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!v&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!v&&Dn(e.href,n),not_regex:(n,e)=>!!v&&!Dn(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Mi=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments(i=>{n.kr("retrieved web experiments from the server"),t.Pr=new Map,i.forEach(s=>{if(s.feature_flag_key){var o;t.Pr&&(n.kr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Pr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);H(a)&&s.variants[a]&&t.Tr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];n.Ir(c)&&t.Tr(s.name,l,c.transforms)}})},r)},this._instance=e,this._instance.onFeatureFlags(r=>{this.onFeatureFlags(r)})}onFeatureFlags(e){if(this._is_bot())n.kr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(T(this.Pr))return this.Pr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.kr("applying feature flags",e),e.forEach(t=>{var r;if(this.Pr&&(r=this.Pr)!=null&&r.has(t)){var i,s=this._instance.getFeatureFlag(t),o=(i=this.Pr)==null?void 0:i.get(t);s&&o!=null&&o.variants[s]&&this.Tr(o.name,s,o.variants[s].transforms)}})}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=Mn(e?.search,"__experiment_id"),r=Mn(e?.search,"__experiment_variant");t&&r&&(n.kr("previewing web experiments "+t+" && "+r),this.getWebExperiments(i=>{this.Cr(parseInt(t),r,i)},!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance._send_request({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)}})}Cr(e,t,r){var i=r.filter(s=>s.id===e);i&&i.length>0&&(n.kr("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.Tr(i[0].name,t,i[0].variants[t].transforms))}static Ir(e){return!T(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(T(e.conditions)||T((t=e.conditions)==null?void 0:t.url))return!0;var r,i,s,o=n.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||Gu[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return v?.location}static Fr(e){var t;if(T(e.conditions)||T((t=e.conditions)==null?void 0:t.utm))return!0;var r=na();if(r.utm_source){var i,s,o,a,l,c,u,p,h=(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,d=(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,g=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,f=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return h&&g&&f&&d}return!1}static kr(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];x.info("[WebExperiments] "+e,r)}Tr(e,t,r){this._is_bot()?n.kr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach(i=>{if(i.selector){var s;n.kr("applying transform of variant "+t+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o?.forEach(a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)})}}):n.kr("Control variants leave the page unmodified.")}_is_bot(){return le&&this._instance?va(le,this._instance.config.custom_blocked_useragents):void 0}},Lu=G("[PostHog ExternalIntegrations]"),Vu={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ri=class{constructor(e){this._instance=e}it(e,t){var r;(r=I.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,i=>{if(i)return Lu.error("failed to load script",i);t()})}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=I.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(Vu[o],()=>{var u;(u=I.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)}),!i&&(l=I.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=I.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}},Ai="[SessionRecording]",Nt=G(Ai),jn=class{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Mr&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Mr=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw Nt.error("started without valid sessionManager"),new Error(Ai+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ai+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(ar))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return v&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!w(Object.assign)&&!w(Array.from);this.Ar&&r?(this.Dr(e),Nt.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(I!=null&&(t=I.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=I.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=I.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,s=>{if(s)return Nt.error("could not load recorder",s);this.Lr(e)}))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(jo)}zr(e){if(this._instance.persistence){var t,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=T(a)?null:parseFloat(a);T(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[ar]:E({enabled:!!o},o,{networkPayloadCapture:E({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:w(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.jr)==null||t.call(this),this.jr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Mr=!0,this.startIfEnabledOrStop()):this.Mr=!0:Nt.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Or)!=null&&r.log?this.Or.log(e,t):Nt.warn("log called before recorder was ready")}get Nr(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(ar);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=I.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=I.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Or||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Or)==null||!r.tryAddCustomEvent(e,t))}},Wt={},Ti=()=>{},ct="posthog",ya=!Ru&&se?.indexOf("MSIE")===-1&&se?.indexOf("Mozilla")===-1,lo=n=>{var e;return E({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Kl(k?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ti,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:B&&H(B?.search)&&B.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_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(v==null||(e=v.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,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:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;x.error(r)},get_device_id:t=>t,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:xi},error_tracking:{},_onCapture:Ti,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},uo=n=>{var e={};w(n.process_person)||(e.person_profiles=n.process_person),w(n.xhr_headers)||(e.request_headers=n.xhr_headers),w(n.cookie_name)||(e.persistence_name=n.cookie_name),w(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),w(n.store_google)||(e.save_campaign_params=n.store_google),w(n.verbose)||(e.debug=n.verbose);var t=L({},e,n);return $(n.property_blacklist)&&(w(n.property_denylist)?t.property_denylist=n.property_blacklist:$(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:x.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Fi=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){x.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Gn=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Fi,this.Br=!1,this.version=Se.LIB_VERSION,this.qr=new en,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=lo(),this.SentryIntegration=ni,this.sentryIntegration=e=>function(t,r){var i=ta(t,r);return{name:ea,processEvent:s=>i(s)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new di(this),this.toolbar=new ri(this),this.scrollManager=new Si(this),this.pageViewManager=new Tn(this),this.surveys=new mi(this),this.conversations=new _i(this),this.logs=new bi(this),this.experiments=new Mi(this),this.exceptions=new pi(this),this.rateLimiter=new ki(this),this.requestRouter=new Ii(this),this.consent=new Qr(this),this.externalIntegrations=new Ri(this),this.people={set:(e,t,r)=>{var i=H(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=H(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",e=>x.info('send "'+e?.event+'"',e))}init(e,t,r){if(r&&r!==ct){var i,s=(i=Wt[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Wt[r]=s,Wt[ct][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),w(e)||Er(e))return x.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 console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(L({},lo(t.defaults),uo(t),{name:r,token:e})),this.config.on_xhr_error&&x.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Me.GZipJS;var s=this.Qr();this.persistence=new Bt(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Bt(E({},this.config,{persistence:"sessionStorage"}),s);var o=E({},this.persistence.props),a=E({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new Ei(b=>this.ts(b),this.config.request_queue_config),this.es=new Pi(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new qn(this),this.sessionPropsManager=new Nn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(x.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(x.info("Initializing extensions synchronously"),this.rs(l)),Se.DEBUG=Se.DEBUG||this.config.debug,Se.DEBUG&&x.info("Starting in debug mode",{this:this,config:t,thisC:E({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,p=this.config.get_device_id(Ge()),h=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(Ce,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this.ss()){var d,g,f=Object.keys(((d=t.bootstrap)==null?void 0:d.featureFlags)||{}).filter(b=>{var _;return!((_=t.bootstrap)==null||(_=_.featureFlags)==null||!_[b])}).reduce((b,_)=>{var m;return b[_]=((m=t.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[_])||!1,b},{}),y=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter(b=>f[b]).reduce((b,_)=>{var m,S;return(m=t.bootstrap)!=null&&(m=m.featureFlagPayloads)!=null&&m[_]&&(b[_]=(S=t.bootstrap)==null||(S=S.featureFlagPayloads)==null?void 0:S[_]),b},{});this.featureFlags.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:y})}if(l)this.register_once({distinct_id:Mt,$device_id:null},"");else if(!this.get_distinct_id()){var P=this.config.get_device_id(Ge());this.register_once({distinct_id:P,$device_id:P},""),this.persistence.set_property(Ce,"anonymous")}return U(v,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?fu(this,()=>this.ns()):this.ns(),Le(this.config._onCapture)&&this.config._onCapture!==Ti&&(x.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",b=>this.config._onCapture(b.event,b))),this.config.ip&&x.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}rs(e){var t=performance.now();this.historyAutocapture=new ti(this),this.historyAutocapture.startIfEnabled();var r=[];r.push(()=>{new ii(this).startIfEnabledOrStop()}),r.push(()=>{var i;this.siteApps=new Ci(this),(i=this.siteApps)==null||i.init()}),e||r.push(()=>{this.sessionRecording=new jn(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.push(()=>{this.autocapture=new Xr(this),this.autocapture.startIfEnabled()}),r.push(()=>{this.surveys.loadIfEnabled()}),r.push(()=>{this.logs.loadIfEnabled()}),r.push(()=>{this.conversations.loadIfEnabled()}),r.push(()=>{this.productTours=new hi(this),this.productTours.loadIfEnabled()}),r.push(()=>{this.heatmaps=new oi(this),this.heatmaps.startIfEnabled()}),r.push(()=>{this.webVitalsAutocapture=new si(this)}),r.push(()=>{this.exceptionObserver=new ei(this),this.exceptionObserver.startIfEnabledOrStop()}),r.push(()=>{this.deadClicksAutocapture=new An(this,hu),this.deadClicksAutocapture.startIfEnabled()}),r.push(()=>{if(this.os){var i=this.os;this.os=void 0,this.yi(i)}}),this.ls(r,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout(()=>{this.ls(e,t)},0);var r=e.shift();if(r)try{r()}catch(s){x.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&x.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!k||!k.body)return x.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.yi(e)},500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=A(e.supportedCompression,Me.GZipJS)?Me.GZipJS:A(e.supportedCompression,Me.Base64)?Me.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"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),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(r){x.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&B!=null&&B.hostname){var e=B.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()},1),new wi(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Ve(this.__request_queue,e=>this.ts(e)),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(ya?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=$n(e.url,{ip:this.config.ip?1:0}),e.headers=E({},this.config.request_headers,e.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,(t=>{var r,i,s,o=E({},t);o.timeout=o.timeout||6e4,o.url=$n(o.url,{_:new Date().getTime().toString(),ver:Se.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=mn.filter(u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport)),c=(i=(s=Do(l,u=>u.transport===a))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(E({},e,{callback:t=>{var r,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,r=[],i=[],s=[];Ve(e,a=>{a&&(t=a[0],$(t)?s.push(a):Le(a)?a.call(this):$(a)&&t==="alias"?r.push(a):$(a)&&t.indexOf("capture")!==-1&&Le(this[t])?s.push(a):i.push(a))});var o=function(a,l){Ve(a,function(c){if($(c[0])){var u=l;N(c,function(p){u=u[p[0]].apply(u,p.slice(1))})}else this[c[0]].apply(this,c.slice(1))},l)};o(r,this),o(i,this),o(s,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!w(e)&&H(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!H(t?.$current_url)&&(x.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$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 a=new Date,l=r?.timestamp||a,c=Ge(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var p,h=e!=="$groupidentify",d=this.vs(r?.$set_once,h);if(d&&(u.$set_once=d),(u=zl(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,w(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===zt.DISMISSED||e===zt.SENT){var g=t?.[_r.SURVEY_ID],f=t?.[_r.SURVEY_ITERATION];p={id:g,current_iteration:f},localStorage.getItem(so(p))||localStorage.setItem(so(p),"true"),u.$set=E({},u.$set,{[Ou({id:g,current_iteration:f},e===zt.SENT?"responded":"dismissed")]:!0})}else e===zt.SHOWN&&(u.$set=E({},u.$set,{[_r.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var y=E({},u.properties.$set,u.$set);if(dt(y)||this.setPersonPropertiesForFlags(y),!T(this.config.before_send)){var P=this.cs(u);if(!P)return;u=P}this.qr.emit("eventCaptured",u);var b={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ts(b):this.Zr.enqueue(b),u}x.critical("This capture call is ignored due to client rate limiting.")}}else x.error("No event name provided to posthog.capture")}else x.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=E({},t);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=E({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!H(a.distinct_id)&&!Te(a.distinct_id)||Er(a.distinct_id))&&x.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=bu(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=h}this.sessionPropsManager&&L(a,this.sessionPropsManager.getSessionProps());try{var d;this.sessionRecording&&L(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(d=this.es)==null?void 0:d.length}catch(P){a.$sdk_debug_error_capturing_properties=String(P)}if(this.requestRouter.region===Ht.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=L(a,c),e==="$pageview"&&k&&(a.title=k.title),!w(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}se&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=L({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),$(this.config.property_denylist)?N(this.config.property_denylist,function(P){delete a[P]}):x.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(x.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var y=this.fs();return a.$process_person_profile=y,y&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.Br)return e;var i=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=L({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(x.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),dt(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var i;(i=this.persistence)==null||i.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var i=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=E({},i,e),a=E({},s,t),l={};for(var[c,u]of Object.entries(o)){var p=typeof u=="string";l[c]={key:c,enabled:!!p||!!u,variant:p?u:void 0,reason:void 0,metadata:w(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.qr.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=Du),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return x.uninitializedWarning("posthog.identify");if(Te(e)&&(e=e.toString(),x.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()))x.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!==Mt){if(this.ps("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(jt)&&(this.unregister(jt),this.register({distinct_id:e}));var o=(this.persistence.get_property(Ce)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(Ce,"identified"),this.setPersonPropertiesForFlags(E({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=Qs(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(xn))}}else x.critical('The string "'+Mt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else x.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=Qs(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(E({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):x.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:E({},i,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===t||r||this.reloadFeatureFlags()}else x.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,i,s;if(x.info("reset"),!this.__loaded)return x.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(Ce,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Mt,$device_id:null},"");else{var a=this.config.get_device_id(Ge());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,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);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,t){return e===this.get_property(No)?(x.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(w(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(jt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(x.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=E({},this.config);if(z(e)){var r,i,s,o,a,l,c;L(this.config,uo(e));var u=this.Qr();(r=this.persistence)==null||r.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Bt(E({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);Ae(p)&&(this.config.debug=p),Ae(this.config.debug)&&(this.config.debug?(Se.DEBUG=!0,j.H()&&j.G("ph_debug","true"),x.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(Se.DEBUG=!1,j.H()&&j.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(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,t){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(E({},i,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:ct;return t!==ct&&(t=ct+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Ce))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(Ce))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&dt(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[jt])&&((t=this.persistence)==null||(t=t.props)==null||!t[Pn]))}ds(){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.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(x.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(Pn,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,r,i,s=this.Qr();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,i,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new qn(this),this.pageViewManager=new Tn(this),this.persistence&&(this.sessionPropsManager=new Nn(this,this.sessionManager,this.persistence)),this.sessionRecording=new jn(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(w(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else x.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Mt,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.hs())):x.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===Ie.GRANTED?"granted":e===Ie.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._s()}_is_bot(){return le?va(le,this.config.custom_blocked_useragents):void 0}hs(){k&&(k.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:k.title},{send_instantly:!0}),this.Gr&&(k.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),U(k,"visibilitychange",this.Gr)))}debug(e){e===!1?(v?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(v?.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)`."),this.set_config({debug:!0}))}M(){var e,t,r,i,s,o,a,l=this.Yr||{};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?(x.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=x,o=(t="advanced_disable_flags")in(e=l)&&!T(e[t]),a=r in e&&!T(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):i)}cs(e){if(T(this.config.before_send))return e;var t=$(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),T(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return yl(e.event)?x.warn(s+". This can cause unexpected behavior."):x.info(s),null}r.properties&&!dt(r.properties)||x.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Kr(e){var t=Ae(e)&&!e,r=j.H()&&j.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=Ul(n.prototype[e[t]])})(Gn,["identify"]);var co;var zn=(co=Wt[ct]=new Gn,function(){function n(){n.done||(n.done=!0,ya=!1,N(Wt,function(e){e._dom_loaded()}))}k!=null&&k.addEventListener?k.readyState==="complete"?n():U(k,"DOMContentLoaded",n,{capture:!1}):v&&x.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),co);var Uu="phc_u9YDYUeUxo3CYn16XGrrwpVb8ycXgcjz5DarvIKRAAG",sn=class n{constructor(e){R(this,"initialized",!1);this.initPostHog(e)}static getInstance(e){if(typeof window>"u")throw new Error("[PaymentKit Analytics] PostHog requires a browser environment");let t=window.__paymentKitPostHog__;if(t){if(t.apiBaseUrl!==e)throw new Error(`[PaymentKit Analytics] PostHog already initialized with apiBaseUrl "${t.apiBaseUrl}", cannot re-initialize with different apiBaseUrl "${e}"`);return t.instance}let r=new n(e);return window.__paymentKitPostHog__={instance:r,apiBaseUrl:e},r}initPostHog(e){try{zn.init(Uu,{api_host:`${e}/ingest`,ui_host:"https://us.posthog.com",persistence:"memory",disable_session_recording:!0,autocapture:!1,capture_pageview:!1,request_batching:!1,opt_out_useragent_filter:!0,loaded:()=>{this.initialized=!0}})}catch(t){console.warn("[PaymentKit Analytics] Failed to initialize PostHog:",t)}}identify(e){try{zn.identify(e)}catch(t){console.warn("[PaymentKit Analytics] Failed to identify:",t)}}capture(e,t){try{zn.capture(e,t)}catch(r){console.warn("[PaymentKit Analytics] Failed to capture event:",r)}}isInitialized(){return this.initialized}};var zi=class{constructor(){R(this,"adapters",[]);R(this,"testMock",null)}init(e,t){try{this.addAdapter(sn.getInstance(e)),t&&this.enableTestMode()}catch(r){console.warn("[PaymentKit Analytics] Init failed:",r)}}enableTestMode(){this.testMock||(this.testMock=new It,this.addAdapter(this.testMock),typeof window<"u"&&(window.__paymentKitAnalytics__=this.testMock))}getTestMock(){return this.testMock}addAdapter(e){this.adapters.includes(e)||this.adapters.push(e)}clearAdapters(){this.adapters=[],this.testMock=null,typeof window<"u"&&delete window.__paymentKitAnalytics__}identify(e){for(let t of this.adapters)try{t.identify(e)}catch{}}capture(e,t){for(let r of this.adapters)try{r.capture(e,t)}catch{}}isInitialized(){return this.adapters.some(e=>e.isInitialized())}},we=new zi;var on=class on{constructor(e,t){R(this,"startTime");R(this,"checkoutSessionId");R(this,"requestId");R(this,"inputReadyTracked",!1);this.startTime=performance.now(),this.checkoutSessionId=e,this.requestId=t}trackPageReady(){on.pageReadyTracked||(on.pageReadyTracked=!0,we.capture("checkout_page_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackInputReady(){this.inputReadyTracked||(this.inputReadyTracked=!0,we.capture("checkout_input_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackSubmit(){we.capture("checkout_submit",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()})}trackSuccess(e){we.capture("checkout_success",{checkout_session_id:this.checkoutSessionId,checkout_attempt_id:e,request_id:this.requestId,total_elapsed_ms:this.getElapsedMs()})}trackFail(e,t,r){we.capture("checkout_fail",{checkout_session_id:this.checkoutSessionId,checkout_attempt_id:e,request_id:this.requestId,error_code:t,error_message:r,total_elapsed_ms:this.getElapsedMs()})}getElapsedMs(){return Math.round(performance.now()-this.startTime)}};R(on,"pageReadyTracked",!1);var an=on;var zu=class extends Error{constructor(e,t){super(t);R(this,"code");this.name="PenpalError",this.code=e}},pe=zu,Hu=n=>({name:n.name,message:n.message,stack:n.stack,penpalCode:n instanceof pe?n.code:void 0}),Ku=({name:n,message:e,stack:t,penpalCode:r})=>{let i=r?new pe(r,e):new Error(e);return i.name=n,i.stack=t,i},Bu=Symbol("Reply"),Bi,wa,Wu=(wa=class{constructor(n,e){R(this,"value");R(this,"transferables");Z(this,Bi,Bu);this.value=n,this.transferables=e?.transferables}},Bi=new WeakMap,wa),Xu=Wu,ce="penpal",Wn=n=>typeof n=="object"&&n!==null,Pa=n=>typeof n=="function",Yu=n=>Wn(n)&&n.namespace===ce,Hn=n=>n.type==="SYN",Xi=n=>n.type==="ACK1",Hi=n=>n.type==="ACK2",Sa=n=>n.type==="CALL",Ca=n=>n.type==="REPLY",Ju=n=>n.type==="DESTROY",Ia=(n,e=[])=>{let t=[];for(let r of Object.keys(n)){let i=n[r];Pa(i)?t.push([...e,r]):Wn(i)&&t.push(...Ia(i,[...e,r]))}return t},Zu=(n,e)=>{let t=n.reduce((r,i)=>Wn(r)?r[i]:void 0,e);return Pa(t)?t:void 0},Ke=n=>n.join("."),ma=(n,e,t)=>({namespace:ce,channel:n,type:"REPLY",callId:e,isError:!0,...t instanceof Error?{value:Hu(t),isSerializedErrorInstance:!0}:{value:t}}),Qu=(n,e,t,r)=>{let i=!1,s=async o=>{if(i||!Sa(o))return;r?.(`Received ${Ke(o.methodPath)}() call`,o);let{methodPath:a,args:l,id:c}=o,u,p;try{let h=Zu(a,e);if(!h)throw new pe("METHOD_NOT_FOUND",`Method \`${Ke(a)}\` is not found.`);let d=await h(...l);d instanceof Xu&&(p=d.transferables,d=await d.value),u={namespace:ce,channel:t,type:"REPLY",callId:c,value:d}}catch(h){u=ma(t,c,h)}if(!i)try{r?.(`Sending ${Ke(a)}() reply`,u),n.sendMessage(u,p)}catch(h){throw h.name==="DataCloneError"&&(u=ma(t,c,h),r?.(`Sending ${Ke(a)}() reply`,u),n.sendMessage(u)),h}};return n.addMessageHandler(s),()=>{i=!0,n.removeMessageHandler(s)}},ec=Qu,Ma=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),tc=Symbol("CallOptions"),Wi,xa,nc=(xa=class{constructor(n){R(this,"transferables");R(this,"timeout");Z(this,Wi,tc);this.transferables=n?.transferables,this.timeout=n?.timeout}},Wi=new WeakMap,xa),rc=nc,ic=new Set(["apply","call","bind"]),Ra=(n,e,t=[])=>new Proxy(t.length?()=>{}:Object.create(null),{get(r,i){if(i!=="then")return t.length&&ic.has(i)?Reflect.get(r,i):Ra(n,e,[...t,i])},apply(r,i,s){return n(t,s)}}),_a=n=>new pe("CONNECTION_DESTROYED",`Method call ${Ke(n)}() failed due to destroyed connection`),sc=(n,e,t)=>{let r=!1,i=new Map,s=l=>{if(!Ca(l))return;let{callId:c,value:u,isError:p,isSerializedErrorInstance:h}=l,d=i.get(c);d&&(i.delete(c),t?.(`Received ${Ke(d.methodPath)}() call`,l),p?d.reject(h?Ku(u):u):d.resolve(u))};return n.addMessageHandler(s),{remoteProxy:Ra((l,c)=>{if(r)throw _a(l);let u=Ma(),p=c[c.length-1],h=p instanceof rc,{timeout:d,transferables:g}=h?p:{},f=h?c.slice(0,-1):c;return new Promise((y,P)=>{let b=d!==void 0?window.setTimeout(()=>{i.delete(u),P(new pe("METHOD_CALL_TIMEOUT",`Method call ${Ke(l)}() timed out after ${d}ms`))},d):void 0;i.set(u,{methodPath:l,resolve:y,reject:P,timeoutId:b});try{let _={namespace:ce,channel:e,type:"CALL",id:u,methodPath:l,args:f};t?.(`Sending ${Ke(l)}() call`,_),n.sendMessage(_,g)}catch(_){P(new pe("TRANSMISSION_FAILED",_.message))}})},t),destroy:()=>{r=!0,n.removeMessageHandler(s);for(let{methodPath:l,reject:c,timeoutId:u}of i.values())clearTimeout(u),c(_a(l));i.clear()}}},oc=sc,ac=()=>{let n,e;return{promise:new Promise((r,i)=>{n=r,e=i}),resolve:n,reject:e}},lc=ac,uc=class extends Error{constructor(n){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${n}`)}},Kn=uc,Ki="deprecated-penpal",cc=n=>Wn(n)&&"penpal"in n,pc=n=>n.split("."),ba=n=>n.join("."),Aa=n=>new Kn(`Unexpected message to translate: ${JSON.stringify(n)}`),dc=n=>{if(n.penpal==="syn")return{namespace:ce,channel:void 0,type:"SYN",participantId:Ki};if(n.penpal==="ack")return{namespace:ce,channel:void 0,type:"ACK2"};if(n.penpal==="call")return{namespace:ce,channel:void 0,type:"CALL",id:n.id,methodPath:pc(n.methodName),args:n.args};if(n.penpal==="reply")return n.resolution==="fulfilled"?{namespace:ce,channel:void 0,type:"REPLY",callId:n.id,value:n.returnValue}:{namespace:ce,channel:void 0,type:"REPLY",callId:n.id,isError:!0,...n.returnValueIsError?{value:n.returnValue,isSerializedErrorInstance:!0}:{value:n.returnValue}};throw Aa(n)},hc=n=>{if(Xi(n))return{penpal:"synAck",methodNames:n.methodPaths.map(ba)};if(Sa(n))return{penpal:"call",id:n.id,methodName:ba(n.methodPath),args:n.args};if(Ca(n))return n.isError?{penpal:"reply",id:n.callId,resolution:"rejected",...n.isSerializedErrorInstance?{returnValue:n.value,returnValueIsError:!0}:{returnValue:n.value}}:{penpal:"reply",id:n.callId,resolution:"fulfilled",returnValue:n.value};throw Aa(n)},fc=({messenger:n,methods:e,timeout:t,channel:r,log:i})=>{let s=Ma(),o,a=[],l=!1,c=Ia(e),{promise:u,resolve:p,reject:h}=lc(),d=t!==void 0?setTimeout(()=>{h(new pe("CONNECTION_TIMEOUT",`Connection timed out after ${t}ms`))},t):void 0,g=()=>{for(let S of a)S()},f=()=>{if(l)return;a.push(ec(n,e,r,i));let{remoteProxy:S,destroy:F}=oc(n,r,i);a.push(F),clearTimeout(d),l=!0,p({remoteProxy:S,destroy:g})},y=()=>{let S={namespace:ce,type:"SYN",channel:r,participantId:s};i?.("Sending handshake SYN",S);try{n.sendMessage(S)}catch(F){h(new pe("TRANSMISSION_FAILED",F.message))}},P=S=>{if(i?.("Received handshake SYN",S),S.participantId===o&&o!==Ki||(o=S.participantId,y(),!(s>o||o===Ki)))return;let O={namespace:ce,channel:r,type:"ACK1",methodPaths:c};i?.("Sending handshake ACK1",O);try{n.sendMessage(O)}catch(C){h(new pe("TRANSMISSION_FAILED",C.message));return}},b=S=>{i?.("Received handshake ACK1",S);let F={namespace:ce,channel:r,type:"ACK2"};i?.("Sending handshake ACK2",F);try{n.sendMessage(F)}catch(O){h(new pe("TRANSMISSION_FAILED",O.message));return}f()},_=S=>{i?.("Received handshake ACK2",S),f()},m=S=>{Hn(S)&&P(S),Xi(S)&&b(S),Hi(S)&&_(S)};return n.addMessageHandler(m),a.push(()=>n.removeMessageHandler(m)),y(),u},gc=fc,vc=n=>{let e=!1,t;return(...r)=>(e||(e=!0,t=n(...r)),t)},yc=vc,ka=new WeakSet,mc=({messenger:n,methods:e={},timeout:t,channel:r,log:i})=>{if(!n)throw new pe("INVALID_ARGUMENT","messenger must be defined");if(ka.has(n))throw new pe("INVALID_ARGUMENT","A messenger can only be used for a single connection");ka.add(n);let s=[n.destroy],o=yc(c=>{if(c){let u={namespace:ce,channel:r,type:"DESTROY"};try{n.sendMessage(u)}catch{}}for(let u of s)u();i?.("Connection destroyed")}),a=c=>Yu(c)&&c.channel===r;return{promise:(async()=>{try{n.initialize({log:i,validateReceivedMessage:a}),n.addMessageHandler(p=>{Ju(p)&&o(!1)});let{remoteProxy:c,destroy:u}=await gc({messenger:n,methods:e,timeout:t,channel:r,log:i});return s.push(u),c}catch(c){throw o(!0),c}})(),destroy:()=>{o(!0)}}},Ta=mc,ze,Ze,kt,wt,Qe,He,ue,et,Bn,xt,ln,un,Et,Ea,_c=(Ea=class{constructor({remoteWindow:n,allowedOrigins:e}){Z(this,ze);Z(this,Ze);Z(this,kt);Z(this,wt);Z(this,Qe);Z(this,He,new Set);Z(this,ue);Z(this,et,!1);R(this,"initialize",({log:n,validateReceivedMessage:e})=>{_e(this,kt,n),_e(this,wt,e),window.addEventListener("message",M(this,un))});R(this,"sendMessage",(n,e)=>{if(Hn(n)){let t=M(this,xt).call(this,n);M(this,ze).postMessage(n,{targetOrigin:t,transfer:e});return}if(Xi(n)||M(this,et)){let t=M(this,et)?hc(n):n,r=M(this,xt).call(this,n);M(this,ze).postMessage(t,{targetOrigin:r,transfer:e});return}if(Hi(n)){let{port1:t,port2:r}=new MessageChannel;_e(this,ue,t),t.addEventListener("message",M(this,Et)),t.start();let i=[r,...e||[]],s=M(this,xt).call(this,n);M(this,ze).postMessage(n,{targetOrigin:s,transfer:i});return}if(M(this,ue)){M(this,ue).postMessage(n,{transfer:e});return}throw new Kn("Port is undefined")});R(this,"addMessageHandler",n=>{M(this,He).add(n)});R(this,"removeMessageHandler",n=>{M(this,He).delete(n)});R(this,"destroy",()=>{window.removeEventListener("message",M(this,un)),M(this,ln).call(this),M(this,He).clear()});Z(this,Bn,n=>M(this,Ze).some(e=>e instanceof RegExp?e.test(n):e===n||e==="*"));Z(this,xt,n=>{if(Hn(n))return"*";if(!M(this,Qe))throw new Kn("Concrete remote origin not set");return M(this,Qe)==="null"&&M(this,Ze).includes("*")?"*":M(this,Qe)});Z(this,ln,()=>{M(this,ue)?.removeEventListener("message",M(this,Et)),M(this,ue)?.close(),_e(this,ue,void 0)});Z(this,un,({source:n,origin:e,ports:t,data:r})=>{var i,s,o;if(n===M(this,ze)&&(cc(r)&&((i=M(this,kt))==null||i.call(this,"Please upgrade the child window to the latest version of Penpal."),_e(this,et,!0),r=dc(r)),!!((s=M(this,wt))!=null&&s.call(this,r)))){if(!M(this,Bn).call(this,e)){(o=M(this,kt))==null||o.call(this,`Received a message from origin \`${e}\` which did not match allowed origins \`[${M(this,Ze).join(", ")}]\``);return}if(Hn(r)&&(M(this,ln).call(this),_e(this,Qe,e)),Hi(r)&&!M(this,et)){if(_e(this,ue,t[0]),!M(this,ue))throw new Kn("No port received on ACK2");M(this,ue).addEventListener("message",M(this,Et)),M(this,ue).start()}for(let a of M(this,He))a(r)}});Z(this,Et,({data:n})=>{var e;if((e=M(this,wt))!=null&&e.call(this,n))for(let t of M(this,He))t(n)});if(!n)throw new pe("INVALID_ARGUMENT","remoteWindow must be defined");_e(this,ze,n),_e(this,Ze,e?.length?e:[window.origin])}},ze=new WeakMap,Ze=new WeakMap,kt=new WeakMap,wt=new WeakMap,Qe=new WeakMap,He=new WeakMap,ue=new WeakMap,et=new WeakMap,Bn=new WeakMap,xt=new WeakMap,ln=new WeakMap,un=new WeakMap,Et=new WeakMap,Ea),Fa=_c;var Xn=({window:n,methods:e})=>{let t=new Fa({remoteWindow:n,allowedOrigins:["*"]});return Ta({methods:e,messenger:t})};var Oa=(n,e)=>Xn({window:n.contentWindow,methods:e});var Jn=class Jn{constructor(e,t){R(this,"penpalConn");R(this,"_methods");this.penpalConn=e,this._methods=t}get publicEndpoints(){let e={get:(t,r)=>async(...i)=>await this._methods.queryPublicEndpoint(r,i[0],i[1])};return new Proxy({},e)}destroy(){this.penpalConn.destroy()}};R(Jn,"createFromPenpalConnection",async e=>{let t=await e.promise;return new Jn(e,t)});var Yn=Jn;var $a={local:{baseUrl:"http://localhost:9101",apiBaseUrl:"http://localhost:9000"},sandbox:{baseUrl:"https://staging.paymentkit.com/customer",apiBaseUrl:"https://staging.paymentkit.com"},production:{baseUrl:"https://app.paymentkit.com/customer",apiBaseUrl:"https://app.paymentkit.com"}};function bc(){if(typeof window<"u"){let e=new URLSearchParams(window.location.search).get("api_base_url");if(e)return{baseUrl:window.location.origin,apiBaseUrl:e};let t=window.location.hostname;if(t.includes("loclx.io")){let r=t.replace(/cportal|playground/,"api");return{baseUrl:`https://${t}`,apiBaseUrl:`https://${r}`}}}return $a.local}function Da(n){if(n==="tunnel")return bc();let t=$a[n];if(!t)throw new Error(`Invalid environment: ${n}. Must be one of: local, tunnel, sandbox, production`);return t}var Na="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var qa=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=Na[t[n]&63];return e};var kc={local:"dev",tunnel:"dev",sandbox:"stg",production:"prod"},Yi="__paymentKitRequestId__";function ja(n){let e=kc[n]||"dev",t=qa(12);return`pk_${e}_${t}`}function tt(n){if(typeof window<"u"&&window[Yi])return window[Yi];let e=ja(n);return typeof window<"u"&&(window[Yi]=e),e}function Ji(n){return{headers:{"x-request-id":n}}}var Zi;function Ga(n){return{lang:n?.lang??Zi?.lang,message:n?.message,abortEarly:n?.abortEarly??Zi?.abortEarly,abortPipeEarly:n?.abortPipeEarly??Zi?.abortPipeEarly}}var wc;function xc(n){return wc?.get(n)}var Ec;function Pc(n){return Ec?.get(n)}var Sc;function Cc(n,e){return Sc?.get(n)?.get(e)}function Ic(n){let e=typeof n;return e==="string"?`"${n}"`:e==="number"||e==="bigint"||e==="boolean"?`${n}`:e==="object"||e==="function"?(n&&Object.getPrototypeOf(n)?.constructor?.name)??"null":e}function nt(n,e,t,r,i){let s=i&&"input"in i?i.input:t.value,o=i?.expected??n.expects??null,a=i?.received??Ic(s),l={kind:n.kind,type:n.type,input:s,expected:o,received:a,message:`Invalid ${e}: ${o?`Expected ${o} but r`:"R"}eceived ${a}`,requirement:n.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=n.kind==="schema",u=i?.message??n.message??Cc(n.reference,l.lang)??(c?Pc(l.lang):null)??r.message??xc(l.lang);u!==void 0&&(l.message=typeof u=="function"?u(l):u),c&&(t.typed=!1),t.issues?t.issues.push(l):t.issues=[l]}function Qi(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},Ga())}}}function La(n){if(n.path){let e="";for(let t of n.path)if(typeof t.key=="string"||typeof t.key=="number")e?e+=`.${t.key}`:e+=t.key;else return null;return e}return null}var Mc=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function es(n){return{kind:"validation",type:"email",reference:es,expects:null,async:!1,requirement:Mc,message:n,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&nt(this,"email",e,t),e}}}function ts(n,e){return{kind:"validation",type:"max_length",reference:ts,async:!1,expects:`<=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length>this.requirement&&nt(this,"length",t,r,{received:`${t.value.length}`}),t}}}function ns(n,e){return{kind:"validation",type:"min_length",reference:ns,async:!1,expects:`>=${n}`,requirement:n,message:e,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&nt(this,"length",t,r,{received:`${t.value.length}`}),t}}}function Pt(n){return{kind:"validation",type:"non_empty",reference:Pt,async:!1,expects:"!0",message:n,"~run"(e,t){return e.typed&&e.value.length===0&&nt(this,"length",e,t,{received:"0"}),e}}}function Rc(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}function Ac(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}function rs(n,e){return{kind:"schema",type:"object",reference:rs,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return Qi(this)},"~run"(t,r){let i=t.value;if(i&&typeof i=="object"){t.typed=!0,t.value={};for(let s in this.entries){let o=this.entries[s];if(s in i||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let a=s in i?i[s]:Ac(o),l=o["~run"]({value:a},r);if(l.issues){let c={type:"object",origin:"value",input:i,key:s,value:a};for(let u of l.issues)u.path?u.path.unshift(c):u.path=[c],t.issues?.push(u);if(t.issues||(t.issues=l.issues),r.abortEarly){t.typed=!1;break}}l.typed||(t.typed=!1),t.value[s]=l.value}else if(o.fallback!==void 0)t.value[s]=Rc(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(nt(this,"key",t,r,{input:void 0,expected:`"${s}"`,path:[{type:"object",origin:"key",input:i,key:s,value:i[s]}]}),r.abortEarly))break}}else nt(this,"type",t,r);return t}}}function rt(n){return{kind:"schema",type:"string",reference:rt,expects:"string",async:!1,message:n,get"~standard"(){return Qi(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:nt(this,"type",e,t),e}}}function St(...n){return{...n[0],pipe:n,get"~standard"(){return Qi(this)},"~run"(e,t){for(let r of n)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!t.abortEarly&&!t.abortPipeEarly)&&(e=r["~run"](e,t))}return e}}}function Va(n,e,t){let r=n["~run"]({value:e},Ga(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var is=async(n,e={})=>{let t=rs({customer_name:St(rt("required"),Pt("required"),ns(4,"invalid"),ts(40,"invalid")),customer_email:St(rt("required"),Pt("required"),es("invalid")),customer_country:St(rt("required"),Pt("required")),customer_zip_code:e.optionalZipCode?St(rt("required")):St(rt("required"),Pt("required"))}),r=Va(t,n);return r.issues?{isSuccess:!1,errors:r.issues.reduce((s,o)=>{let a=La(o);return s[a]=o.kind==="schema"?"required":o.message,s},{})}:{isSuccess:!0}};var Ua=n=>{let e=document.querySelector(n);if(!e)throw new Error(`Cannot find element with selector: ${n}`);return e},Ct=n=>n,Zn=(n,e,t)=>{let r=document.createElement("iframe"),s=new URLSearchParams(t).toString();return r.src=`${e}/embeds/v1/${n}${s?`?${s}`:""}`,Object.assign(r.style,{width:"100%",height:"100%",border:"none"}),r};function it(){return{ipAddress:void 0,browserInfo:{userAgent:navigator.userAgent,language:navigator.language,screenHeight:window.screen.height,screenWidth:window.screen.width,colorDepth:window.screen.colorDepth,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},processorFraudInfo:void 0}}var Fc=(n,e,t)=>{let r=Zn("tunnel-x",n,{checkout_token:t,api_base_url:e});document.body.appendChild(r);let i=Oa(r,{});return{unmount:()=>{i.destroy(),document.body.removeChild(r)},connection:i}},Oc=({environment:n,secureToken:e,paymentMethods:t,cardTokenizationMode:r,vgsVaultId:i,vgsEnvironment:s,__enableAnalyticsTestMode:o})=>{let{baseUrl:a,apiBaseUrl:l}=Da(n);console.log(`[PaymentKit] v${gs} initialized (env: ${n})`);let c=tt(n);console.log(`[PaymentKit] checkout_request_id: ${c}`),we.init(l,o),we.identify(e);let u=new an(e,c);u.trackPageReady();let{connection:p,unmount:h}=Fc(a,l,e),d={baseUrl:a,apiBaseUrl:l,secureToken:e,environment:n,tunnelXConnection:p,timingTracker:u,checkoutRequestId:c,cardTokenizationMode:r,vgsVaultId:i,vgsEnvironment:s,_sessionConfigReady:void 0};if(r===void 0){let b=`${l}/api/checkout-sessions/token/${e}`;console.log(`[PaymentKit] cardTokenizationMode not provided \u2014 auto-detecting from session API: ${b}`),d._sessionConfigReady=fetch(b).then(_=>_.ok?_.json():(console.warn(`[PaymentKit] Session config fetch failed with status ${_.status}`),null)).then(_=>{if(_&&typeof _=="object"&&typeof _.card_tokenization_mode=="string"){d.cardTokenizationMode=_.card_tokenization_mode||"direct",console.log(`[PaymentKit] Session config detected \u2014 cardTokenizationMode: ${d.cardTokenizationMode}`);let m=_.vgs_vault_id,S=_.vgs_environment;m&&/^tnt[a-z0-9]+$/.test(m)&&(S==="sandbox"||S==="live")?(d.vgsVaultId=m,d.vgsEnvironment=S,console.log(`[PaymentKit] VGS config valid \u2014 vaultId: ${m}, environment: ${S}`)):d.cardTokenizationMode==="vgs"&&(console.warn(`[PaymentKit] Invalid VGS config from session API (vaultId: ${m}, env: ${S}), falling back to direct mode`),d.cardTokenizationMode="direct")}else console.log("[PaymentKit] Session response missing card_tokenization_mode \u2014 defaulting to direct mode"),d.cardTokenizationMode="direct"}).catch(_=>{console.error("[PaymentKit] Session config fetch error \u2014 falling back to direct mode:",_),d.cardTokenizationMode="direct"})}else console.log(`[PaymentKit] cardTokenizationMode explicitly set: ${r}`);let g=t.map(b=>b(d)),f=g.reduce((b,{name:_,externalFuncs:m})=>(b[_]=m,b),{});return{submit:({paymentMethod:b,fields:_,options:m,onSuccess:S,onError:F})=>{let O=g.find(({name:C})=>C===b);if(!O){F({root:"payment_method_not_found"});return}O.internalFuncs.submitPayment(_,m).then(({data:C,errors:V})=>{V?F(V):S(C)}).catch(C=>{console.error("PaymentKit:submit:catch",C),C?.response?.data?F(C.response.data):C?.message?F({root:C.message}):F({root:"unknown_error"})})},cleanup:()=>{for(let b of g)b.internalFuncs.cleanup&&b.internalFuncs.cleanup();h()},...f}},za=Oc;var Ha=(n,e)=>Xn({window:n.contentWindow,methods:e});function ss(n){let{url:e,size:t,radius:r=6,onMessage:i}=n;return new Promise(s=>{let o=!1,a=document.createElement("div");a.id="pk-iframe-modal-overlay",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label","3D Secure Verification"),a.style.cssText=`
12
12
  position: fixed;
13
13
  top: 0;
14
14
  left: 0;
@@ -60,6 +60,6 @@
60
60
  transition: opacity 0.2s ease;
61
61
  position: relative;
62
62
  z-index: 1;
63
- `,u.onload=()=>{u.style.opacity="1"},u.onerror=()=>{o||(console.error("[IframeModal] Failed to load iframe"),p(),s({success:!1,error:"Failed to load verification page. Please try again."}))},l.appendChild(c),l.appendChild(u),a.appendChild(l),document.body.appendChild(a),requestAnimationFrame(()=>{a.style.background="rgba(0, 0, 0, 0.5)",l.style.opacity="1",l.style.transform="scale(1) translateY(0)"});let p=()=>{o||(o=!0,window.removeEventListener("message",f),window.removeEventListener("keydown",d),requestAnimationFrame(()=>{a.style.background="rgba(0, 0, 0, 0)",l.style.opacity="0",l.style.transform="scale(0.95) translateY(10px)",setTimeout(()=>{a.parentNode&&a.parentNode.removeChild(a)},250)}))},h=()=>{o||(console.log("[IframeModal] User cancelled"),p(),s({success:!1,error:"Verification cancelled"}))};c.onclick=h;let d=v=>{v.key==="Escape"&&h(),v.key==="Tab"&&(v.preventDefault(),document.activeElement===c?u.focus():c.focus())};window.addEventListener("keydown",d),c.focus();let f=v=>{let y=i(v);y.handled&&(p(),s(y.result))};window.addEventListener("message",f)})}var $c=n=>new Promise(e=>setTimeout(e,n)),Ka=()=>"Stripe"in window,Dc=async n=>{for(let t=0;t<10&&!Ka();t++)await $c(500);if(!Ka())throw new Error(`Stripe.js not loaded. Add this script tag to your HTML <head>:
64
- <script src="https://js.stripe.com/v3/"><\/script>`);return new window.Stripe(n)},Nc=async n=>{let{clientSecret:e,stripePk:t}=n,r=await Dc(t),{error:i}=await r.confirmCardPayment(e);return i?(console.error("[3DS:Stripe] Authentication failed:",i.message),{success:!1,error:i.message||"3DS authentication failed"}):{success:!0}},qc=async n=>ss({url:n.url,size:{width:605,height:550},onMessage:e=>{if(e.data.type!=="3ds_complete")return{handled:!1};let{isSuccess:t,error:r}=e.data;return t?{handled:!0,result:{success:!0,data:{}}}:(console.error("[3DS:Airwallex] Authentication failed:",r),{handled:!0,result:{success:!1,error:r||"3DS authentication failed"}})}}),Zr=async n=>{switch(n.type){case"stripe_3ds":return Nc(n);case"airwallex_3ds":return qc(n);default:return{success:!1,error:`Unknown next action type: ${n.type}`}}};var os="https://js.verygoodvault.com/vgs-collect/3.2.1/vgs-collect.js",ur=null;function Ba(){return ur?(console.log("[PaymentKit] VGS Collect CDN load already in progress \u2014 reusing promise"),ur):(ur=new Promise((n,e)=>{if(typeof window<"u"&&window.VGSCollect){console.log("[PaymentKit] VGS Collect JS already available on window"),n();return}console.log(`[PaymentKit] Loading VGS Collect JS from CDN: ${os}`);let t=document.createElement("script");t.src=os,t.async=!0,t.onload=()=>{console.log("[PaymentKit] VGS Collect JS loaded successfully from CDN"),n()},t.onerror=()=>{console.error(`[PaymentKit] Failed to load VGS Collect JS from CDN: ${os}`),ur=null,e(new Error("Failed to load VGS Collect JS"))},document.head.appendChild(t)}),ur)}function Wa(n,e){if(!window.VGSCollect)throw new Error("VGS Collect JS not loaded. Call loadVgsCollectScript() first.");return window.VGSCollect.create(n,e,()=>{})}function Xa(n,e,t,r,i){let s=document.querySelector(e.pan),o=s?getComputedStyle(s).padding:void 0,l={...t??{"font-size":"1rem",color:"#18181b","font-family":"ui-sans-serif, system-ui, sans-serif"},height:"100%","box-sizing":"border-box",...o&&o!=="0px"?{padding:o}:{}},c=n.cardNumberField(e.pan,{placeholder:i?.card_pan??"Card number",validations:["required","validCardNumber"],css:l}),u=n.field(e.exp,{type:"card-expiration-date",name:"exp-date",placeholder:i?.card_exp??"MM / YY",yearLength:2,serializers:[{name:"separate",options:{monthName:"month",yearName:"year"}}],validations:["required","validCardExpirationDate"],css:l}),p=n.cardCVCField(e.cvc,{placeholder:i?.card_cvc??"123",validations:["required","validCardSecurityCode"],css:l});for(let h of[e.pan,e.exp,e.cvc]){let d=document.querySelector(h);if(!d)continue;let f=y=>{let S=d;getComputedStyle(S).position==="static"&&(S.style.position="relative"),y.style.position="absolute",y.style.inset="0",y.style.width="100%",y.style.height="100%",y.style.border="none"},v=d.querySelector("iframe");v?f(v):new MutationObserver((S,w)=>{let x=d.querySelector("iframe");x&&(f(x),w.disconnect())}).observe(d,{childList:!0,subtree:!0})}if(r){let h=[[c,"card_pan"],[u,"card_exp"],[p,"card_cvc"]];for(let[d,f]of h){let v=r[f];v&&(d.on("focus",()=>v(!0)),d.on("blur",()=>v(!1)))}}}var jc=n=>{let e=n.trim(),t=e.indexOf(" ");return t===-1?{firstName:e}:{firstName:e.substring(0,t),lastName:e.substring(t+1).trim()||void 0}},Gc=n=>{let{firstName:e,lastName:t}=jc(n.customer_name);return{email:n.customer_email||void 0,firstName:e,lastName:t,billingAddress:n.customer_country||n.customer_zip_code?{country:n.customer_country||void 0,zipCode:n.customer_zip_code||void 0}:void 0}},Lc=n=>{let{baseUrl:e,apiBaseUrl:t,cardInputConnections:r,secureToken:i,timingTracker:s}=n;return(o,a)=>{let{style:l,onLoaded:c,onFocusChange:u,placeholder:p}=a;return{mount:d=>{let f,v,y=!1;n.vgsMountSelectors||(n.vgsMountSelectors={}),n.vgsMountSelectors[o]=d;let S=()=>{if(y)return;let w=n.cardTokenizationMode==="vgs";if(console.log(`[PaymentKit] card.doMount(${o}) \u2014 mode: ${n.cardTokenizationMode}, vgsVaultId: ${n.vgsVaultId??"unset"}, vgsEnvironment: ${n.vgsEnvironment??"unset"}`),w&&n.vgsVaultId&&n.vgsEnvironment){if(u&&(n.vgsFocusCallbacks||(n.vgsFocusCallbacks={}),n.vgsFocusCallbacks[o]=u),p&&(n.vgsPlaceholders||(n.vgsPlaceholders={}),n.vgsPlaceholders[o]=p),o==="card_pan"){let V=n.vgsVaultId,X=n.vgsEnvironment;console.log(`[PaymentKit] VGS mode active \u2014 loading VGS Collect CDN for vault ${V} (${X})...`);let ne=15e3,Q;Promise.race([Ba(),new Promise((Y,ie)=>{Q=setTimeout(()=>{console.warn(`[PaymentKit] VGS Collect CDN load timed out after ${ne/1e3}s`),ie(new Error("VGS Collect CDN load timed out"))},ne)})]).finally(()=>clearTimeout(Q)).then(()=>{if(y)return;console.log("[PaymentKit] VGS Collect CDN loaded \u2014 initializing form...");let Y=Wa(V,X);if(y){Y.unmount();return}n.vgsForm=Y;let ie=l?Object.fromEntries(Object.entries(l).map(([ve,Ee])=>[ve.replace(/([A-Z])/g,"-$1").toLowerCase(),Ee])):void 0,J=n.vgsMountSelectors?.card_exp,de=n.vgsMountSelectors?.card_cvc;if(!J||!de){console.error(`[PaymentKit] VGS mode requires all three card fields to be mounted. Missing: ${J?"":"card_exp"}${!J&&!de?", ":""}${de?"":"card_cvc"}`),c?.();return}console.log(`[PaymentKit] Creating VGS card fields \u2014 pan: ${d}, exp: ${J}, cvc: ${de}`),Xa(Y,{pan:d,exp:J,cvc:de},ie,n.vgsFocusCallbacks,n.vgsPlaceholders),console.log("[PaymentKit] VGS card fields created successfully"),s.trackInputReady(),c?.()}).catch(Y=>{console.error("[PaymentKit] Failed to load VGS Collect script. Card input will not be available:",Y),c?.()})}o!=="card_pan"&&c?.(),f=()=>{o==="card_pan"&&n.vgsForm&&(n.vgsForm.unmount(),n.vgsForm=void 0)};return}w&&console.warn(`[PaymentKit] VGS mode requested but config incomplete (vgsVaultId: ${n.vgsVaultId??"unset"}, vgsEnvironment: ${n.vgsEnvironment??"unset"}) \u2014 using direct mode`);let x=Ua(d),m=getComputedStyle(x),P=m.padding!=="0px"?m.padding:void 0,F={...l??{},height:"100%",boxSizing:"border-box",...P?{padding:P}:{}},O={checkout_token:i,api_base_url:t,style:JSON.stringify(F)},C=Jr(o.replace("_","-"),e,O);m.position==="static"&&(x.style.position="relative"),C.style.position="absolute",C.style.inset="0",v=()=>{r[o]?.destroy(),x.removeChild(C),n.cardInputConnections[o]=void 0},x.appendChild(C),C.onload=()=>{o==="card_pan"&&s.trackInputReady();let V=Ha(C,{onLoaded:c||(()=>{}),onFocusChange:u||(()=>{})});n.cardInputConnections[o]=V}};return n._sessionConfigReady?n._sessionConfigReady.then(S):S(),{unmount:()=>{y=!0,f?.(),v?.()}}}}}},Vc=n=>async t=>{n._sessionConfigReady&&await n._sessionConfigReady;let r=n.cardTokenizationMode==="vgs",{timingTracker:i,checkoutRequestId:s}=n;i.trackSubmit();let o=Ji(s),a=await Xr.createFromPenpalConnection(n.tunnelXConnection),l=await is(t);if(r){if(!l.isSuccess)return i.trackFail(null,"validation_error","Form validation failed"),{errors:l.errors}}else{let d=await Kc(n);if(!(d.isSuccess&&l.isSuccess))return i.trackFail(null,"validation_error","Form validation failed"),{errors:{...d.errors,...l.errors}}}if(!n.cardSetupIntentId){let d=await a.publicEndpoints.createCardSetupIntent({checkoutToken:n.secureToken});n.cardSetupIntentId=d.cardSetupIntentId}if(r){console.log("[PaymentKit] Submitting card via VGS CMP...");let d=await zc(n,a);if(!d.isSuccess)return i.trackFail(null,"card_submit_error","VGS card submission failed"),{errors:d.errors}}else{let d=await Hc(n);if(!d.isSuccess)return i.trackFail(null,"card_submit_error","Card submission failed"),{errors:d.errors}}let c=await a.publicEndpoints.getCardSetupIntent({cardSetupIntentId:n.cardSetupIntentId,checkoutToken:n.secureToken});if(!c.isCardAllSet){let d={};return c.isCardPanSet||(d.card_pan="required"),c.isCardExpSet||(d.card_exp="required"),c.isCardCvcSet||(d.card_cvc="required"),i.trackFail(null,"card_setup_incomplete","Card details incomplete"),{errors:d}}console.log("Card setup intent is set \u2705",c),console.log("Fields",t);let u=await a.publicEndpoints.cardCheckout({checkoutToken:n.secureToken,publicCardCheckoutRequest:{cardSetupIntentId:n.cardSetupIntentId,customerInfo:Gc(t),fraudMetadata:it()}},o);console.log("Card checkout result:",u);let p=5,h=0;for(;u.nextAction&&h<p;){h++,console.log(`Handling user action ${h}/${p}...`);let d=await Zr(u.nextAction);console.log("User action completed, verifying checkout...");let f=await a.publicEndpoints.cardCheckoutVerify({checkoutToken:n.secureToken},o);if(f.nextAction){d.success?console.log("Another user action required, continuing loop..."):console.log("3DS failed but cascade triggered new action, continuing loop..."),u=f;continue}return d.success?(console.log("Card checkout verified \u2705",f),i.trackSuccess(f.checkoutAttemptId||"unknown"),{data:f}):(console.log("3DS authentication failed, checkout concluded:",f),i.trackFail(f.checkoutAttemptId||null,f.errorCode||"3ds_failed",f.errorMessageForCustomer||d.error),{errors:{root:f.errorMessageForCustomer||d.error,checkout_response:f}})}return h>=p?(console.error("Max user actions exceeded"),i.trackFail(null,"max_actions_exceeded","Too many authentication attempts"),{errors:{root:"Too many authentication attempts. Please try again."}}):u.state==="payment_failed"||u.state==="checkout_failed"?(console.log("Card checkout failed:",u),i.trackFail(u.checkoutAttemptId||null,u.errorCode||"payment_failed",u.errorMessageForCustomer||"Payment failed"),{errors:{root:u.errorMessageForCustomer||"Payment failed",checkout_response:u}}):(console.log("Card checkout completed \u2705",u),i.trackSuccess(u.checkoutAttemptId||"unknown"),{data:u})},Uc=async(n,e)=>{let t=await fetch(`${n}/api/card-setup-intents/${e}/collect-token`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`Failed to get collect token: ${t.status}`);return(await t.json()).access_token},zc=async(n,e)=>{let{vgsForm:t,cardSetupIntentId:r,secureToken:i,apiBaseUrl:s}=n,o={};if(!t)return o.card_pan="required",{errors:o,isSuccess:!1};if(!r)return o.root="Card setup intent not created",{errors:o,isSuccess:!1};try{let a=await Uc(s,i),l=3e4,c,u=await Promise.race([new Promise((S,w)=>{t.createCard({auth:a,data:{cardholder:{}}},(x,m)=>S(m),x=>w(x))}),new Promise((S,w)=>{c=setTimeout(()=>w(new Error("VGS createCard timed out")),l)})]).finally(()=>clearTimeout(c)),{pan_alias:p,cvc_alias:h,exp_month:d,exp_year:f}=u.data.attributes,v=f<100?2e3+f:f,y=`${String(d).padStart(2,"0")}/${v}`;return await e.publicEndpoints.updateCardSetupIntent({checkoutToken:i,cardSetupIntentId:r,updateCardSetupIntentReq:{cardPan:p,cardExp:y,cardCvc:h,fraudMetadata:it()}}),{errors:{},isSuccess:!0}}catch(a){return console.error("[PaymentKit] VGS CMP createCard failed:",a),o.root="Card submission failed",{errors:o,isSuccess:!1}}},Hc=async n=>{let e={},{cardSetupIntentId:t,cardInputConnections:r}=n,i=Object.entries(r).map(async([s,o])=>{let a=s,c=await(await o.promise).onSubmit(t||"");"error"in c&&(e[a]=c.error)});return await Promise.allSettled(i),{errors:e,isSuccess:Object.keys(e).length===0}},Kc=async n=>{let e={},{cardInputConnections:t}=n,r=Object.entries(t).map(async([i,s])=>{let o=i;if(!s){e[o]="penpal_not_connected";return}let l=await(await s.promise).onValidate();l&&(e[o]=l)});return await Promise.allSettled(r),{errors:e,isSuccess:Object.keys(e).length===0}},Bc=Ct(n=>{let e=Object.create(n);return e.cardInputConnections={},{name:"card",externalFuncs:{createElement:Lc(e)},internalFuncs:{submitPayment:Vc(e),cleanup:()=>{e.vgsForm&&(e.vgsForm.unmount(),e.vgsForm=void 0);for(let t of Object.values(e.cardInputConnections))t?.destroy();e.cardInputConnections={}}}}}),Ya=Bc;var Qr=class{constructor(e){R(this,"client",null);R(this,"config",null);R(this,"mockScenario");this.mockScenario=e??"none"}initialize(e){return this.mockScenario!=="none"?(console.log("[MockGooglePay:Airwallex] initialize called (mock mode)"),this.config=e,!0):window.google?.payments?.api?.PaymentsClient?(this.config=e,this.client=new window.google.payments.api.PaymentsClient({environment:e.isProduction?"PRODUCTION":"TEST"}),this.client!==null):(console.error("[GooglePay:Airwallex] Google Pay API not loaded"),!1)}getAllowedPaymentMethods(e){if(!this.config)throw new Error("Config not set. Call initialize() first.");let t={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["VISA","MASTERCARD","AMEX","DISCOVER","JCB"]}};return e&&(t.tokenizationSpecification={type:"PAYMENT_GATEWAY",parameters:{gateway:"airwallex",gatewayMerchantId:this.config.gatewayMerchantId}}),[t]}async canMakePayment(){if(this.mockScenario!=="none")return console.log("[MockGooglePay:Airwallex] canMakePayment: true (mock mode)"),!0;if(!this.client)return!1;try{let e={apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:this.getAllowedPaymentMethods(!1)};return(await this.client.isReadyToPay(e)).result}catch(e){return console.error("[GooglePay:Airwallex] canMakePayment error:",e),!1}}async showPaymentSheet(){if(this.mockScenario==="success")return console.log("[MockGooglePay:Airwallex] showPaymentSheet: returning mock success token"),{success:!0,token:{protocolVersion:"ECv2",signature:"MOCK_SIGNATURE",intermediateSigningKey:{signedKey:"MOCK_SIGNED_KEY",signatures:["MOCK_SIGNATURE"]},signedMessage:"MOCK_SIGNED_MESSAGE"}};if(this.mockScenario==="cancelled")return console.log("[MockGooglePay:Airwallex] showPaymentSheet: returning mock cancelled"),{success:!1,cancelled:!0};if(!this.client||!this.config)return{success:!1,error:"Google Pay not initialized"};try{let e=this.config.amountDisplay,t={apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:this.getAllowedPaymentMethods(!0),merchantInfo:{merchantName:this.config.merchantId,...this.config.isProduction&&this.config.googleMerchantId?{merchantId:this.config.googleMerchantId}:{}},transactionInfo:{totalPriceStatus:"FINAL",totalPrice:e,currencyCode:this.config.currency.toUpperCase(),countryCode:this.config.country.toUpperCase()}},i=(await this.client.loadPaymentData(t)).paymentMethodData.tokenizationData.token;return{success:!0,token:JSON.parse(i)}}catch(e){return e instanceof Error&&e.message?.includes("CANCELED")?{success:!1,cancelled:!0}:e.statusCode==="CANCELED"?{success:!1,cancelled:!0}:(console.error("[GooglePay:Airwallex] Payment sheet error:",e),{success:!1,error:e instanceof Error?e.message:"Unknown error"})}}};var en=class{constructor(e){R(this,"stripe",null);R(this,"paymentRequest",null);R(this,"mockScenario");this.mockScenario=e??"none"}initialize(e){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] initialize called"),!window.Stripe)return console.log("[GooglePay] Stripe.js not loaded"),!1;this.stripe=window.Stripe(e);let t=this.stripe!==null;return console.log("[GooglePay] initialize result:",t),t}case"success":case"cancelled":return console.log("[MockGooglePay] initialize called"),console.log("[MockGooglePay] initialize result:",!0),!0}}createPaymentRequest(e){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] createPaymentRequest called",e),!this.stripe)throw new Error("Stripe not initialized");this.paymentRequest=this.stripe.paymentRequest(e),console.log("[GooglePay] paymentRequest created");return}case"success":case"cancelled":{console.log("[MockGooglePay] createPaymentRequest called",e);return}}}async canMakePayment(){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] canMakePayment called"),!this.paymentRequest)return console.log("[GooglePay] canMakePayment: no paymentRequest"),!1;let e=await this.paymentRequest.canMakePayment(),t=e?.googlePay??!1;return console.log("[GooglePay] canMakePayment result:",{result:e,isAvailable:t}),t}case"success":case"cancelled":return console.log("[MockGooglePay] canMakePayment called"),console.log("[MockGooglePay] canMakePayment result:",{result:{googlePay:!0},isAvailable:!0}),!0}}async showPaymentSheet(){switch(this.mockScenario){case"none":return console.log("[GooglePay] showPaymentSheet called"),this.paymentRequest?new Promise(e=>{this.paymentRequest.on("paymentmethod",t=>{console.log("[GooglePay] showPaymentSheet: paymentmethod event",{paymentMethodId:t.paymentMethod.id}),e({success:!0,paymentMethodId:t.paymentMethod.id,complete:r=>{console.log("[GooglePay] complete called:",r),t.complete(r)}})}),this.paymentRequest.on("cancel",()=>{console.log("[GooglePay] showPaymentSheet: cancelled by user"),e({success:!1,cancelled:!0})}),console.log("[GooglePay] showing payment sheet..."),this.paymentRequest.show()}):(console.log("[GooglePay] showPaymentSheet: no paymentRequest"),{success:!1,error:"Payment request not created"});case"success":return console.log("[MockGooglePay] showPaymentSheet: success"),await new Promise(e=>setTimeout(e,500)),{success:!0,paymentMethodId:"pm_mock_123456789",complete:e=>console.log(`[MockGooglePay] complete: ${e}`)};case"cancelled":return console.log("[MockGooglePay] showPaymentSheet: cancelled"),await new Promise(e=>setTimeout(e,500)),{success:!1,cancelled:!0}}}async confirmCardSetup(e,t){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] confirmCardSetup called",{clientSecret:`${e.slice(0,20)}...`,paymentMethodId:t}),!this.stripe)return console.log("[GooglePay] confirmCardSetup: Stripe not initialized"),{success:!1,error:"Stripe not initialized"};let{error:r}=await this.stripe.confirmCardSetup(e,{payment_method:t});return r?(console.log("[GooglePay] confirmCardSetup error:",r),{success:!1,error:r.message??"Card setup failed"}):(console.log("[GooglePay] confirmCardSetup success"),{success:!0})}case"success":return console.log("[MockGooglePay] confirmCardSetup called",{clientSecret:e,paymentMethodId:t}),{success:!0};case"cancelled":throw new Error("confirmCardSetup should not be called when scenario is Cancelled")}}};async function ls(n,e,t){let r=new Headers(e.headers);t&&r.set("x-request-id",t);let i=await fetch(n,{...e,headers:r});if(!i.ok){let s=`Request failed (${i.status})`;try{s=(await i.json()).detail||s}catch{s=i.statusText||s}return{error:s}}return{data:await i.json()}}function Wc(n){return n?.processorId?null:{processor_id:"Processor ID is required"}}function Xc(n){return n&&n!=="none"?n:void 0}async function Yc(n,e,t,r,i){return ls(`${n}/api/checkout/${e}/google-pay/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processor_id:t.processorId,customer_info:t.customerInfo,fraud_metadata:it(),mock_scenario:r})},i)}function Jc(n,e,t){let r=new en(t);if(!r.initialize(n))return{error:'Stripe.js not loaded. Add <script src="https://js.stripe.com/v3/"><\/script> to your page.'};let i={country:e.country,currency:e.currency.toLowerCase(),total:{label:"Total",amount:e.amount},requestPayerName:!0,requestPayerEmail:!0};return r.createPaymentRequest(i),{adapter:r}}async function Zc(n,e){if(!n.stripe_pk||!n.client_secret)return{success:!1,error:"Stripe credentials not provided"};let{adapter:t,error:r}=Jc(n.stripe_pk,n,e);if(!t)return{success:!1,error:r};if(!await t.canMakePayment())return{success:!1,error:"Google Pay not available on this device"};let s=await t.showPaymentSheet();if(!s.success)return"cancelled"in s&&s.cancelled?{success:!1,error:"Google Pay cancelled by user"}:{success:!1,error:"error"in s?s.error:"Unknown error"};let o=await t.confirmCardSetup(n.client_secret,s.paymentMethodId);return o.success?(s.complete("success"),{success:!0}):(s.complete("fail"),{success:!1,error:"error"in o?o.error:"Card setup failed"})}function Qc(n,e){if(!n.merchant_name||!n.airwallex_account_id)return{error:"Airwallex Google Pay credentials not provided"};let t="none";e==="success"?t="success":e==="cancelled"&&(t="cancelled");let r=new Qr(t),i={merchantId:n.merchant_name,gatewayMerchantId:n.airwallex_account_id,amountDisplay:n.amount_display,currency:n.currency,country:n.country,isProduction:n.is_sandbox===!1,googleMerchantId:n.google_merchant_id};return r.initialize(i)?{adapter:r}:{error:'Google Pay API not loaded. Add <script src="https://pay.google.com/gp/p/js/pay.js"><\/script> to your page.'}}async function ep(n,e){let{adapter:t,error:r}=Qc(n,e);if(!t)return{success:!1,error:r};if(!await t.canMakePayment())return{success:!1,error:"Google Pay not available on this device"};let s=await t.showPaymentSheet();return s.success?{success:!0,token:s.token}:"cancelled"in s&&s.cancelled?{success:!1,error:"Google Pay cancelled by user"}:{success:!1,error:"error"in s?s.error:"Unknown error"}}async function Za(n,e,t,r,i){let s={mock_scenario:r};t&&(s.google_pay_token=t);let o=await ls(`${n}/api/checkout/${e}/google-pay/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},i);return o.error||!o.data?{charge_status:"fail",error_message:o.error||"Failed to confirm payment",checkout_attempt_id:""}:o.data}async function tp(n,e,t){let r=await ls(`${n}/api/checkout/${e}/google-pay/verify`,{method:"POST",headers:{"Content-Type":"application/json"}},t);return r.error||!r.data?{charge_status:"fail",error_message:r.error||"Failed to verify payment",checkout_attempt_id:""}:r.data}function as(n,e){return n.charge_status==="success"?{data:{id:n.transaction_id,checkoutAttemptId:n.checkout_attempt_id,checkoutSessionId:e,state:"checkout_succeeded"}}:{errors:{google_pay:n.error_message||"Payment failed"}}}async function rp(n,e,t,r){let i=await Za(n,e,void 0,t,r);return as(i,e)}var Ja=5;async function np(n,e,t,r,i){let s=0,o=await Za(n,e,t,r,i);for(;o.charge_status==="pending"&&o.next_action&&s<Ja;){s++;let a=await Zr(o.next_action),l=await tp(n,e,i);if(l.charge_status==="pending"&&l.next_action){a.success||console.log("[GooglePay:Airwallex] 3DS failed but retry available, continuing loop..."),o=l;continue}return a.success?as(l,e):{errors:{google_pay:l.error_message||a.error||"3DS authentication failed"}}}return s>=Ja?{errors:{google_pay:"Too many authentication attempts. Please try again."}}:as(o,e)}var ip=n=>async(t,r)=>{let{apiBaseUrl:i,secureToken:s,environment:o}=n,a=r,l=Wc(a);if(l)return{errors:l};try{let c=Xc(a.mockScenario),u=tt(o);console.log(`[GooglePay] Using checkout_request_id: ${u}`);let p=await Yc(i,s,a,c,u);if(p.error||!p.data)return{errors:{google_pay:p.error||"Failed to start Google Pay"}};let h=p.data;if(h.processor==="stripe"){let d=await Zc(h,a.mockScenario);return d.success?await rp(i,s,c,u):{errors:{google_pay:d.error}}}if(h.processor==="airwallex"){let d=await ep(h,a.mockScenario);return d.success?d.token?await np(i,s,d.token,c,u):{errors:{google_pay:"Google Pay token not received"}}:{errors:{google_pay:d.error}}}return{errors:{google_pay:`Unsupported processor: ${h.processor}`}}}catch(c){return{errors:{google_pay:`Google Pay error: ${c}`}}}},sp=Ct(n=>({name:"google_pay",externalFuncs:{},internalFuncs:{submitPayment:ip(n),cleanup:()=>{}}}));var Qa=sp;var op=n=>async(t,r)=>{let{apiBaseUrl:i,secureToken:s,environment:o}=n,a=r;if(!a?.processorId)return{errors:{processor_id:"Processor ID is required"}};if(!a?.customerInfo?.first_name||!a?.customerInfo?.last_name)return{errors:{customer_name:"Customer first and last name are required"}};try{let l=tt(o);console.log(`[PayPal] Using checkout_request_id: ${l}`);let c=await fetch(`${i}/api/checkout/${s}/paypal/start`,{method:"POST",headers:{"Content-Type":"application/json","x-request-id":l},body:JSON.stringify({processor_id:a.processorId,customer_info:a.customerInfo,fraud_metadata:it()})});if(!c.ok){let f=`Failed to start PayPal checkout (${c.status})`;try{f=(await c.json()).detail||f}catch{f=c.statusText||f}return{errors:{paypal:f}}}let{approval_url:u,popup_token:p,checkout_attempt_id:h}=await c.json(),d=window.open(u,"PayPal","width=600,height=700");return d?(n.popup=d,new Promise(f=>{let v=setInterval(async()=>{try{let y=await fetch(`${i}/api/checkout/${s}/popup/status?popup_token=${p}`);if(!y.ok){clearInterval(v),d.close(),f({errors:{paypal:"Failed to check PayPal status"}});return}let S=await y.json();if(S.completed){if(clearInterval(v),d.close(),S.status==="success"){let w=S.result||{id:h,checkoutAttemptId:h,checkoutSessionId:s,state:"checkout_succeeded"};f({data:w})}else f({errors:{paypal:S.error||`PayPal checkout ${S.status}`}});return}if(d.closed){clearInterval(v),f({errors:{paypal:"PayPal popup closed by user"}});return}}catch(y){clearInterval(v),d.close(),f({errors:{paypal:`Polling error: ${y}`}})}},2e3);n.pollInterval=v})):{errors:{paypal:"Failed to open PayPal popup. Please allow popups for this site."}}}catch(l){return{errors:{paypal:`PayPal checkout error: ${l}`}}}},ap=Ct(n=>{let e={...n};return{name:"paypal",externalFuncs:{},internalFuncs:{submitPayment:op(e),cleanup:()=>{e.pollInterval&&clearInterval(e.pollInterval),e.popup&&!e.popup.closed&&e.popup.close()}}}}),el=ap;var lp=za,up={card:Ya,googlePay:Qa,paypal:el};return pl(cp);})();
63
+ `,u.onload=()=>{u.style.opacity="1"},u.onerror=()=>{o||(console.error("[IframeModal] Failed to load iframe"),p(),s({success:!1,error:"Failed to load verification page. Please try again."}))},l.appendChild(c),l.appendChild(u),a.appendChild(l),document.body.appendChild(a),requestAnimationFrame(()=>{a.style.background="rgba(0, 0, 0, 0.5)",l.style.opacity="1",l.style.transform="scale(1) translateY(0)"});let p=()=>{o||(o=!0,window.removeEventListener("message",g),window.removeEventListener("keydown",d),requestAnimationFrame(()=>{a.style.background="rgba(0, 0, 0, 0)",l.style.opacity="0",l.style.transform="scale(0.95) translateY(10px)",setTimeout(()=>{a.parentNode&&a.parentNode.removeChild(a)},250)}))},h=()=>{o||(console.log("[IframeModal] User cancelled"),p(),s({success:!1,error:"Verification cancelled"}))};c.onclick=h;let d=f=>{f.key==="Escape"&&h(),f.key==="Tab"&&(f.preventDefault(),document.activeElement===c?u.focus():c.focus())};window.addEventListener("keydown",d),c.focus();let g=f=>{let y=i(f);y.handled&&(p(),s(y.result))};window.addEventListener("message",g)})}var $c=n=>new Promise(e=>setTimeout(e,n)),Ka=()=>"Stripe"in window,Dc=async n=>{for(let t=0;t<10&&!Ka();t++)await $c(500);if(!Ka())throw new Error(`Stripe.js not loaded. Add this script tag to your HTML <head>:
64
+ <script src="https://js.stripe.com/v3/"><\/script>`);return new window.Stripe(n)},Nc=async n=>{let{clientSecret:e,stripePk:t}=n,r=await Dc(t),{error:i}=await r.confirmCardPayment(e);return i?(console.error("[3DS:Stripe] Authentication failed:",i.message),{success:!1,error:i.message||"3DS authentication failed"}):{success:!0}},qc=async n=>ss({url:n.url,size:{width:605,height:550},onMessage:e=>{if(e.data.type!=="3ds_complete")return{handled:!1};let{isSuccess:t,error:r}=e.data;return t?{handled:!0,result:{success:!0,data:{}}}:(console.error("[3DS:Airwallex] Authentication failed:",r),{handled:!0,result:{success:!1,error:r||"3DS authentication failed"}})}}),Qn=async n=>{switch(n.type){case"stripe_3ds":return Nc(n);case"airwallex_3ds":return qc(n);default:return{success:!1,error:`Unknown next action type: ${n.type}`}}};var os="https://js.verygoodvault.com/vgs-collect/3.2.1/vgs-collect.js",cn=null;function Ba(){return cn?(console.log("[PaymentKit] VGS Collect CDN load already in progress \u2014 reusing promise"),cn):(cn=new Promise((n,e)=>{if(typeof window<"u"&&window.VGSCollect){console.log("[PaymentKit] VGS Collect JS already available on window"),n();return}console.log(`[PaymentKit] Loading VGS Collect JS from CDN: ${os}`);let t=document.createElement("script");t.src=os,t.async=!0,t.onload=()=>{console.log("[PaymentKit] VGS Collect JS loaded successfully from CDN"),n()},t.onerror=()=>{console.error(`[PaymentKit] Failed to load VGS Collect JS from CDN: ${os}`),cn=null,e(new Error("Failed to load VGS Collect JS"))},document.head.appendChild(t)}),cn)}function Wa(n,e){if(!window.VGSCollect)throw new Error("VGS Collect JS not loaded. Call loadVgsCollectScript() first.");return window.VGSCollect.create(n,e,()=>{})}function Xa(n,e,t,r,i){let s=document.querySelector(e.pan),o=s?getComputedStyle(s).padding:void 0,l={...t??{"font-size":"1rem",color:"#18181b","font-family":"ui-sans-serif, system-ui, sans-serif"},height:"100%","box-sizing":"border-box",...o&&o!=="0px"?{padding:o}:{}};for(let g of[e.pan,e.exp,e.cvc]){let f=document.querySelector(g);if(!f)continue;let y=f.querySelectorAll("iframe");for(let P of y)P.remove()}let c=n.cardNumberField(e.pan,{placeholder:i?.card_pan??"Card number",validations:["required","validCardNumber"],css:l}),u=n.field(e.exp,{type:"card-expiration-date",name:"exp-date",placeholder:i?.card_exp??"MM / YY",yearLength:2,serializers:[{name:"separate",options:{monthName:"month",yearName:"year"}}],validations:["required","validCardExpirationDate"],css:l}),p=n.cardCVCField(e.cvc,{placeholder:i?.card_cvc??"123",validations:["required","validCardSecurityCode"],css:l}),h=[],d=[];for(let g of[e.pan,e.exp,e.cvc]){let f=document.querySelector(g);if(!f)continue;d.push(f);let y=_=>{let m=f;getComputedStyle(m).position==="static"&&(m.style.position="relative"),_.style.position="absolute",_.style.inset="0",_.style.width="100%",_.style.height="100%",_.style.border="none"},P=new MutationObserver(()=>{let _=f.querySelector("iframe");_&&_.style.position!=="absolute"&&y(_)});P.observe(f,{childList:!0,subtree:!0}),h.push(P);let b=f.querySelector("iframe");b&&b.style.position!=="absolute"&&y(b)}if(r){let g=[[c,"card_pan"],[u,"card_exp"],[p,"card_cvc"]];for(let[f,y]of g){let P=r[y];P&&(f.on("focus",()=>P(!0)),f.on("blur",()=>P(!1)))}}return()=>{for(let g of h)g.disconnect();for(let g of d){let f=g.querySelectorAll("iframe");for(let y of f)y.remove()}}}var jc=n=>{let e=n.trim(),t=e.indexOf(" ");return t===-1?{firstName:e}:{firstName:e.substring(0,t),lastName:e.substring(t+1).trim()||void 0}},Gc=n=>{let{firstName:e,lastName:t}=jc(n.customer_name),r=n.customer_country||n.customer_zip_code||n.customer_address_line1||n.customer_address_line2||n.customer_city||n.customer_state,i=n.shipping_address_line1||n.shipping_address_line2||n.shipping_city||n.shipping_state||n.shipping_zip_code||n.shipping_country,s;if(n.customer_tax_ids)try{s=JSON.parse(n.customer_tax_ids)}catch{s=void 0}return{email:n.customer_email||void 0,firstName:e,lastName:t,businessName:n.customer_business_name||void 0,taxIds:s?.length?s:void 0,billingAddress:r?{country:n.customer_country||void 0,zipCode:n.customer_zip_code||void 0,line1:n.customer_address_line1||void 0,line2:n.customer_address_line2||void 0,city:n.customer_city||void 0,state:n.customer_state||void 0}:void 0,shippingAddress:i?{line1:n.shipping_address_line1||void 0,line2:n.shipping_address_line2||void 0,city:n.shipping_city||void 0,state:n.shipping_state||void 0,zipCode:n.shipping_zip_code||void 0,country:n.shipping_country||void 0}:void 0}},Lc=n=>{let{baseUrl:e,apiBaseUrl:t,cardInputConnections:r,secureToken:i,timingTracker:s}=n;return(o,a)=>{let{style:l,onLoaded:c,onFocusChange:u,placeholder:p}=a;return{mount:d=>{let g,f,y=!1;n.vgsMountSelectors||(n.vgsMountSelectors={}),n.vgsMountSelectors[o]=d;let P=()=>{if(y)return;let b=n.cardTokenizationMode==="vgs";if(console.log(`[PaymentKit] card.doMount(${o}) \u2014 mode: ${n.cardTokenizationMode}, vgsVaultId: ${n.vgsVaultId??"unset"}, vgsEnvironment: ${n.vgsEnvironment??"unset"}`),b&&n.vgsVaultId&&n.vgsEnvironment){if(u&&(n.vgsFocusCallbacks||(n.vgsFocusCallbacks={}),n.vgsFocusCallbacks[o]=u),p&&(n.vgsPlaceholders||(n.vgsPlaceholders={}),n.vgsPlaceholders[o]=p),o==="card_pan"){let V=n.vgsVaultId,X=n.vgsEnvironment;console.log(`[PaymentKit] VGS mode active \u2014 loading VGS Collect CDN for vault ${V} (${X})...`);let re=15e3,Q;Promise.race([Ba(),new Promise((Y,ie)=>{Q=setTimeout(()=>{console.warn(`[PaymentKit] VGS Collect CDN load timed out after ${re/1e3}s`),ie(new Error("VGS Collect CDN load timed out"))},re)})]).finally(()=>clearTimeout(Q)).then(()=>{if(y)return;console.log("[PaymentKit] VGS Collect CDN loaded \u2014 initializing form...");let Y=Wa(V,X);if(y){Y.unmount();return}n.vgsForm=Y;let ie=l?Object.fromEntries(Object.entries(l).map(([ve,xe])=>[ve.replace(/([A-Z])/g,"-$1").toLowerCase(),xe])):void 0,J=n.vgsMountSelectors?.card_exp,de=n.vgsMountSelectors?.card_cvc;if(!J||!de){console.error(`[PaymentKit] VGS mode requires all three card fields to be mounted. Missing: ${J?"":"card_exp"}${!J&&!de?", ":""}${de?"":"card_cvc"}`),c?.();return}console.log(`[PaymentKit] Creating VGS card fields \u2014 pan: ${d}, exp: ${J}, cvc: ${de}`),n.vgsFieldsCleanup=Xa(Y,{pan:d,exp:J,cvc:de},ie,n.vgsFocusCallbacks,n.vgsPlaceholders),console.log("[PaymentKit] VGS card fields created successfully"),s.trackInputReady(),c?.()}).catch(Y=>{console.error("[PaymentKit] Failed to load VGS Collect script. Card input will not be available:",Y),c?.()})}o!=="card_pan"&&c?.(),g=()=>{o==="card_pan"&&n.vgsForm&&(n.vgsFieldsCleanup?.(),n.vgsFieldsCleanup=void 0,n.vgsForm.unmount(),n.vgsForm=void 0)};return}b&&console.warn(`[PaymentKit] VGS mode requested but config incomplete (vgsVaultId: ${n.vgsVaultId??"unset"}, vgsEnvironment: ${n.vgsEnvironment??"unset"}) \u2014 using direct mode`);let _=Ua(d),m=getComputedStyle(_),S=m.padding!=="0px"?m.padding:void 0,F={...l??{},height:"100%",boxSizing:"border-box",...S?{padding:S}:{}},O={checkout_token:i,api_base_url:t,style:JSON.stringify(F)},C=Zn(o.replace("_","-"),e,O);m.position==="static"&&(_.style.position="relative"),C.style.position="absolute",C.style.inset="0",f=()=>{r[o]?.destroy(),_.removeChild(C),n.cardInputConnections[o]=void 0},_.appendChild(C),C.onload=()=>{o==="card_pan"&&s.trackInputReady();let V=Ha(C,{onLoaded:c||(()=>{}),onFocusChange:u||(()=>{})});n.cardInputConnections[o]=V}};return n._sessionConfigReady?n._sessionConfigReady.then(P):P(),{unmount:()=>{y=!0,g?.(),f?.()}}}}}},Vc=n=>async(t,r)=>{n._sessionConfigReady&&await n._sessionConfigReady;let i=n.cardTokenizationMode==="vgs",{timingTracker:s,checkoutRequestId:o}=n;s.trackSubmit();let a=Ji(o),l=await Yn.createFromPenpalConnection(n.tunnelXConnection),u=r?.skipCustomerValidation===!0?{isSuccess:!0}:await is(t);if(i){if(!u.isSuccess)return s.trackFail(null,"validation_error","Form validation failed"),{errors:u.errors}}else{let f=await Kc(n);if(!(f.isSuccess&&u.isSuccess))return s.trackFail(null,"validation_error","Form validation failed"),{errors:{...f.errors,...u.errors}}}if(!n.cardSetupIntentId){let f=await l.publicEndpoints.createCardSetupIntent({checkoutToken:n.secureToken});n.cardSetupIntentId=f.cardSetupIntentId}if(i){console.log("[PaymentKit] Submitting card via VGS CMP...");let f=await zc(n,l);if(!f.isSuccess)return s.trackFail(null,"card_submit_error","VGS card submission failed"),{errors:f.errors}}else{let f=await Hc(n);if(!f.isSuccess)return s.trackFail(null,"card_submit_error","Card submission failed"),{errors:f.errors}}let p=await l.publicEndpoints.getCardSetupIntent({cardSetupIntentId:n.cardSetupIntentId,checkoutToken:n.secureToken});if(!p.isCardAllSet){let f={};return p.isCardPanSet||(f.card_pan="required"),p.isCardExpSet||(f.card_exp="required"),p.isCardCvcSet||(f.card_cvc="required"),s.trackFail(null,"card_setup_incomplete","Card details incomplete"),{errors:f}}console.log("Card setup intent is set \u2705",p),console.log("Fields",t);let h=await l.publicEndpoints.cardCheckout({checkoutToken:n.secureToken,publicCardCheckoutRequest:{cardSetupIntentId:n.cardSetupIntentId,customerInfo:Gc(t),fraudMetadata:it()}},a);console.log("Card checkout result:",h);let d=5,g=0;for(;h.nextAction&&g<d;){g++,console.log(`Handling user action ${g}/${d}...`);let f=await Qn(h.nextAction);console.log("User action completed, verifying checkout...");let y=await l.publicEndpoints.cardCheckoutVerify({checkoutToken:n.secureToken},a);if(y.nextAction){f.success?console.log("Another user action required, continuing loop..."):console.log("3DS failed but cascade triggered new action, continuing loop..."),h=y;continue}return f.success?(console.log("Card checkout verified \u2705",y),s.trackSuccess(y.checkoutAttemptId||"unknown"),{data:y}):(console.log("3DS authentication failed, checkout concluded:",y),s.trackFail(y.checkoutAttemptId||null,y.errorCode||"3ds_failed",y.errorMessageForCustomer||f.error),{errors:{root:y.errorMessageForCustomer||f.error,checkout_response:y}})}return g>=d?(console.error("Max user actions exceeded"),s.trackFail(null,"max_actions_exceeded","Too many authentication attempts"),{errors:{root:"Too many authentication attempts. Please try again."}}):h.state==="payment_failed"||h.state==="checkout_failed"?(console.log("Card checkout failed:",h),s.trackFail(h.checkoutAttemptId||null,h.errorCode||"payment_failed",h.errorMessageForCustomer||"Payment failed"),{errors:{root:h.errorMessageForCustomer||"Payment failed",checkout_response:h}}):(console.log("Card checkout completed \u2705",h),s.trackSuccess(h.checkoutAttemptId||"unknown"),{data:h})},Uc=async(n,e)=>{let t=await fetch(`${n}/api/card-setup-intents/${e}/collect-token`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw new Error(`Failed to get collect token: ${t.status}`);return(await t.json()).access_token},zc=async(n,e)=>{let{vgsForm:t,cardSetupIntentId:r,secureToken:i,apiBaseUrl:s}=n,o={};if(!t)return o.card_pan="required",{errors:o,isSuccess:!1};if(!r)return o.root="Card setup intent not created",{errors:o,isSuccess:!1};try{let a=await Uc(s,i),l=3e4,c,u=await Promise.race([new Promise((P,b)=>{t.createCard({auth:a,data:{cardholder:{}}},(_,m)=>P(m),_=>b(_))}),new Promise((P,b)=>{c=setTimeout(()=>b(new Error("VGS createCard timed out")),l)})]).finally(()=>clearTimeout(c));if(!u?.data?.attributes)throw new Error("VGS createCard returned an invalid response");let{pan_alias:p,cvc_alias:h,exp_month:d,exp_year:g}=u.data.attributes,f=g<100?2e3+g:g,y=`${String(d).padStart(2,"0")}/${f}`;return await e.publicEndpoints.updateCardSetupIntent({checkoutToken:i,cardSetupIntentId:r,updateCardSetupIntentReq:{cardPan:p,cardExp:y,cardCvc:h,fraudMetadata:it()}}),{errors:{},isSuccess:!0}}catch(a){return console.error("[PaymentKit] VGS CMP createCard failed:",a),o.root="Card submission failed",{errors:o,isSuccess:!1}}},Hc=async n=>{let e={},{cardSetupIntentId:t,cardInputConnections:r}=n,i=Object.entries(r).map(async([s,o])=>{let a=s,c=await(await o.promise).onSubmit(t||"");"error"in c&&(e[a]=c.error)});return await Promise.allSettled(i),{errors:e,isSuccess:Object.keys(e).length===0}},Kc=async n=>{let e={},{cardInputConnections:t}=n,r=Object.entries(t).map(async([i,s])=>{let o=i;if(!s){e[o]="penpal_not_connected";return}let l=await(await s.promise).onValidate();l&&(e[o]=l)});return await Promise.allSettled(r),{errors:e,isSuccess:Object.keys(e).length===0}},Bc=Ct(n=>{let e=Object.create(n);return e.cardInputConnections={},{name:"card",externalFuncs:{createElement:Lc(e)},internalFuncs:{submitPayment:Vc(e),cleanup:()=>{e.vgsForm&&(e.vgsFieldsCleanup?.(),e.vgsFieldsCleanup=void 0,e.vgsForm.unmount(),e.vgsForm=void 0);for(let t of Object.values(e.cardInputConnections))t?.destroy();e.cardInputConnections={}}}}}),Ya=Bc;var er=class{constructor(e){R(this,"client",null);R(this,"config",null);R(this,"mockScenario");this.mockScenario=e??"none"}initialize(e){return this.mockScenario!=="none"?(console.log("[MockGooglePay:Airwallex] initialize called (mock mode)"),this.config=e,!0):window.google?.payments?.api?.PaymentsClient?(this.config=e,this.client=new window.google.payments.api.PaymentsClient({environment:e.isProduction?"PRODUCTION":"TEST"}),this.client!==null):(console.error("[GooglePay:Airwallex] Google Pay API not loaded"),!1)}getAllowedPaymentMethods(e){if(!this.config)throw new Error("Config not set. Call initialize() first.");let t={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["VISA","MASTERCARD","AMEX","DISCOVER","JCB"]}};return e&&(t.tokenizationSpecification={type:"PAYMENT_GATEWAY",parameters:{gateway:"airwallex",gatewayMerchantId:this.config.gatewayMerchantId}}),[t]}async canMakePayment(){if(this.mockScenario!=="none")return console.log("[MockGooglePay:Airwallex] canMakePayment: true (mock mode)"),!0;if(!this.client)return!1;try{let e={apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:this.getAllowedPaymentMethods(!1)};return(await this.client.isReadyToPay(e)).result}catch(e){return console.error("[GooglePay:Airwallex] canMakePayment error:",e),!1}}async showPaymentSheet(){if(this.mockScenario==="success")return console.log("[MockGooglePay:Airwallex] showPaymentSheet: returning mock success token"),{success:!0,token:{protocolVersion:"ECv2",signature:"MOCK_SIGNATURE",intermediateSigningKey:{signedKey:"MOCK_SIGNED_KEY",signatures:["MOCK_SIGNATURE"]},signedMessage:"MOCK_SIGNED_MESSAGE"}};if(this.mockScenario==="cancelled")return console.log("[MockGooglePay:Airwallex] showPaymentSheet: returning mock cancelled"),{success:!1,cancelled:!0};if(!this.client||!this.config)return{success:!1,error:"Google Pay not initialized"};try{let e=this.config.amountDisplay,t={apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:this.getAllowedPaymentMethods(!0),merchantInfo:{merchantName:this.config.merchantId,...this.config.isProduction&&this.config.googleMerchantId?{merchantId:this.config.googleMerchantId}:{}},transactionInfo:{totalPriceStatus:"FINAL",totalPrice:e,currencyCode:this.config.currency.toUpperCase(),countryCode:this.config.country.toUpperCase()}},i=(await this.client.loadPaymentData(t)).paymentMethodData.tokenizationData.token;return{success:!0,token:JSON.parse(i)}}catch(e){return e instanceof Error&&e.message?.includes("CANCELED")?{success:!1,cancelled:!0}:e.statusCode==="CANCELED"?{success:!1,cancelled:!0}:(console.error("[GooglePay:Airwallex] Payment sheet error:",e),{success:!1,error:e instanceof Error?e.message:"Unknown error"})}}};var tr=class{constructor(e){R(this,"stripe",null);R(this,"paymentRequest",null);R(this,"mockScenario");this.mockScenario=e??"none"}initialize(e){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] initialize called"),!window.Stripe)return console.log("[GooglePay] Stripe.js not loaded"),!1;this.stripe=window.Stripe(e);let t=this.stripe!==null;return console.log("[GooglePay] initialize result:",t),t}case"success":case"cancelled":return console.log("[MockGooglePay] initialize called"),console.log("[MockGooglePay] initialize result:",!0),!0}}createPaymentRequest(e){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] createPaymentRequest called",e),!this.stripe)throw new Error("Stripe not initialized");this.paymentRequest=this.stripe.paymentRequest(e),console.log("[GooglePay] paymentRequest created");return}case"success":case"cancelled":{console.log("[MockGooglePay] createPaymentRequest called",e);return}}}async canMakePayment(){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] canMakePayment called"),!this.paymentRequest)return console.log("[GooglePay] canMakePayment: no paymentRequest"),!1;let e=await this.paymentRequest.canMakePayment(),t=e?.googlePay??!1;return console.log("[GooglePay] canMakePayment result:",{result:e,isAvailable:t}),t}case"success":case"cancelled":return console.log("[MockGooglePay] canMakePayment called"),console.log("[MockGooglePay] canMakePayment result:",{result:{googlePay:!0},isAvailable:!0}),!0}}async showPaymentSheet(){switch(this.mockScenario){case"none":return console.log("[GooglePay] showPaymentSheet called"),this.paymentRequest?new Promise(e=>{this.paymentRequest.on("paymentmethod",t=>{console.log("[GooglePay] showPaymentSheet: paymentmethod event",{paymentMethodId:t.paymentMethod.id}),e({success:!0,paymentMethodId:t.paymentMethod.id,complete:r=>{console.log("[GooglePay] complete called:",r),t.complete(r)}})}),this.paymentRequest.on("cancel",()=>{console.log("[GooglePay] showPaymentSheet: cancelled by user"),e({success:!1,cancelled:!0})}),console.log("[GooglePay] showing payment sheet..."),this.paymentRequest.show()}):(console.log("[GooglePay] showPaymentSheet: no paymentRequest"),{success:!1,error:"Payment request not created"});case"success":return console.log("[MockGooglePay] showPaymentSheet: success"),await new Promise(e=>setTimeout(e,500)),{success:!0,paymentMethodId:"pm_mock_123456789",complete:e=>console.log(`[MockGooglePay] complete: ${e}`)};case"cancelled":return console.log("[MockGooglePay] showPaymentSheet: cancelled"),await new Promise(e=>setTimeout(e,500)),{success:!1,cancelled:!0}}}async confirmCardSetup(e,t){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] confirmCardSetup called",{clientSecret:`${e.slice(0,20)}...`,paymentMethodId:t}),!this.stripe)return console.log("[GooglePay] confirmCardSetup: Stripe not initialized"),{success:!1,error:"Stripe not initialized"};let{error:r}=await this.stripe.confirmCardSetup(e,{payment_method:t});return r?(console.log("[GooglePay] confirmCardSetup error:",r),{success:!1,error:r.message??"Card setup failed"}):(console.log("[GooglePay] confirmCardSetup success"),{success:!0})}case"success":return console.log("[MockGooglePay] confirmCardSetup called",{clientSecret:e,paymentMethodId:t}),{success:!0};case"cancelled":throw new Error("confirmCardSetup should not be called when scenario is Cancelled")}}};async function ls(n,e,t){let r=new Headers(e.headers);t&&r.set("x-request-id",t);let i=await fetch(n,{...e,headers:r});if(!i.ok){let s=`Request failed (${i.status})`;try{s=(await i.json()).detail||s}catch{s=i.statusText||s}return{error:s}}return{data:await i.json()}}function Wc(n){return n?.processorId?null:{processor_id:"Processor ID is required"}}function Xc(n){return n&&n!=="none"?n:void 0}async function Yc(n,e,t,r,i){return ls(`${n}/api/checkout/${e}/google-pay/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processor_id:t.processorId,customer_info:t.customerInfo,fraud_metadata:it(),mock_scenario:r})},i)}function Jc(n,e,t){let r=new tr(t);if(!r.initialize(n))return{error:'Stripe.js not loaded. Add <script src="https://js.stripe.com/v3/"><\/script> to your page.'};let i={country:e.country,currency:e.currency.toLowerCase(),total:{label:"Total",amount:e.amount},requestPayerName:!0,requestPayerEmail:!0};return r.createPaymentRequest(i),{adapter:r}}async function Zc(n,e){if(!n.stripe_pk||!n.client_secret)return{success:!1,error:"Stripe credentials not provided"};let{adapter:t,error:r}=Jc(n.stripe_pk,n,e);if(!t)return{success:!1,error:r};if(!await t.canMakePayment())return{success:!1,error:"Google Pay not available on this device"};let s=await t.showPaymentSheet();if(!s.success)return"cancelled"in s&&s.cancelled?{success:!1,error:"Google Pay cancelled by user"}:{success:!1,error:"error"in s?s.error:"Unknown error"};let o=await t.confirmCardSetup(n.client_secret,s.paymentMethodId);return o.success?(s.complete("success"),{success:!0}):(s.complete("fail"),{success:!1,error:"error"in o?o.error:"Card setup failed"})}function Qc(n,e){if(!n.merchant_name||!n.airwallex_account_id)return{error:"Airwallex Google Pay credentials not provided"};let t="none";e==="success"?t="success":e==="cancelled"&&(t="cancelled");let r=new er(t),i={merchantId:n.merchant_name,gatewayMerchantId:n.airwallex_account_id,amountDisplay:n.amount_display,currency:n.currency,country:n.country,isProduction:n.is_sandbox===!1,googleMerchantId:n.google_merchant_id};return r.initialize(i)?{adapter:r}:{error:'Google Pay API not loaded. Add <script src="https://pay.google.com/gp/p/js/pay.js"><\/script> to your page.'}}async function ep(n,e){let{adapter:t,error:r}=Qc(n,e);if(!t)return{success:!1,error:r};if(!await t.canMakePayment())return{success:!1,error:"Google Pay not available on this device"};let s=await t.showPaymentSheet();return s.success?{success:!0,token:s.token}:"cancelled"in s&&s.cancelled?{success:!1,error:"Google Pay cancelled by user"}:{success:!1,error:"error"in s?s.error:"Unknown error"}}async function Za(n,e,t,r,i){let s={mock_scenario:r};t&&(s.google_pay_token=t);let o=await ls(`${n}/api/checkout/${e}/google-pay/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)},i);return o.error||!o.data?{charge_status:"fail",error_message:o.error||"Failed to confirm payment",checkout_attempt_id:""}:o.data}async function tp(n,e,t){let r=await ls(`${n}/api/checkout/${e}/google-pay/verify`,{method:"POST",headers:{"Content-Type":"application/json"}},t);return r.error||!r.data?{charge_status:"fail",error_message:r.error||"Failed to verify payment",checkout_attempt_id:""}:r.data}function as(n,e){return n.charge_status==="success"?{data:{id:n.transaction_id,checkoutAttemptId:n.checkout_attempt_id,checkoutSessionId:e,state:"checkout_succeeded"}}:{errors:{google_pay:n.error_message||"Payment failed"}}}async function np(n,e,t,r){let i=await Za(n,e,void 0,t,r);return as(i,e)}var Ja=5;async function rp(n,e,t,r,i){let s=0,o=await Za(n,e,t,r,i);for(;o.charge_status==="pending"&&o.next_action&&s<Ja;){s++;let a=await Qn(o.next_action),l=await tp(n,e,i);if(l.charge_status==="pending"&&l.next_action){a.success||console.log("[GooglePay:Airwallex] 3DS failed but retry available, continuing loop..."),o=l;continue}return a.success?as(l,e):{errors:{google_pay:l.error_message||a.error||"3DS authentication failed"}}}return s>=Ja?{errors:{google_pay:"Too many authentication attempts. Please try again."}}:as(o,e)}var ip=n=>async(t,r)=>{let{apiBaseUrl:i,secureToken:s,environment:o}=n,a=r,l=Wc(a);if(l)return{errors:l};try{let c=Xc(a.mockScenario),u=tt(o);console.log(`[GooglePay] Using checkout_request_id: ${u}`);let p=await Yc(i,s,a,c,u);if(p.error||!p.data)return{errors:{google_pay:p.error||"Failed to start Google Pay"}};let h=p.data;if(h.processor==="stripe"){let d=await Zc(h,a.mockScenario);return d.success?await np(i,s,c,u):{errors:{google_pay:d.error}}}if(h.processor==="airwallex"){let d=await ep(h,a.mockScenario);return d.success?d.token?await rp(i,s,d.token,c,u):{errors:{google_pay:"Google Pay token not received"}}:{errors:{google_pay:d.error}}}return{errors:{google_pay:`Unsupported processor: ${h.processor}`}}}catch(c){return{errors:{google_pay:`Google Pay error: ${c}`}}}},sp=Ct(n=>({name:"google_pay",externalFuncs:{},internalFuncs:{submitPayment:ip(n),cleanup:()=>{}}}));var Qa=sp;var op=n=>async(t,r)=>{let{apiBaseUrl:i,secureToken:s,environment:o}=n,a=r;if(!a?.processorId)return{errors:{processor_id:"Processor ID is required"}};if(!a?.customerInfo?.first_name||!a?.customerInfo?.last_name)return{errors:{customer_name:"Customer first and last name are required"}};try{let l=tt(o);console.log(`[PayPal] Using checkout_request_id: ${l}`);let c=await fetch(`${i}/api/checkout/${s}/paypal/start`,{method:"POST",headers:{"Content-Type":"application/json","x-request-id":l},body:JSON.stringify({processor_id:a.processorId,customer_info:a.customerInfo,fraud_metadata:it()})});if(!c.ok){let g=`Failed to start PayPal checkout (${c.status})`;try{g=(await c.json()).detail||g}catch{g=c.statusText||g}return{errors:{paypal:g}}}let{approval_url:u,popup_token:p,checkout_attempt_id:h}=await c.json(),d=window.open(u,"PayPal","width=600,height=700");return d?(n.popup=d,new Promise(g=>{let f=setInterval(async()=>{try{let y=await fetch(`${i}/api/checkout/${s}/popup/status?popup_token=${p}`);if(!y.ok){clearInterval(f),d.close(),g({errors:{paypal:"Failed to check PayPal status"}});return}let P=await y.json();if(P.completed){if(clearInterval(f),d.close(),P.status==="success"){let b=P.result||{id:h,checkoutAttemptId:h,checkoutSessionId:s,state:"checkout_succeeded"};g({data:b})}else g({errors:{paypal:P.error||`PayPal checkout ${P.status}`}});return}if(d.closed){clearInterval(f),g({errors:{paypal:"PayPal popup closed by user"}});return}}catch(y){clearInterval(f),d.close(),g({errors:{paypal:`Polling error: ${y}`}})}},2e3);n.pollInterval=f})):{errors:{paypal:"Failed to open PayPal popup. Please allow popups for this site."}}}catch(l){return{errors:{paypal:`PayPal checkout error: ${l}`}}}},ap=Ct(n=>{let e={...n};return{name:"paypal",externalFuncs:{},internalFuncs:{submitPayment:op(e),cleanup:()=>{e.pollInterval&&clearInterval(e.pollInterval),e.popup&&!e.popup.closed&&e.popup.close()}}}}),el=ap;var lp=za,up={card:Ya,googlePay:Qa,paypal:el};return pl(cp);})();
65
65
  //# sourceMappingURL=paymentkit.min.js.map