@payment-kit-js/vanilla 0.3.0 → 0.4.1

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.
Files changed (67) hide show
  1. package/dist/airwallex-google-pay-adapter-BCmTZip5.mjs +167 -0
  2. package/dist/airwallex-google-pay-adapter-BCmTZip5.mjs.map +1 -0
  3. package/dist/airwallex-google-pay-adapter-Be2Af4N9.d.mts +140 -0
  4. package/dist/airwallex-google-pay-adapter-Be2Af4N9.d.mts.map +1 -0
  5. package/dist/cdn/paymentkit.js +5768 -83
  6. package/dist/cdn/paymentkit.js.map +4 -4
  7. package/dist/cdn/paymentkit.min.js +58 -3
  8. package/dist/cdn/paymentkit.min.js.map +4 -4
  9. package/dist/{connect-card-DO2EJxu6.mjs → connect-card-BrtCmsjz.mjs} +1 -1
  10. package/dist/{connect-card-DO2EJxu6.mjs.map → connect-card-BrtCmsjz.mjs.map} +1 -1
  11. package/dist/{connect-card-C582hcWw.d.mts → connect-card-DTfXuTsW.d.mts} +1 -1
  12. package/dist/{connect-card-C582hcWw.d.mts.map → connect-card-DTfXuTsW.d.mts.map} +1 -1
  13. package/dist/connect-tunnel-x-BhVAej5Q.mjs.map +1 -1
  14. package/dist/{connect-tunnel-x-B7iMQ7DX.d.mts → connect-tunnel-x-Dxcg5Y7Y.d.mts} +6 -5
  15. package/dist/connect-tunnel-x-Dxcg5Y7Y.d.mts.map +1 -0
  16. package/dist/index.d.mts +3 -3
  17. package/dist/index.d.mts.map +1 -1
  18. package/dist/index.mjs +337 -5
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/next-action-handlers-BZs04hYb.mjs +271 -0
  21. package/dist/next-action-handlers-BZs04hYb.mjs.map +1 -0
  22. package/dist/payment-methods/airwallex-google-pay-adapter.d.mts +2 -0
  23. package/dist/payment-methods/airwallex-google-pay-adapter.mjs +3 -0
  24. package/dist/payment-methods/apple-pay.d.mts +78 -0
  25. package/dist/payment-methods/apple-pay.d.mts.map +1 -0
  26. package/dist/payment-methods/apple-pay.mjs +188 -0
  27. package/dist/payment-methods/apple-pay.mjs.map +1 -0
  28. package/dist/payment-methods/card.d.mts +3 -3
  29. package/dist/payment-methods/card.d.mts.map +1 -1
  30. package/dist/payment-methods/card.mjs +40 -12
  31. package/dist/payment-methods/card.mjs.map +1 -1
  32. package/dist/payment-methods/google-pay.d.mts +25 -7
  33. package/dist/payment-methods/google-pay.d.mts.map +1 -1
  34. package/dist/payment-methods/google-pay.mjs +165 -30
  35. package/dist/payment-methods/google-pay.mjs.map +1 -1
  36. package/dist/payment-methods/next-action-handlers.d.mts.map +1 -1
  37. package/dist/payment-methods/next-action-handlers.mjs +1 -1
  38. package/dist/payment-methods/paypal.d.mts +3 -3
  39. package/dist/payment-methods/paypal.d.mts.map +1 -1
  40. package/dist/payment-methods/paypal.mjs +8 -3
  41. package/dist/payment-methods/paypal.mjs.map +1 -1
  42. package/dist/payment-methods/stripe-apple-pay-adapter.d.mts +2 -0
  43. package/dist/payment-methods/stripe-apple-pay-adapter.mjs +3 -0
  44. package/dist/payment-methods/stripe-google-pay-adapter.d.mts +1 -1
  45. package/dist/payment-methods/stripe-google-pay-adapter.mjs +1 -1
  46. package/dist/penpal/connect-card.d.mts +1 -1
  47. package/dist/penpal/connect-card.mjs +1 -1
  48. package/dist/penpal/connect-tunnel-x.d.mts +1 -1
  49. package/dist/stripe-apple-pay-adapter-Bg7nCy3P.mjs +313 -0
  50. package/dist/stripe-apple-pay-adapter-Bg7nCy3P.mjs.map +1 -0
  51. package/dist/stripe-apple-pay-adapter-Bq3f1mqv.d.mts +141 -0
  52. package/dist/stripe-apple-pay-adapter-Bq3f1mqv.d.mts.map +1 -0
  53. package/dist/{stripe-google-pay-adapter-DMDArVp2.mjs → stripe-google-pay-adapter-DjrgDYWe.mjs} +1 -1
  54. package/dist/{stripe-google-pay-adapter-DMDArVp2.mjs.map → stripe-google-pay-adapter-DjrgDYWe.mjs.map} +1 -1
  55. package/dist/{stripe-google-pay-adapter-DUUB46SG.d.mts → stripe-google-pay-adapter-xktEycOD.d.mts} +1 -1
  56. package/dist/{stripe-google-pay-adapter-DUUB46SG.d.mts.map → stripe-google-pay-adapter-xktEycOD.d.mts.map} +1 -1
  57. package/dist/types-CPuloCtF.d.mts +129 -0
  58. package/dist/types-CPuloCtF.d.mts.map +1 -0
  59. package/dist/{utils-h0dxplHy.mjs → utils-Dgyk7RkM.mjs} +40 -2
  60. package/dist/utils-Dgyk7RkM.mjs.map +1 -0
  61. package/package.json +9 -3
  62. package/dist/connect-tunnel-x-B7iMQ7DX.d.mts.map +0 -1
  63. package/dist/next-action-handlers-DTsWjUIA.mjs +0 -53
  64. package/dist/next-action-handlers-DTsWjUIA.mjs.map +0 -1
  65. package/dist/types-DsVMq4jZ.d.mts +0 -64
  66. package/dist/types-DsVMq4jZ.d.mts.map +0 -1
  67. package/dist/utils-h0dxplHy.mjs.map +0 -1
@@ -1,10 +1,65 @@
1
1
  /**
2
- * PaymentKit.js v0.3.0
2
+ * PaymentKit.js v0.4.1
3
3
  * https://paymentkit.com
4
4
  *
5
5
  * @license MIT
6
6
  */
7
7
 
