@payment-kit-js/vanilla 0.5.1 → 0.5.2
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.
- package/dist/cdn/paymentkit.js +55 -11
- package/dist/cdn/paymentkit.js.map +2 -2
- package/dist/cdn/paymentkit.min.js +6 -6
- package/dist/cdn/paymentkit.min.js.map +3 -3
- package/dist/index.mjs +31 -15
- package/dist/index.mjs.map +1 -1
- package/dist/payment-methods/card.d.mts.map +1 -1
- package/dist/payment-methods/card.mjs +14 -3
- package/dist/payment-methods/card.mjs.map +1 -1
- package/dist/payment-methods/vgs-collect-loader.d.mts.map +1 -1
- package/dist/payment-methods/vgs-collect-loader.mjs +1 -1
- package/dist/{vgs-collect-loader-DVYzFDwC.mjs → vgs-collect-loader-D3_xOA-G.mjs} +12 -3
- package/dist/vgs-collect-loader-D3_xOA-G.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/vgs-collect-loader-DVYzFDwC.mjs.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PaymentKit.js v0.5.
|
|
2
|
+
* PaymentKit.js v0.5.2
|
|
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 il=Object.getOwnPropertyDescriptor;var sl=Object.getOwnPropertyNames;var ol=Object.prototype.hasOwnProperty;var ds=n=>{throw TypeError(n)};var al=(n,e,t)=>e in n?cr(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ll=(n,e)=>{for(var t in e)cr(n,t,{get:e[t],enumerable:!0})},ul=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of sl(e))!ol.call(n,i)&&i!==t&&cr(n,i,{get:()=>e[i],enumerable:!(r=il(e,i))||r.enumerable});return n};var cl=n=>ul(cr({},"__esModule",{value:!0}),n);var R=(n,e,t)=>al(n,typeof e!="symbol"?e+"":e,t),hs=(n,e,t)=>e.has(n)||ds("Cannot "+t);var M=(n,e,t)=>(hs(n,e,"read from private field"),t?t.call(n):e.get(n)),J=(n,e,t)=>e.has(n)?ds("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ye=(n,e,t,r)=>(hs(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);var cp={};ll(cp,{PaymentMethods:()=>up,default:()=>lp});var fs="0.5.1";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,Y=typeof globalThis<"u"?globalThis:g;typeof self>"u"&&(Y.self=Y),typeof File>"u"&&(Y.File=function(){});var co=Array.prototype,gs=co.forEach,vs=co.indexOf,oe=Y?.navigator,_=Y?.document,X=Y?.location,kn=Y?.fetch,wn=Y!=null&&Y.XMLHttpRequest&&"withCredentials"in new Y.XMLHttpRequest?Y.XMLHttpRequest:void 0,ys=Y?.AbortController,ne=oe?.userAgent,C=g??{},Ee={DEBUG:!1,LIB_VERSION:"1.341.0"};function ms(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){ms(s,r,i,o,a,"next",l)}function a(l){ms(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 po(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 dl=["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"],_s=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return dl.concat(e).some(r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1})},hl=["$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(/^\$/,"")},fl=Array.isArray,ho=Object.prototype,fo=ho.hasOwnProperty,Lr=ho.toString,$=fl||function(n){return Lr.call(n)==="[object Array]"},qe=n=>typeof n=="function",z=n=>n===Object(n)&&!$(n),dt=n=>{if(z(n)){for(var e in n)if(fo.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,fe=n=>n===null,T=n=>b(n)||fe(n),Me=n=>Lr.call(n)=="[object Number]"&&n==n,ut=n=>Me(n)&&n>0,Ie=n=>Lr.call(n)==="[object Boolean]",gl=n=>n instanceof FormData,vl=n=>A(hl,n);function Pn(n){return n===null||typeof n!="object"}function mr(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function go(n){return!b(Event)&&function(e,t){try{return e instanceof t}catch{return!1}}(n,Event)}var yl=[!0,"true",1,"1","yes"],nn=n=>A(yl,n),ml=[!1,"false",0,"0","no"];function _e(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),Me(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),_e(i||t,e,t,r))}var Sn=class{constructor(e){this.t={},this.i=e.i,this.o=_e(e.bucketSize,0,100,e.h),this.m=_e(e.refillRate,0,this.o,e.h),this.$=_e(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={}}},de="Mobile",_r="iOS",Ce="Android",Xt="Tablet",vo=Ce+" "+Xt,yo="iPad",mo="Apple",_o=mo+" Watch",Yt="Safari",vt="BlackBerry",bo="Samsung",ko=bo+"Browser",wo=bo+" Internet",Xe="Chrome",_l=Xe+" OS",Eo=Xe+" "+_r,Oi="Internet Explorer",xo=Oi+" "+de,$i="Opera",bl=$i+" Mini",Di="Edge",Po="Microsoft "+Di,ft="Firefox",So=ft+" "+_r,Jt="Nintendo",Zt="PlayStation",gt="Xbox",Co=Ce+" "+de,Io=de+" "+Yt,jt="Windows",Cn=jt+" Phone",bs="Nokia",In="Ouya",Mo="Generic",kl=Mo+" "+de.toLowerCase(),Ro=Mo+" "+Xt.toLowerCase(),Mn="Konqueror",ee="(\\d+(\\.\\d+)?)",sn=new RegExp("Version/"+ee),wl=new RegExp(gt,"i"),El=new RegExp(Zt+" \\w+","i"),xl=new RegExp(Jt+" \\w+","i"),Ni=new RegExp(vt+"|PlayBook|BB10","i"),Pl={"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,ks,on,Sl=(n,e)=>e&&A(e,mo)||function(t){return A(t,Yt)&&!A(t,Xe)&&!A(t,Ce)}(n),Ao=function(n,e){return e=e||"",A(n," OPR/")&&A(n,"Mini")?bl:A(n," OPR/")?$i:Ni.test(n)?vt:A(n,"IE"+de)||A(n,"WPDesktop")?xo:A(n,ko)?wo:A(n,Di)||A(n,"Edg/")?Po:A(n,"FBIOS")?"Facebook "+de:A(n,"UCWEB")||A(n,"UCBrowser")?"UC Browser":A(n,"CriOS")?Eo:A(n,"CrMo")||A(n,Xe)?Xe:A(n,Ce)&&A(n,Yt)?Co:A(n,"FxiOS")?So:A(n.toLowerCase(),Mn.toLowerCase())?Mn:Sl(n,e)?A(n,de)?Io:Yt:A(n,ft)?ft:A(n,"MSIE")||A(n,"Trident/")?Oi:A(n,"Gecko")?ft:""},Cl={[xo]:[new RegExp("rv:"+ee)],[Po]:[new RegExp(Di+"?\\/"+ee)],[Xe]:[new RegExp("("+Xe+"|CrMo)\\/"+ee)],[Eo]:[new RegExp("CriOS\\/"+ee)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+ee)],[Yt]:[sn],[Io]:[sn],[$i]:[new RegExp("(Opera|OPR)\\/"+ee)],[ft]:[new RegExp(ft+"\\/"+ee)],[So]:[new RegExp("FxiOS\\/"+ee)],[Mn]:[new RegExp("Konqueror[:/]?"+ee,"i")],[vt]:[new RegExp(vt+" "+ee),sn],[Co]:[new RegExp("android\\s"+ee,"i")],[wo]:[new RegExp(ko+"\\/"+ee)],[Oi]:[new RegExp("(rv:|MSIE )"+ee)],Mozilla:[new RegExp("rv:"+ee)]},Il=function(n,e){var t=Ao(n,e),r=Cl[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},ws=[[new RegExp(gt+"; "+gt+" (.*?)[);]","i"),n=>[gt,n&&n[1]||""]],[new RegExp(Jt,"i"),[Jt,""]],[new RegExp(Zt,"i"),[Zt,""]],[Ni,[vt,""]],[new RegExp(jt,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Cn,""];if(new RegExp(de).test(e)&&!/IEMobile\b/.test(e))return[jt+" "+de,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=Pl[r]||"";return/arm/i.test(e)&&(i="RT"),[jt,i]}return[jt,""]}],[/((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("("+Ce+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ce+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Ce,e.join(".")]}return[Ce,""]}],[/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/,[_l,""]],[/Linux|debian/i,["Linux",""]]],Es=function(n){return xl.test(n)?Jt:El.test(n)?Zt:wl.test(n)?gt:new RegExp(In,"i").test(n)?In:new RegExp("("+Cn+"|WPDesktop)","i").test(n)?Cn:/iPad/.test(n)?yo:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?_o:Ni.test(n)?vt:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(bs,"i").test(n)?bs:/(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(de).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)?Ce:vo:new RegExp("(pda|"+de+")","i").test(n)?kl:new RegExp(Xt,"i").test(n)&&!new RegExp(Xt+" pc","i").test(n)?Ro:""},Ml=n=>n instanceof Error;function Rl(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return on&&t.length===ks||(ks=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:Rl(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 To=(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]},Al=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Tl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Fl=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ol=(n,e)=>{var t=Al.exec(n);if(t){var[,r,i,s]=t;return An(e,r,yt,+i,+s)}var o=Tl.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Fl.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=To(o[1]||yt,o[2]);return An(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},$l=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Dl=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Nl=(n,e)=>{var t=$l.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=Dl.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]=To(s,i),An(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},xs=/\(error: (.*)\)/,Ps=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=xs.test(c)?c.replace(xs,"$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>=Ps)break}}}return function(d){if(!d.length)return[];var f=Array.from(d);return f.reverse(),f.slice(0,Ps).map(v=>{return E({},v,{filename:v.filename||(y=f,y[y.length-1]||{}).filename,function:v.function||yt});var y})}(o)}}("web:javascript",Ol,Nl)}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}}},ql=/^(?:[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(ql);return i&&(t=i[1],r=i[2]),[t,r]}},Gl=["fatal","error","warning","log","info","debug"];function Fo(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 go(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: "+Fo(e)}isSeverityLevel(e){return H(e)&&!xn(e)&&Gl.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(Ml(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 go(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Fo(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},jn=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}}},qn=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}},Oo=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(g&&(Ee.DEBUG||C.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)=>Oo(n+" "+i,s)};return r},w=Oo("[PostHog.js]"),G=w.createLogger,Ll=G("[ExternalScriptsLoader]"),Ss=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return Ll.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)};C.__PosthogExtensions__=C.__PosthogExtensions__||{},C.__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);Ss(n,s,t)},C.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);Ss(n,r,t)};var br={};function Ge(n,e,t){if($(n)){if(gs&&n.forEach===gs)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 Ge(n,e,t);if(gl(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===br)return}else for(var i in n)if(fo.call(n,i)&&e.call(t,n[i],i)===br)return}}var U=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 Ge(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 Ge(t,function(i){Ge(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 Cs=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){w.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),w.critical(i)}}},ji=function(n){var e={};return N(n,function(t,r){(H(t)&&t.length>0||Me(t))&&(e[r]=t)}),e};function Vl(n,e){return t=n,r=s=>H(s)&&!fe(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=[],Ge(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 zl=["herokuapp.com","vercel.app","netlify.app"];function Hl(n){var e=n?.hostname;if(!H(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of zl)if(t===r)return!1;return!0}function $o(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function V(n,e,t,r){var{capture:i=!1,passive:s=!0}=r??{};n?.addEventListener(e,t,{capture:i,passive:s})}var Do="$people_distinct_id",qt="__alias",Gt="__timers",Is="$autocapture_disabled_server_side",Gn="$heatmaps_enabled_server_side",Ms="$exception_capture_enabled_server_side",Ln="$error_tracking_suppression_rules",Rs="$error_tracking_capture_extension_exceptions",As="$web_vitals_enabled_server_side",No="$dead_clicks_enabled_server_side",Ts="$product_tours_enabled_server_side",Fs="$web_vitals_allowed_metrics",an="$session_recording_remote_config",kr="$sesid",jo="$session_is_sampled",ht="$enabled_feature_flags",Lt="$early_access_features",Un="$feature_flag_details",Ut="$stored_person_properties",We="$stored_group_properties",Vn="$surveys",wr="$flag_call_reported",xe="$user_state",zn="$client_session_props",Hn="$capture_rate_limit",Kn="$initial_campaign_params",Bn="$initial_referrer_info",Er="$initial_person_info",xr="$epp",qo="__POSTHOG_TOOLBAR__",Mt="$posthog_cookieless",Kl=[Do,qt,"__cmpns",Gt,"$session_recording_enabled_server_side",Gn,kr,ht,Ln,xe,Lt,Un,We,Ut,Vn,wr,zn,Hn,Kn,Bn,xr,Er,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function Os(n){return n instanceof Element&&(n.id===qo||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function Ur(n){return!!n&&n.nodeType===1}function Le(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function Go(n){return!!n&&n.nodeType===3}function Lo(n){return!!n&&n.nodeType===11}function qi(n){return n?Gr(n).split(/\s+/):[]}function $s(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 qi(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)&&!Bo(n)&&n.childNodes&&n.childNodes.length&&N(n.childNodes,function(t){var r;Go(t)&&t.textContent&&(e+=(r=Uo(t.textContent))!==null&&r!==void 0?r:"")}),Gr(e)}function Vo(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 zo(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 Ho(n){var e=n.parentNode;return!(!e||!Ur(e))&&e}var Bl=["next","previous","prev",">","<"],Ds=10,Ns=[".ph-no-rageclick",".ph-no-capture"];function Wl(n,e){if(!g||Li(n))return!1;var t,r,i;if(Ie(e)?(t=!!e&&Ns,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:Ns,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=Ko(n,!1);return!function(o,a){if(o===!1||b(o))return!1;var l;if(o===!0)l=Bl;else{if(!$(o))return!1;if(o.length>Ds)return w.error("[PostHog] content_ignorelist array cannot exceed "+Ds+" 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())||""}}))&&!zo(s,t)}var Li=n=>!n||Le(n,"html")||!Ur(n),Ko=(n,e)=>{if(!g||Li(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!Le(i,"body");)if(Lo(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=Ho(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 Xl(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&&!$s(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&$s(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}=Ko(n,r);if(!function(f,v){var y=v?.element_allowlist;if(b(y))return!0;var P,m=function(k){if(y.some(x=>k.tagName.toLowerCase()===x))return{v:!0}};for(var I of f)if(P=m(I))return P.v;return!1}(p,t)||!zo(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&&!Le(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 Bo(n){return!!(Le(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Le(n,"select")||Le(n,"textarea")||n.getAttribute("contenteditable")==="true")}var Wo="(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})",Yl=new RegExp("^(?:"+Wo+")$"),Jl=new RegExp(Wo),Xo="\\d{3}-?\\d{2}-?\\d{4}",Zl=new RegExp("^("+Xo+")$"),Ql=new RegExp("("+Xo+")");function Qt(n,e){return e===void 0&&(e=!0),!(T(n)||H(n)&&(n=Gr(n),(e?Yl:Jl).test((n||"").replace(/[- ]/g,""))||(e?Zl:Ql).test(n)))}function Yo(n){var e=tr(n);return Qt(e=(e+" "+Jo(n)).trim())?e:""}function Jo(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+" "+Jo(t)).trim())}catch(s){w.error("[AutoCapture]",s)}}),e}function eu(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:tu(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 tu(n){var e=n.attr__class;return e?$(e)?e:qi(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)},ru=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{w.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",qs=G("[AutoCapture]");function un(n,e){return e.length>n?e.slice(0,n)+"...":e}function nu(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!Ur(e));return e}function iu(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,Yo(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((!Bo(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=qi(h).join(" ")),s["attr__"+u.name]=un(1024,h)}});for(var a=1,l=1,c=n;c=nu(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function su(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!Le(u,"body");)Lo(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,k=>{var x=Wn(k);k.tagName.toLowerCase()==="a"&&(f=k.getAttribute("href"),f=x&&f&&Qt(f)&&f),A(Pr(k),"ph-no-capture")&&(v=!0),h.push(iu(k,s,o,a));var F=function(O){if(!Wn(O))return{};var S={};return N(O.attributes,function(L){if(L.name&&L.name.indexOf("data-ph-capture-attribute")===0){var K=L.name.replace("data-ph-capture-attribute-",""),re=L.value;K&&re&&Qt(re)&&(S[K]=re)}}),S}(k);U(d,F)}),v)return{props:{},explicitNoCapture:v};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?h[0].$el_text=Yo(n):h[0].$el_text=tr(n)),f){var y,P;h[0].attr__href=f;var m=(y=Cr(f))==null?void 0:y.host,I=g==null||(P=g.location)==null?void 0:P.host;m&&I&&m!==I&&(p=f)}return{props:U({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:eu(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){qs.error("Failed to capture event",i)}};if(V(_,"submit",e,{capture:!0}),V(_,"change",e,{capture:!0}),V(_,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||g?.event,this.O(r,ln)};V(_,"copy",t,{capture:!0}),V(_,"cut",t,{capture:!0})}}}else qs.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({[Is]:!!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[Is],i=this.T;if(fe(i)&&!Ie(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=Vo(e);Go(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())&&Wl(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===ln;if(i&&Xl(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=su(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 qe(_?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return Me(n)&&isFinite(n)&&Math.floor(n)===n});var Gs="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+Gs.charAt(this.bytes[t]>>>4)+Gs.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())}},Ls,Zo=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&&(Zo=n=>crypto.getRandomValues(n));var Zn=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(Zo(this.N),this.U=0),this.N[this.U++]}},je=()=>ou().toString(),ou=()=>(Ls||(Ls=new Jn)).generate(),Rt="",au=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function lu(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_"+je();!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(au);return s?s[0]:""})(n);r!==t&&w.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var me={H:()=>!!_,B:function(n){w.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(me.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(_)try{var s="",o="",a=lu(_.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&&w.warn("cookieStore warning: large cookie, len="+c.length),_.cookie=c,c}catch{return}},V:function(n,e){if(_!=null&&_.cookie)try{me.G(n,"",-1,e)}catch{return}}},cn=null,q={H:function(){if(!fe(cn))return cn;var n=!0;if(b(g))n=!1;else try{var e="__mplssupport__";q.G(e,"xyz"),q.q(e)!=='"xyz"'&&(n=!1),q.V(e)}catch{n=!1}return n||w.error("localStorage unsupported; falling back to cookie store"),cn=n,n},B:function(n){w.error("localStorage error: "+n)},q:function(n){try{return g?.localStorage.getItem(n)}catch(e){q.B(e)}return null},W:function(n){try{return JSON.parse(q.q(n))||{}}catch{}return null},G:function(n,e){try{g?.localStorage.setItem(n,JSON.stringify(e))}catch(t){q.B(t)}},V:function(n){try{g?.localStorage.removeItem(n)}catch(e){q.B(e)}}},uu=["$device_id","distinct_id",kr,jo,xr,Er],dr={},cu={H:function(){return!0},B:function(n){w.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]}},Ke=null,W={H:function(){if(!fe(Ke))return Ke;if(Ke=!0,b(g))Ke=!1;else try{var n="__support__";W.G(n,"xyz"),W.q(n)!=='"xyz"'&&(Ke=!1),W.V(n)}catch{Ke=!1}return Ke},B:function(n){w.error("sessionStorage error: ",n)},q:function(n){try{return g?.sessionStorage.getItem(n)}catch(e){W.B(e)}return null},W:function(n){try{return JSON.parse(W.q(n))||null}catch{}return null},G:function(n,e){try{g?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){W.B(t)}},V:function(n){try{g?.sessionStorage.removeItem(n)}catch(e){W.B(e)}}},Pe=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()?Pe.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===Pe.DENIED||this.consent===Pe.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Pe.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)?Pe.GRANTED:A(ml,e)?Pe.DENIED:Pe.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?q:me;var t=e==="localStorage"?me:q;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&&!!$o([oe?.doNotTrack,oe?.msDoNotTrack,C.doNotTrack],e=>nn(e))}},hr=G("[Dead Clicks]"),pu=()=>!0,du=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(No)),r=n.instance.config.capture_dead_clicks;return Ie(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({[No]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,r;(t=C.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=C.__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=C.__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=C.__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=C.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=C.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=C.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=C.__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[Ms]),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=C.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=C.__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({[Ms]: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 qe(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&&(w.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,w.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){w.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};V(g,"popstate",e),this.ft=()=>{g&&g.removeEventListener("popstate",e)}}}},pn=G("[SegmentIntegration]");function hu(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()||je();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(xe,"identified")),i()},a=s.user();"then"in a&&qe(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 Qo="posthog-js";function ea(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(P=>E({},P,{stacktrace:P.stacktrace?E({},P.stacktrace,{type:"raw",frames:(P.stacktrace.frames||[]).map(m=>E({},m,{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=Qo,this.setupOnce=function(a){a(ea(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},fu=g!=null&&g.location?Mr(g.location.hash,"__posthog")||Mr(location.hash,"state"):null,Vs="_postHogToolbarParams",zs=G("[Toolbar]"),Ne=function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n}(Ne||{}),ni=class{constructor(e){this.instance=e}yt(e){C.ph_toolbar_state=e}wt(){var e;return(e=C.ph_toolbar_state)!==null&&e!==void 0?e:Ne.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=fu||Mr(e.hash,"__posthog")||Mr(e.hash,"state"),o=s?Cs(()=>JSON.parse(atob(decodeURIComponent(s))))||Cs(()=>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(Vs)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=C.ph_load_toolbar||C.ph_load_editor;!T(t)&&qe(t)?t(e,this.instance):zs.warn("No toolbar load function found")}loadToolbar(e){var t=!(_==null||!_.getElementById(qo));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(Vs,JSON.stringify(E({},i,{source:void 0}))),this.wt()===Ne.LOADED)this.xt(i);else if(this.wt()===Ne.UNINITIALIZED){var s;this.yt(Ne.LOADING),(s=C.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",o=>{if(o)return zs.error("[Toolbar] Failed to load",o),void this.yt(Ne.UNINITIALIZED);this.yt(Ne.LOADED),this.xt(i)}),V(g,"turbolinks:load",()=>{this.yt(Ne.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)}},gu=G("[TracingHeaders]"),ii=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;b(this.$t)&&((t=C.__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=C.__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=C.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return gu.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"],vu=_t(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],bt),nr="<masked>",yu=["li_fat_id"];function ta(n,e,t){if(!_)return{};var r,i=e?_t([],bt,t||[]):[],s=ra(rr(_.URL,i,nr),n),o=(r={},N(yu,function(a){var l=me.q(a);r[a]=l||null}),r);return U(o,s)}function ra(n,e){var t=vu.concat(e||[]),r={};return N(t,function(i){var s=Ir(n,i);r[i]=s||null}),r}function na(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(!fe(e)){r.$search_engine=e;var i=_?Ir(_.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function Hs(){return navigator.language||navigator.userLanguage}function ia(){return _?.referrer||"$direct"}function sa(n,e){var t=n?_t([],bt,e||[]):[],r=X?.href.substring(0,1e3);return{r:ia().substring(0,1e3),u:r?rr(r,t,nr):void 0}}function oa(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=ra(r);U(i,o)}if(t){var a=na(t);U(i,a)}return i}function aa(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function mu(){try{return new Date().getTimezoneOffset()}catch{return}}function _u(n,e){if(!ne)return{};var t,r,i,s=n?_t([],bt,e||[]):[],[o,a]=function(l){for(var c=0;c<ws.length;c++){var[u,p]=ws[c],h=u.exec(l),d=h&&(qe(p)?p(h,l):p);if(d)return d}return["",""]}(ne);return U(ji({$os:o,$os_version:a,$browser:Ao(ne,navigator.vendor),$device:Es(ne),$device_type:(r=ne,i=Es(r),i===yo||i===vo||i==="Kobo"||i==="Kindle Fire"||i===Ro?Xt:i===Jt||i===gt||i===Zt||i===In?"Console":i===_o?"Wearable":i?de:"Desktop"),$timezone:aa(),$timezone_offset:mu()}),{$current_url:rr(X?.href,s,nr),$host:X?.host,$pathname:X?.pathname,$raw_user_agent:ne.length>1e3?ne.substring(0,997)+"...":ne,$browser_version:Il(ne,navigator.vendor),$browser_language:Hs(),$browser_language_prefix:(t=Hs(),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:Ee.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Oe=G("[Web Vitals]"),Ks=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))Oe.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)?Oe.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?Oe.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=C.__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):Oe.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[As]),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[Fs])||["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)&&Me(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Ks;return 0<e&&e<=6e4?Ks:e}get isEnabled(){var e=X?.protocol;if(e!=="http:"&&e!=="https:")return Oe.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:Ie(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Ie(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Oe.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({[As]:t}),this._instance.persistence.register({[Fs]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=C.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,s=>{s?Oe.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)}Oe.error("Could not determine current URL")}},bu=G("[Heatmaps]");function Bs(n){return z(n)&&"clientX"in n&&"clientY"in n&&Me(n.clientX)&&Me(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;bu.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),V(g,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||g?.event),V(_,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||g?.event),V(_,"mousemove",this.zt,{capture:!0}),this.Bt=new Rr(this.instance,pu,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),V(_,"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&&Ur(u)&&!Le(u,"body");){if(u===c)return!1;if(A(l,g?.getComputedStyle(u).position))return!0;u=Ho(u)}return!1}(Vo(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"),!Os(e.target)&&Bs(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){!Os(e.target)&&Bs(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)&&(w.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:_e(a/o,0,1,w),d=o<=1?1:_e(l/o,0,1,w),f=c<=1?1:_e(u/c,0,1,w),v=c<=1?1:_e(p/c,0,1,w);i=U(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 Se=function(n){return n.GZipJS="gzip-js",n.Base64="base64",n}({}),he=Uint8Array,te=Uint16Array,mt=Uint32Array,Ui=new he([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]),Vi=new he([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]),Ws=new he([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),la=function(n,e){for(var t=new te(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]},ua=la(Ui,2),ku=ua[0],ai=ua[1];ku[28]=258,ai[258]=28;for(li=la(Vi,0)[1],Tr=new te(32768),j=0;j<32768;++j)$e=(43690&j)>>>1|(21845&j)<<1,$e=(61680&($e=(52428&$e)>>>2|(13107&$e)<<2))>>>4|(3855&$e)<<4,Tr[j]=((65280&$e)>>>8|(255&$e)<<8)>>>1;var $e,li,Tr,j,Kt=function(n,e,t){for(var r=n.length,i=0,s=new te(e);i<r;++i)++s[n[i]-1];var o,a=new te(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new te(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 te(r),i=0;i<r;++i)o[i]=Tr[a[n[i]-1]++]>>>15-n[i];return o},Ye=new he(288);for(j=0;j<144;++j)Ye[j]=8;for(j=144;j<256;++j)Ye[j]=9;for(j=256;j<280;++j)Ye[j]=7;for(j=280;j<288;++j)Ye[j]=8;var Fr=new he(32);for(j=0;j<32;++j)Fr[j]=5;var wu=Kt(Ye,9,0),Eu=Kt(Fr,5,0),ca=function(n){return(n/8>>0)+(7&n&&1)},pa=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof te?te:n instanceof mt?mt:he)(t-e);return r.set(n.subarray(e,t)),r},ke=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 he(0),0];if(i==1){var o=new he(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort(function(x,F){return x.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 te(h+1),f=ui(t[u-1],d,0);if(f>e){r=0;var v=0,y=f-e,P=1<<y;for(s.sort(function(x,F){return d[F.s]-d[x.s]||x.f-F.f});r<i;++r){var m=s[r].s;if(!(d[m]>e))break;v+=P-(1<<f-d[m]),d[m]=e}for(v>>>=y;v>0;){var I=s[r].s;d[I]<e?v-=1<<e-d[I]++-1:++r}for(;r>=0&&v;--r){var k=s[r].s;d[k]==e&&(--d[k],++v)}f=e}return[new he(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},Xs=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new te(++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=ca(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)},Ys=function(n,e,t,r,i,s,o,a,l,c,u){ke(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],P=Xs(h),m=P[0],I=P[1],k=Xs(v),x=k[0],F=k[1],O=new te(19),S=0;S<m.length;++S)O[31&m[S]]++;for(S=0;S<x.length;++S)O[31&x[S]]++;for(var L=dn(O,7),K=L[0],re=L[1],Z=19;Z>4&&!K[Ws[Z-1]];--Z);var B,ce,ge,it,Re=c+5<<3,He=Ft(i,Ye)+Ft(s,Fr)+o,ve=Ft(i,h)+Ft(s,v)+o+14+3*Z+Ft(O,K)+(2*O[16]+3*O[17]+7*O[18]);if(Re<=He&&Re<=ve)return ci(e,u,n.subarray(l,l+c));if(ke(e,u,1+(ve<He)),u+=2,ve<He){B=Kt(h,d,0),ce=h,ge=Kt(v,y,0),it=v;var Ae=Kt(K,re,0);for(ke(e,u,I-257),ke(e,u+5,F-1),ke(e,u+10,Z-4),u+=14,S=0;S<Z;++S)ke(e,u+3*S,K[Ws[S]]);u+=3*Z;for(var st=[m,x],Q=0;Q<2;++Q){var pe=st[Q];for(S=0;S<pe.length;++S){var ie=31&pe[S];ke(e,u,Ae[ie]),u+=K[ie],ie>15&&(ke(e,u,pe[S]>>>5&127),u+=pe[S]>>>12)}}}else B=wu,ce=Ye,ge=Eu,it=Fr;for(S=0;S<a;++S)if(r[S]>255){ie=r[S]>>>18&31,Tt(e,u,B[ie+257]),u+=ce[ie+257],ie>7&&(ke(e,u,r[S]>>>23&31),u+=Ui[ie]);var ot=31&r[S];Tt(e,u,ge[ot]),u+=it[ot],ot>3&&(Tt(e,u,r[S]>>>5&8191),u+=Vi[ot])}else Tt(e,u,B[r[S]]),u+=ce[r[S]];return Tt(e,u,B[256]),u+ce[256]},xu=new mt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Pu=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}(),Su=function(n,e,t,r,i){return function(s,o,a,l,c,u){var p=s.length,h=new he(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 P=xu[o-1],m=P>>>13,I=8191&P,k=(1<<a)-1,x=new te(32768),F=new te(k+1),O=Math.ceil(a/3),S=2*O,L=function(rn){return(s[rn]^s[rn+1]<<O^s[rn+2]<<S)&k},K=new mt(25e3),re=new te(288),Z=new te(32),B=0,ce=0,ge=(v=0,0),it=0,Re=0;v<p;++v){var He=L(v),ve=32767&v,Ae=F[He];if(x[ve]=Ae,F[He]=ve,it<=v){var st=p-v;if((B>7e3||ge>24576)&&st>423){f=Ys(s,d,0,K,re,Z,ce,ge,Re,v-Re,f),ge=B=ce=0,Re=v;for(var Q=0;Q<286;++Q)re[Q]=0;for(Q=0;Q<30;++Q)Z[Q]=0}var pe=2,ie=0,ot=I,Te=ve-Ae&32767;if(st>2&&He==L(v-Te))for(var el=Math.min(m,st)-1,tl=Math.min(32767,v),rl=Math.min(258,st);Te<=tl&&--ot&&ve!=Ae;){if(s[v+pe]==s[v+pe-Te]){for(var Fe=0;Fe<rl&&s[v+Fe]==s[v+Fe-Te];++Fe);if(Fe>pe){if(pe=Fe,ie=Te,Fe>el)break;var nl=Math.min(Te,Fe-2),ls=0;for(Q=0;Q<nl;++Q){var tn=v-Te+Q+32768&32767,us=tn-x[tn]+32768&32767;us>ls&&(ls=us,Ae=tn)}}}Te+=(ve=Ae)-(Ae=x[ve])+32768&32767}if(ie){K[ge++]=268435456|ai[pe]<<18|li[ie];var cs=31&ai[pe],ps=31&li[ie];ce+=Ui[cs]+Vi[ps],++re[257+cs],++Z[ps],it=v+pe,++B}else K[ge++]=s[v],++re[s[v]]}}f=Ys(s,d,u,K,re,Z,ce,ge,Re,v-Re,f)}return pa(h,0,l+ca(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 Cu(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=Pu[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}}(),r=n.length;t.p(n);var i,s=Su(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 Iu=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 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),ye=(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.2";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,Y=typeof globalThis<"u"?globalThis:g;typeof self>"u"&&(Y.self=Y),typeof File>"u"&&(Y.File=function(){});var po=Array.prototype,vs=po.forEach,ys=po.indexOf,oe=Y?.navigator,_=Y?.document,X=Y?.location,kn=Y?.fetch,wn=Y!=null&&Y.XMLHttpRequest&&"withCredentials"in new Y.XMLHttpRequest?Y.XMLHttpRequest:void 0,ms=Y?.AbortController,ne=oe?.userAgent,I=g??{},Ee={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 w(){return w=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},w.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]"},qe=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,fe=n=>n===null,T=n=>b(n)||fe(n),Me=n=>Lr.call(n)=="[object Number]"&&n==n,ut=n=>Me(n)&&n>0,Ie=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 _e(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),Me(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),_e(i||t,e,t,r))}var Sn=class{constructor(e){this.t={},this.i=e.i,this.o=_e(e.bucketSize,0,100,e.h),this.m=_e(e.refillRate,0,this.o,e.h),this.$=_e(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={}}},de="Mobile",_r="iOS",Ce="Android",Xt="Tablet",yo=Ce+" "+Xt,mo="iPad",_o="Apple",bo=_o+" Watch",Yt="Safari",vt="BlackBerry",ko="Samsung",wo=ko+"Browser",Eo=ko+" Internet",Xe="Chrome",bl=Xe+" OS",xo=Xe+" "+_r,Oi="Internet Explorer",Po=Oi+" "+de,$i="Opera",kl=$i+" Mini",Di="Edge",So="Microsoft "+Di,ft="Firefox",Co=ft+" "+_r,Jt="Nintendo",Zt="PlayStation",gt="Xbox",Io=Ce+" "+de,Mo=de+" "+Yt,jt="Windows",Cn=jt+" Phone",ks="Nokia",In="Ouya",Ro="Generic",wl=Ro+" "+de.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,Xe)&&!A(t,Ce)}(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"+de)||A(n,"WPDesktop")?Po:A(n,wo)?Eo:A(n,Di)||A(n,"Edg/")?So:A(n,"FBIOS")?"Facebook "+de:A(n,"UCWEB")||A(n,"UCBrowser")?"UC Browser":A(n,"CriOS")?xo:A(n,"CrMo")||A(n,Xe)?Xe:A(n,Ce)&&A(n,Yt)?Io:A(n,"FxiOS")?Co:A(n.toLowerCase(),Mn.toLowerCase())?Mn:Cl(n,e)?A(n,de)?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)],[Xe]:[new RegExp("("+Xe+"|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(jt,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Cn,""];if(new RegExp(de).test(e)&&!/IEMobile\b/.test(e))return[jt+" "+de,""];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"),[jt,i]}return[jt,""]}],[/((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("("+Ce+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ce+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Ce,e.join(".")]}return[Ce,""]}],[/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(de).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)?Ce:yo:new RegExp("(pda|"+de+")","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)),w({},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,w({},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 w({},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,jl=(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 ql(){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 w({},v,{filename:v.filename||(y=f,y[y.length-1]||{}).filename,function:v.function||yt});var y})}(o)}}("web:javascript",$l,jl)}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}}},jn=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}}},qn=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&&(Ee.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 Ge(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 Ge(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 V=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 Ge(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 Ge(t,function(i){Ge(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)}}},ji=function(n){var e={};return N(n,function(t,r){(H(t)&&t.length>0||Me(t))&&(e[r]=t)}),e};function zl(n,e){return t=n,r=s=>H(s)&&!fe(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=[],Ge(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",qt="__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",jo="$dead_clicks_enabled_server_side",Fs="$product_tours_enabled_server_side",Os="$web_vitals_allowed_metrics",an="$session_recording_remote_config",kr="$sesid",qo="$session_is_sampled",ht="$enabled_feature_flags",Lt="$early_access_features",Vn="$feature_flag_details",Vt="$stored_person_properties",We="$stored_group_properties",Un="$surveys",wr="$flag_call_reported",xe="$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,qt,"__cmpns",Gt,"$session_recording_enabled_server_side",Gn,kr,ht,Ln,xe,Lt,Vn,We,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 Le(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 qi(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 qi(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,js=[".ph-no-rageclick",".ph-no-capture"];function Xl(n,e){if(!g||Li(n))return!1;var t,r,i;if(Ie(e)?(t=!!e&&js,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:js,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||Le(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&&!Le(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,E=function(m){if(y.some(x=>m.tagName.toLowerCase()===x))return{v:!0}};for(var P of f)if(S=E(P))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&&!Le(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!!(Le(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Le(n,"select")||Le(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=w({},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[qs(p.toString())]=qs(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 qs(n){return n.replace(/"|\\"/g,'\\"')}function ru(n){var e=n.attr__class;return e?$(e)?e:qi(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=qi(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&&!Le(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 x=Wn(m);m.tagName.toLowerCase()==="a"&&(f=m.getAttribute("href"),f=x&&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(L){if(L.name&&L.name.indexOf("data-ph-capture-attribute")===0){var K=L.name.replace("data-ph-capture-attribute-",""),Q=L.value;K&&Q&&Qt(Q)&&(C[K]=Q)}}),C}(m);V(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 E=(y=Cr(f))==null?void 0:y.host,P=g==null||(S=g.location)==null?void 0:S.host;E&&P&&E!==P&&(p=f)}return{props:V({$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(fe(i)&&!Ie(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 qe(_?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return Me(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++]}},je=()=>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_"+je();!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 me={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(me.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{me.G(n,"",-1,e)}catch{return}}},cn=null,q={H:function(){if(!fe(cn))return cn;var n=!0;if(b(g))n=!1;else try{var e="__mplssupport__";q.G(e,"xyz"),q.q(e)!=='"xyz"'&&(n=!1),q.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){q.B(e)}return null},W:function(n){try{return JSON.parse(q.q(n))||{}}catch{}return null},G:function(n,e){try{g?.localStorage.setItem(n,JSON.stringify(e))}catch(t){q.B(t)}},V:function(n){try{g?.localStorage.removeItem(n)}catch(e){q.B(e)}}},cu=["$device_id","distinct_id",kr,qo,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]}},Ke=null,W={H:function(){if(!fe(Ke))return Ke;if(Ke=!0,b(g))Ke=!1;else try{var n="__support__";W.G(n,"xyz"),W.q(n)!=='"xyz"'&&(Ke=!1),W.V(n)}catch{Ke=!1}return Ke},B:function(n){k.error("sessionStorage error: ",n)},q:function(n){try{return g?.sessionStorage.getItem(n)}catch(e){W.B(e)}return null},W:function(n){try{return JSON.parse(W.q(n))||null}catch{}return null},G:function(n,e){try{g?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){W.B(t)}},V:function(n){try{g?.sessionStorage.removeItem(n)}catch(e){W.B(e)}}},Pe=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()?Pe.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===Pe.DENIED||this.consent===Pe.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Pe.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)?Pe.GRANTED:A(_l,e)?Pe.DENIED:Pe.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?q:me;var t=e==="localStorage"?me:q;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([oe?.doNotTrack,oe?.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(jo)),r=n.instance.config.capture_dead_clicks;return Ie(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({[jo]: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=w({},t,e):(b(e)?this.ht:e)&&(t=w({},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 qe(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()||je();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(xe,"identified")),i()},a=s.user();"then"in a&&qe(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=>w({},S,{stacktrace:S.stacktrace?w({},S.stacktrace,{type:"raw",frames:(S.stacktrace.frames||[]).map(E=>w({},E,{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]"),Ne=function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n}(Ne||{}),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:Ne.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)&&qe(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=w({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(g.localStorage.setItem(zs,JSON.stringify(w({},i,{source:void 0}))),this.wt()===Ne.LOADED)this.xt(i);else if(this.wt()===Ne.UNINITIALIZED){var s;this.yt(Ne.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(Ne.UNINITIALIZED);this.yt(Ne.LOADED),this.xt(i)}),U(g,"turbolinks:load",()=>{this.yt(Ne.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=me.q(a);r[a]=l||null}),r);return V(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(!fe(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=X?.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);V(i,o)}if(t){var a=ia(t);V(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(!ne)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&&(qe(p)?p(h,l):p);if(d)return d}return["",""]}(ne);return V(ji({$os:o,$os_version:a,$browser:To(ne,navigator.vendor),$device:xs(ne),$device_type:(r=ne,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?de:"Desktop"),$timezone:la(),$timezone_offset:_u()}),{$current_url:rr(X?.href,s,nr),$host:X?.host,$pathname:X?.pathname,$raw_user_agent:ne.length>1e3?ne.substring(0,997)+"...":ne,$browser_version:Ml(ne,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:Ee.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Oe=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)=>w({},r,{["$web_vitals_"+i.name+"_event"]:w({},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))Oe.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)?Oe.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?Oe.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(w({},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):Oe.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)&&Me(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=X?.protocol;if(e!=="http:"&&e!=="https:")return Oe.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:Ie(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Ie(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Oe.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?Oe.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)}Oe.error("Could not determine current URL")}},ku=G("[Heatmaps]");function Ws(n){return z(n)&&"clientX"in n&&"clientY"in n&&Me(n.clientX)&&Me(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)&&!Le(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(w({},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:_e(a/o,0,1,k),d=o<=1?1:_e(l/o,0,1,k),f=c<=1?1:_e(u/c,0,1,k),v=c<=1?1:_e(p/c,0,1,k);i=V(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 Se=function(n){return n.GZipJS="gzip-js",n.Base64="base64",n}({}),he=Uint8Array,re=Uint16Array,mt=Uint32Array,Vi=new he([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 he([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 he([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),j=0;j<32768;++j)$e=(43690&j)>>>1|(21845&j)<<1,$e=(61680&($e=(52428&$e)>>>2|(13107&$e)<<2))>>>4|(3855&$e)<<4,Tr[j]=((65280&$e)>>>8|(255&$e)<<8)>>>1;var $e,li,Tr,j,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},Ye=new he(288);for(j=0;j<144;++j)Ye[j]=8;for(j=144;j<256;++j)Ye[j]=9;for(j=256;j<280;++j)Ye[j]=7;for(j=280;j<288;++j)Ye[j]=8;var Fr=new he(32);for(j=0;j<32;++j)Fr[j]=5;var Eu=Kt(Ye,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:he)(t-e);return r.set(n.subarray(e,t)),r},ke=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 he(0),0];if(i==1){var o=new he(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort(function(x,F){return x.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(x,F){return d[F.s]-d[x.s]||x.f-F.f});r<i;++r){var E=s[r].s;if(!(d[E]>e))break;v+=S-(1<<f-d[E]),d[E]=e}for(v>>>=y;v>0;){var P=s[r].s;d[P]<e?v-=1<<e-d[P]++-1:++r}for(;r>=0&&v;--r){var m=s[r].s;d[m]==e&&(--d[m],++v)}f=e}return[new he(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){ke(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),E=S[0],P=S[1],m=Ys(v),x=m[0],F=m[1],O=new re(19),C=0;C<E.length;++C)O[31&E[C]]++;for(C=0;C<x.length;++C)O[31&x[C]]++;for(var L=dn(O,7),K=L[0],Q=L[1],J=19;J>4&&!K[Xs[J-1]];--J);var B,ce,ge,it,Re=c+5<<3,He=Ft(i,Ye)+Ft(s,Fr)+o,ve=Ft(i,h)+Ft(s,v)+o+14+3*J+Ft(O,K)+(2*O[16]+3*O[17]+7*O[18]);if(Re<=He&&Re<=ve)return ci(e,u,n.subarray(l,l+c));if(ke(e,u,1+(ve<He)),u+=2,ve<He){B=Kt(h,d,0),ce=h,ge=Kt(v,y,0),it=v;var Ae=Kt(K,Q,0);for(ke(e,u,P-257),ke(e,u+5,F-1),ke(e,u+10,J-4),u+=14,C=0;C<J;++C)ke(e,u+3*C,K[Xs[C]]);u+=3*J;for(var st=[E,x],ee=0;ee<2;++ee){var pe=st[ee];for(C=0;C<pe.length;++C){var ie=31&pe[C];ke(e,u,Ae[ie]),u+=K[ie],ie>15&&(ke(e,u,pe[C]>>>5&127),u+=pe[C]>>>12)}}}else B=Eu,ce=Ye,ge=xu,it=Fr;for(C=0;C<a;++C)if(r[C]>255){ie=r[C]>>>18&31,Tt(e,u,B[ie+257]),u+=ce[ie+257],ie>7&&(ke(e,u,r[C]>>>23&31),u+=Vi[ie]);var ot=31&r[C];Tt(e,u,ge[ot]),u+=it[ot],ot>3&&(Tt(e,u,r[C]>>>5&8191),u+=Ui[ot])}else Tt(e,u,B[r[C]]),u+=ce[r[C]];return Tt(e,u,B[256]),u+ce[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 he(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],E=S>>>13,P=8191&S,m=(1<<a)-1,x=new re(32768),F=new re(m+1),O=Math.ceil(a/3),C=2*O,L=function(rn){return(s[rn]^s[rn+1]<<O^s[rn+2]<<C)&m},K=new mt(25e3),Q=new re(288),J=new re(32),B=0,ce=0,ge=(v=0,0),it=0,Re=0;v<p;++v){var He=L(v),ve=32767&v,Ae=F[He];if(x[ve]=Ae,F[He]=ve,it<=v){var st=p-v;if((B>7e3||ge>24576)&&st>423){f=Js(s,d,0,K,Q,J,ce,ge,Re,v-Re,f),ge=B=ce=0,Re=v;for(var ee=0;ee<286;++ee)Q[ee]=0;for(ee=0;ee<30;++ee)J[ee]=0}var pe=2,ie=0,ot=P,Te=ve-Ae&32767;if(st>2&&He==L(v-Te))for(var tl=Math.min(E,st)-1,rl=Math.min(32767,v),nl=Math.min(258,st);Te<=rl&&--ot&&ve!=Ae;){if(s[v+pe]==s[v+pe-Te]){for(var Fe=0;Fe<nl&&s[v+Fe]==s[v+Fe-Te];++Fe);if(Fe>pe){if(pe=Fe,ie=Te,Fe>tl)break;var il=Math.min(Te,Fe-2),us=0;for(ee=0;ee<il;++ee){var tn=v-Te+ee+32768&32767,cs=tn-x[tn]+32768&32767;cs>us&&(us=cs,Ae=tn)}}}Te+=(ve=Ae)-(Ae=x[ve])+32768&32767}if(ie){K[ge++]=268435456|ai[pe]<<18|li[ie];var ps=31&ai[pe],ds=31&li[ie];ce+=Vi[ps]+Ui[ds],++Q[257+ps],++J[ds],it=v+pe,++B}else K[ge++]=s[v],++Q[s[v]]}}f=Js(s,d,u,K,Q,J,ce,ge,Re,v-Re,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,`
|
|
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),fe(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},Mu=!!wn||!!kn,Js="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=ru(o);return l&&a.push(l),i+"?"+a.join("&")},Vt=(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===Se.GZipJS){var r=Cu(function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new he(l.length+(l.length>>>1)),h=0,d=function(P){p[h++]=P},f=0;f<u;++f){if(h+5>p.length){var v=new he(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 pa(p,0,h)}(Vt(e)),{mtime:0}),i=new Blob([r],{type:Js});return{contentType:Js,body:i,estimatedSize:i.size}}if(t===Se.Base64){var s=function(l){var c,u,p,h,d,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,y=0,P="",m=[];if(!l)return l;l=Iu(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,m[y++]=f.charAt(c)+f.charAt(u)+f.charAt(p)+f.charAt(h);while(v<l.length);switch(P=m.join(""),l.length%3){case 1:P=P.slice(0,-2)+"==";break;case 2:P=P.slice(0,-1)+"="}return P}(Vt(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Vt(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Vt(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(ys){var c=new ys;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){w.error(d)}n.callback==null||n.callback(h)})).catch(u=>{w.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)}}),oe!=null&&oe.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;oe.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 Zs(n,e,t){return Vt({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var da={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 ha(n,e){return!n||Object.entries(n).every(t=>{var[r,i]=t,s=e?.[r];if(b(s)||fe(s))return!1;var o=[String(s)],a=da[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 qn,new On,new Fn,new Nn,new Dn,new $n,new jn],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,[Rs]:o})}get ii(){var e,t=!!this._instance.get_property(Rs),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=da[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)}},se=G("[FeatureFlags]"),Ot=G("[FeatureFlags]",{debugEnabled:!0}),vn="$active_feature_flags",at="$override_feature_flags",Qs="$feature_flag_payloads",$t="$override_feature_flag_payloads",eo="$feature_flag_request_id",to="$feature_flag_evaluated_at",ro=n=>{var e={};for(var[t,r]of vr(n||{}))r&&(e[t]=r);return e},Ru=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]}))):se.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},Au=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||(se.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||se.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(Un),t=this._instance.get_property(at),r=this._instance.get_property($t);if(!r&&!t)return e||{};var i=U({},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||(se.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=U({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(se.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(Qs),t=this._instance.get_property($t);if(!t)return e||{};for(var r=U({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(se.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(Ut)||{}),group_properties:this._instance.get_property(We)};fe(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=aa()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Se.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(Au.FeatureFlags))se.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}se.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(eo)||void 0,c=this._instance.get_property(to)||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,P,m,I;$(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[wr]:u});var k=this.getFeatureFlagDetails(e),x={$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(k==null||(f=k.metadata)==null?void 0:f.version)||(x.$feature_flag_version=k.metadata.version);var F,O=(v=k==null||(y=k.reason)==null?void 0:y.description)!==null&&v!==void 0?v:k==null||(P=k.reason)==null?void 0:P.code;O&&(x.$feature_flag_reason=O),k!=null&&(m=k.metadata)!=null&&m.id&&(x.$feature_flag_id=k.metadata.id),b(k?.original_variant)&&b(k?.original_enabled)||(x.$feature_flag_original_response=b(k.original_variant)?k.original_enabled:k.original_variant),k!=null&&(I=k.metadata)!=null&&I.original_payload&&(x.$feature_flag_original_payload=k==null||(F=k.metadata)==null?void 0:F.original_payload),this._instance.capture("$feature_flag_called",x)}if(i){var S=o;if(!b(o))try{S=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:S}}}else se.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:Se.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}se.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=Ru(o),h=p.flags,d=p.featureFlags,f=p.featureFlagPayloads;if(d){var v=o.requestId,y=o.evaluatedAt;if($(d)){se.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var P={};if(d)for(var m=0;m<d.length;m++)P[d[m]]=!0;a&&a.register({[vn]:d,[ht]:P})}else{var I=d,k=f,x=h;if(o.errorsWhileComputingFlags)if(h){var F=new Set(Object.keys(h).filter(O=>{var S;return!((S=h[O])!=null&&S.failed)}));I=E({},l,Object.fromEntries(Object.entries(I).filter(O=>{var[S]=O;return F.has(S)}))),k=E({},c,Object.fromEntries(Object.entries(k||{}).filter(O=>{var[S]=O;return F.has(S)}))),x=E({},u,Object.fromEntries(Object.entries(x||{}).filter(O=>{var[S]=O;return F.has(S)})))}else I=E({},l,I),k=E({},c,k),x=E({},u,x);a&&a.register(E({[vn]:Object.keys(ro(I)),[ht]:I||{},[Qs]:k||{},[Un]:x||{}},v?{[eo]:v}:{},y?{[to]:y}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),se.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return se.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(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(Ut)||{};this._instance.register({[Ut]:E({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Ut)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(We)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=E({},r[i],e[i]),delete e[i]}),this._instance.register({[We]:E({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(We)||{};this._instance.register({[We]:E({},t,{[e]:{}})})}else this._instance.unregister(We)}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}},Tu=["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&&w.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){Tu.indexOf(e.persistence.toLowerCase())===-1&&(w.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=[...uu,...i];return E({},q,{W:function(o){try{var a={};try{a=me.W(o)||{}}catch{}var l=U(a,JSON.parse(q.q(o)||"{}"));return q.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{q.G(o,a,void 0,void 0,p);var h={};s.forEach(d=>{a[d]&&(h[d]=a[d])}),Object.keys(h).length&&me.G(o,h,l,c,u,p)}catch(d){q.B(d)}},V:function(o,a){try{g?.localStorage.removeItem(o),me.V(o,a)}catch(l){q.B(l)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&q.H()?q:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&W.H()?W:r==="memory"?cu:r==="cookie"?me:t.H()?t:me}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,(fe(o=Kl)?l:vs&&o.indexOf===vs?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=U({},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=ta(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);dt(ji(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=_?.referrer)?na(e):{})}update_referrer_info(){var e;this.register_once({$referrer:ia(),$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]:sa(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=oa(i),r={},N(t,function(o,a){r["$initial_"+En(a)]=o}),r);U(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()}},no=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({[Ts]:!(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(Ts)||this.it(()=>this.Oi())}it(e){var t,r;(t=C.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",i=>{i?no.error("Could not load product tours script",i):e()})}Oi(){var e;!this.Ri&&(e=C.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=C.__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 no.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]"),fa="seenSurvey_",Fu=(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},io=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(fa,n),Ou=[mn.Popover,mn.Widget,mn.API],$u={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&<((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||ha(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&&ha(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(fa)||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=C?.__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(Vn);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({[Vn]: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(Ou.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()}},we=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)||(Ie(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=C?.__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 we.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),we.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else we.error("Cannot complete initialization: remote config is null")}Se(e,t){we.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():we.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!fe(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):(we.warn("Conversations not available yet."),null)})()}getMessages(e,t){var r=this;return pt(function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(we.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(we.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(we.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=C?.__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.")}}},so=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=>{so.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void so.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}},Be=G("[RemoteConfig]"),wi=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=C._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=C.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(Be.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 Be.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void Be.warn("Remote config is disabled. Falling back to local config.");this.Te(e=>{if(!e)return Be.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){Be.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()):Be.info("__preview_remote_config is disabled. Logging config instead",e):Be.error("Failed to fetch remote config from PostHog.")}},Ei=3e3,xi=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=_e(t?.flush_interval_ms||Ei,250,5e3,w.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}},Du=["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},V(g,"online",this.ze),V(g,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=po(e,Du);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)"),w.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){w.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(){V(g,"scroll",this.Ge,{capture:!0}),V(g,"scrollend",this.Ge,{capture:!0}),V(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}},Nu=n=>sa(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||Nu,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?oa(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(ji(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||je,this.ar=r||je;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*_e(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=W.W(this.ur),l=W.W(this.hr);a&&!l?this.rr=a:W.V(this.ur),W.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&&W.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&W.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?W.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()&&W.V(this.hr)},V(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"],De=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=C._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({},po(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&&(De.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,De.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){De.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){De.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){De.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 De.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;C["__$$ph_site_app_"+c]=s._instance,(u=C.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,p=>{if(p)return De.error("Error while initializing PostHog app with config id "+c,p)})};for(var{id:a,url:l}of e.siteApps)o(a)}else De.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},ga=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&_s(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>_s(i?.brand,e)))return!0}catch{}return!!n.webdriver},Ht=function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n}({}),oo="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("."+oo,".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=oo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},qu={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||qu[(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=ta();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];w.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 oe&&this._instance?ga(oe,this._instance.config.custom_blocked_useragents):void 0}},Gu=G("[PostHog ExternalIntegrations]"),Lu={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ri=class{constructor(e){this._instance=e}it(e,t){var r;(r=C.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,i=>{if(i)return Gu.error("failed to load script",i);t()})}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=C.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(Lu[o],()=>{var u;(u=C.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)}),!i&&(l=C.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=C.__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),jr=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&&(C!=null&&(t=C.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=C.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=C.__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=C.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=C.__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",va=!Mu&&ne?.indexOf("MSIE")===-1&&ne?.indexOf("Mozilla")===-1,ao=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:Hl(_?.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:X&&H(X?.search)&&X.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;w.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))},lo=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=U({},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]:w.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){w.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},qr=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=Ee.LIB_VERSION,this.qr=new er,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ao(),this.SentryIntegration=ri,this.sentryIntegration=e=>function(t,r){var i=ea(t,r);return{name:Qo,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=>w.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 w.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(U({},ao(t.defaults),lo(t),{name:r,token:e})),this.config.on_xhr_error&&w.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Se.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(m=>this.ts(m),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?(w.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(w.info("Initializing extensions synchronously"),this.rs(l)),Ee.DEBUG=Ee.DEBUG||this.config.debug,Ee.DEBUG&&w.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(je()),h=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(xe,(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(m=>{var I;return!((I=t.bootstrap)==null||(I=I.featureFlags)==null||!I[m])}).reduce((m,I)=>{var k;return m[I]=((k=t.bootstrap)==null||(k=k.featureFlags)==null?void 0:k[I])||!1,m},{}),y=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlagPayloads)||{}).filter(m=>v[m]).reduce((m,I)=>{var k,x;return(k=t.bootstrap)!=null&&(k=k.featureFlagPayloads)!=null&&k[I]&&(m[I]=(x=t.bootstrap)==null||(x=x.featureFlagPayloads)==null?void 0:x[I]),m},{});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 P=this.config.get_device_id(je());this.register_once({distinct_id:P,$device_id:P},""),this.persistence.set_property(xe,"anonymous")}return V(g,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?hu(this,()=>this.ns()):this.ns(),qe(this.config._onCapture)&&this.config._onCapture!==Ti&&(w.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",m=>this.config._onCapture(m.event,m))),this.config.ip&&w.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 jr(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,du),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){w.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&&w.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!_||!_.body)return w.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,Se.GZipJS)?Se.GZipJS:A(e.supportedCompression,Se.Base64)?Se.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){w.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&X!=null&&X.hostname){var e=X.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()&&Ge(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&&(va?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:Ee.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=$o(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=[];Ge(e,a=>{a&&(t=a[0],$(t)?s.push(a):qe(a)?a.call(this):$(a)&&t==="alias"?r.push(a):$(a)&&t.indexOf("capture")!==-1&&qe(this[t])?s.push(a):i.push(a))});var o=function(a,l){Ge(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)&&(w.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=je(),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=Vl(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(io(p))||localStorage.setItem(io(p),"true"),u.$set=E({},u.$set,{[Fu({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 P=this.cs(u);if(!P)return;u=P}this.qr.emit("eventCaptured",u);var m={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(m):this.Zr.enqueue(m),u}w.critical("This capture call is ignored due to client rate limiting.")}}else w.error("No event name provided to posthog.capture")}else w.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)&&!Me(a.distinct_id)||xn(a.distinct_id))&&w.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=_u(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&&U(a,this.sessionPropsManager.getSessionProps());try{var d;this.sessionRecording&&U(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=U(a,c),e==="$pageview"&&_&&(a.title=_.title),!b(o)){var f=r.getTime()-o;a.$duration=parseFloat((f/1e3).toFixed(3))}ne&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=U({},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]}):w.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&&(w.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=U({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(w.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=$u),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 w.uninitializedWarning("posthog.identify");if(Me(e)&&(e=e.toString(),w.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()))w.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(qt)&&(this.unregister(qt),this.register({distinct_id:e}));var o=(this.persistence.get_property(xe)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(xe,"identified"),this.setPersonPropertiesForFlags(E({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=Zs(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(wr))}}else w.critical('The string "'+Mt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else w.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=Zs(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):w.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 w.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(w.info("reset"),!this.__loaded)return w.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(xe,"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(je());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(Do)?(w.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(qt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(w.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;U(this.config,lo(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);Ie(p)&&(this.config.debug=p),Ie(this.config.debug)&&(this.config.debug?(Ee.DEBUG=!0,q.H()&&q.G("ph_debug","true"),w.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(Ee.DEBUG=!1,q.H()&&q.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(xe))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(xe))==="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[qt])&&((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"?(w.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 jr(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 w.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())):w.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===Pe.GRANTED?"granted":e===Pe.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 oe?ga(oe,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),V(_,"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?(w.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=w,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 vl(e.event)?w.warn(s+". This can cause unexpected behavior."):w.info(s),null}r.properties&&!dt(r.properties)||w.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=Ie(e)&&!e,r=q.H()&&q.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]])})(qr,["identify"]);var uo;var Vr=(uo=Wt[ct]=new qr,function(){function n(){n.done||(n.done=!0,va=!1,N(Wt,function(e){e._dom_loaded()}))}_!=null&&_.addEventListener?_.readyState==="complete"?n():V(_,"DOMContentLoaded",n,{capture:!1}):g&&w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),uo);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{Vr.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{Vr.identify(e)}catch(t){console.warn("[PaymentKit Analytics] Failed to identify:",t)}}capture(e,t){try{Vr.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())}},be=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,be.capture("checkout_page_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackInputReady(){this.inputReadyTracked||(this.inputReadyTracked=!0,be.capture("checkout_input_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackSubmit(){be.capture("checkout_submit",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()})}trackSuccess(e){be.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){be.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 Vu=class extends Error{constructor(e,t){super(t);R(this,"code");this.name="PenpalError",this.code=e}},ue=Vu,zu=n=>({name:n.name,message:n.message,stack:n.stack,penpalCode:n instanceof ue?n.code:void 0}),Hu=({name:n,message:e,stack:t,penpalCode:r})=>{let i=r?new ue(r,e):new Error(e);return i.name=n,i.stack=t,i},Ku=Symbol("Reply"),Bi,ka,Bu=(ka=class{constructor(n,e){R(this,"value");R(this,"transferables");J(this,Bi,Ku);this.value=n,this.transferables=e?.transferables}},Bi=new WeakMap,ka),Wu=Bu,le="penpal",Br=n=>typeof n=="object"&&n!==null,xa=n=>typeof n=="function",Xu=n=>Br(n)&&n.namespace===le,zr=n=>n.type==="SYN",Xi=n=>n.type==="ACK1",Hi=n=>n.type==="ACK2",Pa=n=>n.type==="CALL",Sa=n=>n.type==="REPLY",Yu=n=>n.type==="DESTROY",Ca=(n,e=[])=>{let t=[];for(let r of Object.keys(n)){let i=n[r];xa(i)?t.push([...e,r]):Br(i)&&t.push(...Ca(i,[...e,r]))}return t},Ju=(n,e)=>{let t=n.reduce((r,i)=>Br(r)?r[i]:void 0,e);return xa(t)?t:void 0},ze=n=>n.join("."),ya=(n,e,t)=>({namespace:le,channel:n,type:"REPLY",callId:e,isError:!0,...t instanceof Error?{value:zu(t),isSerializedErrorInstance:!0}:{value:t}}),Zu=(n,e,t,r)=>{let i=!1,s=async o=>{if(i||!Pa(o))return;r?.(`Received ${ze(o.methodPath)}() call`,o);let{methodPath:a,args:l,id:c}=o,u,p;try{let h=Ju(a,e);if(!h)throw new ue("METHOD_NOT_FOUND",`Method \`${ze(a)}\` is not found.`);let d=await h(...l);d instanceof Wu&&(p=d.transferables,d=await d.value),u={namespace:le,channel:t,type:"REPLY",callId:c,value:d}}catch(h){u=ya(t,c,h)}if(!i)try{r?.(`Sending ${ze(a)}() reply`,u),n.sendMessage(u,p)}catch(h){throw h.name==="DataCloneError"&&(u=ya(t,c,h),r?.(`Sending ${ze(a)}() reply`,u),n.sendMessage(u)),h}};return n.addMessageHandler(s),()=>{i=!0,n.removeMessageHandler(s)}},Qu=Zu,Ia=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),ec=Symbol("CallOptions"),Wi,wa,tc=(wa=class{constructor(n){R(this,"transferables");R(this,"timeout");J(this,Wi,ec);this.transferables=n?.transferables,this.timeout=n?.timeout}},Wi=new WeakMap,wa),rc=tc,nc=new Set(["apply","call","bind"]),Ma=(n,e,t=[])=>new Proxy(t.length?()=>{}:Object.create(null),{get(r,i){if(i!=="then")return t.length&&nc.has(i)?Reflect.get(r,i):Ma(n,e,[...t,i])},apply(r,i,s){return n(t,s)}}),ma=n=>new ue("CONNECTION_DESTROYED",`Method call ${ze(n)}() failed due to destroyed connection`),ic=(n,e,t)=>{let r=!1,i=new Map,s=l=>{if(!Sa(l))return;let{callId:c,value:u,isError:p,isSerializedErrorInstance:h}=l,d=i.get(c);d&&(i.delete(c),t?.(`Received ${ze(d.methodPath)}() call`,l),p?d.reject(h?Hu(u):u):d.resolve(u))};return n.addMessageHandler(s),{remoteProxy:Ma((l,c)=>{if(r)throw ma(l);let u=Ia(),p=c[c.length-1],h=p instanceof rc,{timeout:d,transferables:f}=h?p:{},v=h?c.slice(0,-1):c;return new Promise((y,P)=>{let m=d!==void 0?window.setTimeout(()=>{i.delete(u),P(new ue("METHOD_CALL_TIMEOUT",`Method call ${ze(l)}() timed out after ${d}ms`))},d):void 0;i.set(u,{methodPath:l,resolve:y,reject:P,timeoutId:m});try{let I={namespace:le,channel:e,type:"CALL",id:u,methodPath:l,args:v};t?.(`Sending ${ze(l)}() call`,I),n.sendMessage(I,f)}catch(I){P(new ue("TRANSMISSION_FAILED",I.message))}})},t),destroy:()=>{r=!0,n.removeMessageHandler(s);for(let{methodPath:l,reject:c,timeoutId:u}of i.values())clearTimeout(u),c(ma(l));i.clear()}}},sc=ic,oc=()=>{let n,e;return{promise:new Promise((r,i)=>{n=r,e=i}),resolve:n,reject:e}},ac=oc,lc=class extends Error{constructor(n){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${n}`)}},Hr=lc,Ki="deprecated-penpal",uc=n=>Br(n)&&"penpal"in n,cc=n=>n.split("."),_a=n=>n.join("."),Ra=n=>new Hr(`Unexpected message to translate: ${JSON.stringify(n)}`),pc=n=>{if(n.penpal==="syn")return{namespace:le,channel:void 0,type:"SYN",participantId:Ki};if(n.penpal==="ack")return{namespace:le,channel:void 0,type:"ACK2"};if(n.penpal==="call")return{namespace:le,channel:void 0,type:"CALL",id:n.id,methodPath:cc(n.methodName),args:n.args};if(n.penpal==="reply")return n.resolution==="fulfilled"?{namespace:le,channel:void 0,type:"REPLY",callId:n.id,value:n.returnValue}:{namespace:le,channel:void 0,type:"REPLY",callId:n.id,isError:!0,...n.returnValueIsError?{value:n.returnValue,isSerializedErrorInstance:!0}:{value:n.returnValue}};throw Ra(n)},dc=n=>{if(Xi(n))return{penpal:"synAck",methodNames:n.methodPaths.map(_a)};if(Pa(n))return{penpal:"call",id:n.id,methodName:_a(n.methodPath),args:n.args};if(Sa(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 Ra(n)},hc=({messenger:n,methods:e,timeout:t,channel:r,log:i})=>{let s=Ia(),o,a=[],l=!1,c=Ca(e),{promise:u,resolve:p,reject:h}=ac(),d=t!==void 0?setTimeout(()=>{h(new ue("CONNECTION_TIMEOUT",`Connection timed out after ${t}ms`))},t):void 0,f=()=>{for(let x of a)x()},v=()=>{if(l)return;a.push(Qu(n,e,r,i));let{remoteProxy:x,destroy:F}=sc(n,r,i);a.push(F),clearTimeout(d),l=!0,p({remoteProxy:x,destroy:f})},y=()=>{let x={namespace:le,type:"SYN",channel:r,participantId:s};i?.("Sending handshake SYN",x);try{n.sendMessage(x)}catch(F){h(new ue("TRANSMISSION_FAILED",F.message))}},P=x=>{if(i?.("Received handshake SYN",x),x.participantId===o&&o!==Ki||(o=x.participantId,y(),!(s>o||o===Ki)))return;let O={namespace:le,channel:r,type:"ACK1",methodPaths:c};i?.("Sending handshake ACK1",O);try{n.sendMessage(O)}catch(S){h(new ue("TRANSMISSION_FAILED",S.message));return}},m=x=>{i?.("Received handshake ACK1",x);let F={namespace:le,channel:r,type:"ACK2"};i?.("Sending handshake ACK2",F);try{n.sendMessage(F)}catch(O){h(new ue("TRANSMISSION_FAILED",O.message));return}v()},I=x=>{i?.("Received handshake ACK2",x),v()},k=x=>{zr(x)&&P(x),Xi(x)&&m(x),Hi(x)&&I(x)};return n.addMessageHandler(k),a.push(()=>n.removeMessageHandler(k)),y(),u},fc=hc,gc=n=>{let e=!1,t;return(...r)=>(e||(e=!0,t=n(...r)),t)},vc=gc,ba=new WeakSet,yc=({messenger:n,methods:e={},timeout:t,channel:r,log:i})=>{if(!n)throw new ue("INVALID_ARGUMENT","messenger must be defined");if(ba.has(n))throw new ue("INVALID_ARGUMENT","A messenger can only be used for a single connection");ba.add(n);let s=[n.destroy],o=vc(c=>{if(c){let u={namespace:le,channel:r,type:"DESTROY"};try{n.sendMessage(u)}catch{}}for(let u of s)u();i?.("Connection destroyed")}),a=c=>Xu(c)&&c.channel===r;return{promise:(async()=>{try{n.initialize({log:i,validateReceivedMessage:a}),n.addMessageHandler(p=>{Yu(p)&&o(!1)});let{remoteProxy:c,destroy:u}=await fc({messenger:n,methods:e,timeout:t,channel:r,log:i});return s.push(u),c}catch(c){throw o(!0),c}})(),destroy:()=>{o(!0)}}},Aa=yc,Ue,Je,kt,wt,Ze,Ve,ae,Qe,Kr,Et,ar,lr,xt,Ea,mc=(Ea=class{constructor({remoteWindow:n,allowedOrigins:e}){J(this,Ue);J(this,Je);J(this,kt);J(this,wt);J(this,Ze);J(this,Ve,new Set);J(this,ae);J(this,Qe,!1);R(this,"initialize",({log:n,validateReceivedMessage:e})=>{ye(this,kt,n),ye(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,Ue).postMessage(n,{targetOrigin:t,transfer:e});return}if(Xi(n)||M(this,Qe)){let t=M(this,Qe)?dc(n):n,r=M(this,Et).call(this,n);M(this,Ue).postMessage(t,{targetOrigin:r,transfer:e});return}if(Hi(n)){let{port1:t,port2:r}=new MessageChannel;ye(this,ae,t),t.addEventListener("message",M(this,xt)),t.start();let i=[r,...e||[]],s=M(this,Et).call(this,n);M(this,Ue).postMessage(n,{targetOrigin:s,transfer:i});return}if(M(this,ae)){M(this,ae).postMessage(n,{transfer:e});return}throw new Hr("Port is undefined")});R(this,"addMessageHandler",n=>{M(this,Ve).add(n)});R(this,"removeMessageHandler",n=>{M(this,Ve).delete(n)});R(this,"destroy",()=>{window.removeEventListener("message",M(this,lr)),M(this,ar).call(this),M(this,Ve).clear()});J(this,Kr,n=>M(this,Je).some(e=>e instanceof RegExp?e.test(n):e===n||e==="*"));J(this,Et,n=>{if(zr(n))return"*";if(!M(this,Ze))throw new Hr("Concrete remote origin not set");return M(this,Ze)==="null"&&M(this,Je).includes("*")?"*":M(this,Ze)});J(this,ar,()=>{M(this,ae)?.removeEventListener("message",M(this,xt)),M(this,ae)?.close(),ye(this,ae,void 0)});J(this,lr,({source:n,origin:e,ports:t,data:r})=>{var i,s,o;if(n===M(this,Ue)&&(uc(r)&&((i=M(this,kt))==null||i.call(this,"Please upgrade the child window to the latest version of Penpal."),ye(this,Qe,!0),r=pc(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,Je).join(", ")}]\``);return}if(zr(r)&&(M(this,ar).call(this),ye(this,Ze,e)),Hi(r)&&!M(this,Qe)){if(ye(this,ae,t[0]),!M(this,ae))throw new Hr("No port received on ACK2");M(this,ae).addEventListener("message",M(this,xt)),M(this,ae).start()}for(let a of M(this,Ve))a(r)}});J(this,xt,({data:n})=>{var e;if((e=M(this,wt))!=null&&e.call(this,n))for(let t of M(this,Ve))t(n)});if(!n)throw new ue("INVALID_ARGUMENT","remoteWindow must be defined");ye(this,Ue,n),ye(this,Je,e?.length?e:[window.origin])}},Ue=new WeakMap,Je=new WeakMap,kt=new WeakMap,wt=new WeakMap,Ze=new WeakMap,Ve=new WeakMap,ae=new WeakMap,Qe=new WeakMap,Kr=new WeakMap,Et=new WeakMap,ar=new WeakMap,lr=new WeakMap,xt=new WeakMap,Ea),Ta=mc;var Wr=({window:n,methods:e})=>{let t=new Ta({remoteWindow:n,allowedOrigins:["*"]});return Aa({methods:e,messenger:t})};var Fa=(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 Oa={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 _c(){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 Oa.local}function $a(n){if(n==="tunnel")return _c();let t=Oa[n];if(!t)throw new Error(`Invalid environment: ${n}. Must be one of: local, tunnel, sandbox, production`);return t}var Da="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Na=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=Da[t[n]&63];return e};var bc={local:"dev",tunnel:"dev",sandbox:"stg",production:"prod"},Yi="__paymentKitRequestId__";function ja(n){let e=bc[n]||"dev",t=Na(12);return`pk_${e}_${t}`}function et(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 qa(n){return{lang:n?.lang??Zi?.lang,message:n?.message,abortEarly:n?.abortEarly??Zi?.abortEarly,abortPipeEarly:n?.abortPipeEarly??Zi?.abortPipeEarly}}var kc;function wc(n){return kc?.get(n)}var Ec;function xc(n){return Ec?.get(n)}var Pc;function Sc(n,e){return Pc?.get(n)?.get(e)}function Cc(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 tt(n,e,t,r,i){let s=i&&"input"in i?i.input:t.value,o=i?.expected??n.expects??null,a=i?.received??Cc(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??Sc(n.reference,l.lang)??(c?xc(l.lang):null)??r.message??wc(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},qa())}}}function Ga(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 Ic=/^[\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:Ic,message:n,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&tt(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&&tt(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&&tt(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&&tt(this,"length",e,t,{received:"0"}),e}}}function Mc(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}function Rc(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]:Rc(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]=Mc(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(tt(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 tt(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:tt(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 La(n,e,t){let r=n["~run"]({value:e},qa(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(rt("required"),Pt("required"),rs(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=La(t,n);return r.issues?{isSuccess:!1,errors:r.issues.reduce((s,o)=>{let a=Ga(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 nt(){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 Tc=(n,e,t)=>{let r=Jr("tunnel-x",n,{checkout_token:t,api_base_url:e});document.body.appendChild(r);let i=Fa(r,{});return{unmount:()=>{i.destroy(),document.body.removeChild(r)},connection:i}},Fc=({environment:n,secureToken:e,paymentMethods:t,cardTokenizationMode:r,vgsVaultId:i,vgsEnvironment:s,__enableAnalyticsTestMode:o})=>{let{baseUrl:a,apiBaseUrl:l}=$a(n);console.log(`[PaymentKit] v${fs} initialized (env: ${n})`);let c=et(n);console.log(`[PaymentKit] checkout_request_id: ${c}`),be.init(l,o),be.identify(e);let u=new or(e,c);u.trackPageReady();let{connection:p,unmount:h}=Tc(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};r===void 0&&(d._sessionConfigReady=fetch(`${l}/api/checkout-sessions/token/${e}`).then(m=>m.ok?m.json():null).then(m=>{if(m&&typeof m=="object"&&typeof m.card_tokenization_mode=="string"){d.cardTokenizationMode=m.card_tokenization_mode||"direct";let I=m.vgs_vault_id,k=m.vgs_environment;I&&/^tnt[a-z0-9]+$/.test(I)&&(k==="sandbox"||k==="live")?(d.vgsVaultId=I,d.vgsEnvironment=k):d.cardTokenizationMode==="vgs"&&(console.warn("[PaymentKit] Invalid VGS config from session API, falling back to direct mode"),d.cardTokenizationMode="direct")}else d.cardTokenizationMode="direct"}).catch(()=>{d.cardTokenizationMode="direct"}));let f=t.map(m=>m(d)),v=f.reduce((m,{name:I,externalFuncs:k})=>(m[I]=k,m),{});return{submit:({paymentMethod:m,fields:I,options:k,onSuccess:x,onError:F})=>{let O=f.find(({name:S})=>S===m);if(!O){F({root:"payment_method_not_found"});return}O.internalFuncs.submitPayment(I,k).then(({data:S,errors:L})=>{L?F(L):x(S)}).catch(S=>{console.error("PaymentKit:submit:catch",S),S?.response?.data?F(S.response.data):S?.message?F({root:S.message}):F({root:"unknown_error"})})},cleanup:()=>{for(let m of f)m.internalFuncs.cleanup&&m.internalFuncs.cleanup();h()},...v}},Va=Fc;var za=(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),fe(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=w({},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===Se.GZipJS){var r=Iu(function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new he(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 he(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===Se.Base64){var s=function(l){var c,u,p,h,d,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,y=0,S="",E=[];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,E[y++]=f.charAt(c)+f.charAt(u)+f.charAt(p)+f.charAt(h);while(v<l.length);switch(S=E.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,w({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)}}),oe!=null&&oe.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;oe.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)||fe(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 qn,new On,new Fn,new Nn,new Dn,new $n,new jn],ql()),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)}},se=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]}))):se.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||(se.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||se.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=V({},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=w({},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=w({},c?.metadata,{payload:d,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=f}return this.oi||(se.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=V({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(se.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=V({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(se.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:w({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(Vt)||{}),group_properties:this._instance.get_property(We)};fe(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:Se.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))se.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}se.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,E,P;$(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[wr]:u});var m=this.getFeatureFlagDetails(e),x={$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)||(x.$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&&(x.$feature_flag_reason=O),m!=null&&(E=m.metadata)!=null&&E.id&&(x.$feature_flag_id=m.metadata.id),b(m?.original_variant)&&b(m?.original_enabled)||(x.$feature_flag_original_response=b(m.original_variant)?m.original_enabled:m.original_variant),m!=null&&(P=m.metadata)!=null&&P.original_payload&&(x.$feature_flag_original_payload=m==null||(F=m.metadata)==null?void 0:F.original_payload),this._instance.capture("$feature_flag_called",x)}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 se.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:Se.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}se.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)){se.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var S={};if(d)for(var E=0;E<d.length;E++)S[d[E]]=!0;a&&a.register({[vn]:d,[ht]:S})}else{var P=d,m=f,x=h;if(o.errorsWhileComputingFlags)if(h){var F=new Set(Object.keys(h).filter(O=>{var C;return!((C=h[O])!=null&&C.failed)}));P=w({},l,Object.fromEntries(Object.entries(P).filter(O=>{var[C]=O;return F.has(C)}))),m=w({},c,Object.fromEntries(Object.entries(m||{}).filter(O=>{var[C]=O;return F.has(C)}))),x=w({},u,Object.fromEntries(Object.entries(x||{}).filter(O=>{var[C]=O;return F.has(C)})))}else P=w({},l,P),m=w({},c,m),x=w({},u,x);a&&a.register(w({[vn]:Object.keys(no(P)),[ht]:P||{},[eo]:m||{},[Vn]:x||{}},v?{[to]:v}:{},y?{[ro]:y}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),se.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return se.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=w({},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]:w({},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(We)||{};Object.keys(r).length!==0&&Object.keys(r).forEach(i=>{r[i]=w({},r[i],e[i]),delete e[i]}),this._instance.register({[We]:w({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(We)||{};this._instance.register({[We]:w({},t,{[e]:{}})})}else this._instance.unregister(We)}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,w({},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 w({},q,{W:function(o){try{var a={};try{a=me.W(o)||{}}catch{}var l=V(a,JSON.parse(q.q(o)||"{}"));return q.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{q.G(o,a,void 0,void 0,p);var h={};s.forEach(d=>{a[d]&&(h[d]=a[d])}),Object.keys(h).length&&me.G(o,h,l,c,u,p)}catch(d){q.B(d)}},V:function(o,a){try{g?.localStorage.removeItem(o),me.V(o,a)}catch(l){q.B(l)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&q.H()?q:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&W.H()?W:r==="memory"?pu:r==="cookie"?me:t.H()?t:me}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,(fe(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=V({},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(ji(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);V(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&<((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=w({},i,{appearance:w({},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()}},we=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)||(Ie(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 we.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),we.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else we.error("Cannot complete initialization: remote config is null")}Se(e,t){we.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():we.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!fe(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):(we.warn("Conversations not available yet."),null)})()}getMessages(e,t){var r=this;return pt(function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(we.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(we.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return pt(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(we.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}},Be=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)):(Be.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 Be.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void Be.warn("Remote config is disabled. Falling back to local config.");this.Te(e=>{if(!e)return Be.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){Be.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()):Be.info("__preview_remote_config is disabled. Logging config instead",e):Be.error("Failed to fetch remote config from PostHog.")}},Ei=3e3,xi=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=_e(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(w({},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]=w({},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(w({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(w({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(w({},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}},ju=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||ju,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(ji(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||je,this.ar=r||je;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*_e(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=W.W(this.ur),l=W.W(this.hr);a&&!l?this.rr=a:W.V(this.ur),W.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&&W.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&W.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?W.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()&&W.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)}},qu=["$set_once","$set"],De=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:w({},ho(e,qu),{properties:w({},e.properties,v?{$set:w({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},f?{$set_once:w({},(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&&(De.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,De.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){De.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){De.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){De.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 De.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 De.error("Error while initializing PostHog app with config id "+c,p)})};for(var{id:a,url:l}of e.siteApps)o(a)}else De.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 oe&&this._instance?va(oe,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),jr=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(qo)}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]:w({enabled:!!o},o,{networkPayloadCapture:w({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&&ne?.indexOf("MSIE")===-1&&ne?.indexOf("Mozilla")===-1,lo=n=>{var e;return w({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:X&&H(X?.search)&&X.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=V({},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}},qr=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=Ee.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(V({},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:Se.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(w({},this.config,{persistence:"sessionStorage"}),s);var o=w({},this.persistence.props),a=w({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new xi(E=>this.ts(E),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)),Ee.DEBUG=Ee.DEBUG||this.config.debug,Ee.DEBUG&&k.info("Starting in debug mode",{this:this,config:t,thisC:w({},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(je()),h=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(xe,(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(E=>{var P;return!((P=t.bootstrap)==null||(P=P.featureFlags)==null||!P[E])}).reduce((E,P)=>{var m;return E[P]=((m=t.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[P])||!1,E},{}),y=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlagPayloads)||{}).filter(E=>v[E]).reduce((E,P)=>{var m,x;return(m=t.bootstrap)!=null&&(m=m.featureFlagPayloads)!=null&&m[P]&&(E[P]=(x=t.bootstrap)==null||(x=x.featureFlagPayloads)==null?void 0:x[P]),E},{});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(je());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(xe,"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(),qe(this.config._onCapture)&&this.config._onCapture!==Ti&&(k.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",E=>this.config._onCapture(E.event,E))),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 jr(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,Se.GZipJS)?Se.GZipJS:A(e.supportedCompression,Se.Base64)?Se.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&&X!=null&&X.hostname){var e=X.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()&&Ge(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=w({},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=w({},t);o.timeout=o.timeout||6e4,o.url=Or(o.url,{_:new Date().getTime().toString(),ver:Ee.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)})(w({},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=[];Ge(e,a=>{a&&(t=a[0],$(t)?s.push(a):qe(a)?a.call(this):$(a)&&t==="alias"?r.push(a):$(a)&&t.indexOf("capture")!==-1&&qe(this[t])?s.push(a):i.push(a))});var o=function(a,l){Ge(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=je(),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=w({},u.$set,{[Ou({id:f,current_iteration:v},e===zt.SENT?"responded":"dismissed")]:!0})}else e===zt.SHOWN&&(u.$set=w({},u.$set,{[_n.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var y=w({},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 E={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(E):this.Zr.enqueue(E),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=w({},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=w({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!H(a.distinct_id)&&!Me(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&&V(a,this.sessionPropsManager.getSessionProps());try{var d;this.sessionRecording&&V(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=V(a,c),e==="$pageview"&&_&&(a.title=_.title),!b(o)){var f=r.getTime()-o;a.$duration=parseFloat((f/1e3).toFixed(3))}ne&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=V({},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=V({},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=w({},i,e),a=w({},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(Me(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(qt)&&(this.unregister(qt),this.register({distinct_id:e}));var o=(this.persistence.get_property(xe)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(xe,"identified"),this.setPersonPropertiesForFlags(w({},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(w({},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:w({},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(xe,"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(je());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(qt,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=w({},this.config);if(z(e)){var r,i,s,o,a,l,c;V(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(w({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);Ie(p)&&(this.config.debug=p),Ie(this.config.debug)&&(this.config.debug?(Ee.DEBUG=!0,q.H()&&q.G("ph_debug","true"),k.info("set_config",{config:e,oldConfig:t,newConfig:w({},this.config)})):(Ee.DEBUG=!1,q.H()&&q.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(w({},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(xe))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(xe))==="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[qt])&&((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 jr(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===Pe.GRANTED?"granted":e===Pe.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 oe?va(oe,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=Ie(e)&&!e,r=q.H()&&q.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]])})(qr,["identify"]);var co;var Ur=(co=Wt[ct]=new qr,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())}},be=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,be.capture("checkout_page_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackInputReady(){this.inputReadyTracked||(this.inputReadyTracked=!0,be.capture("checkout_input_ready",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()}))}trackSubmit(){be.capture("checkout_submit",{checkout_session_id:this.checkoutSessionId,request_id:this.requestId,elapsed_ms:this.getElapsedMs()})}trackSuccess(e){be.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){be.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}},ue=zu,Hu=n=>({name:n.name,message:n.message,stack:n.stack,penpalCode:n instanceof ue?n.code:void 0}),Ku=({name:n,message:e,stack:t,penpalCode:r})=>{let i=r?new ue(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,le="penpal",Br=n=>typeof n=="object"&&n!==null,Pa=n=>typeof n=="function",Yu=n=>Br(n)&&n.namespace===le,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},ze=n=>n.join("."),ma=(n,e,t)=>({namespace:le,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 ${ze(o.methodPath)}() call`,o);let{methodPath:a,args:l,id:c}=o,u,p;try{let h=Zu(a,e);if(!h)throw new ue("METHOD_NOT_FOUND",`Method \`${ze(a)}\` is not found.`);let d=await h(...l);d instanceof Xu&&(p=d.transferables,d=await d.value),u={namespace:le,channel:t,type:"REPLY",callId:c,value:d}}catch(h){u=ma(t,c,h)}if(!i)try{r?.(`Sending ${ze(a)}() reply`,u),n.sendMessage(u,p)}catch(h){throw h.name==="DataCloneError"&&(u=ma(t,c,h),r?.(`Sending ${ze(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 ue("CONNECTION_DESTROYED",`Method call ${ze(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 ${ze(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 E=d!==void 0?window.setTimeout(()=>{i.delete(u),S(new ue("METHOD_CALL_TIMEOUT",`Method call ${ze(l)}() timed out after ${d}ms`))},d):void 0;i.set(u,{methodPath:l,resolve:y,reject:S,timeoutId:E});try{let P={namespace:le,channel:e,type:"CALL",id:u,methodPath:l,args:v};t?.(`Sending ${ze(l)}() call`,P),n.sendMessage(P,f)}catch(P){S(new ue("TRANSMISSION_FAILED",P.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:le,channel:void 0,type:"SYN",participantId:Ki};if(n.penpal==="ack")return{namespace:le,channel:void 0,type:"ACK2"};if(n.penpal==="call")return{namespace:le,channel:void 0,type:"CALL",id:n.id,methodPath:pc(n.methodName),args:n.args};if(n.penpal==="reply")return n.resolution==="fulfilled"?{namespace:le,channel:void 0,type:"REPLY",callId:n.id,value:n.returnValue}:{namespace:le,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 ue("CONNECTION_TIMEOUT",`Connection timed out after ${t}ms`))},t):void 0,f=()=>{for(let x of a)x()},v=()=>{if(l)return;a.push(ec(n,e,r,i));let{remoteProxy:x,destroy:F}=oc(n,r,i);a.push(F),clearTimeout(d),l=!0,p({remoteProxy:x,destroy:f})},y=()=>{let x={namespace:le,type:"SYN",channel:r,participantId:s};i?.("Sending handshake SYN",x);try{n.sendMessage(x)}catch(F){h(new ue("TRANSMISSION_FAILED",F.message))}},S=x=>{if(i?.("Received handshake SYN",x),x.participantId===o&&o!==Ki||(o=x.participantId,y(),!(s>o||o===Ki)))return;let O={namespace:le,channel:r,type:"ACK1",methodPaths:c};i?.("Sending handshake ACK1",O);try{n.sendMessage(O)}catch(C){h(new ue("TRANSMISSION_FAILED",C.message));return}},E=x=>{i?.("Received handshake ACK1",x);let F={namespace:le,channel:r,type:"ACK2"};i?.("Sending handshake ACK2",F);try{n.sendMessage(F)}catch(O){h(new ue("TRANSMISSION_FAILED",O.message));return}v()},P=x=>{i?.("Received handshake ACK2",x),v()},m=x=>{zr(x)&&S(x),Xi(x)&&E(x),Hi(x)&&P(x)};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 ue("INVALID_ARGUMENT","messenger must be defined");if(ka.has(n))throw new ue("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:le,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,Ve,Je,kt,wt,Ze,Ue,ae,Qe,Kr,Et,ar,lr,xt,xa,_c=(xa=class{constructor({remoteWindow:n,allowedOrigins:e}){Z(this,Ve);Z(this,Je);Z(this,kt);Z(this,wt);Z(this,Ze);Z(this,Ue,new Set);Z(this,ae);Z(this,Qe,!1);R(this,"initialize",({log:n,validateReceivedMessage:e})=>{ye(this,kt,n),ye(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,Ve).postMessage(n,{targetOrigin:t,transfer:e});return}if(Xi(n)||M(this,Qe)){let t=M(this,Qe)?hc(n):n,r=M(this,Et).call(this,n);M(this,Ve).postMessage(t,{targetOrigin:r,transfer:e});return}if(Hi(n)){let{port1:t,port2:r}=new MessageChannel;ye(this,ae,t),t.addEventListener("message",M(this,xt)),t.start();let i=[r,...e||[]],s=M(this,Et).call(this,n);M(this,Ve).postMessage(n,{targetOrigin:s,transfer:i});return}if(M(this,ae)){M(this,ae).postMessage(n,{transfer:e});return}throw new Hr("Port is undefined")});R(this,"addMessageHandler",n=>{M(this,Ue).add(n)});R(this,"removeMessageHandler",n=>{M(this,Ue).delete(n)});R(this,"destroy",()=>{window.removeEventListener("message",M(this,lr)),M(this,ar).call(this),M(this,Ue).clear()});Z(this,Kr,n=>M(this,Je).some(e=>e instanceof RegExp?e.test(n):e===n||e==="*"));Z(this,Et,n=>{if(zr(n))return"*";if(!M(this,Ze))throw new Hr("Concrete remote origin not set");return M(this,Ze)==="null"&&M(this,Je).includes("*")?"*":M(this,Ze)});Z(this,ar,()=>{M(this,ae)?.removeEventListener("message",M(this,xt)),M(this,ae)?.close(),ye(this,ae,void 0)});Z(this,lr,({source:n,origin:e,ports:t,data:r})=>{var i,s,o;if(n===M(this,Ve)&&(cc(r)&&((i=M(this,kt))==null||i.call(this,"Please upgrade the child window to the latest version of Penpal."),ye(this,Qe,!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,Je).join(", ")}]\``);return}if(zr(r)&&(M(this,ar).call(this),ye(this,Ze,e)),Hi(r)&&!M(this,Qe)){if(ye(this,ae,t[0]),!M(this,ae))throw new Hr("No port received on ACK2");M(this,ae).addEventListener("message",M(this,xt)),M(this,ae).start()}for(let a of M(this,Ue))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,Ue))t(n)});if(!n)throw new ue("INVALID_ARGUMENT","remoteWindow must be defined");ye(this,Ve,n),ye(this,Je,e?.length?e:[window.origin])}},Ve=new WeakMap,Je=new WeakMap,kt=new WeakMap,wt=new WeakMap,Ze=new WeakMap,Ue=new WeakMap,ae=new WeakMap,Qe=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 ja=(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 qa(n){let e=kc[n]||"dev",t=ja(12);return`pk_${e}_${t}`}function et(n){if(typeof window<"u"&&window[Yi])return window[Yi];let e=qa(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 tt(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)&&tt(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&&tt(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&&tt(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&&tt(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"&&(tt(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 tt(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:tt(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(rt("required"),Pt("required"),rs(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,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 nt(){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=et(n);console.log(`[PaymentKit] checkout_request_id: ${c}`),be.init(l,o),be.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 E=`${l}/api/checkout-sessions/token/${e}`;console.log(`[PaymentKit] cardTokenizationMode not provided \u2014 auto-detecting from session API: ${E}`),d._sessionConfigReady=fetch(E).then(P=>P.ok?P.json():(console.warn(`[PaymentKit] Session config fetch failed with status ${P.status}`),null)).then(P=>{if(P&&typeof P=="object"&&typeof P.card_tokenization_mode=="string"){d.cardTokenizationMode=P.card_tokenization_mode||"direct",console.log(`[PaymentKit] Session config detected \u2014 cardTokenizationMode: ${d.cardTokenizationMode}`);let m=P.vgs_vault_id,x=P.vgs_environment;m&&/^tnt[a-z0-9]+$/.test(m)&&(x==="sandbox"||x==="live")?(d.vgsVaultId=m,d.vgsEnvironment=x,console.log(`[PaymentKit] VGS config valid \u2014 vaultId: ${m}, environment: ${x}`)):d.cardTokenizationMode==="vgs"&&(console.warn(`[PaymentKit] Invalid VGS config from session API (vaultId: ${m}, env: ${x}), 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(P=>{console.error("[PaymentKit] Session config fetch error \u2014 falling back to direct mode:",P),d.cardTokenizationMode="direct"})}else console.log(`[PaymentKit] cardTokenizationMode explicitly set: ${r}`);let f=t.map(E=>E(d)),v=f.reduce((E,{name:P,externalFuncs:m})=>(E[P]=m,E),{});return{submit:({paymentMethod:E,fields:P,options:m,onSuccess:x,onError:F})=>{let O=f.find(({name:C})=>C===E);if(!O){F({root:"payment_method_not_found"});return}O.internalFuncs.submitPayment(P,m).then(({data:C,errors:L})=>{L?F(L):x(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 E of f)E.internalFuncs.cleanup&&E.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=`
|
|
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
|
|
64
|
-
<script src="https://js.stripe.com/v3/"><\/script>`);return new window.Stripe(n)},Dc=async n=>{let{clientSecret:e,stripePk:t}=n,r=await $c(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}},Nc=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 Dc(n);case"airwallex_3ds":return Nc(n);default:return{success:!1,error:`Unknown next action type: ${n.type}`}}};var jc="https://js.verygoodvault.com/vgs-collect/3.2.1/vgs-collect.js",ur=null;function Ka(){return ur||(ur=new Promise((n,e)=>{if(typeof window<"u"&&window.VGSCollect){n();return}let t=document.createElement("script");t.src=jc,t.async=!0,t.onload=()=>n(),t.onerror=()=>{ur=null,e(new Error("Failed to load VGS Collect JS"))},document.head.appendChild(t)}),ur)}function Ba(n,e){if(!window.VGSCollect)throw new Error("VGS Collect JS not loaded. Call loadVgsCollectScript() first.");return window.VGSCollect.create(n,e,()=>{})}function Wa(n,e,t,r){let i=t??{height:"46px","font-size":"1rem",color:"#18181b","font-family":"ui-sans-serif, system-ui, sans-serif"},s=n.cardNumberField(e.pan,{placeholder:"Card number",validations:["required","validCardNumber"],css:i}),o=n.cardExpirationDateField(e.exp,{placeholder:"MM / YY",validations:["required","validCardExpirationDate"],css:i}),a=n.cardCVCField(e.cvc,{placeholder:"123",validations:["required","validCardSecurityCode"],css:i});if(r){let l=[[s,"card_pan"],[o,"card_exp"],[a,"card_cvc"]];for(let[c,u]of l){let p=r[u];p&&(c.on("focus",()=>p(!0)),c.on("blur",()=>p(!1)))}}}var qc=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}=qc(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}=a;return{mount:h=>{let d,f,v=!1,y=()=>{if(v)return;if(n.cardTokenizationMode==="vgs"&&n.vgsVaultId&&n.vgsEnvironment){if(u&&(n.vgsFocusCallbacks||(n.vgsFocusCallbacks={}),n.vgsFocusCallbacks[o]=u),o==="card_pan"){let x=n.vgsVaultId,F=n.vgsEnvironment,O=15e3,S;Promise.race([Ka(),new Promise((L,K)=>{S=setTimeout(()=>K(new Error("VGS Collect CDN load timed out")),O)})]).finally(()=>clearTimeout(S)).then(()=>{if(v)return;let L=Ba(x,F);if(v){L.unmount();return}n.vgsForm=L;let K=l?Object.fromEntries(Object.entries(l).map(([B,ce])=>[B.replace(/([A-Z])/g,"-$1").toLowerCase(),ce])):void 0,re=h.replace(/card[-_]pan/,B=>B.replace("pan","exp")),Z=h.replace(/card[-_]pan/,B=>B.replace("pan","cvc"));if(re===h||Z===h){let B=`[PaymentKit] Failed to derive exp/cvc selectors from "${h}". Expected a selector containing "card-pan" or "card_pan".`;console.error(B),c?.();return}Wa(L,{pan:h,exp:re,cvc:Z},K,n.vgsFocusCallbacks),s.trackInputReady(),c?.()}).catch(L=>{console.error("[PaymentKit] Failed to load VGS Collect script. Card input will not be available:",L),c?.()})}o!=="card_pan"&&c?.(),d=()=>{o==="card_pan"&&n.vgsForm&&(n.vgsForm.unmount(),n.vgsForm=void 0)};return}let m=Ua(h),I={checkout_token:i,api_base_url:t};l&&(I.style=JSON.stringify(l));let k=Jr(o.replace("_","-"),e,I);f=()=>{r[o]?.destroy(),m.removeChild(k),n.cardInputConnections[o]=void 0},m.appendChild(k),k.onload=()=>{o==="card_pan"&&s.trackInputReady();let x=za(k,{onLoaded:c||(()=>{}),onFocusChange:u||(()=>{})});n.cardInputConnections[o]=x}};return n._sessionConfigReady?n._sessionConfigReady.then(y):y(),{unmount:()=>{v=!0,d?.(),f?.()}}}}}},Uc=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){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:nt()}},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})},Vc=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 Vc(s,i),l=3e4,c,u=await Promise.race([new Promise((P,m)=>{t.createCard({auth:a,data:{cardholder:{}}},(I,k)=>P(k),I=>m(I))}),new Promise((P,m)=>{c=setTimeout(()=>m(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:nt()}}),{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:Uc(e),cleanup:()=>{e.vgsForm&&(e.vgsForm.unmount(),e.vgsForm=void 0);for(let t of Object.values(e.cardInputConnections))t?.destroy();e.cardInputConnections={}}}}}),Xa=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 as(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 as(`${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:nt(),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 Ja(n,e,t,r,i){let s={mock_scenario:r};t&&(s.google_pay_token=t);let o=await as(`${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 as(`${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 os(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 Ja(n,e,void 0,t,r);return os(i,e)}var Ya=5;async function np(n,e,t,r,i){let s=0,o=await Ja(n,e,t,r,i);for(;o.charge_status==="pending"&&o.next_action&&s<Ya;){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?os(l,e):{errors:{google_pay:l.error_message||a.error||"3DS authentication failed"}}}return s>=Ya?{errors:{google_pay:"Too many authentication attempts. Please try again."}}:os(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=et(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 Za=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=et(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:nt()})});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 P=await y.json();if(P.completed){if(clearInterval(v),d.close(),P.status==="success"){let m=P.result||{id:h,checkoutAttemptId:h,checkoutSessionId:s,state:"checkout_succeeded"};f({data:m})}else f({errors:{paypal:P.error||`PayPal checkout ${P.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()}}}}),Qa=ap;var lp=Va,up={card:Xa,googlePay:Za,paypal:Qa};return cl(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",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}},jc=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 jc(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){let i=t??{height:"46px","font-size":"1rem",color:"#18181b","font-family":"ui-sans-serif, system-ui, sans-serif"},s=n.cardNumberField(e.pan,{placeholder:"Card number",validations:["required","validCardNumber"],css:i}),o=n.cardExpirationDateField(e.exp,{placeholder:"MM / YY",validations:["required","validCardExpirationDate"],css:i}),a=n.cardCVCField(e.cvc,{placeholder:"123",validations:["required","validCardSecurityCode"],css:i});if(r){let l=[[s,"card_pan"],[o,"card_exp"],[a,"card_cvc"]];for(let[c,u]of l){let p=r[u];p&&(c.on("focus",()=>p(!0)),c.on("blur",()=>p(!1)))}}}var qc=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}=qc(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}=a;return{mount:h=>{let d,f,v=!1,y=()=>{if(v)return;let S=n.cardTokenizationMode==="vgs";if(console.log(`[PaymentKit] card.doMount(${o}) \u2014 mode: ${n.cardTokenizationMode}, vgsVaultId: ${n.vgsVaultId??"unset"}, vgsEnvironment: ${n.vgsEnvironment??"unset"}`),S&&n.vgsVaultId&&n.vgsEnvironment){if(u&&(n.vgsFocusCallbacks||(n.vgsFocusCallbacks={}),n.vgsFocusCallbacks[o]=u),o==="card_pan"){let x=n.vgsVaultId,F=n.vgsEnvironment;console.log(`[PaymentKit] VGS mode active \u2014 loading VGS Collect CDN for vault ${x} (${F})...`);let O=15e3,C;Promise.race([Ba(),new Promise((L,K)=>{C=setTimeout(()=>{console.warn(`[PaymentKit] VGS Collect CDN load timed out after ${O/1e3}s`),K(new Error("VGS Collect CDN load timed out"))},O)})]).finally(()=>clearTimeout(C)).then(()=>{if(v)return;console.log("[PaymentKit] VGS Collect CDN loaded \u2014 initializing form...");let L=Wa(x,F);if(v){L.unmount();return}n.vgsForm=L;let K=l?Object.fromEntries(Object.entries(l).map(([B,ce])=>[B.replace(/([A-Z])/g,"-$1").toLowerCase(),ce])):void 0,Q=h.replace(/card[-_]pan/,B=>B.replace("pan","exp")),J=h.replace(/card[-_]pan/,B=>B.replace("pan","cvc"));if(Q===h||J===h){let B=`[PaymentKit] Failed to derive exp/cvc selectors from "${h}". Expected a selector containing "card-pan" or "card_pan".`;console.error(B),c?.();return}console.log(`[PaymentKit] Creating VGS card fields \u2014 pan: ${h}, exp: ${Q}, cvc: ${J}`),Xa(L,{pan:h,exp:Q,cvc:J},K,n.vgsFocusCallbacks),console.log("[PaymentKit] VGS card fields created successfully"),s.trackInputReady(),c?.()}).catch(L=>{console.error("[PaymentKit] Failed to load VGS Collect script. Card input will not be available:",L),c?.()})}o!=="card_pan"&&c?.(),d=()=>{o==="card_pan"&&n.vgsForm&&(n.vgsForm.unmount(),n.vgsForm=void 0)};return}S&&console.warn(`[PaymentKit] VGS mode requested but config incomplete (vgsVaultId: ${n.vgsVaultId??"unset"}, vgsEnvironment: ${n.vgsEnvironment??"unset"}) \u2014 using direct mode`);let E=Ua(h),P={checkout_token:i,api_base_url:t};l&&(P.style=JSON.stringify(l));let m=Jr(o.replace("_","-"),e,P);f=()=>{r[o]?.destroy(),E.removeChild(m),n.cardInputConnections[o]=void 0},E.appendChild(m),m.onload=()=>{o==="card_pan"&&s.trackInputReady();let x=Ha(m,{onLoaded:c||(()=>{}),onFocusChange:u||(()=>{})});n.cardInputConnections[o]=x}};return n._sessionConfigReady?n._sessionConfigReady.then(y):y(),{unmount:()=>{v=!0,d?.(),f?.()}}}}}},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:nt()}},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,E)=>{t.createCard({auth:a,data:{cardholder:{}}},(P,m)=>S(m),P=>E(P))}),new Promise((S,E)=>{c=setTimeout(()=>E(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:nt()}}),{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:nt(),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=et(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=et(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:nt()})});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 E=S.result||{id:h,checkoutAttemptId:h,checkoutSessionId:s,state:"checkout_succeeded"};f({data:E})}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);})();
|
|
65
65
|
//# sourceMappingURL=paymentkit.min.js.map
|