8
- "use strict";var PaymentKit=(()=>{var W=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var ve=e=>{throw TypeError(e)};var en=(e,n,t)=>n in e?W(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var nn=(e,n)=>{for(var t in n)W(e,t,{get:n[t],enumerable:!0})},tn=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of Ye(n))!Qe.call(e,s)&&s!==t&&W(e,s,{get:()=>n[s],enumerable:!(r=Ze(n,s))||r.enumerable});return e};var rn=e=>tn(W({},"__esModule",{value:!0}),e);var d=(e,n,t)=>en(e,typeof n!="symbol"?n+"":n,t),ge=(e,n,t)=>n.has(e)||ve("Cannot "+t);var f=(e,n,t)=>(ge(e,n,"read from private field"),t?t.call(e):n.get(e)),g=(e,n,t)=>n.has(e)?ve("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(e):n.set(e,t),_=(e,n,t,r)=>(ge(e,n,"write to private field"),r?r.call(e,t):n.set(e,t),t);var gt={};nn(gt,{PaymentMethods:()=>vt,default:()=>dt});var ke="0.3.0";var on=class extends Error{constructor(n,t){super(t);d(this,"code");this.name="PenpalError",this.code=n}},E=on,un=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof E?e.code:void 0}),an=({name:e,message:n,stack:t,penpalCode:r})=>{let s=r?new E(r,n):new Error(n);return s.name=e,s.stack=t,s},ln=Symbol("Reply"),oe,Ee,cn=(Ee=class{constructor(e,n){d(this,"value");d(this,"transferables");g(this,oe,ln);this.value=e,this.transferables=n?.transferables}},oe=new WeakMap,Ee),pn=cn,x="penpal",Y=e=>typeof e=="object"&&e!==null,Ce=e=>typeof e=="function",fn=e=>Y(e)&&e.namespace===x,B=e=>e.type==="SYN",ae=e=>e.type==="ACK1",se=e=>e.type==="ACK2",Se=e=>e.type==="CALL",Me=e=>e.type==="REPLY",yn=e=>e.type==="DESTROY",Ae=(e,n=[])=>{let t=[];for(let r of Object.keys(e)){let s=e[r];Ce(s)?t.push([...n,r]):Y(s)&&t.push(...Ae(s,[...n,r]))}return t},hn=(e,n)=>{let t=e.reduce((r,s)=>Y(r)?r[s]:void 0,n);return Ce(t)?t:void 0},A=e=>e.join("."),be=(e,n,t)=>({namespace:x,channel:e,type:"REPLY",callId:n,isError:!0,...t instanceof Error?{value:un(t),isSerializedErrorInstance:!0}:{value:t}}),mn=(e,n,t,r)=>{let s=!1,i=async o=>{if(s||!Se(o))return;r?.(`Received ${A(o.methodPath)}() call`,o);let{methodPath:p,args:u,id:l}=o,c,y;try{let a=hn(p,n);if(!a)throw new E("METHOD_NOT_FOUND",`Method \`${A(p)}\` is not found.`);let h=await a(...u);h instanceof pn&&(y=h.transferables,h=await h.value),c={namespace:x,channel:t,type:"REPLY",callId:l,value:h}}catch(a){c=be(t,l,a)}if(!s)try{r?.(`Sending ${A(p)}() reply`,c),e.sendMessage(c,y)}catch(a){throw a.name==="DataCloneError"&&(c=be(t,l,a),r?.(`Sending ${A(p)}() reply`,c),e.sendMessage(c)),a}};return e.addMessageHandler(i),()=>{s=!0,e.removeMessageHandler(i)}},dn=mn,Re=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),vn=Symbol("CallOptions"),ue,_e,gn=(_e=class{constructor(e){d(this,"transferables");d(this,"timeout");g(this,ue,vn);this.transferables=e?.transferables,this.timeout=e?.timeout}},ue=new WeakMap,_e),kn=gn,bn=new Set(["apply","call","bind"]),Te=(e,n,t=[])=>new Proxy(t.length?()=>{}:Object.create(null),{get(r,s){if(s!=="then")return t.length&&bn.has(s)?Reflect.get(r,s):Te(e,n,[...t,s])},apply(r,s,i){return e(t,i)}}),Pe=e=>new E("CONNECTION_DESTROYED",`Method call ${A(e)}() failed due to destroyed connection`),Pn=(e,n,t)=>{let r=!1,s=new Map,i=u=>{if(!Me(u))return;let{callId:l,value:c,isError:y,isSerializedErrorInstance:a}=u,h=s.get(l);h&&(s.delete(l),t?.(`Received ${A(h.methodPath)}() call`,u),y?h.reject(a?an(c):c):h.resolve(c))};return e.addMessageHandler(i),{remoteProxy:Te((u,l)=>{if(r)throw Pe(u);let c=Re(),y=l[l.length-1],a=y instanceof kn,{timeout:h,transferables:v}=a?y:{},b=a?l.slice(0,-1):l;return new Promise((k,C)=>{let P=h!==void 0?window.setTimeout(()=>{s.delete(c),C(new E("METHOD_CALL_TIMEOUT",`Method call ${A(u)}() timed out after ${h}ms`))},h):void 0;s.set(c,{methodPath:u,resolve:k,reject:C,timeoutId:P});try{let I={namespace:x,channel:n,type:"CALL",id:c,methodPath:u,args:b};t?.(`Sending ${A(u)}() call`,I),e.sendMessage(I,v)}catch(I){C(new E("TRANSMISSION_FAILED",I.message))}})},t),destroy:()=>{r=!0,e.removeMessageHandler(i);for(let{methodPath:u,reject:l,timeoutId:c}of s.values())clearTimeout(c),l(Pe(u));s.clear()}}},wn=Pn,xn=()=>{let e,n;return{promise:new Promise((r,s)=>{e=r,n=s}),resolve:e,reject:n}},En=xn,_n=class extends Error{constructor(e){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${e}`)}},J=_n,ie="deprecated-penpal",In=e=>Y(e)&&"penpal"in e,Cn=e=>e.split("."),we=e=>e.join("."),De=e=>new J(`Unexpected message to translate: ${JSON.stringify(e)}`),Sn=e=>{if(e.penpal==="syn")return{namespace:x,channel:void 0,type:"SYN",participantId:ie};if(e.penpal==="ack")return{namespace:x,channel:void 0,type:"ACK2"};if(e.penpal==="call")return{namespace:x,channel:void 0,type:"CALL",id:e.id,methodPath:Cn(e.methodName),args:e.args};if(e.penpal==="reply")return e.resolution==="fulfilled"?{namespace:x,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:x,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw De(e)},Mn=e=>{if(ae(e))return{penpal:"synAck",methodNames:e.methodPaths.map(we)};if(Se(e))return{penpal:"call",id:e.id,methodName:we(e.methodPath),args:e.args};if(Me(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw De(e)},An=({messenger:e,methods:n,timeout:t,channel:r,log:s})=>{let i=Re(),o,p=[],u=!1,l=Ae(n),{promise:c,resolve:y,reject:a}=En(),h=t!==void 0?setTimeout(()=>{a(new E("CONNECTION_TIMEOUT",`Connection timed out after ${t}ms`))},t):void 0,v=()=>{for(let m of p)m()},b=()=>{if(u)return;p.push(dn(e,n,r,s));let{remoteProxy:m,destroy:R}=wn(e,r,s);p.push(R),clearTimeout(h),u=!0,y({remoteProxy:m,destroy:v})},k=()=>{let m={namespace:x,type:"SYN",channel:r,participantId:i};s?.("Sending handshake SYN",m);try{e.sendMessage(m)}catch(R){a(new E("TRANSMISSION_FAILED",R.message))}},C=m=>{if(s?.("Received handshake SYN",m),m.participantId===o&&o!==ie||(o=m.participantId,k(),!(i>o||o===ie)))return;let H={namespace:x,channel:r,type:"ACK1",methodPaths:l};s?.("Sending handshake ACK1",H);try{e.sendMessage(H)}catch(Je){a(new E("TRANSMISSION_FAILED",Je.message));return}},P=m=>{s?.("Received handshake ACK1",m);let R={namespace:x,channel:r,type:"ACK2"};s?.("Sending handshake ACK2",R);try{e.sendMessage(R)}catch(H){a(new E("TRANSMISSION_FAILED",H.message));return}b()},I=m=>{s?.("Received handshake ACK2",m),b()},de=m=>{B(m)&&C(m),ae(m)&&P(m),se(m)&&I(m)};return e.addMessageHandler(de),p.push(()=>e.removeMessageHandler(de)),k(),c},Rn=An,Tn=e=>{let n=!1,t;return(...r)=>(n||(n=!0,t=e(...r)),t)},Dn=Tn,xe=new WeakSet,On=({messenger:e,methods:n={},timeout:t,channel:r,log:s})=>{if(!e)throw new E("INVALID_ARGUMENT","messenger must be defined");if(xe.has(e))throw new E("INVALID_ARGUMENT","A messenger can only be used for a single connection");xe.add(e);let i=[e.destroy],o=Dn(l=>{if(l){let c={namespace:x,channel:r,type:"DESTROY"};try{e.sendMessage(c)}catch{}}for(let c of i)c();s?.("Connection destroyed")}),p=l=>fn(l)&&l.channel===r;return{promise:(async()=>{try{e.initialize({log:s,validateReceivedMessage:p}),e.addMessageHandler(y=>{yn(y)&&o(!1)});let{remoteProxy:l,destroy:c}=await Rn({messenger:e,methods:n,timeout:t,channel:r,log:s});return i.push(c),l}catch(l){throw o(!0),l}})(),destroy:()=>{o(!0)}}},Oe=On,S,T,N,q,D,M,w,O,Z,G,U,V,$,Ie,Fn=(Ie=class{constructor({remoteWindow:e,allowedOrigins:n}){g(this,S);g(this,T);g(this,N);g(this,q);g(this,D);g(this,M,new Set);g(this,w);g(this,O,!1);d(this,"initialize",({log:e,validateReceivedMessage:n})=>{_(this,N,e),_(this,q,n),window.addEventListener("message",f(this,V))});d(this,"sendMessage",(e,n)=>{if(B(e)){let t=f(this,G).call(this,e);f(this,S).postMessage(e,{targetOrigin:t,transfer:n});return}if(ae(e)||f(this,O)){let t=f(this,O)?Mn(e):e,r=f(this,G).call(this,e);f(this,S).postMessage(t,{targetOrigin:r,transfer:n});return}if(se(e)){let{port1:t,port2:r}=new MessageChannel;_(this,w,t),t.addEventListener("message",f(this,$)),t.start();let s=[r,...n||[]],i=f(this,G).call(this,e);f(this,S).postMessage(e,{targetOrigin:i,transfer:s});return}if(f(this,w)){f(this,w).postMessage(e,{transfer:n});return}throw new J("Port is undefined")});d(this,"addMessageHandler",e=>{f(this,M).add(e)});d(this,"removeMessageHandler",e=>{f(this,M).delete(e)});d(this,"destroy",()=>{window.removeEventListener("message",f(this,V)),f(this,U).call(this),f(this,M).clear()});g(this,Z,e=>f(this,T).some(n=>n instanceof RegExp?n.test(e):n===e||n==="*"));g(this,G,e=>{if(B(e))return"*";if(!f(this,D))throw new J("Concrete remote origin not set");return f(this,D)==="null"&&f(this,T).includes("*")?"*":f(this,D)});g(this,U,()=>{f(this,w)?.removeEventListener("message",f(this,$)),f(this,w)?.close(),_(this,w,void 0)});g(this,V,({source:e,origin:n,ports:t,data:r})=>{var s,i,o;if(e===f(this,S)&&(In(r)&&((s=f(this,N))==null||s.call(this,"Please upgrade the child window to the latest version of Penpal."),_(this,O,!0),r=Sn(r)),!!((i=f(this,q))!=null&&i.call(this,r)))){if(!f(this,Z).call(this,n)){(o=f(this,N))==null||o.call(this,`Received a message from origin \`${n}\` which did not match allowed origins \`[${f(this,T).join(", ")}]\``);return}if(B(r)&&(f(this,U).call(this),_(this,D,n)),se(r)&&!f(this,O)){if(_(this,w,t[0]),!f(this,w))throw new J("No port received on ACK2");f(this,w).addEventListener("message",f(this,$)),f(this,w).start()}for(let p of f(this,M))p(r)}});g(this,$,({data:e})=>{var n;if((n=f(this,q))!=null&&n.call(this,e))for(let t of f(this,M))t(e)});if(!e)throw new E("INVALID_ARGUMENT","remoteWindow must be defined");_(this,S,e),_(this,T,n?.length?n:[window.origin])}},S=new WeakMap,T=new WeakMap,N=new WeakMap,q=new WeakMap,D=new WeakMap,M=new WeakMap,w=new WeakMap,O=new WeakMap,Z=new WeakMap,G=new WeakMap,U=new WeakMap,V=new WeakMap,$=new WeakMap,Ie),Fe=Fn;var Q=({window:e,methods:n})=>{let t=new Fe({remoteWindow:e,allowedOrigins:["*"]});return Oe({methods:n,messenger:t})};var je=(e,n)=>Q({window:e.contentWindow,methods:n});var ne=class ne{constructor(n,t){d(this,"penpalConn");d(this,"_methods");this.penpalConn=n,this._methods=t}get publicEndpoints(){let n={get:(t,r)=>async(...s)=>await this._methods.queryPublicEndpoint(r,s[0],s[1])};return new Proxy({},n)}destroy(){this.penpalConn.destroy()}};d(ne,"createFromPenpalConnection",async n=>{let t=await n.promise;return new ne(n,t)});var ee=ne;var jn={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 Ne(e){let t=jn[e];if(!t)throw new Error(`Invalid environment: ${e}. Must be one of: local, sandbox, production`);return t}var le;function qe(e){return{lang:e?.lang??le?.lang,message:e?.message,abortEarly:e?.abortEarly??le?.abortEarly,abortPipeEarly:e?.abortPipeEarly??le?.abortPipeEarly}}var Nn;function qn(e){return Nn?.get(e)}var Gn;function $n(e){return Gn?.get(e)}var Kn;function zn(e,n){return Kn?.get(e)?.get(n)}function Ln(e){let n=typeof e;return n==="string"?`"${e}"`:n==="number"||n==="bigint"||n==="boolean"?`${e}`:n==="object"||n==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":n}function F(e,n,t,r,s){let i=s&&"input"in s?s.input:t.value,o=s?.expected??e.expects??null,p=s?.received??Ln(i),u={kind:e.kind,type:e.type,input:i,expected:o,received:p,message:`Invalid ${n}: ${o?`Expected ${o} but r`:"R"}eceived ${p}`,requirement:e.requirement,path:s?.path,issues:s?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind==="schema",c=s?.message??e.message??zn(e.reference,u.lang)??(l?$n(u.lang):null)??r.message??qn(u.lang);c!==void 0&&(u.message=typeof c=="function"?c(u):c),l&&(t.typed=!1),t.issues?t.issues.push(u):t.issues=[u]}function ce(e){return{version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},qe())}}}function Ge(e){if(e.path){let n="";for(let t of e.path)if(typeof t.key=="string"||typeof t.key=="number")n?n+=`.${t.key}`:n+=t.key;else return null;return n}return null}var Xn=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function pe(e){return{kind:"validation",type:"email",reference:pe,expects:null,async:!1,requirement:Xn,message:e,"~run"(n,t){return n.typed&&!this.requirement.test(n.value)&&F(this,"email",n,t),n}}}function fe(e,n){return{kind:"validation",type:"max_length",reference:fe,async:!1,expects:`<=${e}`,requirement:e,message:n,"~run"(t,r){return t.typed&&t.value.length>this.requirement&&F(this,"length",t,r,{received:`${t.value.length}`}),t}}}function ye(e,n){return{kind:"validation",type:"min_length",reference:ye,async:!1,expects:`>=${e}`,requirement:e,message:n,"~run"(t,r){return t.typed&&t.value.length<this.requirement&&F(this,"length",t,r,{received:`${t.value.length}`}),t}}}function K(e){return{kind:"validation",type:"non_empty",reference:K,async:!1,expects:"!0",message:e,"~run"(n,t){return n.typed&&n.value.length===0&&F(this,"length",n,t,{received:"0"}),n}}}function Un(e,n,t){return typeof e.fallback=="function"?e.fallback(n,t):e.fallback}function Vn(e,n,t){return typeof e.default=="function"?e.default(n,t):e.default}function he(e,n){return{kind:"schema",type:"object",reference:he,expects:"Object",async:!1,entries:e,message:n,get"~standard"(){return ce(this)},"~run"(t,r){let s=t.value;if(s&&typeof s=="object"){t.typed=!0,t.value={};for(let i in this.entries){let o=this.entries[i];if(i in s||(o.type==="exact_optional"||o.type==="optional"||o.type==="nullish")&&o.default!==void 0){let p=i in s?s[i]:Vn(o),u=o["~run"]({value:p},r);if(u.issues){let l={type:"object",origin:"value",input:s,key:i,value:p};for(let c of u.issues)c.path?c.path.unshift(l):c.path=[l],t.issues?.push(c);if(t.issues||(t.issues=u.issues),r.abortEarly){t.typed=!1;break}}u.typed||(t.typed=!1),t.value[i]=u.value}else if(o.fallback!==void 0)t.value[i]=Un(o);else if(o.type!=="exact_optional"&&o.type!=="optional"&&o.type!=="nullish"&&(F(this,"key",t,r,{input:void 0,expected:`"${i}"`,path:[{type:"object",origin:"key",input:s,key:i,value:s[i]}]}),r.abortEarly))break}}else F(this,"type",t,r);return t}}}function j(e){return{kind:"schema",type:"string",reference:j,expects:"string",async:!1,message:e,get"~standard"(){return ce(this)},"~run"(n,t){return typeof n.value=="string"?n.typed=!0:F(this,"type",n,t),n}}}function z(...e){return{...e[0],pipe:e,get"~standard"(){return ce(this)},"~run"(n,t){for(let r of e)if(r.kind!=="metadata"){if(n.issues&&(r.kind==="schema"||r.kind==="transformation")){n.typed=!1;break}(!n.issues||!t.abortEarly&&!t.abortPipeEarly)&&(n=r["~run"](n,t))}return n}}}function $e(e,n,t){let r=e["~run"]({value:n},qe(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var me=async(e,n={})=>{let t=he({customer_name:z(j("required"),K("required"),ye(4,"invalid"),fe(40,"invalid")),customer_email:z(j("required"),K("required"),pe("invalid")),customer_country:z(j("required"),K("required")),customer_zip_code:n.optionalZipCode?z(j("required")):z(j("required"),K("required"))}),r=$e(t,e);return r.issues?{isSuccess:!1,errors:r.issues.reduce((i,o)=>{let p=Ge(o);return i[p]=o.kind==="schema"?"required":o.message,i},{})}:{isSuccess:!0}};var Ke=e=>{let n=document.querySelector(e);if(!n)throw new Error(`Cannot find element with selector: ${e}`);return n},L=e=>e,te=(e,n,t)=>{let r=document.createElement("iframe"),i=new URLSearchParams(t).toString();return r.src=`${n}/embeds/v1/${e}${i?`?${i}`:""}`,Object.assign(r.style,{width:"100%",height:"100%",border:"none"}),r};function X(){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 Wn=(e,n,t)=>{let r=te("tunnel-x",e,{checkout_token:t,api_base_url:n});document.body.appendChild(r);let s=je(r,{});return{unmount:()=>{s.destroy(),document.body.removeChild(r)},connection:s}},Bn=({environment:e,secureToken:n,paymentMethods:t})=>{let{baseUrl:r,apiBaseUrl:s}=Ne(e);console.log(`[PaymentKit] v${ke} initialized (env: ${e})`);let{connection:i,unmount:o}=Wn(r,s,n),p={baseUrl:r,apiBaseUrl:s,secureToken:n,tunnelXConnection:i},u=t.map(a=>a(p)),l=u.reduce((a,{name:h,externalFuncs:v})=>(a[h]=v,a),{});return{submit:({paymentMethod:a,fields:h,options:v,onSuccess:b,onError:k})=>{let C=u.find(({name:P})=>P===a);if(!C){k({root:"payment_method_not_found"});return}C.internalFuncs.submitPayment(h,v).then(({data:P,errors:I})=>{I?k(I):b(P)}).catch(P=>{console.error("PaymentKit:submit:catch",P),P?.response?.data?k(P.response.data):P?.message?k({root:P.message}):k({root:"unknown_error"})})},cleanup:()=>{for(let a of u)a.internalFuncs.cleanup&&a.internalFuncs.cleanup();o()},...l}},ze=Bn;var Le=(e,n)=>Q({window:e.contentWindow,methods:n});var Jn=e=>new Promise(n=>setTimeout(n,e)),Xe=()=>"Stripe"in window,Zn=async e=>{for(let t=0;t<10&&!Xe();t++)await Jn(500);if(!Xe())throw new Error(`Stripe.js not loaded. Add this script tag to your HTML <head>:
9
- <script src="https://js.stripe.com/v3/"><\/script>`);return new window.Stripe(e)},Yn=async e=>{console.log("3DS authentication required, loading Stripe...");let{clientSecret:n,stripePk:t}=e,r=await Zn(t),{error:s}=await r.confirmCardPayment(n);return s?(console.error("3DS authentication failed:",s),{success:!1,error:s.message||"3DS authentication failed"}):(console.log("3DS authentication completed"),{success:!0})},Ue=async e=>{switch(e.type){case"stripe_3ds":return Yn(e);default:return{success:!1,error:`Unknown next action type: ${e.type}`}}};var Qn=e=>{let n=e.trim(),t=n.indexOf(" ");return t===-1?{firstName:n}:{firstName:n.substring(0,t),lastName:n.substring(t+1).trim()||void 0}},et=e=>{let{firstName:n,lastName:t}=Qn(e.customer_name);return{email:e.customer_email||void 0,firstName:n,lastName:t,billingAddress:e.customer_country||e.customer_zip_code?{country:e.customer_country||void 0,zipCode:e.customer_zip_code||void 0}:void 0}},nt=e=>{let{baseUrl:n,apiBaseUrl:t,cardInputConnections:r,secureToken:s}=e;return(i,o)=>{let{style:p,onLoaded:u,onFocusChange:l}=o;return{mount:y=>{let a=Ke(y),h={checkout_token:s,api_base_url:t};p&&(h.style=JSON.stringify(p));let v=te(i.replace("_","-"),n,h);return a.appendChild(v),v.onload=()=>{let k=Le(v,{onLoaded:u||(()=>{}),onFocusChange:l||(()=>{})});e.cardInputConnections[i]=k},{unmount:()=>{r[i]?.destroy(),a.removeChild(v),e.cardInputConnections[i]=void 0}}}}}},tt=e=>async t=>{let r=await ee.createFromPenpalConnection(e.tunnelXConnection),s=await st(e),i=await me(t);if(!(s.isSuccess&&i.isSuccess))return{errors:{...s.errors,...i.errors}};if(!e.cardSetupIntentId){let y=await r.publicEndpoints.createCardSetupIntent({checkoutToken:e.secureToken});e.cardSetupIntentId=y.cardSetupIntentId}let o=await rt(e);if(!o.isSuccess)return{errors:o.errors};let p=await r.publicEndpoints.getCardSetupIntent({cardSetupIntentId:e.cardSetupIntentId,checkoutToken:e.secureToken});if(!p.isCardAllSet){let y={};return p.isCardPanSet||(y.card_pan="required"),p.isCardExpSet||(y.card_exp="required"),p.isCardCvcSet||(y.card_cvc="required"),{errors:y}}console.log("Card setup intent is set \u2705",p),console.log("Fields",t);let u=await r.publicEndpoints.cardCheckout({checkoutToken:e.secureToken,publicCardCheckoutRequest:{cardSetupIntentId:e.cardSetupIntentId,customerInfo:et(t),fraudMetadata:X()}});console.log("Card checkout result:",u);let l=5,c=0;for(;u.nextAction&&c<l;){c++,console.log(`Handling user action ${c}/${l}...`);let y=await Ue(u.nextAction);console.log("User action completed, verifying checkout...");let a=await r.publicEndpoints.cardCheckoutVerify({checkoutToken:e.secureToken});if(a.nextAction){y.success?console.log("Another user action required, continuing loop..."):console.log("3DS failed but cascade triggered new action, continuing loop..."),u=a;continue}return y.success?(console.log("Card checkout verified \u2705",a),{data:a}):(console.log("3DS authentication failed, checkout concluded:",a),{errors:{root:y.error}})}return c>=l?(console.error("Max user actions exceeded"),{errors:{root:"Too many authentication attempts. Please try again."}}):(console.log("Card checkout completed \u2705",u),{data:u})},rt=async e=>{let n={},{cardSetupIntentId:t,cardInputConnections:r}=e,s=Object.entries(r).map(async([i,o])=>{let p=i,l=await(await o.promise).onSubmit(t||"");"error"in l&&(n[p]=l.error)});return await Promise.allSettled(s),{errors:n,isSuccess:Object.keys(n).length===0}},st=async e=>{let n={},{cardInputConnections:t}=e,r=Object.entries(t).map(async([s,i])=>{let o=s;if(!i){n[o]="penpal_not_connected";return}let u=await(await i.promise).onValidate();u&&(n[o]=u)});return await Promise.allSettled(r),{errors:n,isSuccess:Object.keys(n).length===0}},it=L(e=>{let n={...e,cardInputConnections:{}};return{name:"card",externalFuncs:{createElement:nt(n)},internalFuncs:{submitPayment:tt(n),cleanup:()=>{for(let t of Object.values(n.cardInputConnections))t?.destroy();n.cardInputConnections={}}}}}),Ve=it;var re=class{constructor(n){d(this,"stripe",null);d(this,"paymentRequest",null);d(this,"mockScenario");this.mockScenario=n??"none"}initialize(n){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(n);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(n){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] createPaymentRequest called",n),!this.stripe)throw new Error("Stripe not initialized");this.paymentRequest=this.stripe.paymentRequest(n),console.log("[GooglePay] paymentRequest created");return}case"success":case"cancelled":{console.log("[MockGooglePay] createPaymentRequest called",n);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 n=await this.paymentRequest.canMakePayment(),t=n?.googlePay??!1;return console.log("[GooglePay] canMakePayment result:",{result:n,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(n=>{this.paymentRequest.on("paymentmethod",t=>{console.log("[GooglePay] showPaymentSheet: paymentmethod event",{paymentMethodId:t.paymentMethod.id}),n({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"),n({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(n=>setTimeout(n,500)),{success:!0,paymentMethodId:"pm_mock_123456789",complete:n=>console.log(`[MockGooglePay] complete: ${n}`)};case"cancelled":return console.log("[MockGooglePay] showPaymentSheet: cancelled"),await new Promise(n=>setTimeout(n,500)),{success:!1,cancelled:!0}}}async confirmCardSetup(n,t){switch(this.mockScenario){case"none":{if(console.log("[GooglePay] confirmCardSetup called",{clientSecret:`${n.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(n,{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:n,paymentMethodId:t}),{success:!0};case"cancelled":throw new Error("confirmCardSetup should not be called when scenario is Cancelled")}}};async function He(e,n){let t=await fetch(e,n);if(!t.ok){let r=`Request failed (${t.status})`;try{r=(await t.json()).detail||r}catch{r=t.statusText||r}return{error:r}}return{data:await t.json()}}function ot(e){return e?.processorId?!e?.customerInfo?.first_name||!e?.customerInfo?.last_name?{customer_name:"Customer first and last name are required"}:null:{processor_id:"Processor ID is required"}}function ut(e){return e&&e!=="none"?e:void 0}async function at(e,n,t,r){return He(`${e}/api/checkout/${n}/google-pay/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processor_id:t.processorId,customer_info:t.customerInfo,fraud_metadata:X(),mock_scenario:r})})}function lt(e,n,t){let r=new re(t);if(!r.initialize(e))return{error:'Stripe.js not loaded. Add <script src="https://js.stripe.com/v3/"><\/script> to your page.'};let s={country:n.country,currency:n.currency.toLowerCase(),total:{label:"Total",amount:n.amount},requestPayerName:!0,requestPayerEmail:!0};return console.log("[GooglePay] PaymentRequest config:",s),r.createPaymentRequest(s),{adapter:r}}async function ct(e,n){let t=await e.canMakePayment();if(console.log("[GooglePay] canMakePayment result:",t),!t)return{success:!1,error:"Google Pay not available on this device"};let r=await e.showPaymentSheet();if(!r.success)return"cancelled"in r&&r.cancelled?{success:!1,error:"Google Pay cancelled by user"}:{success:!1,error:"error"in r?r.error:"Unknown error"};let s=await e.confirmCardSetup(n,r.paymentMethodId);return s.success?(r.complete("success"),{success:!0}):(r.complete("fail"),{success:!1,error:s.error})}async function pt(e,n,t){let r=await He(`${e}/api/checkout/${n}/google-pay/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mock_scenario:t})});if(r.error||!r.data)return{errors:{google_pay:r.error||"Failed to confirm payment"}};let s=r.data;return s.charge_status==="success"?{data:{id:s.transaction_id,checkoutAttemptId:s.checkout_attempt_id,checkoutSessionId:n,state:"checkout_succeeded"}}:{errors:{google_pay:s.error_message||"Payment failed"}}}var ft=e=>async(t,r)=>{let{apiBaseUrl:s,secureToken:i}=e,o=r,p=ot(o);if(p)return{errors:p};try{let u=ut(o.mockScenario),l=await at(s,i,o,u);if(l.error||!l.data)return{errors:{google_pay:l.error||"Failed to start Google Pay"}};let{adapter:c,error:y}=lt(l.data.stripe_pk,l.data,o.mockScenario);if(!c)return{errors:{google_pay:y}};let a=await ct(c,l.data.client_secret);return a.success?await pt(s,i,u):{errors:{google_pay:a.error}}}catch(u){return{errors:{google_pay:`Google Pay error: ${u}`}}}},yt=L(e=>({name:"google_pay",externalFuncs:{},internalFuncs:{submitPayment:ft(e),cleanup:()=>{}}}));var We=yt;var ht=e=>async(t,r)=>{let{apiBaseUrl:s,secureToken:i}=e,o=r;if(!o?.processorId)return{errors:{processor_id:"Processor ID is required"}};if(!o?.customerInfo?.first_name||!o?.customerInfo?.last_name)return{errors:{customer_name:"Customer first and last name are required"}};try{let p=await fetch(`${s}/api/checkout/${i}/paypal/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processor_id:o.processorId,customer_info:o.customerInfo,fraud_metadata:X()})});if(!p.ok){let a=`Failed to start PayPal checkout (${p.status})`;try{a=(await p.json()).detail||a}catch{a=p.statusText||a}return{errors:{paypal:a}}}let{approval_url:u,popup_token:l,checkout_attempt_id:c}=await p.json(),y=window.open(u,"PayPal","width=600,height=700");return y?(e.popup=y,new Promise(a=>{let h=setInterval(async()=>{try{let v=await fetch(`${s}/api/checkout/${i}/popup/status?popup_token=${l}`);if(!v.ok){clearInterval(h),y.close(),a({errors:{paypal:"Failed to check PayPal status"}});return}let b=await v.json();if(b.completed){if(clearInterval(h),y.close(),b.status==="success"){let k=b.result||{id:c,checkoutAttemptId:c,checkoutSessionId:i,state:"checkout_succeeded"};a({data:k})}else a({errors:{paypal:b.error||`PayPal checkout ${b.status}`}});return}if(y.closed){clearInterval(h),a({errors:{paypal:"PayPal popup closed by user"}});return}}catch(v){clearInterval(h),y.close(),a({errors:{paypal:`Polling error: ${v}`}})}},2e3);e.pollInterval=h})):{errors:{paypal:"Failed to open PayPal popup. Please allow popups for this site."}}}catch(p){return{errors:{paypal:`PayPal checkout error: ${p}`}}}},mt=L(e=>{let n={...e};return{name:"paypal",externalFuncs:{},internalFuncs:{submitPayment:ht(n),cleanup:()=>{n.pollInterval&&clearInterval(n.pollInterval),n.popup&&!n.popup.closed&&n.popup.close()}}}}),Be=mt;var dt=ze,vt={card:Ve,googlePay:We,paypal:Be};return rn(gt);})();
8
+ "use strict";var PaymentKit=(()=>{var ur=Object.defineProperty;var Ja=Object.getOwnPropertyDescriptor;var Za=Object.getOwnPropertyNames;var Qa=Object.prototype.hasOwnProperty;var cs=n=>{throw TypeError(n)};var el=(n,e,t)=>e in n?ur(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var tl=(n,e)=>{for(var t in e)ur(n,t,{get:e[t],enumerable:!0})},rl=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Za(e))!Qa.call(n,i)&&i!==t&&ur(n,i,{get:()=>e[i],enumerable:!(r=Ja(e,i))||r.enumerable});return n};var nl=n=>rl(ur({},"__esModule",{value:!0}),n);var A=(n,e,t)=>el(n,typeof e!="symbol"?e+"":e,t),ps=(n,e,t)=>e.has(n)||cs("Cannot "+t);var C=(n,e,t)=>(ps(n,e,"read from private field"),t?t.call(n):e.get(n)),B=(n,e,t)=>e.has(n)?cs("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),ve=(n,e,t,r)=>(ps(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t);var ep={};tl(ep,{PaymentMethods:()=>Qc,default:()=>Zc});var ds="0.4.1";var Ct=class{constructor(){A(this,"events",[]);A(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 f=typeof window<"u"?window:void 0,K=typeof globalThis<"u"?globalThis:f;typeof self>"u"&&(K.self=K),typeof File>"u"&&(K.File=function(){});var lo=Array.prototype,hs=lo.forEach,fs=lo.indexOf,re=K?.navigator,m=K?.document,Z=K?.location,bn=K?.fetch,kn=K!=null&&K.XMLHttpRequest&&"withCredentials"in new K.XMLHttpRequest?K.XMLHttpRequest:void 0,gs=K?.AbortController,J=re?.userAgent,S=f??{},xe={DEBUG:!1,LIB_VERSION:"1.336.2"};function vs(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 ct(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(l){vs(s,r,i,o,a,"next",l)}function a(l){vs(s,r,i,o,a,"throw",l)}o(void 0)})}}function k(){return k=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},k.apply(null,arguments)}function uo(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 sl=["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"],ys=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return sl.concat(e).some(r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1})},ol=["$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 R(n,e){return n.indexOf(e)!==-1}var Lr=function(n){return n.trim()},wn=function(n){return n.replace(/^\$/,"")},al=Array.isArray,co=Object.prototype,po=co.hasOwnProperty,Gr=co.toString,F=al||function(n){return Gr.call(n)==="[object Array]"},Le=n=>typeof n=="function",z=n=>n===Object(n)&&!F(n),pt=n=>{if(z(n)){for(var e in n)if(po.call(n,e))return!1;return!0}return!1},_=n=>n===void 0,H=n=>Gr.call(n)=="[object String]",xn=n=>H(n)&&n.trim().length===0,de=n=>n===null,T=n=>_(n)||de(n),Me=n=>Gr.call(n)=="[object Number]"&&n==n,lt=n=>Me(n)&&n>0,Ce=n=>Gr.call(n)==="[object Boolean]",ll=n=>n instanceof FormData,ul=n=>R(ol,n);function En(n){return n===null||typeof n!="object"}function yr(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function ho(n){return!_(Event)&&function(e,t){try{return e instanceof t}catch{return!1}}(n,Event)}var cl=[!0,"true",1,"1","yes"],rn=n=>R(cl,n),pl=[!1,"false",0,"0","no"];function me(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),me(i||t,e,t,r))}var Pn=class{constructor(e){this.t={},this.i=e.i,this.o=me(e.bucketSize,0,100,e.h),this.m=me(e.refillRate,0,this.o,e.h),this.$=me(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={}}},le="Mobile",mr="iOS",Ie="Android",Xt="Tablet",fo=Ie+" "+Xt,go="iPad",vo="Apple",yo=vo+" Watch",Yt="Safari",gt="BlackBerry",mo="Samsung",_o=mo+"Browser",bo=mo+" Internet",Xe="Chrome",dl=Xe+" OS",ko=Xe+" "+mr,Fi="Internet Explorer",wo=Fi+" "+le,Oi="Opera",hl=Oi+" Mini",$i="Edge",xo="Microsoft "+$i,ht="Firefox",Eo=ht+" "+mr,Jt="Nintendo",Zt="PlayStation",ft="Xbox",Po=Ie+" "+le,So=le+" "+Yt,qt="Windows",Sn=qt+" Phone",ms="Nokia",In="Ouya",Io="Generic",fl=Io+" "+le.toLowerCase(),Co=Io+" "+Xt.toLowerCase(),Cn="Konqueror",X="(\\d+(\\.\\d+)?)",nn=new RegExp("Version/"+X),gl=new RegExp(ft,"i"),vl=new RegExp(Zt+" \\w+","i"),yl=new RegExp(Jt+" \\w+","i"),Di=new RegExp(gt+"|PlayBook|BB10","i"),ml={"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"},cr,_s,sn,_l=(n,e)=>e&&R(e,vo)||function(t){return R(t,Yt)&&!R(t,Xe)&&!R(t,Ie)}(n),Mo=function(n,e){return e=e||"",R(n," OPR/")&&R(n,"Mini")?hl:R(n," OPR/")?Oi:Di.test(n)?gt:R(n,"IE"+le)||R(n,"WPDesktop")?wo:R(n,_o)?bo:R(n,$i)||R(n,"Edg/")?xo:R(n,"FBIOS")?"Facebook "+le:R(n,"UCWEB")||R(n,"UCBrowser")?"UC Browser":R(n,"CriOS")?ko:R(n,"CrMo")||R(n,Xe)?Xe:R(n,Ie)&&R(n,Yt)?Po:R(n,"FxiOS")?Eo:R(n.toLowerCase(),Cn.toLowerCase())?Cn:_l(n,e)?R(n,le)?So:Yt:R(n,ht)?ht:R(n,"MSIE")||R(n,"Trident/")?Fi:R(n,"Gecko")?ht:""},bl={[wo]:[new RegExp("rv:"+X)],[xo]:[new RegExp($i+"?\\/"+X)],[Xe]:[new RegExp("("+Xe+"|CrMo)\\/"+X)],[ko]:[new RegExp("CriOS\\/"+X)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+X)],[Yt]:[nn],[So]:[nn],[Oi]:[new RegExp("(Opera|OPR)\\/"+X)],[ht]:[new RegExp(ht+"\\/"+X)],[Eo]:[new RegExp("FxiOS\\/"+X)],[Cn]:[new RegExp("Konqueror[:/]?"+X,"i")],[gt]:[new RegExp(gt+" "+X),nn],[Po]:[new RegExp("android\\s"+X,"i")],[bo]:[new RegExp(_o+"\\/"+X)],[Fi]:[new RegExp("(rv:|MSIE )"+X)],Mozilla:[new RegExp("rv:"+X)]},kl=function(n,e){var t=Mo(n,e),r=bl[t];if(_(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},bs=[[new RegExp(ft+"; "+ft+" (.*?)[);]","i"),n=>[ft,n&&n[1]||""]],[new RegExp(Jt,"i"),[Jt,""]],[new RegExp(Zt,"i"),[Zt,""]],[Di,[gt,""]],[new RegExp(qt,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Sn,""];if(new RegExp(le).test(e)&&!/IEMobile\b/.test(e))return[qt+" "+le,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=ml[r]||"";return/arm/i.test(e)&&(i="RT"),[qt,i]}return[qt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[mr,e.join(".")]}return[mr,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=_(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+Ie+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Ie+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Ie,e.join(".")]}return[Ie,""]}],[/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/,[dl,""]],[/Linux|debian/i,["Linux",""]]],ks=function(n){return yl.test(n)?Jt:vl.test(n)?Zt:gl.test(n)?ft:new RegExp(In,"i").test(n)?In:new RegExp("("+Sn+"|WPDesktop)","i").test(n)?Sn:/iPad/.test(n)?go:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?yo:Di.test(n)?gt:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(ms,"i").test(n)?ms:/(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(le).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)?Ie:fo:new RegExp("(pda|"+le+")","i").test(n)?fl:new RegExp(Xt,"i").test(n)&&!new RegExp(Xt+" pc","i").test(n)?Co:""},wl=n=>n instanceof Error;function xl(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return sn&&t.length===_s||(_s=t.length,sn=t.reduce((r,i)=>{cr||(cr={});var s=cr[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,cr[i]=[c,u];break}}return r},{})),sn}}var Mn=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 ct(function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&F(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)),k({},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 ct(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,k({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:xl(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 k({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},vt="?";function Rn(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?vt:t,in_app:!0};return _(r)||(s.lineno=r),_(i)||(s.colno=i),s}var Ro=(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]:vt,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},El=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Pl=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Sl=/\((\S*)(?::(\d+))(?::(\d+))\)/,Il=(n,e)=>{var t=El.exec(n);if(t){var[,r,i,s]=t;return Rn(e,r,vt,+i,+s)}var o=Pl.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Sl.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=Ro(o[1]||vt,o[2]);return Rn(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Cl=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ml=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Rl=(n,e)=>{var t=Cl.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=Ml.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]||vt;return[s,i]=Ro(s,i),Rn(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},ws=/\(error: (.*)\)/,xs=50;function Al(){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=ws.test(c)?c.replace(ws,"$1"):c;if(!u.match(/\S*Error: /)){for(var p of t){var d=p(u,n);if(d){o.push(d);break}}if(o.length>=xs)break}}}return function(h){if(!h.length)return[];var g=Array.from(h);return g.reverse(),g.slice(0,xs).map(v=>{return k({},v,{filename:v.filename||(y=g,y[y.length-1]||{}).filename,function:v.function||vt});var y})}(o)}}("web:javascript",Il,Rl)}var An=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 yr(e,"DOMException")}isDOMError(e){return yr(e,"DOMError")}},Tn=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}},Fn=class{constructor(){}match(e){return yr(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}}},Tl=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,On=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(Tl);return i&&(t=i[1],r=i[2]),[t,r]}},Fl=["fatal","error","warning","log","info","debug"];function Ao(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 $n=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 ho(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: "+Ao(e)}isSeverityLevel(e){return H(e)&&!xn(e)&&Fl.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(wl(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Dn=class{match(e){return ho(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Ao(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Nn=class{match(e){return En(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 yr(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return En(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(En(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}},To=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(f&&(xe.DEBUG||S.POSTHOG_DEBUG||t)&&!_(f.console)&&f.console){for(var s=("__rrweb_original__"in f.console[i])?f.console[i].__rrweb_original__:f.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)=>To(n+" "+i,s)};return r},b=To("[PostHog.js]"),L=b.createLogger,Ol=L("[ExternalScriptsLoader]"),Es=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return Ol.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=m?.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(!m)return t("document not found");var l=m.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")m.head.appendChild(l);else{var c,u=m.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):m.body.appendChild(l)}};m!=null&&m.body?a():m?.addEventListener("DOMContentLoaded",a)};S.__PosthogExtensions__=S.__PosthogExtensions__||{},S.__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);Es(n,s,t)},S.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);Es(n,r,t)};var _r={};function Ge(n,e,t){if(F(n)){if(hs&&n.forEach===hs)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)===_r)return}}}function $(n,e,t){if(!T(n)){if(F(n))return Ge(n,e,t);if(ll(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===_r)return}else for(var i in n)if(po.call(n,i)&&e.call(t,n[i],i)===_r)return}}var j=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},mt=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 gr(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 Ps=function(n){try{return n()}catch{return}},$l=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){b.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),b.critical(i)}}},Ni=function(n){var e={};return $(n,function(t,r){(H(t)&&t.length>0||Me(t))&&(e[r]=t)}),e};function Dl(n,e){return t=n,r=s=>H(s)&&!de(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),F(o)?(l=[],Ge(o,c=>{l.push(s(c))})):(l={},$(o,(c,u)=>{i.has(c)||(l[u]=s(c,u))})),l);var l}(t);var t,r,i}var Nl=["herokuapp.com","vercel.app","netlify.app"];function ql(n){var e=n?.hostname;if(!H(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of Nl)if(t===r)return!1;return!0}function Fo(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 Oo="$people_distinct_id",Lt="__alias",Gt="__timers",Ss="$autocapture_disabled_server_side",Ln="$heatmaps_enabled_server_side",Is="$exception_capture_enabled_server_side",Gn="$error_tracking_suppression_rules",Cs="$error_tracking_capture_extension_exceptions",Ms="$web_vitals_enabled_server_side",$o="$dead_clicks_enabled_server_side",Rs="$product_tours_enabled_server_side",As="$web_vitals_allowed_metrics",on="$session_recording_remote_config",br="$sesid",Do="$session_is_sampled",dt="$enabled_feature_flags",jt="$early_access_features",jn="$feature_flag_details",Ut="$stored_person_properties",We="$stored_group_properties",Un="$surveys",kr="$flag_call_reported",Ee="$user_state",zn="$client_session_props",Hn="$capture_rate_limit",Vn="$initial_campaign_params",Kn="$initial_referrer_info",wr="$initial_person_info",xr="$epp",No="__POSTHOG_TOOLBAR__",Mt="$posthog_cookieless",Ll=[Oo,Lt,"__cmpns",Gt,"$session_recording_enabled_server_side",Ln,br,dt,Gn,Ee,jt,jn,We,Ut,Un,kr,zn,Hn,Vn,Kn,xr,wr,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function Ts(n){return n instanceof Element&&(n.id===No||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function jr(n){return!!n&&n.nodeType===1}function je(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function qo(n){return!!n&&n.nodeType===3}function Lo(n){return!!n&&n.nodeType===11}function qi(n){return n?Lr(n).split(/\s+/):[]}function Fs(n){var e=f?.location.href;return!!(e&&n&&n.some(t=>e.match(t)))}function Er(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 Go(n){return T(n)?null:Lr(n).split(/(\s+)/).filter(e=>Qt(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function tr(n){var e="";return Bn(n)&&!Vo(n)&&n.childNodes&&n.childNodes.length&&$(n.childNodes,function(t){var r;qo(t)&&t.textContent&&(e+=(r=Go(t.textContent))!==null&&r!==void 0?r:"")}),Lr(e)}function jo(n){return _(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var Li=["a","button","form","input","select","textarea","label"];function Uo(n,e){if(_(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 zo(n){var e=n.parentNode;return!(!e||!jr(e))&&e}var Gl=["next","previous","prev",">","<"],Os=10,$s=[".ph-no-rageclick",".ph-no-capture"];function jl(n,e){if(!f||Gi(n))return!1;var t,r,i;if(Ce(e)?(t=!!e&&$s,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:$s,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=Ho(n,!1);return!function(o,a){if(o===!1||_(o))return!1;var l;if(o===!0)l=Gl;else{if(!F(o))return!1;if(o.length>Os)return b.error("[PostHog] content_ignorelist array cannot exceed "+Os+" 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(d=>u.includes(d)||p.includes(d))})}(r,s.map(o=>{var a;return{safeText:tr(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}}))&&!Uo(s,t)}var Gi=n=>!n||je(n,"html")||!jr(n),Ho=(n,e)=>{if(!f||Gi(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!je(i,"body");)if(Lo(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=zo(i);if(!s)break;if(e||Li.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=f.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),i=s}return{parentIsUsefulElement:t,targetElementList:r}};function Ul(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!f||Gi(n)||(s=t)!=null&&s.url_allowlist&&!Fs(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Fs(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some(g=>e.type===g))return!1}var{parentIsUsefulElement:u,targetElementList:p}=Ho(n,r);if(!function(g,v){var y=v?.element_allowlist;if(_(y))return!0;var x,P=function(w){if(y.some(E=>w.tagName.toLowerCase()===E))return{v:!0}};for(var I of g)if(x=P(I))return x.v;return!1}(p,t)||!Uo(p,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var d=f.getComputedStyle(n);if(d&&d.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var h=n.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(i||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(e.type)>=0;default:return u?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Li.indexOf(h)>-1||n.getAttribute("contenteditable")==="true")}}function Bn(n){for(var e=n;e.parentNode&&!je(e,"body");e=e.parentNode){var t=Er(e);if(R(t,"ph-sensitive")||R(t,"ph-no-capture"))return!1}if(R(Er(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 Vo(n){return!!(je(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||je(n,"select")||je(n,"textarea")||n.getAttribute("contenteditable")==="true")}var Ko="(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})",zl=new RegExp("^(?:"+Ko+")$"),Hl=new RegExp(Ko),Bo="\\d{3}-?\\d{2}-?\\d{4}",Vl=new RegExp("^("+Bo+")$"),Kl=new RegExp("("+Bo+")");function Qt(n,e){return e===void 0&&(e=!0),!(T(n)||H(n)&&(n=Lr(n),(e?zl:Hl).test((n||"").replace(/[- ]/g,""))||(e?Vl:Kl).test(n)))}function Wo(n){var e=tr(n);return Qt(e=(e+" "+Xo(n)).trim())?e:""}function Xo(n){var e="";return n&&n.childNodes&&n.childNodes.length&&$(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+" "+Xo(t)).trim())}catch(s){b.error("[AutoCapture]",s)}}),e}function Bl(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=k({},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 gr(l).sort((u,p)=>{var[d]=u,[h]=p;return d.localeCompare(h)}).forEach(u=>{var[p,d]=u;return c[Ds(p.toString())]=Ds(d.toString())}),o+=":",o+=gr(c).map(u=>{var[p,d]=u;return p+'="'+d+'"'}).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:Wl(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return gr(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 Ds(n){return n.replace(/"|\\"/g,'\\"')}function Wl(n){var e=n.attr__class;return e?F(e)?e:qi(e):void 0}var Pr=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}},Sr=n=>{var e=m?.createElement("a");return _(e)?null:(e.href=n,e)},Xl=function(n,e){var t,r;e===void 0&&(e="&");var i=[];return $(n,function(s,o){_(s)||_(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(!F(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{b.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 d=c[p].split("=");F(d)&&(e.includes(d[0])?u.push(d[0]+"="+t):u.push(c[p]))}var h=l;return a!=null&&(h+="?"+u.join("&")),s!=null&&(h+="#"+s),h},Cr=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},an="$copy_autocapture",Ns=L("[AutoCapture]");function ln(n,e){return e.length>n?e.slice(0,n)+"...":e}function Yl(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!jr(e));return e}function Jl(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};Li.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=ln(1024,Wo(n)):s.$el_text=ln(1024,tr(n)));var o=Er(n);o.length>0&&(s.classes=o.filter(function(u){return u!==""})),$(n.attributes,function(u){var p;if((!Vo(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 d=u.value;u.name==="class"&&(d=qi(d).join(" ")),s["attr__"+u.name]=ln(1024,d)}});for(var a=1,l=1,c=n;c=Yl(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function Zl(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!je(u,"body");)Lo(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var p,d=[],h={},g=!1,v=!1;if($(c,w=>{var E=Bn(w);w.tagName.toLowerCase()==="a"&&(g=w.getAttribute("href"),g=E&&g&&Qt(g)&&g),R(Er(w),"ph-no-capture")&&(v=!0),d.push(Jl(w,s,o,a));var q=function(G){if(!Bn(G))return{};var M={};return $(G.attributes,function(ce){if(ce.name&&ce.name.indexOf("data-ph-capture-attribute")===0){var Q=ce.name.replace("data-ph-capture-attribute-",""),pe=ce.value;Q&&pe&&Qt(pe)&&(M[Q]=pe)}}),M}(w);j(h,q)}),v)return{props:{},explicitNoCapture:v};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?d[0].$el_text=Wo(n):d[0].$el_text=tr(n)),g){var y,x;d[0].attr__href=g;var P=(y=Sr(g))==null?void 0:y.host,I=f==null||(x=f.location)==null?void 0:x.host;P&&I&&P!==I&&(p=g)}return{props:j({$event_type:i.type,$ce_version:1},l?{}:{$elements:d},{$elements_chain:Bl(d)},(t=d[0])!=null&&t.$el_text?{$el_text:(r=d[0])==null?void 0:r.$el_text}:{},p&&i.type==="click"?{$external_click_url:p}:{},h)}}var Wn=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Pr(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(f&&m){var e=r=>{r=r||f?.event;try{this.M(r)}catch(i){Ns.error("Failed to capture event",i)}};if(U(m,"submit",e,{capture:!0}),U(m,"change",e,{capture:!0}),U(m,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||f?.event,this.M(r,an)};U(m,"copy",t,{capture:!0}),U(m,"cut",t,{capture:!0})}}}else Ns.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({[Ss]:!!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=m?.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[Ss],i=this.T;if(de(i)&&!Ce(r)&&!this.instance.O())return!1;var s=(t=this.T)!==null&&t!==void 0?t:!!r;return!!this.instance.config.autocapture&&!s}M(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var r,i=jo(e);qo(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())&&jl(i,this.instance.config.rageclick)&&this.M(e,"$rageclick");var s=t===an;if(i&&Ul(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=Zl(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===an){var c,u=Go(f==null||(c=f.getSelection())==null?void 0:c.toString()),p=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=p}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return Le(m?.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 qs="0123456789abcdef",Xn=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+qs.charAt(this.bytes[t]>>>4)+qs.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}},Yn=class{constructor(){this.A=0,this.D=0,this.j=new Jn}generate(){var e=this.generateOrAbort();if(_(e)){this.A=0;var t=this.generateOrAbort();if(_(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.D++,this.D>4398046511103&&(this.A++,this.L())}return Xn.fromFieldsV7(this.A,Math.trunc(this.D/Math.pow(2,30)),this.D&Math.pow(2,30)-1,this.j.nextUint32())}L(){this.D=1024*this.j.nextUint32()+(1023&this.j.nextUint32())}},Ls,Yo=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};f&&!_(f.crypto)&&crypto.getRandomValues&&(Yo=n=>crypto.getRandomValues(n));var Jn=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(Yo(this.N),this.U=0),this.N[this.U++]}},qe=()=>Ql().toString(),Ql=()=>(Ls||(Ls=new Yn)).generate(),Rt="",eu=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function tu(n,e){if(e){var t=function(i,s){if(s===void 0&&(s=m),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_"+qe();!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(eu);return s?s[0]:""})(n);r!==t&&b.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var ye={H:()=>!!m,B:function(n){b.error("cookieStore error: "+n)},q:function(n){if(m){try{for(var e=n+"=",t=m.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(ye.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(m)try{var s="",o="",a=tu(m.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&&b.warn("cookieStore warning: large cookie, len="+c.length),m.cookie=c,c}catch{return}},V:function(n,e){if(m!=null&&m.cookie)try{ye.G(n,"",-1,e)}catch{return}}},un=null,N={H:function(){if(!de(un))return un;var n=!0;if(_(f))n=!1;else try{var e="__mplssupport__";N.G(e,"xyz"),N.q(e)!=='"xyz"'&&(n=!1),N.V(e)}catch{n=!1}return n||b.error("localStorage unsupported; falling back to cookie store"),un=n,n},B:function(n){b.error("localStorage error: "+n)},q:function(n){try{return f?.localStorage.getItem(n)}catch(e){N.B(e)}return null},W:function(n){try{return JSON.parse(N.q(n))||{}}catch{}return null},G:function(n,e){try{f?.localStorage.setItem(n,JSON.stringify(e))}catch(t){N.B(t)}},V:function(n){try{f?.localStorage.removeItem(n)}catch(e){N.B(e)}}},ru=["$device_id","distinct_id",br,Do,xr,wr],pr={},nu={H:function(){return!0},B:function(n){b.error("memoryStorage error: "+n)},q:function(n){return pr[n]||null},W:function(n){return pr[n]||null},G:function(n,e){pr[n]=e},V:function(n){delete pr[n]}},Ke=null,V={H:function(){if(!de(Ke))return Ke;if(Ke=!0,_(f))Ke=!1;else try{var n="__support__";V.G(n,"xyz"),V.q(n)!=='"xyz"'&&(Ke=!1),V.V(n)}catch{Ke=!1}return Ke},B:function(n){b.error("sessionStorage error: ",n)},q:function(n){try{return f?.sessionStorage.getItem(n)}catch(e){V.B(e)}return null},W:function(n){try{return JSON.parse(V.q(n))||null}catch{}return null},G:function(n,e){try{f?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){V.B(t)}},V:function(n){try{f?.sessionStorage.removeItem(n)}catch(e){V.B(e)}}},Pe=function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n}({}),Zn=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 rn(e)?Pe.GRANTED:R(pl,e)?Pe.DENIED:Pe.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?N:ye;var t=e==="localStorage"?ye:N;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(rn(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Fo([re?.doNotTrack,re?.msDoNotTrack,S.doNotTrack],e=>rn(e))}},dr=L("[Dead Clicks]"),iu=()=>!0,su=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property($o)),r=n.instance.config.capture_dead_clicks;return Ce(r)?r:!!z(r)||t},Mr=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({[$o]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,r;(t=S.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=S.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?dr.error("failed to load script",i):e()})}et(){var e;if(m){if(!this.tt&&(e=S.__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=S.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(m),dr.info("starting...")}}else dr.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,dr.info("stopping..."))}},At=L("[ExceptionAutocapture]"),Qn=class{constructor(e){var t,r,i;this.rt=()=>{var s;if(f&&this.isEnabled&&(s=S.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=S.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=S.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=S.__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[Is]),this.dt=new Pn({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=k({},t,e):(_(e)?this.ht:e)&&(t=k({},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=S.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=S.__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({[Is]: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 Gs(n,e,t){try{if(!(e in n))return()=>{};var r=n[e],i=t(r);return Le(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=i,()=>{n[e]=r}}catch{return()=>{}}}var ei=class{constructor(e){var t;this._instance=e,this.ct=(f==null||(t=f.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(b.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,b.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(f&&f.history){var r=this;(e=f.history.pushState)!=null&&e.__posthog_wrapped__||Gs(f.history,"pushState",i=>function(s,o,a){i.call(this,s,o,a),r._t("pushState")}),(t=f.history.replaceState)!=null&&t.__posthog_wrapped__||Gs(f.history,"replaceState",i=>function(s,o,a){i.call(this,s,o,a),r._t("replaceState")}),this.yt()}}_t(e){try{var t,r=f==null||(t=f.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){b.error("Error capturing "+e+" pageview",i)}}yt(){if(!this.ft){var e=()=>{this._t("popstate")};U(f,"popstate",e),this.ft=()=>{f&&f.removeEventListener("popstate",e)}}}},cn=L("[SegmentIntegration]");function ou(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()||qe();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(Ee,"identified")),i()},a=s.user();"then"in a&&Le(a.then)?a.then(o):o(a)})(n,()=>{t.register((r=>{Promise&&Promise.resolve||cn.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()||(cn.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(cn.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 Jo="posthog-js";function Zo(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,d;if(!(s==="*"||s.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var h=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=h,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var g=((l=a.exception)==null?void 0:l.values)||[],v=g.map(x=>k({},x,{stacktrace:x.stacktrace?k({},x.stacktrace,{type:"raw",frames:(x.stacktrace.frames||[]).map(P=>k({},P,{platform:"web:javascript"}))}):void 0})),y={$exception_message:((c=g[0])==null?void 0:c.value)||a.message,$exception_type:(u=g[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((p=g[0])==null?void 0:p.value)||a.message,$sentry_exception_type:(d=g[0])==null?void 0:d.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 ti=class{constructor(e,t,r,i,s,o){this.name=Jo,this.setupOnce=function(a){a(Zo(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},au=f!=null&&f.location?Cr(f.location.hash,"__posthog")||Cr(location.hash,"state"):null,js="_postHogToolbarParams",Us=L("[Toolbar]"),Ne=function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n}(Ne||{}),ri=class{constructor(e){this.instance=e}bt(e){S.ph_toolbar_state=e}wt(){var e;return(e=S.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),!f||!m)return!1;e=e??f.location,r=r??f.history;try{if(!t){try{f.localStorage.setItem("test","test"),f.localStorage.removeItem("test")}catch{return!1}t=f?.localStorage}var i,s=au||Cr(e.hash,"__posthog")||Cr(e.hash,"state"),o=s?Ps(()=>JSON.parse(atob(decodeURIComponent(s))))||Ps(()=>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(js)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=S.ph_load_toolbar||S.ph_load_editor;!T(t)&&Le(t)?t(e,this.instance):Us.warn("No toolbar load function found")}loadToolbar(e){var t=!(m==null||!m.getElementById(No));if(!f||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=k({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(f.localStorage.setItem(js,JSON.stringify(k({},i,{source:void 0}))),this.wt()===Ne.LOADED)this.xt(i);else if(this.wt()===Ne.UNINITIALIZED){var s;this.bt(Ne.LOADING),(s=S.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",o=>{if(o)return Us.error("[Toolbar] Failed to load",o),void this.bt(Ne.UNINITIALIZED);this.bt(Ne.LOADED),this.xt(i)}),U(f,"turbolinks:load",()=>{this.bt(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)}},lu=L("[TracingHeaders]"),ni=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;_(this.$t)&&((t=S.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),_(this.St)&&((r=S.__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=S.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=S.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return lu.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)}},hr="https?://(.*)",_t=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],uu=mt(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],_t),nr="<masked>",cu=["li_fat_id"];function Qo(n,e,t){if(!m)return{};var r,i=e?mt([],_t,t||[]):[],s=ea(rr(m.URL,i,nr),n),o=(r={},$(cu,function(a){var l=ye.q(a);r[a]=l||null}),r);return j(o,s)}function ea(n,e){var t=uu.concat(e||[]),r={};return $(t,function(i){var s=Ir(n,i);r[i]=s||null}),r}function ta(n){var e=function(s){return s?s.search(hr+"google.([^/?]*)")===0?"google":s.search(hr+"bing.com")===0?"bing":s.search(hr+"yahoo.com")===0?"yahoo":s.search(hr+"duckduckgo.com")===0?"duckduckgo":null:null}(n),t=e!="yahoo"?"q":"p",r={};if(!de(e)){r.$search_engine=e;var i=m?Ir(m.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function zs(){return navigator.language||navigator.userLanguage}function ra(){return m?.referrer||"$direct"}function na(n,e){var t=n?mt([],_t,e||[]):[],r=Z?.href.substring(0,1e3);return{r:ra().substring(0,1e3),u:r?rr(r,t,nr):void 0}}function ia(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Sr(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=Sr(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=ea(r);j(i,o)}if(t){var a=ta(t);j(i,a)}return i}function sa(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function pu(){try{return new Date().getTimezoneOffset()}catch{return}}function du(n,e){if(!J)return{};var t,r,i,s=n?mt([],_t,e||[]):[],[o,a]=function(l){for(var c=0;c<bs.length;c++){var[u,p]=bs[c],d=u.exec(l),h=d&&(Le(p)?p(d,l):p);if(h)return h}return["",""]}(J);return j(Ni({$os:o,$os_version:a,$browser:Mo(J,navigator.vendor),$device:ks(J),$device_type:(r=J,i=ks(r),i===go||i===fo||i==="Kobo"||i==="Kindle Fire"||i===Co?Xt:i===Jt||i===ft||i===Zt||i===In?"Console":i===yo?"Wearable":i?le:"Desktop"),$timezone:sa(),$timezone_offset:pu()}),{$current_url:rr(Z?.href,s,nr),$host:Z?.host,$pathname:Z?.pathname,$raw_user_agent:J.length>1e3?J.substring(0,997)+"...":J,$browser_version:kl(J,navigator.vendor),$browser_language:zs(),$browser_language_prefix:(t=zs(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:f?.screen.height,$screen_width:f?.screen.width,$viewport_height:f?.innerHeight,$viewport_width:f?.innerWidth,$lib:"web",$lib_version:xe.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Oe=L("[Web Vitals]"),Hs=9e5,ii=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)=>k({},r,{["$web_vitals_"+i.name+"_event"]:k({},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(_(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();_(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)),_(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=_(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(k({},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=S.__PosthogExtensions__;_(a)||_(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[Ms]),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[As])||["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:Hs;return 0<e&&e<=6e4?Hs:e}get isEnabled(){var e=Z?.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:Ce(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Ce(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({[Ms]:t}),this._instance.persistence.register({[As]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=S.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=S.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,s=>{s?Oe.error("failed to load script",s):e()})}}Ct(){var e=f?f.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?mt([],_t,r||[]):[];return rr(e,i,nr)}Oe.error("Could not determine current URL")}},hu=L("[Heatmaps]");function Vs(n){return z(n)&&"clientX"in n&&"clientY"in n&&Me(n.clientX)&&Me(n.clientY)}var si=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[Ln]),this.rageclicks=new Pr(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;hu.info("starting..."),this.Mt(),this.Ot()}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({[Ln]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}Dt(e){this.jt(e.originalEvent,"deadclick")}Ot(){this.Ft&&clearInterval(this.Ft),this.Ft=function(e){return e?.visibilityState==="visible"}(m)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Mt(){f&&m&&(this.Nt=this.Lt.bind(this),U(f,"beforeunload",this.Nt),this.Ut=e=>this.jt(e||f?.event),U(m,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||f?.event),U(m,"mousemove",this.zt,{capture:!0}),this.Bt=new Mr(this.instance,iu,this.Dt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Ot.bind(this),U(m,"visibilitychange",this.qt),this.P=!0)}At(){var e;f&&m&&(this.Nt&&f.removeEventListener("beforeunload",this.Nt),this.Ut&&m.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&m.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&m.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&&jr(u)&&!je(u,"body");){if(u===c)return!1;if(R(l,f?.getComputedStyle(u).position))return!0;u=zo(u)}return!1}(jo(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:t}}jt(e,t){var r;if(t===void 0&&(t="click"),!Ts(e.target)&&Vs(e)){var i=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(k({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!Ts(e.target)&&Vs(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(f){var t=f.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?mt([],_t,i||[]):[],o=rr(t,s,nr);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!pt(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Rr=class{constructor(e){this.Jt=(t,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(b.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=f?.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(!(_(o)||_(a)||_(l)||_(c)||_(u)||_(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 d=o<=1?1:me(a/o,0,1,b),h=o<=1?1:me(l/o,0,1,b),g=c<=1?1:me(u/c,0,1,b),v=c<=1?1:me(p/c,0,1,b);i=j(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:g,$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}({}),ue=Uint8Array,Y=Uint16Array,yt=Uint32Array,ji=new ue([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 ue([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]),Ks=new ue([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),oa=function(n,e){for(var t=new Y(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new yt(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]},aa=oa(ji,2),fu=aa[0],oi=aa[1];fu[28]=258,oi[258]=28;for(ai=oa(Ui,0)[1],Ar=new Y(32768),D=0;D<32768;++D)$e=(43690&D)>>>1|(21845&D)<<1,$e=(61680&($e=(52428&$e)>>>2|(13107&$e)<<2))>>>4|(3855&$e)<<4,Ar[D]=((65280&$e)>>>8|(255&$e)<<8)>>>1;var $e,ai,Ar,D,Kt=function(n,e,t){for(var r=n.length,i=0,s=new Y(e);i<r;++i)++s[n[i]-1];var o,a=new Y(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new Y(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,d=p|(1<<u)-1;p<=d;++p)o[Ar[p]>>>l]=c}else for(o=new Y(r),i=0;i<r;++i)o[i]=Ar[a[n[i]-1]++]>>>15-n[i];return o},Ye=new ue(288);for(D=0;D<144;++D)Ye[D]=8;for(D=144;D<256;++D)Ye[D]=9;for(D=256;D<280;++D)Ye[D]=7;for(D=280;D<288;++D)Ye[D]=8;var Tr=new ue(32);for(D=0;D<32;++D)Tr[D]=5;var gu=Kt(Ye,9,0),vu=Kt(Tr,5,0),la=function(n){return(n/8>>0)+(7&n&&1)},ua=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof Y?Y:n instanceof yt?yt:ue)(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},pn=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 ue(0),0];if(i==1){var o=new ue(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort(function(E,q){return E.f-q.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 d=s[0].s;for(r=1;r<i;++r)s[r].s>d&&(d=s[r].s);var h=new Y(d+1),g=li(t[u-1],h,0);if(g>e){r=0;var v=0,y=g-e,x=1<<y;for(s.sort(function(E,q){return h[q.s]-h[E.s]||E.f-q.f});r<i;++r){var P=s[r].s;if(!(h[P]>e))break;v+=x-(1<<g-h[P]),h[P]=e}for(v>>>=y;v>0;){var I=s[r].s;h[I]<e?v-=1<<e-h[I]++-1:++r}for(;r>=0&&v;--r){var w=s[r].s;h[w]==e&&(--h[w],++v)}g=e}return[new ue(h),g]},li=function(n,e,t){return n.s==-1?Math.max(li(n.l,e,t+1),li(n.r,e,t+1)):e[n.s]=t},Bs=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new Y(++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},ui=function(n,e,t){var r=t.length,i=la(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)},Ws=function(n,e,t,r,i,s,o,a,l,c,u){ke(e,u++,t),++i[256];for(var p=pn(i,15),d=p[0],h=p[1],g=pn(s,15),v=g[0],y=g[1],x=Bs(d),P=x[0],I=x[1],w=Bs(v),E=w[0],q=w[1],G=new Y(19),M=0;M<P.length;++M)G[31&P[M]]++;for(M=0;M<E.length;++M)G[31&E[M]]++;for(var ce=pn(G,7),Q=ce[0],pe=ce[1],oe=19;oe>4&&!Q[Ks[oe-1]];--oe);var be,he,fe,nt,Re=c+5<<3,Ve=Ft(i,Ye)+Ft(s,Tr)+o,ge=Ft(i,d)+Ft(s,v)+o+14+3*oe+Ft(G,Q)+(2*G[16]+3*G[17]+7*G[18]);if(Re<=Ve&&Re<=ge)return ui(e,u,n.subarray(l,l+c));if(ke(e,u,1+(ge<Ve)),u+=2,ge<Ve){be=Kt(d,h,0),he=d,fe=Kt(v,y,0),nt=v;var Ae=Kt(Q,pe,0);for(ke(e,u,I-257),ke(e,u+5,q-1),ke(e,u+10,oe-4),u+=14,M=0;M<oe;++M)ke(e,u+3*M,Q[Ks[M]]);u+=3*oe;for(var it=[P,E],W=0;W<2;++W){var ae=it[W];for(M=0;M<ae.length;++M){var ee=31&ae[M];ke(e,u,Ae[ee]),u+=Q[ee],ee>15&&(ke(e,u,ae[M]>>>5&127),u+=ae[M]>>>12)}}}else be=gu,he=Ye,fe=vu,nt=Tr;for(M=0;M<a;++M)if(r[M]>255){ee=r[M]>>>18&31,Tt(e,u,be[ee+257]),u+=he[ee+257],ee>7&&(ke(e,u,r[M]>>>23&31),u+=ji[ee]);var st=31&r[M];Tt(e,u,fe[st]),u+=nt[st],st>3&&(Tt(e,u,r[M]>>>5&8191),u+=Ui[st])}else Tt(e,u,be[r[M]]),u+=he[r[M]];return Tt(e,u,be[256]),u+he[256]},yu=new yt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mu=function(){for(var n=new yt(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n}(),_u=function(n,e,t,r,i){return function(s,o,a,l,c,u){var p=s.length,d=new ue(l+p+5*(1+Math.floor(p/7e3))+c),h=d.subarray(l,d.length-c),g=0;if(!o||p<8)for(var v=0;v<=p;v+=65535){var y=v+65535;y<p?g=ui(h,g,s.subarray(v,y)):(h[v]=u,g=ui(h,g,s.subarray(v,p)))}else{for(var x=yu[o-1],P=x>>>13,I=8191&x,w=(1<<a)-1,E=new Y(32768),q=new Y(w+1),G=Math.ceil(a/3),M=2*G,ce=function(tn){return(s[tn]^s[tn+1]<<G^s[tn+2]<<M)&w},Q=new yt(25e3),pe=new Y(288),oe=new Y(32),be=0,he=0,fe=(v=0,0),nt=0,Re=0;v<p;++v){var Ve=ce(v),ge=32767&v,Ae=q[Ve];if(E[ge]=Ae,q[Ve]=ge,nt<=v){var it=p-v;if((be>7e3||fe>24576)&&it>423){g=Ws(s,h,0,Q,pe,oe,he,fe,Re,v-Re,g),fe=be=he=0,Re=v;for(var W=0;W<286;++W)pe[W]=0;for(W=0;W<30;++W)oe[W]=0}var ae=2,ee=0,st=I,Te=ge-Ae&32767;if(it>2&&Ve==ce(v-Te))for(var Ba=Math.min(P,it)-1,Wa=Math.min(32767,v),Xa=Math.min(258,it);Te<=Wa&&--st&&ge!=Ae;){if(s[v+ae]==s[v+ae-Te]){for(var Fe=0;Fe<Xa&&s[v+Fe]==s[v+Fe-Te];++Fe);if(Fe>ae){if(ae=Fe,ee=Te,Fe>Ba)break;var Ya=Math.min(Te,Fe-2),os=0;for(W=0;W<Ya;++W){var en=v-Te+W+32768&32767,as=en-E[en]+32768&32767;as>os&&(os=as,Ae=en)}}}Te+=(ge=Ae)-(Ae=E[ge])+32768&32767}if(ee){Q[fe++]=268435456|oi[ae]<<18|ai[ee];var ls=31&oi[ae],us=31&ai[ee];he+=ji[ls]+Ui[us],++pe[257+ls],++oe[us],nt=v+ae,++be}else Q[fe++]=s[v],++pe[s[v]]}}g=Ws(s,h,u,Q,pe,oe,he,fe,Re,v-Re,g)}return ua(d,0,l+la(g)+c)}(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,r,!0)},dn=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function bu(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=mu[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}}(),r=n.length;t.p(n);var i,s=_u(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&&dn(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),dn(s,o-8,t.d()),dn(s,o-4,r),s}var ku=function(n){var e,t,r,i,s="";for(e=t=0,r=(n=(n+"").replace(/\r\n/g,`
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),de(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},wu=!!kn||!!bn,Xs="text/plain",Fr=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=k({},e),a=(r=s?.split("&").map(c=>{var u,[p,d]=c.split("="),h=t&&(u=o[p])!==null&&u!==void 0?u:d;return delete o[p],p+"="+h}))!==null&&r!==void 0?r:[],l=Xl(o);return l&&a.push(l),i+"?"+a.join("&")},zt=(n,e)=>JSON.stringify(n,(t,r)=>typeof r=="bigint"?r.toString():r,e),hn=n=>{var{data:e,compression:t}=n;if(e){if(t===Se.GZipJS){var r=bu(function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new ue(l.length+(l.length>>>1)),d=0,h=function(x){p[d++]=x},g=0;g<u;++g){if(d+5>p.length){var v=new ue(d+8+(u-g<<1));v.set(p),p=v}var y=l.charCodeAt(g);y<128||c?h(y):y<2048?(h(192|y>>>6),h(128|63&y)):y>55295&&y<57344?(h(240|(y=65536+(1047552&y)|1023&l.charCodeAt(++g))>>>18),h(128|y>>>12&63),h(128|y>>>6&63),h(128|63&y)):(h(224|y>>>12),h(128|y>>>6&63),h(128|63&y))}return ua(p,0,d)}(zt(e)),{mtime:0}),i=new Blob([r],{type:Xs});return{contentType:Xs,body:i,estimatedSize:i.size}}if(t===Se.Base64){var s=function(l){var c,u,p,d,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,y=0,x="",P=[];if(!l)return l;l=ku(l);do c=(h=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=h>>12&63,p=h>>6&63,d=63&h,P[y++]=g.charAt(c)+g.charAt(u)+g.charAt(p)+g.charAt(d);while(v<l.length);switch(x=P.join(""),l.length%3){case 1:x=x.slice(0,-2)+"==";break;case 2:x=x.slice(0,-1)+"="}return x}(zt(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:zt(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=zt(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},vr=[];bn&&vr.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=hn(n))!==null&&e!==void 0?e:{},o=new Headers;$(n.headers,function(u,p){o.append(p,u)}),r&&o.append("Content-Type",r);var a=n.url,l=null;if(gs){var c=new gs;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),n.timeout)}}bn(a,k({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 d={statusCode:u.status,text:p};if(u.status===200)try{d.json=JSON.parse(p)}catch(h){b.error(h)}n.callback==null||n.callback(d)})).catch(u=>{b.error(u),n.callback==null||n.callback({statusCode:0,text:u})}).finally(()=>l?clearTimeout(l.timeout):null)}}),kn&&vr.push({transport:"XHR",method:n=>{var e,t=new kn;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=hn(n))!==null&&e!==void 0?e:{};$(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)}}),re!=null&&re.sendBeacon&&vr.push({transport:"sendBeacon",method:n=>{var e=Fr(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=hn(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;re.sendBeacon(e,s)}catch{}}});var Or=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 Ys(n,e,t){return zt({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var ca={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=>Or(t,r))),not_regex:(n,e)=>e.every(t=>n.every(r=>!Or(t,r))),icontains:(n,e)=>e.map(fr).some(t=>n.map(fr).some(r=>t.includes(r))),not_icontains:(n,e)=>e.map(fr).every(t=>n.map(fr).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))})},fr=n=>n.toLowerCase();function pa(n,e){return!n||Object.entries(n).every(t=>{var[r,i]=t,s=e?.[r];if(_(s)||de(s))return!1;var o=[String(s)],a=ca[i.operator];return!!a&&a(i.values,o)})}var fn=L("[Error tracking]"),ci=class{constructor(e){var t,r;this.Zt=[],this.ti=new Mn([new An,new qn,new Fn,new Tn,new Dn,new $n,new On,new Nn],Al()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Gn))!==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({[Gn]:this.Zt,[Cs]:o})}get ii(){var e,t=!!this._instance.get_property(Cs),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 fn.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void fn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void fn.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=ca[s.operator],l=F(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)&&F(e)}},te=L("[FeatureFlags]"),Ot=L("[FeatureFlags]",{debugEnabled:!0}),gn="$active_feature_flags",ot="$override_feature_flags",Js="$feature_flag_payloads",$t="$override_feature_flag_payloads",Zs="$feature_flag_request_id",Qs="$feature_flag_evaluated_at",eo=n=>{var e={};for(var[t,r]of gr(n||{}))r&&(e[t]=r);return e},xu=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]}))):te.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},Eu=function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n}({}),pi=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||(te.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||te.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(jn),t=this._instance.get_property(ot),r=this._instance.get_property($t);if(!r&&!t)return e||{};var i=j({},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=_(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,d=_(u)?c.variant:typeof u=="string"?u:void 0,h=r?.[o],g=k({},c,{enabled:p,variant:p?d??c?.variant:void 0});p!==c?.enabled&&(g.original_enabled=c?.enabled),d!==c?.variant&&(g.original_variant=c?.variant),h&&(g.metadata=k({},c?.metadata,{payload:h,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=g}return this.oi||(te.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(dt),t=this._instance.get_property(ot);if(!t)return e||{};for(var r=j({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(te.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(Js),t=this._instance.get_property($t);if(!t)return e||{};for(var r=j({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(te.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))}yi(){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.yi(),!this._instance.O())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:k({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(Ut)||{}),group_properties:this._instance.get_property(We)};de(i)||_(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=sa()),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,d,h=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),h=!1),this.li=!1,this.di||(this.di=!0,this._instance.bi((d=u.json)!==null&&d!==void 0?d:{})),!s.disable_flags||this.hi)if(this.vi=!h,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(Eu.FeatureFlags))te.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var g;s.disable_flags||this.receivedFeatureFlags((g=u.json)!==null&&g!==void 0?g:{},h),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}te.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(Zs)||void 0,c=this._instance.get_property(Qs)||void 0,u=this._instance.get_property(kr)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,d,h,g,v,y,x,P,I;F(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[kr]:u});var w=this.getFeatureFlagDetails(e),E={$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:((d=this._instance.config.bootstrap)==null||(d=d.featureFlags)==null?void 0:d[e])||null,$feature_flag_bootstrapped_payload:((h=this._instance.config.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.vi};_(w==null||(g=w.metadata)==null?void 0:g.version)||(E.$feature_flag_version=w.metadata.version);var q,G=(v=w==null||(y=w.reason)==null?void 0:y.description)!==null&&v!==void 0?v:w==null||(x=w.reason)==null?void 0:x.code;G&&(E.$feature_flag_reason=G),w!=null&&(P=w.metadata)!=null&&P.id&&(E.$feature_flag_id=w.metadata.id),_(w?.original_variant)&&_(w?.original_enabled)||(E.$feature_flag_original_response=_(w.original_variant)?w.original_enabled:w.original_variant),w!=null&&(I=w.metadata)!=null&&I.original_payload&&(E.$feature_flag_original_payload=w==null||(q=w.metadata)==null?void 0:q.original_payload),this._instance.capture("$feature_flag_called",E)}if(i){var M=o;if(!_(o))try{M=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:M}}}else te.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 _(r)?void 0:!!r}te.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=xu(o),d=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,y=o.evaluatedAt;if(F(h)){te.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var x={};if(h)for(var P=0;P<h.length;P++)x[h[P]]=!0;a&&a.register({[gn]:h,[dt]:x})}else{var I=h,w=g,E=d;o.errorsWhileComputingFlags&&(I=k({},l,I),w=k({},c,w),E=k({},u,E)),a&&a.register(k({[gn]:Object.keys(eo(I)),[dt]:I||{},[Js]:w||{},[jn]:E||{}},v?{[Zs]:v}:{},y?{[Qs]:y}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),te.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return te.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ot),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(ot),Ot.info("Flag overrides cleared");else if(r.flags){if(F(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[ot]:i})}else this._instance.persistence.register({[ot]: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(jt)||[]).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=k({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[gn]:Object.keys(eo(l)),[dt]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(jt),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(jt),(l=this._instance.persistence)==null||l.register({[jt]: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]:k({},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]=k({},r[i],e[i]),delete e[i]}),this._instance.register({[We]:k({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(We)||{};this._instance.register({[We]:k({},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.yi(),this.oi=!1}},Pu=["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&&b.info("Persistence loaded",e.persistence,k({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){Pu.indexOf(e.persistence.toLowerCase())===-1&&(b.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=[...ru,...i];return k({},N,{W:function(o){try{var a={};try{a=ye.W(o)||{}}catch{}var l=j(a,JSON.parse(N.q(o)||"{}"));return N.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{N.G(o,a,void 0,void 0,p);var d={};s.forEach(h=>{a[h]&&(d[h]=a[h])}),Object.keys(d).length&&ye.G(o,d,l,c,u,p)}catch(h){N.B(h)}},V:function(o,a){try{f?.localStorage.removeItem(o),ye.V(o,a)}catch(l){N.B(l)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&N.H()?N:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&V.H()?V:r==="memory"?nu:r==="cookie"?ye:t.H()?t:ye}properties(){var e={};return $(this.props,function(t,r){if(r===dt&&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,(de(o=Ll)?l:fs&&o.indexOf===fs?o.indexOf(a)!=-1:($(o,function(c){if(l||(l=c===a))return _r}),l))||(e[r]=t);var o,a,l}),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=j({},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)){_(t)&&(t="None"),this.Pi=_(r)?this.Ci:r;var i=!1;if($(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=_(t)?this.Ci:t;var r=!1;if($(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=Qo(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);pt(Ni(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=m?.referrer)?ta(e):{})}update_referrer_info(){var e;this.register_once({$referrer:ra(),$referring_domain:m!=null&&m.referrer&&((e=Sr(m.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Vn]||this.props[Kn]||this.register_once({[wr]:na(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};$([Kn,Vn],o=>{var a=this.props[o];a&&$(a,function(l,c){e["$initial_"+wn(c)]=l})});var t,r,i=this.props[wr];if(i){var s=(t=ia(i),r={},$(t,function(o,a){r["$initial_"+wn(a)]=o}),r);j(e,s)}return e}safe_merge(e){return $(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 _(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()}},to=L("[Product Tours]"),vn="ph_product_tours",di=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Rs]:!(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(Rs)||this.it(()=>this.Mi())}it(e){var t,r;(t=S.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=S.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",i=>{i?to.error("Could not load product tours script",i):e()})}Mi(){var e;!this.Ri&&(e=S.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=S.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!F(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[vn];if(F(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 to.error(a),void e([],{isLoaded:!1,error:a})}var l=F(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[vn]: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.Mi(),(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(vn)}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}({}),sp=function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n}({}),op=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}({}),ap=function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n}({}),yn=function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n}({}),lp=function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n}({}),up=function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n}({}),cp=function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n}({}),Ht=function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n}({}),mn=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}({}),hi=function(n){return n.Popover="popover",n.Inline="inline",n}({}),O=L("[Surveys]"),da="seenSurvey_",Su=(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},ro=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(da,n),Iu=[yn.Popover,yn.Widget,yn.API],Cu={ignoreConditions:!1,ignoreDelay:!1,displayType:hi.Popover},er=class{constructor(){this.Oi={},this.Oi={}}on(e,t){return this.Oi[e]||(this.Oi[e]=[]),this.Oi[e].push(t),()=>{this.Oi[e]=this.Oi[e].filter(r=>r!==t)}}emit(e,t){for(var r of this.Oi[e]||[])r(t);for(var i of this.Oi["*"]||[])i(e,t)}};function at(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 fi=class{constructor(e){this.Ai=new er,this.Di=(t,r)=>this.ji(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.ji=(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(!_((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(!_((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.Di(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"||!at(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=>at(a.href,t.href,t.href_matching||"exact"));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&at((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=>at(c.text,t.text,t.text_matching||"exact")||at(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=[],d=/(?::|")text="(.*?)"/g;!T(u=d.exec(c));)p.includes(u[1])||p.push(u[1]);return p}(l),o=t.text,a=t.text_matching||"exact",s.some(c=>at(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||pa(t.properties.reduce((r,i)=>{var s=F(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)}},gi=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&pa(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;_((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 fi(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 d=this.te(e,t,Dt.Cancellation);d.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:d.map(g=>g.id)}),d.forEach(g=>{var v=a.indexOf(g.id);v>=0&&a.splice(v,1),this.ue(g.id)}),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var h=this.te(e,t,Dt.Activation);this.le(a.concat(h.map(g=>g.id)||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter(o=>!this.he(o));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},vi=class extends gi{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return Ht.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 O}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},yi=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 O.warn("Flags not loaded yet. Not loading surveys.");var r=F(t);this.ve=r?t.length>0:t,O.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(da)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach(i=>localStorage.removeItem(i))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)O.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)O.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())O.info("Not loading surveys in cookieless mode without consent.");else{var e=S?.__PosthogExtensions__;if(e){if(!_(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 O.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new vi(this._instance),O.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){O.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 O.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;O.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,p=s.json.surveys||[],d=p.filter(g=>function(v){return!(!v.start_date||v.end_date)}(g)&&(function(v){var y;return!((y=v.conditions)==null||(y=y.events)==null||(y=y.values)==null||!y.length)}(g)||function(v){var y;return!((y=v.conditions)==null||(y=y.actions)==null||(y=y.values)==null||!y.length)}(g)));d.length>0&&((u=this._surveyEventReceiver)==null||u.register(d)),(o=this._instance.persistence)==null||o.register({[Un]:p});var h={isLoaded:!0};e(p,h),r?.({surveys:p,context:h})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){O.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!T(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);O.warn("init was not called")}ye(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}be(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.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(T(this._surveyManager))return O.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.be(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return T(this._surveyManager)?(O.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.be(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))O.warn("init was not called");else{var s=typeof e=="string"?this.ye(e):e;if(s!=null&&s.id)if(Iu.includes(s.type)){var o=m?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(O.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var a,l;O.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),O.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);O.warn("Survey element not found")}else O.warn("Surveys of type "+s.type+" cannot be rendered in the app");else O.warn("Survey not found")}}displaySurvey(e,t){var r;if(T(this._surveyManager))O.warn("init was not called");else{var i=this.ye(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=k({},i,{appearance:k({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==hi.Popover&&t.initialResponses&&O.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 O.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==hi.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else O.warn("Survey not found")}}cancelPendingSurvey(e){T(this._surveyManager)?O.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},we=L("[Conversations]"),mi=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)||(Ce(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=S?.__PosthogExtensions__;if(e&&!_(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&&!de(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 ct(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(we.warn("Conversations not available yet."),null)})()}getMessages(e,t){var r=this;return ct(function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(we.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return ct(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(we.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return ct(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}},_i=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=L("[logs]"),t=S?.__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.")}}},no=L("[RateLimiter]"),bi=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=>{no.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void no.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=L("[RemoteConfig]"),ki=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=S._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=S.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=S.__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.bi(this.remoteConfig);if(this._instance.O())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.bi(t)});this.bi(e)})}catch(e){Be.error("Error loading remote config",e)}}bi(e){e?this._instance.config.__preview_remote_config?(this._instance.bi(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.")}},wi=3e3,xi=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=me(t?.flush_interval_ms||wi,250,5e3,b.createLogger("flush interval"),wi),this.Me=e}enqueue(e){this.Re.push(e),this.Oe||this.Ae()}unload(){this.De();var e=this.Re.length>0?this.je():{},t=Object.values(e);[...t.filter(r=>r.url.indexOf("/e")===0),...t.filter(r=>r.url.indexOf("/e")!==0)].map(r=>{this.Me(k({},r,{transport:"sendBeacon"}))})}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Oe=setTimeout(()=>{if(this.De(),this.Re.length>0){var t=this.je(),r=function(){var s=t[i],o=new Date().getTime();s.data&&F(s.data)&&$(s.data,a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp}),e.Me(s)};for(var i in t)r()}},this.Fe))}De(){clearTimeout(this.Oe),this.Oe=void 0}je(){var e={};return $(this.Re,t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;_(e[s])&&(e[s]=k({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)}),this.Re=[],e}},Mu=["retriesPerformedSoFar"],Ei=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!_(f)&&"onLine"in f.navigator&&(this.Ue=f.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},U(f,"online",this.ze),U(f,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=uo(e,Mu);lt(t)&&(r.url=Fr(r.url,{retry_count:t})),this._instance._send_request(k({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(k({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)"),b.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,_(f)||(this.ze&&(f.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(f.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(t){b.error(t)}this.Re=[]}},Pi=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(f,"scroll",this.Ge,{capture:!0}),U(f,"scrollend",this.Ge,{capture:!0}),U(f,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return f?.document.documentElement;var e=F(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=f?.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 f&&(f.scrollY||f.pageYOffset||f.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return f&&(f.scrollX||f.pageXOffset||f.document.documentElement.scrollLeft)||0}},Ru=n=>na(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),$r=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||Ru,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?ia(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 $(Ni(this.getSetOnceProps()),(t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+wn(r)]=t}),e}},_n=L("[SessionId]"),Dr=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)=>!(!lt(u)||!lt(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||qe,this.ar=r||qe;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*me(o,60,36e3,_n.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=V.W(this.ur),l=V.W(this.hr);a&&!l?this.rr=a:V.V(this.ur),V.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){_n.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return _(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&&V.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&V.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?V.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({[br]:[t,e,r]}))}_r(){var e=this.Xe.props[br];return F(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&&f&&(f.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&V.V(this.hr)},U(f,"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=lt(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(),_n.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 d=lt(i)&&e&&!l?i:r,h=lt(o)?o:new Date().getTime();return this.pr(a),this.vr(s,d,h),e||this.lr(),c&&this.tr.forEach(g=>g(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0)),{sessionId:s,windowId:a,sessionStartTimestamp:h,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)}},Au=["$set_once","$set"],De=L("[SiteApps]"),Si=class{constructor(e){this._instance=e,this.yr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}br(e,t){if(t){var r=this.globalsForEvent(t);this.yr.push(r),this.yr.length>1e3&&(this.yr=this.yr.slice(10))}}get siteAppLoaders(){var e;return(e=S._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.br.bind(this));this.wr=()=>{e(),this.yr=[],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[d,h]of Object.entries(p))c[d]={id:u[d],type:d,properties:h};var{$set_once:g,$set:v}=e;return{event:k({},uo(e,Au),{properties:k({},e.properties,v?{$set:k({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},g?{$set_once:k({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.yr.length&&(De.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.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;S["__$$ph_site_app_"+c]=s._instance,(u=S.__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.')}},ha=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&ys(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some(i=>ys(i?.brand,e)))return!0}catch{}return!!n.webdriver},Vt=function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n}({}),io="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("."+io,".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]=Vt.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Vt.EU:this.Sr[this.apiHost]=Vt.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===Vt.CUSTOM)return this.apiHost+t;var r=io+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},Tu={icontains:(n,e)=>!!f&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!f&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!f&&Or(e.href,n),not_regex:(n,e)=>!!f&&!Or(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Ci=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||Tu[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return f?.location}static Fr(e){var t;if(T(e.conditions)||T((t=e.conditions)==null?void 0:t.utm))return!0;var r=Qo();if(r.utm_source){var i,s,o,a,l,c,u,p,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,h=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,g=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,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 d&&g&&v&&h}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];b.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 re&&this._instance?ha(re,this._instance.config.custom_blocked_useragents):void 0}},Fu=L("[PostHog ExternalIntegrations]"),Ou={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Mi=class{constructor(e){this._instance=e}it(e,t){var r;(r=S.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,i=>{if(i)return Fu.error("failed to load script",i);t()})}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=S.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(Ou[o],()=>{var u;(u=S.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)}),!i&&(l=S.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=S.__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)}}},Ri="[SessionRecording]",Nt=L(Ri),Nr=class{get started(){var e;return!((e=this.Mr)==null||!e.isStarted)}get status(){return this.Mr?this.Mr.status:this.Or&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Or=!1,this.Dr=void 0,this._instance=e,!this._instance.sessionManager)throw Nt.error("started without valid sessionManager"),new Error(Ri+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ri+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(on))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return f&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Mr)==null||!t.isStarted){var r=!_(Object.assign)&&!_(Array.from);this.Ar&&r?(this.jr(e),Nt.info("starting")):this.stopRecording()}}jr(e){var t,r,i;this.Ar&&(S!=null&&(t=S.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=S.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=S.__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.Dr)==null||e.call(this),this.Dr=void 0,(t=this.Mr)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(Do)}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({[on]:k({enabled:!!o},o,{networkPayloadCapture:k({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:_(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.Dr)==null||t.call(this),this.Dr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Or=!0,this.startIfEnabledOrStop()):this.Or=!0:Nt.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Mr)!=null&&r.log?this.Mr.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(on);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=S.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=(r=S.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;(t=this.Mr)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Mr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Mr)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Mr||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Mr)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Mr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Mr)==null||!r.tryAddCustomEvent(e,t))}},Wt={},Ai=()=>{},ut="posthog",fa=!wu&&J?.indexOf("MSIE")===-1&&J?.indexOf("Mozilla")===-1,so=n=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ql(m?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Ai,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:Z&&H(Z?.search)&&Z.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:(f==null||(e=f.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;b.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:wi},error_tracking:{},_onCapture:Ai,__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"}))(n))},oo=n=>{var e={};_(n.process_person)||(e.person_profiles=n.process_person),_(n.xhr_headers)||(e.request_headers=n.xhr_headers),_(n.cookie_name)||(e.persistence_name=n.cookie_name),_(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),_(n.store_google)||(e.save_campaign_params=n.store_google),_(n.verbose)||(e.debug=n.verbose);var t=j({},e,n);return F(n.property_blacklist)&&(_(n.property_denylist)?t.property_denylist=n.property_blacklist:F(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:b.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Ti=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){b.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 Ti,this.Br=!1,this.version=xe.LIB_VERSION,this.qr=new er,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=so(),this.SentryIntegration=ti,this.sentryIntegration=e=>function(t,r){var i=Zo(t,r);return{name:Jo,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 pi(this),this.toolbar=new ri(this),this.scrollManager=new Pi(this),this.pageViewManager=new Rr(this),this.surveys=new yi(this),this.conversations=new mi(this),this.logs=new _i(this),this.experiments=new Ci(this),this.exceptions=new ci(this),this.rateLimiter=new bi(this),this.requestRouter=new Ii(this),this.consent=new Zn(this),this.externalIntegrations=new Mi(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=>b.info('send "'+e?.event+'"',e))}init(e,t,r){if(r&&r!==ut){var i,s=(i=Wt[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Wt[r]=s,Wt[ut][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),_(e)||xn(e))return b.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(j({},so(t.defaults),oo(t),{name:r,token:e})),this.config.on_xhr_error&&b.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(k({},this.config,{persistence:"sessionStorage"}),s);var o=k({},this.persistence.props),a=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new xi(P=>this.ts(P),this.config.request_queue_config),this.es=new Ei(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 Dr(this),this.sessionPropsManager=new $r(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(b.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(b.info("Initializing extensions synchronously"),this.rs(l)),xe.DEBUG=xe.DEBUG||this.config.debug,xe.DEBUG&&b.info("Starting in debug mode",{this:this,config:t,thisC:k({},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(qe()),d=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(Ee,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:d})}if(this.ss()){var h,g,v=Object.keys(((h=t.bootstrap)==null?void 0:h.featureFlags)||{}).filter(P=>{var I;return!((I=t.bootstrap)==null||(I=I.featureFlags)==null||!I[P])}).reduce((P,I)=>{var w;return P[I]=((w=t.bootstrap)==null||(w=w.featureFlags)==null?void 0:w[I])||!1,P},{}),y=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter(P=>v[P]).reduce((P,I)=>{var w,E;return(w=t.bootstrap)!=null&&(w=w.featureFlagPayloads)!=null&&w[I]&&(P[I]=(E=t.bootstrap)==null||(E=E.featureFlagPayloads)==null?void 0:E[I]),P},{});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 x=this.config.get_device_id(qe());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(Ee,"anonymous")}return U(f,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?ou(this,()=>this.ns()):this.ns(),Le(this.config._onCapture)&&this.config._onCapture!==Ai&&(b.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",P=>this.config._onCapture(P.event,P))),this.config.ip&&b.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 ei(this),this.historyAutocapture.startIfEnabled();var r=[];r.push(()=>{new ni(this).startIfEnabledOrStop()}),r.push(()=>{var i;this.siteApps=new Si(this),(i=this.siteApps)==null||i.init()}),e||r.push(()=>{this.sessionRecording=new Nr(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||r.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),r.push(()=>{this.autocapture=new Wn(this),this.autocapture.startIfEnabled()}),r.push(()=>{this.surveys.loadIfEnabled()}),r.push(()=>{this.logs.loadIfEnabled()}),r.push(()=>{this.conversations.loadIfEnabled()}),r.push(()=>{this.productTours=new di(this),this.productTours.loadIfEnabled()}),r.push(()=>{this.heatmaps=new si(this),this.heatmaps.startIfEnabled()}),r.push(()=>{this.webVitalsAutocapture=new ii(this)}),r.push(()=>{this.exceptionObserver=new Qn(this),this.exceptionObserver.startIfEnabledOrStop()}),r.push(()=>{this.deadClicksAutocapture=new Mr(this,su),this.deadClicksAutocapture.startIfEnabled()}),r.push(()=>{if(this.os){var i=this.os;this.os=void 0,this.bi(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){b.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&&b.info("PostHog extensions initialized ("+i+"ms)")}bi(e){var t,r,i,s,o,a,l,c,u;if(!m||!m.body)return b.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.bi(e)},500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=R(e.supportedCompression,Se.GZipJS)?Se.GZipJS:R(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(e){b.critical("`loaded` function failed",e)}this.us(),this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()},1),new ki(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&&(fa?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Fr(e.url,{ip:this.config.ip?1:0}),e.headers=k({},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=k({},t);o.timeout=o.timeout||6e4,o.url=Fr(o.url,{_:new Date().getTime().toString(),ver:xe.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=vr.filter(u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport)),c=(i=(s=Fo(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)})(k({},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],F(t)?s.push(a):Le(a)?a.call(this):F(a)&&t==="alias"?r.push(a):F(a)&&t.indexOf("capture")!==-1&&Le(this[t])?s.push(a):i.push(a))});var o=function(a,l){Ge(a,function(c){if(F(c[0])){var u=l;$(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(!_(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)&&(b.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=qe(),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,d=e!=="$groupidentify",h=this.vs(r?.$set_once,d);if(h&&(u.$set_once=h),(u=Dl(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,_(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===Ht.DISMISSED||e===Ht.SENT){var g=t?.[mn.SURVEY_ID],v=t?.[mn.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(ro(p))||localStorage.setItem(ro(p),"true"),u.$set=k({},u.$set,{[Su({id:g,current_iteration:v},e===Ht.SENT?"responded":"dismissed")]:!0})}else e===Ht.SHOWN&&(u.$set=k({},u.$set,{[mn.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var y=k({},u.properties.$set,u.$set);if(pt(y)||this.setPersonPropertiesForFlags(y),!T(this.config.before_send)){var x=this.cs(u);if(!x)return;u=x}this.qr.emit("eventCaptured",u);var P={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(P):this.Zr.enqueue(P),u}b.critical("This capture call is ignored due to client rate limiting.")}}else b.error("No event name provided to posthog.capture")}else b.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=k({},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=k({},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))&&b.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=du(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=d}this.sessionPropsManager&&j(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&j(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.es)==null?void 0:h.length}catch(x){a.$sdk_debug_error_capturing_properties=String(x)}if(this.requestRouter.region===Vt.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=j(a,c),e==="$pageview"&&m&&(a.title=m.title),!_(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}J&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=j({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),F(this.config.property_denylist)?$(this.config.property_denylist,function(x){delete a[x]}):b.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&&(b.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=j({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(b.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),pt(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=k({},i,e),a=k({},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:_(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=Cu),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 b.uninitializedWarning("posthog.identify");if(Me(e)&&(e=e.toString(),b.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()))b.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(Lt)&&(this.unregister(Lt),this.register({distinct_id:e}));var o=(this.persistence.get_property(Ee)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(Ee,"identified"),this.setPersonPropertiesForFlags(k({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=Ys(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(kr))}}else b.critical('The string "'+Mt+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else b.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=Ys(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(k({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):b.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:k({},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 b.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(b.info("reset"),!this.__loaded)return b.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(Ee,"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(qe());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(Oo)?(b.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(_(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Lt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(b.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=k({},this.config);if(z(e)){var r,i,s,o,a,l,c;j(this.config,oo(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(k({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);Ce(p)&&(this.config.debug=p),Ce(this.config.debug)&&(this.config.debug?(xe.DEBUG=!0,N.H()&&N.G("ph_debug","true"),b.info("set_config",{config:e,oldConfig:t,newConfig:k({},this.config)})):(xe.DEBUG=!1,N.H()&&N.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(k({},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:ut;return t!==ut&&(t=ut+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Ee))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(Ee))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&pt(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Lt])&&((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({},{})}ps(e){return this.config.person_profiles==="never"?(b.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 Dr(this),this.pageViewManager=new Rr(this),this.persistence&&(this.sessionPropsManager=new $r(this,this.sessionManager,this.persistence)),this.sessionRecording=new Nr(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(),(_(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 b.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())):b.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 re?ha(re,this.config.custom_blocked_useragents):void 0}hs(){m&&(m.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:m.title},{send_instantly:!0}),this.Gr&&(m.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),U(m,"visibilitychange",this.Gr)))}debug(e){e===!1?(f?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(f?.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}))}O(){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?(b.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=b,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=F(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 ul(e.event)?b.warn(s+". This can cause unexpected behavior."):b.info(s),null}r.properties&&!pt(r.properties)||b.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=Ce(e)&&!e,r=N.H()&&N.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=$l(n.prototype[e[t]])})(qr,["identify"]);var ao;var Ur=(ao=Wt[ut]=new qr,function(){function n(){n.done||(n.done=!0,fa=!1,$(Wt,function(e){e._dom_loaded()}))}m!=null&&m.addEventListener?m.readyState==="complete"?n():U(m,"DOMContentLoaded",n,{capture:!1}):f&&b.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),ao);var $u="phc_u9YDYUeUxo3CYn16XGrrwpVb8ycXgcjz5DarvIKRAAG",ir=class n{constructor(e){A(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($u,{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(){A(this,"adapters",[]);A(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 Ct,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())}},_e=new zi;var sr=class sr{constructor(e){A(this,"startTime");A(this,"checkoutSessionId");A(this,"inputReadyTracked",!1);this.startTime=performance.now(),this.checkoutSessionId=e}trackPageReady(){sr.pageReadyTracked||(sr.pageReadyTracked=!0,_e.capture("checkout_page_ready",{checkout_session_id:this.checkoutSessionId,elapsed_ms:this.getElapsedMs()}))}trackInputReady(){this.inputReadyTracked||(this.inputReadyTracked=!0,_e.capture("checkout_input_ready",{checkout_session_id:this.checkoutSessionId,elapsed_ms:this.getElapsedMs()}))}trackSubmit(){_e.capture("checkout_submit",{checkout_session_id:this.checkoutSessionId,elapsed_ms:this.getElapsedMs()})}trackSuccess(e){_e.capture("checkout_success",{checkout_session_id:this.checkoutSessionId,checkout_attempt_id:e,total_elapsed_ms:this.getElapsedMs()})}trackFail(e,t,r){_e.capture("checkout_fail",{checkout_session_id:this.checkoutSessionId,checkout_attempt_id:e,error_code:t,error_message:r,total_elapsed_ms:this.getElapsedMs()})}getElapsedMs(){return Math.round(performance.now()-this.startTime)}};A(sr,"pageReadyTracked",!1);var or=sr;var Du=class extends Error{constructor(e,t){super(t);A(this,"code");this.name="PenpalError",this.code=e}},se=Du,Nu=n=>({name:n.name,message:n.message,stack:n.stack,penpalCode:n instanceof se?n.code:void 0}),qu=({name:n,message:e,stack:t,penpalCode:r})=>{let i=r?new se(r,e):new Error(e);return i.name=n,i.stack=t,i},Lu=Symbol("Reply"),Ki,_a,Gu=(_a=class{constructor(n,e){A(this,"value");A(this,"transferables");B(this,Ki,Lu);this.value=n,this.transferables=e?.transferables}},Ki=new WeakMap,_a),ju=Gu,ie="penpal",Kr=n=>typeof n=="object"&&n!==null,wa=n=>typeof n=="function",Uu=n=>Kr(n)&&n.namespace===ie,zr=n=>n.type==="SYN",Wi=n=>n.type==="ACK1",Hi=n=>n.type==="ACK2",xa=n=>n.type==="CALL",Ea=n=>n.type==="REPLY",zu=n=>n.type==="DESTROY",Pa=(n,e=[])=>{let t=[];for(let r of Object.keys(n)){let i=n[r];wa(i)?t.push([...e,r]):Kr(i)&&t.push(...Pa(i,[...e,r]))}return t},Hu=(n,e)=>{let t=n.reduce((r,i)=>Kr(r)?r[i]:void 0,e);return wa(t)?t:void 0},He=n=>n.join("."),ga=(n,e,t)=>({namespace:ie,channel:n,type:"REPLY",callId:e,isError:!0,...t instanceof Error?{value:Nu(t),isSerializedErrorInstance:!0}:{value:t}}),Vu=(n,e,t,r)=>{let i=!1,s=async o=>{if(i||!xa(o))return;r?.(`Received ${He(o.methodPath)}() call`,o);let{methodPath:a,args:l,id:c}=o,u,p;try{let d=Hu(a,e);if(!d)throw new se("METHOD_NOT_FOUND",`Method \`${He(a)}\` is not found.`);let h=await d(...l);h instanceof ju&&(p=h.transferables,h=await h.value),u={namespace:ie,channel:t,type:"REPLY",callId:c,value:h}}catch(d){u=ga(t,c,d)}if(!i)try{r?.(`Sending ${He(a)}() reply`,u),n.sendMessage(u,p)}catch(d){throw d.name==="DataCloneError"&&(u=ga(t,c,d),r?.(`Sending ${He(a)}() reply`,u),n.sendMessage(u)),d}};return n.addMessageHandler(s),()=>{i=!0,n.removeMessageHandler(s)}},Ku=Vu,Sa=crypto.randomUUID?.bind(crypto)??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),Bu=Symbol("CallOptions"),Bi,ba,Wu=(ba=class{constructor(n){A(this,"transferables");A(this,"timeout");B(this,Bi,Bu);this.transferables=n?.transferables,this.timeout=n?.timeout}},Bi=new WeakMap,ba),Xu=Wu,Yu=new Set(["apply","call","bind"]),Ia=(n,e,t=[])=>new Proxy(t.length?()=>{}:Object.create(null),{get(r,i){if(i!=="then")return t.length&&Yu.has(i)?Reflect.get(r,i):Ia(n,e,[...t,i])},apply(r,i,s){return n(t,s)}}),va=n=>new se("CONNECTION_DESTROYED",`Method call ${He(n)}() failed due to destroyed connection`),Ju=(n,e,t)=>{let r=!1,i=new Map,s=l=>{if(!Ea(l))return;let{callId:c,value:u,isError:p,isSerializedErrorInstance:d}=l,h=i.get(c);h&&(i.delete(c),t?.(`Received ${He(h.methodPath)}() call`,l),p?h.reject(d?qu(u):u):h.resolve(u))};return n.addMessageHandler(s),{remoteProxy:Ia((l,c)=>{if(r)throw va(l);let u=Sa(),p=c[c.length-1],d=p instanceof Xu,{timeout:h,transferables:g}=d?p:{},v=d?c.slice(0,-1):c;return new Promise((y,x)=>{let P=h!==void 0?window.setTimeout(()=>{i.delete(u),x(new se("METHOD_CALL_TIMEOUT",`Method call ${He(l)}() timed out after ${h}ms`))},h):void 0;i.set(u,{methodPath:l,resolve:y,reject:x,timeoutId:P});try{let I={namespace:ie,channel:e,type:"CALL",id:u,methodPath:l,args:v};t?.(`Sending ${He(l)}() call`,I),n.sendMessage(I,g)}catch(I){x(new se("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(va(l));i.clear()}}},Zu=Ju,Qu=()=>{let n,e;return{promise:new Promise((r,i)=>{n=r,e=i}),resolve:n,reject:e}},ec=Qu,tc=class extends Error{constructor(n){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${n}`)}},Hr=tc,Vi="deprecated-penpal",rc=n=>Kr(n)&&"penpal"in n,nc=n=>n.split("."),ya=n=>n.join("."),Ca=n=>new Hr(`Unexpected message to translate: ${JSON.stringify(n)}`),ic=n=>{if(n.penpal==="syn")return{namespace:ie,channel:void 0,type:"SYN",participantId:Vi};if(n.penpal==="ack")return{namespace:ie,channel:void 0,type:"ACK2"};if(n.penpal==="call")return{namespace:ie,channel:void 0,type:"CALL",id:n.id,methodPath:nc(n.methodName),args:n.args};if(n.penpal==="reply")return n.resolution==="fulfilled"?{namespace:ie,channel:void 0,type:"REPLY",callId:n.id,value:n.returnValue}:{namespace:ie,channel:void 0,type:"REPLY",callId:n.id,isError:!0,...n.returnValueIsError?{value:n.returnValue,isSerializedErrorInstance:!0}:{value:n.returnValue}};throw Ca(n)},sc=n=>{if(Wi(n))return{penpal:"synAck",methodNames:n.methodPaths.map(ya)};if(xa(n))return{penpal:"call",id:n.id,methodName:ya(n.methodPath),args:n.args};if(Ea(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 Ca(n)},oc=({messenger:n,methods:e,timeout:t,channel:r,log:i})=>{let s=Sa(),o,a=[],l=!1,c=Pa(e),{promise:u,resolve:p,reject:d}=ec(),h=t!==void 0?setTimeout(()=>{d(new se("CONNECTION_TIMEOUT",`Connection timed out after ${t}ms`))},t):void 0,g=()=>{for(let E of a)E()},v=()=>{if(l)return;a.push(Ku(n,e,r,i));let{remoteProxy:E,destroy:q}=Zu(n,r,i);a.push(q),clearTimeout(h),l=!0,p({remoteProxy:E,destroy:g})},y=()=>{let E={namespace:ie,type:"SYN",channel:r,participantId:s};i?.("Sending handshake SYN",E);try{n.sendMessage(E)}catch(q){d(new se("TRANSMISSION_FAILED",q.message))}},x=E=>{if(i?.("Received handshake SYN",E),E.participantId===o&&o!==Vi||(o=E.participantId,y(),!(s>o||o===Vi)))return;let G={namespace:ie,channel:r,type:"ACK1",methodPaths:c};i?.("Sending handshake ACK1",G);try{n.sendMessage(G)}catch(M){d(new se("TRANSMISSION_FAILED",M.message));return}},P=E=>{i?.("Received handshake ACK1",E);let q={namespace:ie,channel:r,type:"ACK2"};i?.("Sending handshake ACK2",q);try{n.sendMessage(q)}catch(G){d(new se("TRANSMISSION_FAILED",G.message));return}v()},I=E=>{i?.("Received handshake ACK2",E),v()},w=E=>{zr(E)&&x(E),Wi(E)&&P(E),Hi(E)&&I(E)};return n.addMessageHandler(w),a.push(()=>n.removeMessageHandler(w)),y(),u},ac=oc,lc=n=>{let e=!1,t;return(...r)=>(e||(e=!0,t=n(...r)),t)},uc=lc,ma=new WeakSet,cc=({messenger:n,methods:e={},timeout:t,channel:r,log:i})=>{if(!n)throw new se("INVALID_ARGUMENT","messenger must be defined");if(ma.has(n))throw new se("INVALID_ARGUMENT","A messenger can only be used for a single connection");ma.add(n);let s=[n.destroy],o=uc(c=>{if(c){let u={namespace:ie,channel:r,type:"DESTROY"};try{n.sendMessage(u)}catch{}}for(let u of s)u();i?.("Connection destroyed")}),a=c=>Uu(c)&&c.channel===r;return{promise:(async()=>{try{n.initialize({log:i,validateReceivedMessage:a}),n.addMessageHandler(p=>{zu(p)&&o(!1)});let{remoteProxy:c,destroy:u}=await ac({messenger:n,methods:e,timeout:t,channel:r,log:i});return s.push(u),c}catch(c){throw o(!0),c}})(),destroy:()=>{o(!0)}}},Ma=cc,Ue,Je,bt,kt,Ze,ze,ne,Qe,Vr,wt,ar,lr,xt,ka,pc=(ka=class{constructor({remoteWindow:n,allowedOrigins:e}){B(this,Ue);B(this,Je);B(this,bt);B(this,kt);B(this,Ze);B(this,ze,new Set);B(this,ne);B(this,Qe,!1);A(this,"initialize",({log:n,validateReceivedMessage:e})=>{ve(this,bt,n),ve(this,kt,e),window.addEventListener("message",C(this,lr))});A(this,"sendMessage",(n,e)=>{if(zr(n)){let t=C(this,wt).call(this,n);C(this,Ue).postMessage(n,{targetOrigin:t,transfer:e});return}if(Wi(n)||C(this,Qe)){let t=C(this,Qe)?sc(n):n,r=C(this,wt).call(this,n);C(this,Ue).postMessage(t,{targetOrigin:r,transfer:e});return}if(Hi(n)){let{port1:t,port2:r}=new MessageChannel;ve(this,ne,t),t.addEventListener("message",C(this,xt)),t.start();let i=[r,...e||[]],s=C(this,wt).call(this,n);C(this,Ue).postMessage(n,{targetOrigin:s,transfer:i});return}if(C(this,ne)){C(this,ne).postMessage(n,{transfer:e});return}throw new Hr("Port is undefined")});A(this,"addMessageHandler",n=>{C(this,ze).add(n)});A(this,"removeMessageHandler",n=>{C(this,ze).delete(n)});A(this,"destroy",()=>{window.removeEventListener("message",C(this,lr)),C(this,ar).call(this),C(this,ze).clear()});B(this,Vr,n=>C(this,Je).some(e=>e instanceof RegExp?e.test(n):e===n||e==="*"));B(this,wt,n=>{if(zr(n))return"*";if(!C(this,Ze))throw new Hr("Concrete remote origin not set");return C(this,Ze)==="null"&&C(this,Je).includes("*")?"*":C(this,Ze)});B(this,ar,()=>{C(this,ne)?.removeEventListener("message",C(this,xt)),C(this,ne)?.close(),ve(this,ne,void 0)});B(this,lr,({source:n,origin:e,ports:t,data:r})=>{var i,s,o;if(n===C(this,Ue)&&(rc(r)&&((i=C(this,bt))==null||i.call(this,"Please upgrade the child window to the latest version of Penpal."),ve(this,Qe,!0),r=ic(r)),!!((s=C(this,kt))!=null&&s.call(this,r)))){if(!C(this,Vr).call(this,e)){(o=C(this,bt))==null||o.call(this,`Received a message from origin \`${e}\` which did not match allowed origins \`[${C(this,Je).join(", ")}]\``);return}if(zr(r)&&(C(this,ar).call(this),ve(this,Ze,e)),Hi(r)&&!C(this,Qe)){if(ve(this,ne,t[0]),!C(this,ne))throw new Hr("No port received on ACK2");C(this,ne).addEventListener("message",C(this,xt)),C(this,ne).start()}for(let a of C(this,ze))a(r)}});B(this,xt,({data:n})=>{var e;if((e=C(this,kt))!=null&&e.call(this,n))for(let t of C(this,ze))t(n)});if(!n)throw new se("INVALID_ARGUMENT","remoteWindow must be defined");ve(this,Ue,n),ve(this,Je,e?.length?e:[window.origin])}},Ue=new WeakMap,Je=new WeakMap,bt=new WeakMap,kt=new WeakMap,Ze=new WeakMap,ze=new WeakMap,ne=new WeakMap,Qe=new WeakMap,Vr=new WeakMap,wt=new WeakMap,ar=new WeakMap,lr=new WeakMap,xt=new WeakMap,ka),Ra=pc;var Br=({window:n,methods:e})=>{let t=new Ra({remoteWindow:n,allowedOrigins:["*"]});return Ma({methods:e,messenger:t})};var Aa=(n,e)=>Br({window:n.contentWindow,methods:e});var Xr=class Xr{constructor(e,t){A(this,"penpalConn");A(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()}};A(Xr,"createFromPenpalConnection",async e=>{let t=await e.promise;return new Xr(e,t)});var Wr=Xr;var dc={local:{baseUrl:"http://localhost:9101",apiBaseUrl:"http://localhost:9000"},loclx:{baseUrl:"https://pkmateuscportal.loclx.io",apiBaseUrl:"https://pkmateusapi.loclx.io"},sandbox:{baseUrl:"https://staging.paymentkit.com/customer",apiBaseUrl:"https://staging.paymentkit.com"},production:{baseUrl:"https://paymentkit.com/customer",apiBaseUrl:"https://paymentkit.com"}};function Ta(n){let t=dc[n];if(!t)throw new Error(`Invalid environment: ${n}. Must be one of: local, loclx, sandbox, production`);return t}var Fa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Oa=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n|=0));for(;n--;)e+=Fa[t[n]&63];return e};var hc={local:"dev",loclx:"dev",sandbox:"stg",production:"prod"};function et(n){let e=hc[n]||"dev",t=Oa(12);return`pk_${e}_${t}`}function Xi(n){return{headers:{"x-request-id":n}}}var Yi;function $a(n){return{lang:n?.lang??Yi?.lang,message:n?.message,abortEarly:n?.abortEarly??Yi?.abortEarly,abortPipeEarly:n?.abortPipeEarly??Yi?.abortPipeEarly}}var fc;function gc(n){return fc?.get(n)}var vc;function yc(n){return vc?.get(n)}var mc;function _c(n,e){return mc?.get(n)?.get(e)}function bc(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??bc(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??_c(n.reference,l.lang)??(c?yc(l.lang):null)??r.message??gc(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 Ji(n){return{version:1,vendor:"valibot",validate(e){return n["~run"]({value:e},$a())}}}function Da(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 kc=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;function Zi(n){return{kind:"validation",type:"email",reference:Zi,expects:null,async:!1,requirement:kc,message:n,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&tt(this,"email",e,t),e}}}function Qi(n,e){return{kind:"validation",type:"max_length",reference:Qi,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 es(n,e){return{kind:"validation",type:"min_length",reference:es,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 Et(n){return{kind:"validation",type:"non_empty",reference:Et,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 wc(n,e,t){return typeof n.fallback=="function"?n.fallback(e,t):n.fallback}function xc(n,e,t){return typeof n.default=="function"?n.default(e,t):n.default}function ts(n,e){return{kind:"schema",type:"object",reference:ts,expects:"Object",async:!1,entries:n,message:e,get"~standard"(){return Ji(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]:xc(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]=wc(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 Ji(this)},"~run"(e,t){return typeof e.value=="string"?e.typed=!0:tt(this,"type",e,t),e}}}function Pt(...n){return{...n[0],pipe:n,get"~standard"(){return Ji(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 Na(n,e,t){let r=n["~run"]({value:e},$a(t));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var rs=async(n,e={})=>{let t=ts({customer_name:Pt(rt("required"),Et("required"),es(4,"invalid"),Qi(40,"invalid")),customer_email:Pt(rt("required"),Et("required"),Zi("invalid")),customer_country:Pt(rt("required"),Et("required")),customer_zip_code:e.optionalZipCode?Pt(rt("required")):Pt(rt("required"),Et("required"))}),r=Na(t,n);return r.issues?{isSuccess:!1,errors:r.issues.reduce((s,o)=>{let a=Da(o);return s[a]=o.kind==="schema"?"required":o.message,s},{})}:{isSuccess:!0}};var qa=n=>{let e=document.querySelector(n);if(!e)throw new Error(`Cannot find element with selector: ${n}`);return e},St=n=>n,Yr=(n,e,t)=>{let r=document.createElement("iframe"),s=new URLSearchParams(t).toString();return r.src=`${e}/embeds/v1/${n}${s?`?${s}`:""}`,Object.assign(r.style,{width:"100%",height:"100%",border:"none"}),r};function It(){return{ipAddress:void 0,browserInfo:{userAgent:navigator.userAgent,language:navigator.language,screenHeight:window.screen.height,screenWidth:window.screen.width,colorDepth:window.screen.colorDepth,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone},processorFraudInfo:void 0}}var Pc=(n,e,t)=>{let r=Yr("tunnel-x",n,{checkout_token:t,api_base_url:e});document.body.appendChild(r);let i=Aa(r,{});return{unmount:()=>{i.destroy(),document.body.removeChild(r)},connection:i}},Sc=({environment:n,secureToken:e,paymentMethods:t,__enableAnalyticsTestMode:r})=>{let{baseUrl:i,apiBaseUrl:s}=Ta(n);console.log(`[PaymentKit] v${ds} initialized (env: ${n})`),_e.init(s,r),_e.identify(e);let o=new or(e);o.trackPageReady();let{connection:a,unmount:l}=Pc(i,s,e),c={baseUrl:i,apiBaseUrl:s,secureToken:e,environment:n,tunnelXConnection:a,timingTracker:o},u=t.map(g=>g(c)),p=u.reduce((g,{name:v,externalFuncs:y})=>(g[v]=y,g),{});return{submit:({paymentMethod:g,fields:v,options:y,onSuccess:x,onError:P})=>{let I=u.find(({name:w})=>w===g);if(!I){P({root:"payment_method_not_found"});return}I.internalFuncs.submitPayment(v,y).then(({data:w,errors:E})=>{E?P(E):x(w)}).catch(w=>{console.error("PaymentKit:submit:catch",w),w?.response?.data?P(w.response.data):w?.message?P({root:w.message}):P({root:"unknown_error"})})},cleanup:()=>{for(let g of u)g.internalFuncs.cleanup&&g.internalFuncs.cleanup();l()},...p}},La=Sc;var Ga=(n,e)=>Br({window:n.contentWindow,methods:e});function ns(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
+ position: fixed;
13
+ top: 0;
14
+ left: 0;
15
+ width: 100%;
16
+ height: 100%;
17
+ background: rgba(0, 0, 0, 0);
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ z-index: 10000;
22
+ transition: background 0.25s cubic-bezier(0.4, 0, 0.2, 1);
23
+ `;let l=document.createElement("div");l.style.cssText=`
24
+ position: relative;
25
+ width: ${t.width}px;
26
+ height: ${t.height}px;
27
+ max-width: calc(100vw - 32px);
28
+ max-height: calc(100vh - 64px);
29
+ overflow: visible;
30
+ opacity: 0;
31
+ transform: scale(0.95) translateY(10px);
32
+ transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
33
+ `;let c=document.createElement("button");c.id="pk-iframe-modal-close",c.setAttribute("aria-label","Cancel verification"),c.setAttribute("type","button"),c.style.cssText=`
34
+ position: absolute;
35
+ top: -40px;
36
+ right: 0;
37
+ width: 32px;
38
+ height: 32px;
39
+ border: none;
40
+ background: white;
41
+ border-radius: 8px;
42
+ cursor: pointer;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ z-index: 10;
47
+ transition: background 0.15s ease;
48
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
49
+ `,c.innerHTML=`
50
+ <svg width="12" height="12" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
51
+ <path d="M1 1L13 13M1 13L13 1" stroke="#666" stroke-width="2" stroke-linecap="round"/>
52
+ </svg>
53
+ `,c.onmouseenter=()=>{c.style.background="#f5f5f5"},c.onmouseleave=()=>{c.style.background="white"};let u=document.createElement("iframe");u.src=e,u.setAttribute("title","3D Secure Verification"),u.style.cssText=`
54
+ width: 100%;
55
+ height: 100%;
56
+ border: none;
57
+ opacity: 0;
58
+ border-radius: ${r}px;
59
+ background: white;
60
+ transition: opacity 0.2s ease;
61
+ position: relative;
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",g),window.removeEventListener("keydown",h),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)}))},d=()=>{o||(console.log("[IframeModal] User cancelled"),p(),s({success:!1,error:"Verification cancelled"}))};c.onclick=d;let h=v=>{v.key==="Escape"&&d(),v.key==="Tab"&&(v.preventDefault(),document.activeElement===c?u.focus():c.focus())};window.addEventListener("keydown",h),c.focus();let g=v=>{let y=i(v);y.handled&&(p(),s(y.result))};window.addEventListener("message",g)})}var Ic=n=>new Promise(e=>setTimeout(e,n)),ja=()=>"Stripe"in window,Cc=async n=>{for(let t=0;t<10&&!ja();t++)await Ic(500);if(!ja())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)},Mc=async n=>{let{clientSecret:e,stripePk:t}=n,r=await Cc(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}},Rc=async n=>ns({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"}})}}),Jr=async n=>{switch(n.type){case"stripe_3ds":return Mc(n);case"airwallex_3ds":return Rc(n);default:return{success:!1,error:`Unknown next action type: ${n.type}`}}};var Ac=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}},Tc=n=>{let{firstName:e,lastName:t}=Ac(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}},Fc=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:d=>{let h=qa(d),g={checkout_token:i,api_base_url:t};l&&(g.style=JSON.stringify(l));let v=Yr(o.replace("_","-"),e,g);return h.appendChild(v),v.onload=()=>{o==="card_pan"&&s.trackInputReady();let x=Ga(v,{onLoaded:c||(()=>{}),onFocusChange:u||(()=>{})});n.cardInputConnections[o]=x},{unmount:()=>{r[o]?.destroy(),h.removeChild(v),n.cardInputConnections[o]=void 0}}}}}},Oc=n=>async t=>{let{timingTracker:r,environment:i}=n;r.trackSubmit();let s=et(i),o=Xi(s);console.log(`[Card] Generated checkout_request_id: ${s}`);let a=await Wr.createFromPenpalConnection(n.tunnelXConnection),l=await Dc(n),c=await rs(t);if(!(l.isSuccess&&c.isSuccess))return r.trackFail(null,"validation_error","Form validation failed"),{errors:{...l.errors,...c.errors}};if(!n.cardSetupIntentId){let v=await a.publicEndpoints.createCardSetupIntent({checkoutToken:n.secureToken});n.cardSetupIntentId=v.cardSetupIntentId}let u=await $c(n);if(!u.isSuccess)return r.trackFail(null,"card_submit_error","Card submission failed"),{errors:u.errors};let p=await a.publicEndpoints.getCardSetupIntent({cardSetupIntentId:n.cardSetupIntentId,checkoutToken:n.secureToken});if(!p.isCardAllSet){let v={};return p.isCardPanSet||(v.card_pan="required"),p.isCardExpSet||(v.card_exp="required"),p.isCardCvcSet||(v.card_cvc="required"),r.trackFail(null,"card_setup_incomplete","Card details incomplete"),{errors:v}}console.log("Card setup intent is set \u2705",p),console.log("Fields",t);let d=await a.publicEndpoints.cardCheckout({checkoutToken:n.secureToken,publicCardCheckoutRequest:{cardSetupIntentId:n.cardSetupIntentId,customerInfo:Tc(t),fraudMetadata:It()}},o);console.log("Card checkout result:",d);let h=5,g=0;for(;d.nextAction&&g<h;){g++,console.log(`Handling user action ${g}/${h}...`);let v=await Jr(d.nextAction);console.log("User action completed, verifying checkout...");let y=await a.publicEndpoints.cardCheckoutVerify({checkoutToken:n.secureToken},o);if(y.nextAction){v.success?console.log("Another user action required, continuing loop..."):console.log("3DS failed but cascade triggered new action, continuing loop..."),d=y;continue}return v.success?(console.log("Card checkout verified \u2705",y),r.trackSuccess(y.checkoutAttemptId||"unknown"),{data:y}):(console.log("3DS authentication failed, checkout concluded:",y),r.trackFail(y.checkoutAttemptId||null,y.errorCode||"3ds_failed",y.errorMessageForCustomer||v.error),{errors:{root:y.errorMessageForCustomer||v.error,checkout_response:y}})}return g>=h?(console.error("Max user actions exceeded"),r.trackFail(null,"max_actions_exceeded","Too many authentication attempts"),{errors:{root:"Too many authentication attempts. Please try again."}}):d.state==="payment_failed"||d.state==="checkout_failed"?(console.log("Card checkout failed:",d),r.trackFail(d.checkoutAttemptId||null,d.errorCode||"payment_failed",d.errorMessageForCustomer||"Payment failed"),{errors:{root:d.errorMessageForCustomer||"Payment failed",checkout_response:d}}):(console.log("Card checkout completed \u2705",d),r.trackSuccess(d.checkoutAttemptId||"unknown"),{data:d})},$c=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}},Dc=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}},Nc=St(n=>{let e={...n,cardInputConnections:{}};return{name:"card",externalFuncs:{createElement:Fc(e)},internalFuncs:{submitPayment:Oc(e),cleanup:()=>{for(let t of Object.values(e.cardInputConnections))t?.destroy();e.cardInputConnections={}}}}}),Ua=Nc;var Zr=class{constructor(e){A(this,"client",null);A(this,"config",null);A(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 Qr=class{constructor(e){A(this,"stripe",null);A(this,"paymentRequest",null);A(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 ss(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 qc(n){return n?.processorId?!n?.customerInfo?.first_name||!n?.customerInfo?.last_name?{customer_name:"Customer first and last name are required"}:null:{processor_id:"Processor ID is required"}}function Lc(n){return n&&n!=="none"?n:void 0}async function Gc(n,e,t,r,i){return ss(`${n}/api/checkout/${e}/google-pay/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({processor_id:t.processorId,customer_info:t.customerInfo,fraud_metadata:It(),mock_scenario:r})},i)}function jc(n,e,t){let r=new Qr(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 Uc(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 zc(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 Zr(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 Hc(n,e){let{adapter:t,error:r}=zc(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 Ha(n,e,t,r,i){let s={mock_scenario:r};t&&(s.google_pay_token=t);let o=await ss(`${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 Vc(n,e,t){let r=await ss(`${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 is(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 Kc(n,e,t,r){let i=await Ha(n,e,void 0,t,r);return is(i,e)}var za=5;async function Bc(n,e,t,r,i){let s=0,o=await Ha(n,e,t,r,i);for(;o.charge_status==="pending"&&o.next_action&&s<za;){s++;let a=await Jr(o.next_action),l=await Vc(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?is(l,e):{errors:{google_pay:l.error_message||a.error||"3DS authentication failed"}}}return s>=za?{errors:{google_pay:"Too many authentication attempts. Please try again."}}:is(o,e)}var Wc=n=>async(t,r)=>{let{apiBaseUrl:i,secureToken:s,environment:o}=n,a=r,l=qc(a);if(l)return{errors:l};try{let c=Lc(a.mockScenario),u=et(o);console.log(`[GooglePay] Generated checkout_request_id: ${u}`);let p=await Gc(i,s,a,c,u);if(p.error||!p.data)return{errors:{google_pay:p.error||"Failed to start Google Pay"}};let d=p.data;if(d.processor==="stripe"){let h=await Uc(d,a.mockScenario);return h.success?await Kc(i,s,c,u):{errors:{google_pay:h.error}}}if(d.processor==="airwallex"){let h=await Hc(d,a.mockScenario);return h.success?h.token?await Bc(i,s,h.token,c,u):{errors:{google_pay:"Google Pay token not received"}}:{errors:{google_pay:h.error}}}return{errors:{google_pay:`Unsupported processor: ${d.processor}`}}}catch(c){return{errors:{google_pay:`Google Pay error: ${c}`}}}},Xc=St(n=>({name:"google_pay",externalFuncs:{},internalFuncs:{submitPayment:Wc(n),cleanup:()=>{}}}));var Va=Xc;var Yc=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] Generated checkout_request_id: ${l}`);let c=await fetch(`${i}/api/checkout/${s}/paypal/start`,{method:"POST",headers:{"Content-Type":"application/json","x-request-id":l},body:JSON.stringify({processor_id:a.processorId,customer_info:a.customerInfo,fraud_metadata:It()})});if(!c.ok){let g=`Failed to start PayPal checkout (${c.status})`;try{g=(await c.json()).detail||g}catch{g=c.statusText||g}return{errors:{paypal:g}}}let{approval_url:u,popup_token:p,checkout_attempt_id:d}=await c.json(),h=window.open(u,"PayPal","width=600,height=700");return h?(n.popup=h,new Promise(g=>{let v=setInterval(async()=>{try{let y=await fetch(`${i}/api/checkout/${s}/popup/status?popup_token=${p}`);if(!y.ok){clearInterval(v),h.close(),g({errors:{paypal:"Failed to check PayPal status"}});return}let x=await y.json();if(x.completed){if(clearInterval(v),h.close(),x.status==="success"){let P=x.result||{id:d,checkoutAttemptId:d,checkoutSessionId:s,state:"checkout_succeeded"};g({data:P})}else g({errors:{paypal:x.error||`PayPal checkout ${x.status}`}});return}if(h.closed){clearInterval(v),g({errors:{paypal:"PayPal popup closed by user"}});return}}catch(y){clearInterval(v),h.close(),g({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}`}}}},Jc=St(n=>{let e={...n};return{name:"paypal",externalFuncs:{},internalFuncs:{submitPayment:Yc(e),cleanup:()=>{e.pollInterval&&clearInterval(e.pollInterval),e.popup&&!e.popup.closed&&e.popup.close()}}}}),Ka=Jc;var Zc=La,Qc={card:Ua,googlePay:Va,paypal:Ka};return nl(ep);})();
10
65
  //# sourceMappingURL=paymentkit.min.js.map